protected void createSection(Section section, FormToolkit toolkit) { setTitle("Tools"); Composite body = createTableWrapBody(1, toolkit); toolkit.createLabel(body, "Tools to help manage this project:"); Hyperlink launch = toolkit.createHyperlink(body, "Resolve missing dependencies", SWT.NULL); launch.setHref("resolve"); launch.addHyperlinkListener(this); Hyperlink debug = toolkit.createHyperlink(body, "Prune unused dependencies", SWT.NULL); debug.setHref("prune"); debug.addHyperlinkListener(this); }
public Composite createControl(final Composite parent) { // Form form=tk.createForm(parent); // form.setLayoutData(SWTHelper.getFillGridData(1,true,1,false)); // Composite ret=form.getBody(); Composite ret = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; ret.setLayout(layout); ret.setBackground(parent.getBackground()); ImageHyperlink hClr = tk.createImageHyperlink(ret, SWT.NONE); // $NON-NLS-1$ hClr.setImage(Images.IMG_CLEAR.getImage()); hClr.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(final HyperlinkEvent e) { clearValues(); } }); hClr.setBackground(parent.getBackground()); Composite inner = new Composite(ret, SWT.NONE); GridLayout lRet = new GridLayout(fields.length, true); inner.setLayout(lRet); inner.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); for (String l : fields) { Hyperlink hl = tk.createHyperlink(inner, l, SWT.NONE); hl.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(final HyperlinkEvent e) { Hyperlink h = (Hyperlink) e.getSource(); fireSortEvent(h.getText()); } }); hl.setBackground(parent.getBackground()); } createSelectors(fields.length); for (int i = 0; i < selectors.length; i++) { selectors[i] = new ElexisText(tk.createText(inner, "", SWT.BORDER)); // $NON-NLS-1$ selectors[i].addModifyListener(ml); selectors[i].addSelectionListener(sl); selectors[i].setToolTipText( Messages.getString("DefaultControlFieldProvider.enterFilter")); // $NON-NLS-1$ selectors[i].setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); SWTHelper.setSelectOnFocus((Text) selectors[i].getWidget()); } return ret; }
private void createHeaderArea(Composite parent, FormToolkit toolkit, int span) { RevCommit commit = getCommit().getRevCommit(); Composite top = toolkit.createComposite(parent); GridDataFactory.fillDefaults().grab(true, false).span(span, 1).applyTo(top); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(top); Composite userArea = toolkit.createComposite(top); GridLayoutFactory.fillDefaults().spacing(2, 2).numColumns(1).applyTo(userArea); GridDataFactory.fillDefaults().grab(true, false).applyTo(userArea); PersonIdent author = commit.getAuthorIdent(); if (author != null) createUserArea(userArea, toolkit, author, true); PersonIdent committer = commit.getCommitterIdent(); if (committer != null && !committer.equals(author)) createUserArea(userArea, toolkit, committer, false); int count = commit.getParentCount(); if (count > 0) { Composite parents = toolkit.createComposite(top); GridLayoutFactory.fillDefaults().spacing(2, 2).numColumns(2).applyTo(parents); GridDataFactory.fillDefaults().grab(false, false).applyTo(parents); for (int i = 0; i < count; i++) { final RevCommit parentCommit = commit.getParent(i); toolkit .createLabel(parents, UIText.CommitEditorPage_LabelParent) .setForeground(toolkit.getColors().getColor(IFormColors.TB_TOGGLE)); final Hyperlink link = toolkit.createHyperlink( parents, parentCommit.abbreviate(PARENT_LENGTH).name(), SWT.NONE); link.addHyperlinkListener( new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { try { CommitEditor.open( new RepositoryCommit(getCommit().getRepository(), parentCommit)); if ((e.getStateMask() & SWT.MOD1) != 0) getEditor().close(false); } catch (PartInitException e1) { Activator.logError("Error opening commit editor", e1); // $NON-NLS-1$ } } }); } } createTagsArea(userArea, toolkit, 2); }
/** * Creates {@link Hyperlink} that when clicked sets the last specified time to the timeframe * control. * * @param parent Parent composite. * @param toolkit {@link FormToolkit} * @param text Text on the {@link Hyperlink}. * @param time Wanted time frame to set on click. * @return Created {@link Hyperlink}. */ private Hyperlink createTimeHyperlink( Composite parent, FormToolkit toolkit, String text, final long time) { Hyperlink hyperlink = toolkit.createHyperlink(parent, text, SWT.NONE); hyperlink.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { Date toDate = new Date(); Date fromDate = new Date(toDate.getTime() - time); toDateTime.setSelection(toDate); fromDateTime.setSelection(fromDate); getPreferencePanel().update(); } }); return hyperlink; }
/* * (non-Javadoc) * * @see org.eclipse.pde.internal.ui.neweditor.plugin.ExtensionElementEditor#createContents(org.eclipse.swt.widgets.Composite, * org.eclipse.ui.forms.widgets.FormToolkit, int) */ protected void createLabel(Composite parent, FormToolkit toolkit) { if (!part.isEditable()) { super.createLabel(parent, toolkit); return; } Hyperlink link = toolkit.createHyperlink(parent, getPropertyLabel(), SWT.NULL); link.addHyperlinkListener( new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { if (!isReferenceModel()) { openReference(); } else { Display.getCurrent().beep(); } } }); PDETextHover.addHoverListenerToControl(fIC, link, this); }
/** * Create the link to the element * * @see * org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) * @param parent the parent composite * @return the hyperlink control */ @Override protected Control createCustomArea(Composite parent) { FormToolkit toolkit = new FormToolkit(parent.getDisplay()); Hyperlink hyperLink = toolkit.createHyperlink(parent, label, SWT.UNDERLINE_LINK); hyperLink.setBackground(parent.getBackground()); hyperLink.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false)); if (allowNavigation) { hyperLink.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { navigateToElement(); okPressed(); } }); } return hyperLink; }
/** This is a callback that will allow us to create the viewer and initialize it. */ @Override public void createPartControl(Composite parent) { FormToolkit toolkit = new FormToolkit(parent.getDisplay()); Composite frame = toolkit.createComposite(parent, SWT.BORDER); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(frame); Composite comboDescFrame = toolkit.createComposite(frame, SWT.NONE); GridDataFactory.fillDefaults().applyTo(comboDescFrame); GridLayoutFactory.fillDefaults() .margins(5, 20) .spacing(SWT.DEFAULT, 25) .applyTo(comboDescFrame); Composite comboFrame = toolkit.createComposite(comboDescFrame, SWT.NONE); GridDataFactory.fillDefaults().applyTo(comboFrame); GridLayoutFactory.fillDefaults().applyTo(comboFrame); Composite labelFrame = toolkit.createComposite(comboFrame, SWT.NONE); GridDataFactory.fillDefaults().applyTo(labelFrame); GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(false).applyTo(labelFrame); Label jbLabel = WidgetFactory.createLabel( labelFrame, UTIL.getString("TeiidServerOverviewSection.jbLabel")); // $NON-NLS-1$ jbLabel.setForeground(labelFrame.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE)); GridDataFactory.swtDefaults().grab(false, false).applyTo(jbLabel); newServerOrOpenServerViewHyperlink = toolkit.createHyperlink(labelFrame, EDIT_SERVER_LABEL, SWT.NONE); GridDataFactory.swtDefaults().applyTo(newServerOrOpenServerViewHyperlink); newServerOrOpenServerViewHyperlink.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { if (serverMap.isEmpty()) { // There are no servers so open the server wizard NewServerAction action = new NewServerAction(getViewSite().getShell(), getServerManager()); action.run(); } else { // open the servers view IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); try { window .getActivePage() .showView("org.eclipse.wst.server.ui.ServersView"); // $NON-NLS-1$ } catch (PartInitException ex) { UTIL.log(ex); } } } }); jbossServerCombo = new Combo(comboFrame, SWT.READ_ONLY | SWT.DROP_DOWN); toolkit.adapt(jbossServerCombo); GridDataFactory.swtDefaults().minSize(250, 30).grab(true, false).applyTo(jbossServerCombo); jbossServerCombo.addSelectionListener( new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { handleServerComboSelection(); } @Override public void widgetDefaultSelected(SelectionEvent e) { handleServerComboSelection(); } }); Text descriptionText = toolkit.createText( comboDescFrame, UTIL.getString("TeiidServerOverviewSection.description"), // $NON-NLS-1$ SWT.MULTI | SWT.WRAP); descriptionText.setForeground(comboDescFrame.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE)); GridDataFactory.fillDefaults() .grab(false, true) .hint(100, SWT.DEFAULT) .applyTo(descriptionText); super.createPartControl(frame); viewer = getCommonViewer(); GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl()); viewer.setSorter(new NameSorter()); DqpPlugin.getInstance().getServersProvider().addServerLifecycleListener(serversListener); // Populate the jboss server combo box which // should also populate the viewer as well populateJBossServerCombo(); viewer.expandToLevel(3); }
@Override public void createPartControl(Composite parent) { parent.setLayout(new FillLayout()); Composite main = new Composite(parent, SWT.NONE); main.setLayout(new FillLayout()); tk = UiDesk.getToolkit(); form = tk.createScrolledForm(main); form.getBody().setLayout(new GridLayout(1, true)); SashForm mainSash = new SashForm(form.getBody(), SWT.VERTICAL); mainSash.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); dauermedikationSection = tk.createExpandableComposite( mainSash, ExpandableComposite.EXPANDED | ExpandableComposite.TWISTIE); dauermedikationSection.setText("Fixmedikation"); Composite dauermedikationComposite = tk.createComposite(dauermedikationSection); dauermedikationSection.setClient(dauermedikationComposite); Composite bottomComposite = tk.createComposite(mainSash); mainSash.setWeights(new int[] {25, 75}); // Dauermedikation dauermedikationComposite.setLayout(new GridLayout()); // Label lDauermedikation = tk.createLabel(dauermedikationComposite, "Fixmedikation"); // lDauermedikation.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); dlDauerMedi = new ProblemFixMediDisplay(dauermedikationComposite, getViewSite()); bottomComposite.setLayout(new GridLayout()); SashForm bottomSash = new SashForm(bottomComposite, SWT.HORIZONTAL); bottomSash.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); diagnosenComposite = tk.createComposite(bottomSash); Composite konsultationenComposite = tk.createComposite(bottomSash); bottomSash.setWeights(new int[] {25, 75}); diagnosenComposite.setLayout(new GridLayout(1, true)); Hyperlink hDiagnosen = tk.createHyperlink(diagnosenComposite, "Diagnosen", SWT.NONE); hDiagnosen.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); hDiagnosen.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { try { getViewSite().getPage().showView(DiagnosenView.ID); } catch (Exception ex) { ExHandler.handle(ex); log.error("Fehler beim Starten des Diagnosencodes " + ex.getMessage()); } } }); Table diagnosenTable = tk.createTable(diagnosenComposite, SWT.SINGLE); diagnosenTable.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); diagnosenViewer = new TableViewer(diagnosenTable); diagnosenViewer.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); diagnosenViewer.setContentProvider( new IStructuredContentProvider() { @Override public Object[] getElements(Object inputElement) { if (actProblem != null) { List<IDiagnose> diagnosen = actProblem.getDiagnosen(); return diagnosen.toArray(); } return new Object[0]; } @Override public void dispose() { // nothing to do } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // nothing to do } }); diagnosenViewer.setLabelProvider( new LabelProvider() { @Override public String getText(Object element) { if (!(element instanceof IDiagnose)) { return ""; } IDiagnose diagnose = (IDiagnose) element; return diagnose.getLabel(); } }); diagnosenViewer.setInput(this); konsultationenComposite.setLayout(new GridLayout(1, true)); Label lKonsultationen = tk.createLabel(konsultationenComposite, "Konsultationen", SWT.LEFT); lKonsultationen.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false)); Table konsultationenTable = tk.createTable(konsultationenComposite, SWT.SINGLE); konsultationenTable.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); konsultationenViewer = new TableViewer(konsultationenTable); konsultationenViewer.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true)); konsultationenViewer.setContentProvider( new IStructuredContentProvider() { @Override public Object[] getElements(Object inputElement) { if (actProblem != null) { List<Konsultation> konsultationen = actProblem.getKonsultationen(); return konsultationen.toArray(); } return new Object[0]; } @Override public void dispose() { // nothing to do } @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // nothing to do } }); konsultationenViewer.setLabelProvider( new LabelProvider() { @Override public String getText(Object element) { if (!(element instanceof Konsultation)) { return ""; } Konsultation konsultation = (Konsultation) element; return konsultation.getLabel(); } }); konsultationenViewer.setInput(this); /* Implementation Drag&Drop */ final TextTransfer textTransfer = TextTransfer.getInstance(); Transfer[] types = new Transfer[] {textTransfer}; // diagnosenComposite DropTarget dtarget = new DropTarget(diagnosenComposite, DND.DROP_COPY); dtarget.setTransfer(types); dtarget.addDropListener( new DropTargetListener() { @Override public void dragEnter(DropTargetEvent event) { /* Wir machen nur Copy-Operationen */ event.detail = DND.DROP_COPY; } /* Mausbewegungen mit gedrückter Taste sind uns egal */ @Override public void dragLeave(DropTargetEvent event) { /* leer */ } @Override public void dragOperationChanged(DropTargetEvent event) { /* leer */ } @Override public void dragOver(DropTargetEvent event) { /* leer */ } /* Erst das Loslassen interessiert uns wieder */ @Override public void drop(DropTargetEvent event) { String drp = (String) event.data; String[] dl = drp.split(","); for (String obj : dl) { PersistentObject dropped = CoreHub.poFactory.createFromString(obj); if (dropped instanceof IDiagnose) { IDiagnose diagnose = (IDiagnose) dropped; actProblem.addDiagnose(diagnose); // tell other viewers that something has changed IatrixEventHelper.updateProblem(actProblem); // update ourselves // TODO: implement ObjectListener diagnosenViewer.refresh(); } } } @Override public void dropAccept(DropTargetEvent event) { /* leer */ } }); makeListeners(); makeActions(); menus = new ViewMenus(getViewSite()); menus.createViewerContextMenu(diagnosenViewer, delDiagnoseAction); menus.createViewerContextMenu(konsultationenViewer, unassignProblemAction); GlobalEventDispatcher.addActivationListener(this, this); }