Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.ote.ui/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.osee.ote.ui/plugin.xml31
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsole.java79
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsoleWrapper.java243
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleCommandHandler.java40
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsolePageParticipant.java91
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleServiceImpl.java53
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/TestCoreGuiPlugin.java27
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePreferences.java38
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePrefsUtil.java39
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizPage.java132
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizard.java32
12 files changed, 800 insertions, 10 deletions
diff --git a/plugins/org.eclipse.osee.ote.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.ui/META-INF/MANIFEST.MF
index 7e23d4e4de..32811c2b01 100644
--- a/plugins/org.eclipse.osee.ote.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ote.ui/META-INF/MANIFEST.MF
@@ -36,7 +36,10 @@ Import-Package: org.eclipse.core.resources,
org.eclipse.osee.ote.service,
org.eclipse.swt,
org.eclipse.swt.widgets,
+ org.eclipse.ui.console,
+ org.eclipse.ui.internal.console,
org.osgi.framework,
org.osgi.service.event;version="1.3.0",
org.osgi.util.tracker
-Require-Bundle: org.eclipse.ui
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.ui.workbench
diff --git a/plugins/org.eclipse.osee.ote.ui/plugin.xml b/plugins/org.eclipse.osee.ote.ui/plugin.xml
index 1dee02323a..d4cf308d04 100644
--- a/plugins/org.eclipse.osee.ote.ui/plugin.xml
+++ b/plugins/org.eclipse.osee.ote.ui/plugin.xml
@@ -62,4 +62,35 @@
</viewerContribution>
</extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="true"
+ locationURI="toolbar:org.eclipse.ui.console.ConsoleVifdfew">
+ <command
+ commandId="org.eclipse.osee.ote.ui.consolePrefs"
+ id="OTEConsolePrefs"
+ label="OTE"
+ style="push">
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.osee.ote.ui.internal.OteConsoleCommandHandler"
+ id="org.eclipse.osee.ote.ui.consolePrefs"
+ name="OTE">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.console.consolePageParticipants">
+ <consolePageParticipant
+ class="org.eclipse.osee.ote.ui.internal.OteConsolePageParticipant"
+ id="org.eclipse.osee.ote.ui.oteConsolePreferences">
+ <enablement>
+ <instsanceof value="org.eclipse.osee.ote.ui.OteConsole"/>
+ </enablement>
+ </consolePageParticipant>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsole.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsole.java
new file mode 100644
index 0000000000..6a412b02e0
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsole.java
@@ -0,0 +1,79 @@
+/*
+ * Created on Feb 10, 2017
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.ui;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleView;
+import org.eclipse.ui.console.IOConsole;
+import org.eclipse.ui.internal.console.IOConsolePage;
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.part.IPageSite;
+
+/**
+ * @author Michael P. Masterson
+ */
+public class OteConsole extends IOConsole {
+
+ private IActionBars bars;
+ private Action optionsButton;
+
+ /**
+ * @param name
+ * @param consoleType
+ * @param imageDescriptor
+ */
+ public OteConsole(String name, ImageDescriptor imageDescriptor) {
+ super(name, imageDescriptor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.console.IOConsole#createPage(org.eclipse.ui.console.IConsoleView)
+ */
+ @Override
+ public IPageBookViewPage createPage(IConsoleView view) {
+
+ @SuppressWarnings("restriction")
+ IPageBookViewPage page = new IOConsolePage(this, view) {
+ @Override
+ public void init(IPageSite pageSite) throws PartInitException {
+ super.init(pageSite);
+ bars = getSite().getActionBars();
+ createOptionsButton();
+
+ bars.getMenuManager().add(optionsButton);
+ bars.getToolBarManager().add(optionsButton);
+
+ bars.updateActionBars();
+ }
+ };
+
+ return page;
+ }
+
+ /**
+ *
+ */
+ private void createOptionsButton() {
+ this.optionsButton = new Action("OTE_MOREs") {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ System.out.println("YEAAAHHHH BUDDY");
+ super.run();
+ }
+ };
+
+ optionsButton.setEnabled(true);
+ }
+
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsoleWrapper.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsoleWrapper.java
new file mode 100644
index 0000000000..ed46e111f7
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/OteConsoleWrapper.java
@@ -0,0 +1,243 @@
+/*
+ * Created on Feb 10, 2017
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+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.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;
+
+/**
+ * @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 = new OteConsole(title, null);
+ this.time = time;
+ this.newline = newline;
+ this.inputHandler = new HandleInput();
+
+ thread = new Thread(inputHandler);
+ thread.setName("OTE 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();
+ }
+
+ 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;
+
+ public void setWaterMarks(int low, int high) {
+ console.setWaterMarks(low, high);
+ }
+
+ /**
+ * Writes string to console without popping console forward
+ */
+ public void write(String str) {
+ write(str, false);
+ }
+
+ /**
+ * Writes string to console without popping console forward
+ */
+ public void writeError(String str) {
+ write(str, CONSOLE_ERROR, true);
+ }
+
+ /**
+ * Writes string to console
+ *
+ * @param popup bring console window forward
+ */
+ public void write(String str, boolean popup) {
+ write(str, CONSOLE_OUT, popup);
+ }
+
+ /**
+ * Write string to console
+ *
+ * @param type CONSOLE_ERROR, CONSOLE_OUT, CONSOLE_PROMPT
+ */
+ public void write(String str, int type) {
+ write(str, type, false);
+ }
+
+ /**
+ * Write string to console
+ *
+ * @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(OteConsoleWrapper.class, Level.INFO, "done with the handling of input");
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleCommandHandler.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleCommandHandler.java
new file mode 100644
index 0000000000..92ddf2b1a8
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleCommandHandler.java
@@ -0,0 +1,40 @@
+/*
+ * Created on Feb 10, 2017
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.ui.internal;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+public class OteConsoleCommandHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#isHandled()
+ */
+ @Override
+ public boolean isHandled() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsolePageParticipant.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsolePageParticipant.java
new file mode 100644
index 0000000000..4fd27e5a14
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsolePageParticipant.java
@@ -0,0 +1,91 @@
+/*
+ * Created on Feb 10, 2017
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+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.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.IConsoleConstants;
+import org.eclipse.ui.console.IConsolePageParticipant;
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.part.IPageSite;
+
+public class OteConsolePageParticipant implements IConsolePageParticipant {
+
+ private IConsole console;
+ private IPageBookViewPage page;
+ private IActionBars bars;
+ private Action optionsButton;
+
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
+ return null;
+ }
+
+ @Override
+ public void init(IPageBookViewPage page, IConsole console) {
+ this.console = console;
+ this.page = page;
+ IPageSite site = page.getSite();
+ this.bars = site.getActionBars();
+
+ createOptionsButton();
+
+ bars.getMenuManager().add(optionsButton);
+
+ bars.getToolBarManager().appendToGroup(IConsoleConstants.LAUNCH_GROUP, optionsButton);
+
+ bars.updateActionBars();
+ }
+
+ /**
+ *
+ */
+ private void createOptionsButton() {
+ this.optionsButton = new Action("OTE_AGAIN") {
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), new OteConsolePrefsWizard());
+ System.out.println("YEAAAHHHH BUDDY");
+ super.run();
+ }
+ };
+ }
+
+ @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/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleServiceImpl.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleServiceImpl.java
index 9f6105fbd2..bed5ed261b 100644
--- a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleServiceImpl.java
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/OteConsoleServiceImpl.java
@@ -11,22 +11,67 @@
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.ui.IOteConsoleService;
+import org.eclipse.osee.ote.ui.OteConsoleWrapper;
+import org.eclipse.osee.ote.ui.internal.prefs.OteConsolePreferences;
+import org.eclipse.osee.ote.ui.internal.prefs.OteConsolePrefsUtil;
/**
* @author Roberto E. Escobar
*/
public class OteConsoleServiceImpl implements IOteConsoleService {
- private final OseeConsole console = new OseeConsole("OTE Console");
+ private static final int HIGH_TO_LOW_DIFF = 100;
+ private final OteConsoleWrapper console = new OteConsoleWrapper("OTE Console2");
+ private int limit;
+ private boolean noLimit;
+ private static OteConsoleServiceImpl instance;
public OteConsoleServiceImpl() {
+ limit = OteConsolePrefsUtil.getInt(OteConsolePreferences.BUFFER_LIMIT);
+ noLimit = OteConsolePrefsUtil.getBoolean(OteConsolePreferences.NO_BUFFER_LIMIT);
+ setWaterMarks();
+ instance = this;
+ }
+ /**
+ *
+ */
+ private void setWaterMarks() {
+ int lowMark, highMark;
+
+ if(noLimit) {
+ lowMark = -1;
+ highMark = -1;
+ } else if( limit > HIGH_TO_LOW_DIFF ){
+ lowMark = limit -1;
+ highMark = limit;
+ } else {
+ lowMark = limit - HIGH_TO_LOW_DIFF;
+ highMark = limit;
+ }
+
+ console.setWaterMarks(lowMark, highMark);
+ }
+
+ public static OteConsoleServiceImpl getInstance() {
+ return instance;
+ }
+
+ /**
+ * @param limit the buffer size limit in bytes
+ */
+ public void setLimit(int limit) {
+ this.limit = limit;
+ }
+
+ public void setNoLimit(boolean noLimit) {
+ this.noLimit = noLimit;
}
- private OseeConsole getConsole() {
+ private OteConsoleWrapper getConsole() {
return console;
}
@@ -72,4 +117,4 @@ public class OteConsoleServiceImpl implements IOteConsoleService {
public void close() {
getConsole().shutdown();
}
-}
+ }
diff --git a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/TestCoreGuiPlugin.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/TestCoreGuiPlugin.java
index 19ff552b3a..06c86dd6d0 100644
--- a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/TestCoreGuiPlugin.java
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/TestCoreGuiPlugin.java
@@ -11,7 +11,9 @@
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.exception.OseeExceptions;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
import org.eclipse.osee.framework.core.operation.Operations;
@@ -21,16 +23,17 @@ 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.osgi.framework.BundleActivator;
+import org.eclipse.osee.ote.ui.internal.prefs.OteConsolePreferences;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* The main plugin class to be used in the desktop.
*/
-public class TestCoreGuiPlugin implements BundleActivator {
+public class TestCoreGuiPlugin extends AbstractUIPlugin {
public static final String PLUGIN_ID = "org.eclipse.osee.ote.ui";
@@ -49,6 +52,17 @@ public class TestCoreGuiPlugin implements BundleActivator {
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();
+ }
+ setDefaultPreferences();
+ }
+
+ /**
+ * @param context
+ */
+ private void createWorkspaceTracker(final BundleContext context) {
workspaceStartTracker = new ServiceTracker(context, SafeWorkspaceAccess.class.getName(), null) {
private RemoteConsoleLauncher tracker;
@@ -96,9 +110,12 @@ public class TestCoreGuiPlugin implements BundleActivator {
workbenchUserServiceTracker = new ServiceTracker(context, IWorkbenchUserService.class.getName(), null);
workbenchUserServiceTracker.open();
-
- if (System.getProperty("NO_OTE_ARTIFACT_BULK_LOAD") == null) {
- startOTEArtifactBulkLoad();
+ }
+
+ public static void setDefaultPreferences() {
+ IPreferenceStore store = getDefault().getPreferenceStore();
+ for( OteConsolePreferences pref : OteConsolePreferences.values()) {
+ store.setDefault(pref.getPropKey(), pref.getDefaultValue().toString());
}
}
diff --git a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePreferences.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePreferences.java
new file mode 100644
index 0000000000..2f450b0fe3
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePreferences.java
@@ -0,0 +1,38 @@
+/*
+ * Created on Feb 10, 2017
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+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/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePrefsUtil.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePrefsUtil.java
new file mode 100644
index 0000000000..dd8ec32a61
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/prefs/OteConsolePrefsUtil.java
@@ -0,0 +1,39 @@
+/*
+ * Created on Feb 10, 2017
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+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) {
+ return TestCoreGuiPlugin.getDefault().getPreferenceStore().getInt(bufferLimit.getPropKey());
+ }
+
+ public static String getString(OteConsolePreferences bufferLimit) {
+ return TestCoreGuiPlugin.getDefault().getPreferenceStore().getString(bufferLimit.getPropKey());
+ }
+
+ public static boolean getBoolean(OteConsolePreferences bufferLimit) {
+ return TestCoreGuiPlugin.getDefault().getPreferenceStore().getBoolean(bufferLimit.getPropKey());
+ }
+
+ 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);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizPage.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizPage.java
new file mode 100644
index 0000000000..004af2aaf2
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizPage.java
@@ -0,0 +1,132 @@
+/*
+ * Created on Feb 10, 2017
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+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.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;
+
+ /**
+ * @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) {
+ GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
+
+ addBufferLimit(parent);
+ addErrorLabel(parent);
+ determinePageComplete();
+ }
+
+ 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 (Characters)");
+
+ bufferText = new Text(comp, SWT.BORDER);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(bufferText);
+
+ String defaultText = OteConsolePrefsUtil.getString(OteConsolePreferences.BUFFER_LIMIT);
+
+ noLimitCheckbox = new Button(comp, SWT.CHECK);
+ noLimitCheckbox.setText("No Limit");
+ boolean defaultNoLimit = OteConsolePrefsUtil.getBoolean(OteConsolePreferences.NO_BUFFER_LIMIT);
+ noLimitCheckbox.setSelection(defaultNoLimit);
+
+ if(!defaultNoLimit) {
+ bufferText.setText(defaultText);
+ }
+
+ bufferText.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(KeyEvent e) {
+ determinePageComplete();
+ }
+ });
+
+ bufferText.addFocusListener(new FocusListener() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ savePreferences();
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ }
+ });
+ }
+
+ /**
+ *
+ */
+ protected void savePreferences() {
+ if(isPageComplete()) {
+ OteConsolePrefsUtil.setInt(OteConsolePreferences.BUFFER_LIMIT, Integer.parseInt(bufferText.getText()));
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizard.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizard.java
new file mode 100644
index 0000000000..f7b15a51fe
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/internal/wizard/OteConsolePrefsWizard.java
@@ -0,0 +1,32 @@
+/*
+ * Created on Feb 10, 2017
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ote.ui.internal.wizard;
+
+import org.eclipse.jface.wizard.Wizard;
+
+/**
+ * @author Michael P. Masterson
+ */
+public class OteConsolePrefsWizard extends Wizard {
+
+
+ OteConsolePrefsWizPage mainPage;
+
+ public OteConsolePrefsWizard() {
+ mainPage = new OteConsolePrefsWizPage();
+ }
+
+ @Override
+ public boolean performFinish() {
+ return true;
+ }
+
+ @Override
+ public void addPages() {
+ addPage(mainPage);
+ }
+
+}

Back to the top