Example #1
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
   */
  public void setVisible(boolean visible) {
    super.setVisible(visible);
    if (visible) {
      final ReleaseWizard wizard = (ReleaseWizard) getWizard();
      try {
        // Get updated selected project in case that some projects have outgoing changes and
        // excluded by user
        wizard.updateSelectedProject();

        // Get the finalized selected projects and the associated tags from existing map files
        final IProject[] projects = wizard.getSelectedProjects();
        final CVSTag[] tags = mapProject.getTagsFor(projects);

        // Collect all the out-of-sync projects from selected projects and update the selected
        // project again
        getContainer()
            .run(
                true,
                true,
                new IRunnableWithProgress() {
                  public void run(IProgressMonitor monitor)
                      throws InvocationTargetException, InterruptedException {
                    IResource[] r = null;
                    if (projects != null && projects.length != 0) {
                      try {
                        r = getOutOfSyncProjects(projects, tags, monitor);
                        wizard.setSelectedProjects(r);
                      } catch (TeamException e) {
                        throw new InvocationTargetException(e);
                      }
                    }
                  }
                });

        // Show no-project-changed information on the page book if condition satisfied
        if (wizard.getSelectedProjects() == null || wizard.getSelectedProjects().length == 0) {
          setPageComplete(false);
          pageBook.showPage(noneChangeMessage);
        }
        // Open a compare editor otherwise
        else {
          setPageComplete(true);
          pageBook.showPage(compareView);
        }
      } catch (InvocationTargetException e) {
        CVSUIPlugin.openError(getShell(), null, null, e);
      } catch (InterruptedException e) {
        CVSUIPlugin.openError(getShell(), null, null, e);
      }
    }
    // When the page is invisible, it should not affect the wizard work flow by anyway
    else {
      setPageComplete(true);
    }
  }
 /**
  * Show page.
  *
  * @param id the id
  */
 protected void showPage(String id) {
   if (ID_ACTION_OUTLINE.equals(id)) {
     showOutlineAction.setChecked(true);
     showOverviewAction.setChecked(false);
     pageBook.showPage(outline);
     if (thumbnail != null) thumbnail.setVisible(false);
   } else if (ID_ACTION_OVERVIEW.equals(id)) {
     if (thumbnail == null) initializeOverview();
     showOutlineAction.setChecked(false);
     showOverviewAction.setChecked(true);
     pageBook.showPage(overview);
     thumbnail.setVisible(true);
   }
 }
  /** @param page */
  public void setPageActive(IContentOutlinePage page) {

    synchronized (fEditor) // don't want to call this while a reconciling
    // action
    // is occuring!
    {
      Control control = fCurrentPage.getControl();
      if ((control != null && !control.isDisposed()) && page == fCurrentPage) return;

      if (page == fMessagePage && fCurrentPage != fTapestryOutlinePage) page = fCurrentPage;

      if (page == fTapestryOutlinePage && fReconciledObject == null) page = fMessagePage;

      if (fCurrentPage != null) {
        fCurrentPage.removeSelectionChangedListener(this);
      }
      page.addSelectionChangedListener(this);
      this.fCurrentPage = page;
      if (fPageBook == null) {
        // still not being made
        return;
      }
      control = page.getControl();
      if (control == null || control.isDisposed()) {
        // first time
        page.createControl(fPageBook);
        control = page.getControl();
      }
      fPageBook.showPage(control);
      this.fCurrentPage = page;
    }
    updateToolbar();
  }
  @Override
  public void refresh() {
    PictogramElement pe = getSelectedPictogramElement();
    if (pe != null) {
      Object bo = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pe);
      _interface = null;

      // the filter assured, that it is a Service or Reference
      if (bo == null) {
        _composite.showPage(_blank);
        _composite.redraw();
        return;
      }
      if (bo instanceof Contract) {
        Contract contract = (Contract) bo;
        _interface = contract.getInterface();
      }

      if (_interface != null) {
        if (_modelComposites.get(_interface) == null) {
          TabbedPropertySheetWidgetFactory factory = getWidgetFactory();
          IInterfaceComposite composite =
              (IInterfaceComposite) InterfaceCompositeAdapter.adaptModelToComposite(_interface);
          if (composite != null) {
            ((AbstractSwitchyardComposite) composite).createContents(_composite, SWT.NONE);
            factory.adapt(((AbstractSwitchyardComposite) composite).getPanel());
            _modelComposites.put(_interface, composite);
          }
        }
        IInterfaceComposite composite = (IInterfaceComposite) _modelComposites.get(_interface);
        if (composite != null) {
          composite.setInterface(_interface);
          _composite.showPage(((AbstractSwitchyardComposite) composite).getPanel());
          Composite parent = _composite;
          // this is a hack to get it to refresh properly
          while (parent != null) {
            parent.layout(true, true);
            parent = parent.getParent();
          }
        } else {
          _composite.getParent().layout();
          _composite.showPage(_blank);
          _composite.layout(true, true);
        }
      } else {
        _composite.showPage(_blank);
        _composite.getParent().layout();
        _composite.layout(true, true);
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls
   * (org.eclipse.swt.widgets.Composite,
   * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
   */
  @Override
  public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
    super.createControls(parent, tabbedPropertySheetPage);

    TabbedPropertySheetWidgetFactory factory = getWidgetFactory();
    _composite = new PageBook(parent, SWT.NONE);
    factory.adapt(_composite);

    _blank = factory.createFlatFormComposite(_composite);
    _composite.showPage(_blank);
  }
Example #6
0
  private void createTestViewers(final Composite parent) {
    fViewerbook = new PageBook(parent, SWT.NULL);
    viewer = new TreeViewer(fViewerbook, SWT.V_SCROLL | SWT.SINGLE);

    labelProvider = new TestViewLabelProvider();
    contentProvider = new TestViewContentProvider();
    viewer.setContentProvider(contentProvider);
    viewer.setLabelProvider(labelProvider);

    fViewerbook.showPage(viewer.getTree());
  }
Example #7
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {
    Font font = parent.getFont();
    GridData data = new GridData(GridData.FILL_BOTH);

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(data);
    composite.setFont(font);

    pageBook = new PageBook(composite, SWT.NONE);
    pageBook.setLayoutData(new GridData(GridData.FILL_BOTH));
    pageBook.setFont(font);

    input = createCompareInput();
    input.createPartControl(pageBook);
    compareView = input.getControl();
    compareView.setFont(font);
    compareView.setLayoutData(data);

    noneChangeMessage = new Label(pageBook, SWT.WRAP);
    noneChangeMessage.setText(Messages.getString("ProjectComparePage.1")); // $NON-NLS-1$
    noneChangeMessage.setLayoutData(data);
    noneChangeMessage.setFont(font);

    buildNotesButton = new Button(composite, SWT.CHECK);
    buildNotesButton.setText(Messages.getString("ProjectComparePage.2")); // $NON-NLS-1$
    buildNotesButton.setFont(font);
    buildNotesButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            buildNotesButtonChecked = buildNotesButton.getSelection();
          }
        });

    initialize();
    setControl(composite);
  }
  public boolean showLoading() {
    if (pageBook.isDisposed()) {
      return false;
    }
    Display display = getDisplay();
    display.syncExec(
        new Runnable() {

          @Override
          public void run() {
            pageBook.showPage(loadingComposite);
            setBusyIndicator(loadingComposite, true);
            form.reflow(true);
            form.redraw();
          }
        });
    return true;
  }
  /**
   * Shows page contained in the given page record in this view. The page record must be one from
   * this pagebook view.
   *
   * <p>The <code>PageBookView</code> implementation of this method asks the pagebook control to
   * show the given page's control, and records that the given page is now current. Subclasses may
   * extend.
   *
   * @param pageRec the page record containing the page to show
   */
  protected void showPageRec(PageRec pageRec) {
    // If already showing do nothing
    if (activeRec == pageRec) {
      return;
    }
    // If the page is the same, just set activeRec to pageRec
    if (activeRec != null && pageRec != null && activeRec.page == pageRec.page) {
      activeRec = pageRec;
      return;
    }

    // Show new page.
    activeRec = pageRec;
    Control pageControl = activeRec.page.getControl();
    if (pageControl != null && !pageControl.isDisposed()) {
      // Verify that the page control is not disposed
      // If we are closing, it may have already been disposed
      pageBook.showPage(pageControl);
    }
  }
  public boolean refresh() {
    if (pageBook == null
        || pageBook.isDisposed()
        || discoveryViewer == null
        || discoveryViewer.getControl() == null) {
      return false;
    }
    Display display = getDisplay();
    display.syncExec(
        new Runnable() {

          @Override
          public void run() {
            pageBook.showPage(discoveryViewer.getControl());
            form.reflow(true);
            form.redraw();
          }
        });

    return true;
  }
  public void testMessage() {
    String string = "Test Message"; // $NON-NLS-1$
    table.message(string);
    while (Display.getCurrent().readAndDispatch()) ;

    PageBook book = (PageBook) table.getControl();
    assertTrue(book.getChildren()[0] instanceof Text);
    assertTrue(book.getChildren()[0].isVisible());
    assertTrue(book.getChildren()[1] instanceof Table);
    assertFalse(book.getChildren()[1].isVisible());

    Text text = (Text) book.getChildren()[0];
    assertEquals(string, text.getText());

    table.message(null);
    while (Display.getCurrent().readAndDispatch()) ;
    assertFalse(book.getChildren()[0].isVisible());
    assertTrue(book.getChildren()[1].isVisible());
  }
  protected void createFeaturesSection(FormToolkit toolkit, Composite parent) {
    final Section features =
        toolkit.createSection(
            parent,
            ExpandableComposite.TITLE_BAR
                | ExpandableComposite.TWISTIE
                | ExpandableComposite.EXPANDED);
    features.setText("Features Available");
    features.setLayout(new GridLayout());
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.widthHint = 350;
    // gd.heightHint = 100;
    features.setLayoutData(gd);

    createFeaturesToolbar(toolkit, features);

    featureComposite = toolkit.createComposite(features);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    featureComposite.setLayoutData(gd);
    featureComposite.setLayout(new GridLayout());

    pageBook = new PageBook(featureComposite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    pageBook.setLayoutData(gd);

    discoveryViewer = new DiscoveryViewer(getSite(), this);
    discoveryViewer.setShowConnectorDescriptorKindFilter(false);
    discoveryViewer.setShowInstalledFilterEnabled(true);
    discoveryViewer.setDirectoryUrl(
        ProjectExamplesActivator.getDefault().getConfigurator().getJBossDiscoveryDirectory());
    discoveryViewer.createControl(pageBook);
    discoveryViewer.setEnvironment(getEnvironment());
    discoveryViewer.addFilter(
        new ViewerFilter() {

          @Override
          public boolean select(Viewer viewer, Object parentElement, Object element) {
            DiscoveryConnector connector = (DiscoveryConnector) element;
            // System.out.println(connector.getId());
            if (connector.getId().equals("org.eclipse.mylyn.discovery.tests.connectorDescriptor1")
                || connector.getId().equals("org.eclipse.mylyn.discovery.test1")
                || connector.getId().equals("org.eclipse.mylyn.discovery.2tests")
                || connector.getId().equals("org.eclipse.mylyn.trac")) {
              // System.out.println("filtered " + connector.getId());
              return false;
            }
            return true;
          }
        });

    Control discoveryControl = discoveryViewer.getControl();
    adapt(toolkit, discoveryControl);
    if (discoveryControl instanceof Composite) {
      ((Composite) discoveryControl).setLayout(new GridLayout());
    }
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    discoveryControl.setLayoutData(gd);

    loadingComposite = createLoadingComposite(toolkit, pageBook);

    form.addControlListener(
        new ControlAdapter() {

          @Override
          public void controlResized(ControlEvent e) {
            GridData gridData = (GridData) featureComposite.getLayoutData();
            Point size = form.getSize();
            gridData.heightHint = size.y - 25;
            gridData.widthHint = size.x - 25;
            gridData.grabExcessVerticalSpace = true;

            gridData = (GridData) features.getLayoutData();
            gridData.heightHint = size.y - 20;
            gridData.widthHint = size.x - 20;
            gridData.grabExcessVerticalSpace = false;
            form.reflow(true);
            form.redraw();
          }
        });

    installButton = toolkit.createButton(featureComposite, "Install", SWT.PUSH);
    installButton.setEnabled(false);
    installButton.setImage(JBossCentralActivator.getDefault().getImage(ICON_INSTALL));
    installButton.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            installAction.run();
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {}
        });
    discoveryViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            installAction.setEnabled(discoveryViewer.getInstallableConnectors().size() > 0);
            installButton.setEnabled(discoveryViewer.getInstallableConnectors().size() > 0);
          }
        });
    features.setClient(featureComposite);
    showLoading();
    pageBook.pack(true);

    RefreshDiscoveryJob refreshDiscoveryJob = RefreshDiscoveryJob.INSTANCE;
    refreshJobChangeListener = new RefreshJobChangeListener();
    refreshDiscoveryJob.addJobChangeListener(refreshJobChangeListener);
    refreshDiscoveryJob.schedule();
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.gef.ui.parts.ContentOutlinePage#createControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createControl(Composite parent) {
    pageBook = new PageBook(parent, SWT.NONE);

    outline = getViewer().createControl(pageBook);

    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(outline, "com.jaspersoft.studio.doc.view_outline");

    overview = new Canvas(pageBook, SWT.NONE);
    pageBook.showPage(outline);
    configureOutlineViewer();
    hookOutlineViewer();
    setContents(editor.getModel());
    if (outline instanceof Tree) {
      final Tree tree = (Tree) outline;

      tree.addFocusListener(
          new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {
              mousePosition.setLocation(-1, -1);
            }

            @Override
            public void focusGained(FocusEvent e) {
              if (enableFocusFix && mousePosition.x != -1) {
                EditPart part = getViewer().findObjectAt(mousePosition);
                if (part != null && part.getModel() instanceof MRoot) {
                  EditPart translatedPart =
                      getViewer().findObjectAt(new Point(mousePosition.x + 10, mousePosition.y));
                  if (translatedPart != null && translatedPart.getModel() != part.getModel()) {
                    TreeItem item = (TreeItem) ((TreeEditPart) translatedPart).getWidget();
                    item.setExpanded(!item.getExpanded());
                    tree.deselectAll();
                    tree.select(item);
                    tree.layout(true);
                  }
                }
              }
            }
          });

      tree.addMouseListener(
          new MouseListener() {

            public void mouseUp(MouseEvent e) {}

            public void mouseDown(MouseEvent e) {}

            public void mouseDoubleClick(MouseEvent e) {
              if (e.getSource() instanceof Tree) {
                Tree t = (Tree) e.getSource();
                TreeItem[] ti = t.getSelection();
                if (ti != null && ti.length > 0) {
                  Object obj = ti[0].getData();
                  if (obj instanceof TreeEditPart && editor instanceof AbstractVisualEditor) {

                    EditPart part =
                        (EditPart)
                            ((AbstractVisualEditor) editor)
                                .getGraphicalViewer()
                                .getEditPartRegistry()
                                .get(((TreeEditPart) obj).getModel());
                    if (part != null) {
                      SelectionRequest request = new SelectionRequest();
                      request.setType(RequestConstants.REQ_OPEN);
                      part.performRequest(request);
                    } else {
                      TreeEditPart atep = (TreeEditPart) obj;
                      if (atep.getModel() instanceof ANode) {
                        EditableFigureEditPart.openEditor(
                            ((ANode) atep.getModel()).getValue(),
                            (IEditorPart) editor,
                            (ANode) atep.getModel());
                      }
                    }
                  }
                }
              }
            }
          });

      // This listener display the tooltip text for the abbreviated nodes names
      tree.addMouseMoveListener(
          new MouseMoveListener() {

            public void mouseMove(MouseEvent e) {
              mousePosition.setLocation(e.x, e.y);
              EditPart part = getViewer().findObjectAt(new Point(e.x, e.y));
              Tree t = (Tree) e.getSource();
              if (part != null && part.getModel() != null && !(part.getModel() instanceof MRoot)) {
                Object model = part.getModel();
                String toolTipText = Misc.nvl(((ANode) model).getToolTip());
                String displayText = Misc.nvl(((ANode) model).getDisplayText());
                String text = "";
                if (!toolTipText.isEmpty() && !toolTipText.equals(displayText))
                  text = toolTipText + "\n";
                text += displayText;
                t.setToolTipText(text);
                return;
              }
              t.setToolTipText(null);
            }
          });
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.part.IPage#dispose()
  */
 public void dispose() {
   if (fPageBook != null && !fPageBook.isDisposed()) fPageBook.dispose();
   fPageBook = null;
   fDisposed = true;
 }