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); }
protected void createRunnables(Composite compo) { if (!runnables.isEmpty()) { boolean first = true; for (final NotificationRunnable r : runnables) { if (!first) { toolkit.createLabel(compo, " "); } Hyperlink h = toolkit.createHyperlink(compo, r.getLabel() == null ? "run" : r.getLabel(), SWT.NONE); h.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { Display.getDefault() .asyncExec( new Runnable() { public void run() { PapyrusAsyncNotificationPopup.this.run(r); } }); } }); first = false; } } }
private void hook(Hyperlink link) { link.addListener(SWT.MouseDown, listener); link.addHyperlinkListener(listener); link.addListener(SWT.Dispose, listener); link.addListener(SWT.MouseEnter, listener); link.addListener(SWT.MouseExit, listener); links.add(link); }
private Composite getErrorComposite(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setBackground(getListBackgroundColor()); GridLayout layout = new GridLayout(); layout.numColumns = 2; composite.setLayout(layout); GridData data = new GridData(GridData.FILL_BOTH); data.grabExcessVerticalSpace = true; composite.setLayoutData(data); Hyperlink link = new Hyperlink(composite, SWT.WRAP); link.setText(TeamUIMessages.ChangesSection_8); link.addHyperlinkListener( new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { showErrors(); } }); link.setBackground(getListBackgroundColor()); link.setUnderlined(true); link = new Hyperlink(composite, SWT.WRAP); link.setText(TeamUIMessages.ChangesSection_9); link.addHyperlinkListener( new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { getPage().reset(); } }); link.setBackground(getListBackgroundColor()); link.setUnderlined(true); createDescriptionLabel( composite, NLS.bind( TeamUIMessages.ChangesSection_10, new String[] { Utils.shortenText( SynchronizeView.MAX_NAME_LENGTH, getConfiguration().getParticipant().getName()) })); return composite; }
public SMAEstimatedHoursHeader( Composite parent, int style, final AbstractWorkflowArtifact sma, final SMAEditor editor) { super(parent, style); this.awa = sma; setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); setLayout(ALayout.getZeroMarginLayout(2, false)); editor.getToolkit().adapt(this); try { if (!sma.isCancelled() && !sma.isCompleted()) { Hyperlink link = editor.getToolkit().createHyperlink(this, LABEL, SWT.NONE); link.addHyperlinkListener( new IHyperlinkListener() { @Override public void linkEntered(HyperlinkEvent e) { // do nothing } @Override public void linkExited(HyperlinkEvent e) { // do nothing } @Override public void linkActivated(HyperlinkEvent e) { try { if (editor.isDirty()) { editor.doSave(null); } PromptChangeUtil.promptChangeAttribute( sma, AtsAttributeTypes.EstimatedHours, true, false); } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } } }); } else { Label origLabel = editor.getToolkit().createLabel(this, LABEL); origLabel.setLayoutData(new GridData()); } valueLabel = editor.getToolkit().createLabel(this, "0.0"); valueLabel.setToolTipText(getToolTip()); valueLabel.setLayoutData(new GridData()); updateLabel(sma); } catch (OseeCoreException ex) { Label errorLabel = editor.getToolkit().createLabel(this, "Error: " + ex.getLocalizedMessage()); errorLabel.setForeground(Displays.getSystemColor(SWT.COLOR_RED)); OseeLog.log(Activator.class, Level.SEVERE, ex); } }
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 createLink(Object object) { Image image = labelProvider != null ? labelProvider.getImage(object) : null; Hyperlink hyperlink; if (image != null) { hyperlink = getManagedForm().getToolkit().createImageHyperlink(linkContainer, SWT.NULL); ((ImageHyperlink) hyperlink).setImage(image); } else hyperlink = getManagedForm().getToolkit().createHyperlink(linkContainer, null, SWT.NULL); update(hyperlink, object); hyperlink.setData(object); hyperlink.addHyperlinkListener(linkHandler); }
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; }
private void createImportSection(final Composite composite) { Hyperlink link = new Hyperlink(composite, SWT.None); link.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { ImportEnvironmentsWizard newWizard = new ImportEnvironmentsWizard(); WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), newWizard); dialog.open(); } }); link.setText("Import an existing environment into the Servers view"); link.setUnderlined(true); GridData layoutData = new GridData(); layoutData.horizontalSpan = 2; link.setLayoutData(layoutData); }
/* * (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); }
/* * (non-Javadoc) * @see org.eclipse.ice.viz.service.widgets.PlotComposite#createInfoContent(org.eclipse.swt.widgets.Composite, int) */ @Override protected Composite createInfoContent(Composite parent, int style) { // Get the info Composite and its child with the message label. final Composite infoComposite = super.createInfoContent(parent, style); final Composite msgComposite = (Composite) infoComposite.getChildren()[1]; // Get a Display and Shell used to create the hyperlink. final Display display = infoComposite.getDisplay(); final Shell shell = infoComposite.getShell(); // Set the text to display in the hyperlink. final String linkText = "Click here to update the connection " + "preferences."; // Create a link to the preference page. link = new Hyperlink(msgComposite, SWT.NONE); link.setText(linkText); link.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); link.setUnderlined(true); link.setForeground(display.getSystemColor(SWT.COLOR_LINK_FOREGROUND)); // Add the listener to redirect the user to the preferences. link.addHyperlinkListener( new IHyperlinkListener() { @Override public void linkActivated(HyperlinkEvent e) { // Open up the viz service connection preferences. PreferencesUtil.createPreferenceDialogOn( shell, getConnectionPreferencePageID(), null, null) .open(); } @Override public void linkEntered(HyperlinkEvent e) { // Nothing to do yet. } @Override public void linkExited(HyperlinkEvent e) { // Nothing to do yet. } }); return infoComposite; }
/** * 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; }
@Override public void createControl(Composite parent) { GridData gd; Composite composite = new Composite(parent, SWT.NULL); setControl(composite); composite.setLayout(new GridLayout(1, false)); new Label(composite, SWT.NONE).setText("Select Template:"); tree = new Tree(composite, SWT.BORDER | SWT.FULL_SELECTION); gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = 100; tree.setLayoutData(gd); viewer = new TreeViewer(tree); contentProvider = new RepoTemplateContentProvider(false); viewer.setContentProvider(contentProvider); viewer.setLabelProvider(new RepoTemplateLabelProvider(loadedImages)); viewer.addFilter(latestFilter); setTemplates(Collections.singletonList(emptyTemplate)); btnLatestOnly = new Button(composite, SWT.CHECK); btnLatestOnly.setText("Show latest versions only"); btnLatestOnly.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false)); btnLatestOnly.setSelection(true); new Label(composite, SWT.NONE).setText("Description:"); Composite cmpDescription = new Composite(composite, SWT.BORDER); cmpDescription.setBackground(tree.getBackground()); txtDescription = new ScrolledFormText(cmpDescription, SWT.V_SCROLL | SWT.H_SCROLL, false); FormText formText = new FormText(txtDescription, SWT.NO_FOCUS); txtDescription.setFormText(formText); txtDescription.setBackground(tree.getBackground()); formText.setBackground(tree.getBackground()); formText.setForeground(tree.getForeground()); formText.setFont("fixed", JFaceResources.getTextFont()); formText.setFont("italic", JFaceResources.getFontRegistry().getItalic("")); GridData gd_cmpDescription = new GridData(SWT.FILL, SWT.FILL, true, true); gd_cmpDescription.heightHint = 100; cmpDescription.setLayoutData(gd_cmpDescription); GridLayout layout_cmpDescription = new GridLayout(1, false); cmpDescription.setLayout(layout_cmpDescription); GridData gd_txtDescription = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_txtDescription.heightHint = 100; txtDescription.setLayoutData(gd_txtDescription); Hyperlink linkRetina = new Hyperlink(composite, SWT.NONE); linkRetina.setText("Why is this text blurred?"); linkRetina.setUnderlined(true); linkRetina.setForeground(JFaceColors.getHyperlinkText(getShell().getDisplay())); linkRetina.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false)); viewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement(); setTemplate(element instanceof Template ? (Template) element : null); getContainer().updateButtons(); } }); viewer.addOpenListener( new IOpenListener() { @Override public void open(OpenEvent event) { Object element = ((IStructuredSelection) viewer.getSelection()).getFirstElement(); setTemplate(element instanceof Template ? (Template) element : null); getContainer().updateButtons(); IWizardPage nextPage = getNextPage(); if (nextPage != null) getContainer().showPage(nextPage); } }); btnLatestOnly.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean latestOnly = btnLatestOnly.getSelection(); if (latestOnly) viewer.addFilter(latestFilter); else viewer.removeFilter(latestFilter); } }); linkRetina.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent ev) { try { IWorkbenchBrowserSupport browser = PlatformUI.getWorkbench().getBrowserSupport(); browser .getExternalBrowser() .openURL( new URL( "https://github.com/bndtools/bndtools/wiki/Blurry-Form-Text-on-High-Resolution-Displays")); } catch (Exception e) { log.log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Browser open error", e)); } } }); }
void createSubSectionContents( final ChangeDetail changeDetail, final PatchSetDetail patchSetDetail, PatchSetPublishDetail publishDetail, Section subSection) { Composite composite = toolkit.createComposite(subSection); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite); subSection.setClient(composite); Label authorLabel = new Label(composite, SWT.NONE); authorLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); authorLabel.setText("Author"); Text authorText = new Text(composite, SWT.READ_ONLY); authorText.setText(GerritUtil.getUserLabel(patchSetDetail.getInfo().getAuthor())); Label committerLabel = new Label(composite, SWT.NONE); committerLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); committerLabel.setText("Committer"); Text committerText = new Text(composite, SWT.READ_ONLY); committerText.setText(GerritUtil.getUserLabel(patchSetDetail.getInfo().getCommitter())); Label commitLabel = new Label(composite, SWT.NONE); commitLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); commitLabel.setText("Commit"); Hyperlink commitLink = new Hyperlink(composite, SWT.READ_ONLY); commitLink.setText(patchSetDetail.getPatchSet().getRevision().get()); commitLink.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent event) { GerritToGitMapping mapping = getRepository(changeDetail); if (mapping != null) { final FetchPatchSetJob job = new FetchPatchSetJob( "Opening Commit Viewer", mapping.getRepository(), mapping.getRemote(), patchSetDetail.getPatchSet()); job.schedule(); job.addJobChangeListener( new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { Display.getDefault() .asyncExec( new Runnable() { @Override public void run() { CommitEditor.openQuiet(job.getCommit()); } }); } }); } } }); Label refLabel = new Label(composite, SWT.NONE); refLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); refLabel.setText("Ref"); Text refText = new Text(composite, SWT.READ_ONLY); refText.setText(patchSetDetail.getPatchSet().getRefName()); final TableViewer viewer = new TableViewer(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL); GridDataFactory.fillDefaults() .span(2, 1) .grab(true, true) .hint(500, SWT.DEFAULT) .applyTo(viewer.getControl()); viewer.setContentProvider( new IStructuredContentProvider() { private EContentAdapter modelAdapter; public void dispose() { // ignore } public Object[] getElements(Object inputElement) { return getReviewItems(inputElement).toArray(); } private List<IReviewItem> getReviewItems(Object inputElement) { if (inputElement instanceof IReviewItemSet) { return ((IReviewItemSet) inputElement).getItems(); } return Collections.emptyList(); } public void inputChanged(final Viewer viewer, Object oldInput, Object newInput) { if (modelAdapter != null) { for (IReviewItem item : getReviewItems(oldInput)) { ((EObject) item).eAdapters().remove(modelAdapter); } addedDrafts = 0; } if (newInput instanceof IReviewItemSet) { // monitors any new topics that are added modelAdapter = new EContentAdapter() { @Override public void notifyChanged(Notification notification) { super.notifyChanged(notification); if (notification.getFeatureID(IReviewItem.class) == ReviewsPackage.REVIEW_ITEM__TOPICS && notification.getEventType() == Notification.ADD) { viewer.refresh(); addedDrafts++; } } }; for (Object item : getReviewItems(newInput)) { ((EObject) item).eAdapters().add(modelAdapter); } } } }); viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new ReviewItemLabelProvider())); viewer.addOpenListener( new IOpenListener() { public void open(OpenEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); IFileItem item = (IFileItem) selection.getFirstElement(); if (item != null) { doOpen((IReviewItemSet) viewer.getInput(), item); } } }); IReviewItemSet itemSet = GerritUtil.createInput(changeDetail, new GerritPatchSetContent(patchSetDetail), cache); viewer.setInput(itemSet); Composite actionComposite = createActions(changeDetail, patchSetDetail, publishDetail, composite); GridDataFactory.fillDefaults().span(2, 1).applyTo(actionComposite); subSectionExpanded(changeDetail, patchSetDetail, subSection, viewer); EditorUtil.addScrollListener(viewer.getTable()); getTaskEditorPage().reflow(); }
/** 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); }
public VerrechnungsDisplay(final IWorkbenchPage p, Composite parent, int style) { super(parent, style); setLayout(new GridLayout()); this.page = p; defaultRGB = UiDesk.createColor(new RGB(255, 255, 255)); hVer = UiDesk.getToolkit() .createHyperlink(this, Messages.VerrechnungsDisplay_billing, SWT.NONE); // $NON-NLS-1$ hVer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); hVer.addHyperlinkListener( new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { try { if (StringTool.isNothing(LeistungenView.ID)) { SWTHelper.alert( Messages.VerrechnungsDisplay_error, "LeistungenView.ID"); //$NON-NLS-1$ //$NON-NLS-2$ } page.showView(LeistungenView.ID); CodeSelectorHandler.getInstance().setCodeSelectorTarget(dropTarget); } catch (Exception ex) { ElexisStatus status = new ElexisStatus( ElexisStatus.ERROR, Hub.PLUGIN_ID, ElexisStatus.CODE_NONE, Messages.VerrechnungsDisplay_errorStartingCodeWindow + ex.getMessage(), ex, ElexisStatus.LOG_ERRORS); StatusManager.getManager().handle(status, StatusManager.SHOW); } } }); makeActions(); tVerr = UiDesk.getToolkit().createTable(this, SWT.MULTI); tVerr.setLayoutData(new GridData(GridData.FILL_BOTH)); tVerr.setMenu(createVerrMenu()); // dummy table viewer needed for SelectionsProvider for Menu viewer = new TableViewer(tVerr); // add selection event to table which provides selection to ElexisEventDispatcher tVerr.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableItem[] selection = tVerr.getSelection(); Verrechnet verrechnet = (Verrechnet) selection[0].getData(); ElexisEventDispatcher.fireSelectionEvent(verrechnet); applyMedicationAction.setEnabled(false); IVerrechenbar verrechenbar = verrechnet.getVerrechenbar(); if (verrechenbar != null && (verrechenbar instanceof Artikel)) { applyMedicationAction.setEnabled(true); } } }); tVerr.addKeyListener( new KeyListener() { @Override public void keyReleased(KeyEvent e) {} @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { if (tVerr.getSelectionIndices().length >= 1 && removeAction != null) { removeAction.run(); } } } }); dropTarget = new PersistentObjectDropTarget( Messages.VerrechnungsDisplay_doBill, tVerr, new DropReceiver()); // $NON-NLS-1$ // refresh the table if a update to a Verrechnet occurs ElexisEventDispatcher.getInstance() .addListeners( new ElexisUiEventListenerImpl(Verrechnet.class, ElexisEvent.EVENT_UPDATE) { @Override public void runInUi(ElexisEvent ev) { Konsultation actKons = (Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class); setLeistungen(actKons); } }); ElexisEventDispatcher.getInstance().addListeners(eeli_update); }