Exemplo n.º 1
0
  /**
   * This function is called when an observable notify the AppFrame
   *
   * @param o an observable
   * @param arg the arg of the observable
   */
  @Override
  public void update(Observable o, Object arg) {
    this.toolsMenuItems.clear();
    this.tools.removeAll();

    /*
       TODO: En 2 observers
       1 pour ajouter
       1 pour supprimer
    */

    for (File f : this.pluginFinder.getFoundFiles()) {
      final Plugin plugin = this.createPlugin(f);
      JMenuItem toolsMenuItem = new JMenuItem();
      toolsMenuItem.setText(plugin.getDescription());
      toolsMenuItem.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              textArea.setText(plugin.doAction(textArea.getText()));
            }
          });
      this.toolsMenuItems.add(toolsMenuItem);
      this.tools.add(toolsMenuItem);
    }
  }
 /* (non-Javadoc)
  * @see model.observer.Observer#update(model.observer.Observable, java.lang.Object)
  */
 @Override
 public void update(Observable<List<Plugin>> source, List<Plugin> newPlugins) {
   menuBar.removePluginsMenu();
   System.out.println("Modifications in plugins folder !");
   for (Plugin plugin : newPlugins) {
     menuBar.createMenu(plugin);
     System.out.println("Added " + plugin.getLabel());
   }
 }
Exemplo n.º 3
0
 /**
  * method update will update the list of items of the tools menu with the list of plugins found by
  * the finder
  *
  * @param finderPlugins
  */
 public void update(ArrayList<Plugin> finderPlugins) {
   this.removeAll();
   for (Plugin p : finderPlugins) {
     final Plugin plugAdd = p;
     JMenuItem plug = new JMenuItem(p.getLabel());
     plug.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent event) {
             transformTextArea(plugAdd);
           }
         });
     this.add(plug);
   }
 }
Exemplo n.º 4
0
 /**
  * method transformTextArea(Plugin plugin) : use the method transform(String s) of the plugin in
  * parameter
  *
  * @param plugin the plugin will apply his transform method
  */
 public void transformTextArea(Plugin plugin) {
   this.textArea.setText(plugin.transform(this.textArea.getText()));
 }