Search in sources :

Example 1 with JFreeplaneMenuItem

use of org.freeplane.core.ui.components.JFreeplaneMenuItem in project freeplane by freeplane.

the class ColorProperty method layout.

public void layout(final DefaultFormBuilder builder) {
    layout(builder, mButton);
    final JMenuItem item = new JFreeplaneMenuItem(TextUtils.getOptionalText("ColorProperty.ResetColor"));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(final ActionEvent e) {
            setValue(defaultColor);
        }
    });
    menu.add(item);
    mButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(final MouseEvent evt) {
            if (evt.isPopupTrigger()) {
                menu.show(evt.getComponent(), evt.getX(), evt.getY());
            }
        }

        @Override
        public void mouseReleased(final MouseEvent evt) {
            if (evt.isPopupTrigger()) {
                menu.show(evt.getComponent(), evt.getX(), evt.getY());
            }
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) JMenuItem(javax.swing.JMenuItem) JFreeplaneMenuItem(org.freeplane.core.ui.components.JFreeplaneMenuItem)

Example 2 with JFreeplaneMenuItem

use of org.freeplane.core.ui.components.JFreeplaneMenuItem in project freeplane by freeplane.

the class MenuActionComponentProvider 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 AFreeplaneAction action = entryAccessor.getAction(entry);
    if (action != null) {
        final JMenuItem actionComponent;
        IFreeplaneAction wrappedAction = acceleratebleActionProvider.wrap(action);
        if (action.isSelectable()) {
            actionComponent = new JAutoCheckBoxMenuItem(wrappedAction);
        } else {
            actionComponent = new JFreeplaneMenuItem(wrappedAction);
        }
        final KeyStroke accelerator = accelerators.getAccelerator(action);
        actionComponent.setAccelerator(accelerator);
        MenuIconScaling.scaleIcon(actionComponent);
        return actionComponent;
    } else if (entry.builders().contains("separator")) {
        return new JPopupMenu.Separator();
    } else
        return null;
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) IFreeplaneAction(org.freeplane.core.ui.IFreeplaneAction) JAutoCheckBoxMenuItem(org.freeplane.core.ui.components.JAutoCheckBoxMenuItem) KeyStroke(javax.swing.KeyStroke) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu) JFreeplaneMenuItem(org.freeplane.core.ui.components.JFreeplaneMenuItem)

Example 3 with JFreeplaneMenuItem

use of org.freeplane.core.ui.components.JFreeplaneMenuItem in project freeplane by freeplane.

the class EmptyMenuItemBuilder method visit.

@Override
public void visit(Entry target) {
    final Container container = getMenuItemContainer(target);
    if (container.getComponentCount() == 0) {
        final String text = TextUtils.getText(target.getParent().getName() + ".noActions");
        final JFreeplaneMenuItem noActionItem = new JFreeplaneMenuItem(text);
        noActionItem.setEnabled(false);
        entryAccessor.setComponent(target, noActionItem);
        container.add(noActionItem);
    }
}
Also used : Container(java.awt.Container) JFreeplaneMenuItem(org.freeplane.core.ui.components.JFreeplaneMenuItem)

Aggregations

JFreeplaneMenuItem (org.freeplane.core.ui.components.JFreeplaneMenuItem)3 JMenuItem (javax.swing.JMenuItem)2 Container (java.awt.Container)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 JPopupMenu (javax.swing.JPopupMenu)1 KeyStroke (javax.swing.KeyStroke)1 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)1 IFreeplaneAction (org.freeplane.core.ui.IFreeplaneAction)1 JAutoCheckBoxMenuItem (org.freeplane.core.ui.components.JAutoCheckBoxMenuItem)1