wip: finished alias, alias ID and alias action editing framework.

This commit is contained in:
denny
2016-03-04 09:33:46 -05:00
parent 2c3dbe1b22
commit 00d2b43c2a
68 changed files with 1472 additions and 647 deletions

View File

@@ -0,0 +1,29 @@
package gui.editor;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public abstract class DocumentListenerEditor<T> extends Editor<T>
implements DocumentListener
{
private static final long serialVersionUID = 1L;
public DocumentListenerEditor()
{
}
@Override
public void insertUpdate( DocumentEvent e )
{
setModified( true );
}
@Override
public void removeUpdate( DocumentEvent e )
{
setModified( true );
}
@Override
public void changedUpdate( DocumentEvent e ) { }
}

View File

@@ -0,0 +1,94 @@
package gui.editor;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import alias.id.AliasIdentifierEditor;
/**
* Generic editor with change detection, save and reset functions.
*/
public abstract class Editor<T> extends JPanel
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger( Editor.class );
protected T mItem;
protected boolean mModified = false;
public Editor()
{
}
/**
* Sets the object to be edited
*/
public void setItem( T item )
{
if( isModified() )
{
int option = JOptionPane.showConfirmDialog(
Editor.this,
"This item has changed. Do you want to save these changes?",
"Save Changes?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE );
if( option == JOptionPane.YES_OPTION )
{
save();
}
setModified( false );
}
mItem = item;
}
/**
* Current editing item
*/
public T getItem()
{
return mItem;
}
public boolean hasItem()
{
return mItem != null;
}
/**
* Sets the contents modified flag
*/
public void setModified( boolean modified )
{
mModified = modified;
}
/**
* Indicates if this editor contents have been modified
*/
public boolean isModified()
{
return mModified;
}
/**
* Save the contents of the editor
*/
public abstract void save();
/**
* Reset the contents of the editor without saving any changes
*/
public void reset()
{
mModified = false;
setItem( mItem );
}
}

View File

@@ -0,0 +1,26 @@
package gui.editor;
import javax.swing.JLabel;
import net.miginfocom.swing.MigLayout;
public class EmptyEditor<T> extends Editor<T>
{
private static final long serialVersionUID = 1L;
public EmptyEditor()
{
setLayout( new MigLayout( "", "[center]", "[grow]" ) );
add( new JLabel( "Please select an item" ), "wrap" );
}
@Override
public void save()
{
}
@Override
public void reset()
{
}
}