use of org.freeplane.features.edge.AutomaticEdgeColorHook in project freeplane by freeplane.
the class StyleControlGroup method setStyle.
@Override
public void setStyle(NodeModel node) {
internalChange = true;
try {
final LogicalStyleController logicalStyleController = LogicalStyleController.getController();
if (addStyleBox) {
final boolean isStyleSet = LogicalStyleModel.getStyle(node) != null;
mSetStyle.setValue(isStyleSet);
setStyleList(mMapStyleButton, logicalStyleController.getMapStyleNames(node, "\n"));
}
setStyleList(mNodeStyleButton, logicalStyleController.getNodeStyleNames(node, "\n"));
if (mAutomaticLayoutComboBox != null) {
final ModeController modeController = Controller.getCurrentModeController();
AutomaticLayoutController al = modeController.getExtension(AutomaticLayoutController.class);
IExtension extension = al.getExtension(node);
if (extension == null)
mAutomaticLayoutComboBox.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
else
mAutomaticLayoutComboBox.setSelectedIndex(((AutomaticLayout) extension).ordinal());
}
if (mAutomaticEdgeColorComboBox != null) {
final ModeController modeController = Controller.getCurrentModeController();
AutomaticEdgeColorHook al = (AutomaticEdgeColorHook) modeController.getExtension(AutomaticEdgeColorHook.class);
final AutomaticEdgeColor extension = (AutomaticEdgeColor) al.getExtension(node);
if (extension == null) {
mAutomaticEdgeColorComboBox.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
mEditEdgeColorsBtn.setEnabled(false);
} else {
mAutomaticEdgeColorComboBox.setSelectedIndex(extension.rule.ordinal());
mEditEdgeColorsBtn.setEnabled(true);
}
}
} finally {
internalChange = false;
}
}
use of org.freeplane.features.edge.AutomaticEdgeColorHook 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();
}
Aggregations