Пример #1
0
  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();
  }
 @Override
 public String getUrlString() {
   return JBossCentralActivator.getDefault().getConfigurator().getBuzzUrl();
 }
 @Override
 public String getLocation() {
   return JBossCentralActivator.getDefault().getConfigurator().getTwitterLink();
 }
 protected File getFile(String name) {
   IPath location = JBossCentralActivator.getDefault().getStateLocation();
   File file = new File(location.toFile(), name);
   return file;
 }