Ejemplo n.º 1
0
 protected void createActions() {
   super.createActions();
   final Action action =
       new ContentAssistAction(
           ResourceBundle.getBundle(GroovyEditor.class.getPackage().getName() + ".messages"),
           "ContentAssistProposal.",
           this);
   action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
   setAction("ContentAssist", action);
 }
Ejemplo n.º 2
0
  private ActionHandler createQuickFixActionHandler(
      final ITextOperationTarget textOperationTarget) {
    Action quickFixAction =
        new Action() {

          public void run() {
            textOperationTarget.doOperation(ISourceViewer.QUICK_ASSIST);
          }
        };
    quickFixAction.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
    return new ActionHandler(quickFixAction);
  }
Ejemplo n.º 3
0
 private ActionHandler createContentAssistActionHandler(
     final ITextOperationTarget textOperationTarget) {
   Action proposalAction =
       new Action() {
         public void run() {
           if (textOperationTarget.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS)
               && getTextWidget().isFocusControl())
             textOperationTarget.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
         }
       };
   proposalAction.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
   return new ActionHandler(proposalAction);
 }
Ejemplo n.º 4
0
 /**
  * Needed for content assistant in the Text viewer. This ensures actions such as key press would
  * trigger content assistant
  */
 @SuppressWarnings("deprecation")
 protected void createActions() {
   super.createActions();
   ResourceBundle bundle = T24BasicPlugin.getDefault().getResourceBundle();
   String id = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
   Action action = new ContentAssistAction(bundle, "ContentAssistProposal", this);
   action.setActionDefinitionId(id);
   setAction("ContentAssistProposal", action);
   this.markAsContentDependentAction(id, true);
   ResourceAction printAction =
       new TextOperationAction(bundle, "Editor.Print.", this, ITextOperationTarget.PRINT, true);
   String printid = IWorkbenchActionDefinitionIds.PRINT;
   printAction.setHelpContextId(IAbstractTextEditorHelpContextIds.PRINT_ACTION);
   printAction.setActionDefinitionId(printid);
   setAction(ITextEditorActionConstants.PRINT, new PrintActionDecorator(printAction));
   this.markAsContentDependentAction(printid, true);
 }
  @Override
  protected void createActions() {
    super.createActions();

    ResourceBundle bundle = ResourceBundle.getBundle("bpelexpression"); // $NON-NLS-1$
    Action action = new ContentAssistAction(bundle, "ContentAssistProposal.", this); // $NON-NLS-1$
    String id = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
    action.setActionDefinitionId(id);
    setAction("ContentAssistProposal", action); // $NON-NLS-1$
    markAsStateDependentAction("ContentAssistProposal", true); // $NON-NLS-1$

    this.fVariablePickerAction =
        new VariablePickerAction(
            XPathEditorMessages.getBundleForConstructedKeys(),
            "Editor.VariablePicker.",
            this); //$NON-NLS-1$
    // action.setHelpContextId(IAbstractTextEditorHelpContextIds.GOTO_LINE_ACTION);
    this.fVariablePickerAction.setActionDefinitionId(
        IXPathEditorActionDefinitionIds.VARIABLE_PICKER);
    setAction(IXPathEditorActionConstants.VARIABLE_PICKER, this.fVariablePickerAction);
  }
Ejemplo n.º 6
0
  @Override
  protected void createActions() {
    super.createActions();
    // TODO: Figure out how to do this later.
    //  	fFoldingGroup= new FoldingActionGroup(this, getSourceViewer());

    // Sticky hover support
    ResourceAction resAction =
        new TextOperationAction(
            AutoconfEditorMessages.getResourceBundle(),
            "ShowToolTip.",
            this,
            ISourceViewer.INFORMATION,
            true); //$NON-NLS-1$
    resAction =
        new InformationDispatchAction(
            AutoconfEditorMessages.getResourceBundle(),
            "ShowToolTip.",
            (TextOperationAction) resAction); // $NON-NLS-1$
    resAction.setActionDefinitionId(IAutotoolEditorActionDefinitionIds.SHOW_TOOLTIP);
    setAction("ShowToolTip", resAction); // $NON-NLS-1$
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(resAction, IAutotoolHelpContextIds.SHOW_TOOLTIP_ACTION);

    // Content assist
    Action action =
        new ContentAssistAction(
            AutoconfEditorMessages.getResourceBundle(),
            "ContentAssistProposal.",
            this); //$NON-NLS-1$
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    setAction("ContentAssistProposal", action); // $NON-NLS-1$
    markAsStateDependentAction("ContentAssistProposal", true); // $NON-NLS-1$
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(action, IAutotoolHelpContextIds.CONTENT_ASSIST);
  }
  private void makeActions() {
    fCodeSelectAction =
        new Action(
            "Set Input from Editor (&codeSelect)", JEPluginImages.IMG_SET_FOCUS_CODE_SELECT) {
          @Override
          public void run() {
            IEditorPart editor = getSite().getPage().getActiveEditor();
            if (editor == null) {
              setEmptyInput();
              return;
            }
            IEditorInput input = editor.getEditorInput();
            ISelectionProvider selectionProvider = editor.getSite().getSelectionProvider();
            if (input == null || selectionProvider == null) {
              setEmptyInput();
              return;
            }
            ISelection selection = selectionProvider.getSelection();
            if (!(selection instanceof ITextSelection)) {
              setEmptyInput();
              return;
            }
            IJavaElement javaElement = (IJavaElement) input.getAdapter(IJavaElement.class);
            if (javaElement == null) {
              setEmptyInput();
              return;
            }

            IJavaElement[] resolved;
            try {
              resolved = codeResolve(javaElement, (ITextSelection) selection);
            } catch (JavaModelException e) {
              setEmptyInput();
              return;
            }
            if (resolved.length == 0) {
              setEmptyInput();
              return;
            }

            setInput(Arrays.asList(resolved));
          }
        };
    fCodeSelectAction.setToolTipText("Set input from current editor's selection (codeSelect)");

    fElementAtAction =
        new Action("Set Input from Editor location (&getElementAt)", JEPluginImages.IMG_SET_FOCUS) {
          @Override
          public void run() {
            IEditorPart editor = getSite().getPage().getActiveEditor();
            if (editor == null) {
              setEmptyInput();
              return;
            }
            IEditorInput input = editor.getEditorInput();
            ISelectionProvider selectionProvider = editor.getSite().getSelectionProvider();
            if (input == null || selectionProvider == null) {
              setEmptyInput();
              return;
            }
            ISelection selection = selectionProvider.getSelection();
            if (!(selection instanceof ITextSelection)) {
              setEmptyInput();
              return;
            }
            IJavaElement javaElement = (IJavaElement) input.getAdapter(IJavaElement.class);
            if (javaElement == null) {
              setEmptyInput();
              return;
            }

            IJavaElement resolved;
            try {
              resolved = getElementAtOffset(javaElement, (ITextSelection) selection);
            } catch (JavaModelException e) {
              setEmptyInput();
              return;
            }
            if (resolved == null) {
              setEmptyInput();
              return;
            }

            setSingleInput(resolved);
          }
        };
    fElementAtAction.setToolTipText(
        "Set input from current editor's selection location (getElementAt)");

    fCreateFromHandleAction =
        new Action("Create From &Handle...") {
          @Override
          public void run() {
            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "Create Java Element From Handle Identifier",
                    "&Handle identifier:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            String handleIdentifier = dialog.getValue();
            IJavaElement javaElement = JavaCore.create(handleIdentifier);
            setSingleInput(javaElement);
          }
        };

    fFocusAction =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            if (selected instanceof JavaElement) {
              setSingleInput(((JavaElement) selected).getJavaElement());
            } else if (selected instanceof JEResource) {
              setSingleInput(((JEResource) selected).getResource());
            }
          }
        };
    fFocusAction.setToolTipText("Focus on Selection");

    fFindTypeAction =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IJavaProject project = (IJavaProject) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IJavaProject#findType(String fullyQualifiedName)",
                    "fullyQualifiedName:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;

            final String fullyQualifiedName = dialog.getValue();
            try {
              IType type = project.findType(fullyQualifiedName);
              JavaElement element = new JavaElement(fInput, fullyQualifiedName, type);
              fViewer.add(fInput, element);
              fViewer.setSelection(new StructuredSelection(element));
            } catch (JavaModelException e) {
              JEViewPlugin.log(e);
            }
          }
        };
    fFindTypeAction.setText("findType(String)...");

    fFindType2Action =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IJavaProject project = (IJavaProject) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IJavaProject#findType(String fullyQualifiedName, IProgressMonitor pm)",
                    "fullyQualifiedName:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            final String fullyQualifiedName = dialog.getValue();

            class Runner implements IRunnableWithProgress {
              IType type;

              public void run(IProgressMonitor monitor)
                  throws InvocationTargetException, InterruptedException {
                try {
                  type = project.findType(fullyQualifiedName, monitor);
                } catch (JavaModelException e) {
                  throw new InvocationTargetException(e);
                }
              }
            }
            Runner runner = new Runner();
            try {
              PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runner);
            } catch (InvocationTargetException e) {
              JEViewPlugin.log(e);
            } catch (InterruptedException e) {
              JEViewPlugin.log(e);
            }
            JavaElement element = new JavaElement(fInput, fullyQualifiedName, runner.type);
            fViewer.add(fInput, element);
            fViewer.setSelection(new StructuredSelection(element));
          }
        };
    fFindType2Action.setText("findType(String, IProgressMonitor)...");

    fResolveTypeAction =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IType type = (IType) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IType#resolveType(String typeName)",
                    "typeName:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            final String typeName = dialog.getValue();

            JavaElementChildrenProperty element =
                new JavaElementChildrenProperty(
                    fInput,
                    "'" + type.getFullyQualifiedName() + "'.resolveType(\"" + typeName + "\")") {
                  @Override
                  protected JEAttribute[] computeChildren() throws Exception {
                    String[][] resolvedTypes = type.resolveType(typeName);
                    if (resolvedTypes == null) {
                      return new JEAttribute[] {new Null(this, "result")};
                    }
                    JEAttribute[] resolvedJEAttributes = new JEAttribute[resolvedTypes.length];
                    for (int i = 0; i < resolvedTypes.length; i++) {
                      String[] resolvedType = resolvedTypes[i];
                      resolvedJEAttributes[i] =
                          new JavaElementProperty(
                              this, null, resolvedType[0] + ", " + resolvedType[1]);
                    }
                    return resolvedJEAttributes;
                  }
                };
            fViewer.add(fInput, element);
            fViewer.setSelection(new StructuredSelection(element));
            fViewer.setExpandedState(element, true);
          }
        };
    fResolveTypeAction.setText("resolveType(String)...");

    fGetAnnotationAction =
        new Action() {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IAnnotatable annotatable =
                (IAnnotatable) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IAnnotatable#getAnnotation(String name)",
                    "name:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            final String name = dialog.getValue();

            JavaElementChildrenProperty element =
                new JavaElementChildrenProperty(
                    fInput,
                    "'"
                        + ((IJavaElement) annotatable).getElementName()
                        + "'.getAnnotation(\""
                        + name
                        + "\")") {
                  @Override
                  protected JEAttribute[] computeChildren() throws Exception {
                    IAnnotation annotation = annotatable.getAnnotation(name);
                    return new JEAttribute[] {new JavaElement(this, annotation)};
                  }
                };
            fViewer.add(fInput, element);
            fViewer.setSelection(new StructuredSelection(element));
            fViewer.setExpandedState(element, true);
          }
        };
    fGetAnnotationAction.setText("getAnnotation(String)...");

    fCreateFromBindingKeyAction =
        new Action("Create From &Binding Key...") {
          @Override
          public void run() {
            Object selected = ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
            final IJavaProject project = (IJavaProject) ((JavaElement) selected).getJavaElement();

            InputDialog dialog =
                new InputDialog(
                    getSite().getShell(),
                    "IJavaProject#findElement(String bindingKey, WorkingCopyOwner owner)",
                    "&bindingKey:",
                    "",
                    null);
            if (dialog.open() != Window.OK) return;
            final String bindingKey = dialog.getValue();

            class Runner implements IRunnableWithProgress {
              IJavaElement element;

              public void run(IProgressMonitor monitor)
                  throws InvocationTargetException, InterruptedException {
                try {
                  element = project.findElement(bindingKey, null);
                } catch (JavaModelException e) {
                  throw new InvocationTargetException(e);
                }
              }
            }
            Runner runner = new Runner();
            try {
              PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runner);
            } catch (InvocationTargetException e) {
              JEViewPlugin.log(e);
            } catch (InterruptedException e) {
              JEViewPlugin.log(e);
            }
            JavaElement element = new JavaElement(fInput, bindingKey, runner.element);
            fViewer.add(fInput, element);
            fViewer.setSelection(new StructuredSelection(element));
          }
        };

    fResetAction =
        new Action("&Reset View", getJavaModelImageDescriptor()) {
          @Override
          public void run() {
            reset();
          }
        };
    fResetAction.setToolTipText("Reset View to JavaModel");

    fRefreshAction =
        new Action("Re&fresh", JEPluginImages.IMG_REFRESH) {
          @Override
          public void run() {
            BusyIndicator.showWhile(
                getSite().getShell().getDisplay(),
                new Runnable() {
                  public void run() {
                    fViewer.refresh();
                  }
                });
          }
        };
    fRefreshAction.setToolTipText("Refresh");
    fRefreshAction.setActionDefinitionId("org.eclipse.ui.file.refresh");

    fCopyAction = new TreeCopyAction(new Tree[] {fViewer.getTree()});

    fPropertiesAction =
        new Action("&Properties", JEPluginImages.IMG_PROPERTIES) {
          @Override
          public void run() {
            String viewId = IPageLayout.ID_PROP_SHEET;
            IWorkbenchPage page = getViewSite().getPage();
            IViewPart view;
            try {
              view = page.showView(viewId);
              page.activate(JavaElementView.this);
              page.bringToTop(view);
            } catch (PartInitException e) {
              JEViewPlugin.log("could not find Properties view", e);
            }
          }
        };
    fPropertiesAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);

    fDoubleClickAction =
        new Action() {
          private Object fPreviousDouble;

          @Override
          public void run() {
            ISelection selection = fViewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();

            boolean isSecondDoubleClick = (obj == fPreviousDouble);
            fPreviousDouble = isSecondDoubleClick ? null : obj;

            if (obj instanceof JavaElement) {
              IJavaElement javaElement = ((JavaElement) obj).getJavaElement();
              if (javaElement != null) {
                switch (javaElement.getElementType()) {
                  case IJavaElement.JAVA_MODEL:
                    break;

                  case IJavaElement.JAVA_PROJECT:
                  case IJavaElement.PACKAGE_FRAGMENT_ROOT:
                  case IJavaElement.PACKAGE_FRAGMENT:
                    ICommandService service =
                        (ICommandService) getSite().getService(ICommandService.class);
                    Command showInCommand =
                        service.getCommand(IWorkbenchCommandConstants.NAVIGATE_SHOW_IN);
                    Map<String, String> params =
                        Collections.singletonMap(
                            "org.eclipse.ui.navigate.showIn.targetId", JavaUI.ID_PACKAGES);
                    try {
                      Object context =
                          ((IHandlerService) getSite().getService(IHandlerService.class))
                              .getCurrentState();
                      showInCommand.executeWithChecks(
                          new ExecutionEvent(null, params, null, context));
                    } catch (ExecutionException e1) {
                      showAndLogError("Could not show element", e1);
                    } catch (NotDefinedException e1) {
                      showAndLogError("Could not show element", e1);
                    } catch (NotEnabledException e1) {
                      showAndLogError("Could not show element", e1);
                    } catch (NotHandledException e1) {
                      showAndLogError("Could not show element", e1);
                    }
                    break;

                  default:
                    try {
                      IEditorPart editorPart = JavaUI.openInEditor(javaElement);
                      if (editorPart != null) {
                        if (isSecondDoubleClick
                            && javaElement instanceof ISourceReference
                            && editorPart instanceof ITextEditor) {
                          ISourceRange sourceRange =
                              ((ISourceReference) javaElement).getSourceRange();
                          EditorUtility.selectInEditor(
                              (ITextEditor) editorPart,
                              sourceRange.getOffset(),
                              sourceRange.getLength());
                        } else {
                          JavaUI.revealInEditor(editorPart, javaElement);
                        }
                      }
                    } catch (PartInitException e) {
                      showAndLogError("Could not open editor.", e); // $NON-NLS-1$
                    } catch (JavaModelException e) {
                      showAndLogError("Could not open editor.", e); // $NON-NLS-1$
                    }
                }
              }

            } else if (obj instanceof Error) {
              Error error = (Error) obj;
              JEViewPlugin.log(error.getException());

            } else if (obj instanceof JEMarker) {
              JEMarker marker = (JEMarker) obj;
              try {
                IDE.openEditor(getSite().getPage(), marker.getMarker());
              } catch (PartInitException e) {
                showAndLogError("Could not open editor.", e); // $NON-NLS-1$
              }
            }
          }
        };

    fCompareAction =
        new Action() {
          @Override
          public void run() {
            TreePath[] selection = ((ITreeSelection) fViewer.getSelection()).getPaths();
            Object first = ((JEAttribute) selection[0].getLastSegment()).getWrappedObject();
            Object second = ((JEAttribute) selection[1].getLastSegment()).getWrappedObject();
            boolean identical = first == second;
            boolean equals1 = first != null && first.equals(second);
            boolean equals2 = second != null && second.equals(first);
            boolean inconsistentEquals = equals1 != equals2;

            String msg =
                "==: "
                    + identical
                    + "\nequals(..): "
                    + (inconsistentEquals ? "INCONSISTENT" : equals1);
            MessageDialog.openInformation(fViewer.getTree().getShell(), "Comparison", msg);
          }
        };
    fCompareAction.setText("C&ompare with Each Other...");

    fLogDeltasAction =
        new Action("Log Java element deltas", IAction.AS_CHECK_BOX) {

          private IElementChangedListener fListener =
              new IElementChangedListener() {
                @SuppressWarnings("deprecation")
                public void elementChanged(ElementChangedEvent event) {
                  String type = "\nEvent type: ";
                  switch (event.getType()) {
                    case ElementChangedEvent.POST_CHANGE:
                      type += "POST_CHANGE";
                      break;
                    case ElementChangedEvent.POST_RECONCILE:
                      type += "POST_RECONCILE";
                      break;
                    case ElementChangedEvent.PRE_AUTO_BUILD:
                      type += "PRE_AUTO_BUILD";
                      break;
                    default:
                      type += event.getType();
                      break;
                  }
                  JEViewPlugin.logMessage(event.getDelta().toString() + type);
                }
              };

          @Override
          public void run() {
            String message;
            if (!isChecked()) {
              JavaCore.removeElementChangedListener(fListener);
              message = "Element listener removed";
            } else {
              JavaCore.addElementChangedListener(fListener);
              message = "Element listener added. Deltas are now written to log.";
            }
            MessageDialog.openInformation(
                fViewer.getTree().getShell(), "Log Java Element Deltas", message);
          }
        };
  }
Ejemplo n.º 8
0
  protected void createActions() {
    ISharedImages sharedImages =
        getViewSite().getWorkbenchWindow().getWorkbench().getSharedImages();

    zoomInAction =
        new Action(Messages.ChartViewPart_ZoomInAction) {

          @Override
          public void run() {
            int factor = viewer.getZoomFactor();
            viewer.setZoomFactor(factor + 1);
            zoomOutAction.setEnabled(true);
            zoomResetAction.setEnabled(true);
          }
        };
    zoomInAction.setId("zoomIn"); // $NON-NLS-1$
    zoomInAction.setActionDefinitionId("org.eclipsetrader.ui.charts.zoomIn"); // $NON-NLS-1$

    zoomOutAction =
        new Action(Messages.ChartViewPart_ZoomOutAction) {

          @Override
          public void run() {
            int factor = viewer.getZoomFactor();
            if (factor > 0) {
              viewer.setZoomFactor(factor - 1);
            }
            zoomOutAction.setEnabled(factor != 1);
            zoomResetAction.setEnabled(factor != 1);
          }
        };
    zoomOutAction.setId("zoomOut"); // $NON-NLS-1$
    zoomOutAction.setActionDefinitionId("org.eclipsetrader.ui.charts.zoomOut"); // $NON-NLS-1$

    zoomResetAction =
        new Action(Messages.ChartViewPart_NormalSizeAction) {

          @Override
          public void run() {
            viewer.setZoomFactor(0);
            zoomOutAction.setEnabled(false);
            zoomResetAction.setEnabled(false);
          }
        };
    zoomResetAction.setId("zoomReset"); // $NON-NLS-1$
    zoomResetAction.setActionDefinitionId("org.eclipsetrader.ui.charts.zoomReset"); // $NON-NLS-1$

    zoomOutAction.setEnabled(false);
    zoomResetAction.setEnabled(false);

    periodAllAction =
        new Action(Messages.ChartViewPart_AllPeriodAction, IAction.AS_RADIO_BUTTON) {

          @Override
          public void run() {
            setPeriod(null, TimeSpan.days(1));
          }
        };

    cutAction =
        new Action(Messages.ChartViewPart_CutAction) {

          @Override
          public void run() {}
        };
    cutAction.setId("cut"); // $NON-NLS-1$
    cutAction.setActionDefinitionId("org.eclipse.ui.edit.cut"); // $NON-NLS-1$
    cutAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
    cutAction.setDisabledImageDescriptor(
        sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED));
    cutAction.setEnabled(false);

    copyAction =
        new Action(Messages.ChartViewPart_CopyAction) {

          @Override
          public void run() {}
        };
    copyAction.setId("copy"); // $NON-NLS-1$
    copyAction.setActionDefinitionId("org.eclipse.ui.edit.copy"); // $NON-NLS-1$
    copyAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
    copyAction.setDisabledImageDescriptor(
        sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
    copyAction.setEnabled(false);

    pasteAction =
        new Action(Messages.ChartViewPart_PasteAction) {

          @Override
          public void run() {}
        };
    pasteAction.setId("copy"); // $NON-NLS-1$
    pasteAction.setActionDefinitionId("org.eclipse.ui.edit.paste"); // $NON-NLS-1$
    pasteAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
    pasteAction.setDisabledImageDescriptor(
        sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
    pasteAction.setEnabled(false);

    deleteAction =
        new Action(Messages.ChartViewPart_DeleteAction) {

          @Override
          public void run() {
            IStructuredSelection selection =
                (IStructuredSelection) getViewSite().getSelectionProvider().getSelection();
            if (!selection.isEmpty()) {
              if (MessageDialog.openConfirm(
                  getViewSite().getShell(),
                  getPartName(),
                  Messages.ChartViewPart_DeleteConfirmMessage)) {
                ChartViewItem viewItem = (ChartViewItem) selection.getFirstElement();
                ChartRowViewItem rowViewItem = (ChartRowViewItem) viewItem.getParent();
                if (rowViewItem.getItemCount() == 1) {
                  rowViewItem.getParentView().removeRow(rowViewItem);
                } else {
                  rowViewItem.removeChildItem(viewItem);
                }
              }
            }
          }
        };
    deleteAction.setId("delete"); // $NON-NLS-1$
    deleteAction.setActionDefinitionId("org.eclipse.ui.edit.delete"); // $NON-NLS-1$
    deleteAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
    deleteAction.setDisabledImageDescriptor(
        sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
    deleteAction.setEnabled(false);

    updateAction =
        new Action(Messages.ChartViewPart_UpdateAction) {

          @Override
          public void run() {
            doUpdate();
          }
        };
    updateAction.setId("update"); // $NON-NLS-1$
    updateAction.setImageDescriptor(
        UIActivator.getImageDescriptor("icons/etool16/refresh.gif")); // $NON-NLS-1$
    updateAction.setEnabled(true);

    propertiesAction =
        new PropertyDialogAction(
            new SameShellProvider(getViewSite().getShell()), getSite().getSelectionProvider()) {

          @Override
          public void run() {
            PreferenceDialog dialog = createDialog();
            if (dialog != null) {
              if (dialog.open() == Window.OK) {
                IStructuredSelection selection =
                    (IStructuredSelection) getSite().getSelectionProvider().getSelection();

                ChartViewItem viewItem = (ChartViewItem) selection.getFirstElement();
                ((ChartRowViewItem) viewItem.getParent()).refresh();

                refreshChart();
                setDirty();
              }
            }
          }
        };
    propertiesAction.setId(ActionFactory.PROPERTIES.getId());
    propertiesAction.setActionDefinitionId("org.eclipse.ui.file.properties"); // $NON-NLS-1$
    propertiesAction.setEnabled(false);

    currentPriceLineAction =
        new Action(Messages.ChartViewPart_ShowCurrentPriceAction, IAction.AS_CHECK_BOX) {

          @Override
          public void run() {
            currentPriceLineFactory.setEnable(isChecked());
            dialogSettings.put(K_SHOW_CURRENT_PRICE, isChecked());
          }
        };

    currentBookAction =
        new Action(Messages.ChartViewPart_ShowBookAction, IAction.AS_CHECK_BOX) {

          @Override
          public void run() {
            currentBookFactory.setEnable(isChecked());
            dialogSettings.put(K_SHOW_CURRENT_BOOK, isChecked());
          }
        };
  }