Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.osee.ote.ui/src/org')
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/IOteConsoleService.java34
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsole.java78
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsoleWrapper.java270
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteImage.java41
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteRemoteConsole.java83
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/ProjectNatureTest.java50
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/RemoteConsoleLauncher.java55
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/TestPerspective.java77
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsolePageParticipant.java90
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleServiceImpl.java72
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteServerConsole.java86
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/TestCoreGuiPlugin.java171
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePreferences.java43
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePrefsUtil.java58
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizPage.java177
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizard.java48
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateView.java126
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateViewItems.java100
-rw-r--r--org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateViewerSorter.java34
19 files changed, 1693 insertions, 0 deletions
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/IOteConsoleService.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/IOteConsoleService.java
new file mode 100644
index 000000000..457e13725
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/IOteConsoleService.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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;
+
+import java.io.IOException;
+import org.eclipse.osee.framework.jdk.core.util.IConsoleInputListener;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IOteConsoleService {
+
+ void addInputListener(IConsoleInputListener listener);
+
+ void removeInputListener(IConsoleInputListener listener);
+
+ void write(String value);
+
+ void write(String value, int type, boolean popup);
+
+ void writeError(String string);
+
+ void prompt(String str) throws IOException;
+
+ void popup();
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsole.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsole.java
new file mode 100644
index 000000000..29d11135e
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsole.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osee.ote.ui.internal.prefs.OteConsolePreferences;
+import org.eclipse.osee.ote.ui.internal.prefs.OteConsolePrefsUtil;
+import org.eclipse.ui.console.IOConsole;
+
+/**
+ * This class provides a way to set the high and low water marks of the console to limit the output buffer.
+ * @author Michael P. Masterson
+ */
+public class OteConsole extends IOConsole {
+ /**
+ * Arbitrary number is arbitrary.
+ */
+ private static final int HIGH_TO_LOW_DIFF = 100;
+
+ private int limit;
+ private boolean noLimit;
+
+ /**
+ * @param name
+ * @param consoleType
+ * @param imageDescriptor
+ */
+ public OteConsole(String name, ImageDescriptor imageDescriptor) {
+ super(name, imageDescriptor);
+ limit = OteConsolePrefsUtil.getInt(OteConsolePreferences.BUFFER_LIMIT);
+ noLimit = OteConsolePrefsUtil.getBoolean(OteConsolePreferences.NO_BUFFER_LIMIT);
+ setWaterMarks();
+ }
+
+ /**
+ * When the limit is too small (less than {@value #HIGH_TO_LOW_DIFF}), the low and high mark will be right next to eachother
+ * meaning that characters will be deleted from the beginning at the same speed as they are being written
+ * to the end. Otherwise, every time the limit is hit, the buffer will shrink by {@value #HIGH_TO_LOW_DIFF}.
+ */
+ private void setWaterMarks() {
+ int lowMark, highMark;
+
+ if(noLimit) {
+ lowMark = -1;
+ highMark = -1;
+ } else if( limit > HIGH_TO_LOW_DIFF ){
+ lowMark = limit - HIGH_TO_LOW_DIFF;
+ highMark = limit;
+ } else {
+ lowMark = limit -1;
+ highMark = limit;
+ }
+
+ setWaterMarks(lowMark, highMark);
+ }
+
+ /**
+ * @param limit the buffer size limit in bytes
+ */
+ public void setLimit(int limit) {
+ this.limit = limit;
+ setWaterMarks();
+ }
+
+ public void setNoLimit(boolean noLimit) {
+ this.noLimit = noLimit;
+ setWaterMarks();
+ }
+
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsoleWrapper.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsoleWrapper.java
new file mode 100644
index 000000000..067b1a328
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsoleWrapper.java
@@ -0,0 +1,270 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.logging.Level;
+
+import org.eclipse.osee.framework.jdk.core.util.IConsoleInputListener;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
+import org.eclipse.osee.ote.ui.internal.TestCoreGuiPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IOConsole;
+import org.eclipse.ui.console.IOConsoleOutputStream;
+
+/**
+ * This class is needed to get the OTE specific OTE Console class which will provide the ability to set the buffer limit of the console
+ * @author Michael P. Masterson
+ */
+public class OteConsoleWrapper {
+ private IOConsoleOutputStream streamOut = null;
+
+ private IOConsoleOutputStream streamErr = null;
+
+ private IOConsoleOutputStream streamPrompt = null;
+
+ private final IOConsole console;
+
+ private final HandleInput inputHandler;
+
+ private final boolean time;
+
+ private final Thread thread;
+
+ private boolean newline;
+
+ public OteConsoleWrapper(String title) {
+ this(title, true, true);
+ }
+
+ public OteConsoleWrapper(String title, boolean time, boolean newline) {
+ console = createConsole(title);
+ this.time = time;
+ this.newline = newline;
+ this.inputHandler = new HandleInput();
+
+ thread = new Thread(inputHandler);
+ thread.setName("Osee console input handler");
+ ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {console});
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ streamOut = console.newOutputStream();// newMessageStream();
+ streamOut.setColor(Displays.getSystemColor(SWT.COLOR_BLACK));
+ streamOut.setActivateOnWrite(false);
+ streamErr = console.newOutputStream();
+ streamErr.setColor(Displays.getSystemColor(SWT.COLOR_RED));
+ streamErr.setActivateOnWrite(false);
+ streamPrompt = console.newOutputStream();
+ streamPrompt.setColor(Displays.getSystemColor(SWT.COLOR_BLUE));
+ streamPrompt.setActivateOnWrite(false);
+ }
+ });
+ thread.start();
+ }
+
+ /**
+ * @param low
+ * @param high
+ * @see org.eclipse.ui.console.IOConsole#setWaterMarks(int, int)
+ */
+ public void setWaterMarks(int low, int high) {
+ this.console.setWaterMarks(low, high);
+ }
+
+ /**
+ * This should only be called once in the constructor. This method may be overridden by subclasses if a different
+ * instance of an IOConsole is required.
+ * @param title
+ * @return a new IOConsole with the title provided
+ */
+ protected IOConsole createConsole(String title) {
+ return new OteConsole(title, null);
+ }
+
+ public PrintStream getPrintStream() {
+ return new PrintStream(streamOut);
+ }
+
+ public void shutdown() {
+ thread.interrupt();
+ try {
+ thread.join(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[] {console});
+ }
+ }
+
+ public static final int CONSOLE_ERROR = 0;
+
+ public static final int CONSOLE_OUT = 1;
+
+ public static final int CONSOLE_PROMPT = 2;
+
+ /**
+ * Writes string to console without popping console forward
+ * @param str
+ */
+ public void write(String str) {
+ write(str, false);
+ }
+
+ /**
+ * Writes string to console without popping console forward
+ * @param str
+ */
+ public void writeError(String str) {
+ write(str, CONSOLE_ERROR, true);
+ }
+
+ /**
+ * Writes string to console
+ * @param str
+ *
+ * @param popup bring console window forward
+ */
+ public void write(String str, boolean popup) {
+ write(str, CONSOLE_OUT, popup);
+ }
+
+ /**
+ * Write string to console
+ * @param str
+ *
+ * @param type CONSOLE_ERROR, CONSOLE_OUT, CONSOLE_PROMPT
+ */
+ public void write(String str, int type) {
+ write(str, type, false);
+ }
+
+ /**
+ * Write string to console
+ * @param str
+ *
+ * @param type CONSOLE_ERROR, CONSOLE_OUT, CONSOLE_PROMPT
+ * @param popup bring console window forward
+ */
+ public void write(String str, int type, boolean popup) {
+ String time = "";
+ if (this.time) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(new Date());
+
+ if (cal.get(Calendar.HOUR) == 0) {
+ time = "12";
+ } else {
+ time = "" + cal.get(Calendar.HOUR);
+ }
+ time = Lib.padLeading(time, '0', 2);
+ String minute = "" + cal.get(Calendar.MINUTE);
+ minute = Lib.padLeading(minute, '0', 2);
+ time += ":" + minute + " => ";
+ }
+ try {
+ sendToStreams(type, time);
+ if (str.length() > 100000) {
+ int i = 0;
+
+ while (i < str.length()) {
+ int endIndex = i + 100000;
+ endIndex = endIndex > str.length() ? str.length() : endIndex;
+ String chunk = str.substring(i, endIndex);
+ sendToStreams(type, chunk);
+ i = endIndex;
+ }
+ } else {
+ sendToStreams(type, str);
+ }
+ if(newline ){
+ sendToStreams(type, "\n");
+ }
+ if (popup) {
+ popup();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void prompt(String str) throws IOException {
+ sendToStreams(CONSOLE_PROMPT, str);
+ }
+
+ private void sendToStreams(int type, String str) throws IOException {
+ if (type == CONSOLE_ERROR && streamErr != null) {
+ streamErr.write(str);
+ }
+ if (type == CONSOLE_PROMPT && streamPrompt != null) {
+ streamPrompt.write(str);
+ }
+ if (type == CONSOLE_OUT && streamOut != null) {
+ streamOut.write(str);
+ }
+ }
+
+ public void popup() {
+ ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
+ }
+
+ public void addInputListener(IConsoleInputListener listener) {
+ inputHandler.addListener(listener);
+ }
+
+ public void removeInputListener(IConsoleInputListener listener) {
+ inputHandler.removeListener(listener);
+ }
+
+ private class HandleInput implements Runnable {
+
+ private final CopyOnWriteArrayList<IConsoleInputListener> listeners;
+
+ public HandleInput() {
+ listeners = new CopyOnWriteArrayList<>();
+ }
+
+ public void addListener(IConsoleInputListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeListener(IConsoleInputListener listener) {
+ listeners.remove(listener);
+ }
+
+ @Override
+ public void run() {
+ BufferedReader input = new BufferedReader(new InputStreamReader(console.getInputStream()));
+ try {
+ String line = null;
+ while ((line = input.readLine()) != null) {
+ for (IConsoleInputListener listener : listeners) {
+ listener.lineRead(line);
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ OseeLog.log(TestCoreGuiPlugin.class, Level.INFO, "done with the handling of input");
+ }
+
+ }
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteImage.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteImage.java
new file mode 100644
index 000000000..0839ac7ae
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteImage.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osee.framework.ui.swt.ImageManager;
+import org.eclipse.osee.framework.ui.swt.KeyedImage;
+import org.eclipse.osee.ote.ui.internal.TestCoreGuiPlugin;
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public enum OteImage implements KeyedImage {
+ CHECKOUT("checkout.gif"),
+ CONNECTED("connected_sm.gif"),
+ OTE("welcome_item3.gif");
+
+ private final String fileName;
+
+ private OteImage(String fileName) {
+ this.fileName = fileName;
+ }
+
+ @Override
+ public ImageDescriptor createImageDescriptor() {
+ return ImageManager.createImageDescriptor(TestCoreGuiPlugin.PLUGIN_ID, "images", fileName);
+ }
+
+ @Override
+ public String getImageKey() {
+ return TestCoreGuiPlugin.PLUGIN_ID + ".images." + fileName;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteRemoteConsole.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteRemoteConsole.java
new file mode 100644
index 000000000..4dfeafe5f
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteRemoteConsole.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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;
+
+import java.rmi.RemoteException;
+import java.util.logging.Level;
+
+import org.eclipse.osee.connection.service.IServiceConnector;
+import org.eclipse.osee.framework.jdk.core.util.IConsoleInputListener;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.ote.core.environment.interfaces.IRemoteCommandConsole;
+import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment;
+import org.eclipse.osee.ote.service.ConnectionEvent;
+import org.eclipse.osee.ote.service.ITestConnectionListener;
+import org.eclipse.osee.ote.ui.internal.TestCoreGuiPlugin;
+
+public class OteRemoteConsole implements IConsoleInputListener, ITestConnectionListener {
+
+ private IRemoteCommandConsole remoteConsole;
+ private ITestEnvironment env;
+ private final IOteConsoleService oteConsoleService;
+
+ public OteRemoteConsole(IOteConsoleService oteConsoleService) {
+ this.oteConsoleService = oteConsoleService;
+ }
+
+ @Override
+ public void lineRead(String line) {
+ try {
+ String result = remoteConsole.doCommand(line);
+ oteConsoleService.write(result);
+ } catch (RemoteException e) {
+ OseeLog.log(TestCoreGuiPlugin.class, Level.SEVERE, "exception executing command " + line, e);
+ oteConsoleService.writeError("Exception during executing of command. See Error Log");
+ }
+ }
+
+ public void close() {
+ if (env != null) {
+ try {
+ env.closeCommandConsole(remoteConsole);
+ } catch (Exception e) {
+ OseeLog.log(TestCoreGuiPlugin.class, Level.INFO, "failed to close remote terminal", e);
+ }
+ }
+
+ oteConsoleService.removeInputListener(this);
+
+ env = null;
+ }
+
+ @Override
+ public void onConnectionLost(IServiceConnector connector) {
+ oteConsoleService.removeInputListener(this);
+
+ env = null;
+ }
+
+ @Override
+ public void onPostConnect(ConnectionEvent event) {
+ try {
+ env = event.getEnvironment();
+ remoteConsole = env.getCommandConsole();
+ oteConsoleService.addInputListener(this);
+ } catch (RemoteException e) {
+ OseeLog.log(TestCoreGuiPlugin.class, Level.SEVERE, "exception acquiring remote console", e);
+ }
+ }
+
+ @Override
+ public void onPreDisconnect(ConnectionEvent event) {
+ close();
+ }
+
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/ProjectNatureTest.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/ProjectNatureTest.java
new file mode 100644
index 000000000..1b59976f2
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/ProjectNatureTest.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+
+public class ProjectNatureTest implements IProjectNature {
+
+ public static final String TEST_NATURE = "org.eclipse.osee.ote.ui.testnature";
+
+ private static List<IProject> testProjects = new ArrayList<>();
+
+ private IProject project;
+
+ @Override
+ public void configure() throws CoreException {
+ testProjects.add(project);
+ }
+
+ @Override
+ public void deconfigure() throws CoreException {
+ testProjects.remove(project);
+ }
+
+ @Override
+ public IProject getProject() {
+ return project;
+ }
+
+ @Override
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ public static List<IProject> getTestProjects() {
+ return testProjects;
+ }
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/RemoteConsoleLauncher.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/RemoteConsoleLauncher.java
new file mode 100644
index 000000000..bb69e50c2
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/RemoteConsoleLauncher.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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;
+
+import org.eclipse.osee.ote.service.IOteClientService;
+import org.eclipse.osee.ote.ui.internal.TestCoreGuiPlugin;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class RemoteConsoleLauncher extends ServiceTracker {
+
+ private OteRemoteConsole remoteConsole;
+
+ private final IOteConsoleService oteConsoleService;
+
+ public RemoteConsoleLauncher(IOteConsoleService oteConsoleService) {
+ super(TestCoreGuiPlugin.getContext(), IOteClientService.class.getName(), null);
+ this.oteConsoleService = oteConsoleService;
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference) {
+ IOteClientService clientService = (IOteClientService) super.addingService(reference);
+ remoteConsole = new OteRemoteConsole(oteConsoleService);
+ clientService.addConnectionListener(remoteConsole);
+ return clientService;
+ }
+
+ @Override
+ public void close() {
+ if (remoteConsole != null) {
+ IOteClientService service = (IOteClientService) getService();
+ service.removeConnectionListener(remoteConsole);
+ remoteConsole.close();
+ }
+ super.close();
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service) {
+ if (remoteConsole != null) {
+ remoteConsole.close();
+ remoteConsole = null;
+ }
+ super.removedService(reference, service);
+ }
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/TestPerspective.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/TestPerspective.java
new file mode 100644
index 000000000..62263829c
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/TestPerspective.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.osee.ote.ui.navigate.OteNavigateView;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+public class TestPerspective implements IPerspectiveFactory {
+
+ public TestPerspective() {
+ super();
+ }
+
+ @Override
+ public void createInitialLayout(IPageLayout layout) {
+ defineActions(layout);
+ defineLayout(layout);
+ }
+
+ public void defineActions(IPageLayout layout) {
+
+ // Add "show views".
+ // layout.addShowViewShortcut("org.eclipse.osee.framework.ui.service.control.view.ServiceManagerView");
+ layout.addShowViewShortcut(OteNavigateView.VIEW_ID);
+ // layout.addShowViewShortcut(EgiView.VIEW_ID);
+ // layout.addShowViewShortcut(EufdView.VIEW_ID);
+ // layout.addShowViewShortcut(GunView.VIEW_ID);
+ // layout.addShowViewShortcut(IhdssView.VIEW_ID);
+ // layout.addShowViewShortcut(KeyboardView.VIEW_ID);
+ // layout.addShowViewShortcut(LmpView.VIEW_ID);
+ // layout.addShowViewShortcut(MpdView.VIEW_ID);
+ // layout.addShowViewShortcut(MtadsView.VIEW_ID);
+ // layout.addShowViewShortcut(RocketView.VIEW_ID);
+ // layout.addShowViewShortcut(UtaView.VIEW_ID);
+ // layout.addShowViewShortcut(EmulatorsView.VIEW_ID);
+ layout.addShowViewShortcut("org.eclipse.pde.runtime.LogView");
+ layout.addShowViewShortcut("org.eclipse.ui.console.ConsoleView");
+ layout.addShowViewShortcut("org.eclipse.jdt.ui.PackageExplorer");
+ layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+
+ }
+
+ public void defineLayout(IPageLayout layout) {
+ // Editors are placed for free.
+ String editorArea = layout.getEditorArea();
+
+ // Place navigator and outline to left of
+ // editor area.
+ IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, (float) 0.20, editorArea);
+ left.addView(OteNavigateView.VIEW_ID);
+ left.addView("org.eclipse.jdt.ui.PackageExplorer");
+
+ IFolderLayout lower = layout.createFolder("bottom", IPageLayout.BOTTOM, (float) 0.65, editorArea);
+ lower.addView("org.eclipse.pde.runtime.LogView");
+ lower.addView("org.eclipse.ui.console.ConsoleView");
+ lower.addView(IPageLayout.ID_PROBLEM_VIEW);
+
+ // string found in JavaUI.ID_ACTION_SET
+ layout.addActionSet("org.eclipse.jdt.ui.JavaActionSet");
+
+ // string found in JavaUI.ID_ELEMENT_CRATION_ACTION_SET
+ layout.addActionSet("org.eclipse.jdt.ui.JavaElementCreationActionSet");
+ layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
+
+ }
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsolePageParticipant.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsolePageParticipant.java
new file mode 100644
index 000000000..4b2615f61
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsolePageParticipant.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.osee.ote.ui.OteConsole;
+import org.eclipse.osee.ote.ui.internal.wizard.OteConsolePrefsWizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsolePageParticipant;
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.part.IPageSite;
+
+public class OteConsolePageParticipant implements IConsolePageParticipant {
+
+ private IPageBookViewPage page;
+ private IActionBars bars;
+ private Action optionsButton;
+ private OteConsole console;
+
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
+ return null;
+ }
+
+ @Override
+ public void init(IPageBookViewPage page, IConsole console) {
+ this.console = (OteConsole) console;
+ this.page = page;
+ IPageSite site = page.getSite();
+ this.bars = site.getActionBars();
+
+ createOptionsButton();
+
+ bars.getMenuManager().add(optionsButton);
+
+ bars.updateActionBars();
+ }
+
+ private void createOptionsButton() {
+ this.optionsButton = new Action("Preferences") {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ WizardDialog wd = new WizardDialog(Display.getCurrent().getActiveShell(), new OteConsolePrefsWizard(console));
+ wd.open();
+ }
+ };
+ }
+
+ @Override
+ public void dispose() {
+ this.page = null;
+ this.bars = null;
+ this.optionsButton = null;
+ }
+
+ @Override
+ public void activated() {
+ update();
+ }
+
+ private void update() {
+ if(page == null) {
+ return;
+ }
+
+ optionsButton.setEnabled(true);
+
+ bars.updateActionBars();
+ }
+
+ @Override
+ public void deactivated() {
+ update();
+ }
+
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleServiceImpl.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleServiceImpl.java
new file mode 100644
index 000000000..ef4d4bf46
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleServiceImpl.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.internal;
+
+import java.io.IOException;
+
+import org.eclipse.osee.framework.jdk.core.util.IConsoleInputListener;
+import org.eclipse.osee.ote.ui.IOteConsoleService;
+import org.eclipse.osee.ote.ui.OteConsoleWrapper;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OteConsoleServiceImpl implements IOteConsoleService {
+
+ private final OteConsoleWrapper console = new OteConsoleWrapper("OTE Console");
+
+ private OteConsoleWrapper getConsole() {
+ return console;
+ }
+
+ @Override
+ public void addInputListener(IConsoleInputListener listener) {
+ if (listener != null) {
+ getConsole().addInputListener(listener);
+ }
+ }
+
+ @Override
+ public void removeInputListener(IConsoleInputListener listener) {
+ if (listener != null) {
+ getConsole().removeInputListener(listener);
+ }
+ }
+
+ @Override
+ public void write(String value) {
+ getConsole().write(value);
+ }
+
+ @Override
+ public void writeError(String value) {
+ getConsole().writeError(value);
+ }
+
+ @Override
+ public void prompt(String value) throws IOException {
+ getConsole().prompt(value);
+ }
+
+ @Override
+ public void popup() {
+ getConsole().popup();
+ }
+
+ @Override
+ public void write(String value, int type, boolean popup) {
+ getConsole().write(value, type, popup);
+ }
+
+ public void close() {
+ getConsole().shutdown();
+ }
+ }
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteServerConsole.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteServerConsole.java
new file mode 100644
index 000000000..9290154d2
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteServerConsole.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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.internal;
+
+import java.io.IOException;
+
+import org.eclipse.osee.framework.jdk.core.util.IConsoleInputListener;
+import org.eclipse.osee.framework.ui.plugin.util.OseeConsole;
+import org.eclipse.osee.ote.message.event.OteEventMessageUtil;
+import org.eclipse.osee.ote.remote.messages.ConsoleInputMessage;
+import org.eclipse.osee.ote.remote.messages.ConsoleOutputMessage;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
+
+public class OteServerConsole {
+
+ private final OseeConsole console = new OseeConsole("OTE Server", false, false);
+ private ServiceRegistration<EventHandler> registration;
+
+ public OteServerConsole() {
+ console.addInputListener(new OTEServerConsoleInputListener());
+ registration = OteEventMessageUtil.subscribe(ConsoleOutputMessage.TOPIC, new ConsoleOutputHandler(console));
+ }
+
+ private OseeConsole getConsole() {
+ return console;
+ }
+
+ public void close() {
+ getConsole().shutdown();
+ if(registration != null){
+ registration.unregister();
+ registration = null;
+ }
+ }
+
+ private static class ConsoleOutputHandler implements EventHandler {
+
+ private OseeConsole console;
+ private ConsoleOutputMessage output;
+
+ public ConsoleOutputHandler(OseeConsole console) {
+ this.console = console;
+ this.output = new ConsoleOutputMessage();
+ }
+
+ @Override
+ public void handleEvent(Event arg0) {
+ output.setBackingBuffer(OteEventMessageUtil.getBytes(arg0));
+ try {
+ console.write(output.getString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ }
+
+ private static class OTEServerConsoleInputListener implements IConsoleInputListener {
+
+ private ConsoleInputMessage input = new ConsoleInputMessage();
+
+ @Override
+ public void lineRead(String line) {
+ try {
+ input.setString(line);
+ OteEventMessageUtil.sendEvent(input);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/TestCoreGuiPlugin.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/TestCoreGuiPlugin.java
new file mode 100644
index 000000000..23431b236
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/TestCoreGuiPlugin.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * 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.internal;
+
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.IWorkbenchUserService;
+import org.eclipse.osee.framework.ui.plugin.workspace.SafeWorkspaceAccess;
+import org.eclipse.osee.ote.ui.IOteConsoleService;
+import org.eclipse.osee.ote.ui.RemoteConsoleLauncher;
+import org.eclipse.osee.ote.ui.internal.prefs.OteConsolePreferences;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+@SuppressWarnings("rawtypes")
+public class TestCoreGuiPlugin extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID = "org.eclipse.osee.ote.ui";
+
+ private static TestCoreGuiPlugin instance;
+
+ private ServiceRegistration oteConsoleServiceRegistration;
+ private ServiceTracker workbenchUserServiceTracker;
+
+ private ServiceTracker workspaceStartTracker;
+ private OteConsoleServiceImpl oteConsoleService;
+ private BundleContext context;
+
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ this.context = context;
+ instance = this;
+ createWorkspaceTracker(context);
+ if (System.getProperty("NO_OTE_ARTIFACT_BULK_LOAD") == null) {
+ startOTEArtifactBulkLoad();
+ }
+ super.start(context);
+ }
+
+ /**
+ * @param context
+ */
+ @SuppressWarnings("unchecked")
+ private void createWorkspaceTracker(final BundleContext context) {
+ workspaceStartTracker = new ServiceTracker(context, SafeWorkspaceAccess.class.getName(), null) {
+ private RemoteConsoleLauncher tracker;
+
+ @Override
+ public void removedService(ServiceReference reference, Object service) {
+ if (oteConsoleService != null) {
+ oteConsoleServiceRegistration.unregister();
+ oteConsoleService.close();
+ oteConsoleService = null;
+ }
+ if (tracker != null) {
+ tracker.close();
+ }
+ super.removedService(reference, service);
+ }
+
+ @Override
+ public void close() {
+ if (tracker != null) {
+ tracker.close();
+ }
+ super.close();
+ }
+
+ @Override
+ public void modifiedService(ServiceReference reference, Object service) {
+ // do nothing
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference) {
+ oteConsoleService = new OteConsoleServiceImpl();
+ oteConsoleServiceRegistration =
+ context.registerService(IOteConsoleService.class.getName(), oteConsoleService, null);
+ if (System.getProperty("NO_OTE_REMOTE_CONSOLE") == null) {
+ tracker = new RemoteConsoleLauncher(oteConsoleService);
+ tracker.open(true);
+ }
+ return super.addingService(reference);
+ }
+ };
+ workspaceStartTracker.open(true);
+
+ workbenchUserServiceTracker = new ServiceTracker(context, IWorkbenchUserService.class.getName(), null);
+ workbenchUserServiceTracker.open();
+ }
+
+ public static void setDefaultPreferences() {
+ IPreferenceStore store = getDefault().getPreferenceStore();
+ for( OteConsolePreferences pref : OteConsolePreferences.values()) {
+ store.setDefault(pref.getPropKey(), pref.getDefaultValue().toString());
+ }
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ if (workbenchUserServiceTracker != null) {
+ workbenchUserServiceTracker.close();
+ }
+ if (oteConsoleServiceRegistration != null) {
+ oteConsoleServiceRegistration.unregister();
+ oteConsoleService.close();
+ oteConsoleService = null;
+ }
+ workspaceStartTracker.close();
+ instance = null;
+
+ super.stop(context);
+ }
+
+ private void startOTEArtifactBulkLoad() {
+ Operations.executeAsJob(new AbstractOperation("OTE Persistance Bulk Load", PLUGIN_ID) {
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ try{
+ if (getWorkbenchUserService() != null) {
+ getWorkbenchUserService().getUser();
+ }
+ } catch (Throwable th){
+ OseeLog.log(getClass(), Level.WARNING, "Unable to connect to OSEE Data Store, user information will default to system properties.", th);
+ }
+ }
+ }, false);
+ }
+
+ private IWorkbenchUserService getWorkbenchUserService() throws OseeCoreException {
+ IWorkbenchUserService service = null;
+ try {
+ service = (IWorkbenchUserService) workbenchUserServiceTracker.waitForService(3000);
+ } catch (InterruptedException ex) {
+ OseeCoreException.wrapAndThrow(ex);
+ }
+ return service;
+ }
+
+ public static TestCoreGuiPlugin getDefault() {
+ return instance;
+ }
+
+ public IOteConsoleService getOteConsoleService() {
+ return oteConsoleService;
+ }
+
+ public static BundleContext getContext() {
+ return instance.context;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePreferences.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePreferences.java
new file mode 100644
index 000000000..8c8bdf724
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePreferences.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.prefs;
+
+/**
+ * @author Michael P. Masterson
+ */
+public enum OteConsolePreferences {
+ BUFFER_LIMIT("org.eclipse.osee.ote.ui.bufferLimit", 1000000),
+ NO_BUFFER_LIMIT("org.eclipse.osee.ote.ui.noLimit", false);
+
+
+ private String propKey;
+ private Object defaultValue;
+
+ private OteConsolePreferences(String propKey, Object defaultValue) {
+ this.propKey = propKey;
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * @return the defaultValue
+ */
+ public Object getDefaultValue() {
+ return defaultValue;
+ }
+
+ /**
+ * @return the propKey
+ */
+ public String getPropKey() {
+ return propKey;
+ }
+
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePrefsUtil.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePrefsUtil.java
new file mode 100644
index 000000000..d4a6a2dad
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePrefsUtil.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.prefs;
+
+import org.eclipse.osee.ote.ui.internal.TestCoreGuiPlugin;
+
+/**
+ * @author Michael P. Masterson
+ */
+public class OteConsolePrefsUtil {
+
+ public static int getInt(OteConsolePreferences bufferLimit) {
+ String propKey = bufferLimit.getPropKey();
+ lateLoadDefaults(propKey);
+ return TestCoreGuiPlugin.getDefault().getPreferenceStore().getInt(propKey);
+ }
+
+ public static String getString(OteConsolePreferences bufferLimit) {
+ String propKey = bufferLimit.getPropKey();
+ lateLoadDefaults(propKey);
+ return TestCoreGuiPlugin.getDefault().getPreferenceStore().getString(propKey);
+ }
+
+ public static boolean getBoolean(OteConsolePreferences bufferLimit) {
+ String propKey = bufferLimit.getPropKey();
+ lateLoadDefaults(propKey);
+ return TestCoreGuiPlugin.getDefault().getPreferenceStore().getBoolean(propKey);
+ }
+
+ public static void setInt(OteConsolePreferences preference, int value) {
+ TestCoreGuiPlugin.getDefault().getPreferenceStore().setValue(preference.getPropKey(), value);
+ }
+
+ public static void setString(OteConsolePreferences preference, String value) {
+ TestCoreGuiPlugin.getDefault().getPreferenceStore().setValue(preference.getPropKey(), value);
+ }
+
+ public static void setBoolean(OteConsolePreferences preference, boolean value) {
+ TestCoreGuiPlugin.getDefault().getPreferenceStore().setValue(preference.getPropKey(), value);
+ }
+
+ private static void lateLoadDefaults(String keyStr) {
+ TestCoreGuiPlugin plugin = TestCoreGuiPlugin.getDefault();
+ String defaultString = plugin.getPreferenceStore().getDefaultString(keyStr);
+ if(defaultString == null || defaultString.length() <= 0) {
+ TestCoreGuiPlugin.setDefaultPreferences();
+ }
+ }
+
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizPage.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizPage.java
new file mode 100644
index 000000000..73c3985f1
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizPage.java
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.wizard;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osee.ote.ui.internal.prefs.OteConsolePreferences;
+import org.eclipse.osee.ote.ui.internal.prefs.OteConsolePrefsUtil;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Michael P. Masterson
+ */
+public class OteConsolePrefsWizPage extends WizardPage {
+
+ private Text bufferText;
+ private Label errorLabel;
+ private Button noLimitCheckbox;
+
+ private int bufferLimit;
+ private boolean noLimitSelection;
+
+ /**
+ * @param pageName
+ */
+ public OteConsolePrefsWizPage() {
+ super("OTE Console Preferences Wizard");
+ setTitle("OTE Console Options");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+ Composite main = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.fillDefaults().numColumns(1).applyTo(main);
+
+ addBufferLimit(main);
+ addErrorLabel(main);
+ determinePageComplete();
+
+ setControl(main);
+ }
+
+ private void addErrorLabel(Composite parent) {
+ this.errorLabel = new Label(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(errorLabel);
+ errorLabel.setVisible(false);
+ }
+
+ /**
+ *
+ */
+ private void determinePageComplete() {
+ boolean allIsWell = false;
+ String bufferLimitStr = bufferText.getText();
+ if(bufferLimitStr != null && bufferLimitStr.length() > 0 ) {
+ try {
+ Integer.parseInt(bufferLimitStr);
+ allIsWell = true;
+ } catch (NumberFormatException ex) {
+ errorLabel.setText("Buffer limit must be a number between 0 and " + Integer.MAX_VALUE);
+ allIsWell = false;
+ }
+ }
+
+ errorLabel.setVisible(!allIsWell);
+ setPageComplete(allIsWell);
+ }
+
+ /**
+ * @param parent
+ */
+ private void addBufferLimit(Composite parent) {
+ Group comp = new Group(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().grab(false, false).applyTo(comp);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(comp);
+ comp.setText("Select Console Buffer Limit (Bytes)");
+
+ bufferText = new Text(comp, SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(bufferText);
+
+ String defaultText = OteConsolePrefsUtil.getString(OteConsolePreferences.BUFFER_LIMIT);
+ bufferText.setText(defaultText);
+
+ noLimitCheckbox = new Button(comp, SWT.CHECK);
+ noLimitCheckbox.setText("No Limit");
+ boolean defaultNoLimit = OteConsolePrefsUtil.getBoolean(OteConsolePreferences.NO_BUFFER_LIMIT);
+ noLimitCheckbox.setSelection(defaultNoLimit);
+
+
+ bufferText.setEnabled(!defaultNoLimit);
+
+ noLimitCheckbox.addSelectionListener(new SelectionAdapter() {
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ boolean isNoLimit = noLimitCheckbox.getSelection();
+ bufferText.setEnabled(!isNoLimit);
+ determinePageComplete();
+ savePreferences();
+ }
+ });
+
+ bufferText.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ determinePageComplete();
+ }
+ });
+
+ bufferText.addFocusListener(new FocusListener() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ determinePageComplete();
+ savePreferences();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ }
+ });
+ }
+
+ /**
+ *
+ */
+ protected void savePreferences() {
+ if(isPageComplete() && !bufferText.isDisposed()) {
+ saveNoLimitSelection();
+ saveBufferLimit();
+ OteConsolePrefsUtil.setInt(OteConsolePreferences.BUFFER_LIMIT, getBufferLimit());
+ OteConsolePrefsUtil.setBoolean(OteConsolePreferences.NO_BUFFER_LIMIT, getNoLimitSelection());
+ }
+ }
+
+ private void saveNoLimitSelection() {
+ this.noLimitSelection = noLimitCheckbox.getSelection();
+ }
+
+ public boolean getNoLimitSelection() {
+ return noLimitSelection;
+ }
+
+ private void saveBufferLimit() {
+ this.bufferLimit = Integer.parseInt(bufferText.getText());
+ }
+
+ public int getBufferLimit() {
+ return bufferLimit;
+ }
+
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizard.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizard.java
new file mode 100644
index 000000000..ad3245e98
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizard.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal.wizard;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osee.ote.ui.OteConsole;
+
+/**
+ * @author Michael P. Masterson
+ */
+public class OteConsolePrefsWizard extends Wizard {
+
+ OteConsolePrefsWizPage mainPage;
+ private OteConsole console;
+
+ /**
+ * @param console
+ */
+ public OteConsolePrefsWizard(OteConsole console) {
+ this.console = console;
+ mainPage = new OteConsolePrefsWizPage();
+ }
+
+ @Override
+ public boolean performFinish() {
+ int bufferLimit = mainPage.getBufferLimit();
+ boolean noLimitSelected = mainPage.getNoLimitSelection();
+
+ console.setLimit(bufferLimit);
+ console.setNoLimit(noLimitSelected);
+
+ return true;
+ }
+
+ @Override
+ public void addPages() {
+ addPage(mainPage);
+ }
+
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateView.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateView.java
new file mode 100644
index 000000000..17b8ffe49
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateView.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * 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.navigate;
+
+import java.util.logging.Level;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IRegistryEventListener;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.Action;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
+import org.eclipse.osee.framework.ui.plugin.util.HelpUtil;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite;
+import org.eclipse.osee.framework.ui.swt.ImageManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Insert the type's description here.
+ *
+ * @see ViewPart
+ */
+public class OteNavigateView extends ViewPart {
+
+ public static final String VIEW_ID = "org.eclipse.osee.ote.ui.navigate.OteNavigateView";
+ private XNavigateComposite xNavComp;
+
+ @Override
+ public void setFocus() {
+ if (xNavComp != null) {
+ xNavComp.setFocus();
+ }
+ }
+
+ /*
+ * @see IWorkbenchPart#createPartControl(Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ xNavComp = new XNavigateComposite(new OteNavigateViewItems(), parent, SWT.NONE);
+
+ xNavComp.getFilteredTree().getViewer().setSorter(new OteNavigateViewerSorter());
+
+ createActions();
+ xNavComp.refresh();
+
+ addExtensionPointListenerBecauseOfWorkspaceLoading();
+
+ // TODO: Change to use OteHelpContext
+ HelpUtil.setHelp(parent, "ote_navigator", "org.eclipse.osee.ote.help.ui");
+ HelpUtil.setHelp(xNavComp, "ote_navigator", "org.eclipse.osee.ote.help.ui");
+ }
+
+ private void addExtensionPointListenerBecauseOfWorkspaceLoading() {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ extensionRegistry.addListener(new IRegistryEventListener() {
+ @Override
+ public void added(IExtension[] extensions) {
+ try {
+ refresh();
+ } catch (Exception ex) {
+ OseeLog.log(getClass(), Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void added(IExtensionPoint[] extensionPoints) {
+ try {
+ refresh();
+ } catch (Exception ex) {
+ OseeLog.log(getClass(), Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void removed(IExtension[] extensions) {
+ try {
+ refresh();
+ } catch (Exception ex) {
+ OseeLog.log(getClass(), Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void removed(IExtensionPoint[] extensionPoints) {
+ try {
+ refresh();
+ } catch (Exception ex) {
+ OseeLog.log(getClass(), Level.SEVERE, ex);
+ }
+ }
+ }, "org.eclipse.osee.framework.ui.plugin.XNavigateItem");
+ }
+
+ protected void createActions() {
+ Action refreshAction = new Action("Refresh") {
+
+ @Override
+ public void run() {
+ if (!xNavComp.isDisposed()) {
+ xNavComp.refresh();
+ }
+ }
+ };
+ refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
+ refreshAction.setToolTipText("Refresh");
+
+ }
+
+ public void refresh() {
+ if (!xNavComp.isDisposed()) {
+ xNavComp.refresh();
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateViewItems.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateViewItems.java
new file mode 100644
index 000000000..30159408a
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateViewItems.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.navigate;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateContributionManager;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateExtensionPointData;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateViewItems;
+import org.eclipse.osee.ote.ui.internal.TestCoreGuiPlugin;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OteNavigateViewItems implements XNavigateViewItems {
+
+ public OteNavigateViewItems() {
+ super();
+ }
+
+ @Override
+ public List<XNavigateItem> getSearchNavigateItems() {
+ List<XNavigateItem> items = new ArrayList<>();
+ try {
+ addExtensionPointItems(items);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(TestCoreGuiPlugin.class, Level.SEVERE, ex);
+ }
+ return items;
+ }
+
+ private void addExtensionPointItems(List<XNavigateItem> items) throws OseeCoreException {
+ Collection<XNavigateExtensionPointData> oteNavigateItemExtensions =
+ XNavigateContributionManager.getNavigateItems(OteNavigateView.VIEW_ID);
+ Map<String, XNavigateItem> categoryToNavigateItem =
+ createCategoriesAndAddToItems(items, oteNavigateItemExtensions);
+ for (XNavigateExtensionPointData data : oteNavigateItemExtensions) {
+ XNavigateItem item = categoryToNavigateItem.get(data.getCategory());
+ try {
+ if (item == null) {
+ items.addAll(data.getNavigateItems());
+ } else {
+
+ for (XNavigateItem navItem : data.getNavigateItems()) {
+ item.addChild(navItem);
+ }
+ }
+ } catch (Throwable th) {
+ OseeLog.log(OteNavigateViewItems.class, Level.SEVERE, th);
+ }
+ }
+ }
+
+ private Map<String, XNavigateItem> createCategoriesAndAddToItems(List<XNavigateItem> items, Collection<XNavigateExtensionPointData> oteNavigateItemExtensions) {
+ Map<String, XNavigateItem> categoryToNavigateItem = new HashMap<>();
+ for (XNavigateExtensionPointData data : oteNavigateItemExtensions) {
+ if (!categoryToNavigateItem.containsKey(data.getCategory())) {
+ String[] path = data.getItemPath();
+ StringBuilder keyBuilder = new StringBuilder(256);
+ XNavigateItem lastItem = null;
+ for (int i = 0; i < path.length; i++) {
+
+ keyBuilder.append(path[i]);
+ String key = keyBuilder.toString();
+ XNavigateItem foundItem = categoryToNavigateItem.get(key);
+ if (foundItem == null) {
+ foundItem = new XNavigateItem(lastItem, path[i], PluginUiImage.FOLDER);
+ categoryToNavigateItem.put(key, foundItem);
+ // if(lastItem != null){
+ // lastItem.addChild(foundItem);
+ // }
+ if (i == 0) {
+ items.add(foundItem);
+ }
+ }
+ lastItem = foundItem;
+ keyBuilder.append('.');
+ }
+ }
+ }
+ return categoryToNavigateItem;
+ }
+
+}
diff --git a/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateViewerSorter.java b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateViewerSorter.java
new file mode 100644
index 000000000..f24c62df3
--- /dev/null
+++ b/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateViewerSorter.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.navigate;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OteNavigateViewerSorter extends ViewerSorter {
+
+ public OteNavigateViewerSorter() {
+ super();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ XNavigateItem item1 = (XNavigateItem) e1;
+ XNavigateItem item2 = (XNavigateItem) e2;
+ return getComparator().compare(item1.getName(), item2.getName());
+ }
+
+}

Back to the top