Esempio n. 1
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;
 }
 public void setFocus() {
   if (filterAction.isChecked()) {
     txtFilter.setFocus();
   } else {
     doSetFocus();
   }
 }
Esempio n. 3
0
  private void updatePreview(boolean force) {
    if (swtXmlEditorPart == null) {
      setContent(null);
      return;
    }

    IDocument doc = (IDocument) swtXmlEditorPart.getAdapter(IDocument.class);
    IDocumentExtension4 document = (IDocumentExtension4) doc;
    if (force || document.getModificationStamp() != lastPreviewModificationStamp) {
      try {
        ResizableComposite resizableComposite = null;
        Composite newComposite;
        Composite swtXmlComposite;

        if (resizeAction.isChecked()) {
          resizableComposite = new ResizableComposite(container);
          newComposite = resizableComposite;
          swtXmlComposite = resizableComposite.getResizeableComposite();
        } else {
          newComposite = swtXmlComposite = new Composite(container, SWT.None);
        }

        IEditorInput editorInput = swtXmlEditorPart.getEditorInput();
        ILocationProvider locationProvider =
            (ILocationProvider) editorInput.getAdapter(ILocationProvider.class);

        File file =
            (locationProvider == null) ? null : locationProvider.getPath(editorInput).toFile();
        FileEditorInput input = (FileEditorInput) editorInput;
        SwtXmlParser parser =
            new SwtXmlParser(
                swtXmlComposite, new PreviewResource(getProjectRootDir(input), file, doc), null);
        parser.parse();
        setContent(newComposite);

        if (resizableComposite != null) {
          resizableComposite.resetSize();
        }
      } catch (Exception e) {
        Activator.getDefault()
            .getLog()
            .log(new Status(Status.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
        setContent(new ErrorComposite(container, SWT.NONE, e));
      } finally {
        lastPreviewModificationStamp = document.getModificationStamp();
        container.layout();
      }
    }
  }