List of usage examples for org.eclipse.swt.widgets Label setToolTipText
public void setToolTipText(String toolTipText)
From source file:org.eclipse.swt.snippets.Snippet278.java
public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setText("Snippet 278"); shell.setBounds(10, 10, 300, 100);// w w w . j av a 2s. co m shell.setLayout(new FillLayout()); final Label label = new Label(shell, SWT.NONE); label.setText("resize the Shell then hover over this Label"); label.addListener(SWT.MouseEnter, event -> { Point requiredSize = label.computeSize(SWT.DEFAULT, SWT.DEFAULT); Point labelSize = label.getSize(); boolean fullyVisible = requiredSize.x <= labelSize.x && requiredSize.y <= labelSize.y; System.out.println("Label is fully visible: " + fullyVisible); label.setToolTipText(fullyVisible ? null : label.getText()); }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:edu.isistan.carcha.plugin.editors.DXMIEditor.java
/** * Creates the DDD list page.//from ww w. j ava 2 s . c o m */ void createListPage() { final Composite composite = new Composite(getContainer(), SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 4)); composite.setLayout(new GridLayout()); Label concernLabel = new Label(composite, SWT.BORDER); concernLabel.setText("Design Decisions"); concernLabel.setToolTipText("This are the Design Decisions detected in the architectural document"); GridData gridData = new GridData(SWT.LEFT, SWT.LEFT, false, false); concernLabel.setLayoutData(gridData); ddsViewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); createColumns(composite, ddsViewer); final Table table = ddsViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); ddsViewer.setContentProvider(new ArrayContentProvider()); getSite().setSelectionProvider(ddsViewer); // define layout for the viewer gridData = new GridData(SWT.FILL, SWT.FILL, true, true); ddsViewer.getControl().setLayoutData(gridData); int index = addPage(composite); setPageText(index, "List"); }
From source file:edu.isistan.carcha.plugin.editors.TraceabilityEditor.java
/** * Creates a page to allow users to create a traceability link. *///from w ww . j a v a 2 s . co m void createTraceabilityLinkPage() { final Composite composite = new Composite(getContainer(), SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 5)); composite.setLayout(new GridLayout()); Label concernLabel = new Label(composite, SWT.BORDER); concernLabel.setText("Crosscuttings Concerns(CCC)"); concernLabel.setToolTipText("This are the Crosscuttings Concerns detected on the requierement document"); GridData gridData = new GridData(SWT.LEFT, SWT.TOP, false, false); concernLabel.setLayoutData(gridData); topNewLink = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); createColumns(composite, topNewLink); final Table table = topNewLink.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); topNewLink.setContentProvider(new ArrayContentProvider()); getSite().setSelectionProvider(topNewLink); // define layout for the viewer gridData = new GridData(SWT.FILL, SWT.FILL, true, true); topNewLink.getControl().setLayoutData(gridData); Button button = new Button(composite, SWT.PUSH); button.setText("Link"); button.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent event) { } public void widgetSelected(SelectionEvent event) { IStructuredSelection topSelection = (IStructuredSelection) topNewLink.getSelection(); IStructuredSelection bottomSelection = (IStructuredSelection) bottomNewLink.getSelection(); String[] crosscuttingConcern = (String[]) topSelection.getFirstElement(); String[] designDecision = (String[]) bottomSelection.getFirstElement(); if ((crosscuttingConcern != null) && (designDecision != null)) { // create dialog with ok and cancel button and info icon MessageBox dialog = new MessageBox(composite.getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); dialog.setText("Link confirmation"); dialog.setMessage("Do you want to link the selected items?"); // open dialog and await user selection int response = dialog.open(); if (response == SWT.OK) { PluginUtil.createNewLink(crosscuttingConcern, designDecision, cp); dirty = true; firePropertyChange(IEditorPart.PROP_DIRTY); } } else { MessageDialog.openError(composite.getShell(), "Error", "Please select item(s) to link"); } } }); gridData = new GridData(SWT.CENTER, SWT.TOP, false, false, 2, 1); button.setLayoutData(gridData); Label ddsLabel = new Label(composite, SWT.BORDER); ddsLabel.setText("Architectural design decisions"); ddsLabel.setToolTipText("This are the design decisions detected in the architectural document"); gridData = new GridData(SWT.LEFT, SWT.TOP, false, false); ddsLabel.setLayoutData(gridData); bottomNewLink = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); createColumns(composite, bottomNewLink); Table table2 = bottomNewLink.getTable(); table2.setHeaderVisible(true); table2.setLinesVisible(true); bottomNewLink.setContentProvider(new ArrayContentProvider()); getSite().setSelectionProvider(bottomNewLink); gridData = new GridData(SWT.FILL, SWT.FILL, true, true); bottomNewLink.getControl().setLayoutData(gridData); int index = addPage(composite); setPageText(index, "New Link"); }
From source file:edu.isistan.carcha.plugin.editors.TraceabilityEditor.java
/** * Creates the impact list page.//from ww w . j a v a2s .co m */ void impactListPage() { final Composite composite = new Composite(getContainer(), SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); composite.setLayout(new GridLayout()); Label concernLabel = new Label(composite, SWT.BORDER); concernLabel.setText("Crosccuting Concerns(CCC)"); concernLabel.setToolTipText("This are the concern detected on the requierement document."); GridData gridData = new GridData(SWT.LEFT, SWT.TOP, false, false); concernLabel.setLayoutData(gridData); ///////////////////// ScrolledComposite sc = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL); Composite parent = new Composite(sc, SWT.NONE); parent.setLayout(new GridLayout()); topViewLink = new TableViewer(parent, SWT.BORDER); createColumns(parent, topViewLink); final Table table = topViewLink.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); topViewLink.setContentProvider(new ArrayContentProvider()); getSite().setSelectionProvider(topViewLink); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.heightHint = 10 * table.getItemHeight(); table.setLayoutData(data); sc.setContent(parent); sc.setExpandHorizontal(true); sc.setExpandVertical(true); sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); ///////////////////// Button button = new Button(composite, SWT.PUSH); button.setText("Remove"); button.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent event) { } public void widgetSelected(SelectionEvent event) { IStructuredSelection topSelection = (IStructuredSelection) topViewLink.getSelection(); IStructuredSelection bottomSelection = (IStructuredSelection) bottomViewLink.getSelection(); String[] crosscuttingConcern = (String[]) topSelection.getFirstElement(); String[] designDecision = (String[]) bottomSelection.getFirstElement(); if (topSelection.size() > 1) { MessageDialog.openError(composite.getShell(), "Error", "Please select one crosscutting concern"); } else { if ((crosscuttingConcern != null) && (designDecision != null)) { // create dialog with ok and cancel button and info icon MessageBox dialog = new MessageBox(composite.getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); dialog.setText("Link confirmation"); dialog.setMessage("Do you want to remove the link between the selected items?"); // open dialog and await user selection int response = dialog.open(); if (response == SWT.OK) { PluginUtil.removeLink(crosscuttingConcern, designDecision, cp); dirty = true; firePropertyChange(IEditorPart.PROP_DIRTY); // update the list after the remove generateLinkViewData(); bottomViewLink.getTable().clearAll(); } } else { MessageDialog.openError(composite.getShell(), "Error", "Please select a crosscutting concern and a design decision to remove a traceability link"); } } } }); gridData = new GridData(SWT.CENTER, SWT.TOP, false, false, 2, 1); button.setLayoutData(gridData); Label ddsLabel = new Label(composite, SWT.BORDER); ddsLabel.setText("Architectural design decisions"); ddsLabel.setToolTipText("This are the design decisions detected on the architectural document"); gridData = new GridData(SWT.LEFT, SWT.TOP, false, false); ddsLabel.setLayoutData(gridData); bottomViewLink = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); createColumns(composite, bottomViewLink); Table table2 = bottomViewLink.getTable(); table2.setHeaderVisible(true); table2.setLinesVisible(true); bottomViewLink.setContentProvider(new ArrayContentProvider()); topViewLink.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (!selection.isEmpty()) { String[] cccs = (String[]) selection.getFirstElement(); List<DesignDecision> dds = PluginUtil.getDesignDecisionsForCrossCuttingConcern(cp, cccs[1], cccs[0]); logger.info("Impact List for CCC (" + dds.size() + " DDD): " + cccs[0] + " - " + cccs[1]); List<String[]> designDecisions = new ArrayList<String[]>(); for (DesignDecision dd : dds) { String[] designDecision = { dd.getKind(), dd.getName() }; designDecisions.add(designDecision); } bottomViewLink.setInput(designDecisions); } } }); getSite().setSelectionProvider(bottomViewLink); gridData = new GridData(SWT.FILL, SWT.FILL, true, true); bottomViewLink.getControl().setLayoutData(gridData); int index = addPage(composite); setPageText(index, "Links"); }