Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2018-06-08 15:21:55 -0400
committerdonald.g.dunne2018-09-05 10:54:07 -0400
commitd3130e1b3f8f73da04874e3f466e0393731365d3 (patch)
tree88ca1583afd7edeb3a42ac80ee64ff24714f05ae
parentee742746f0aeeae1ec22457f56918a5316e638ea (diff)
downloadorg.eclipse.osee-d3130e1b3f8f73da04874e3f466e0393731365d3.tar.gz
org.eclipse.osee-d3130e1b3f8f73da04874e3f466e0393731365d3.tar.xz
org.eclipse.osee-d3130e1b3f8f73da04874e3f466e0393731365d3.zip
feature: Add CheckBoxStateTreeViewer
-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/CheckBoxStateTreeLabelProvider.java52
-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.java138
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewerExample.java256
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/ICheckBoxStateTreeListener.java26
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/ICheckBoxStateTreeViewer.java24
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/CheckBoxStateImageCache.java42
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_checked.gifbin0 -> 343 bytes
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_disabled.gifbin0 -> 152 bytes
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_unchecked.gifbin0 -> 90 bytes
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/refresh.gifbin0 -> 182 bytes
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/report.gifbin0 -> 648 bytes
13 files changed, 691 insertions, 0 deletions
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
new file mode 100644
index 0000000000..62400277ad
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeContentProvider.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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/CheckBoxStateTreeLabelProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeLabelProvider.java
new file mode 100644
index 0000000000..575e616fd1
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeLabelProvider.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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 org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.osee.framework.ui.skynet.widgets.checkbox.images.CheckBoxStateImageCache;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class CheckBoxStateTreeLabelProvider extends LabelProvider {
+
+ private ICheckBoxStateTreeViewer treeViewer;
+
+ public CheckBoxStateTreeLabelProvider(ICheckBoxStateTreeViewer treeViewer) {
+ this.treeViewer = treeViewer;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ Image image = CheckBoxStateImageCache.getImage("chkbox_unchecked.gif");
+ if (isEnabled(element)) {
+ if (treeViewer.isChecked(element)) {
+ image = CheckBoxStateImageCache.getImage("chkbox_checked.gif");
+ }
+ } else {
+ image = CheckBoxStateImageCache.getImage("chkbox_disabled.gif");
+ }
+ return image;
+ }
+
+ /**
+ * Override to provide different implementation
+ */
+ protected boolean isEnabled(Object element) {
+ return treeViewer.isEnabled(element);
+ }
+
+ public void setTreeViewer(ICheckBoxStateTreeViewer treeViewer) {
+ this.treeViewer = treeViewer;
+ }
+
+}
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
new file mode 100644
index 0000000000..a5c6d56777
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeNode.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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
new file mode 100644
index 0000000000..3b783918df
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewer.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * 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.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * 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 CheckBoxStateTreeViewer<T> extends TreeViewer implements ICheckBoxStateTreeViewer {
+
+ private final List<ICheckBoxStateTreeListener> listeners = new ArrayList<>();
+ private final Map<T, Boolean> checked = new HashMap<T, Boolean>();
+ private final Map<T, Boolean> enabled = new HashMap<T, Boolean>();
+
+ public CheckBoxStateTreeViewer(Composite parent, int style) {
+ super(parent, style);
+ setLabelProvider(new CheckBoxStateTreeLabelProvider(this));
+ 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.checkStateChanged(selected);
+ }
+ for (ICheckBoxStateTreeListener listener : listeners) {
+ listener.checkStateNodesChanged();
+ }
+ refresh(selected);
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean isEnabled(Object obj) {
+ Boolean enabled = this.enabled.get(obj);
+ if (enabled != null) {
+ return enabled;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean isChecked(Object obj) {
+ Boolean checked = this.checked.get(obj);
+ if (checked != null) {
+ return checked;
+ }
+ return false;
+ }
+
+ public void setChecked(T obj, boolean checked) {
+ this.checked.put(obj, checked);
+ refresh();
+ for (ICheckBoxStateTreeListener listener : listeners) {
+ listener.checkStateChanged(obj);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setEnabled(Object obj, boolean enabled) {
+ this.enabled.put((T) obj, enabled);
+ }
+
+ public void addCheckListener(ICheckBoxStateTreeListener listener) {
+ listeners.add(listener);
+ }
+
+ public void deSelectAll() {
+ for (Entry<T, Boolean> entry : this.checked.entrySet()) {
+ if (entry.getValue()) {
+ setChecked(entry.getKey(), false);
+ }
+ }
+ refresh();
+ for (ICheckBoxStateTreeListener listener : listeners) {
+ listener.checkStateNodesChanged();
+ }
+ }
+
+ 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()) {
+ if (entry.getValue()) {
+ results.add(entry.getKey());
+ }
+ }
+ return results;
+ }
+
+ public void setChecked(Collection<T> checked) {
+ for (Entry<T, Boolean> entry : this.checked.entrySet()) {
+ entry.setValue(false);
+ if (checked.contains(entry.getKey())) {
+ entry.setValue(true);
+ }
+ }
+ refresh();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewerExample.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewerExample.java
new file mode 100644
index 0000000000..8aa601db85
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/CheckBoxStateTreeViewerExample.java
@@ -0,0 +1,256 @@
+/*******************************************************************************
+ * 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.Arrays;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osee.framework.ui.skynet.widgets.checkbox.images.CheckBoxStateImageCache;
+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.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class CheckBoxStateTreeViewerExample {
+
+ private static CheckBoxStateTreeViewer<ExampleTreeNode> treeViewer;
+ private static Text textBox;
+
+ public static void main(String[] args) {
+ // Get the Display. Create on if none exists
+ Display Display_1 = Display.getCurrent();
+ boolean displayCreated = false;
+ if (Display_1 == null) {
+ Display_1 = Display.getDefault();
+ displayCreated = true;
+ } else {
+ Display_1 = Display.getDefault();
+ }
+
+ Shell Shell_1 = new Shell(Display_1, SWT.SHELL_TRIM);
+ Shell_1.setText("CheckBoxStateTreeViewer Test");
+ Shell_1.setBounds(0, 0, 1000, 500);
+ Shell_1.setLayout(new GridLayout(2, false));
+ Shell_1.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ Composite toolBarComposite = new Composite(Shell_1, SWT.NONE);
+ toolBarComposite.setLayout(new GridLayout(2, false));
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ toolBarComposite.setLayoutData(gd);
+
+ treeViewer = new CheckBoxStateTreeViewer<ExampleTreeNode>(Shell_1, SWT.MULTI | SWT.BORDER);
+ treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ treeViewer.setContentProvider(new ExampleCheckBoxStateTreeContentProvider());
+ treeViewer.setLabelProvider(new CheckBoxStateTreeLabelProvider(treeViewer));
+ treeViewer.addCheckListener(new ICheckBoxStateTreeListener() {
+ @Override
+ public void checkStateChanged(Object obj) {
+ textBox.setText(String.format("State Changed [%s] to [%s]", obj,
+ String.valueOf(treeViewer.isChecked(obj)).toUpperCase()));
+ }
+ });
+
+ textBox = new Text(Shell_1, SWT.BORDER | SWT.WRAP);
+ textBox.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ createTaskActionBar(toolBarComposite);
+
+ List<Object> tasks = new ArrayList<Object>();
+ for (int x = 0; x < 1; x++) {
+ tasks.addAll(getTestTasks(treeViewer));
+ }
+ treeViewer.setInput(tasks);
+ treeViewer.expandAll();
+ Shell_1.open();
+ while (!Shell_1.isDisposed()) {
+ if (!Display_1.readAndDispatch()) {
+ Display_1.sleep();
+ }
+ }
+
+ if (displayCreated) {
+ Display_1.dispose();
+ }
+ }
+
+ public static void createTaskActionBar(Composite parent) {
+
+ Composite actionComp = new Composite(parent, SWT.NONE);
+ actionComp.setLayout(new GridLayout());
+ actionComp.setLayoutData(new GridData(GridData.END));
+
+ ToolBar toolBar = new ToolBar(actionComp, SWT.FLAT | SWT.RIGHT);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ toolBar.setLayoutData(gd);
+
+ ToolItem getChecked = new ToolItem(toolBar, SWT.PUSH);
+ getChecked.setImage(CheckBoxStateImageCache.getImage("report.gif"));
+ getChecked.setToolTipText("Get Checked");
+ getChecked.setText("Checked");
+ getChecked.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ List<ExampleTreeNode> checked = treeViewer.getChecked();
+ openReport("Checked Items", checked);
+ }
+ });
+
+ ToolItem deSelectAll = new ToolItem(toolBar, SWT.PUSH);
+ deSelectAll.setImage(CheckBoxStateImageCache.getImage("chkbox_unchecked.gif"));
+ deSelectAll.setToolTipText("De-Select All");
+ deSelectAll.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ List<Object> tasks = new ArrayList<Object>();
+ for (int x = 0; x < 1; x++) {
+ tasks.addAll(getTestTasks(treeViewer));
+ }
+ treeViewer.deSelectAll();
+ }
+ });
+
+ ToolItem refreshItem = new ToolItem(toolBar, SWT.PUSH);
+ refreshItem.setImage(CheckBoxStateImageCache.getImage("refresh.gif"));
+ refreshItem.setToolTipText("Refresh");
+ refreshItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ List<Object> tasks = new ArrayList<Object>();
+ for (int x = 0; x < 1; x++) {
+ tasks.addAll(getTestTasks(treeViewer));
+ }
+ treeViewer.setInput(tasks);
+ treeViewer.expandAll();
+ }
+ });
+ }
+
+ protected static void openReport(String title, Collection<ExampleTreeNode> items) {
+ StringBuilder sb = new StringBuilder();
+ for (ExampleTreeNode node : items) {
+ sb.append(node.getName() + "\n");
+ }
+ textBox.setText(sb.toString());
+ }
+
+ private static List<ExampleTreeNode> getTestTasks(ICheckBoxStateTreeViewer treeViewer) {
+ List<ExampleTreeNode> tasks = new ArrayList<ExampleTreeNode>();
+ ExampleTreeNode task = new ExampleTreeNode("Trees", null, true, treeViewer);
+ tasks.add(task);
+ for (String str : Arrays.asList("Pine", "Redwood", "Oak")) {
+ new ExampleTreeNode(str + " will run to test this test", task, true, treeViewer);
+ }
+
+ ExampleTreeNode node = new ExampleTreeNode("Rocks", null, false, treeViewer);
+ treeViewer.setEnabled(node, false);
+ tasks.add(node);
+
+ ExampleTreeNode task2 = new ExampleTreeNode("Animals", null, false, treeViewer);
+ tasks.add(task2);
+ for (String str : Arrays.asList("Dog", "Cat", "Squirrel", "Lizard", "Bird")) {
+ new ExampleTreeNode(str + " will run to test this test", task2, !str.contains("Cat"), treeViewer);
+ }
+ return tasks;
+ }
+
+ private static class ExampleCheckBoxStateTreeContentProvider 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<ExampleTreeNode>) inputElement).toArray(new ExampleTreeNode[((List<?>) inputElement).size()]);
+ }
+ if (inputElement instanceof ExampleTreeNode) {
+ return ((ExampleTreeNode) inputElement).getChildren().toArray();
+ }
+ return null;
+ }
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ return ((ExampleTreeNode) parentElement).getChildren().toArray();
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ return ((ExampleTreeNode) element).getParent();
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ return ((ExampleTreeNode) element).getChildren().size() > 0;
+ }
+
+ }
+
+ private static class ExampleTreeNode {
+ private final String name;
+ private final ExampleTreeNode parent;
+ private final List<ExampleTreeNode> children = new ArrayList<>();
+
+ protected ExampleTreeNode(String name, ExampleTreeNode aiNode, boolean enabled, ICheckBoxStateTreeViewer treeViewer) {
+ this.name = name;
+ this.parent = aiNode;
+ if (aiNode != null) {
+ aiNode.addChild(this);
+ }
+ treeViewer.setEnabled(this, enabled);
+ }
+
+ public List<ExampleTreeNode> getChildren() {
+ return children;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public ExampleTreeNode getParent() {
+ return parent;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ public void addChild(ExampleTreeNode child) {
+ children.add(child);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/ICheckBoxStateTreeListener.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/ICheckBoxStateTreeListener.java
new file mode 100644
index 0000000000..37c7c856f4
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/ICheckBoxStateTreeListener.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface ICheckBoxStateTreeListener {
+
+ public default void checkStateChanged(Object obj) {
+ // do nothing
+ }
+
+ public default void checkStateNodesChanged() {
+ // do nothing
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/ICheckBoxStateTreeViewer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/ICheckBoxStateTreeViewer.java
new file mode 100644
index 0000000000..ed7d337b9f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/ICheckBoxStateTreeViewer.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @author Donald G. Dunne
+ */
+public interface ICheckBoxStateTreeViewer {
+
+ boolean isEnabled(Object element);
+
+ boolean isChecked(Object element);
+
+ void setEnabled(Object object, boolean enabled);
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/CheckBoxStateImageCache.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/CheckBoxStateImageCache.java
new file mode 100644
index 0000000000..55f50dde0b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/CheckBoxStateImageCache.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.images;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class CheckBoxStateImageCache {
+
+ static Map<String, Image> imageCache = new HashMap<String, Image>();
+ static Map<String, ImageDescriptor> imageDescriptorCache = new HashMap<String, ImageDescriptor>();
+
+ public static Image getImage(String imageName) {
+ if (!imageCache.containsKey(imageName)) {
+ imageCache.put(imageName, getImageDescriptor(imageName).createImage());
+ }
+ return imageCache.get(imageName);
+ }
+
+ public static ImageDescriptor getImageDescriptor(String imageName) {
+ if (!imageDescriptorCache.containsKey(imageName)) {
+ URL url = CheckBoxStateImageCache.class.getResource(imageName);
+ imageDescriptorCache.put(imageName, ImageDescriptor.createFromURL(url));
+ }
+ return imageDescriptorCache.get(imageName);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_checked.gif b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_checked.gif
new file mode 100644
index 0000000000..9cacb96dca
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_checked.gif
Binary files differ
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_disabled.gif b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_disabled.gif
new file mode 100644
index 0000000000..4f3dcba276
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_disabled.gif
Binary files differ
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_unchecked.gif b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_unchecked.gif
new file mode 100644
index 0000000000..7aa131aedb
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/chkbox_unchecked.gif
Binary files differ
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/refresh.gif b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/refresh.gif
new file mode 100644
index 0000000000..a063c230ac
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/refresh.gif
Binary files differ
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/report.gif b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/report.gif
new file mode 100644
index 0000000000..e6bf9cf178
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/checkbox/images/report.gif
Binary files differ

Back to the top