Exemplo n.º 1
0
 private IAction createImageRecognitionModeAction() {
   IAction action = new Action("", IAction.AS_RADIO_BUTTON) { // $NON-NLS-1$
         @Override
         public void run() {
           recordingSupport.setMode(RecordingMode.ImageRecognition);
         }
       };
   action.setImageDescriptor(Images.getImageDescriptor(Images.PANEL_MODE_IML));
   action.setToolTipText(Messages.ControlPanelWindow_SwitchToRecognitionModeActionToolTip);
   dbc.bindValue(Actions.observeEnabled(action), modeEnablementObservable);
   dbc.bindValue(
       Actions.observeChecked(action),
       new ComputedValue(Boolean.TYPE) {
         @Override
         protected Object calculate() {
           return recordingSupport.getMode() == RecordingMode.ImageRecognition;
         }
       });
   return action;
 }
Exemplo n.º 2
0
 public ImageDescriptor getImage(Context context) {
   return Images.getImageDescriptor(Images.CONTEXT);
 }
Exemplo n.º 3
0
  private void createToolBar(Composite parent) {
    final Composite toolbarComposite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(1).applyTo(toolbarComposite);
    toolbarComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

    CoolBarManager coolBarManager = new CoolBarManager(SWT.HORIZONTAL | SWT.FLAT);
    {
      ToolBarManager manager = new ToolBarManager(SWT.HORIZONTAL | SWT.FLAT);
      IAction homeAction =
          new Action() {
            @Override
            public void run() {
              close();
            }
          };
      homeAction.setToolTipText(Messages.ControlPanelWindow_ReturnActionTooltip);
      homeAction.setImageDescriptor(Images.getImageDescriptor(Images.PANEL_HOME));
      manager.add(homeAction);

      IAction saveAction =
          new Action() {
            @Override
            public void run() {
              if (getModel() != null) {
                save();
              } else {
                saveAs();
              }
            }
          };

      saveAction.setMenuCreator(
          new ActionMenuCreator() {
            @Override
            protected void fill(MenuManager manager) {
              manager.add(
                  new Action(Messages.ControlPanelWindow_SaveAction) {
                    {
                      dbc.bindValue(
                          Actions.observeEnabled(this),
                          new ComputedValue() {
                            @Override
                            protected Object calculate() {
                              return getModel() != null;
                            }
                          });
                    }

                    @Override
                    public void run() {
                      save();
                    }
                  });
              manager.add(
                  new Action(Messages.ControlPanelWindow_SaveAsAction) {
                    @Override
                    public void run() {
                      saveAs();
                    }
                  });
            }
          });
      dbc.bindValue(
          Actions.observeToolTipText(saveAction),
          new ComputedValue() {
            @Override
            protected Object calculate() {
              if (getModel() != null) {
                return Messages.ControlPanelWindow_SaveAction;
              } else {
                return Messages.ControlPanelWindow_SaveAsAction;
              }
            }
          });
      ISharedImages sharedImages = WorkbenchPlugin.getDefault().getSharedImages();
      saveAction.setImageDescriptor(
          sharedImages.getImageDescriptor(ISharedImages.IMG_ETOOL_SAVE_EDIT));
      saveAction.setDisabledImageDescriptor(
          sharedImages.getImageDescriptor(ISharedImages.IMG_ETOOL_SAVE_EDIT_DISABLED));
      manager.add(saveAction);
      coolBarManager.add(manager);
    }
    {
      ToolBarManager manager = new ToolBarManager(SWT.HORIZONTAL | SWT.FLAT);
      manager.add(createRecordAction());
      manager.add(createReplayAction());
      coolBarManager.add(manager);
    }
    {
      ToolBarManager manager = new ToolBarManager(SWT.HORIZONTAL | SWT.FLAT);
      manager.add(createRecordingModeAction());
      manager.add(createAssertingModeAction());
      if (Q7UIPlugin.isImageRecognitionAllowed()) {
        manager.add(createImageRecognitionModeAction());
      }
      coolBarManager.add(manager);
    }
    coolBar = coolBarManager.createControl(toolbarComposite);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(coolBar);
    coolBar.addListener(
        SWT.Resize,
        new Listener() {
          public void handleEvent(Event event) {
            getShell().layout();
          }
        });
  }