private void createControl(final Composite parent) { Composite comp = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.BEGINNING).applyTo(comp); GridLayoutFactory.fillDefaults() .numColumns(isCentered ? 1 : 2) .margins(margin.x, margin.y) .applyTo(comp); updateStatusLabel = new Link(comp, SWT.NO_FOCUS); if (backgroundColor != null) { comp.setBackground(backgroundColor); updateStatusLabel.setBackground(backgroundColor); } updateStatusLabel.addSelectionListener( new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } @Override public void widgetSelected(SelectionEvent e) { ExternalBrowserUtil.openInExternalBrowser(UpdateCore.getChangeLogUrl()); } }); GridDataFactory.fillDefaults() .align(isCentered ? SWT.CENTER : SWT.FILL, SWT.CENTER) .grab(true, false) .applyTo(updateStatusLabel); updateStatusButton = new Button(comp, SWT.PUSH); updateStatusButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); GridDataFactory.fillDefaults() .align(SWT.CENTER, SWT.CENTER) .indent(0, 3) .applyTo(updateStatusButton); updateStatusButton.addSelectionListener( new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { performAction(e); } @Override public void widgetSelected(SelectionEvent e) { performAction(e); } }); }
@Override public void createControl(Composite parent) { Color background = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); composite.setBackground(background); Link link = new Link(composite, SWT.NONE); link.setText(SearchMessages.SearchView_empty_search_label); link.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false)); link.setBackground(background); fControl = composite; }
/** * Creates a link. * * @param parent * @param text * @param tooltip * @param url */ private void createLink(Composite parent, String text, String tooltip, final String url) { Link link = new Link(parent, SWT.NONE); link.setLayoutData(SWTUtil.createFillHorizontallyGridData()); link.setText(text); link.setToolTipText(tooltip); link.setBackground(parent.getBackground()); link.addListener( SWT.Selection, new Listener() { public void handleEvent(Event event) { try { Program.launch(url); } catch (Exception e) { /* Ignore*/ } } }); }
@Override protected Control createDialogArea(Composite parent) { Color background = JFaceColors.getBannerBackground(parent.getDisplay()); // Color foreground = JFaceColors.getBannerForeground(parent.getDisplay()); parent.setBackground(background); Composite group = new Composite(parent, SWT.NONE); group.setBackground(background); GridLayout layout = new GridLayout(1, false); layout.marginHeight = 20; layout.marginWidth = 20; group.setLayout(layout); GridData gd; IProduct product = Platform.getProduct(); String productVersion = DBeaverCore.getVersion().toString(); Label titleLabel = new Label(group, SWT.NONE); titleLabel.setBackground(background); titleLabel.setFont(TITLE_FONT); titleLabel.setText(product.getProperty(PRODUCT_PROP_SUB_TITLE)); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment = GridData.CENTER; titleLabel.setLayoutData(gd); titleLabel.addMouseListener( new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { BusyIndicator.showWhile( getShell().getDisplay(), new Runnable() { @Override public void run() { // Do not create InstallationDialog directly // but execute "org.eclipse.ui.help.installationDialog" command IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IHandlerService service = workbenchWindow.getService(IHandlerService.class); if (service != null) { try { service.executeCommand( "org.eclipse.ui.help.installationDialog", null); // $NON-NLS-1$ } catch (Exception e1) { // just ignore error } } } }); } }); Label imageLabel = new Label(group, SWT.NONE); imageLabel.setBackground(background); gd = new GridData(); gd.verticalAlignment = GridData.BEGINNING; gd.horizontalAlignment = GridData.CENTER; gd.grabExcessHorizontalSpace = true; imageLabel.setLayoutData(gd); imageLabel.setImage(ABOUT_IMAGE); Label versionLabel = new Label(group, SWT.NONE); versionLabel.setBackground(background); versionLabel.setText(CoreMessages.dialog_about_label_version + productVersion); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment = GridData.CENTER; versionLabel.setLayoutData(gd); Label authorLabel = new Label(group, SWT.NONE); authorLabel.setBackground(background); authorLabel.setText(product.getProperty(PRODUCT_PROP_COPYRIGHT)); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment = GridData.CENTER; authorLabel.setLayoutData(gd); Link siteLink = UIUtils.createLink( group, UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)), new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { UIUtils.launchProgram(e.text); } }); siteLink.setBackground(background); gd = new GridData(); gd.horizontalAlignment = GridData.CENTER; siteLink.setLayoutData(gd); Link emailLink = UIUtils.createLink( group, UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_EMAIL)), new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { UIUtils.launchProgram("mailto:" + e.text); // $NON-NLS-1$ } }); emailLink.setBackground(background); gd = new GridData(); gd.horizontalAlignment = GridData.CENTER; emailLink.setLayoutData(gd); return parent; }
// TODO the implementation of this method is horrible and creating too many widgets // table/column renderer/editor should be used instead should be used instead protected void addInstallButtons() { final AtomicInteger enabledButtonCount = new AtomicInteger(0); tableViewerCreator.getTableViewer().getControl().setRedraw(false); final Table table = tableViewerCreator.getTable(); manualInstallButtonMap = new HashMap<ModuleToInstall, Button>(); ILibrariesService librariesService = LibManagerUiPlugin.getDefault().getLibrariesService(); disposePreviousEditors(); for (final TableItem item : table.getItems()) { TableEditor editor = new TableEditor(table); installButtonsEditors.add(editor); Control control = null; Object obj = item.getData(); if (obj instanceof ModuleToInstall) { final ModuleToInstall data = (ModuleToInstall) obj; boolean isInstalled = false; try { isInstalled = librariesService.getLibraryStatus(data.getName()) == ELibraryInstallStatus.INSTALLED; } catch (BusinessException e1) { // log the error and consider as unsinstalled log.error(e1); } boolean hasDownloadUrl = data.getUrl_description() != null; if (!MavenConstants.DOWNLOAD_MANUAL.equals( data.getDistribution())) { // add the button to download final Button button = new Button(table, SWT.FLAT); control = button; enabledButtonCount.incrementAndGet(); button.setText( Messages.getString("ExternalModulesInstallDialog_Download")); // $NON-NLS-1$ button.setData(item); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { table.select(table.indexOf(item)); launchIndividualDownload(enabledButtonCount, data, button); } }); button.setEnabled(!isInstalled); button.setToolTipText(data.toString()); } else { // add the link for manual download Composite composite = new Composite(table, SWT.NONE); composite.setBackground(color); control = composite; GridLayout layout = new GridLayout(hasDownloadUrl ? 2 : 1, false); layout.marginHeight = 0; layout.verticalSpacing = 1; composite.setLayout(layout); if (hasDownloadUrl) { Link openLink = new Link(composite, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(openLink); openLink.setBackground(color); // openLink.setLayoutData(gData); openLink.setText( "<a href=\"\">" + Messages.getString("ExternalModulesInstallDialog.openInBrowser") + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ openLink.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { // Program.launch(data.getUrl_description()); openURL(data.getUrl_description()); } }); } // else no download URL so just add the install buttonb enabledButtonCount.incrementAndGet(); Button importButton = new Button(composite, SWT.FLAT); importButton.setImage(ImageProvider.getImage(ECoreImage.IMPORT_JAR)); importButton.setToolTipText( Messages.getString("ImportExternalJarAction.title")); // $NON-NLS-1$ importButton.addSelectionListener( new ImportButtonSelectionListener(enabledButtonCount, item)); manualInstallButtonMap.put(data, importButton); GridDataFactory.fillDefaults() .align(SWT.RIGHT, SWT.CENTER) .grab(true, false) .applyTo(importButton); importButton.setEnabled(!isInstalled); importButton.setToolTipText(data.toString()); } editor.grabHorizontal = true; editor.setEditor(control, item, tableViewerCreator.getColumns().indexOf(installcolumn)); editor.layout(); // url editor = new TableEditor(table); installButtonsEditors.add(editor); Composite composite = new Composite(table, SWT.NONE); composite.setBackground(color); // GridLayout layout = new GridLayout(); FormLayout layout = new FormLayout(); layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); FormData gData = new FormData(); gData.left = new FormAttachment(0); gData.right = new FormAttachment(100); gData.top = new FormAttachment(composite, 0, SWT.CENTER); final Link openLink = new Link(composite, SWT.NONE); openLink.setLayoutData(gData); openLink.setBackground(color); gData.height = new GC(composite).stringExtent(" ").y; // $NON-NLS-1$ openLink.setText( "<a href=\"\">" + (hasDownloadUrl ? data.getUrl_description() : "") + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ openLink.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { // Program.launch(data.getUrl_description()); openURL(data.getUrl_description()); } }); editor.grabHorizontal = true; // editor.minimumHeight = 20; editor.setEditor(composite, item, tableViewerCreator.getColumns().indexOf(urlcolumn)); editor.layout(); } } tableViewerCreator.getTableViewer().getTable().layout(); tableViewerCreator.getTableViewer().refresh(true); tableViewerCreator.getTableViewer().getControl().setRedraw(true); }
@Override public void registeredWith(iVisualElement root) { super.registeredWith(root); this.root = root; this.container = new Composite(ToolBarFolder.currentFolder.getContainer(), SWT.NO_BACKGROUND); ToolBarFolder.currentFolder.add("icons/reload.png", container); toolbar = new Composite(container, SWT.BACKGROUND); Color backgroundColor = ToolBarFolder.currentFolder.firstLineBackground; toolbar.setBackground(backgroundColor); tree = new Tree(container, 0); tree.setBackground(ToolBarFolder.firstLineBackground); new GraphNodeToTreeFancy.Pretty(tree, 200); GridLayout gl = new GridLayout(1, false); gl.marginHeight = 0; gl.marginWidth = 0; if (Platform.isLinux()) { gl.marginLeft = 0; gl.marginRight = 0; gl.marginTop = 0; gl.marginBottom = 0; gl.verticalSpacing = 0; } container.setLayout(gl); { GridData data = new GridData(); data.heightHint = 28; if (Platform.getOS() == OS.linux) { data.heightHint = 38; } data.widthHint = 1000; data.horizontalAlignment = SWT.FILL; data.grabExcessHorizontalSpace = true; toolbar.setLayoutData(data); } { GridData data = new GridData(); data.grabExcessVerticalSpace = true; data.grabExcessHorizontalSpace = true; data.verticalAlignment = SWT.FILL; data.horizontalAlignment = SWT.FILL; data.verticalIndent = 0; data.horizontalIndent = 0; tree.setLayoutData(data); } Link label = new Link(toolbar, SWT.MULTI | SWT.NO_BACKGROUND | SWT.CENTER); label.setText("Java class reloading"); label.setFont( new Font( Launcher.display, label.getFont().getFontData()[0].getName(), label.getFont().getFontData()[0].getHeight() + 2, SWT.NORMAL)); label.setBackground(ToolBarFolder.firstLineBackground); toolbar.setLayout(new GridLayout(1, true)); GridData gd = new GridData(SWT.CENTER, SWT.CENTER, true, true); // gd.verticalIndent = 1; label.setLayoutData(gd); tree.setBackground(ToolBarFolder.background); tree.addListener( SWT.MouseDown, new Listener() { @Override public void handleEvent(Event arg0) { if (Platform.isPopupTrigger(arg0)) { TreeItem[] s = tree.getSelection(); if (s.length == 1) popupFor(s[0], arg0); } } }); tree.addListener( SWT.MouseDoubleClick, new Listener() { @Override public void handleEvent(Event arg0) { if (Platform.isPopupTrigger(arg0)) return; TreeItem[] s = tree.getSelection(); if (s.length == 1) doubleClickFor(s[0], arg0); } }); for (String s : reloadDomains) { Trampoline2.trampoline.reloadingSupport.addDomain(s); } }