use of org.freeplane.core.ui.components.JAutoToggleButton in project freeplane by freeplane.
the class ToolbarComponentProvider method createComponent.
/* (non-Javadoc)
* @see org.freeplane.core.ui.menubuilders.menu.ComponentProvider#createComponent(org.freeplane.core.ui.menubuilders.generic.Entry)
*/
@Override
public Component createComponent(Entry entry) {
final EntryAccessor entryAccessor = new EntryAccessor();
final Object existingComponent = entryAccessor.getComponent(entry);
if (existingComponent != null)
return (Component) existingComponent;
final AFreeplaneAction action = entryAccessor.getAction(entry);
Component component;
if (action != null) {
if (action.isSelectable()) {
component = new JAutoToggleButton(action);
} else {
component = new JButton(action);
}
} else if (entry.builders().contains("separator")) {
component = new Separator();
} else
component = null;
return component;
}
use of org.freeplane.core.ui.components.JAutoToggleButton in project freeplane by freeplane.
the class TranslatedElementFactory method createToggleButton.
public static JToggleButton createToggleButton(Action action, String labelKey) {
final JToggleButton component = action != null ? new JAutoToggleButton(action) : new JAutoToggleButton();
final String text = TextUtils.getRawText(labelKey);
LabelAndMnemonicSetter.setLabelAndMnemonic(component, text);
TranslatedElement.TEXT.setKey(component, labelKey);
createTooltip(component, labelKey + ".tooltip");
return component;
}
use of org.freeplane.core.ui.components.JAutoToggleButton in project freeplane by freeplane.
the class TranslatedElementFactory method createToggleButtonWithIcon.
public static JToggleButton createToggleButtonWithIcon(final String iconKey, String tooltipKey) {
final JToggleButton button = new JAutoToggleButton();
createTooltip(button, tooltipKey);
return addIcon(button, iconKey);
}
use of org.freeplane.core.ui.components.JAutoToggleButton in project freeplane by freeplane.
the class JToolbarComponentBuilderTest method createsToolbarButtonWithSelectableAction.
@Test
public void createsToolbarButtonWithSelectableAction() {
Entry actionEntry = new Entry();
final AFreeplaneAction action = Mockito.mock(AFreeplaneAction.class);
when(action.isSelectable()).thenReturn(true);
new EntryAccessor().setAction(actionEntry, action);
Entry toolbarEntry = new Entry();
final FreeplaneToolBar toolbar = new FreeplaneToolBar("toolbar", SwingConstants.HORIZONTAL);
new EntryAccessor().setComponent(toolbarEntry, toolbar);
toolbarEntry.addChild(actionEntry);
final JToolbarComponentBuilder toolbarActionGroupBuilder = new JToolbarComponentBuilder();
toolbarActionGroupBuilder.visit(actionEntry);
JAutoToggleButton button = (JAutoToggleButton) new EntryAccessor().getComponent(actionEntry);
assertThat(button.getAction(), CoreMatchers.<Action>equalTo(action));
assertThat(button.getParent(), CoreMatchers.equalTo((Container) toolbar));
}
use of org.freeplane.core.ui.components.JAutoToggleButton in project freeplane by freeplane.
the class MenuBuilder method addButton.
private void addButton(final String category, final Action action, final String key, final int position) {
final AbstractButton button;
assert action != null;
if (action.getClass().getAnnotation(SelectableAction.class) != null) {
button = new JAutoToggleButton(action);
} else {
button = new JButton(action);
}
addElement(category, button, key, position);
}
Aggregations