use of org.freeplane.core.ui.ribbon.RibbonBuildContext 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.ribbon.RibbonBuildContext 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.ribbon.RibbonBuildContext in project freeplane by freeplane.
the class LastOpenedMapsRibbonContributorFactory method getContributor.
public ARibbonContributor getContributor(final Properties attributes) {
return new ARibbonContributor() {
@Override
public String getKey() {
return "lastOpenedMaps";
}
private final String menuName = TextUtils.getText(attributes.getProperty("name_ref"));
@Override
public void contribute(RibbonBuildContext context, ARibbonContributor parent) {
RibbonApplicationMenuEntryPrimary primeEntry = new RibbonApplicationMenuEntryPrimary(null, menuName, null, CommandButtonKind.POPUP_ONLY);
primeEntry.setRolloverCallback(getCallback(primeEntry));
parent.addChild(primeEntry, new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", ""))));
}
@Override
public void addChild(Object child, ChildProperties properties) {
}
private PrimaryRolloverCallback getCallback(final RibbonApplicationMenuEntryPrimary primeEntry) {
if (rolloverCallback == null) {
rolloverCallback = new PrimaryRolloverCallback() {
public void menuEntryActivated(JPanel targetPanel) {
targetPanel.removeAll();
targetPanel.setLayout(new BorderLayout());
JCommandButtonPanel secondary = new JRibbonApplicationMenuPopupPanelSecondary(primeEntry);
secondary.setToShowGroupLabels(false);
String groupDesc = menuName;
secondary.addButtonGroup(groupDesc);
List<AFreeplaneAction> openActions = lastOpenedList.createOpenLastMapActionList();
for (AFreeplaneAction action : openActions) {
String restoreable = (String) action.getValue(Action.DEFAULT);
StringTokenizer tokens = new StringTokenizer(restoreable, ";");
File file = lastOpenedList.createFileFromRestorable(tokens);
JCommandButton menuButton = new JCommandButton(file.getName());
menuButton.addActionListener(action);
menuButton.setCommandButtonKind(CommandButtonKind.ACTION_ONLY);
menuButton.setHorizontalAlignment(SwingUtilities.LEADING);
menuButton.setPopupOrientationKind(CommandButtonPopupOrientationKind.SIDEWARD);
menuButton.setEnabled(true);
menuButton.setActionRichTooltip(new RichTooltip((String) action.getValue(Action.SHORT_DESCRIPTION), file.toString()));
secondary.addButtonToLastGroup(menuButton);
}
JScrollablePanel<JCommandButtonPanel> scrollPanel = new JScrollablePanel<JCommandButtonPanel>(secondary, ScrollType.VERTICALLY);
targetPanel.add(scrollPanel, BorderLayout.CENTER);
}
};
}
return rolloverCallback;
}
};
}
use of org.freeplane.core.ui.ribbon.RibbonBuildContext in project freeplane by freeplane.
the class FontStyleContributorFactory 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) {
setAccelerator(context.getBuilder(), "control B", "BoldAction");
setAccelerator(context.getBuilder(), "control I", "ItalicAction");
setAccelerator(context.getBuilder(), "control PLUS", "IncreaseNodeFontAction");
setAccelerator(context.getBuilder(), "control MINUS", "DecreaseNodeFontAction");
setAccelerator(context.getBuilder(), "alt shift F", "NodeColorAction");
setAccelerator(context.getBuilder(), "alt shift P", "UsePlainTextAction");
if (parent == null) {
return;
}
// RIBBONS expandlistener and icon
JFlowRibbonBand band = new JFlowRibbonBand(TextUtils.removeTranslateComment(TextUtils.getText("ribbon.band.font")), null, null);
band.setExpandButtonKeyTip("FN");
band.setCollapsedStateKeyTip("ZF");
MUIFactory uiFactory = Controller.getCurrentModeController().getExtension(MUIFactory.class);
final Container fontBox = uiFactory.createFontBox();
JRibbonComponent fontComboWrapper = new JRibbonComponent((JComponent) fontBox);
fontComboWrapper.setKeyTip("SF");
addDefaultToggleHandler(context, fontComboWrapper);
band.addFlowComponent(fontComboWrapper);
final Container sizeBox = uiFactory.createSizeBox();
JRibbonComponent sizeComboWrapper = new JRibbonComponent((JComponent) sizeBox);
sizeComboWrapper.setKeyTip("SS");
addDefaultToggleHandler(context, sizeComboWrapper);
band.addFlowComponent(sizeComboWrapper);
final Container styleBox = uiFactory.createStyleBox();
JRibbonComponent styleComboWrapper = new JRibbonComponent((JComponent) styleBox);
styleComboWrapper.setKeyTip("SD");
addDefaultToggleHandler(context, styleComboWrapper);
band.addFlowComponent(styleComboWrapper);
JCommandButtonStrip styleStrip = new JCommandButtonStrip();
AFreeplaneAction action = context.getBuilder().getMode().getAction("BoldAction");
final JCommandToggleButton boldButton = RibbonActionContributorFactory.createCommandToggleButton(action);
addDefaultToggleHandler(context, action, boldButton);
styleStrip.add(boldButton);
action = context.getBuilder().getMode().getAction("ItalicAction");
final JCommandToggleButton italicButton = RibbonActionContributorFactory.createCommandToggleButton(action);
addDefaultToggleHandler(context, action, italicButton);
styleStrip.add(italicButton);
action = context.getBuilder().getMode().getAction("NodeColorAction");
JCommandButton button = RibbonActionContributorFactory.createCommandButton(action);
addDefaultToggleHandler(context, action, button);
styleStrip.add(button);
action = context.getBuilder().getMode().getAction("NodeBackgroundColorAction");
button = RibbonActionContributorFactory.createCommandButton(action);
addDefaultToggleHandler(context, action, button);
styleStrip.add(button);
action = context.getBuilder().getMode().getAction("NodeColorBlendAction");
button = RibbonActionContributorFactory.createCommandButton(action);
addDefaultToggleHandler(context, action, button);
styleStrip.add(button);
action = context.getBuilder().getMode().getAction("BlinkingNodeHookAction");
button = RibbonActionContributorFactory.createCommandButton(action);
addDefaultToggleHandler(context, action, button);
styleStrip.add(button);
action = context.getBuilder().getMode().getAction("MapBackgroundColorAction");
button = RibbonActionContributorFactory.createCommandButton(action);
addDefaultToggleHandler(context, action, button);
styleStrip.add(button);
band.addFlowComponent(styleStrip);
action = context.getBuilder().getMode().getAction("RemoveFormatAction");
button = RibbonActionContributorFactory.createCommandButton(action);
button.setDisplayState(CommandButtonDisplayState.MEDIUM);
addDefaultToggleHandler(context, action, button);
band.addFlowComponent(button);
action = context.getBuilder().getMode().getAction("UsePlainTextAction");
button = RibbonActionContributorFactory.createCommandButton(action);
button.setDisplayState(CommandButtonDisplayState.MEDIUM);
addDefaultToggleHandler(context, action, button);
band.addFlowComponent(button);
List<RibbonBandResizePolicy> policies = new ArrayList<RibbonBandResizePolicy>();
policies.add(new CoreRibbonResizePolicies.FlowThreeRows(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.ribbon.RibbonBuildContext in project freeplane by freeplane.
the class FilterConditionsContributorFactory 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;
}
JCommandButton button = new JCommandButton(TextUtils.removeTranslateComment(TextUtils.getText("FilterCondition")));
button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
button.setPopupCallback(new PopupPanelCallback() {
public JPopupPanel getPopupPanel(JCommandButton commandButton) {
JCommandPopupMenu popupmenu = new JCommandPopupMenu();
AFreeplaneAction action = context.getBuilder().getMode().getAction("ApplyToVisibleAction");
JCommandToggleMenuButton toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
action.setSelected();
toggleButton.getActionModel().setSelected(action.isSelected());
popupmenu.addMenuButton(toggleButton);
action = context.getBuilder().getMode().getAction("ShowAncestorsAction");
toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
action.setSelected();
toggleButton.getActionModel().setSelected(action.isSelected());
popupmenu.addMenuButton(toggleButton);
action = context.getBuilder().getMode().getAction("ShowDescendantsAction");
toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(action);
action.setSelected();
toggleButton.getActionModel().setSelected(action.isSelected());
popupmenu.addMenuButton(toggleButton);
return popupmenu;
}
});
ChildProperties props = new ChildProperties(parseOrderSettings(attributes.getProperty("orderPriority", "")));
props.set(RibbonElementPriority.class, RibbonElementPriority.MEDIUM);
parent.addChild(button, props);
}
public void addChild(Object child, ChildProperties properties) {
}
};
}
Aggregations