Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2016-12-06 03:57:48 +0000
committerFrank Becker2016-12-06 03:57:48 +0000
commit694a0d149829a332c0a10d5586712d07926ca82e (patch)
tree66d29eb99e4e527f81273421d15d8e1d7f74a702
parent8d884a379c1de286f1268bad7aef13ce8680e7c3 (diff)
downloadorg.eclipse.mylyn.commons-694a0d149829a332c0a10d5586712d07926ca82e.tar.gz
org.eclipse.mylyn.commons-694a0d149829a332c0a10d5586712d07926ca82e.tar.xz
org.eclipse.mylyn.commons-694a0d149829a332c0a10d5586712d07926ca82e.zip
234445: [upstream] show descriptions for keywords for the REST Connector
Change-Id: Iab7b3c3e86389039bb854b874abe1597fe6d8bd6 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=234445
-rw-r--r--org.eclipse.mylyn.commons.workbench/src/org/eclipse/mylyn/commons/workbench/InPlaceCheckBoxTreeDialog.java50
1 files changed, 47 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.commons.workbench/src/org/eclipse/mylyn/commons/workbench/InPlaceCheckBoxTreeDialog.java b/org.eclipse.mylyn.commons.workbench/src/org/eclipse/mylyn/commons/workbench/InPlaceCheckBoxTreeDialog.java
index ca3321d6..ca154b91 100644
--- a/org.eclipse.mylyn.commons.workbench/src/org/eclipse/mylyn/commons/workbench/InPlaceCheckBoxTreeDialog.java
+++ b/org.eclipse.mylyn.commons.workbench/src/org/eclipse/mylyn/commons/workbench/InPlaceCheckBoxTreeDialog.java
@@ -21,8 +21,11 @@ import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylyn.commons.ui.dialogs.AbstractInPlaceDialog;
@@ -31,7 +34,9 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
import org.eclipse.ui.progress.WorkbenchJob;
@@ -50,6 +55,10 @@ public class InPlaceCheckBoxTreeDialog extends AbstractInPlaceDialog {
private final String dialogLabel;
+ private final Map<String, String> validDescriptions;
+
+ private Text description;
+
private class CheckboxFilteredTree extends FilteredTree {
public CheckboxFilteredTree(Composite parent, int treeStyle, PatternFilter filter) {
@@ -82,8 +91,11 @@ public class InPlaceCheckBoxTreeDialog extends AbstractInPlaceDialog {
}
+ /**
+ * @since 3.22
+ */
public InPlaceCheckBoxTreeDialog(Shell shell, Control openControl, List<String> values,
- Map<String, String> validValues, String dialogLabel) {
+ Map<String, String> validValues, String dialogLabel, Map<String, String> validDescriptions) {
super(shell, SWT.RIGHT, openControl);
Assert.isNotNull(values);
Assert.isNotNull(validValues);
@@ -91,9 +103,15 @@ public class InPlaceCheckBoxTreeDialog extends AbstractInPlaceDialog {
this.selectedValues = new HashSet<String>(values);
this.validValues = validValues;
this.dialogLabel = dialogLabel;
+ this.validDescriptions = validDescriptions;
setShellStyle(getShellStyle());
}
+ public InPlaceCheckBoxTreeDialog(Shell shell, Control openControl, List<String> values,
+ Map<String, String> validValues, String dialogLabel) {
+ this(shell, openControl, values, validValues, dialogLabel, null);
+ }
+
@Override
protected Control createControl(Composite parent) {
getShell().setText(dialogLabel);
@@ -108,13 +126,25 @@ public class InPlaceCheckBoxTreeDialog extends AbstractInPlaceDialog {
GridData gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
composite.setLayoutData(gd);
- valueTree = new CheckboxFilteredTree(composite, SWT.CHECK | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL
- | SWT.BORDER, new SubstringPatternFilter());
+ valueTree = new CheckboxFilteredTree(composite,
+ SWT.CHECK | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, new SubstringPatternFilter());
gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
gd.heightHint = 175;
gd.widthHint = 160;
CheckboxTreeViewer viewer = valueTree.getViewer();
viewer.getControl().setLayoutData(gd);
+ if (validDescriptions != null) {
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("Description:"); //$NON-NLS-1$
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
+ gd.widthHint = 160;
+ label.setLayoutData(gd);
+ description = new Text(composite, SWT.WRAP);
+ gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
+ gd.heightHint = 25;
+ gd.widthHint = 160;
+ description.setLayoutData(gd);
+ }
if (validValues != null) {
@@ -192,6 +222,20 @@ public class InPlaceCheckBoxTreeDialog extends AbstractInPlaceDialog {
}
});
+ if (validDescriptions != null) {
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ TreeSelection treeSelection = (TreeSelection) event.getSelection();
+ Object firstSelectedElement = treeSelection.getFirstElement();
+ if (validDescriptions.containsKey(firstSelectedElement)) {
+ description.setText(validDescriptions.get(firstSelectedElement));
+ } else {
+ description.setText(""); //$NON-NLS-1$
+ }
+ }
+ });
+ }
return valueTree;
}

Back to the top