コード例 #1
0
 /**
  * @param aContentService
  * @param descriptor
  * @return True if the descriptor is visible to the given content service.
  */
 private boolean isVisible(
     INavigatorContentService aContentService, CommonWizardDescriptor descriptor) {
   return !WorkbenchActivityHelper.filterItem(descriptor)
       && (aContentService == null
           || (descriptor.getId() == null
               || (aContentService.isVisible(descriptor.getId())
                   && aContentService.isActive(descriptor.getId()))));
 }
コード例 #2
0
 /** Constructor */
 public ContentMRUAction(
     int order,
     INavigatorContentDescriptor contentDescriptor,
     INavigatorContentService contentService,
     CommonViewer commonViewer) {
   super(
       "" + order + " " + contentDescriptor.getName(), AS_CHECK_BOX); // $NON-NLS-1$//$NON-NLS-2$
   this.contentDescriptor = contentDescriptor;
   this.contentService = contentService;
   this.commonViewer = commonViewer;
   setChecked(contentService.isActive(contentDescriptor.getId()));
 }
コード例 #3
0
 /*
  * (non-Javadoc)
  * @see org.eclipse.jface.action.Action#run()
  */
 @Override
 public void run() {
   Set<String> activeIds = new HashSet<String>();
   String[] visibleIds = contentService.getVisibleExtensionIds();
   if (visibleIds != null) {
     for (String visibleId : visibleIds) {
       if (contentService.isActive(visibleId)) activeIds.add(visibleId);
     }
   }
   if (isChecked()) activeIds.add(contentDescriptor.getId());
   else activeIds.remove(contentDescriptor.getId());
   String[] idsToActivate = activeIds.toArray(new String[activeIds.size()]);
   UpdateActiveExtensionsOperation updateExtensions =
       new UpdateActiveExtensionsOperation(commonViewer, idsToActivate);
   updateExtensions.execute(null, null);
 }
コード例 #4
0
  /** {@inheritDoc} */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    if (getCommonNavigator() == null || getCommonNavigator().getCommonViewer() == null) {
      return null; // The model explorer is not displayed (The editor is closed?)
    }

    CommonViewer viewer = getCommonNavigator().getCommonViewer();

    String[] newContents = null;

    Object trigger = event.getTrigger();

    if (trigger instanceof Event) {
      // State based on the widget
      Event triggerEvent = (Event) trigger;
      if (triggerEvent.widget instanceof ToolItem) {
        if (((ToolItem) triggerEvent.widget).getSelection()) {
          newContents = new String[] {DIAGRAM_CONTENTS};
        } else {
          newContents = new String[] {UML_MODEL_CONTENTS};
        }
      }
    }

    if (newContents == null) {
      // Revert the current state
      INavigatorContentService navigatorContent = viewer.getNavigatorContentService();

      if (navigatorContent.isActive(DIAGRAM_CONTENTS)) {
        newContents = new String[] {UML_MODEL_CONTENTS};
      } else {
        newContents = new String[] {DIAGRAM_CONTENTS};
      }
    }

    UpdateActiveExtensionsOperation updateExtensions =
        new UpdateActiveExtensionsOperation(viewer, newContents);
    updateExtensions.execute(null, null);

    return null;
  }