use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class IconSelectionPlugin method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController modeController = Controller.getCurrentModeController();
ArrayList<IIconInformation> actions = new ArrayList<IIconInformation>();
final Controller controller = Controller.getCurrentController();
final MapModel map = controller.getMap();
final IconRegistry iconRegistry = map.getIconRegistry();
final ListModel usedIcons = iconRegistry.getIconsAsListModel();
for (int i = 0; i < usedIcons.getSize(); i++) {
final Object icon = usedIcons.getElementAt(i);
if (icon instanceof MindIcon) {
actions.add(new IconAction((MindIcon) icon));
}
}
final MIconController mIconController = (MIconController) IconController.getController();
for (AFreeplaneAction aFreeplaneAction : mIconController.getIconActions()) actions.add((IIconInformation) aFreeplaneAction);
actions.add((IIconInformation) modeController.getAction("RemoveIcon_0_Action"));
actions.add((IIconInformation) modeController.getAction("RemoveIconAction"));
actions.add((IIconInformation) modeController.getAction("RemoveAllIconsAction"));
final ViewController viewController = controller.getViewController();
final IconSelectionPopupDialog selectionDialog = new IconSelectionPopupDialog(viewController.getJFrame(), actions);
final NodeModel selected = controller.getSelection().getSelected();
controller.getMapViewManager().scrollNodeToVisible(selected);
selectionDialog.pack();
UITools.setDialogLocationRelativeTo(selectionDialog, selected);
selectionDialog.setModal(true);
selectionDialog.show();
final int result = selectionDialog.getResult();
if (result >= 0) {
final Action action = (Action) actions.get(result);
action.actionPerformed(new ActionEvent(action, 0, NodeModel.NODE_ICON, selectionDialog.getModifiers()));
}
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class ZoomContributorFactory method getContributor.
public ARibbonContributor getContributor(final Properties attributes) {
return new ARibbonContributor() {
public String getKey() {
return attributes.getProperty("name");
}
public void contribute(final RibbonBuildContext context, ARibbonContributor parent) {
if (parent == null) {
return;
}
JFlowRibbonBand band = new JFlowRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band.zoom")), null, null);
JComboBox zoomBox = ((MapViewController) Controller.getCurrentController().getMapViewManager()).createZoomBox();
addDefaultToggleHandler(context, zoomBox);
band.addFlowComponent(zoomBox);
JCommandButtonStrip strip = new JCommandButtonStrip();
AFreeplaneAction action = context.getBuilder().getMode().getAction("ZoomInAction");
JCommandButton button = RibbonActionContributorFactory.createCommandButton(action);
button.setDisplayState(CommandButtonDisplayState.SMALL);
getAccelChangeListener().addAction(action.getKey(), button);
addDefaultToggleHandler(context, action, button);
strip.add(button);
action = context.getBuilder().getMode().getAction("ZoomOutAction");
button = RibbonActionContributorFactory.createCommandButton(action);
button.setDisplayState(CommandButtonDisplayState.SMALL);
getAccelChangeListener().addAction(action.getKey(), button);
addDefaultToggleHandler(context, action, button);
strip.add(button);
action = context.getBuilder().getMode().getAction("FitToPage");
button = RibbonActionContributorFactory.createCommandButton(action);
button.setDisplayState(CommandButtonDisplayState.MEDIUM);
getAccelChangeListener().addAction(action.getKey(), button);
addDefaultToggleHandler(context, action, button);
strip.add(button);
band.addFlowComponent(strip);
List<RibbonBandResizePolicy> policies = new ArrayList<RibbonBandResizePolicy>();
policies.add(new CoreRibbonResizePolicies.FlowTwoRows(band.getControlPanel()));
policies.add(new IconRibbonBandResizePolicy(band.getControlPanel()));
band.setResizePolicies(policies);
parent.addChild(band, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
}
public void addChild(Object child, ChildProperties properties) {
}
};
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class RibbonMenuPrimaryContributorFactory method getContributor.
/**
*********************************************************************************
* REQUIRED METHODS FOR INTERFACES
*********************************************************************************
*/
public ARibbonContributor getContributor(final Properties attributes) {
String accel = attributes.getProperty("accelerator", null);
final String actionKey = attributes.getProperty("action");
if (actionKey != null) {
if (accel != null) {
if (Compat.isMacOsX()) {
accel = accel.replaceFirst("CONTROL", "META").replaceFirst("control", "meta");
}
builder.getAcceleratorManager().setDefaultAccelerator(actionKey, accel);
}
}
return new ARibbonContributor() {
RibbonApplicationMenuEntryPrimary entry;
public String getKey() {
String key = attributes.getProperty("action", null);
if (key == null) {
key = attributes.getProperty("name", null);
}
return key;
}
public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
entry = null;
if (context.hasChildren(context.getCurrentPath())) {
if (attributes.get("action") == null) {
AFreeplaneAction action = ActionUtils.getDummyAction(getKey());
entry = createMenuEntry(action, CommandButtonKind.POPUP_ONLY);
} else {
AFreeplaneAction action = context.getBuilder().getMode().getAction(getKey());
if (action == null) {
action = ActionUtils.getDummyAction(getKey());
}
entry = createMenuEntry(action, CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION);
}
context.processChildren(context.getCurrentPath(), this);
} else {
if (attributes.get("action") == null) {
return;
}
AFreeplaneAction action = context.getBuilder().getMode().getAction(getKey());
if (action == null) {
return;
}
entry = createMenuEntry(action, CommandButtonKind.ACTION_ONLY);
}
KeyStroke ks = context.getBuilder().getAcceleratorManager().getAccelerator(getKey());
if (ks != null) {
AFreeplaneAction action = context.getBuilder().getMode().getAction(getKey());
if (action != null) {
RichTooltip tip = RibbonActionContributorFactory.getRichTooltip(action, ks);
if (tip != null) {
entry.setActionRichTooltip(tip);
}
}
}
parent.addChild(entry, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
}
public void addChild(Object child, ChildProperties properties) {
if (child instanceof SecondaryEntryGroup) {
SecondaryEntryGroup group = (SecondaryEntryGroup) child;
entry.addSecondaryMenuGroup(group.getTitle(), group.getEntries().toArray(new RibbonApplicationMenuEntrySecondary[0]));
}
}
};
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class EdgeStyleContributorFactory method getContributor.
public ARibbonContributor getContributor(final Properties attributes) {
return new ARibbonContributor() {
public String getKey() {
return attributes.getProperty("name");
}
public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
if (parent == null) {
return;
}
JRibbonBand band = new JRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band.edgeStyles")), null, null);
band.setExpandButtonKeyTip("ES");
band.setCollapsedStateKeyTip("ZE");
JCommandButton styleGroupButton = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("edgeStyleGroupAction.text")));
styleGroupButton.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
AFreeplaneAction action = context.getBuilder().getMode().getAction("EdgeStyleAsParentAction");
final JCommandToggleMenuButton styleAsParent = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, styleAsParent);
action = context.getBuilder().getMode().getAction("EdgeStyleAction.linear");
final JCommandToggleMenuButton styleLinear = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, styleLinear);
action = context.getBuilder().getMode().getAction("EdgeStyleAction.bezier");
final JCommandToggleMenuButton styleBezier = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, styleBezier);
action = context.getBuilder().getMode().getAction("EdgeStyleAction.sharp_linear");
final JCommandToggleMenuButton styleSharpLinear = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, styleSharpLinear);
action = context.getBuilder().getMode().getAction("EdgeStyleAction.sharp_bezier");
final JCommandToggleMenuButton styleSharpBezier = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, styleSharpBezier);
action = context.getBuilder().getMode().getAction("EdgeStyleAction.horizontal");
final JCommandToggleMenuButton styleHorizontal = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, styleHorizontal);
action = context.getBuilder().getMode().getAction("EdgeStyleAction.hide_edge");
final JCommandToggleMenuButton styleHideEdge = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, styleHideEdge);
ButtonGroup group = new ButtonGroup();
styleAsParent.getActionModel().setGroup(group);
styleLinear.getActionModel().setGroup(group);
styleAsParent.getActionModel().setGroup(group);
styleBezier.getActionModel().setGroup(group);
styleAsParent.getActionModel().setGroup(group);
styleSharpLinear.getActionModel().setGroup(group);
styleAsParent.getActionModel().setGroup(group);
styleSharpBezier.getActionModel().setGroup(group);
styleAsParent.getActionModel().setGroup(group);
styleHorizontal.getActionModel().setGroup(group);
styleAsParent.getActionModel().setGroup(group);
styleHideEdge.getActionModel().setGroup(group);
styleAsParent.getActionModel().setGroup(group);
styleGroupButton.setPopupCallback(new PopupPanelCallback() {
public JPopupPanel getPopupPanel(JCommandButton commandButton) {
JCommandPopupMenu popupmenu = new JCommandPopupMenu();
popupmenu.addMenuButton(styleAsParent);
popupmenu.addMenuButton(styleLinear);
popupmenu.addMenuButton(styleBezier);
popupmenu.addMenuButton(styleSharpLinear);
popupmenu.addMenuButton(styleSharpBezier);
popupmenu.addMenuButton(styleHorizontal);
popupmenu.addMenuButton(styleHideEdge);
return popupmenu;
}
});
band.addCommandButton(styleGroupButton, RibbonElementPriority.MEDIUM);
JCommandButton lineWidthGroupButton = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("edgeLineWidthGroupAction.text")));
lineWidthGroupButton.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
action = context.getBuilder().getMode().getAction("EdgeWidthAction_width_parent");
final JCommandToggleMenuButton widthParent = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, widthParent);
action = context.getBuilder().getMode().getAction("EdgeWidthAction_width_thin");
final JCommandToggleMenuButton widthThin = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, widthThin);
action = context.getBuilder().getMode().getAction("EdgeWidthAction_1");
final JCommandToggleMenuButton width1 = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, width1);
action = context.getBuilder().getMode().getAction("EdgeWidthAction_2");
final JCommandToggleMenuButton width2 = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, width2);
action = context.getBuilder().getMode().getAction("EdgeWidthAction_4");
final JCommandToggleMenuButton width4 = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, width4);
action = context.getBuilder().getMode().getAction("EdgeWidthAction_8");
final JCommandToggleMenuButton width8 = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
addDefaultToggleHandler(context, action, width8);
lineWidthGroupButton.setPopupCallback(new PopupPanelCallback() {
public JPopupPanel getPopupPanel(JCommandButton commandButton) {
JCommandPopupMenu popupmenu = new JCommandPopupMenu();
popupmenu.addMenuButton(widthParent);
popupmenu.addMenuButton(widthThin);
popupmenu.addMenuButton(width1);
popupmenu.addMenuButton(width2);
popupmenu.addMenuButton(width4);
popupmenu.addMenuButton(width8);
return popupmenu;
}
});
band.addCommandButton(lineWidthGroupButton, RibbonElementPriority.MEDIUM);
action = context.getBuilder().getMode().getAction("EdgeColorAction");
final JCommandButton edgeColorButton = RibbonActionContributorFactory.createCommandButton(action);
band.addCommandButton(edgeColorButton, RibbonElementPriority.MEDIUM);
action = context.getBuilder().getMode().getAction("AutomaticEdgeColorHookAction");
// RIBBONS
// KeyStroke ks =RibbonAcceleratorManager.parseKeyStroke("j2ef2");
// context.getBuilder().getAcceleratorManager().setAccelerator(action, ks);
// RibbonActionContributorFactory.updateRichTooltip(button, action, ks);
final JCommandButton automaticColorButton = RibbonActionContributorFactory.createCommandButton(action);
band.addCommandButton(automaticColorButton, RibbonElementPriority.MEDIUM);
List<RibbonBandResizePolicy> policies = new ArrayList<RibbonBandResizePolicy>();
policies.add(new CoreRibbonResizePolicies.Mirror(band.getControlPanel()));
policies.add(new CoreRibbonResizePolicies.High2Mid(band.getControlPanel()));
band.setResizePolicies(policies);
parent.addChild(band, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
}
public void addChild(Object child, ChildProperties properties) {
}
};
}
use of org.freeplane.core.ui.AFreeplaneAction in project freeplane by freeplane.
the class RibbonMenuFooterContributorFactory method getContributor.
/**
*********************************************************************************
* METHODS
*********************************************************************************
*/
/**
*********************************************************************************
* REQUIRED METHODS FOR INTERFACES
*********************************************************************************
*/
public ARibbonContributor getContributor(final Properties attributes) {
String accel = attributes.getProperty("accelerator", null);
final String actionKey = attributes.getProperty("action");
if (actionKey != null) {
if (accel != null) {
if (Compat.isMacOsX()) {
accel = accel.replaceFirst("CONTROL", "META").replaceFirst("control", "meta");
}
builder.getAcceleratorManager().setDefaultAccelerator(actionKey, accel);
}
}
return new ARibbonContributor() {
public String getKey() {
return attributes.getProperty("action");
}
public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
final String key = attributes.getProperty("action");
if (key != null) {
AFreeplaneAction action = context.getBuilder().getMode().getAction(key);
if (action != null) {
String title = ActionUtils.getActionTitle(action);
ResizableIcon icon = ActionUtils.getActionIcon(action);
ActionListener listener = new RibbonActionContributorFactory.RibbonActionListener(action);
final RibbonApplicationMenuEntryFooter entry = new RibbonApplicationMenuEntryFooter(icon, title, listener);
KeyStroke ks = context.getBuilder().getAcceleratorManager().getAccelerator(key);
if (ks != null) {
RichTooltip tip = RibbonActionContributorFactory.getRichTooltip(action, ks);
if (tip != null) {
entry.setActionRichTooltip(tip);
}
}
parent.addChild(entry, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
}
}
}
public void addChild(Object child, ChildProperties properties) {
}
};
}
Aggregations