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());
  }
 @Override
 public void saveProperties() {
   lastOpened.saveProperties();
   OutputStream out = null;
   try {
     out = new FileOutputStream(autoPropertiesFile);
     final OutputStreamWriter outputStreamWriter = new OutputStreamWriter(out, "8859_1");
     outputStreamWriter.write("#Freeplane ");
     outputStreamWriter.write(FreeplaneVersion.getVersion().toString());
     outputStreamWriter.write('\n');
     outputStreamWriter.flush();
     props.store(out, null);
   } catch (final Exception ex) {
   } finally {
     if (out != null) {
       try {
         out.close();
       } catch (final IOException e) {
       }
     }
   }
   FilterController.getCurrentFilterController().saveConditions();
 }
Example #3
0
  @SuppressWarnings("serial")
  @Override
  public void init() {
    try {
      appletLock.lock();
      appletResourceController = new AppletResourceController(this);
      if (appletResourceController == null) {
        appletResourceController = new AppletResourceController(this);
      }
      new ParserDelegator() {
        {
          setDefaultDTD();
        }
      };
      updateLookAndFeel();
      createRootPane();
      controller = new Controller(appletResourceController);
      appletResourceController.init();
      Controller.setCurrentController(controller);
      final Container contentPane = getContentPane();
      contentPane.setLayout(new BorderLayout());
      MapViewController mapViewController = new MapViewController(controller);
      appletViewController = new AppletViewController(this, controller, mapViewController);
      controller.addAction(new ViewLayoutTypeAction(MapViewLayout.OUTLINE));
      FilterController.install();
      PrintController.install();
      HelpController.install();
      NodeHistory.install(controller);
      FormatController.install(new FormatController());
      ModelessAttributeController.install();
      TextController.install();
      MapController.install();

      TimeController.install();
      LinkController.install();
      IconController.install();
      FilterController.getCurrentFilterController()
          .getConditionFactory()
          .addConditionController(7, new LogicalStyleFilterController());
      final BModeController browseController = BModeControllerFactory.createModeController();
      final Set<String> emptySet = Collections.emptySet();
      FilterController.getController(controller).loadDefaultConditions();
      browseController.updateMenus("/xml/appletMenu.xml", emptySet);
      controller.addAction(new ShowSelectionAsRectangleAction());
      controller.addAction(new NextNodeAction(Direction.FORWARD));
      controller.addAction(new NextNodeAction(Direction.BACK));
      controller.addAction(new NextPresentationItemAction());
      controller.selectMode(browseController);
      appletResourceController.setPropertyByParameter(this, "browsemode_initial_map");
      appletViewController.init(controller);
      final GlassPane glassPane = new GlassPane();
      setGlassPane(glassPane);
      glassPane.setVisible(true);
      controller.getViewController().setMenubarVisible(false);
    } catch (RuntimeException e) {
      e.printStackTrace();
      throw e;
    } finally {
      appletLock.unlock();
    }
  }