public void dispose() {
    getSite()
        .getWorkbenchWindow()
        .getSelectionService()
        .removePostSelectionListener(getSelectionServiceListener());
    if (fDoubleClickProvider != null) {
      getTreeViewer().removeDoubleClickListener(fDoubleClickProvider);
    }

    // dispose menu controls
    if (fContextMenu != null) {
      fContextMenu.dispose();
    }
    if (fContextMenuManager != null) {
      fContextMenuManager.removeMenuListener(fGroupAdder);
      fContextMenuManager.removeAll();
      fContextMenuManager.dispose();
    }

    fDropTarget.dispose();
    fDragSource.dispose();

    IStatusLineManager statusLineManager = getSite().getActionBars().getStatusLineManager();
    if (statusLineManager != null) {
      statusLineManager.setMessage(null);
    }
    unconfigure();
    super.dispose();
  }
Esempio n. 2
0
 @Override
 public Menu getMenu(Control parent) {
   if (menu != null) {
     menu.dispose();
   }
   Menu newMenu = new Menu(parent);
   List<String> preferenceConfigurations =
       PrologRuntimeUIPlugin.getDefault().getPreferenceConfigurations();
   String defaultConfiguration =
       PrologRuntimeUIPlugin.getDefault()
           .getPreferenceStore()
           .getString(PrologRuntimeUI.PREF_CONFIGURATION);
   for (String preferenceConfiguration : preferenceConfigurations) {
     MenuItem item = new MenuItem(newMenu, SWT.NONE);
     item.setText(preferenceConfiguration.replaceAll("&", "&&"));
     if (preferenceConfiguration.equals(defaultConfiguration)) {
       item.setImage(ImageRepository.getImage(ImageRepository.NEW_PROCESS));
     }
     final String configuration = preferenceConfiguration;
     item.addSelectionListener(
         new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
             askForNameAndCreateProcess(configuration);
           }
         });
   }
   menu = newMenu;
   return menu;
 }
  private void showStandaloneViewMenu(
      ExecutionEvent event, MPart model, MMenu menuModel, Composite partContainer) {
    Shell shell = partContainer.getShell();
    Menu menu = (Menu) menuModel.getWidget();
    if (menu == null) {
      IPresentationEngine engine =
          (IPresentationEngine) HandlerUtil.getVariable(event, IPresentationEngine.class.getName());
      menu = (Menu) engine.createGui(menuModel, shell, model.getContext());
      if (menu != null) {
        final Menu tmpMenu = menu;
        partContainer.addDisposeListener(
            new DisposeListener() {
              public void widgetDisposed(DisposeEvent e) {
                tmpMenu.dispose();
              }
            });
      }
    }

    Display display = menu.getDisplay();
    Point location = display.map(partContainer, null, partContainer.getLocation());
    Point size = partContainer.getSize();
    menu.setLocation(location.x + size.x, location.y);
    menu.setVisible(true);

    while (!menu.isDisposed() && menu.isVisible()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    if (!(menu.getData() instanceof MenuManager)) {
      menu.dispose();
    }
  }
  /** {@inheritDoc} */
  public Menu getMenu(final Control parent) {
    if (manager == null) {
      manager = new MenuManager();
    }
    Menu menu = manager.getMenu();
    if (menu != null) {
      menu.dispose();
      menu = null;
    }
    manager.removeAll();
    menu = manager.createContextMenu(parent);
    IAction removeAction =
        new Action(
            "Remove Section Set",
            Activator.imageDescriptorFromPlugin(Activator.ID, "/icons/delete.gif")) {

          /** {@inheritDoc} */
          @Override
          public void run() {
            // remove this section descriptor set state from its parent
            sectionSetDescriptorStates.remove(getSectionSetDescriptorState());
            metamodelViewer.refresh();
          }
        };
    manager.add(removeAction);
    manager.add(new Separator(ADD_GROUP));

    return menu;
  }
  public Menu getMenu(Control parent) {
    if (fMenu != null) {
      fMenu.dispose();
    }

    fMenu = new Menu(parent);
    for (int i = 0; i < LOG_LEVEL_MESSAGES.length; i++) {
      final int logLevel = i;
      Action action =
          new Action(LOG_LEVEL_MESSAGES[i]) {
            public void run() {
              console.setLogLevel(logLevel);
            }
          };
      action.setChecked(console.getLogLevel() == i);
      addActionToMenu(fMenu, action);
    }
    new Separator().fill(fMenu, -1);
    for (int i = 0; i < LOG_LEVEL_MESSAGES.length; i++) {
      final int logLevel = i;
      Action action =
          new Action("IvyDE " + LOG_LEVEL_MESSAGES[i]) {
            public void run() {
              console.getIvyDEMessageLogger().setLogLevel(logLevel);
            }
          };
      action.setChecked(console.getIvyDEMessageLogger().getLogLevel() == i);
      addActionToMenu(fMenu, action);
    }
    return fMenu;
  }
Esempio n. 6
0
 @Override
 public void dispose() {
   if (fMenu != null) {
     fMenu.dispose();
     fMenu = null;
   }
 }
 public Menu getMenu(Control parent) {
   if (lastMenu != null) {
     lastMenu.dispose();
   }
   lastMenu = new Menu(parent);
   createEntries(lastMenu);
   return lastMenu;
 }
Esempio n. 8
0
  private void widgetDisposed() {
    if (store != null) store.updateActive(serialize());
    else preferences.setValue(identifier, serialize());

    if (contextMenu != null) contextMenu.dispose();

    if (store != null) store.dispose();
  }
 /** {@inheritDoc} */
 public void dispose() {
   if (manager != null) {
     Menu menu = manager.getMenu();
     if (menu != null) {
       menu.dispose();
       menu = null;
     }
   }
 }
 @Override
 public void dispose() {
   endCharCaret.dispose();
   cutItem.dispose();
   copyItem.dispose();
   pasteItem.dispose();
   selectAllItem.dispose();
   contextMenu.dispose();
 }
Esempio n. 11
0
  @Override
  public void dispose() {
    super.dispose();
    Workspace.getInstance().uninstallResourceListener(m_listener);

    if (fMenu != null && !fMenu.isDisposed()) {
      fMenu.dispose();
      fMenu = null;
    }
  }
 @Override
 public void dispose() {
   super.dispose();
   if (popupMenu != null) {
     popupMenu.dispose();
     popupMenu = null;
   }
   if (manager != null) {
     manager.dispose();
     manager = null;
   }
 }
Esempio n. 13
0
  @Override
  public Menu getMenu(Menu parent) {
    if (fMenu != null) fMenu.dispose();

    fMenu = new Menu(parent);

    for (IAction action : actions) {
      addActionToMenu(fMenu, action);
    }
    for (int i = 0; i < iSeparator; i++) addSeparatorToMenu(fMenu, i);
    return fMenu;
  }
  private void attachContextMenu(final Table table) {
    MenuManager menuMgr = new MenuManager("#PopupMenu"); // $NON-NLS-1$
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(manager -> showContextMenu(manager));

    final Menu contextMenu = menuMgr.createContextMenu(table.getShell());
    table.setMenu(contextMenu);

    table.addDisposeListener(
        e -> {
          if (contextMenu != null && !contextMenu.isDisposed()) contextMenu.dispose();
        });
  }
 private void disposeToolItems() {
   for (int i = 0; i < toolItemList.size(); i++) {
     ToolItem item = (ToolItem) toolItemList.get(i);
     if (!item.isDisposed()) {
       Object data = item.getData();
       if (data != null && data instanceof Menu) {
         Menu menu = (Menu) data;
         if (!menu.isDisposed()) {
           menu.dispose();
         }
       }
       item.dispose();
     }
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.jface.action.IMenuCreator#dispose()
  */
 public void dispose() {
   if (dropDownMenuMgr != null) {
     dropDownMenuMgr.dispose();
     dropDownMenuMgr = null;
   }
   if (menus.size() > 0) {
     for (Iterator i = menus.iterator(); i.hasNext(); ) {
       Menu m = (Menu) i.next();
       if (!m.isDisposed()) {
         m.dispose();
       }
     }
     menus.clear();
   }
 }
  public Menu getMenu(Control parent) {
    if (menu != null) {
      menu.dispose();
      menu = null;
    }

    for (Alias alias : SQLExplorerPlugin.getDefault().getAliasManager().getAliases())
      for (User user : alias.getUsers()) {
        if (menu == null) menu = new Menu(parent);
        NewConnection action = new NewConnection(user);
        addActionToMenu(menu, action);
      }

    return menu;
  }
Esempio n. 18
0
  /**
   * Create the help menu.
   *
   * @param header the header from which the menu hangs
   */
  private void createHelpMenu(final MenuItem header) {
    if (helpMenu != null) {
      helpMenu.dispose();
    }
    helpMenu = new Menu(shell, SWT.DROP_DOWN);
    MenuItem helpAboutItem = new MenuItem(helpMenu, SWT.PUSH);
    helpAboutItem.setText("&About");

    helpAboutItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            new AboutShell();
          }
        });

    helpMenuHeader.setMenu(helpMenu);
  }
 public Menu getMenu(Control parent) {
   if (menu != null) {
     menu.dispose();
   }
   menu = new Menu(parent);
   Collection<String> availableItems = getAvailableItems();
   for (final String menuItemId : availableItems) {
     MenuItem menuItem = new MenuItem(menu, getMenuStyle());
     menuItem.setText(getDisplayName(menuItemId));
     menuItem.setSelection(getSelection(menuItemId));
     menuItem.addSelectionListener(
         new SelectionAdapter() {
           public void widgetSelected(SelectionEvent e) {
             handleSelection(menuItemId);
           }
         });
   }
   return menu;
 }
Esempio n. 20
0
  /**
   * Create the options menu.
   *
   * @param header the header from which the menu hangs
   */
  private void createOptionsMenu(final MenuItem header) {
    if (optionsMenu != null) {
      optionsMenu.dispose();
    }

    optionsMenu = new Menu(shell, SWT.DROP_DOWN);

    MenuItem viewShowPathItem = new MenuItem(optionsMenu, SWT.CHECK);
    viewShowPathItem.setText("&Show agent's path\tCTRL+P");
    viewShowPathItem.setAccelerator(SWT.CTRL + 'P');
    viewShowPathItem.setSelection(true);
    viewShowPathItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            gui.setPathShown(!gui.isPathShown());
          }
        });

    MenuItem simulateNightItem = new MenuItem(optionsMenu, SWT.CHECK);
    simulateNightItem.setText("Simulate &night");
    simulateNightItem.setSelection(gui.isNightSimulated());
    simulateNightItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            gui.simulateNight(((MenuItem) e.getSource()).getSelection());
          }
        });

    new MenuItem(optionsMenu, SWT.SEPARATOR);

    MenuItem toolsOptionsItem = new MenuItem(optionsMenu, SWT.PUSH);
    toolsOptionsItem.setText("Con&figuration\tCtrl+T");
    toolsOptionsItem.setAccelerator(SWT.CTRL + 'T');
    toolsOptionsItem.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent e) {
            new ConfigShell(siafuConfig);
          }
        });

    optionsMenuHeader.setMenu(optionsMenu);
  }
Esempio n. 21
0
  /** {@inheritDoc} */
  public void run() {
    Display display = Display.getCurrent();
    if (display == null) return;
    Control focus = display.getFocusControl();
    if (focus == null || focus.isDisposed()) return;

    MenuManager menu = new MenuManager();
    fillMenu(menu);
    final Menu widget = menu.createContextMenu(focus.getShell());
    Point location = computeMenuLocation(focus, widget);
    if (location == null) return;
    widget.setLocation(location);
    widget.setVisible(true);
    while (!widget.isDisposed() && widget.isVisible()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    if (!widget.isDisposed()) {
      widget.dispose();
    }
  }
  /**
   * Disposes of this menu manager and frees all allocated SWT resources. Notifies all contribution
   * items of the dispose. Note that this method does not clean up references between this menu
   * manager and its associated contribution items. Use <code>removeAll</code> for that purpose.
   */
  public void dispose() {
    if (menuExist()) {
      menu.dispose();
    }
    menu = null;

    if (menuItem != null) {
      menuItem.dispose();
      menuItem = null;
    }

    disposeOldImages();

    IContributionItem[] items = getItems();
    for (int i = 0; i < items.length; i++) {
      items[i].dispose();
    }

    markDirty();
  }
Esempio n. 23
0
 @Override
 public void dispose() {
   PrologConsolePlugin.getDefault().getPrologConsoleService().unregisterPrologConsole(this);
   PrologRuntimeUIPlugin.getDefault()
       .getPrologInterfaceService()
       .unRegisterActivePrologInterfaceListener(this);
   for (Iterator<PrologInterface> it = models.keySet().iterator(); it.hasNext(); ) {
     PrologInterface pif = it.next();
     try {
       disconnect(pif);
       removeHooks(pif);
     } catch (Throwable e) {
       Debug.report(e);
     }
   }
   models.clear();
   contextMenu.dispose();
   // viewer.getControl().dispose();
   super.dispose();
 }
Esempio n. 24
0
    public Menu getMenu(Control parent) {
      if (fMenu != null) {
        fMenu.dispose();
      }

      final MenuManager manager = new MenuManager();
      manager.setRemoveAllWhenShown(true);
      manager.addMenuListener(
          new IMenuListener() {
            public void menuAboutToShow(final IMenuManager manager2) {
              fillMenuManager(
                  new IActionsMenu() {

                    public void add(IAction action) {
                      manager2.add(action);
                    }
                  });
            }
          });
      fMenu = manager.createContextMenu(parent);

      return fMenu;
    }
  @Override
  public void dispose() {
    if (composite != null && !composite.isDisposed()) {
      composite.dispose();
    }
    composite = null;

    if (menuManager != null) {
      menuManager.removeAll();
      menuManager.dispose();
    }
    menuManager = null;

    if (menu != null && !menu.isDisposed()) {
      menu.dispose();
    }
    menu = null;

    actionGroup.setSelectionProvider(null);

    TasksUi.getTaskActivityManager().removeActivationListener(taskActivationListener);
    TasksUiPlugin.getTaskList().removeChangeListener(taskListListener);
  }
  /**
   * Create the popoup menu about all the exporters. If the menu is already build this method do
   * nothing.
   */
  private void createPopupMenu() {

    if (popupMenu != null && !popupMenu.isDisposed()) popupMenu.dispose();

    manager = new MenuManager();
    ActionRegistry registry = new ActionRegistry();
    // Create the PDF decorator
    PDF508ElementDecorator pdfDecorator = new PDF508ElementDecorator();
    IWorkbenchPart activePart = getWorkbenchPart();
    pdfDecorator.registerActions(registry, new ArrayList<String>(), activePart);
    pdfDecorator.fillContextMenu(registry, manager);
    // Create the XLS decorator
    XLSElementDecorator xlsDecorator = new XLSElementDecorator();
    xlsDecorator.registerActions(registry, new ArrayList<String>(), activePart);
    xlsDecorator.fillContextMenu(registry, manager);
    // Create the CSV action
    CSVElementDecorator csvDecorator = new CSVElementDecorator();
    csvDecorator.registerActions(registry, new ArrayList<String>(), activePart);
    ISelection actualSelection = getLastRawSelection();
    csvDecorator.fillContextMenu(registry, manager, (IStructuredSelection) actualSelection);
    popupMenu = new Menu(Display.getCurrent().getActiveShell());
    createMenu(popupMenu, manager.getItems());
  }
 public void dispose() {
   if (menu != null) {
     menu.dispose();
   }
 }
Esempio n. 28
0
 public void dispose() {
   if (fMenu != null) {
     fMenu.dispose();
   }
 }
 public void dispose() {
   if (menu != null && !menu.isDisposed()) {
     menu.dispose();
     menu = null;
   }
 }
 public void dispose() {
   if (lastMenu != null) {
     lastMenu.dispose();
     lastMenu = null;
   }
 }