private void createFeaturesToolbar(FormToolkit toolkit, Section section) { Composite headerComposite = toolkit.createComposite(section, SWT.NONE); RowLayout rowLayout = new RowLayout(); rowLayout.marginTop = 0; rowLayout.marginBottom = 0; headerComposite.setLayout(rowLayout); headerComposite.setBackground(null); toolBarManager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); toolBarManager.createControl(headerComposite); installAction = new InstallAction(); installAction.setEnabled(false); toolBarManager.add(installAction); toolBarManager.add(new CheckForUpdatesAction()); CommandContributionItem item = JBossCentralActivator.createContributionItem( getSite(), "org.jboss.tools.central.refreshDiscovery"); toolBarManager.add(item); toolBarManager.update(true); section.setTextClient(headerComposite); }
@Override public void run() { IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class); try { setEnabled(false); handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.update", new Event()); } catch (Exception e) { JBossCentralActivator.log(e); } finally { setEnabled(true); } }
public CheckForUpdatesAction() { super( "Check for Updates", JBossCentralActivator.imageDescriptorFromPlugin( JBossCentralActivator.PLUGIN_ID, "/icons/update.gif")); }
public InstallAction() { super( "Install", JBossCentralActivator.imageDescriptorFromPlugin( JBossCentralActivator.PLUGIN_ID, ICON_INSTALL)); }
private Dictionary<Object, Object> getEnvironment() { if (environment == null) { environment = JBossCentralActivator.getEnvironment(); } return environment; }
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 getLocation() { return JBossCentralActivator.getDefault().getConfigurator().getTwitterLink(); }
@Override public String getUrlString() { return JBossCentralActivator.getDefault().getConfigurator().getBuzzUrl(); }
protected File getFile(String name) { IPath location = JBossCentralActivator.getDefault().getStateLocation(); File file = new File(location.toFile(), name); return file; }