Search in sources :

Example 1 with JComboBoxWithBorder

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

the class StyleControlGroup method addStyleControls.

private void addStyleControls(final DefaultFormBuilder formBuilder) {
    TranslatedObject[] automaticLayoutTypes = TranslatedObject.fromEnum(AutomaticLayout.class);
    mAutomaticLayoutComboBox = new JComboBoxWithBorder(automaticLayoutTypes);
    DefaultComboBoxModel automaticLayoutComboBoxModel = (DefaultComboBoxModel) mAutomaticLayoutComboBox.getModel();
    automaticLayoutComboBoxModel.addElement(AUTOMATIC_LAYOUT_DISABLED);
    automaticLayoutComboBoxModel.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
    mAutomaticLayoutComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (internalChange)
                return;
            final ModeController modeController = Controller.getCurrentModeController();
            AutomaticLayoutController al = modeController.getExtension(AutomaticLayoutController.class);
            TranslatedObject selectedItem = (TranslatedObject) mAutomaticLayoutComboBox.getSelectedItem();
            al.undoableDeactivateHook(Controller.getCurrentController().getMap().getRootNode());
            if (!selectedItem.equals(AUTOMATIC_LAYOUT_DISABLED)) {
                al.undoableActivateHook(Controller.getCurrentController().getMap().getRootNode(), (AutomaticLayout) selectedItem.getObject());
            }
        }
    });
    appendLabeledComponent(formBuilder, "AutomaticLayoutAction.text", mAutomaticLayoutComboBox);
}
Also used : AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) AutomaticLayout(org.freeplane.features.styles.AutomaticLayout) TranslatedObject(org.freeplane.core.resources.TranslatedObject) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ModeController(org.freeplane.features.mode.ModeController) JComboBoxWithBorder(org.freeplane.core.ui.components.JComboBoxWithBorder)

Example 2 with JComboBoxWithBorder

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

the class StyleControlGroup method addEdgeColoringControls.

private void addEdgeColoringControls(final DefaultFormBuilder formBuilder) {
    TranslatedObject[] automaticLayoutTypes = TranslatedObject.fromEnum(AutomaticEdgeColor.class.getSimpleName() + ".", AutomaticEdgeColor.Rule.class);
    mAutomaticEdgeColorComboBox = new JComboBoxWithBorder(automaticLayoutTypes);
    DefaultComboBoxModel automaticEdgeColorComboBoxModel = (DefaultComboBoxModel) mAutomaticEdgeColorComboBox.getModel();
    automaticEdgeColorComboBoxModel.addElement(AUTOMATIC_LAYOUT_DISABLED);
    automaticEdgeColorComboBoxModel.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
    mAutomaticEdgeColorComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (internalChange)
                return;
            final ModeController modeController = Controller.getCurrentModeController();
            AutomaticEdgeColorHook hook = modeController.getExtension(AutomaticEdgeColorHook.class);
            TranslatedObject selectedItem = (TranslatedObject) mAutomaticEdgeColorComboBox.getSelectedItem();
            final MapModel map = Controller.getCurrentController().getMap();
            final AutomaticEdgeColor oldExtension = (AutomaticEdgeColor) hook.getMapHook(map);
            final int colorCount = oldExtension == null ? 0 : oldExtension.getColorCounter();
            final NodeModel rootNode = map.getRootNode();
            hook.undoableDeactivateHook(rootNode);
            if (!selectedItem.equals(AUTOMATIC_LAYOUT_DISABLED)) {
                final AutomaticEdgeColor newExtension = new AutomaticEdgeColor((AutomaticEdgeColor.Rule) selectedItem.getObject(), colorCount);
                hook.undoableActivateHook(rootNode, newExtension);
            }
        }
    });
    appendLabeledComponent(formBuilder, "AutomaticEdgeColorHookAction.text", mAutomaticEdgeColorComboBox);
    mEditEdgeColorsBtn = TranslatedElementFactory.createButton("editEdgeColors");
    mEditEdgeColorsBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final MEdgeController edgeController = (MEdgeController) modeController.getExtension(EdgeController.class);
            edgeController.editEdgeColorConfiguration(Controller.getCurrentController().getMap());
        }
    });
    formBuilder.appendLineGapRow();
    formBuilder.nextLine();
    formBuilder.appendRow(FormSpecs.PREF_ROWSPEC);
    formBuilder.setColumn(1);
    formBuilder.append(mEditEdgeColorsBtn, 7);
    formBuilder.nextLine();
}
Also used : AutomaticEdgeColorHook(org.freeplane.features.edge.AutomaticEdgeColorHook) ActionEvent(java.awt.event.ActionEvent) TranslatedObject(org.freeplane.core.resources.TranslatedObject) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) AutomaticEdgeColor(org.freeplane.features.edge.AutomaticEdgeColor) NodeModel(org.freeplane.features.map.NodeModel) ActionListener(java.awt.event.ActionListener) JComboBoxWithBorder(org.freeplane.core.ui.components.JComboBoxWithBorder) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController)

Aggregations

ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2 TranslatedObject (org.freeplane.core.resources.TranslatedObject)2 JComboBoxWithBorder (org.freeplane.core.ui.components.JComboBoxWithBorder)2 ModeController (org.freeplane.features.mode.ModeController)2 AutomaticEdgeColor (org.freeplane.features.edge.AutomaticEdgeColor)1 AutomaticEdgeColorHook (org.freeplane.features.edge.AutomaticEdgeColorHook)1 MEdgeController (org.freeplane.features.edge.mindmapmode.MEdgeController)1 MapModel (org.freeplane.features.map.MapModel)1 NodeModel (org.freeplane.features.map.NodeModel)1 AutomaticLayout (org.freeplane.features.styles.AutomaticLayout)1 AutomaticLayoutController (org.freeplane.features.styles.AutomaticLayoutController)1