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);
  }
 /**
  * Creates a reader that pipes the input file through a XSLT-Script that updates the version to
  * the current.
  *
  * @throws IOException
  */
 public Reader getUpdateReader(final File file, final String xsltScript)
     throws FileNotFoundException, IOException {
   try {
     String updatedXml = transform(file, xsltScript);
     return new StringReader(updatedXml);
   } catch (final Exception ex) {
     final String message = ex.getMessage();
     UITools.errorMessage(TextUtils.format("update_failed", String.valueOf(message)));
     LogUtils.warn(ex);
     final InputStream input = new BufferedInputStream(new FileInputStream(file));
     return getActualReader(input);
   }
 }
示例#3
0
 private boolean validate() {
   final Properties properties = getOptionProperties();
   final ValidationResult result = new ValidationResult();
   for (IValidator validator : Controller.getCurrentController().getOptionValidators()) {
     result.add(validator.validate(properties));
   }
   if (!result.isValid()) {
     UITools.errorMessage(formatErrors("OptionPanel.validation_error", result.getErrors()));
     LogUtils.severe(result.toString());
   } else if (result.hasWarnings()) {
     UITools.informationMessage(
         formatErrors("OptionPanel.validation_warning", result.getWarnings()));
     LogUtils.warn(result.toString());
   }
   return result.isValid();
 }
示例#4
0
 public static void executeMenuItems(final List<String> menuItemKeys) {
   LogUtils.info("menu items to execute: " + menuItemKeys);
   final MenuBuilder menuBuilder = getMenuBuilder();
   for (String menuItemKey : menuItemKeys) {
     final DefaultMutableTreeNode treeNode = menuBuilder.get(menuItemKey);
     if (treeNode == null
         || !treeNode.isLeaf()
         || !(treeNode.getUserObject() instanceof JMenuItem)) {
       UITools.errorMessage(TextUtils.format("MenuUtils.invalid_menuitem", menuItemKey));
       return;
     }
     final JMenuItem menuItem = (JMenuItem) treeNode.getUserObject();
     final Action action = menuItem.getAction();
     LogUtils.info("executing " + menuItem.getText() + "(" + menuItemKey + ")");
     ActionEvent e = new ActionEvent(menuItem, 0, null);
     action.actionPerformed(e);
   }
 }