bibliothek.notes.view.actions.IconAction Maven / Gradle / Ivy
package bibliothek.notes.view.actions;
import javax.swing.Icon;
import bibliothek.gui.DockController;
import bibliothek.gui.DockTheme;
import bibliothek.gui.Dockable;
import bibliothek.gui.dock.action.ActionType;
import bibliothek.gui.dock.action.actions.SimpleDockAction;
import bibliothek.gui.dock.action.view.ActionViewConverter;
import bibliothek.gui.dock.action.view.ViewGenerator;
import bibliothek.gui.dock.action.view.ViewTarget;
import bibliothek.notes.model.Note;
import bibliothek.notes.util.ResourceSet;
import bibliothek.notes.view.actions.icon.IconButtonHandler;
import bibliothek.notes.view.actions.icon.IconGrid;
/**
* A new kind of action, used to select one icon out of a whole set of icons.
* This action has its own graphical representation, normally a button
* and a popup-panel with the icons.
* The action of opening the popup-panel is implemented by the {@link IconButtonHandler}.
* The popup-panel containing the icons is implemented as the {@link IconGrid}.
* All the {@link DockTheme}s used by this application will register a
* {@link ViewGenerator} under the new {@link ActionType} {@link #ICON} at
* the {@link ActionViewConverter} of the
* {@link DockController#getActionViewConverter() controller}.
* @author Benjamin Sigg
*/
public class IconAction extends SimpleDockAction {
/** The type of action that an {@link IconAction} is */
public static final ActionType ICON = new ActionType( "icon" );
/** The Note
whose icon might be changed by this action */
private Note note;
/**
* Creates a new action.
* @param note the Note
whose {@link Icon} might be changed.
*/
public IconAction( Note note ){
this.note = note;
setIcon( ResourceSet.APPLICATION_ICONS.get( "icon" ) );
}
/**
* Gets the owner of this action.
* @return the owner
*/
public Note getNote(){
return note;
}
public V createView( ViewTarget target, ActionViewConverter converter, Dockable dockable ){
return converter.createView( ICON, this, target, dockable );
}
public boolean trigger( Dockable dockable ) {
return false;
}
}