Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-03-12 13:27:25 -0500
committerrescobar2010-03-12 13:27:25 -0500
commit205aa057fa925d37a3a5375aa8418b9567e99c6d (patch)
treed33f80b9f727c479b8031aeb352494c38ad9878d /plugins/org.eclipse.osee.ote.ui.host.cmd
parent0e6d2b595cfb4d54eccdf3479e7c5d74d9c736a5 (diff)
downloadorg.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.tar.gz
org.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.tar.xz
org.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.zip
Diffstat (limited to 'plugins/org.eclipse.osee.ote.ui.host.cmd')
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/.classpath7
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/.project28
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/META-INF/MANIFEST.MF22
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/build.properties6
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/images/console.gifbin0 -> 582 bytes
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/images/test_server.gifbin0 -> 605 bytes
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/images/user.gifbin0 -> 542 bytes
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/plugin.xml12
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/CategoryNode.java27
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/ConsoleNode.java51
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/EnvironmentViewer.java285
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/OteUiHostCmdImage.java33
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TestServerConsoleServiceRenderer.java202
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TreeBuilder.java38
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/UiPlugin.java29
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/UserNode.java27
16 files changed, 767 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/.classpath b/plugins/org.eclipse.osee.ote.ui.host.cmd/.classpath
new file mode 100644
index 0000000000..64ed6b3795
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/.project b/plugins/org.eclipse.osee.ote.ui.host.cmd/.project
new file mode 100644
index 0000000000..0093ca2301
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.ote.ui.host.cmd</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.ui.host.cmd/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..224701f4c5
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OTE UI Host Cmd Plugin (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.ote.ui.host.cmd;singleton:=true
+Bundle-Version: 0.9.2.qualifier
+Bundle-Activator: org.eclipse.osee.ote.ui.host.cmd.UiPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.osee.framework.jdk.core,
+ org.eclipse.osee.ote.core,
+ org.eclipse.osee.framework.jini,
+ net.jini,
+ org.eclipse.osee.framework.ui.service.control,
+ org.eclipse.osee.framework.plugin.core,
+ org.eclipse.osee.framework.ui.plugin,
+ org.eclipse.osee.framework.ui.swt,
+ org.eclipse.osgi,
+ org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: Eclipse.org
+Export-Package: org.eclipse.osee.ote.ui.host.cmd
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.eclipse.osee.framework.logging
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/build.properties b/plugins/org.eclipse.osee.ote.ui.host.cmd/build.properties
new file mode 100644
index 0000000000..8a33b335c3
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ images/
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/images/console.gif b/plugins/org.eclipse.osee.ote.ui.host.cmd/images/console.gif
new file mode 100644
index 0000000000..a598f6082f
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/images/console.gif
Binary files differ
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/images/test_server.gif b/plugins/org.eclipse.osee.ote.ui.host.cmd/images/test_server.gif
new file mode 100644
index 0000000000..c52ee5689b
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/images/test_server.gif
Binary files differ
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/images/user.gif b/plugins/org.eclipse.osee.ote.ui.host.cmd/images/user.gif
new file mode 100644
index 0000000000..5e6e549598
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/images/user.gif
Binary files differ
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/plugin.xml b/plugins/org.eclipse.osee.ote.ui.host.cmd/plugin.xml
new file mode 100644
index 0000000000..bcbfbda304
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/plugin.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension
+ point="org.eclipse.osee.framework.ui.service.control.ServiceView">
+ <ServiceHandler
+ ServiceIcon="images/test_server.gif"
+ ServiceInterface="org.eclipse.osee.ote.core.environment.interfaces.IHostTestEnvironment"
+ ServiceRenderer="org.eclipse.osee.ote.ui.host.cmd.TestServerConsoleServiceRenderer"/>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/CategoryNode.java b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/CategoryNode.java
new file mode 100644
index 0000000000..7ab4275065
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/CategoryNode.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.ote.ui.host.cmd;
+
+import org.eclipse.osee.framework.jdk.core.type.TreeParent;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class CategoryNode extends TreeParent {
+
+ /**
+ * @param name
+ */
+ public CategoryNode(String name) {
+ super(name);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/ConsoleNode.java b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/ConsoleNode.java
new file mode 100644
index 0000000000..f03b4cf389
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/ConsoleNode.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.ote.ui.host.cmd;
+
+import org.eclipse.osee.framework.jdk.core.type.TreeObject;
+import org.eclipse.osee.ote.core.OSEEPerson1_4;
+import org.eclipse.osee.ote.core.environment.interfaces.IRemoteCommandConsole;
+
+
+/**
+ * @author Ken J. Aguilar
+ */
+public class ConsoleNode extends TreeObject {
+
+ private final IRemoteCommandConsole console;
+ private String users;
+
+ public ConsoleNode(IRemoteCommandConsole console, OSEEPerson1_4[] users) {
+ super("Console");
+ this.console = console;
+ if (users.length > 1) {
+ StringBuilder sb = new StringBuilder(128);
+ sb.append(users[0].getName());
+ sb.append(", ");
+ for (int i = 1; i < users.length - 1; i++) {
+ sb.append(users[i].getName());
+ sb.append(", ");
+ }
+ sb.append(users[users.length -1]);
+ this.users = sb.toString();
+ } else {
+ this.users = users.length == 0 ? "<none>" : users[0].getName();
+ }
+ }
+
+ public IRemoteCommandConsole getConsole() {
+ return console;
+ }
+
+ public String getUsers() {
+ return users;
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/EnvironmentViewer.java b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/EnvironmentViewer.java
new file mode 100644
index 0000000000..8ce5297ecd
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/EnvironmentViewer.java
@@ -0,0 +1,285 @@
+/*******************************************************************************
+ * 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.ote.ui.host.cmd;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ITreeViewerListener;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeExpansionEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.osee.framework.jdk.core.type.TreeObject;
+import org.eclipse.osee.framework.jdk.core.type.TreeParent;
+import org.eclipse.osee.framework.ui.swt.ImageManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+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.TreeColumn;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class EnvironmentViewer extends Composite {
+
+ private static final Image ENVIRONMENT_IMAGE =
+ PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+
+ private static final Image USER_IMAGE = ImageManager.getImage(OteUiHostCmdImage.USER);
+
+ private static final Image CONSOLE_IMAGE = ImageManager.getImage(OteUiHostCmdImage.CONSOLE);
+
+ protected enum ColumnEnum {
+ Service(SWT.LEFT),
+ Users;
+
+ private int alignment;
+
+ private ColumnEnum() {
+ this.alignment = SWT.CENTER;
+ }
+
+ private ColumnEnum(int alignment) {
+ this.alignment = alignment;
+ }
+
+ public int getAlignment() {
+ return alignment;
+ }
+
+ public static String[] toArray() {
+ ColumnEnum[] enumArray = ColumnEnum.values();
+ String[] toReturn = new String[enumArray.length];
+ for (int index = 0; index < enumArray.length; index++) {
+ toReturn[index] = enumArray[index].toString();
+ }
+ return toReturn;
+ }
+ }
+
+ private TreeViewer viewer;
+
+ public EnvironmentViewer(Composite parent, int style) {
+ super(parent, style);
+ createControl();
+ }
+
+ public void createControl() {
+ this.setLayout(new GridLayout());
+ this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ createTreeArea(this);
+ createColumns();
+ attachListeners();
+ packColumnData();
+ }
+
+ private void createTreeArea(Composite parent) {
+ viewer = new TreeViewer(parent, SWT.SINGLE | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ (viewer).getTree().setHeaderVisible(true);
+ (viewer).getTree().setLinesVisible(true);
+ viewer.setUseHashlookup(true);
+ viewer.setColumnProperties(ColumnEnum.toArray());
+ viewer.setContentProvider(new TreeContentProvider());
+ viewer.setLabelProvider(new TreeLabelProvider());
+ viewer.setSorter(new ViewerSorter());
+ viewer.setInput(new ArrayList<String>());
+ viewer.getControl().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+ }
+
+ private void createColumns() {
+ for (ColumnEnum columnEnum : ColumnEnum.values()) {
+ TreeColumn column = new TreeColumn(viewer.getTree(), SWT.CENTER, columnEnum.ordinal());
+ column.setText(columnEnum.toString());
+ column.setWidth(columnEnum.toString().length());
+ column.setAlignment(columnEnum.getAlignment());
+ }
+ }
+
+ public void packColumnData() {
+ TreeColumn[] columns = viewer.getTree().getColumns();
+ for (TreeColumn column : columns) {
+ column.pack();
+ }
+ }
+
+ private void attachListeners() {
+ viewer.addTreeListener(new ITreeViewerListener() {
+
+ public void treeCollapsed(TreeExpansionEvent event) {
+ packColumnData();
+ }
+
+ public void treeExpanded(TreeExpansionEvent event) {
+ packColumnData();
+ }
+
+ });
+ }
+
+ private class TreeLabelProvider implements ITableLabelProvider, ILabelProvider {
+
+ public Image getImage(Object obj) {
+ Image toReturn = null;
+ if (obj instanceof UserNode) {
+ toReturn = USER_IMAGE;
+ } else if (obj instanceof ConsoleNode) {
+ toReturn = CONSOLE_IMAGE;
+ } else if (obj instanceof TreeParent) {
+ toReturn = ENVIRONMENT_IMAGE;
+ }
+ return toReturn;
+ }
+
+ public String getText(Object obj) {
+ if (obj instanceof ConsoleNode) {
+ ((ConsoleNode) obj).getName();
+ }
+ return obj.toString();
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ Image toReturn = null;
+ ColumnEnum column = ColumnEnum.values()[columnIndex];
+ switch (column) {
+ case Service:
+ if (element instanceof UserNode) {
+ toReturn = USER_IMAGE;
+ } else if (element instanceof ConsoleNode) {
+ toReturn = CONSOLE_IMAGE;
+ } else if (element instanceof TreeParent) {
+ toReturn = ENVIRONMENT_IMAGE;
+ }
+ break;
+ default:
+ break;
+ }
+ return toReturn;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ String toReturn = null;
+ ColumnEnum column = ColumnEnum.values()[columnIndex];
+ switch (column) {
+ case Service:
+ if (element instanceof ConsoleNode) {
+ toReturn = ((ConsoleNode) element).getName();
+ } else if (element instanceof TreeParent) {
+ toReturn = element.toString();
+ }
+ break;
+ case Users:
+ if (element instanceof ConsoleNode) {
+ toReturn = ((ConsoleNode) element).getUsers();
+ }
+ break;
+ default:
+ break;
+ }
+ return toReturn;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+ }
+
+ private class TreeContentProvider implements ITreeContentProvider {
+
+ public void dispose() {
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement != null && parentElement instanceof TreeParent) {
+ TreeParent parent = (TreeParent) parentElement;
+ if (parent.hasChildren()) {
+ return parent.getChildren();
+ }
+ }
+ return new Object[0];
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement != null && inputElement instanceof Collection) {
+ Collection<?> elementArray = (Collection<?>) inputElement;
+ return elementArray.toArray();
+ }
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ if (element != null && element instanceof TreeObject) {
+ TreeObject child = (TreeObject) element;
+ return child.getParent();
+ }
+ return new Object();
+ }
+
+ public boolean hasChildren(Object element) {
+ if (element instanceof TreeParent) {
+ TreeParent parent = (TreeParent) element;
+ return parent.hasChildren();
+ }
+ return false;
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ @Override
+ public boolean setFocus() {
+ return this.viewer.getControl().setFocus();
+ }
+
+ public StructuredViewer getViewer() {
+ return viewer;
+ }
+
+ public void setInput(List<TreeParent> input) {
+ viewer.setInput(input);
+ }
+
+ public void refresh() {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ packColumnData();
+ viewer.refresh();
+ }
+ });
+ }
+
+ @Override
+ public void dispose() {
+ viewer.getControl().dispose();
+ super.dispose();
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/OteUiHostCmdImage.java b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/OteUiHostCmdImage.java
new file mode 100644
index 0000000000..2f2bede375
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/OteUiHostCmdImage.java
@@ -0,0 +1,33 @@
+/*
+ * Created on Jul 24, 2009
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.ui.host.cmd;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osee.framework.ui.swt.ImageManager;
+import org.eclipse.osee.framework.ui.swt.KeyedImage;
+
+public enum OteUiHostCmdImage implements KeyedImage {
+ CONSOLE("console.gif"),
+ TEST_SERVER("test_server.gif"),
+ USER("user.gif");
+
+ private final String fileName;
+
+ private OteUiHostCmdImage(String fileName) {
+ this.fileName = fileName;
+ }
+
+ @Override
+ public ImageDescriptor createImageDescriptor() {
+ return ImageManager.createImageDescriptor(UiPlugin.PLUGIN_ID, "images", fileName);
+ }
+
+ @Override
+ public String getImageKey() {
+ return UiPlugin.PLUGIN_ID + ".images." + fileName;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TestServerConsoleServiceRenderer.java b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TestServerConsoleServiceRenderer.java
new file mode 100644
index 0000000000..96dcab31f9
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TestServerConsoleServiceRenderer.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * 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.ote.ui.host.cmd;
+
+import java.util.Hashtable;
+import java.util.logging.Level;
+import net.jini.core.lookup.ServiceItem;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osee.framework.jdk.core.type.InputManager;
+import org.eclipse.osee.framework.jdk.core.type.TreeParent;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.service.control.renderer.IServiceRenderer;
+import org.eclipse.osee.framework.ui.swt.Widgets;
+import org.eclipse.osee.ote.core.environment.interfaces.IHostTestEnvironment;
+import org.eclipse.osee.ote.core.environment.interfaces.IRemoteCommandConsole;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TraverseEvent;
+import org.eclipse.swt.events.TraverseListener;
+import org.eclipse.swt.graphics.Font;
+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.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Created on Oct 9, 2006
+ */
+public class TestServerConsoleServiceRenderer implements IServiceRenderer {
+ private IHostTestEnvironment testService;
+ private Group composite;
+ private Hashtable<ITestEnvironment, IRemoteCommandConsole> consoles;
+ private volatile IRemoteCommandConsole selectedConsole;
+ private Text outputTxt;
+ private Text inputTxt;
+ private Button sendCmdBtn;
+ private EnvironmentViewer envViewer;
+ private InputManager<TreeParent> inputManager;
+
+ public TestServerConsoleServiceRenderer() {
+ this.consoles = new Hashtable<ITestEnvironment, IRemoteCommandConsole>(24);
+ this.selectedConsole = null;
+ this.inputManager = new InputManager<TreeParent>();
+ }
+
+ public void refresh() {
+ Display.getCurrent().asyncExec(new Runnable() {
+
+ public void run() {
+ if (composite != null && !composite.isDisposed() && testService != null) {
+ cleanupService();
+ try {
+ ITestEnvironment[] envs = testService.getRemoteEnvironments();
+ consoles.clear();
+ if (envs.length > 0) {
+ for (ITestEnvironment env : envs) {
+ consoles.put(env, env.getCommandConsole());
+ }
+ selectedConsole = consoles.get(envs[0]);
+ } else {
+ selectedConsole = null;
+ }
+
+ envViewer.setInput(inputManager.getInputList());
+ TreeBuilder.buildTree(inputManager, testService, consoles);
+ envViewer.refresh();
+
+ } catch (Throwable t) {
+ OseeLog.log(UiPlugin.class, Level.SEVERE, "exception getting hosts", t);
+ }
+ }
+ }
+ });
+ }
+
+ public void setService(ServiceItem serviceItem) {
+ OseeLog.log(UiPlugin.class, Level.INFO, "setting test environment service");
+ testService = (IHostTestEnvironment) serviceItem.service;
+ if (outputTxt != null && !outputTxt.isDisposed()) {
+ outputTxt.setText("");
+ }
+ }
+
+ public void disconnect() {
+ consoles.clear();
+ }
+
+ public void dispose() {
+ cleanupService();
+ Widgets.disposeWidgets(composite, outputTxt, inputTxt, sendCmdBtn);
+ }
+
+ public Control renderInComposite(Composite parent) {
+ composite = new Group(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ composite.setText("Test Server Console");
+
+ SashForm sashForm = new SashForm(composite, SWT.NONE);
+ sashForm.setLayout(new GridLayout());
+ sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ sashForm.setOrientation(SWT.VERTICAL);
+ sashForm.SASH_WIDTH = 3;
+
+ envViewer = new EnvironmentViewer(sashForm, SWT.NONE);
+ envViewer.getViewer().addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();
+ if (element != null && element instanceof ConsoleNode) {
+ selectedConsole = ((ConsoleNode) element).getConsole();
+ outputTxt.setText("");
+ }
+ }
+
+ });
+ createConsoleArea(sashForm);
+
+ sashForm.setWeights(new int[] {3, 7});
+ return composite;
+ }
+
+ private void createConsoleArea(Composite parent) {
+ Group composite = new Group(parent, SWT.NONE);
+ Widgets.setFormLayout(composite, 5, 5);
+ composite.setText("Interact");
+
+ outputTxt =
+ Widgets.createTxt(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY | SWT.BORDER, "");
+ outputTxt.setTabs(4);
+ outputTxt.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ outputTxt.setForeground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_GREEN));
+ outputTxt.setFont(new Font(Display.getDefault(), "Courier", 10, SWT.NORMAL));
+ Widgets.attachToParent(outputTxt, SWT.TOP, 0, 5);
+ Widgets.attachToParent(outputTxt, SWT.BOTTOM, 75, 0);
+ Widgets.attachToParent(outputTxt, SWT.LEFT, 0, 5);
+ Widgets.attachToParent(outputTxt, SWT.RIGHT, 100, -5);
+
+ inputTxt = Widgets.createTxt(composite, SWT.SINGLE | SWT.BORDER, "");
+ inputTxt.addTraverseListener(new TraverseListener() {
+
+ public void keyTraversed(TraverseEvent event) {
+ if (event.detail == SWT.TRAVERSE_RETURN) {
+ sendCmd(inputTxt.getText());
+ }
+ }
+
+ });
+ Widgets.attachToControl(inputTxt, outputTxt, SWT.LEFT, SWT.LEFT, 0);
+ sendCmdBtn = Widgets.createBtn(composite, SWT.PUSH, "Execute");
+ sendCmdBtn.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ sendCmd(inputTxt.getText());
+ }
+
+ });
+ Widgets.attachToControl(sendCmdBtn, outputTxt, SWT.TOP, SWT.BOTTOM, 5);
+ Widgets.attachToControl(sendCmdBtn, outputTxt, SWT.RIGHT, SWT.RIGHT, 0);
+ Widgets.attachToControl(inputTxt, sendCmdBtn, SWT.RIGHT, SWT.LEFT, -5);
+ Widgets.attachToControl(inputTxt, sendCmdBtn, SWT.TOP, SWT.CENTER, 0);
+ }
+
+ private void sendCmd(String cmd) {
+ try {
+ if (selectedConsole != null) {
+ outputTxt.append(selectedConsole.doCommand(cmd));
+ inputTxt.setText("");
+ } else {
+ outputTxt.append("No Consoles Available\n");
+ }
+ } catch (Throwable t) {
+ OseeLog.log(UiPlugin.class, Level.SEVERE, "Exception trying to execute test service console command " + cmd, t);
+ outputTxt.append("Exception ocurred when executing command\n");
+
+ }
+ }
+
+ private void cleanupService() {
+ consoles.clear();
+ inputManager.removeAll();
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TreeBuilder.java b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TreeBuilder.java
new file mode 100644
index 0000000000..77bb76c078
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TreeBuilder.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.ote.ui.host.cmd;
+
+import java.util.Collection;
+import java.util.Map;
+import org.eclipse.osee.framework.jdk.core.type.InputManager;
+import org.eclipse.osee.framework.jdk.core.type.TreeParent;
+import org.eclipse.osee.ote.core.OSEEPerson1_4;
+import org.eclipse.osee.ote.core.environment.interfaces.IHostTestEnvironment;
+import org.eclipse.osee.ote.core.environment.interfaces.IRemoteCommandConsole;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TreeBuilder {
+
+ public static void buildTree(InputManager<TreeParent> inputManager, IHostTestEnvironment host, Map<ITestEnvironment, IRemoteCommandConsole> consoles) throws Exception {
+
+ TreeParent treeParent = new TreeParent("Test Service");
+ CategoryNode categoryNode = new CategoryNode("Consoles");
+ treeParent.addChild(categoryNode);
+ for (ITestEnvironment env : host.getRemoteEnvironments()) {
+ Collection<OSEEPerson1_4> users = env.getUserList();
+ categoryNode.addChild(new ConsoleNode(consoles.get(env), users.toArray(new OSEEPerson1_4[users.size()])));
+ }
+ inputManager.addNode(treeParent);
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/UiPlugin.java b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/UiPlugin.java
new file mode 100644
index 0000000000..cf6fa53d79
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/UiPlugin.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.ote.ui.host.cmd;
+
+import org.eclipse.osee.framework.ui.plugin.OseeUiActivator;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class UiPlugin extends OseeUiActivator {
+ public static final String PLUGIN_ID = "org.eclipse.osee.ote.ui.host.cmd";
+ private static UiPlugin plugin;
+
+ public UiPlugin() {
+ plugin = this;
+ }
+
+ public static UiPlugin getInstance() {
+ return plugin;
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/UserNode.java b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/UserNode.java
new file mode 100644
index 0000000000..4583010b6e
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/UserNode.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.ote.ui.host.cmd;
+
+import org.eclipse.osee.framework.jdk.core.type.TreeObject;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class UserNode extends TreeObject {
+
+ /**
+ * @param name
+ */
+ public UserNode(String name) {
+ super(name);
+ }
+
+}

Back to the top