Esempio n. 1
0
 /** Register the context menu for the viewer so that commands may be added to it. */
 private void registerContextMenu() {
   MenuManager contextMenu = new MenuManager();
   contextMenu.setRemoveAllWhenShown(true);
   getSite().registerContextMenu(contextMenu, mViewer);
   Control control = mViewer.getControl();
   Menu menu = contextMenu.createContextMenu(control);
   control.setMenu(menu);
 }
 protected void initContextMenu(Control control) {
   MenuManager menuManager = createMenuManager();
   Menu contextMenu = menuManager.createContextMenu(control);
   control.setMenu(contextMenu);
   IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   IWorkbenchPartSite site = window.getActivePage().getActivePart().getSite();
   site.registerContextMenu(CONTEXTMENUID, menuManager, site.getSelectionProvider());
 }
Esempio n. 3
0
 /** Removes all widgets from the content pane. */
 private void removeAllWidgets() {
   Control[] childs = connectors.getChildren();
   for (Control control : childs) {
     control.setMenu(null);
     control.dispose();
   }
   reloadPrefrences();
 }
Esempio n. 4
0
 private static void setMenu(Control c, Menu ma) {
   if (c instanceof Composite) {
     for (final Control cc : ((Composite) c).getChildren()) {
       setMenu(cc, ma);
     }
   }
   c.setMenu(ma);
 }
 private void createRulerContextMenu() {
   String id = getRulerContextMenuId();
   fRulerMenuManager = new MenuManager(id, id);
   fRulerMenuManager.setRemoveAllWhenShown(true);
   fRulerMenuManager.addMenuListener(getContextMenuListener());
   Control rulerControl = fVerticalRuler.getControl();
   setRulerContextMenu(fRulerMenuManager.createContextMenu(rulerControl));
   rulerControl.setMenu(getRulerContextMenu());
   rulerControl.addMouseListener(getRulerMouseListener());
 }
Esempio n. 6
0
 /**
  * Creates a menu for the given control containing the given actions
  *
  * @param control the Control to add the menu to
  * @param actions the actions to be shown in the menu
  */
 public void createControlContextMenu(Control control, final IAction... actions) {
   contextMenu = new MenuManager();
   contextMenu.setRemoveAllWhenShown(true);
   contextMenu.addMenuListener(
       new IMenuListener() {
         public void menuAboutToShow(IMenuManager manager) {
           fillContextMenu(manager, actions);
         }
       });
   Menu menu = contextMenu.createContextMenu(control);
   control.setMenu(menu);
 }
Esempio n. 7
0
 private void makeContextMenu(ListViewer listMB3) {
   MenuManager manager = new MenuManager("#PopupMenu"); // $NON-NLS-1$
   Control contr = listMB3.getControl();
   manager.addMenuListener(
       new IMenuListener() {
         public void menuAboutToShow(IMenuManager manager) {
           manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
         }
       });
   Menu menu = manager.createContextMenu(contr);
   contr.setMenu(menu);
   if (_site != null) {
     _site.registerContextMenu(manager, listMB3);
   } else {
     // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("Wrong site");
     System.out.println("Wrong site");
   }
 }
Esempio n. 8
0
 /**
  * Creates a menu for the given Control that will be populated by the provided populator This can
  * be used to construct dynamic menus that change contents depending of state.
  */
 public void createControlContextMenu(Control control, final IMenuPopulator populator) {
   contextMenu = new MenuManager();
   contextMenu.setRemoveAllWhenShown(true);
   contextMenu.addMenuListener(
       new IMenuListener() {
         public void menuAboutToShow(IMenuManager manager) {
           for (IAction ac : populator.fillMenu()) {
             if (ac == null) {
               contextMenu.add(new Separator());
             } else {
               contextMenu.add(ac);
             }
           }
         }
       });
   Menu menu = contextMenu.createContextMenu(control);
   control.setMenu(menu);
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {
    super.createControl(parent);
    TreeViewer viewer = getTreeViewer();
    viewer.setContentProvider(new MakefileContentProvider());
    viewer.setLabelProvider(new MakefileLabelProvider());
    if (fInput != null) {
      viewer.setInput(fInput);
    }

    MenuManager manager = new MenuManager("#MakefileOutlinerContext"); // $NON-NLS-1$
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(
        new IMenuListener() {
          public void menuAboutToShow(IMenuManager m) {
            contextMenuAboutToShow(m);
          }
        });
    Control tree = viewer.getControl();
    Menu menu = manager.createContextMenu(tree);
    tree.setMenu(menu);

    viewer.addDoubleClickListener(
        new IDoubleClickListener() {
          /* (non-Javadoc)
           * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
           */
          public void doubleClick(DoubleClickEvent event) {
            if (fOpenIncludeAction != null) {
              fOpenIncludeAction.run();
            }
          }
        });

    IPageSite site = getSite();
    // FIXME: should pluginid below be MakeUIPlugin id?
    site.registerContextMenu(
        AutotoolsUIPlugin.getPluginId() + ".outline", manager, viewer); // $NON-NLS-1$
    site.setSelectionProvider(viewer);
  }
  public void makeContributions(
      IMenuManager menuManager,
      IToolBarManager toolBarManager,
      IStatusLineManager statusLineManager) {

    MenuManager popupMenuManager = new MenuManager();
    IMenuListener listener =
        new IMenuListener() {
          public void menuAboutToShow(IMenuManager manager) {
            ISelection selection = getSelection();
            MonitorSearchActionGroup actionGroup = new MonitorSearchActionGroup();
            if (fEditor != null) actionGroup.setBaseModel(fEditor.getAggregateModel());
            actionGroup.setContext(new ActionContext(selection));
            actionGroup.fillContextMenu(manager);
          }
        };

    popupMenuManager.addMenuListener(listener);
    popupMenuManager.setRemoveAllWhenShown(true);
    Control control = getTreeViewer().getControl();
    Menu menu = popupMenuManager.createContextMenu(control);
    control.setMenu(menu);
  }
Esempio n. 11
0
  CommitMessageViewer(final Composite parent, final IPageSite site, IWorkbenchPartSite partSite) {
    super(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    this.partSite = partSite;

    final StyledText t = getTextWidget();
    t.setFont(UIUtils.getFont(UIPreferences.THEME_CommitMessageFont));

    sys_normalCursor = t.getCursor();

    // set the cursor when hovering over a link
    t.addListener(
        SWT.MouseMove,
        new Listener() {
          public void handleEvent(final Event e) {
            if (getStyleRange(e.x, e.y) instanceof ObjectLink) t.setCursor(SYS_LINK_CURSOR);
            else t.setCursor(sys_normalCursor);
          }
        });
    // react on link click
    t.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(final MouseEvent e) {
            // only process the hyper link if it was a primary mouse click
            if (e.button != 1) return;

            final StyleRange r = getStyleRange(e.x, e.y);
            if (r instanceof ObjectLink) {
              final RevCommit c = ((ObjectLink) r).targetCommit;
              for (final Object l : navListeners.getListeners())
                ((CommitNavigationListener) l).showCommit(c);
            }
          }
        });
    setTextDoubleClickStrategy(
        new DefaultTextDoubleClickStrategy(), IDocument.DEFAULT_CONTENT_TYPE);
    activatePlugins();

    // react on changes in the fill and wrap preferences
    listener =
        new IPropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP)) {
              setWrap(((Boolean) event.getNewValue()).booleanValue());
              return;
            }
            if (event.getProperty().equals(UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_FILL)) {
              setFill(((Boolean) event.getNewValue()).booleanValue());
              return;
            }
            if (event.getProperty().equals(UIPreferences.HISTORY_SHOW_TAG_SEQUENCE)) {
              format();
              return;
            }
          }
        };

    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    store.addPropertyChangeListener(listener);
    fill = store.getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_FILL);
    setWrap(store.getBoolean(UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP));

    // global action handlers for select all and copy
    final IAction selectAll =
        new Action() {
          @Override
          public void run() {
            doOperation(ITextOperationTarget.SELECT_ALL);
          }

          @Override
          public boolean isEnabled() {
            return canDoOperation(ITextOperationTarget.SELECT_ALL);
          }
        };

    final IAction copy =
        new Action() {
          @Override
          public void run() {
            doOperation(ITextOperationTarget.COPY);
          }

          @Override
          public boolean isEnabled() {
            return canDoOperation(ITextOperationTarget.COPY);
          }
        };
    // register and unregister the global actions upon focus events
    getControl()
        .addFocusListener(
            new FocusListener() {
              public void focusLost(FocusEvent e) {
                site.getActionBars().setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), null);
                site.getActionBars().setGlobalActionHandler(ActionFactory.COPY.getId(), null);
                site.getActionBars().updateActionBars();
              }

              public void focusGained(FocusEvent e) {
                site.getActionBars()
                    .setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAll);
                site.getActionBars().setGlobalActionHandler(ActionFactory.COPY.getId(), copy);
                site.getActionBars().updateActionBars();
              }
            });

    final MenuManager mgr = new MenuManager();
    Control c = getControl();
    c.setMenu(mgr.createContextMenu(c));

    IPersistentPreferenceStore pstore = (IPersistentPreferenceStore) store;

    Action showTagSequence =
        new BooleanPrefAction(
            pstore,
            UIPreferences.HISTORY_SHOW_TAG_SEQUENCE,
            UIText.ResourceHistory_ShowTagSequence) {
          @Override
          protected void apply(boolean value) {
            // nothing, just toggle
          }
        };
    mgr.add(showTagSequence);

    Action wrapComments =
        new BooleanPrefAction(
            pstore,
            UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_WRAP,
            UIText.ResourceHistory_toggleCommentWrap) {
          @Override
          protected void apply(boolean value) {
            // nothing, just toggle
          }
        };
    mgr.add(wrapComments);

    Action fillParagraphs =
        new BooleanPrefAction(
            pstore,
            UIPreferences.RESOURCEHISTORY_SHOW_COMMENT_FILL,
            UIText.ResourceHistory_toggleCommentFill) {
          @Override
          protected void apply(boolean value) {
            // nothing, just toggle
          }
        };
    mgr.add(fillParagraphs);
  }
  /** {@inheritDoc} */
  @Override
  public void createPartControl(Composite parent) {
    createViewToolbar();

    toolkit = new FormToolkit(parent.getDisplay());

    mainComposite = new SashForm(parent, SWT.VERTICAL);
    GridLayout mainLayout = new GridLayout(1, true);
    mainLayout.marginWidth = 0;
    mainLayout.marginHeight = 0;
    mainComposite.setLayout(mainLayout);

    mainForm = toolkit.createForm(mainComposite);
    mainForm.getBody().setLayout(new GridLayout(1, true));
    mainForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    createHeadClient();
    toolkit.decorateFormHeading(mainForm);

    int borderStyle = toolkit.getBorderStyle();
    toolkit.setBorderStyle(SWT.NULL);
    Table table = toolkit.createTable(mainForm.getBody(), SWT.V_SCROLL | SWT.H_SCROLL);
    toolkit.setBorderStyle(borderStyle);
    tableViewer = new TableViewer(table);

    // create tree content provider
    tableViewer.setContentProvider(getContentProvider());
    tableViewer.setLabelProvider(getLabelProvider());

    ViewerComparator comparator = getViewerComparator();
    if (null != comparator) {
      tableViewer.setComparator(comparator);
    }
    ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);

    // double-click listener
    IDoubleClickListener doubleClickListener = getTreeDoubleClickListener();
    if (null != doubleClickListener) {
      tableViewer.addDoubleClickListener(doubleClickListener);
    }

    // menu
    String menuId = getMenuId();
    if (null != menuId) {
      MenuManager menuManager = new MenuManager();
      menuManager.setRemoveAllWhenShown(true);
      getSite().registerContextMenu(menuId, menuManager, tableViewer);
      Control control = tableViewer.getControl();
      Menu menu = menuManager.createContextMenu(control);
      control.setMenu(menu);
    }

    // resizing listener
    mainComposite.addControlListener(
        new ControlAdapter() {
          private boolean verticaLayout;

          @Override
          public void controlResized(ControlEvent e) {
            int width = mainComposite.getBounds().width;
            int height = mainComposite.getBounds().height;

            if (width > height && verticaLayout) {
              verticaLayout = false;
              mainComposite.setOrientation(SWT.HORIZONTAL);
            } else if (width < height && !verticaLayout) {
              verticaLayout = true;
              mainComposite.setOrientation(SWT.VERTICAL);
            }

            mainComposite.layout();
          }
        });

    // update all
    updateFormTitle();
    updateFormMenuManager();
    updateFormBody();

    tableViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
            if (ss.getFirstElement() instanceof IProfileProvider
                || ss.getFirstElement() instanceof IEnvironmentProvider) {
              selectionProviderAdapter.setSelection(ss);
            } else {
              // setting selection to the CMR so that we can perform all the necessary
              // operations
              selectionProviderAdapter.setSelection(
                  new StructuredSelection(displayedCmrRepositoryDefinition));
            }
          }
        });
    getSite().setSelectionProvider(selectionProviderAdapter);
    selectionProviderAdapter.setSelection(
        new StructuredSelection(displayedCmrRepositoryDefinition));

    // TODO: This needs to be removed as soon as the configuration interface is fully
    // functional.
    UnfinishedWarningUtils.inform(
        "The configuration interface is not yet connected with the agent instrumentation. You can play around with this preview, but the instrumentations will not be effective.",
        "UNFINISHED_WARNING_CONFIGURATION_INTERFACE");
  }
Esempio n. 13
0
 /**
  * Create a popup Menu
  *
  * @param parent Owning Shell
  * @param owner Owning Control
  */
 protected Menu createPopupMenu(Shell shell, Control owner) {
   Menu m = createPopupMenu(shell);
   owner.setMenu(m);
   return m;
 }