Esempio n. 1
0
  private void createActions() {
    // Create the actions
    {
      // Drop down menu to select what to show
      // First selection for All and then each datasource in alphabetical
      // order
      final Menu sectionsMenu = new Menu(pvFomulaInputBar.getParent());
      MenuItem viewerMenuItem =
          ShowHideForGridLayout.createShowHideMenuItem(sectionsMenu, viewerPanel);
      viewerMenuItem.setText(Messages.Probe_sectionViewer);
      sectionToMenu.put(viewerPanel, viewerMenuItem);
      MenuItem valueMenuItem =
          ShowHideForGridLayout.createShowHideMenuItem(sectionsMenu, valuePanel);
      valueMenuItem.setText(Messages.Probe_sectionValue);
      sectionToMenu.put(valuePanel, valueMenuItem);
      MenuItem changeValueMenuItem =
          ShowHideForGridLayout.createShowHideMenuItem(sectionsMenu, changeValuePanel);
      changeValueMenuItem.setText(Messages.Probe_sectionChangeValue);
      sectionToMenu.put(changeValuePanel, changeValueMenuItem);
      MenuItem metadataMenuItem =
          ShowHideForGridLayout.createShowHideMenuItem(sectionsMenu, metadataPanel);
      metadataMenuItem.setText(Messages.Probe_sectionMetadata);
      sectionToMenu.put(metadataPanel, metadataMenuItem);
      MenuItem detailsMenuItem =
          ShowHideForGridLayout.createShowHideMenuItem(sectionsMenu, detailsPanel);
      detailsMenuItem.setText(Messages.Probe_sectionDetails);
      sectionToMenu.put(detailsPanel, detailsMenuItem);

      showHideAction =
          new Action(Messages.Probe_showHideButtonText, SWT.DROP_DOWN) {
            @Override
            public void runWithEvent(Event event) {
              // Point point = event.
              ToolItem toolItem = (ToolItem) event.widget;
              Point point =
                  toolItem
                      .getParent()
                      .toDisplay(
                          new Point(
                              toolItem.getBounds().x,
                              toolItem.getBounds().y + toolItem.getBounds().height));
              sectionsMenu.setLocation(point.x, point.y); // waiting
              sectionsMenu.setVisible(true);
            }
          };
      showHideAction.setImageDescriptor(
          ResourceManager.getPluginImageDescriptor(
              "org.eclipse.ui", //$NON-NLS-1$
              "/icons/full/obj16/submenu.gif")); //$NON-NLS-1$

      // showHideAction.setImageDescriptor(ResourceManager.getPluginImageDescriptor("org.csstudio.utility.pvmanager.ui.toolbox",
      // "icons/source.png"));
      showHideAction.setToolTipText(Messages.Probe_showHideButtonToolTipText);
      showHideAction.setMenuCreator(
          new IMenuCreator() {

            @Override
            public Menu getMenu(Menu parent) {
              return sectionsMenu;
            }

            @Override
            public Menu getMenu(Control parent) {
              // TODO Auto-generated method stub
              return sectionsMenu;
            }

            @Override
            public void dispose() {
              sectionsMenu.dispose();
            }
          });
    }

    copyValueAction =
        new Action(Messages.Probe_copyValueToClipboardButtonText, SWT.NONE) {

          public void runWithEvent(Event event) {
            try {
              StringWriter writer = new StringWriter();
              export.export(pv.getValue(), writer);
              String text = writer.toString();
              final Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
              clipboard.setContents(
                  new String[] {text}, new Transfer[] {TextTransfer.getInstance()});
            } catch (Exception ex) {
              ExceptionDetailsErrorDialog.openError(
                  PVManagerProbe.this.mainPanel.getShell(),
                  Messages.Probe_errorCopyValueToClipboard,
                  ex);
            }
          };
        };
    copyValueAction.setImageDescriptor(
        ResourceManager.getPluginImageDescriptor(
            "org.eclipse.ui", "/icons/full/etool16/paste_edit.gif")); // $NON-NLS-1$ //$NON-NLS-2$
    copyValueAction.setToolTipText(Messages.Probe_copyValueToClipboardButtonToolTipText);
    copyValueAction.setEnabled(false);
  }
Esempio n. 2
0
 private void initSection(Composite section, boolean show) {
   ShowHideForGridLayout.setShow(section, show);
   sectionToMenu.get(section).setSelection(show);
 }