示例#1
0
  private void makeActions() {
    action1 =
        new Action() {
          public void run() {
            showMessage("Action 1 executed");
          }
        };
    action1.setText("Action 1");
    action1.setToolTipText("Action 1 tooltip");
    action1.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));

    action2 =
        new Action() {
          public void run() {
            showMessage("Action 2 executed");
          }
        };
    action2.setText("Action 2");
    action2.setToolTipText("Action 2 tooltip");
    action2.setImageDescriptor(
        PlatformUI.getWorkbench()
            .getSharedImages()
            .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
    doubleClickAction =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();
            Object obj = ((IStructuredSelection) selection).getFirstElement();
            showMessage("Double-click detected on " + obj.toString());
          }
        };
  }
 private void createActions() {
   sampleAction =
       new Action() {
         public void run() {
           MessageDialog.openInformation(null, "EWicket", "Sample Action Executed");
         }
       };
   sampleAction.setText("Sample Action");
   sampleAction.setToolTipText("Sample Action tool tip");
   sampleAction.setImageDescriptor(
       PlatformUI.getWorkbench()
           .getSharedImages()
           .getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK));
 }