示例#1
0
  protected void createToolBarActions(IManagedForm managedForm) {
    final ScrolledForm form = managedForm.getForm();

    Action haction = new Action("hor", IAction.AS_RADIO_BUTTON) { // $NON-NLS-1$
          public void run() {
            sashForm.setOrientation(SWT.HORIZONTAL);
            form.reflow(true);
          }
        };
    haction.setChecked(true);
    haction.setToolTipText(PDEUIMessages.DetailsBlock_horizontal);
    haction.setImageDescriptor(PDEPluginImages.DESC_HORIZONTAL);
    haction.setDisabledImageDescriptor(PDEPluginImages.DESC_HORIZONTAL_DISABLED);

    Action vaction = new Action("ver", IAction.AS_RADIO_BUTTON) { // $NON-NLS-1$
          public void run() {
            sashForm.setOrientation(SWT.VERTICAL);
            form.reflow(true);
          }
        };
    vaction.setChecked(false);
    vaction.setToolTipText(PDEUIMessages.DetailsBlock_vertical);
    vaction.setImageDescriptor(PDEPluginImages.DESC_VERTICAL);
    vaction.setDisabledImageDescriptor(PDEPluginImages.DESC_VERTICAL_DISABLED);
    form.getToolBarManager().add(haction);
    form.getToolBarManager().add(vaction);
  }
  /**
   * Create the toolbar actions
   *
   * @param managedForm
   */
  @Override
  protected void createToolBarActions(IManagedForm managedForm) {
    final ScrolledForm form = managedForm.getForm();

    Action vaction =
        new Action("ver", Action.AS_RADIO_BUTTON) {

          public void run() {
            setSashFormVertical(form);
          }
        };
    vaction.setChecked(vertical);
    vaction.setToolTipText("vertical");
    vaction.setImageDescriptor(POFileEditorPlugin.getImageDescriptor("icons/th_vertical.gif"));

    Action haction =
        new Action("hor", Action.AS_RADIO_BUTTON) {

          public void run() {
            setSashFormHorizontal(form);
          }
        };
    haction.setChecked(horizontal);
    haction.setToolTipText("horizontal");
    haction.setImageDescriptor(POFileEditorPlugin.getImageDescriptor("icons/th_horizontal.gif"));

    form.getToolBarManager().add(haction);
    form.getToolBarManager().add(vaction);
  }
  /**
   * Create toolbar actions to change the layout from vertical to horizontal orientation.
   *
   * @param managedForm form reference for toolbar manager
   */
  protected void createToolBarActions(IManagedForm managedForm) {
    final ScrolledForm form = managedForm.getForm();

    Action haction =
        new Action("hor", Action.AS_RADIO_BUTTON) {
          public void run() {
            sashForm.setOrientation(SWT.HORIZONTAL);
            form.reflow(true);
          }
        };
    haction.setChecked(true);
    haction.setToolTipText("Horizontal orientation");
    haction.setImageDescriptor(
        Activator.getDefault()
            .getImageRegistry()
            .getDescriptor(Activator.EXAMPLE_HORIZONTAL_IMAGE));

    Action vaction =
        new Action("ver", Action.AS_RADIO_BUTTON) {
          public void run() {
            sashForm.setOrientation(SWT.VERTICAL);
            form.reflow(true);
          }
        };
    vaction.setChecked(false);
    vaction.setToolTipText("Vertical orientation");
    vaction.setImageDescriptor(
        Activator.getDefault().getImageRegistry().getDescriptor(Activator.EXAMPLE_VERTICAL_IMAGE));

    form.getToolBarManager().add(haction);
    form.getToolBarManager().add(vaction);
  }
  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;
  }
示例#5
0
 private boolean toggle(Action action, boolean input) {
   action.setChecked(!action.isChecked());
   IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
   for (IContributionItem item : mgr.getItems()) {
     if (item instanceof ActionContributionItem
         && ((ActionContributionItem) item).getAction() == action) {
       action.setChecked(!action.isChecked());
       return !input;
     }
   }
   return input;
 }
示例#6
0
  /** Makes the actions of the view */
  private void makeActions() {

    seeContext =
        new Action("CTX", IAction.AS_RADIO_BUTTON) {
          public void run() {
            try {
              POMode = false;
              inputCTX(); // prompt the context
            } catch (IOException e) {
              TraceView.print(MessageType.ERROR, "POViewer, can't display the CTX file : " + e);
            }
          }
        };

    seePO =
        new Action("PO", IAction.AS_RADIO_BUTTON) {
          public void run() {
            try {
              POMode = true;
              inputPO(); // prompt the selected goal
            } catch (IOException e) {
              TraceView.print(MessageType.ERROR, "POViewer, can't display the PO file : " + e);
            }
          }
        };
    seePO.setChecked(true); // PO viewer by default
  }
 static void toggle(IAction action, ITextEditor editor) {
   StyledText text = (StyledText) editor.getAdapter(Control.class);
   boolean currentWrap = text.getWordWrap();
   text.setWordWrap(!currentWrap);
   if (action instanceof Action) {
     Action act = (Action) action;
     act.setChecked(!currentWrap);
   }
 }
 public void setCollapsed(boolean value) {
   super.setChecked(value);
   collapsed = value;
   if (value) {
     setToolTipText(Messages.RESTORE_ALL_TOOLTIP);
   } else {
     setToolTipText(Messages.COLLAPSE_ALL_BUT_CURRENT_TOOLTIP);
   }
 }
示例#9
0
  public void setPeriod(TimeSpan period, TimeSpan resolution) {
    dialogSettings.put(K_PERIOD, period != null ? period.toString() : (String) null);
    dialogSettings.put(K_RESOLUTION, resolution != null ? resolution.toString() : (String) null);

    periodAllAction.setChecked(period == null);
    setPeriodActionSelection(period, resolution);

    scheduleLoadJob();
  }
示例#10
0
 private void setAncestorVisibility(boolean visible, boolean enabled) {
   if (fAncestorItem != null) {
     Action action = (Action) fAncestorItem.getAction();
     if (action != null) {
       action.setChecked(visible);
       action.setEnabled(enabled);
     }
   }
   getCompareConfiguration()
       .setProperty(ICompareUIConstants.PROP_ANCESTOR_VISIBLE, new Boolean(visible));
 }
示例#11
0
 @Override
 protected void contributeToToolbar(IToolBarManager manager) {
   manager.add(new Separator());
   manager.add(action2);
   action2.setChecked(true);
   manager.add(action3);
   manager.add(action4);
   manager.add(action1);
   manager.add(new Separator());
   manager.add(switchSampleTime);
   manager.add(new Separator());
   manager.add(new ChartAction(getViewSite().getShell(), getSTViewer()));
 }
 static ITextEditor configureActive(IAction action, IWorkbenchPart targetPart) {
   ITextEditor editor = null;
   if (targetPart instanceof ITextEditor && action instanceof Action) {
     editor = (ITextEditor) targetPart;
     Action act = (Action) action;
     Object adapter = editor.getAdapter(Control.class);
     if (adapter instanceof StyledText) {
       StyledText text = (StyledText) adapter;
       boolean currentWrap = text.getWordWrap();
       act.setChecked(currentWrap);
     }
   }
   return editor;
 }
 @Override
 public void propertyChange(PropertyChangeEvent event) {
   if (off) return;
   try {
     off = true;
     final Action action = (Action) event.getSource();
     final Collection<IAction> others = new ArrayList<IAction>(actions);
     others.remove(action);
     action.setChecked(true);
     for (IAction other : others) other.setChecked(false);
   } finally {
     off = false;
   }
 }
示例#14
0
  private void createActionMonitor() {
    actionMonitor =
        new Action("Monitor", IAction.AS_CHECK_BOX) {
          public void run() {
            if (actionMonitor.isChecked()) {
              Display display = output.getDisplay();
              display.timerExec(100, trackWidgets);
            }
          }
        };

    actionMonitor.setToolTipText("Enable/Disable monitoring of widgets");
    actionMonitor.setChecked(false);
  }
 private void makeActions() {
   showHierarchyOfModulesAction =
       new Action("", IAction.AS_CHECK_BOX) {
         @Override
         public void run() {
           setShowModuleHierarchy(isChecked());
         }
       };
   showHierarchyOfModulesAction.setText(CALUIMessages.CALWorkspace_showHierarchyOfModules);
   showHierarchyOfModulesAction.setChecked(getModuleContentProvider().getShowModuleHierarchy());
   showHierarchyOfModulesAction.setToolTipText(
       CALUIMessages.CALWorkspace_showHierarchyOfModules_tooltip);
   //
   // showHierarchyOfModulesAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
   //                getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
 }
  private void createItemAction(final int pageSize, boolean selected) {
    Action pageSizeAction =
        new Action(String.format("%d items", pageSize), Action.AS_RADIO_BUTTON) {
          @Override
          public void run() {
            if (isChecked()) {
              contentProvider.setPageLength(pageSize);
              refresh();
            }
          }
        };

    pageSizeAction.setChecked(selected);

    getViewSite().getActionBars().getMenuManager().add(pageSizeAction);
  }
  protected void updateSelected() {
    StatusBean bean = getSelection();
    if (bean == null) bean = new StatusBean();

    remove.setEnabled(bean.getStatus() != null);
    rerun.setEnabled(true);

    boolean isSubmitted =
        bean.getStatus() == org.eclipse.scanning.api.event.status.Status.SUBMITTED;
    up.setEnabled(isSubmitted);
    edit.setEnabled(isSubmitted);
    down.setEnabled(isSubmitted);
    pause.setEnabled(bean.getStatus().isRunning() || bean.getStatus().isPaused());
    pause.setChecked(bean.getStatus().isPaused());
    pause.setText(bean.getStatus().isPaused() ? "Resume job" : "Pause job");
  }
 private void addActions(Menu menu) { // add repository action
   Presentation selectedPresentation = view.getContentProvider().getPresentation();
   for (final Presentation presentation : Presentation.values()) {
     Action action =
         new Action() {
           @Override
           public void run() {
             view.getContentProvider().setPresentation(presentation);
           }
         };
     action.setText(presentation.toString());
     action.setChecked(presentation == selectedPresentation);
     ActionContributionItem item = new ActionContributionItem(action);
     item.fill(menu, -1);
   }
 }
示例#19
0
  private void fillLocalToolBar(final IToolBarManager manager) {
    final Action viewInPlotter =
        new Action() {
          @Override
          public void run() {
            openPlotter();
          }
        };
    viewInPlotter.setText("View in LPD");
    viewInPlotter.setToolTipText("View 2D overview of scenario");
    viewInPlotter.setImageDescriptor(CorePlugin.getImageDescriptor("icons/overview.gif"));

    final Action actionReloadDatafiles =
        new Action() {
          @Override
          public void run() {
            _myPresenter.reloadDataFiles();
          }
        };
    actionReloadDatafiles.setText("Reload");
    actionReloadDatafiles.setToolTipText("Reload data files");
    final ImageDescriptor desc = CorePlugin.getImageDescriptor("icons/repaint.gif");
    actionReloadDatafiles.setImageDescriptor(desc);

    final Action doNetwork =
        new Action("Broadcast", SWT.TOGGLE) {
          @Override
          public void run() {
            doNetwork(this.isChecked());
          }
        };
    doNetwork.setChecked(true);
    doNetwork.setToolTipText("Broadcast scenarios on network");
    doNetwork.setImageDescriptor(Activator.getImageDescriptor("icons/app_link.png"));

    // and display them
    manager.add(doNetwork);
    manager.add(viewInPlotter);
    manager.add(actionReloadDatafiles);

    manager.add(new Separator());
    manager.add(
        CorePlugin.createOpenHelpAction("org.mwc.asset.help.ScenarioController", null, this));
  }
示例#20
0
  private void addShowHideAction(
      IMenuManager manager,
      final Column column,
      String label,
      final boolean isChecked,
      final Object option) {
    Action action =
        new Action(label) {
          @Override
          public void run() {
            if (isChecked) {
              if (column.isRemovable()) destroyColumnWithOption(column, option);
            } else {
              policy.create(
                  column, option, column.getDefaultSortDirection(), column.getDefaultWidth());
              policy.getViewer().refresh(true);
            }

            if (store != null) store.updateActive(serialize());
          }
        };
    action.setChecked(isChecked);
    manager.add(action);
  }
  @Override
  public void init(IViewSite site, IMemento memento) throws PartInitException {
    init(site);
    String storedExtensions = "";
    if (memento != null) { // Open dir path
      this.dirPath = memento.getString("DIR");
      storedExtensions = memento.getString("FILTERS");
      if (storedExtensions == null) storedExtensions = "";
    }
    // Filter Extensions
    imgExtensions = new Action[ImageExplorerDirectoryChooseAction.LISTOFSUFFIX.length];
    MenuManager filterMenu = new MenuManager("File Filters");
    for (int i = 0; i < ImageExplorerDirectoryChooseAction.LISTOFSUFFIX.length; i++) {
      final int number = i;
      imgExtensions[i] =
          new Action("", IAction.AS_CHECK_BOX) {
            @Override
            public void run() {
              if (this.isChecked()) {
                filter.remove(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[number]);
              } else {
                filter.add(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[number]);
              }
              // reload the directory
              updateDirectory.setUser(true);
              updateDirectory.setPriority(Job.DECORATE);
              updateDirectory.schedule(1000);
            }
          };
      imgExtensions[i].setText(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i]);
      imgExtensions[i].setDescription(
          "Filter " + ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i] + " on/off");
      if (storedExtensions.contains(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i])) {
        imgExtensions[i].setChecked(false);
        filter.add(ImageExplorerDirectoryChooseAction.LISTOFSUFFIX[i]);
      } else imgExtensions[i].setChecked(true);
      filterMenu.add(imgExtensions[i]);
    }

    site.getActionBars().getMenuManager().add(filterMenu);

    // color submenus actions
    final IPaletteService pservice = PlatformUI.getWorkbench().getService(IPaletteService.class);
    final Collection<String> names = pservice.getColorSchemes();
    String schemeName = getPreferenceColourMapChoice();

    colorMenu = new MenuAction("Color");
    colorMenu.setId(getClass().getName() + colorMenu.getText());
    colorMenu.setImageDescriptor(AnalysisRCPActivator.getImageDescriptor("icons/color_wheel.png"));

    final Map<String, IAction> paletteActions = new HashMap<String, IAction>(11);
    CheckableActionGroup group = new CheckableActionGroup();
    for (final String paletteName : names) {
      final Action action =
          new Action(paletteName, IAction.AS_CHECK_BOX) {
            @Override
            public void run() {
              try {
                setPreferenceColourMapChoice(paletteName);

                IPlottingSystem<Composite> system =
                    PlottingFactory.getPlottingSystem(getPreferencePlaybackView());
                if (system != null) {
                  final Collection<ITrace> traces = system.getTraces();
                  if (traces != null)
                    for (ITrace trace : traces) {
                      if (trace instanceof IPaletteTrace) {
                        IPaletteTrace paletteTrace = (IPaletteTrace) trace;
                        paletteTrace.setPalette(paletteName);
                      }
                    }
                }

              } catch (Exception ne) {
                logger.error("Cannot create palette data!", ne);
              }
            }
          };
      action.setId(paletteName);
      group.add(action);
      colorMenu.add(action);
      action.setChecked(paletteName.equals(schemeName));
      paletteActions.put(paletteName, action);
    }
    colorMenu.setToolTipText("Histogram");
    site.getActionBars().getMenuManager().add(colorMenu);

    // ImageExplorer preferences
    final Action openPreferences =
        new Action("Image Explorer Preferences...") {
          @Override
          public void run() {
            PreferenceDialog pref =
                PreferencesUtil.createPreferenceDialogOn(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    ImageExplorerPreferencePage.ID,
                    null,
                    null);
            if (pref != null) pref.open();
          }
        };
    site.getActionBars().getMenuManager().add(openPreferences);
  }
  public void createPartControl(Composite parent) {
    Server server = ServerManager.getInstance().getServer(serverId);
    this.setPartName("DB Activity[" + server.getName() + "]");
    GridLayout layout = new GridLayout(1, true);
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    parent.setLayout(layout);
    parent.setBackground(ColorUtil.getInstance().getColor(SWT.COLOR_WHITE));
    parent.setBackgroundMode(SWT.INHERIT_FORCE);
    canvas = new FigureCanvas(parent);
    canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
    canvas.setScrollBarVisibility(FigureCanvas.NEVER);
    canvas.addControlListener(
        new ControlListener() {
          public void controlMoved(ControlEvent arg0) {}

          public void controlResized(ControlEvent arg0) {
            Rectangle r = canvas.getClientArea();
            xyGraph.setSize(r.width, r.height);
          }
        });

    xyGraph = new XYGraph();
    xyGraph.setShowLegend(true);
    xyGraph.setShowTitle(false);
    canvas.setContents(xyGraph);

    xyGraph.primaryXAxis.setDateEnabled(true);
    xyGraph.primaryXAxis.setShowMajorGrid(true);
    xyGraph.primaryYAxis.setAutoScale(true);
    xyGraph.primaryYAxis.setShowMajorGrid(true);
    xyGraph.primaryXAxis.setFormatPattern("HH:mm:ss");
    xyGraph.primaryYAxis.setFormatPattern("#,##0");

    xyGraph.primaryXAxis.setTitle("");
    xyGraph.primaryYAxis.setTitle("");

    xyGraph.primaryYAxis.addMouseListener(
        new RangeMouseListener(getViewSite().getShell(), xyGraph.primaryYAxis));

    CircularBufferDataProvider callProvider = new CircularBufferDataProvider(true);
    callProvider.setBufferSize(BUFFER_SIZE);
    callProvider.setCurrentXDataArray(new double[] {});
    callProvider.setCurrentYDataArray(new double[] {});
    callTrace = new Trace("Call (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, callProvider);
    callTrace.setPointStyle(PointStyle.NONE);
    callTrace.setTraceType(TraceType.AREA);
    callTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    callTrace.setAreaAlpha(255);
    callTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_BLUE));
    xyGraph.addTrace(callTrace);

    CircularBufferDataProvider selectProvider = new CircularBufferDataProvider(true);
    selectProvider.setBufferSize(BUFFER_SIZE);
    selectProvider.setCurrentXDataArray(new double[] {});
    selectProvider.setCurrentYDataArray(new double[] {});
    selectTrace =
        new Trace("Select (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, selectProvider);
    selectTrace.setPointStyle(PointStyle.NONE);
    selectTrace.setTraceType(TraceType.AREA);
    selectTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    selectTrace.setAreaAlpha(255);
    selectTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_CYAN));
    xyGraph.addTrace(selectTrace);

    CircularBufferDataProvider insertProvider = new CircularBufferDataProvider(true);
    insertProvider.setBufferSize(BUFFER_SIZE);
    insertProvider.setCurrentXDataArray(new double[] {});
    insertProvider.setCurrentYDataArray(new double[] {});
    insertTrace =
        new Trace("Insert (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, insertProvider);
    insertTrace.setPointStyle(PointStyle.NONE);
    insertTrace.setTraceType(TraceType.AREA);
    insertTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    insertTrace.setAreaAlpha(255);
    insertTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_GRAY));
    xyGraph.addTrace(insertTrace);

    CircularBufferDataProvider updateProvider = new CircularBufferDataProvider(true);
    updateProvider.setBufferSize(BUFFER_SIZE);
    updateProvider.setCurrentXDataArray(new double[] {});
    updateProvider.setCurrentYDataArray(new double[] {});
    updateTrace =
        new Trace("Update (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, updateProvider);
    updateTrace.setPointStyle(PointStyle.NONE);
    updateTrace.setTraceType(TraceType.AREA);
    updateTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    updateTrace.setAreaAlpha(255);
    updateTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_GREEN));
    xyGraph.addTrace(updateTrace);

    CircularBufferDataProvider deleteProvider = new CircularBufferDataProvider(true);
    deleteProvider.setBufferSize(BUFFER_SIZE);
    deleteProvider.setCurrentXDataArray(new double[] {});
    deleteProvider.setCurrentYDataArray(new double[] {});
    deleteTrace =
        new Trace("Delete (SUM)", xyGraph.primaryXAxis, xyGraph.primaryYAxis, deleteProvider);
    deleteTrace.setPointStyle(PointStyle.NONE);
    deleteTrace.setTraceType(TraceType.AREA);
    deleteTrace.setLineWidth(PManager.getInstance().getInt(PreferenceConstants.P_CHART_LINE_WIDTH));
    deleteTrace.setAreaAlpha(255);
    deleteTrace.setTraceColor(ColorUtil.getInstance().getColor(SWT.COLOR_DARK_MAGENTA));
    xyGraph.addTrace(deleteTrace);

    ScouterUtil.addHorizontalRangeListener(
        xyGraph.getPlotArea(), new OpenDigestTableAction(serverId), false);

    IToolBarManager man = getViewSite().getActionBars().getToolBarManager();
    Action stackViewAct =
        new Action("Area Mode", IAction.AS_CHECK_BOX) {
          public void run() {
            isStackView = isChecked();
            changeMode();
          }
        };
    stackViewAct.setImageDescriptor(ImageUtil.getImageDescriptor(Images.sum));
    stackViewAct.setChecked(true);
    man.add(stackViewAct);
    Action openDailyView =
        new Action("Open Daily View", ImageUtil.getImageDescriptor(Images.calendar)) {
          public void run() {
            try {
              PlatformUI.getWorkbench()
                  .getActiveWorkbenchWindow()
                  .getActivePage()
                  .showView(
                      DbTodayTotalActivityView.ID, "" + serverId, IWorkbenchPage.VIEW_ACTIVATE);
            } catch (PartInitException e) {
              ConsoleProxy.errorSafe(e.toString());
            }
          }
        };
    man.add(openDailyView);

    thread = new RefreshThread(this, REFRESH_INTERVAL);
    thread.start();
  }
示例#23
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createPartControl(Composite parent) {
    viewer = new BaseChartViewer(parent, SWT.NONE);

    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            handleSelectionChanged((IStructuredSelection) event.getSelection());
            handleActionsEnablement();
          }
        });
    viewer
        .getEditor()
        .addListener(
            new IChartEditorListener() {

              @Override
              public void applyEditorValue() {
                refreshChart();
                setDirty();
              }

              @Override
              public void cancelEditor() {}
            });

    Transfer[] transferTypes =
        new Transfer[] {
          ChartObjectFactoryTransfer.getInstance(),
        };
    DropTarget dropTarget = new DropTarget(viewer.getControl(), DND.DROP_COPY | DND.DROP_MOVE);
    dropTarget.setTransfer(transferTypes);
    dropTarget.addDropListener(dropListener = new ChartViewDropTarget(viewer));

    viewer.setShowTooltips(preferenceStore.getBoolean(UIActivator.PREFS_SHOW_TOOLTIPS));
    viewer.setShowScaleTooltips(preferenceStore.getBoolean(UIActivator.PREFS_SHOW_SCALE_TOOLTIPS));
    viewer.setCrosshairMode(preferenceStore.getInt(UIActivator.PREFS_CROSSHAIR_ACTIVATION));
    viewer.setDecoratorSummaryTooltips(
        preferenceStore.getBoolean(UIActivator.PREFS_CROSSHAIR_SUMMARY_TOOLTIP));
    preferenceStore.addPropertyChangeListener(preferenceChangeListener);

    if (memento != null) {
      if (memento.getString(K_ZOOM_FACTOR) != null) {
        int factor = memento.getInteger(K_ZOOM_FACTOR);
        viewer.setZoomFactor(factor);
        zoomOutAction.setEnabled(factor != 0);
        zoomResetAction.setEnabled(factor != 0);
      }
    }

    createContextMenu();

    currentPriceLineFactory = new CurrentPriceLineFactory();
    currentPriceLineFactory.setSecurity(security);
    currentPriceLineFactory.setEnable(dialogSettings.getBoolean(K_SHOW_CURRENT_PRICE));
    currentPriceLineAction.setChecked(dialogSettings.getBoolean(K_SHOW_CURRENT_PRICE));

    currentBookFactory = new CurrentBookFactory();
    currentBookFactory.setSecurity(security);
    currentBookFactory.setEnable(dialogSettings.getBoolean(K_SHOW_CURRENT_BOOK));
    currentBookAction.setChecked(dialogSettings.getBoolean(K_SHOW_CURRENT_BOOK));

    if (security != null && template != null) {
      setPartName(
          NLS.bind(
              "{0} - {1}",
              new Object[] { // $NON-NLS-1$
                security.getName(), template.getName(),
              }));

      view = new ChartView(template);

      ChartRowViewItem rowItem = (ChartRowViewItem) view.getItems()[0];

      ChartViewItem viewItem = new ChartViewItem(rowItem, currentPriceLineFactory);
      rowItem.addChildItem(0, viewItem);

      viewItem = new ChartViewItem(rowItem, currentBookFactory);
      rowItem.addChildItem(0, viewItem);

      view.addViewChangeListener(viewChangeListener);

      scheduleLoadJob();
    }
  }
  private void createActions() throws Exception {

    final IContributionManager toolMan = getViewSite().getActionBars().getToolBarManager();
    final IContributionManager dropDown = getViewSite().getActionBars().getMenuManager();
    final MenuManager menuMan = new MenuManager();

    final Action openResults =
        new Action(
            "Open results for selected run", Activator.getImageDescriptor("icons/results.png")) {
          public void run() {
            openResults(getSelection());
          }
        };

    toolMan.add(openResults);
    toolMan.add(new Separator());
    menuMan.add(openResults);
    menuMan.add(new Separator());
    dropDown.add(openResults);
    dropDown.add(new Separator());

    this.up =
        new Action("Less urgent (-1)", Activator.getImageDescriptor("icons/arrow-090.png")) {
          public void run() {
            final StatusBean bean = getSelection();
            try {
              queueConnection.reorder(bean, -1);
            } catch (EventException e) {
              ErrorDialog.openError(
                  getViewSite().getShell(),
                  "Cannot move " + bean.getName(),
                  "'" + bean.getName() + "' cannot be moved in the submission queue.",
                  new Status(IStatus.ERROR, "org.eclipse.scanning.event.ui", e.getMessage()));
            }
            refresh();
          }
        };
    up.setEnabled(false);
    toolMan.add(up);
    menuMan.add(up);
    dropDown.add(up);

    this.down =
        new Action("More urgent (+1)", Activator.getImageDescriptor("icons/arrow-270.png")) {
          public void run() {
            final StatusBean bean = getSelection();
            try {
              queueConnection.reorder(getSelection(), +1);
            } catch (EventException e) {
              ErrorDialog.openError(
                  getViewSite().getShell(),
                  "Cannot move " + bean.getName(),
                  e.getMessage(),
                  new Status(IStatus.ERROR, "org.eclipse.scanning.event.ui", e.getMessage()));
            }
            refresh();
          }
        };
    down.setEnabled(false);
    toolMan.add(down);
    menuMan.add(down);
    dropDown.add(down);

    this.pause =
        new Action("Pause job.\nPauses a running job.", IAction.AS_CHECK_BOX) {
          public void run() {
            pauseJob();
          }
        };
    pause.setImageDescriptor(Activator.getImageDescriptor("icons/control-pause.png"));
    pause.setEnabled(false);
    pause.setChecked(false);
    toolMan.add(pause);
    menuMan.add(pause);
    dropDown.add(pause);

    this.pauseConsumer =
        new Action(
            "Pause " + getPartName() + " Queue. Does not pause running job.",
            IAction.AS_CHECK_BOX) {
          public void run() {
            togglePausedConsumer(this);
          }
        };
    pauseConsumer.setImageDescriptor(Activator.getImageDescriptor("icons/control-pause-red.png"));
    pauseConsumer.setChecked(queueConnection.isQueuePaused(getSubmissionQueueName()));
    toolMan.add(pauseConsumer);
    menuMan.add(pauseConsumer);
    dropDown.add(pauseConsumer);

    this.pauseMonitor = service.createSubscriber(getUri(), EventConstants.CMD_TOPIC);
    pauseMonitor.addListener(
        new IBeanListener<PauseBean>() {
          @Override
          public void beanChangePerformed(BeanEvent<PauseBean> evt) {
            pauseConsumer.setChecked(queueConnection.isQueuePaused(getSubmissionQueueName()));
          }
        });

    this.remove =
        new Action(
            "Stop job or remove if finished",
            Activator.getImageDescriptor("icons/control-stop-square.png")) {
          public void run() {
            stopJob();
          }
        };
    remove.setEnabled(false);
    toolMan.add(remove);
    menuMan.add(remove);
    dropDown.add(remove);

    this.rerun =
        new Action("Rerun...", Activator.getImageDescriptor("icons/rerun.png")) {
          public void run() {
            rerunSelection();
          }
        };
    rerun.setEnabled(false);
    toolMan.add(rerun);
    menuMan.add(rerun);
    dropDown.add(rerun);

    IAction open =
        new Action("Open...", Activator.getImageDescriptor("icons/application-dock-090.png")) {
          public void run() {
            openSelection();
          }
        };
    toolMan.add(open);
    menuMan.add(open);
    dropDown.add(open);

    this.edit =
        new Action("Edit...", Activator.getImageDescriptor("icons/modify.png")) {
          public void run() {
            editSelection();
          }
        };
    edit.setEnabled(false);
    toolMan.add(edit);
    menuMan.add(edit);
    dropDown.add(edit);

    toolMan.add(new Separator());
    menuMan.add(new Separator());

    final Action showAll =
        new Action("Show other users results", IAction.AS_CHECK_BOX) {
          public void run() {
            showEntireQueue = isChecked();
            viewer.refresh();
          }
        };
    showAll.setImageDescriptor(Activator.getImageDescriptor("icons/spectacle-lorgnette.png"));

    toolMan.add(showAll);
    menuMan.add(showAll);
    dropDown.add(showAll);

    toolMan.add(new Separator());
    menuMan.add(new Separator());
    dropDown.add(new Separator());

    final Action refresh =
        new Action("Refresh", Activator.getImageDescriptor("icons/arrow-circle-double-135.png")) {
          public void run() {
            reconnect();
          }
        };

    toolMan.add(refresh);
    menuMan.add(refresh);
    dropDown.add(refresh);

    final Action configure =
        new Action("Configure...", Activator.getImageDescriptor("icons/document--pencil.png")) {
          public void run() {
            PropertiesDialog dialog = new PropertiesDialog(getSite().getShell(), idProperties);

            int ok = dialog.open();
            if (ok == PropertiesDialog.OK) {
              idProperties.clear();
              idProperties.putAll(dialog.getProps());
              reconnect();
            }
          }
        };

    toolMan.add(configure);
    menuMan.add(configure);
    dropDown.add(configure);

    final Action clearQueue =
        new Action("Clear Queue") {
          public void run() {
            try {
              purgeQueues();
            } catch (EventException e) {
              e.printStackTrace();
              logger.error("Canot purge queues", e);
            }
          }
        };
    menuMan.add(new Separator());
    dropDown.add(new Separator());
    menuMan.add(clearQueue);
    dropDown.add(clearQueue);

    viewer.getControl().setMenu(menuMan.createContextMenu(viewer.getControl()));
  }
  protected void makeActions(final IWorkbenchWindow window) {
    // Creates the actions and registers them.
    // Registering is needed to ensure that key bindings work.
    // The corresponding commands keybindings are defined in the plugin.xml
    // file.
    // Registering also provides automatic disposal of the actions when
    // the window is closed.

    this.window = window;

    exitAction = ActionFactory.QUIT.create(window);
    register(exitAction);
    {
      closeAction = ActionFactory.CLOSE.create(window);
      register(closeAction);
    }
    {
      closeAllAction = ActionFactory.CLOSE_ALL.create(window);
      register(closeAllAction);
    }
    {
      saveAction = ActionFactory.SAVE.create(window);
      register(saveAction);
    }
    {
      saveAsAction = ActionFactory.SAVE_AS.create(window);
      register(saveAsAction);
    }
    {
      saveAllAction = ActionFactory.SAVE_ALL.create(window);
      register(saveAllAction);
    }
    sizeAction1 =
        new Action("176x208") {
          public void run() {
            Settings.setScreenSize(176, 208);
          }
        };

    sizeAction2 =
        new Action("240x320") {
          public void run() {
            Settings.setScreenSize(240, 320);
          }
        };

    sizeAction3 =
        new Action("320x240") {
          public void run() {
            Settings.setScreenSize(320, 240);
          }
        };

    sizeAction4 =
        new Action("480x320") {
          public void run() {
            Settings.setScreenSize(480, 320);
          }
        };

    sizeAction5 =
        new Action("640x360") {
          public void run() {
            Settings.setScreenSize(640, 360);
          }
        };

    sizeAction6 =
        new Action("960x640") {
          public void run() {
            Settings.setScreenSize(960, 640);
          }
        };

    undoAction =
        new Action("&Undo") {
          public void run() {
            this.firePropertyChange("chosen", this, this);
          }
        };
    undoAction.setEnabled(false);
    undoAction.setImageDescriptor(
        ResourceManager.getPluginImageDescriptor(
            WorkshopPlugin.getDefault(), "icons/undo_edit(1).gif"));
    undoAction.setDisabledImageDescriptor(
        ResourceManager.getPluginImageDescriptor(
            WorkshopPlugin.getDefault(), "icons/undo_edit.gif"));
    undoAction.setAccelerator(SWT.CTRL | 'z');

    redoAction =
        new Action("&Redo") {
          public void run() {
            this.firePropertyChange("chosen", this, this);
          }
        };
    redoAction.setEnabled(false);
    redoAction.setImageDescriptor(
        ResourceManager.getPluginImageDescriptor(
            WorkshopPlugin.getDefault(), "icons/redo_edit(1).gif"));
    redoAction.setDisabledImageDescriptor(
        ResourceManager.getPluginImageDescriptor(
            WorkshopPlugin.getDefault(), "icons/redo_edit.gif"));
    redoAction.setAccelerator(SWT.CTRL | 'y');
    {
      newWizardDropDownAction = ActionFactory.NEW_WIZARD_DROP_DOWN.create(window);
      register(newWizardDropDownAction);
    }

    chooseImageEditorAction =
        new Action("工具设置...") {
          public void run() {
            onChooseImageEditor();
          }
        };

    viewDirectoryAction =
        new Action("Resource Explorer") {
          public void run() {
            try {
              window.getActivePage().showView(DirectoryView.ID);
            } catch (Exception e) {
            }
          }
        };
    viewDirectoryAction.setImageDescriptor(
        ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/items.gif"));

    viewTileLibraryAction =
        new Action("Tile Library") {
          public void run() {
            try {
              window.getActivePage().showView(TileLibView.ID);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        };
    viewTileLibraryAction.setImageDescriptor(
        ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/tilelib.gif"));

    viewTileViewAction =
        new Action("Tile Viewer") {
          public void run() {
            try {
              window.getActivePage().showView(TileView.ID);
              //			window.getActivePage().showView("org.eclipse.swt.sleak.views.SleakView");
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        };
    viewTileViewAction.setImageDescriptor(
        ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/tiles.gif"));

    optimizeColorsAction =
        new Action("Optimize PNG Colors...") {
          public void run() {
            new PNGColorOptimizer().run(window.getShell());
          }
        };

    openLogDirAction =
        new Action("打开日志目录") {
          public void run() {
            String dir = Settings.logDir;
            String cmd = "explorer.exe \"" + dir + "\"";
            try {
              Runtime.getRuntime().exec(cmd);
            } catch (Exception e) {
            }
          }
        };

    projectViewAction =
        new Action("ProjectView") {
          public void run() {
            try {
              window.getActivePage().showView(ProjectView.ID);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        };
    projectViewAction.setImageDescriptor(
        ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/project.gif"));

    frameDelayAction5 =
        new Action("20毫秒") {
          public void run() {
            Settings.animateFrameDelay = 20;
          }
        };

    frameDelayAction6 =
        new Action("10毫秒") {
          public void run() {
            Settings.animateFrameDelay = 10;
          }
        };

    frameDelayAction1 =
        new Action("40毫秒") {
          public void run() {
            Settings.animateFrameDelay = 40;
          }
        };

    frameDelayAction2 =
        new Action("60毫秒") {
          public void run() {
            Settings.animateFrameDelay = 60;
          }
        };

    frameDelayAction3 =
        new Action("80毫秒") {
          public void run() {
            Settings.animateFrameDelay = 80;
          }
        };

    frameDelayAction4 =
        new Action("100毫秒") {
          public void run() {
            Settings.animateFrameDelay = 100;
          }
        };

    limitPIPAction =
        new Action("限制PIP图片大小", IAction.AS_CHECK_BOX) {
          public void run() {
            PipImage.limitSize = !PipImage.limitSize;
          }
        };
    limitPIPAction.setChecked(PipImage.limitSize);

    allowMultiCompAction =
        new Action("允许一个PIP包含多个压缩纹理", IAction.AS_CHECK_BOX) {
          public void run() {
            PipImage.allowMultiCompressTexturesInOneFile =
                !PipImage.allowMultiCompressTexturesInOneFile;
          }
        };
    allowMultiCompAction.setChecked(PipImage.allowMultiCompressTexturesInOneFile);

    actionFontTool =
        new Action("字体工具...") {
          public void run() {
            FontViewDialog dlg = new FontViewDialog(window.getShell());
            dlg.open();
          }
        };

    openglAction =
        new Action("OpenGL模式", IAction.AS_CHECK_BOX) {
          public void run() {
            GLUtils.glEnabled = !GLUtils.glEnabled;
          }
        };
    openglAction.setImageDescriptor(
        ResourceManager.getPluginImageDescriptor(WorkshopPlugin.getDefault(), "icons/gl.gif"));
    openglAction.setToolTipText("开启/关闭OpenGL模式");
    openglAction.setChecked(GLUtils.glEnabled);

    optimizeImageAction =
        new Action("图片优化工具...") {
          public void run() {
            try {
              IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path("."));
              FileStoreEditorInput input = new FileStoreEditorInput(fileStore);
              window.getActivePage().openEditor(input, ImageOptimizeEditor.ID);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        };

    comparePipAction =
        new Action("比较PIP图片...") {
          public void run() {
            try {
              IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path("."));
              FileStoreEditorInput input = new FileStoreEditorInput(fileStore);
              window.getActivePage().openEditor(input, ImageCompareEditor.ID);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        };

    batchConvertAction =
        new Action("批量格式转换...") {
          public void run() {
            DirectoryDialog dlg = new DirectoryDialog(window.getShell());
            dlg.setMessage("请选择源目录:");
            String dir = dlg.open();
            if (dir == null) {
              return;
            }
            dlg.setMessage("请选择目标目录:");
            String targetDir = dlg.open();
            if (targetDir == null) {
              return;
            }

            BatchConvertDialog dlg2 = new BatchConvertDialog(window.getShell());
            try {
              dlg2.setDirectory(dir, targetDir);
              dlg2.open();
            } catch (Exception e1) {
              SWTUtils.showError(window.getShell(), "错误", e1);
            }
          }
        };

    testAction =
        new Action("test") {
          public void run() {
            // new TestPathDialog(null).open();
          }
        };
  }