Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2018-06-11 16:23:31 -0400
committerDonald Dunne2018-09-05 16:33:03 -0400
commitb9ccb28275dd04d94a3e5997eb423d9f578a529e (patch)
tree66d28749352afb2059051c540d1610a4db32b0f6
parent1d4714f136d7aeb36d5449250eec9bea673955f6 (diff)
downloadorg.eclipse.osee-b9ccb28275dd04d94a3e5997eb423d9f578a529e.tar.gz
org.eclipse.osee-b9ccb28275dd04d94a3e5997eb423d9f578a529e.tar.xz
org.eclipse.osee-b9ccb28275dd04d94a3e5997eb423d9f578a529e.zip
feature: Add CheckBoxStateFilterTreeViewer
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/wizard/NewActionPage1.java87
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AICheckTreeDialog.java3
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AITreeContentProvider.java1
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/review/NewPeerReviewDialog.java35
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateFilteredTreeDialog.java261
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateFilteredTreeViewer.java139
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeContentProvider.java62
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeNode.java91
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewer.java18
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/FilteredCheckboxTreeDialog.java6
13 files changed, 477 insertions, 230 deletions
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF
index 3b0175fc5e..cd6c4528ef 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF
@@ -129,6 +129,7 @@ Import-Package: com.google.common.collect,
org.eclipse.osee.framework.ui.skynet.results.html,
org.eclipse.osee.framework.ui.skynet.util.email,
org.eclipse.osee.framework.ui.skynet.widgets,
+ org.eclipse.osee.framework.ui.skynet.widgets.checkbox,
org.eclipse.osee.framework.ui.skynet.widgets.dialog,
org.eclipse.osee.framework.ui.skynet.widgets.util,
org.eclipse.osee.framework.ui.skynet.widgets.xnavigate,
diff --git a/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF
index 0834be0294..df4fb52762 100644
--- a/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF
@@ -216,6 +216,7 @@ Import-Package: com.google.common.base;version="15.0.0",
org.eclipse.osee.framework.ui.skynet.util,
org.eclipse.osee.framework.ui.skynet.util.email,
org.eclipse.osee.framework.ui.skynet.widgets,
+ org.eclipse.osee.framework.ui.skynet.widgets.checkbox,
org.eclipse.osee.framework.ui.skynet.widgets.dialog,
org.eclipse.osee.framework.ui.skynet.widgets.util,
org.eclipse.osee.framework.ui.skynet.widgets.xBranch,
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/wizard/NewActionPage1.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/wizard/NewActionPage1.java
index 103a995aa8..62366d8db2 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/wizard/NewActionPage1.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/actions/wizard/NewActionPage1.java
@@ -18,9 +18,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
@@ -35,7 +32,6 @@ import org.eclipse.osee.ats.core.config.TeamDefinitions;
import org.eclipse.osee.ats.help.ui.AtsHelpContext;
import org.eclipse.osee.ats.internal.Activator;
import org.eclipse.osee.ats.internal.AtsClientService;
-import org.eclipse.osee.ats.util.AtsObjectLabelProvider;
import org.eclipse.osee.ats.util.IAtsClient;
import org.eclipse.osee.ats.util.widgets.dialog.AITreeContentProvider;
import org.eclipse.osee.ats.util.widgets.dialog.AtsObjectNameSorter;
@@ -51,7 +47,10 @@ import org.eclipse.osee.framework.ui.plugin.util.HelpUtil;
import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener;
import org.eclipse.osee.framework.ui.skynet.widgets.XText;
import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
-import org.eclipse.osee.framework.ui.skynet.widgets.dialog.FilteredCheckboxTree;
+import org.eclipse.osee.framework.ui.skynet.widgets.checkbox.CheckBoxStateFilteredTreeViewer;
+import org.eclipse.osee.framework.ui.skynet.widgets.checkbox.CheckBoxStateTreeLabelProvider;
+import org.eclipse.osee.framework.ui.skynet.widgets.checkbox.ICheckBoxStateTreeListener;
+import org.eclipse.osee.framework.ui.skynet.widgets.checkbox.ICheckBoxStateTreeViewer;
import org.eclipse.osee.framework.ui.skynet.widgets.util.XWidgetPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -71,7 +70,7 @@ import org.eclipse.swt.widgets.Text;
public class NewActionPage1 extends WizardPage {
private final NewActionWizard wizard;
private XWidgetPage page;
- protected FilteredCheckboxTree treeViewer;
+ protected CheckBoxStateFilteredTreeViewer<IAtsActionableItem> treeViewer;
private Text descriptionLabel;
private boolean debugPopulated = false;
private static IAtsActionableItem atsAi;
@@ -117,23 +116,23 @@ public class NewActionPage1 extends WizardPage {
}
});
- Pair<FilteredCheckboxTree, Text> results = createActionableItemTreeViewer(comp, wizard.getSelectableAis());
+ Pair<CheckBoxStateFilteredTreeViewer<IAtsActionableItem>, Text> results =
+ createActionableItemTreeViewer(comp, wizard.getSelectableAis());
treeViewer = results.getFirst();
descriptionLabel = results.getSecond();
- treeViewer.getCheckboxTreeViewer().addCheckStateListener(new ICheckStateListener() {
-
+ treeViewer.addCheckListener(new ICheckBoxStateTreeListener() {
@Override
- public void checkStateChanged(CheckStateChangedEvent event) {
+ public void checkStateNodesChanged() {
getContainer().updateButtons();
}
});
- treeViewer.getCheckboxTreeViewer().addCheckStateListener(new CheckStateListener());
+ treeViewer.addCheckListener(new CheckStateListener());
setControl(comp);
setHelpContexts();
if (wizard.getInitialAias() != null) {
- treeViewer.setInitalChecked(wizard.getInitialAias());
+ treeViewer.setChecked(wizard.getInitialAias());
}
((XText) getXWidget(TITLE)).setFocus();
} catch (Exception ex) {
@@ -141,17 +140,18 @@ public class NewActionPage1 extends WizardPage {
}
}
- public static Pair<FilteredCheckboxTree, Text> createActionableItemTreeViewer(Composite comp, Collection<IAtsActionableItem> selectableAis) {
+ public static Pair<CheckBoxStateFilteredTreeViewer<IAtsActionableItem>, Text> createActionableItemTreeViewer(Composite comp, Collection<IAtsActionableItem> selectableAis) {
Composite aiComp = new Composite(comp, SWT.NONE);
aiComp.setLayout(new GridLayout(1, false));
aiComp.setLayoutData(new GridData(GridData.FILL_BOTH));
new Label(aiComp, SWT.NONE).setText("Select Actionable Items:");
- FilteredCheckboxTree treeViewer = new FilteredCheckboxTree(aiComp,
- SWT.CHECK | SWT.MULTI | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ CheckBoxStateFilteredTreeViewer<IAtsActionableItem> treeViewer =
+ new CheckBoxStateFilteredTreeViewer<IAtsActionableItem>(aiComp,
+ SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
treeViewer.getViewer().getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
treeViewer.getViewer().setContentProvider(new AITreeContentProvider(Active.Active));
- treeViewer.getViewer().setLabelProvider(new AtsObjectLabelProvider());
+ treeViewer.getViewer().setLabelProvider(new AITreeLabelProvider(treeViewer));
try {
if (selectableAis == null) {
List<IAtsActionableItem> activeActionableItemTree = new LinkedList<>();
@@ -188,11 +188,31 @@ public class NewActionPage1 extends WizardPage {
@Override
public void widgetSelected(SelectionEvent e) {
- treeViewer.clearChecked();
+ treeViewer.deSelectAll();
};
});
- return new Pair<FilteredCheckboxTree, Text>(treeViewer, descriptionLabel);
+ return new Pair<CheckBoxStateFilteredTreeViewer<IAtsActionableItem>, Text>(treeViewer, descriptionLabel);
+ }
+
+ public static class AITreeLabelProvider extends CheckBoxStateTreeLabelProvider {
+
+ public AITreeLabelProvider(ICheckBoxStateTreeViewer treeViewer) {
+ super(treeViewer);
+ }
+
+ @Override
+ protected boolean isEnabled(Object element) {
+ boolean enabled = false;
+ if (element instanceof IAtsActionableItem) {
+ IAtsActionableItem ai = (IAtsActionableItem) element;
+ if (ai.isActionable()) {
+ enabled = true;
+ }
+ }
+ return enabled;
+ }
+
}
/**
@@ -210,7 +230,7 @@ public class NewActionPage1 extends WizardPage {
AtsArtifactToken.TopActionableItem);
if (atsAi != null) {
treeViewer.getViewer().setSelection(new StructuredSelection(Arrays.asList(atsAi)));
- treeViewer.setInitalChecked(Arrays.asList(atsAi));
+ treeViewer.setChecked(atsAi, true);
}
}
getContainer().updateButtons();
@@ -220,27 +240,20 @@ public class NewActionPage1 extends WizardPage {
}
}
- private class CheckStateListener implements ICheckStateListener {
+ private class CheckStateListener implements ICheckBoxStateTreeListener {
@Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- IStructuredSelection sel = (IStructuredSelection) treeViewer.getViewer().getSelection();
- if (sel.isEmpty()) {
- return;
- }
- Collection<Object> checked = treeViewer.getChecked();
- if (checked.isEmpty()) {
- descriptionLabel.setText("");
- } else {
- Object obj = checked.iterator().next();
- if (obj instanceof IAtsActionableItem) {
- IAtsActionableItem ai = (IAtsActionableItem) obj;
+ public void checkStateChanged(Object obj) {
+ if (descriptionLabel != null) {
+ Collection<IAtsActionableItem> checked = treeViewer.getChecked();
+ if (checked.isEmpty()) {
+ descriptionLabel.setText("");
+ } else {
+ IAtsActionableItem ai = checked.iterator().next();
descriptionLabel.setText(ai.getDescription());
- } else if (obj instanceof JaxActionableItem) {
- JaxActionableItem jai = (JaxActionableItem) obj;
- descriptionLabel.setText(jai.getDescription());
}
}
}
+
}
private void setHelpContexts() {
@@ -274,7 +287,7 @@ public class NewActionPage1 extends WizardPage {
for (IAtsActionableItem aia : getSelectedIAtsActionableItems()) {
if (!aia.isActionable() || !userActionCreationEnabled(aia)) {
AWorkbench.popup("ERROR", ActionableItems.getNotActionableItemError(aia));
- treeViewer.getCheckboxTreeViewer().setChecked(aia, false);
+ treeViewer.setChecked(aia, false);
return false;
}
}
@@ -298,7 +311,7 @@ public class NewActionPage1 extends WizardPage {
return aia.isAllowUserActionCreation();
}
- public FilteredCheckboxTree getTreeViewer() {
+ public CheckBoxStateFilteredTreeViewer<IAtsActionableItem> getTreeViewer() {
return treeViewer;
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AICheckTreeDialog.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AICheckTreeDialog.java
index c517f05217..ac2ae0e05e 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AICheckTreeDialog.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AICheckTreeDialog.java
@@ -32,7 +32,7 @@ import org.eclipse.swt.widgets.Control;
/**
* @author Donald G. Dunne
*/
-public class AICheckTreeDialog extends FilteredCheckboxTreeDialog {
+public class AICheckTreeDialog extends FilteredCheckboxTreeDialog<IAtsActionableItem> {
private final Active active;
private Collection<IAtsActionableItem> initialAias;
@@ -42,7 +42,6 @@ public class AICheckTreeDialog extends FilteredCheckboxTreeDialog {
this.active = active;
}
- @SuppressWarnings("unchecked")
@Override
public Collection<IAtsActionableItem> getChecked() {
return super.getTreeViewer().getChecked();
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AITreeContentProvider.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AITreeContentProvider.java
index 24be92f799..2a966578af 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AITreeContentProvider.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/dialog/AITreeContentProvider.java
@@ -31,7 +31,6 @@ public class AITreeContentProvider implements ITreeContentProvider {
private boolean showChildren = true;
public AITreeContentProvider(Active active) {
- super();
this.active = active;
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/review/NewPeerReviewDialog.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/review/NewPeerReviewDialog.java
index f43263f957..220cd60540 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/review/NewPeerReviewDialog.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/workflow/review/NewPeerReviewDialog.java
@@ -14,8 +14,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.osee.ats.actions.wizard.NewActionPage1;
import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
import org.eclipse.osee.ats.api.review.ReviewFormalType;
@@ -27,8 +25,8 @@ import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.skynet.widgets.XCombo;
import org.eclipse.osee.framework.ui.skynet.widgets.XModifiedListener;
import org.eclipse.osee.framework.ui.skynet.widgets.XWidget;
+import org.eclipse.osee.framework.ui.skynet.widgets.checkbox.CheckBoxStateFilteredTreeViewer;
import org.eclipse.osee.framework.ui.skynet.widgets.dialog.EntryDialog;
-import org.eclipse.osee.framework.ui.skynet.widgets.dialog.FilteredCheckboxTree;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -46,8 +44,7 @@ public class NewPeerReviewDialog extends EntryDialog {
private final Collection<IAtsActionableItem> selectedAis;
private final String defaultRelatedToState;
private final Collection<IAtsActionableItem> ais;
- private FilteredCheckboxTree aiFilteredTree;
- private Text descriptionLabel;
+ private CheckBoxStateFilteredTreeViewer<IAtsActionableItem> treeViewer;
private XCombo relatedToStateCombo;
private XCombo blockingTypeCombo;
@@ -83,30 +80,14 @@ public class NewPeerReviewDialog extends EntryDialog {
}
private void createAisSelection(Composite parent) {
- Pair<FilteredCheckboxTree, Text> results = NewActionPage1.createActionableItemTreeViewer(parent, null);
- aiFilteredTree = results.getFirst();
- descriptionLabel = results.getSecond();
- aiFilteredTree.getCheckboxTreeViewer().addCheckStateListener(new CheckStateListener());
-
- }
- private class CheckStateListener implements ICheckStateListener {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- selectedAis.clear();
- for (Object obj : aiFilteredTree.getChecked()) {
- selectedAis.add((IAtsActionableItem) obj);
- }
- if (!selectedAis.isEmpty()) {
- IAtsActionableItem aia = selectedAis.iterator().next();
- descriptionLabel.setText(aia.getDescription());
- }
- handleModified();
- }
+ Pair<CheckBoxStateFilteredTreeViewer<IAtsActionableItem>, Text> results =
+ NewActionPage1.createActionableItemTreeViewer(parent, null);
+ treeViewer = results.getFirst();
}
public Set<IAtsActionableItem> getSelectedActionableItems() {
Set<IAtsActionableItem> selected = new HashSet<>();
- for (Object obj : aiFilteredTree.getChecked()) {
+ for (Object obj : treeViewer.getChecked()) {
selected.add((IAtsActionableItem) obj);
}
return selected;
@@ -179,7 +160,7 @@ public class NewPeerReviewDialog extends EntryDialog {
setErrorString("Must select Review Type");
return false;
}
- if (aiFilteredTree != null) {
+ if (treeViewer != null) {
if (selectedAis.isEmpty()) {
setErrorString("Must select Actionable Item");
return false;
@@ -191,7 +172,7 @@ public class NewPeerReviewDialog extends EntryDialog {
IAtsTeamDefinition teamDef = ai.getTeamDefinitionInherited();
if (teamDef == null) {
AWorkbench.popup("No related Team Definition for selected Actionable Item. Choose another");
- aiFilteredTree.getCheckboxTreeViewer().setChecked(ai, false);
+ treeViewer.setChecked(ai, false);
}
}
return true;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
index 5126e81a49..b37f93c1c6 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
@@ -243,6 +243,8 @@ Export-Package: org.eclipse.osee.framework.ui.skynet,
org.eclipse.osee.framework.ui.skynet.util.matrix,
org.eclipse.osee.framework.ui.skynet.widgets,
org.eclipse.osee.framework.ui.skynet.widgets.cellEditor,
+ org.eclipse.osee.framework.ui.skynet.widgets.checkbox,
+ org.eclipse.osee.framework.ui.skynet.widgets.checkbox.images,
org.eclipse.osee.framework.ui.skynet.widgets.dialog,
org.eclipse.osee.framework.ui.skynet.widgets.util,
org.eclipse.osee.framework.ui.skynet.widgets.xBranch,
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateFilteredTreeDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateFilteredTreeDialog.java
new file mode 100644
index 0000000000..4411bce3e4
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateFilteredTreeDialog.java
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.ui.skynet.widgets.checkbox;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.osee.framework.core.util.Result;
+import org.eclipse.osee.framework.ui.swt.Displays;
+import org.eclipse.osee.framework.ui.swt.ToStringContainsPatternFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.dialogs.PatternFilter;
+
+public class CheckBoxStateFilteredTreeDialog<T> extends MessageDialog {
+
+ protected Label statusLabel;
+ protected Button okButton;
+ private CheckBoxStateFilteredTreeViewer<T> treeViewer;
+ private Object input;
+ private IContentProvider contentProvider;
+ private final CheckBoxStateTreeLabelProvider labelProvider;
+ private Collection<T> initialSelections;
+ private final ViewerComparator viewerComparator;
+ private boolean showSelectButtons = false;
+ private boolean expandChecked = false;
+ private PatternFilter patternFilter;
+ private Collection<T> selectables;
+
+ public CheckBoxStateFilteredTreeDialog(String dialogTitle, String dialogMessage, IContentProvider contentProvider, CheckBoxStateTreeLabelProvider labelProvider) {
+ this(dialogTitle, dialogMessage, contentProvider, labelProvider, null);
+ }
+
+ public CheckBoxStateFilteredTreeDialog(String dialogTitle, String dialogMessage, IContentProvider contentProvider, CheckBoxStateTreeLabelProvider labelProvider, ViewerComparator viewerSorter) {
+ super(Displays.getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.NONE,
+ new String[] {"OK", "Cancel"}, 0);
+ this.contentProvider = contentProvider;
+ this.labelProvider = labelProvider;
+ this.viewerComparator = viewerSorter;
+ if (patternFilter == null) {
+ this.patternFilter = new ToStringContainsPatternFilter();
+ } else {
+ patternFilter = new PatternFilter();
+ }
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ public CheckBoxStateFilteredTreeDialog(String dialogTitle, String dialogMessage, Collection<T> selectables, IContentProvider contentProvider, CheckBoxStateTreeLabelProvider labelProvider, ViewerComparator viewerSorter) {
+ this(dialogTitle, dialogMessage, contentProvider, labelProvider, viewerSorter);
+ this.selectables = selectables;
+ }
+
+ public void setShowSelectButtons(boolean showSelectButtons) {
+ this.showSelectButtons = showSelectButtons;
+ }
+
+ protected void createPreCustomArea(Composite parent) {
+ // provided for subclass implementation
+ }
+
+ protected void createPostCustomArea(Composite parent) {
+ // provided for subclass implementation
+ }
+
+ /**
+ * Sets the input. Convenience method.
+ *
+ * @param object the input.
+ */
+ public final void setInput(Object input) {
+ this.input = input;
+ if (treeViewer != null) {
+ treeViewer.getViewer().setInput(input);
+ }
+ }
+
+ public void setInitialSelections(Collection<T> initialSelections) {
+ this.initialSelections = initialSelections;
+ if (treeViewer != null) {
+ getCheckboxTreeViewer().setChecked(initialSelections);
+ }
+ }
+
+ protected CheckBoxStateFilteredTreeViewer<T> getCheckboxTreeViewer() {
+ return treeViewer;
+ }
+
+ public Collection<T> getResult() {
+ if (treeViewer == null) {
+ return Collections.emptyList();
+ }
+ return treeViewer.getChecked();
+ }
+
+ @Override
+ protected Control createCustomArea(Composite parent) {
+
+ statusLabel = new Label(parent, SWT.NONE);
+ statusLabel.setForeground(Displays.getSystemColor(SWT.COLOR_RED));
+ createPreCustomArea(parent);
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(1, true);
+ layout.marginWidth = 0;
+ comp.setLayout(layout);
+ comp.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ treeViewer =
+ new CheckBoxStateFilteredTreeViewer<T>(comp, SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.heightHint = 500;
+ treeViewer.getViewer().getTree().setLayoutData(gd);
+ treeViewer.getViewer().setContentProvider(contentProvider);
+ labelProvider.setTreeViewer(treeViewer);
+ treeViewer.getViewer().setLabelProvider(labelProvider);
+ treeViewer.getViewer().setAutoExpandLevel(0);
+ if (viewerComparator != null) {
+ treeViewer.getViewer().setComparator(viewerComparator);
+ }
+ treeViewer.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateStatusLabel();
+ }
+ });
+
+ if (selectables != null && !selectables.isEmpty()) {
+ setInput(selectables);
+ }
+
+ if (input != null) {
+ treeViewer.getViewer().setInput(input);
+ }
+ if (initialSelections != null) {
+ treeViewer.setChecked(initialSelections);
+ treeViewer.getViewer().refresh();
+ }
+ updateStatusLabel();
+
+ if (showSelectButtons) {
+ Composite buttonComp = new Composite(parent, SWT.NONE);
+ buttonComp.setLayout(new GridLayout(2, false));
+ buttonComp.setLayoutData(new GridData());
+
+ Button selectAllButton = new Button(buttonComp, SWT.PUSH);
+ selectAllButton.setText("Select All");
+ selectAllButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ treeViewer.setChecked(getAllItems());
+ updateStatusLabel();
+ }
+ });
+
+ Button deSelectAllButton = new Button(buttonComp, SWT.PUSH);
+ deSelectAllButton.setText("De-Select All");
+ deSelectAllButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ treeViewer.deSelectAll();
+ updateStatusLabel();
+ }
+ });
+ }
+ if (expandChecked) {
+ treeViewer.expandChecked();
+ }
+
+ createPostCustomArea(parent);
+
+ return parent;
+ }
+
+ protected Collection<T> getAllItems() {
+ return null;
+ }
+
+ public void addCheckStateListener(ICheckBoxStateTreeListener listener) {
+ getCheckboxTreeViewer().addCheckListener(listener);
+ }
+
+ protected void updateStatusLabel() {
+ Result result = isComplete();
+ if (result.isFalse()) {
+ statusLabel.setText(result.getText());
+ } else {
+ statusLabel.setText("");
+ }
+ statusLabel.getParent().layout();
+ updateButtons();
+ }
+
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Control c = super.createButtonBar(parent);
+ okButton = getButton(0);
+ okButton.setEnabled(false);
+ return c;
+ }
+
+ protected Result isComplete() {
+ return Result.TrueResult;
+ }
+
+ private void updateButtons() {
+ if (okButton != null) {
+ okButton.setEnabled(isComplete().isTrue());
+ }
+ }
+
+ public void setExpandChecked(boolean expandChecked) {
+ this.expandChecked = expandChecked;
+ }
+
+ public void setPatternFilter(PatternFilter patternFilter) {
+ this.patternFilter = patternFilter;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection<T> getChecked() {
+ List<T> checked = new ArrayList<>();
+ for (Object obj : getResult()) {
+ checked.add((T) obj);
+ }
+ return checked;
+ }
+
+ public Collection<T> getInitialSelections() {
+ return initialSelections;
+ }
+
+ public void setContentProvider(IContentProvider contentProvider) {
+ this.contentProvider = contentProvider;
+ }
+
+ public CheckBoxStateFilteredTreeViewer<T> getTreeViewer() {
+ return treeViewer;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateFilteredTreeViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateFilteredTreeViewer.java
new file mode 100644
index 0000000000..37a15e0162
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateFilteredTreeViewer.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.ui.skynet.widgets.checkbox;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.dialogs.FilteredTree;
+import org.eclipse.ui.dialogs.PatternFilter;
+
+/**
+ * Tree Viewer with ability to disable items from being checked. Override the Label Provider to provide own images. Run
+ * CheckBoxStateTreeViewerExample to see example.
+ *
+ * @author Donald G. Dunne
+ */
+public class CheckBoxStateFilteredTreeViewer<T> extends FilteredTree implements ICheckBoxStateTreeViewer {
+
+ private final List<ICheckBoxStateTreeListener> listeners = new ArrayList<>();
+ private final Set<T> checked = new HashSet<T>();
+ private final Set<T> disabled = new HashSet<T>();
+
+ public CheckBoxStateFilteredTreeViewer(Composite parent, int style) {
+ super(parent, style, new PatternFilter(), true);
+ treeViewer.setLabelProvider(new CheckBoxStateTreeLabelProvider(this));
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object selected = selection.getFirstElement();
+ if (isEnabled(selected)) {
+ setChecked((T) selected, !isChecked(selected));
+ for (ICheckBoxStateTreeListener listener : listeners) {
+ listener.checkStateNodesChanged();
+ }
+ treeViewer.refresh(selected);
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean isEnabled(Object obj) {
+ return !this.disabled.contains(obj);
+ }
+
+ @Override
+ public boolean isChecked(Object obj) {
+ return this.checked.contains(obj);
+ }
+
+ public void setChecked(T obj, boolean checked) {
+ if (checked) {
+ this.checked.add(obj);
+ } else {
+ this.checked.remove(obj);
+ }
+ treeViewer.refresh();
+ for (ICheckBoxStateTreeListener listener : listeners) {
+ listener.checkStateChanged(obj);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setEnabled(Object obj, boolean enabled) {
+ if (enabled) {
+ this.disabled.remove(obj);
+ } else {
+ this.disabled.add((T) obj);
+ }
+ treeViewer.refresh();
+ }
+
+ public void addCheckListener(ICheckBoxStateTreeListener listener) {
+ listeners.add(listener);
+ }
+
+ public void deSelectAll() {
+ this.checked.clear();
+ for (ICheckBoxStateTreeListener listener : listeners) {
+ listener.checkStateNodesChanged();
+ }
+ treeViewer.refresh();
+ }
+
+ public Collection<T> getChecked() {
+ return this.checked;
+ }
+
+ public void setChecked(Collection<T> checked) {
+ this.checked.addAll(checked);
+ treeViewer.refresh();
+ }
+
+ public void expandChecked() {
+ TreeItem[] items = treeViewer.getTree().getItems();
+ expandChecked(items);
+ }
+
+ private void expandChecked(TreeItem[] items) {
+ for (int i = 0; i < items.length; i++) {
+ TreeItem item = items[i];
+ if (item.getData() != null) {
+ if (item.getChecked()) {
+ expandParents(item);
+ }
+ }
+ expandChecked(item.getItems());
+ }
+ }
+
+ public void expandParents(TreeItem item) {
+ if (item.getParentItem() != null) {
+ TreeItem parent = item.getParentItem();
+ if (!parent.getExpanded()) {
+ parent.setExpanded(true);
+ }
+ expandParents(parent);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeContentProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeContentProvider.java
deleted file mode 100644
index 62400277ad..0000000000
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeContentProvider.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2018 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.ui.skynet.widgets.checkbox;
-
-import java.util.List;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * @author Donald G. Dunne
- */
-public class CheckBoxStateTreeContentProvider implements ITreeContentProvider {
-
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
- // TODO Auto-generated method stub
-
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof List<?>) {
- return ((List<CheckBoxStateTreeNode>) inputElement).toArray(
- new CheckBoxStateTreeNode[((List<?>) inputElement).size()]);
- }
- if (inputElement instanceof CheckBoxStateTreeNode) {
- return ((CheckBoxStateTreeNode) inputElement).getChildren().toArray();
- }
- return null;
- }
-
- @Override
- public Object[] getChildren(Object parentElement) {
- return ((CheckBoxStateTreeNode) parentElement).getChildren().toArray();
- }
-
- @Override
- public Object getParent(Object element) {
- return ((CheckBoxStateTreeNode) element).getParent();
- }
-
- @Override
- public boolean hasChildren(Object element) {
- return ((CheckBoxStateTreeNode) element).getChildren().size() > 0;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeNode.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeNode.java
deleted file mode 100644
index a5c6d56777..0000000000
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeNode.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2018 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.ui.skynet.widgets.checkbox;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Donald G. Dunne
- */
-public class CheckBoxStateTreeNode {
- private final String name;
- private final CheckBoxStateTreeNode parent;
- private List<CheckBoxStateTreeNode> children = new ArrayList<>();
- private boolean checked;
- private boolean enabled = true;
- private Object data;
-
- public CheckBoxStateTreeNode(String name, Object data, CheckBoxStateTreeNode parent) {
- this.name = name;
- this.data = data;
- this.parent = parent;
- if (parent != null) {
- parent.addChild(this);
- }
- }
-
- public void setCheckAll(boolean checked) {
- this.checked = checked;
- for (CheckBoxStateTreeNode child : children) {
- child.setChecked(checked);
- }
- }
-
- public void addChild(CheckBoxStateTreeNode child) {
- children.add(child);
- }
-
- public List<CheckBoxStateTreeNode> getChildren() {
- return children;
- }
-
- public void setChildren(List<CheckBoxStateTreeNode> children) {
- this.children = children;
- }
-
- public String getName() {
- return name;
- }
-
- public CheckBoxStateTreeNode getParent() {
- return parent;
- }
-
- public boolean isChecked() {
- return checked;
- }
-
- public void setChecked(boolean checked) {
- this.checked = checked;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public Object getData() {
- return data;
- }
-
- public void setData(Object data) {
- this.data = data;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewer.java
index 3b783918df..2122d9ecc6 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewer.java
@@ -76,6 +76,15 @@ public class CheckBoxStateTreeViewer<T> extends TreeViewer implements ICheckBoxS
return false;
}
+ public void deSelectAll(Collection<T> selection) {
+ for (Entry<T, Boolean> entry : this.checked.entrySet()) {
+ if (selection.contains(entry.getKey())) {
+ entry.setValue(false);
+ }
+ }
+ refresh();
+ }
+
public void setChecked(T obj, boolean checked) {
this.checked.put(obj, checked);
refresh();
@@ -106,15 +115,6 @@ public class CheckBoxStateTreeViewer<T> extends TreeViewer implements ICheckBoxS
}
}
- public void deSelectAll(Collection<T> selection) {
- for (Entry<T, Boolean> entry : this.checked.entrySet()) {
- if (selection.contains(entry.getKey())) {
- entry.setValue(false);
- }
- }
- refresh();
- }
-
public List<T> getChecked() {
List<T> results = new ArrayList<>();
for (Entry<T, Boolean> entry : this.checked.entrySet()) {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/FilteredCheckboxTreeDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/FilteredCheckboxTreeDialog.java
index a6fb799d48..889a403df2 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/FilteredCheckboxTreeDialog.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/dialog/FilteredCheckboxTreeDialog.java
@@ -42,7 +42,7 @@ public class FilteredCheckboxTreeDialog<T> extends MessageDialog {
protected Button okButton;
private FilteredCheckboxTree treeViewer;
private Object input;
- private final IContentProvider contentProvider;
+ private IContentProvider contentProvider;
private final IBaseLabelProvider labelProvider;
private Collection<T> initialSelections;
private final ViewerComparator viewerComparator;
@@ -262,4 +262,8 @@ public class FilteredCheckboxTreeDialog<T> extends MessageDialog {
return initialSelections;
}
+ public void setContentProvider(IContentProvider contentProvider) {
+ this.contentProvider = contentProvider;
+ }
+
}

Back to the top