public void propertyChange(PropertyChangeEvent evt) {
   IFormPage page = (IFormPage) getManagedForm().getContainer();
   if (page.isActive()) {
     refresh();
   } else {
     markStale();
   }
 }
Exemplo n.º 2
0
 @Override
 public void setFocus() {
   IFormPage page = getActivePageInstance();
   if (page != null) {
     page.setFocus();
   } else {
     super.setFocus();
   }
 }
Exemplo n.º 3
0
 @Deprecated
 public void setFocusOfActivePage() {
   if (this.getActivePage() > -1) {
     IFormPage page = this.getPages()[this.getActivePage()];
     if (page != null) {
       page.setFocus();
     }
   }
 }
Exemplo n.º 4
0
 @Override
 public boolean isDirty() {
   for (IFormPage page : getPages()) {
     if (page.isDirty()) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 5
0
 /**
  * Refresh editor pages with new contents.
  *
  * @since 3.0
  */
 public void refreshPages() {
   for (IFormPage page : getPages()) {
     if (page instanceof TaskFormPage) {
       if (page.getManagedForm() != null && !page.getManagedForm().getForm().isDisposed()) {
         ((TaskFormPage) page).refresh();
       }
     }
   }
 }
Exemplo n.º 6
0
  @Override
  public void doSave(IProgressMonitor monitor) {
    for (IFormPage page : getPages()) {
      if (page.isDirty()) {
        page.doSave(monitor);
      }
    }

    editorDirtyStateChanged();
  }
Exemplo n.º 7
0
 public void propertyChange(PropertyChangeEvent evt) {
   if (editablePropertySet.contains(evt.getPropertyName())) {
     IFormPage page = (IFormPage) getManagedForm().getContainer();
     if (page.isActive()) {
       refresh();
     } else {
       markStale();
     }
   }
 }
  protected void pageChange(int newPageIndex) {
    if ((newPageIndex == sourceEditorIndex) && (dirty)) {
      updateSourceFromDesign();
    } else if ((newPageIndex == formEditorIndex) && (sourceDirty)) {
      updateDesignFromSource();
    }

    super.pageChange(newPageIndex);

    final IFormPage page = getActivePageInstance();
    if (page != null) {
      page.setFocus();
    }
  }
 private void tryToInitFromActiveEditor() {
   IEditorPart editor =
       PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
   if (editor instanceof FormEditor) {
     FormEditor fe = (FormEditor) editor;
     IFormPage page = fe.getActivePageInstance();
     if (page.getEditorInput() instanceof GenericEditorInput<?>) {
       GenericEditorInput<?> editorInput = (GenericEditorInput<?>) page.getEditorInput();
       Object obj = editorInput.getEntity();
       if (obj instanceof Deployment) {
         addDeployment((Deployment) obj);
       }
       setLighthouseDomain(editorInput.getDomain());
     }
   }
 }
Exemplo n.º 10
0
 @SuppressWarnings("rawtypes")
 @Override
 public Object getAdapter(Class adapter) {
   if (contentOutlineProvider != null) {
     return contentOutlineProvider.getAdapter(adapter);
   } else if (IContentOutlinePage.class.equals(adapter)) {
     IFormPage[] pages = getPages();
     for (IFormPage page : pages) {
       Object outlinePage = page.getAdapter(adapter);
       if (outlinePage != null) {
         return outlinePage;
       }
     }
   }
   return super.getAdapter(adapter);
 }
Exemplo n.º 11
0
  void showHighestPriorityPage() {
    int selectedPrio = Integer.MIN_VALUE;
    String selected = null;

    BndPreferences prefs = new BndPreferences();
    if (prefs.getEditorOpenSourceTab()) {
      selected = SOURCE_PAGE;
      selectedPrio = 0;
    }

    for (Object pageObj : pages) {
      IFormPage page = (IFormPage) pageObj;
      int priority = 0;
      if (page instanceof IPriority) priority = ((IPriority) page).getPriority();
      if (priority > selectedPrio) {
        selected = page.getId();
        selectedPrio = priority;
      }
    }

    if (selected != null) setActivePage(selected);
  }
Exemplo n.º 12
0
 /** Switches focus in the editor to the page where this required body block is. */
 private void switchFocus(ArtifactKeyBuilder select) {
   FormEditor editor = m_formPage.getEditor();
   IFormPage currentPage = editor.getActivePageInstance();
   if (!m_formPage.getId().equals(currentPage.getId())) editor.setActivePage(m_formPage.getId());
   if (select != null) m_viewer.setSelection(new StructuredSelection(select), true);
 }
Exemplo n.º 13
0
 IJavaProject getJavaProject() {
   IFormPage formPage = (IFormPage) getManagedForm().getContainer();
   IFile file = ResourceUtil.getFile(formPage.getEditorInput());
   return file != null ? JavaCore.create(file.getProject()) : null;
 }
Exemplo n.º 14
0
 protected void removePage(String pageId) {
   IFormPage page = findPage(pageId);
   if (page != null) {
     removePage(page.getIndex());
   }
 }
Exemplo n.º 15
0
  void updatePages() {
    List<String> requiredPageIds = new LinkedList<String>();

    // Need to know the file and project names.
    Pair<String, String> fileAndProject = getFileAndProject(getEditorInput());
    String path = fileAndProject.getFirst();
    String projectName = fileAndProject.getSecond();

    if (isMainWorkspaceConfig(path, projectName)) {
      requiredPageIds.add(WORKSPACE_PAGE);
    } else if (isExtWorkspaceConfig(path, projectName)) {
      requiredPageIds.add(WORKSPACE_EXT_PAGE);
      setTitleImage(buildFileImg);
    } else if (path.endsWith(LaunchConstants.EXT_BNDRUN)) {
      requiredPageIds.addAll(getPagesBndRun());
    } else {
      requiredPageIds.addAll(getPagesBnd(path));
    }
    requiredPageIds.add(SOURCE_PAGE);

    // Remove pages no longer required and remember the rest in a map
    int i = 0;
    Map<String, IFormPage> pageCache = new HashMap<String, IFormPage>(requiredPageIds.size());
    while (i < getPageCount()) {
      IFormPage current = (IFormPage) pages.get(i);
      if (!requiredPageIds.contains(current.getId())) removePage(i);
      else {
        pageCache.put(current.getId(), current);
        i++;
      }
    }

    // Cache new pages
    for (String pageId : requiredPageIds) {
      if (!pageCache.containsKey(pageId)) {
        IFormPage page =
            SOURCE_PAGE.equals(pageId)
                ? sourcePage
                : pageFactories.get(pageId).createPage(this, model, pageId);
        pageCache.put(pageId, page);
      }
    }

    // Add pages back in
    int requiredPointer = 0;
    int existingPointer = 0;

    while (requiredPointer < requiredPageIds.size()) {
      try {
        String requiredId = requiredPageIds.get(requiredPointer);
        if (existingPointer >= getPageCount()) {
          if (SOURCE_PAGE.equals(requiredId)) addPage(sourcePage, getEditorInput());
          else addPage(pageCache.get(requiredId));
        } else {
          IFormPage existingPage = (IFormPage) pages.get(existingPointer);
          if (!requiredId.equals(existingPage.getId())) {
            if (SOURCE_PAGE.equals(requiredId))
              addPage(existingPointer, sourcePage, getEditorInput());
            else addPage(existingPointer, pageCache.get(requiredId));
          }
        }
        existingPointer++;
      } catch (PartInitException e) {
        logger.logError("Error adding page(s) to the editor.", e);
      }
      requiredPointer++;
    }

    // Set the source page title
    setPageText(sourcePage.getIndex(), "Source");
  }