public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentModeController();
    final Controller controller = modeController.getController();
    final NodeModel selected = controller.getSelection().getSelected();
    if (selected.depth() < 2) {
      UITools.errorMessage(TextUtils.getText("can_not_delete_style_group"));
      return;
    }
    final MapModel map = selected.getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final NodeModel styleNodeGroup = styleModel.getStyleNodeGroup(selected);
    if (!((StyleNamedObject) styleNodeGroup.getUserObject())
        .getObject()
        .equals("styles.user-defined")) {
      UITools.errorMessage(TextUtils.getText("can_not_delete_predefined_style"));
      return;
    }
    final MMapController mapController = (MMapController) modeController.getMapController();
    mapController.deleteNode(selected);
    final IActor actor =
        new IActor() {
          public void undo() {
            styleModel.addStyleNode(selected);
          }

          public String getDescription() {
            return "DeleteStyle";
          }

          public void act() {
            styleModel.removeStyleNode(selected);
          }
        };
    Controller.getCurrentModeController().execute(actor, map);
  }
Esempio n. 2
0
 private void updateMenus() {
   Controller controller = Controller.getCurrentController();
   final ModeController modeController = controller.getModeController();
   final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder();
   menuBuilder.removeChildElements(MENU_CATEGORY);
   int i = 0;
   int maxEntries = getMaxMenuEntries();
   for (final String key : lastOpenedList) {
     if (i == 0
         && (!modeController.getModeName().equals(MModeController.MODENAME)
             || controller.getMap() == null
             || controller.getMap().getURL() == null)) {
       i++;
       maxEntries++;
     }
     if (i == maxEntries) {
       break;
     }
     final AFreeplaneAction lastOpenedActionListener = new OpenLastOpenedAction(i++, this);
     final IFreeplaneAction decoratedAction = menuBuilder.decorateAction(lastOpenedActionListener);
     final JMenuItem item = new JFreeplaneMenuItem(decoratedAction);
     item.setActionCommand(key);
     String text = createOpenMapItemName(key);
     item.setText(text);
     item.setMnemonic(0);
     menuBuilder.addMenuItem(
         MENU_CATEGORY,
         item,
         MENU_CATEGORY + '/' + lastOpenedActionListener.getKey(),
         UIBuilder.AS_CHILD);
   }
 }
Esempio n. 3
0
 /**
  * Creates all controls and adds them to the frame.
  *
  * @param modeController
  */
 private void init() {
   if (mControls != null) return;
   final String form = "right:max(20dlu;p), 2dlu, p, 1dlu,right:max(20dlu;p), 4dlu, 80dlu, 7dlu";
   final FormLayout rightLayout = new FormLayout(form, "");
   final DefaultFormBuilder rightBuilder = new DefaultFormBuilder(rightLayout);
   rightBuilder.setBorder(Borders.DLU2_BORDER);
   rightBuilder.appendSeparator(TextUtils.getText("OptionPanel.separator.NodeStyle"));
   if (addStyleBox) {
     addAutomaticLayout(rightBuilder);
     addStyleBox(rightBuilder);
   }
   mNodeStyleButton =
       addStyleButton(
           rightBuilder,
           "actual_node_styles",
           modeController.getAction(ManageNodeConditionalStylesAction.NAME));
   if (addStyleBox) {
     mMapStyleButton =
         addStyleButton(
             rightBuilder,
             "actual_map_styles",
             modeController.getAction(ManageMapConditionalStylesAction.NAME));
   }
   mControls = getControls();
   for (final IPropertyControl control : mControls) {
     control.layout(rightBuilder);
   }
   add(rightBuilder.getPanel(), BorderLayout.CENTER);
   addListeners();
   setFont(this, 10);
 }
  private void register(ModeController modeController) {
    modeController.addExtension(
        IScriptEditorStarter.class,
        new IScriptEditorStarter() {
          public String startEditor(final String pScriptInput) {
            final ScriptModel scriptModel = new ScriptModel(pScriptInput);
            final ScriptEditorPanel scriptEditorPanel = new ScriptEditorPanel(scriptModel, false);
            scriptEditorPanel.setVisible(true);
            return scriptModel.getScript();
          }

          public ComboBoxEditor createComboBoxEditor(Dimension minimumSize) {
            final ScriptComboBoxEditor scriptComboBoxEditor = new ScriptComboBoxEditor();
            if (minimumSize != null) scriptComboBoxEditor.setMinimumSize(minimumSize);
            return scriptComboBoxEditor;
          }
        });
    modeController.addExtension(
        IScriptStarter.class,
        new IScriptStarter() {
          public void executeScript(NodeModel node, String script) {
            ScriptingEngine.executeScript(node, script);
          }
        });
    registerScriptAddOns();
    if (!modeController.getController().getViewController().isHeadless()) {
      final IUserInputListenerFactory userInputListenerFactory =
          modeController.getUserInputListenerFactory();
      addPropertiesToOptionPanel();
      final MenuBuilder menuBuilder = userInputListenerFactory.getMenuBuilder();
      modeController.addAction(new ScriptEditor());
      modeController.addAction(new ExecuteScriptForAllNodes());
      modeController.addAction(new ExecuteScriptForSelectionAction());
      final ManageAddOnsAction manageAddOnsAction = new ManageAddOnsAction();
      modeController.addAction(manageAddOnsAction);
      modeController.addExtension(
          AddOnInstaller.class,
          new AddOnInstaller() {
            public void install(final URL url) {
              final ManageAddOnsDialog dialog = manageAddOnsAction.getDialog();
              // FIXME: method does not exist --> boercher
              // dialog.install(url);
            }
          });
      final ScriptingConfiguration configuration = new ScriptingConfiguration();
      ScriptingEngine.setClasspath(configuration.getClasspath());
      ScriptCompiler.compileScriptsOnPath(configuration.getClasspath());
      modeController.addMenuContributor(
          new IMenuContributor() {
            public void updateMenus(ModeController modeController, MenuBuilder builder) {
              registerScripts(menuBuilder, configuration);
            }
          });
      createUserScriptsDirectory();
    }
    FilterController.getCurrentFilterController()
        .getConditionFactory()
        .addConditionController(10, new ScriptConditionController());
  }
Esempio n. 5
0
 public Object executeScript(
     final int pIndex, final PrintStream pOutStream, final IErrorHandler pErrorHandler) {
   final String script = getScript(pIndex).getScript();
   ModeController mMindMapController = Controller.getCurrentModeController();
   return ScriptingEngine.executeScript(
       mMindMapController.getMapController().getSelectedNode(),
       script,
       pErrorHandler,
       pOutStream,
       null,
       ScriptingPermissions.getPermissiveScriptingPermissions());
 }
Esempio n. 6
0
 public String getRestoreable(final MapModel map) {
   if (map == null) {
     return null;
   }
   // ignore documentation maps loaded using documentation actions
   if (map.containsExtension(DocuMapAttribute.class)) return null;
   final ModeController modeController = Controller.getCurrentModeController();
   if (!modeController.getModeName().equals(MModeController.MODENAME)) {
     return null;
   }
   final File file = map.getFile();
   return getRestorable(file);
 }
 public Object executeScript(
     final int pIndex, final PrintStream pOutStream, final IErrorHandler pErrorHandler) {
   final ModeController modeController = Controller.getCurrentModeController();
   // the script is completely in the hand of the user -> no security issues.
   final ScriptingPermissions restrictedPermissions =
       ScriptingPermissions.getPermissiveScriptingPermissions();
   return ScriptingEngine.executeScript(
       modeController.getMapController().getSelectedNode(),
       mScript,
       pErrorHandler,
       pOutStream,
       null,
       restrictedPermissions);
 }
Esempio n. 8
0
 public void actionPerformed(final ActionEvent e) {
   final ModeController modeController = Controller.getCurrentModeController();
   final NodeModel node = modeController.getMapController().getSelectedNode();
   final ArrayList<AttributeHolder> scripts = new ArrayList<AttributeHolder>();
   for (int position = 0;
       position < NodeAttributeTableModel.getModel(node).getAttributeTableLength();
       position++) {
     final Attribute attribute = NodeAttributeTableModel.getModel(node).getAttribute(position);
     if (attribute.getName().startsWith(ScriptingEngine.SCRIPT_PREFIX)) {
       scripts.add(new AttributeHolder(new Attribute(attribute), position));
     }
   }
   final NodeScriptModel nodeScriptModel = new NodeScriptModel(scripts, node);
   final ScriptEditorPanel scriptEditorPanel = new ScriptEditorPanel(nodeScriptModel, true);
   scriptEditorPanel.setVisible(true);
 }
  public void mouseClicked(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON1 && e.getSource() instanceof MainView) {
      MainView view = (MainView) e.getSource();
      Rectangle bounds = ((ZoomableLabelUI) view.getUI()).getIconR(view);
      Point p = e.getPoint();
      if (bounds.contains(p)) {
        if (view.getIcon() instanceof MultipleImage) {
          Rectangle iconR =
              ((MultipleImage) view.getIcon())
                  .getIconR(PdfUtilitiesController.REFRESH_MONITORING_ICON);
          if (iconR != null) {
            float zoom = Controller.getCurrentController().getViewController().getZoom();
            iconR.setLocation((int) (iconR.x * zoom), iconR.y);
            iconR.setSize((int) (iconR.width * zoom), (int) (iconR.height * zoom));
            iconR.translate(bounds.x, bounds.y);
            if (iconR.contains(p)) {
              UpdateMonitoringFolderAction.updateNodesAgainstMonitoringDir(
                  getMonitorNodes(
                      Controller.getCurrentController().getViewController().getMap().getRootNode()),
                  false);
              return;
            }
          }
        }
      }
      //			StringBuilder sb = new StringBuilder();
      //			pdfHeaderExtraction(e, sb);
    }
    boolean openOnPage =
        ResourceController.getResourceController()
            .getBooleanProperty(PdfUtilitiesController.OPEN_PDF_VIEWER_ON_PAGE_KEY);

    if (!openOnPage) {
      this.mouseListener.mouseClicked(e);
      return;
    }

    if (
    /*wasFocused() && */ (e.getModifiers() & ~(InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK))
        == InputEvent.BUTTON1_MASK) {
      final MainView component = (MainView) e.getComponent();
      final ModeController modeController = Controller.getCurrentModeController();
      NodeModel node = null;
      try {
        node = ((MainView) e.getSource()).getNodeView().getModel();
      } catch (Exception ex) {
      }

      if (node == null) {
        node = modeController.getMapController().getSelectedNode();
      }

      if (component.isInFollowLinkRegion(e.getX())) {
        writeToLog(node);
      }
      if (!component.isInFollowLinkRegion(e.getX()) || !MonitoringUtils.isPdfLinkedNode(node)) {
        this.mouseListener.mouseClicked(e);
        return;
      }

      URI uri = Tools.getAbsoluteUri(node);
      if (uri == null) {
        this.mouseListener.mouseClicked(e);
        return;
      }

      IAnnotation annotation = null;
      try {
        annotation = node.getExtension(AnnotationModel.class);
      } catch (Exception ex) {
      }

      LinkController.getController().onDeselect(node);
      if (!PdfUtilitiesController.getController().openPdfOnPage(uri, annotation)) {
        this.mouseListener.mouseClicked(e);
        return;
      }
      LinkController.getController().onSelect(node);

    } else {
      this.mouseListener.mouseClicked(e);
    }
  }
Esempio n. 10
0
 private static MenuBuilder getMenuBuilder() {
   final ModeController modeController = Controller.getCurrentModeController();
   final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder();
   return menuBuilder;
 }
Esempio n. 11
0
  public MUIFactory() {
    size = new DefaultComboBoxModel(MUIFactory.FONT_SIZES);
    styles = new DefaultComboBoxModel();
    final ModeController modeController = Controller.getCurrentModeController();
    final MNodeStyleController styleController =
        (MNodeStyleController) modeController.getExtension(NodeStyleController.class);
    final GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final String[] envFonts = gEnv.getAvailableFontFamilyNames();
    fonts = new DefaultComboBoxModel(envFonts);
    final ListDataListener fontsListener =
        new ListDataListener() {
          public void intervalRemoved(final ListDataEvent e) {}

          public void intervalAdded(final ListDataEvent e) {}

          public void contentsChanged(final ListDataEvent e) {
            if (e.getIndex0() != -1) {
              return;
            }
            if (ignoreChangeEvent) {
              return;
            }
            ignoreChangeEvent = true;
            final DefaultComboBoxModel source = (DefaultComboBoxModel) e.getSource();
            styleController.setFontFamily((String) source.getSelectedItem());
            ignoreChangeEvent = false;
          }
        };
    fonts.addListDataListener(fontsListener);
    final ListDataListener sizeListener =
        new ListDataListener() {
          public void intervalRemoved(final ListDataEvent e) {}

          public void intervalAdded(final ListDataEvent e) {}

          public void contentsChanged(final ListDataEvent e) {
            if (e.getIndex0() != -1) {
              return;
            }
            if (ignoreChangeEvent) {
              return;
            }
            try {
              final DefaultComboBoxModel source = (DefaultComboBoxModel) e.getSource();
              final int intSize = Integer.parseInt(((String) source.getSelectedItem()));
              styleController.setFontSize(intSize);
            } catch (final NumberFormatException nfe) {
            }
          }
        };
    size.addListDataListener(sizeListener);
    final ListDataListener styleListener =
        new ListDataListener() {
          public void intervalRemoved(final ListDataEvent e) {}

          public void intervalAdded(final ListDataEvent e) {}

          public void contentsChanged(final ListDataEvent e) {
            if (e.getIndex0() != -1) {
              return;
            }
            if (ignoreChangeEvent) {
              return;
            }
            final DefaultComboBoxModel source = (DefaultComboBoxModel) e.getSource();
            final IStyle style = (IStyle) source.getSelectedItem();
            final MLogicalStyleController controller =
                (MLogicalStyleController) modeController.getExtension(LogicalStyleController.class);
            controller.setStyle(style);
          }
        };
    styles.addListDataListener(styleListener);
  }
 public void registerListeners(ModeController modeController) {
   final NodeUpdateChangeListener listener = new NodeUpdateChangeListener();
   modeController.getMapController().addNodeChangeListener(listener);
   modeController.getMapController().addMapChangeListener(listener);
 }
Esempio n. 13
0
  public void setStyle(final NodeModel node) {
    if (internalChange) {
      return;
    }
    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"));
      final NodeStyleController styleController = NodeStyleController.getController();
      {
        final Color nodeColor = NodeStyleModel.getColor(node);
        final Color viewNodeColor = styleController.getColor(node);
        mSetNodeColor.setValue(nodeColor != null);
        mNodeColor.setColorValue(viewNodeColor);
      }
      {
        final Color color = NodeStyleModel.getBackgroundColor(node);
        final Color viewColor = styleController.getBackgroundColor(node);
        mSetNodeBackgroundColor.setValue(color != null);
        mNodeBackgroundColor.setColorValue(
            viewColor != null
                ? viewColor
                : Controller.getCurrentController().getMapViewManager().getBackgroundColor(node));
      }
      {
        final String shape = NodeStyleModel.getShape(node);
        final String viewShape = styleController.getShape(node);
        mSetNodeShape.setValue(shape != null);
        mNodeShape.setValue(viewShape);
      }
      final NodeSizeModel nodeSizeModel = NodeSizeModel.getModel(node);
      {
        final int width =
            nodeSizeModel != null ? nodeSizeModel.getMaxNodeWidth() : NodeSizeModel.NOT_SET;
        final int viewWidth = styleController.getMaxWidth(node);
        mSetMaxNodeWidth.setValue(width != NodeSizeModel.NOT_SET);
        mMaxNodeWidth.setValue(Integer.toString(viewWidth));
      }
      {
        final int width =
            nodeSizeModel != null ? nodeSizeModel.getMinNodeWidth() : NodeSizeModel.NOT_SET;
        final int viewWidth = styleController.getMinWidth(node);
        mSetMinNodeWidth.setValue(width != NodeSizeModel.NOT_SET);
        mMinNodeWidth.setValue(Integer.toString(viewWidth));
      }
      final EdgeController edgeController = EdgeController.getController();
      final EdgeModel edgeModel = EdgeModel.getModel(node);
      {
        final Color edgeColor = edgeModel != null ? edgeModel.getColor() : null;
        final Color viewColor = edgeController.getColor(node);
        mSetEdgeColor.setValue(edgeColor != null);
        mEdgeColor.setColorValue(viewColor);
      }
      {
        final EdgeStyle style = edgeModel != null ? edgeModel.getStyle() : null;
        final EdgeStyle viewStyle = edgeController.getStyle(node);
        mSetEdgeStyle.setValue(style != null);
        mEdgeStyle.setValue(viewStyle.toString());
      }
      {
        final int width = edgeModel != null ? edgeModel.getWidth() : EdgeModel.DEFAULT_WIDTH;
        final int viewWidth = edgeController.getWidth(node);
        mSetEdgeWidth.setValue(width != EdgeModel.DEFAULT_WIDTH);
        mEdgeWidth.setValue(Integer.toString(viewWidth));
      }
      {
        final CloudController cloudController = CloudController.getController();
        final CloudModel cloudModel = CloudModel.getModel(node);
        final Color viewCloudColor = cloudController.getColor(node);
        mSetCloud.setValue(cloudModel != null);
        mCloudColor.setColorValue(viewCloudColor);

        final CloudModel.Shape viewCloudShape = cloudController.getShape(node);
        mCloudShape.setValue(
            viewCloudShape != null ? viewCloudShape.toString() : CloudModel.Shape.ARC.toString());
      }
      {
        final String fontFamilyName = NodeStyleModel.getFontFamilyName(node);
        final String viewFontFamilyName = styleController.getFontFamilyName(node);
        mSetNodeFontName.setValue(fontFamilyName != null);
        mNodeFontName.setValue(viewFontFamilyName);
      }
      {
        final Integer fontSize = NodeStyleModel.getFontSize(node);
        final Integer viewfontSize = styleController.getFontSize(node);
        mSetNodeFontSize.setValue(fontSize != null);
        mNodeFontSize.setValue(viewfontSize.toString());
      }
      {
        final Boolean bold = NodeStyleModel.isBold(node);
        final Boolean viewbold = styleController.isBold(node);
        mSetNodeFontBold.setValue(bold != null);
        mNodeFontBold.setValue(viewbold);
      }
      {
        final Boolean italic = NodeStyleModel.isItalic(node);
        final Boolean viewitalic = styleController.isItalic(node);
        mSetNodeFontItalic.setValue(italic != null);
        mNodeFontItalic.setValue(viewitalic);
      }
      {
        final Boolean hyperlink = NodeLinks.formatNodeAsHyperlink(node);
        final Boolean viewhyperlink = LinkController.getController().formatNodeAsHyperlink(node);
        mSetNodeFontHyperlink.setValue(hyperlink != null);
        mNodeFontHyperlink.setValue(viewhyperlink);
      }
      {
        final Boolean nodeNumbering = NodeStyleModel.getNodeNumbering(node);
        final Boolean viewNodeNumbering = styleController.getNodeNumbering(node);
        mSetNodeNumbering.setValue(nodeNumbering != null);
        mNodeNumbering.setValue(viewNodeNumbering);
      }
      {
        String nodeFormat = NodeStyleModel.getNodeFormat(node);
        String viewNodeFormat = TextController.getController().getNodeFormat(node);
        mSetNodeFormat.setValue(nodeFormat != null);
        if (viewNodeFormat == null && node.getUserObject() instanceof IFormattedObject)
          viewNodeFormat = ((IFormattedObject) node.getUserObject()).getPattern();
        mNodeFormat.setValue(viewNodeFormat);
      }
      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 (mAutomaticEdgeColorCheckBox != null) {
        final ModeController modeController = Controller.getCurrentModeController();
        AutomaticEdgeColorHook al =
            (AutomaticEdgeColorHook) modeController.getExtension(AutomaticEdgeColorHook.class);
        mAutomaticEdgeColorCheckBox.setSelected(al.isActive(node));
      }
    } finally {
      internalChange = false;
    }
  }
Esempio n. 14
0
  private void addListeners() {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = Controller.getCurrentModeController();
    final MapController mapController = modeController.getMapController();
    mapController.addNodeSelectionListener(
        new INodeSelectionListener() {
          public void onSelect(final NodeModel node) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
              return;
            }
            if (selection.size() == 1) {
              setStyle(node);
            }
          }

          public void onDeselect(final NodeModel node) {}
        });
    mapController.addNodeChangeListener(
        new INodeChangeListener() {
          public void nodeChanged(final NodeChangeEvent event) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
              return;
            }
            final NodeModel node = event.getNode();
            if (selection.getSelected().equals(node)) {
              setStyle(node);
            }
          }
        });
    mapController.addMapChangeListener(
        new AMapChangeListenerAdapter() {

          @Override
          public void mapChanged(MapChangeEvent event) {
            if (!MapStyle.MAP_STYLES.equals(event.getProperty())) return;
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
              return;
            }
            final NodeModel node = selection.getSelected();
            setStyle(node);
          }
        });
    final IMapViewManager mapViewManager = controller.getMapViewManager();
    mapViewManager.addMapViewChangeListener(
        new IMapViewChangeListener() {
          public void beforeViewChange(final Component oldView, final Component newView) {}

          public void afterViewCreated(final Component mapView) {}

          public void afterViewClose(final Component oldView) {}

          public void afterViewChange(final Component oldView, final Component newView) {
            final Container panel = (Container) getComponent(0);
            for (int i = 0; i < panel.getComponentCount(); i++) {
              panel.getComponent(i).setEnabled(newView != null);
            }
          }
        });
  }
 private static DocearNodeModifiedExtensionController getController(
     ModeController modeController) {
   return (DocearNodeModifiedExtensionController)
       modeController.getExtension(DocearNodeModifiedExtensionController.class);
 }
 public static void install(ModeController modeController) {
   modeController.addExtension(
       DocearNodeModifiedExtensionController.class,
       new DocearNodeModifiedExtensionController(modeController));
 }