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);
  }
示例#2
0
 private String createOpenMapItemName(final String restorable) {
   final int separatorIndex = restorable.indexOf(':');
   if (separatorIndex == -1) return restorable;
   String key = restorable.substring(0, separatorIndex);
   String fileName = restorable.substring(separatorIndex);
   if (fileName.startsWith("::"))
     return TextUtils.getText("open_as" + key, key) + " " + fileName.substring(2);
   else return TextUtils.getText("open_as" + key, key) + " " + fileName.substring(1);
 }
 private static boolean askForReplaceShortcutViaDialog(
     String oldMenuItemTitle, Component parentComponent) {
   final int replace =
       JOptionPane.showConfirmDialog(
           parentComponent,
           TextUtils.format("replace_shortcut_question", oldMenuItemTitle),
           TextUtils.format("replace_shortcut_title"),
           JOptionPane.YES_NO_OPTION);
   return replace == JOptionPane.YES_OPTION;
 }
 private void registerScripts(
     final MenuBuilder menuBuilder, ScriptingConfiguration configuration) {
   final HashSet<String> registeredLocations = new HashSet<String>();
   for (final String scriptsParentLocation : ScriptingConfiguration.getScriptsParentLocations()) {
     final String scriptsLocation =
         ScriptingConfiguration.getScriptsLocation(scriptsParentLocation);
     addSubMenu(
         menuBuilder,
         scriptsParentLocation,
         scriptsLocation,
         TextUtils.getText("ExecuteScripts.text"));
     registeredLocations.add(scriptsLocation);
     if (configuration.getNameScriptMap().isEmpty()) {
       final String message =
           "<html><body><em>"
               + TextUtils.getText("ExecuteScripts.noScriptsAvailable")
               + "</em></body></html>";
       menuBuilder.addElement(scriptsLocation, new JMenuItem(message), 0);
     }
     for (final Entry<String, String> entry : configuration.getNameScriptMap().entrySet()) {
       final String scriptName = entry.getKey();
       final ScriptMetaData metaData = configuration.getNameScriptMetaDataMap().get(scriptName);
       // in the worst case three actions will cache a script - should not matter that much since
       // it's unlikely
       // that one script is used in multiple modes by the same user
       for (final ExecutionMode executionMode : metaData.getExecutionModes()) {
         final String titleKey;
         final String scriptLocation;
         String location = metaData.getMenuLocation(executionMode);
         // FIXME: reduce code duplication (VB)
         if (location == null) {
           location = scriptsLocation + "/" + scriptName;
           if (!registeredLocations.contains(location)) {
             final String parentMenuTitle = pimpMenuTitle(metaData.getScriptName());
             addSubMenu(menuBuilder, parentLocation(location), location, parentMenuTitle);
             registeredLocations.add(location);
           }
           titleKey = metaData.getTitleKey(executionMode);
           scriptLocation = location + "/" + titleKey;
         } else {
           if (!registeredLocations.contains(location)) {
             addSubMenu(menuBuilder, parentLocation(location), location, getMenuTitle(location));
             registeredLocations.add(location);
           }
           titleKey = metaData.getTitleKey(executionMode);
           scriptLocation = location + "/" + titleKey;
         }
         if (!registeredLocations.contains(scriptLocation)) {
           addMenuItem(menuBuilder, location, entry, executionMode, titleKey, metaData);
           registeredLocations.add(scriptLocation);
         }
       }
     }
   }
 }
示例#5
0
 private void addAutomaticLayout(final DefaultFormBuilder rightBuilder) {
   {
     if (mAutomaticLayoutComboBox == null) {
       NamedObject[] automaticLayoutTypes = NamedObject.fromEnum(AutomaticLayout.class);
       mAutomaticLayoutComboBox = new JComboBox(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);
               NamedObject selectedItem = (NamedObject) mAutomaticLayoutComboBox.getSelectedItem();
               al.undoableDeactivateHook(Controller.getCurrentController().getMap().getRootNode());
               if (!selectedItem.equals(AUTOMATIC_LAYOUT_DISABLED)) {
                 al.undoableActivateHook(
                     Controller.getCurrentController().getMap().getRootNode(),
                     (AutomaticLayout) selectedItem.getObject());
               }
             }
           });
     }
     final String label = TextUtils.getText("AutomaticLayoutAction.text");
     rightBuilder.append(new JLabel(label), 5);
     rightBuilder.append(mAutomaticLayoutComboBox);
     rightBuilder.nextLine();
   }
   {
     if (mAutomaticEdgeColorCheckBox == null) {
       mAutomaticEdgeColorCheckBox = new JCheckBox();
       mAutomaticEdgeColorCheckBox.addActionListener(
           new ActionListener() {
             public void actionPerformed(ActionEvent e) {
               final ModeController modeController = Controller.getCurrentModeController();
               AutomaticEdgeColorHook al =
                   (AutomaticEdgeColorHook)
                       modeController.getExtension(AutomaticEdgeColorHook.class);
               al.undoableToggleHook(Controller.getCurrentController().getMap().getRootNode());
             }
           });
     }
     final String label = TextUtils.getText("AutomaticEdgeColorHookAction.text");
     rightBuilder.append(new JLabel(label), 5);
     rightBuilder.append(mAutomaticEdgeColorCheckBox);
     rightBuilder.nextLine();
   }
 }
 public ComboBoxModel getConditionsForProperty(final Object selectedItem) {
   return new DefaultComboBoxModel(
       new NamedObject[] {
         TextUtils.createTranslatedString(ConditionFactory.FILTER_IS_EQUAL_TO),
         TextUtils.createTranslatedString(ConditionFactory.FILTER_IS_NOT_EQUAL_TO),
         NamedObject.literal(ConditionFactory.FILTER_GT),
         NamedObject.literal(ConditionFactory.FILTER_GE),
         NamedObject.literal(ConditionFactory.FILTER_LE),
         NamedObject.literal(ConditionFactory.FILTER_LT),
         TextUtils.createTranslatedString(NodeLevelConditionController.FILTER_ROOT),
         TextUtils.createTranslatedString(NodeLevelConditionController.FILTER_LEAF),
         TextUtils.createTranslatedString(NodeLevelConditionController.FILTER_PERIODIC_LEVEL),
       });
 }
 protected void editScript(boolean selectAll) {
   JEditorPane textEditor = new JEditorPane();
   textEditor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
   final JRestrictedSizeScrollPane scrollPane = new JRestrictedSizeScrollPane(textEditor);
   scrollPane.setMinimumSize(minimumSize);
   textEditor.setContentType("text/groovy");
   textEditor.setText(script);
   if (selectAll) {
     textEditor.selectAll();
   }
   String title = TextUtils.getText("plugins/ScriptEditor/window.title");
   final JOptionPane optionPane =
       new JOptionPane(scrollPane, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
   final JDialog dialog = optionPane.createDialog(showEditorBtn, title);
   dialog.setResizable(true);
   if (bounds != null) dialog.setBounds(bounds);
   dialog.setVisible(true);
   bounds = dialog.getBounds();
   final Integer result = ((Integer) optionPane.getValue());
   if (result == null || result != JOptionPane.OK_OPTION) return;
   script = textEditor.getText();
   setButtonText();
   final ActionEvent actionEvent = new ActionEvent(this, 0, null);
   for (final ActionListener l : actionListeners) {
     l.actionPerformed(actionEvent);
   }
 }
示例#8
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);
 }
示例#9
0
  public void initializePopup() {
    if (popupMenu == null) {

      if (popupMenu == null) {
        popupMenu = new WorkspacePopupMenu();
        WorkspacePopupMenuBuilder.addActions(
            popupMenu,
            new String[] {
              WorkspacePopupMenuBuilder.createSubMenu(
                  TextUtils.getRawText("workspace.action.new.label")),
              "workspace.action.node.new.folder",
              "workspace.action.file.new.mindmap",
              WorkspacePopupMenuBuilder.endSubMenu(),
              WorkspacePopupMenuBuilder.SEPARATOR,
              "workspace.action.node.open.location",
              WorkspacePopupMenuBuilder.SEPARATOR,
              "workspace.action.node.cut",
              "workspace.action.node.copy",
              "workspace.action.node.paste",
              WorkspacePopupMenuBuilder.SEPARATOR,
              "workspace.action.node.rename",
              "workspace.action.node.remove",
              "workspace.action.file.delete",
              WorkspacePopupMenuBuilder.SEPARATOR,
              "workspace.action.node.physical.sort",
              WorkspacePopupMenuBuilder.SEPARATOR,
              "workspace.action.node.refresh"
            });
      }
    }
  }
示例#10
0
  public void initializePopup() {
    if (popupMenu == null) {
      Controller controller = Controller.getCurrentController();
      controller.addAction(new DocearProjectEnableMonitoringAction());

      popupMenu = new WorkspacePopupMenu();
      WorkspacePopupMenuBuilder.addActions(
          popupMenu,
          new String[] {
            WorkspacePopupMenuBuilder.createSubMenu(
                TextUtils.getRawText("workspace.action.new.label")),
            "workspace.action.node.new.folder",
            "workspace.action.file.new.mindmap",
            // WorkspacePopupMenuBuilder.SEPARATOR,
            // "workspace.action.file.new.file",
            WorkspacePopupMenuBuilder.endSubMenu(),
            WorkspacePopupMenuBuilder.SEPARATOR,
            "workspace.action.docear.uri.change",
            "workspace.action.node.open.location",
            WorkspacePopupMenuBuilder.SEPARATOR,
            "workspace.action.node.cut",
            "workspace.action.node.copy",
            "workspace.action.node.paste",
            WorkspacePopupMenuBuilder.SEPARATOR,
            "workspace.action.node.rename",
            "workspace.action.node.remove",
            "workspace.action.file.delete",
            WorkspacePopupMenuBuilder.SEPARATOR,
            "workspace.action.node.physical.sort",
            WorkspacePopupMenuBuilder.SEPARATOR,
            // "workspace.action.docear.project.enable.monitoring",
            "workspace.action.node.refresh"
          });
    }
  }
示例#11
0
 public static List<String> getMenuPathElements(MenuBuilder menuBuilder, final String location) {
   final ArrayList<String> pathElements = new ArrayList<String>();
   final DefaultMutableTreeNode node = menuBuilder.get(location);
   if (node != null) {
     pathElements.addAll(getMenuPathElements(node));
   } else {
     int index = location.lastIndexOf('/');
     if (index != -1) {
       final String lastKey = location.substring(index + 1);
       pathElements.add(
           TextUtils.getText(lastKey, TextUtils.getText("addons." + lastKey, lastKey)));
       // recurse
       if (index > 1)
         pathElements.addAll(getMenuPathElements(menuBuilder, location.substring(0, index)));
     }
   }
   return pathElements;
 }
示例#12
0
 private void addStyleBox(final DefaultFormBuilder rightBuilder) {
   mStyleBox = uiFactory.createStyleBox();
   mSetStyle = new BooleanProperty(StyleEditorPanel.SET_RESOURCE);
   final StyleChangeListener listener = new StyleChangeListener();
   mSetStyle.addPropertyChangeListener(listener);
   mSetStyle.layout(rightBuilder);
   rightBuilder.append(new JLabel(TextUtils.getText("style")));
   rightBuilder.append(mStyleBox);
   rightBuilder.nextLine();
 }
示例#13
0
 public static String createDescription(
     final String attribute,
     final String simpleCondition,
     final String value,
     final boolean matchCase,
     final boolean matchApproximately) {
   final String description =
       attribute
           + " "
           + simpleCondition
           + (value != null ? " \"" + value + "\"" : "")
           + (matchCase && value != null
               ? ", " + TextUtils.getText(ConditionFactory.FILTER_MATCH_CASE)
               : "")
           + (matchApproximately && value != null
               ? ", " + TextUtils.getText(ConditionFactory.FILTER_MATCH_APPROX)
               : "");
   return description;
 }
示例#14
0
 private String formatMenuLocation(ScriptAddOnProperties.Script script) {
   final String location =
       script.menuLocation == null ? "main_menu_scripting" : script.menuLocation;
   MenuBuilder menuBuilder =
       Controller.getCurrentModeController().getUserInputListenerFactory().getMenuBuilder();
   // "/menu_bar/edit/menu_extensions" -> [Node Extensions, Edit]
   final List<String> pathElements = getMenuPathElements(menuBuilder, location);
   Collections.reverse(pathElements);
   pathElements.add(TextUtils.getText(script.menuTitleKey));
   return StringUtils.join(pathElements.iterator(), "->");
 }
 protected void setButtonText() {
   final String text =
       script.substring(0, Math.min(40, script.length())).trim().replaceAll("\\s+", " ");
   if (!text.equals("")) {
     showEditorBtn.setToolTipText(HtmlUtils.plainToHTML(script));
     showEditorBtn.setText(text);
   } else {
     final String title = TextUtils.getText("EditScript");
     showEditorBtn.setToolTipText(null);
     showEditorBtn.setText(title);
   }
 }
示例#16
0
 public void newAccelerator(final JMenuItem editedItem, final KeyStroke newAccelerator) {
   final Object key = menuBuilder.getKeyByUserObject(editedItem);
   final String shortcutKey = menuBuilder.getShortcutKey(key.toString());
   final String oldShortcut = ResourceController.getResourceController().getProperty(shortcutKey);
   if (newAccelerator == null
       || !new KeystrokeValidator(editedItem, key, editedItem)
           .isValid(newAccelerator, newAccelerator.getKeyChar())) {
     final GrabKeyDialog grabKeyDialog = new GrabKeyDialog(oldShortcut);
     final IKeystrokeValidator validator = new KeystrokeValidator(grabKeyDialog, key, editedItem);
     grabKeyDialog.setValidator(validator);
     grabKeyDialog.setVisible(true);
     if (grabKeyDialog.isOK()) {
       final String shortcut = grabKeyDialog.getShortcut();
       final KeyStroke accelerator = UITools.getKeyStroke(shortcut);
       menuBuilder.setAccelerator((Node) menuBuilder.get(key), accelerator);
       ResourceController.getResourceController().setProperty(shortcutKey, shortcut);
       LogUtils.info(
           "created shortcut '"
               + shortcut
               + "' for menuitem '"
               + key
               + "', shortcutKey '"
               + shortcutKey
               + "' ("
               + editedItem.getText()
               + ")");
     }
   } else {
     if (oldShortcut != null) {
       final int replace =
           JOptionPane.showConfirmDialog(
               editedItem,
               oldShortcut,
               TextUtils.getText("remove_shortcut_question"),
               JOptionPane.YES_NO_OPTION);
       if (replace != JOptionPane.YES_OPTION) {
         return;
       }
     }
     menuBuilder.setAccelerator((Node) menuBuilder.get(key), newAccelerator);
     ResourceController.getResourceController().setProperty(shortcutKey, toString(newAccelerator));
     LogUtils.info(
         "created shortcut '"
             + toString(newAccelerator)
             + "' for menuitem '"
             + key
             + "', shortcutKey '"
             + shortcutKey
             + "' ("
             + editedItem.getText()
             + ")");
   }
 }
示例#17
0
 static void setNewAcceleratorOnNextClick(KeyStroke accelerator) {
   if (AccelerateableAction.isNewAcceleratorOnNextClickEnabled()) {
     return;
   }
   acceleratorForNextClickedAction = accelerator;
   String title = TextUtils.getText("SetAccelerator.dialogTitle");
   String text = TextUtils.getText(SET_ACCELERATOR_ON_NEXT_CLICK_ACTION);
   if (accelerator != null)
     text =
         TextUtils.format("SetAccelerator.keystrokeDetected", toString(accelerator)) + "\n" + text;
   final Frame frame = Controller.getCurrentController().getViewController().getFrame();
   setAcceleratorOnNextClickActionDialog = UITools.createCancelDialog(frame, title, text);
   getAcceleratorOnNextClickActionDialog()
       .addComponentListener(
           new ComponentAdapter() {
             @Override
             public void componentHidden(final ComponentEvent e) {
               setAcceleratorOnNextClickActionDialog = null;
               acceleratorForNextClickedAction = null;
             }
           });
   getAcceleratorOnNextClickActionDialog().setVisible(true);
 }
示例#18
0
 public void safeOpen(final String restoreable) {
   try {
     open(restoreable);
   } catch (final Exception ex) {
     LogUtils.warn(ex);
     final String message = TextUtils.format("remove_file_from_list_on_error", restoreable);
     UITools.showFrame();
     final Frame frame = UITools.getFrame();
     final int remove =
         JOptionPane.showConfirmDialog(frame, message, "Freeplane", JOptionPane.YES_NO_OPTION);
     if (remove == JOptionPane.YES_OPTION) {
       remove(restoreable);
     }
   }
 }
示例#19
0
  private JButton addStyleButton(
      DefaultFormBuilder rightBuilder, String label, AFreeplaneAction action) {
    final JButton button =
        new JButton() {
          private static final long serialVersionUID = 1L;

          {
            setUI(BasicButtonUI.createUI(this));
          }
        };
    button.addActionListener(action);
    button.setHorizontalAlignment(SwingConstants.LEFT);
    final String labelText = TextUtils.getText(label);
    UITools.addTitledBorder(button, labelText, 10);
    rightBuilder.append(button, rightBuilder.getColumnCount());
    rightBuilder.nextLine();
    return button;
  }
示例#20
0
 public boolean isValid(final KeyStroke keystroke, final Character keyChar) {
   if (keystroke == null) {
     return true;
   }
   final Node menuBarNode = menuBuilder.getMenuBar(menuBuilder.get(key));
   if (menuBarNode == null) {
     return true;
   }
   if (keyChar != KeyEvent.CHAR_UNDEFINED
       && (keystroke.getModifiers() & (Event.ALT_MASK | Event.CTRL_MASK | Event.META_MASK))
           == 0) {
     final String keyTypeActionString =
         ResourceController.getResourceController()
             .getProperty("key_type_action", FirstAction.EDIT_CURRENT.toString());
     FirstAction keyTypeAction = FirstAction.valueOf(keyTypeActionString);
     return FirstAction.IGNORE.equals(keyTypeAction);
   }
   if ((keystroke.getModifiers() & (Event.ALT_MASK | Event.CTRL_MASK | Event.META_MASK))
       == Event.ALT_MASK) {
     final JMenuBar menuBar = (JMenuBar) menuBarNode.getUserObject();
     final int menuCount = menuBar.getMenuCount();
     for (int i = 0; i < menuCount; i++) {
       final JMenu menu = menuBar.getMenu(i);
       final char c = (char) menu.getMnemonic();
       if (Character.toLowerCase(keystroke.getKeyCode()) == Character.toLowerCase(c)) {
         JOptionPane.showMessageDialog(
             parentComponent,
             menu.getText(),
             TextUtils.getText("used_in_menu"),
             JOptionPane.WARNING_MESSAGE);
         return false;
       }
     }
   }
   if (!checkForOverwriteShortcut(menuBarNode, keystroke)) {
     return false;
   }
   final KeyStroke derivedKS = FreeplaneMenuBar.derive(keystroke, keyChar);
   if (derivedKS == keystroke) {
     return true;
   }
   return checkForOverwriteShortcut(menuBarNode, derivedKS);
 }
 public void actionPerformed(ActionEvent e) {
   PopupFactory popupFactory = PopupFactory.getSharedInstance();
   JToolTip tip = new JToolTip();
   tip.setTipText(TextUtils.getText("docear.monitoring.reload.name"));
   final Point locationOnScreen = comp.getLocationOnScreen();
   final int height = comp.getHeight();
   Rectangle sBounds = comp.getGraphicsConfiguration().getBounds();
   final int minX = sBounds.x;
   final int maxX = sBounds.x + sBounds.width;
   final int minY = sBounds.y;
   final int maxY = sBounds.y + sBounds.height;
   int x = locationOnScreen.x;
   int y = locationOnScreen.y + height;
   final Dimension tipSize = tip.getPreferredSize();
   final int tipWidth = tipSize.width;
   if (x + tipWidth > maxX) {
     x = maxX - tipWidth;
   }
   if (x < minX) {
     x = minX;
   }
   final int tipHeight = tipSize.height;
   if (y + tipHeight > maxY) {
     if (locationOnScreen.y - tipHeight > minY) {
       y = locationOnScreen.y - tipHeight;
     } else {
       y = maxY - tipHeight;
     }
   }
   if (y < minY) {
     y = minY;
   }
   final Popup tipPopup = popupFactory.getPopup(comp, tip, x, y);
   tipPopup.show();
   showTimer.removeActionListener(this);
   hideTimer.addActionListener(new HideToolTipAction(tipPopup, tip, comp));
   hideTimer.start();
 }
示例#22
0
 private JComponent createDetails(final AddOnProperties addOn) {
   final StringBuilder text = new StringBuilder(1024);
   text.append("<html><body>");
   text.append(toHtml(addOn.getDescription()));
   text.append("<p>");
   if (addOn instanceof ScriptAddOnProperties) {
     List<Script> scripts = ((ScriptAddOnProperties) addOn).getScripts();
     if (!scripts.isEmpty()) {
       text.append("<table border='1'>");
       text.append(
           row(
               "th",
               getText("header.function"),
               getText("header.menu"),
               getText("header.shortcut")));
       for (ScriptAddOnProperties.Script script : scripts) {
         text.append(
             row(
                 "td",
                 bold(TextUtils.getText(script.menuTitleKey)),
                 formatMenuLocation(script),
                 formatShortcut(script)));
       }
       text.append("</table>");
     }
   }
   if (warning != null) {
     text.append("<p><p>");
     text.append(warning.replaceAll("</?(html|body)>", ""));
   }
   text.append("</body></html>");
   final JLabel label = new JLabel(text.toString());
   final ImageIcon icon =
       IconNotFound.createIconOrReturnNull(addOn.getName() + "-screenshot-1.png");
   if (icon != null) label.setIcon(icon);
   return label;
 }
 private void addMenuItem(
     final MenuBuilder menuBuilder,
     final String location,
     final Entry<String, String> entry,
     final ExecutionMode executionMode,
     final String titleKey,
     ScriptMetaData metaData) {
   final String scriptName = entry.getKey();
   final String translation = TextUtils.getText(titleKey, titleKey.replace('_', ' '));
   final String menuName =
       translation.contains("{0}")
           ? MessageFormat.format(translation, pimpMenuTitle(scriptName))
           : translation;
   menuBuilder.addAction(
       location,
       new ExecuteScriptAction(
           scriptName,
           menuName,
           entry.getValue(),
           executionMode,
           metaData.cacheContent(),
           metaData.getPermissions()),
       MenuBuilder.AS_CHILD);
 }
示例#24
0
 private final void doUpdateLinks() {
   MindmapUpdateController mindmapUpdateController = new MindmapUpdateController();
   mindmapUpdateController.addMindmapUpdater(
       new MindmapLinkTypeUpdater(TextUtils.getText("updating_link_types")));
   mindmapUpdateController.updateRegisteredMindmapsInWorkspace(true);
 }
示例#25
0
 private String formatErrors(String key, ArrayList<String> errors) {
   // TextUtils.format() xml escapes the format arguments - we don't want that
   final MessageFormat formatter = new MessageFormat(TextUtils.getText(key));
   return formatter.format(new Object[] {StringUtils.join(errors.iterator(), "<br>")});
 }
示例#26
0
 public void buildPanel(final DefaultMutableTreeNode controlsTree) {
   final FormLayout leftLayout = new FormLayout("max(80dlu;p):grow", "");
   final DefaultFormBuilder leftBuilder = new DefaultFormBuilder(leftLayout);
   final CardLayout cardLayout = new VariableSizeCardLayout();
   final JPanel rightStack = new JPanel(cardLayout);
   FormLayout rightLayout = null;
   DefaultFormBuilder rightBuilder = null;
   String lastTabName = null;
   initControls(controlsTree);
   final Iterator<IPropertyControl> iterator = controls.iterator();
   // MaG:
   Controller.getCurrentController()
       .getOptionPanelController()
       .setCurrentPropertyControls(controls);
   while (iterator.hasNext()) {
     final IPropertyControl control = iterator.next();
     if (control instanceof TabProperty) {
       final TabProperty newTab = (TabProperty) control;
       if (rightBuilder != null) {
         rightStack.add(rightBuilder.getPanel(), lastTabName);
       }
       rightLayout = new FormLayout(newTab.getDescription(), "");
       rightBuilder = new DefaultFormBuilder(rightLayout);
       rightBuilder.setDefaultDialogBorder();
       lastTabName = newTab.getLabel();
       final JButton tabButton = new JButton(TextUtils.getOptionalText(lastTabName));
       final ChangeTabAction changeTabAction =
           new ChangeTabAction(cardLayout, rightStack, lastTabName);
       tabButton.addActionListener(changeTabAction);
       registerTabButton(tabButton, lastTabName, changeTabAction);
       leftBuilder.append(tabButton);
     } else {
       control.layout(rightBuilder);
     }
   }
   rightStack.add(rightBuilder.getPanel(), lastTabName);
   if (selectedPanel != null && tabActionMap.containsKey(selectedPanel)) {
     (tabActionMap.get(selectedPanel)).actionPerformed(null);
   }
   final JScrollPane rightComponent = new JScrollPane(rightStack);
   UITools.setScrollbarIncrement(rightComponent);
   final JSplitPane centralPanel =
       new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftBuilder.getPanel(), rightComponent);
   topDialog.getContentPane().add(centralPanel, BorderLayout.CENTER);
   final JButton cancelButton = new JButton();
   MenuBuilder.setLabelAndMnemonic(cancelButton, TextUtils.getRawText("cancel"));
   cancelButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(final ActionEvent arg0) {
           closeWindow();
         }
       });
   final JButton okButton = new JButton();
   MenuBuilder.setLabelAndMnemonic(okButton, TextUtils.getRawText("ok"));
   okButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(final ActionEvent arg0) {
           if (validate()) {
             closeWindow();
             feedback.writeProperties(getOptionProperties());
           }
         }
       });
   topDialog.getRootPane().setDefaultButton(okButton);
   topDialog
       .getContentPane()
       .add(ButtonBarFactory.buildOKCancelBar(cancelButton, okButton), BorderLayout.SOUTH);
 }
示例#27
0
 private static String getText(String key, Object... parameters) {
   if (parameters.length == 0) return TextUtils.getRawText(getResourceKey(key));
   else return TextUtils.format(getResourceKey(key), parameters);
 }
 // location might be something like /menu_bar/edit/editGoodies
 private String getMenuTitle(final String location) {
   int index = location.lastIndexOf('/');
   final String lastKey = location.substring(index + 1);
   return TextUtils.getText(lastKey, TextUtils.getText("addons." + lastKey, lastKey));
 }
 /** menuTitle may either be a scriptName or a translation key. */
 private String pimpMenuTitle(final String menuTitle) {
   final String translation = TextUtils.getText(menuTitle, null);
   // convert CamelCase to Camel Case
   return translation != null ? translation : menuTitle.replaceAll("([a-z])([A-Z])", "$1 $2");
 }
 public ListModel getFilteredProperties() {
   final DefaultListModel list = new DefaultListModel();
   list.addElement(TextUtils.createTranslatedString(NodeLevelConditionController.FILTER_LEVEL));
   return list;
 }