Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-07-20 20:54:53 +0000
committerrescobar2010-07-20 20:54:53 +0000
commitcd8503bd2a67b2fbcb5daceb02b7ad1089eb525e (patch)
tree5ccbb5ab8d149dd0b77425a3df0c9a2184d3f47e
parenta88b295f5a066c21fce3aefc406d1e922ca44733 (diff)
downloadorg.eclipse.osee-cd8503bd2a67b2fbcb5daceb02b7ad1089eb525e.tar.gz
org.eclipse.osee-cd8503bd2a67b2fbcb5daceb02b7ad1089eb525e.tar.xz
org.eclipse.osee-cd8503bd2a67b2fbcb5daceb02b7ad1089eb525e.zip
Refactored to use Displays class
-rw-r--r--plugins/org.eclipse.osee.ote.runtimeManager/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/EarlyStartup.java36
-rw-r--r--plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/RuntimeManager.java62
-rw-r--r--plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/SafeWorkspaceTracker.java461
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/dialogs/ReportsDialog.java889
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/importer/ImportOutfileUIOperation.java200
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/jobs/ReportErrorsJob.java150
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/GrayableBranchSelectionComposite.java357
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/PreviewPanel.java178
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/reports/HttpReportRequest.java266
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/XViewerDataManager.java485
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/LaunchReportsAction.java79
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/OpenAssociatedOutfile.java105
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/data/ArtifactItem.java2
-rw-r--r--plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/views/TestRunView.java451
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/EnvironmentViewer.java485
-rw-r--r--plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TestServerConsoleServiceRenderer.java310
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/tree/MessageUpdateListener.java179
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/tree/MessageWatchLabelProvider.java58
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/view/MessageView.java999
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/DetailsBox.java631
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/ViewRefresher.java6
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java1797
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SendMessageAction.java60
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SetValueAction.java215
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/WatchElementAction.java146
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeElementAction.java64
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeMessageAction.java60
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/recording/RecordingFilePage.java155
-rw-r--r--plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/actions/OpenMuxViewAction.java52
-rw-r--r--plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/view/MuxView.java1684
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchDecorator.java69
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchProjectNature.java399
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java229
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptManager.java127
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerServiceStatusDataVisitor.java565
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditor.java1060
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/ScriptRunJob.java245
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/StoreOutfileJob.java232
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/ScriptPage.java834
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/StatusWindowWidget.java236
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageDataViewer.java235
-rw-r--r--plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageEventHandler.java205
-rw-r--r--plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateView.java172
44 files changed, 7626 insertions, 7605 deletions
diff --git a/plugins/org.eclipse.osee.ote.runtimeManager/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.runtimeManager/META-INF/MANIFEST.MF
index ab1d51af5d8..0b75ddfdcb3 100644
--- a/plugins/org.eclipse.osee.ote.runtimeManager/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ote.runtimeManager/META-INF/MANIFEST.MF
@@ -18,6 +18,7 @@ Import-Package: org.eclipse.core.resources,
org.eclipse.osee.framework.plugin.core.server,
org.eclipse.osee.framework.plugin.core.util,
org.eclipse.osee.framework.ui.plugin.workspace,
+ org.eclipse.osee.framework.ui.swt,
org.eclipse.osee.framework.ui.workspacebundleloader,
org.eclipse.osee.ote.core,
org.eclipse.swt,
diff --git a/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/EarlyStartup.java b/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/EarlyStartup.java
index 9f2499d3c0d..6eca8102076 100644
--- a/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/EarlyStartup.java
+++ b/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/EarlyStartup.java
@@ -13,7 +13,7 @@ package org.eclipse.osee.ote.runtimemanager;
import java.util.logging.Level;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.ui.IStartup;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -23,22 +23,22 @@ import org.osgi.framework.BundleException;
*/
public class EarlyStartup implements IStartup {
- private SafeWorkspaceTracker workspaceTracker;
+ private SafeWorkspaceTracker workspaceTracker;
- @Override
- public void earlyStartup() {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- try {
- Bundle bundle = Platform.getBundle("org.eclipse.osee.ote.runtimeManager");
- bundle.start();
- workspaceTracker = new SafeWorkspaceTracker(bundle.getBundleContext());
- workspaceTracker.open(true);
- } catch (BundleException ex) {
- OseeLog.log(RuntimeManager.class, Level.SEVERE, ex);
- }
- }
- });
- }
+ @Override
+ public void earlyStartup() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Bundle bundle = Platform.getBundle("org.eclipse.osee.ote.runtimeManager");
+ bundle.start();
+ workspaceTracker = new SafeWorkspaceTracker(bundle.getBundleContext());
+ workspaceTracker.open(true);
+ } catch (BundleException ex) {
+ OseeLog.log(RuntimeManager.class, Level.SEVERE, ex);
+ }
+ }
+ });
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/RuntimeManager.java b/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/RuntimeManager.java
index 18cc6e06580..86b31178265 100644
--- a/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/RuntimeManager.java
+++ b/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/RuntimeManager.java
@@ -8,39 +8,37 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.runtimemanager;
-
+package org.eclipse.osee.ote.runtimemanager;
+
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-
-/**
- *
- * @author Robert A. Fisher
- */
-public class RuntimeManager implements BundleActivator {
- public static final String BUNDLE_ID = "org.eclipse.osee.ote.runtimeManager";
-private static RuntimeManager instance;
- private BundleContext context;
-
- public static RuntimeManager getDefault() {
- return instance;
- }
-
-
- public void start(BundleContext context) throws Exception {
- instance = this;
- this.context = context;
- }
-
- public void stop(BundleContext context) throws Exception {
- instance = null;
- this.context = null;
- }
+/**
+ * @author Robert A. Fisher
+ */
+public class RuntimeManager implements BundleActivator {
+ public static final String BUNDLE_ID = "org.eclipse.osee.ote.runtimeManager";
+ private static RuntimeManager instance;
+ private BundleContext context;
+
+ public static RuntimeManager getDefault() {
+ return instance;
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ instance = this;
+ this.context = context;
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ instance = null;
+ this.context = null;
+ }
+
+ public BundleContext getContext() {
+ return context;
+ }
- public BundleContext getContext() {
- return context;
- }
-
-
-}
+}
diff --git a/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/SafeWorkspaceTracker.java b/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/SafeWorkspaceTracker.java
index 03ab00884d7..c77364a80bc 100644
--- a/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/SafeWorkspaceTracker.java
+++ b/plugins/org.eclipse.osee.ote.runtimeManager/src/org/eclipse/osee/ote/runtimemanager/SafeWorkspaceTracker.java
@@ -39,7 +39,6 @@ import org.eclipse.osee.ote.runtimemanager.container.OteClasspathContainer;
import org.eclipse.osee.ote.runtimemanager.internal.ProjectChangeResourceListener;
import org.eclipse.osee.ote.runtimemanager.internal.RuntimeBundleServer;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
@@ -49,236 +48,236 @@ import org.osgi.util.tracker.ServiceTracker;
*/
public class SafeWorkspaceTracker extends ServiceTracker implements OteBundleLocator {
- private JarChangeResourceListener<OteSystemLibsNature> systemLibResourceListener;
- private JarChangeResourceListener<OteUserLibsNature> userLibResourceListener;
- private LibJarListener<OteSystemLibsNature> systemLibListener;
- private LibJarListener<OteUserLibsNature> userLibListener;
- private ProjectChangeResourceListener projectChangeResourceListener;
- private RuntimeBundleServer bundleServer;
- private SafeWorkspaceAccess service;
- private final BundleContext context;
-
- /**
- * @param context
- * @param filter
- * @param customizer
- */
- public SafeWorkspaceTracker(BundleContext context) {
- super(context, SafeWorkspaceAccess.class.getName(), null);
- this.context = context;
- }
-
- @Override
- public Object addingService(ServiceReference reference) {
- this.systemLibListener = new LibJarListener<OteSystemLibsNature>();
- this.userLibListener = new LibJarListener<OteUserLibsNature>();
- this.systemLibResourceListener =
- new JarChangeResourceListener<OteSystemLibsNature>(OteSystemLibsNature.NATURE_ID, systemLibListener);
- this.userLibResourceListener =
- new JarChangeResourceListener<OteUserLibsNature>(OteUserLibsNature.NATURE_ID, userLibListener);
- this.projectChangeResourceListener = new ProjectChangeResourceListener();
- service = (SafeWorkspaceAccess) context.getService(reference);
- slowLoadingJars();
-
- return super.addingService(reference);
- }
-
- /**
+ private JarChangeResourceListener<OteSystemLibsNature> systemLibResourceListener;
+ private JarChangeResourceListener<OteUserLibsNature> userLibResourceListener;
+ private LibJarListener<OteSystemLibsNature> systemLibListener;
+ private LibJarListener<OteUserLibsNature> userLibListener;
+ private ProjectChangeResourceListener projectChangeResourceListener;
+ private RuntimeBundleServer bundleServer;
+ private SafeWorkspaceAccess service;
+ private final BundleContext context;
+
+ /**
+ * @param context
+ * @param filter
+ * @param customizer
+ */
+ public SafeWorkspaceTracker(BundleContext context) {
+ super(context, SafeWorkspaceAccess.class.getName(), null);
+ this.context = context;
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference) {
+ this.systemLibListener = new LibJarListener<OteSystemLibsNature>();
+ this.userLibListener = new LibJarListener<OteUserLibsNature>();
+ this.systemLibResourceListener =
+ new JarChangeResourceListener<OteSystemLibsNature>(OteSystemLibsNature.NATURE_ID, systemLibListener);
+ this.userLibResourceListener =
+ new JarChangeResourceListener<OteUserLibsNature>(OteUserLibsNature.NATURE_ID, userLibListener);
+ this.projectChangeResourceListener = new ProjectChangeResourceListener();
+ service = (SafeWorkspaceAccess) context.getService(reference);
+ slowLoadingJars();
+
+ return super.addingService(reference);
+ }
+
+ /**
*
*/
- private void slowLoadingJars() {
- Jobs.runInJob(new LocateWorkspaceBundles("Locating Workspace Bundles", RuntimeManager.BUNDLE_ID), false);
-
- }
-
- private class LocateWorkspaceBundles extends AbstractOperation {
- /**
- * @param operationName
- * @param pluginId
- */
- public LocateWorkspaceBundles(String operationName, String pluginId) {
- super(operationName, pluginId);
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- IWorkspace workspace = service.getWorkspace();
- try {
- scrapeAllLibs();
- } catch (CoreException ex) {
- OseeLog.log(RuntimeManager.class, Level.SEVERE, ex);
- } catch (BundleException ex) {
- OseeLog.log(RuntimeManager.class, Level.SEVERE, ex);
- }
- workspace.addResourceChangeListener(systemLibResourceListener);
- workspace.addResourceChangeListener(userLibResourceListener);
-
- SafeWorkspaceTracker.this.bundleServer = new RuntimeBundleServer(SafeWorkspaceTracker.this);
-
- context.registerService(OteBundleLocator.class.getName(), SafeWorkspaceTracker.this, new Hashtable());
- OteClasspathContainer.refreshAll();
- }
- }
-
- private void scrapeAllLibs() throws CoreException, BundleException {
- for (OteSystemLibsNature nature : OteSystemLibsNature.getWorkspaceProjects()) {
- for (URL url : nature.getBundles()) {
- systemLibListener.handleBundleAdded(url);
- }
-
- projectChangeResourceListener.addProject(nature.getProject());
- }
- for (OteUserLibsNature nature : OteUserLibsNature.getWorkspaceProjects()) {
- for (URL url : nature.getBundles()) {
- userLibListener.handleBundleAdded(url);
- }
-
- projectChangeResourceListener.addProject(nature.getProject());
- }
- }
-
- @Override
- public synchronized void close() {
- IWorkspace workspace = service.getWorkspace();
- if (workspace != null) {
- workspace.removeResourceChangeListener(systemLibResourceListener);
- workspace.removeResourceChangeListener(userLibResourceListener);
- }
- super.close();
- }
-
- /**
- * Returns a list of URL's to workspace jars to be used for the test server.
- * The collection returned is a combination of all the user libraries and
- * any system libraries that weren't already supplied in the user libraries.
- * The workspace is considered to have runtime libraries only if there are
- * system libraries present. Subsequently, if no system libraries are in the
- * workspace then this method will return an empty collection.
- *
- * @return runtime library bundle infos
- * @throws IOException
- * @throws CoreException
- */
- public Collection<BundleInfo> getRuntimeLibs() throws IOException, CoreException {
- Collection<URL> userLibUrls = getUserLibUrls();
- Collection<URL> systemLibUrls = getSystemLibUrls();
- // If there are no system libs, then claim no runtime libs
- if (!systemLibUrls.isEmpty()) {
- return getRuntimeLibs(systemLibUrls, userLibUrls);
- } else {
- return Collections.emptyList();
- }
- }
-
- private Collection<BundleInfo> getRuntimeLibs(Collection<URL> systemLibUrls, Collection<URL> userLibUrls) throws IOException {
- Map<String, BundleInfo> runtimeMap = new HashMap<String, BundleInfo>();
- Collection<BundleInfo> runtimeInfos = new LinkedList<BundleInfo>();
-
- // First add all of the system libraries to the map
- for (URL url : systemLibUrls) {
- String symbolicName = getBundleNameFromJar(url);
-
- runtimeMap.put(symbolicName, new BundleInfo(url, bundleServer.getClassServerPath(), true));
- }
-
- // Now add the user libraries so any system library with the same name
- // gets replaced
- for (URL url : userLibUrls) {
- String symbolicName = getBundleNameFromJar(url);
-
- runtimeMap.put(symbolicName, new BundleInfo(url, bundleServer.getClassServerPath(), false));
- }
-
- runtimeInfos.addAll(runtimeMap.values());
-
- return runtimeInfos;
- }
-
- /**
- * Returns a list of URL's to all system libraries in the workspace
- * regardless of ones that are supplied in user libraries.
- *
- * @return system library URL's
- * @throws CoreException
- */
- public Collection<URL> getSystemLibUrls() throws CoreException {
- Collection<URL> libs = new LinkedList<URL>();
- for (OteSystemLibsNature systemNature : OteSystemLibsNature.getWorkspaceProjects()) {
- libs.addAll(systemNature.getBundles());
- }
-
- return libs;
- }
-
- /**
- * Returns a list of URL's to all user libraries in the workspace.
- *
- * @return user library URL's
- * @throws CoreException
- */
- public Collection<URL> getUserLibUrls() throws CoreException {
- Collection<URL> libs = new LinkedList<URL>();
- for (OteUserLibsNature userNature : OteUserLibsNature.getWorkspaceProjects()) {
- libs.addAll(userNature.getBundles());
- }
-
- return libs;
- }
-
- /**
- * @param url
- * @return
- * @throws IOException
- */
- private String getBundleNameFromJar(URL url) throws IOException {
- File file;
- try {
- file = new File(url.toURI());
- } catch (URISyntaxException ex) {
- file = new File(url.getPath());
- }
-
- JarFile jarFile = new JarFile(file);
- Manifest jarManifest = jarFile.getManifest();
- return BundleInfo.generateBundleName(jarManifest);
- }
-
- /**
- * Returns a list of all bundles that have been modified since the last time
- * this was called.
- *
- * @throws CoreException
- * @throws IOException
- */
- public Collection<BundleInfo> consumeModifiedLibs() throws IOException, CoreException {
- Collection<BundleInfo> modifiedLibs = new LinkedList<BundleInfo>();
-
- Set<URL> sysNewBundles = systemLibListener.consumeNewBundles();
- Set<URL> sysChangedBundles = systemLibListener.consumeChangedBundles();
- Set<URL> sysRemovedBundles = systemLibListener.consumeRemovedBundles();
-
- Set<URL> userNewBundles = userLibListener.consumeNewBundles();
- Set<URL> userChangedBundles = userLibListener.consumeChangedBundles();
- Set<URL> userRemovedBundles = userLibListener.consumeRemovedBundles();
-
- Collection<URL> sysNewModLibs = new ArrayList<URL>(sysNewBundles.size() + sysChangedBundles.size());
- sysNewModLibs.addAll(sysNewBundles);
- sysNewModLibs.addAll(sysChangedBundles);
-
- Collection<URL> userNewModLibs = new ArrayList<URL>(userNewBundles.size() + userChangedBundles.size());
- userNewModLibs.addAll(userNewBundles);
- userNewModLibs.addAll(userChangedBundles);
-
- // TODO what about removed libs?
- return getRuntimeLibs(sysNewModLibs, userNewModLibs);
-
- // // For now, return all user libs
- // for (BundleInfo info : getRuntimeLibs()) {
- // if (!info.isSystemLibrary()) {
- // modifiedLibs.add(info);
- // }
- // }
- //
- // return modifiedLibs;
- }
+ private void slowLoadingJars() {
+ Jobs.runInJob(new LocateWorkspaceBundles("Locating Workspace Bundles", RuntimeManager.BUNDLE_ID), false);
+
+ }
+
+ private class LocateWorkspaceBundles extends AbstractOperation {
+ /**
+ * @param operationName
+ * @param pluginId
+ */
+ public LocateWorkspaceBundles(String operationName, String pluginId) {
+ super(operationName, pluginId);
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ IWorkspace workspace = service.getWorkspace();
+ try {
+ scrapeAllLibs();
+ } catch (CoreException ex) {
+ OseeLog.log(RuntimeManager.class, Level.SEVERE, ex);
+ }
+ workspace.addResourceChangeListener(systemLibResourceListener);
+ workspace.addResourceChangeListener(userLibResourceListener);
+
+ SafeWorkspaceTracker.this.bundleServer = new RuntimeBundleServer(SafeWorkspaceTracker.this);
+
+ context.registerService(OteBundleLocator.class.getName(), SafeWorkspaceTracker.this, new Hashtable());
+ OteClasspathContainer.refreshAll();
+ }
+ }
+
+ private void scrapeAllLibs() throws CoreException {
+ for (OteSystemLibsNature nature : OteSystemLibsNature.getWorkspaceProjects()) {
+ for (URL url : nature.getBundles()) {
+ systemLibListener.handleBundleAdded(url);
+ }
+
+ projectChangeResourceListener.addProject(nature.getProject());
+ }
+ for (OteUserLibsNature nature : OteUserLibsNature.getWorkspaceProjects()) {
+ for (URL url : nature.getBundles()) {
+ userLibListener.handleBundleAdded(url);
+ }
+
+ projectChangeResourceListener.addProject(nature.getProject());
+ }
+ }
+
+ @Override
+ public synchronized void close() {
+ IWorkspace workspace = service.getWorkspace();
+ if (workspace != null) {
+ workspace.removeResourceChangeListener(systemLibResourceListener);
+ workspace.removeResourceChangeListener(userLibResourceListener);
+ }
+ super.close();
+ }
+
+ /**
+ * Returns a list of URL's to workspace jars to be used for the test server. The collection returned is a combination
+ * of all the user libraries and any system libraries that weren't already supplied in the user libraries. The
+ * workspace is considered to have runtime libraries only if there are system libraries present. Subsequently, if no
+ * system libraries are in the workspace then this method will return an empty collection.
+ *
+ * @return runtime library bundle infos
+ * @throws IOException
+ * @throws CoreException
+ */
+ @Override
+ public Collection<BundleInfo> getRuntimeLibs() throws IOException, CoreException {
+ Collection<URL> userLibUrls = getUserLibUrls();
+ Collection<URL> systemLibUrls = getSystemLibUrls();
+ // If there are no system libs, then claim no runtime libs
+ if (!systemLibUrls.isEmpty()) {
+ return getRuntimeLibs(systemLibUrls, userLibUrls);
+ } else {
+ return Collections.emptyList();
+ }
+ }
+
+ private Collection<BundleInfo> getRuntimeLibs(Collection<URL> systemLibUrls, Collection<URL> userLibUrls) throws IOException {
+ Map<String, BundleInfo> runtimeMap = new HashMap<String, BundleInfo>();
+ Collection<BundleInfo> runtimeInfos = new LinkedList<BundleInfo>();
+
+ // First add all of the system libraries to the map
+ for (URL url : systemLibUrls) {
+ String symbolicName = getBundleNameFromJar(url);
+
+ runtimeMap.put(symbolicName, new BundleInfo(url, bundleServer.getClassServerPath(), true));
+ }
+
+ // Now add the user libraries so any system library with the same name
+ // gets replaced
+ for (URL url : userLibUrls) {
+ String symbolicName = getBundleNameFromJar(url);
+
+ runtimeMap.put(symbolicName, new BundleInfo(url, bundleServer.getClassServerPath(), false));
+ }
+
+ runtimeInfos.addAll(runtimeMap.values());
+
+ return runtimeInfos;
+ }
+
+ /**
+ * Returns a list of URL's to all system libraries in the workspace regardless of ones that are supplied in user
+ * libraries.
+ *
+ * @return system library URL's
+ * @throws CoreException
+ */
+ public Collection<URL> getSystemLibUrls() throws CoreException {
+ Collection<URL> libs = new LinkedList<URL>();
+ for (OteSystemLibsNature systemNature : OteSystemLibsNature.getWorkspaceProjects()) {
+ libs.addAll(systemNature.getBundles());
+ }
+
+ return libs;
+ }
+
+ /**
+ * Returns a list of URL's to all user libraries in the workspace.
+ *
+ * @return user library URL's
+ * @throws CoreException
+ */
+ public Collection<URL> getUserLibUrls() throws CoreException {
+ Collection<URL> libs = new LinkedList<URL>();
+ for (OteUserLibsNature userNature : OteUserLibsNature.getWorkspaceProjects()) {
+ libs.addAll(userNature.getBundles());
+ }
+
+ return libs;
+ }
+
+ /**
+ * @param url
+ * @return
+ * @throws IOException
+ */
+ private String getBundleNameFromJar(URL url) throws IOException {
+ File file;
+ try {
+ file = new File(url.toURI());
+ } catch (URISyntaxException ex) {
+ file = new File(url.getPath());
+ }
+
+ JarFile jarFile = new JarFile(file);
+ Manifest jarManifest = jarFile.getManifest();
+ return BundleInfo.generateBundleName(jarManifest);
+ }
+
+ /**
+ * Returns a list of all bundles that have been modified since the last time this was called.
+ *
+ * @throws CoreException
+ * @throws IOException
+ */
+ @Override
+ public Collection<BundleInfo> consumeModifiedLibs() throws IOException {
+ // Collection<BundleInfo> modifiedLibs = new LinkedList<BundleInfo>();
+
+ Set<URL> sysNewBundles = systemLibListener.consumeNewBundles();
+ Set<URL> sysChangedBundles = systemLibListener.consumeChangedBundles();
+ // Set<URL> sysRemovedBundles =
+ systemLibListener.consumeRemovedBundles();
+
+ Set<URL> userNewBundles = userLibListener.consumeNewBundles();
+ Set<URL> userChangedBundles = userLibListener.consumeChangedBundles();
+ // Set<URL> userRemovedBundles =
+ userLibListener.consumeRemovedBundles();
+
+ Collection<URL> sysNewModLibs = new ArrayList<URL>(sysNewBundles.size() + sysChangedBundles.size());
+ sysNewModLibs.addAll(sysNewBundles);
+ sysNewModLibs.addAll(sysChangedBundles);
+
+ Collection<URL> userNewModLibs = new ArrayList<URL>(userNewBundles.size() + userChangedBundles.size());
+ userNewModLibs.addAll(userNewBundles);
+ userNewModLibs.addAll(userChangedBundles);
+
+ // TODO what about removed libs?
+ return getRuntimeLibs(sysNewModLibs, userNewModLibs);
+
+ // // For now, return all user libs
+ // for (BundleInfo info : getRuntimeLibs()) {
+ // if (!info.isSystemLibrary()) {
+ // modifiedLibs.add(info);
+ // }
+ // }
+ //
+ // return modifiedLibs;
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/dialogs/ReportsDialog.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/dialogs/ReportsDialog.java
index a6816c8b2ae..88f30d85277 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/dialogs/ReportsDialog.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/dialogs/ReportsDialog.java
@@ -38,6 +38,7 @@ import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.osee.ote.define.jobs.RemoteResourceRequestJob;
@@ -61,7 +62,6 @@ 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.Label;
import org.eclipse.swt.widgets.Shell;
@@ -71,446 +71,449 @@ import org.eclipse.swt.widgets.Text;
* @author Roberto E. Escobar
*/
public class ReportsDialog extends TitleAreaDialog {
- private static final Image MESSAGE_IMAGE = ImageManager.getImage(OteDefineImage.COMMIT_WIZ);
- private static final Image TITLE_BAR_IMAGE = ImageManager.getImage(OteDefineImage.COMMIT);
-
- private static final String MESSAGE_TITLE = "Select a report";
- private static final String TITLE_BAR_TEXT = "OSEE Test Run Reports";
- private static final String MESSAGE = "The preview window displays an example of the selected report.";
- private static final String REPORT_SELECTION_TITLE = "Select a Report";
- private static final String PREVIEW_TITLE = "Preview";
- private static final String FORMAT_TITLE = "Select a Format";
- private static final String REPORT_DESCRIPTION = "Report Description";
- private static final String PREVIEW_DESCRIPTION = "Enter Preview Size";
-
- private static final String REPORT_STORE_ID = ReportsDialog.class.getName() + ".reportId";
- private static final String FORMAT_STORE_ID = ReportsDialog.class.getName() + ".formatId";
- private static final String PREVIEW_SIZE_STORE_ID = ReportsDialog.class.getName() + ".previewSize";
-
- private static final int DEFAULT_PREVIEW_SIZE = 5;
-
- private PreviewPanel previewPanel;
- private org.eclipse.osee.ote.ui.define.panels.ListSelectionPanel listSelectionPanel;
- private SelectionChangedListener selectionChangedListener;
- private Text descriptionArea;
- private Text previewSizeArea;
- private String selectedReportId;
- private OutputFormat selectedReportFormat;
- private final List<IFile> filesToDelete;
- private Map<OutputFormat, Button> formatButtons;
-
- public ReportsDialog(Shell parent) {
- super(parent);
- this.filesToDelete = new ArrayList<IFile>();
- setShellStyle(SWT.SHELL_TRIM);
- }
-
- @Override
- protected Control createButtonBar(Composite parent) {
- Label separator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
- separator.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
- return super.createButtonBar(parent);
- }
-
- /*
- * @see Dialog#createDialogArea(Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite content = (Composite) super.createDialogArea(parent);
-
- Composite composite = new Composite(content, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setFont(parent.getFont());
-
- SashForm sash = new SashForm(composite, SWT.HORIZONTAL);
- sash.setLayout(new GridLayout());
- sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- sash.setFont(parent.getFont());
-
- createReportSelectionArea(sash);
-
- Composite panel = new Composite(sash, SWT.NONE);
- GridLayout gL1 = new GridLayout();
- gL1.marginHeight = 0;
- gL1.marginWidth = 0;
- panel.setLayout(gL1);
- panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- createFormatAndDescriptionArea(panel);
- createPreviewArea(panel);
- sash.setWeights(new int[] {1, 2});
-
- setTitle(MESSAGE_TITLE);
- setTitleImage(MESSAGE_IMAGE);
- setMessage(MESSAGE);
- getShell().setText(TITLE_BAR_TEXT);
- getShell().setImage(TITLE_BAR_IMAGE);
- attachListeners();
- restoreDialog();
- return sash;
- }
-
- private void restoreDialog() {
- IDialogSettings settings = OteUiDefinePlugin.getInstance().getDialogSettings();
- if (settings != null) {
- String reportSelected = settings.get(REPORT_STORE_ID);
- String format = settings.get(FORMAT_STORE_ID);
-
- int value = 0;
- try {
- value = settings.getInt(PREVIEW_SIZE_STORE_ID);
- } catch (Exception ex) {
- value = DEFAULT_PREVIEW_SIZE;
- }
- clamp(previewSizeArea, value);
-
- OutputFormat outputFormat = OutputFormat.HTML;
- int index = 0;
- if (Strings.isValid(reportSelected) && Strings.isValid(format)) {
- Pair<String, String> pair = ExtensionDefinedReports.getInstance().getIdAndName(reportSelected);
- index = listSelectionPanel.indexOf(pair);
- outputFormat = OutputFormat.fromString(format);
- }
- if (index > -1) {
- listSelectionPanel.setSelection(index);
- }
- setReportFormat(outputFormat);
- for (OutputFormat key : formatButtons.keySet()) {
- Button button = formatButtons.get(key);
- button.setSelection(key.equals(outputFormat));
- }
- }
- }
-
- private void saveDialog() {
- IDialogSettings settings = OteUiDefinePlugin.getInstance().getDialogSettings();
- if (settings != null) {
- String reportSelected = getReportSelected();
- String format = getReportFormat();
- int previewSize = getPreviewSize();
- settings.put(REPORT_STORE_ID, reportSelected);
- settings.put(FORMAT_STORE_ID, format);
- settings.put(PREVIEW_SIZE_STORE_ID, previewSize);
- }
- }
-
- @Override
- protected void okPressed() {
- saveDialog();
- cleanUp(filesToDelete);
- super.okPressed();
- }
-
- private void createReportSelectionArea(Composite parent) {
- Group composite = new Group(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setFont(parent.getFont());
- composite.setText(REPORT_SELECTION_TITLE);
-
- listSelectionPanel = new ListSelectionPanel(composite, SWT.NONE, 300, 300, new ListLabelProvider());
- listSelectionPanel.setSorter(new ViewerSorter() {
-
- @Override
- @SuppressWarnings("unchecked")
- public int compare(Viewer viewer, Object o1, Object o2) {
- Pair<String, String> pair1 = (Pair<String, String>) o1;
- Pair<String, String> pair2 = (Pair<String, String>) o2;
- return getComparator().compare(pair1.getSecond(), pair2.getSecond());
- }
-
- });
- Pair<String, String>[] reportNames = ExtensionDefinedReports.getInstance().getIdsAndNames();
- listSelectionPanel.setInput(reportNames);
- listSelectionPanel.setSelection(0);
- }
-
- private void createFormatAndDescriptionArea(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout gL = new GridLayout(2, false);
- gL.marginHeight = 0;
- gL.marginWidth = 0;
- composite.setLayout(gL);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- createFormatArea(composite);
-
- Composite panel = new Composite(composite, SWT.NONE);
- GridLayout gL1 = new GridLayout();
- gL1.marginHeight = 0;
- gL1.marginWidth = 0;
- panel.setLayout(gL1);
- panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- createDescriptionArea(panel);
- createPreviewSizeArea(panel);
- }
-
- private void createPreviewSizeArea(Composite parent) {
- Group group = new Group(parent, SWT.NONE);
- group.setLayout(new GridLayout(2, false));
- group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- group.setFont(parent.getFont());
- group.setText(PREVIEW_DESCRIPTION);
-
- previewSizeArea = new Text(group, SWT.SINGLE | SWT.BORDER);
- previewSizeArea.setTextLimit(2);
- GridData gd = new GridData(SWT.RIGHT, SWT.FILL, false, false);
- gd.heightHint = convertHeightInCharsToPixels(1);
- gd.widthHint = convertWidthInCharsToPixels(4);
- previewSizeArea.setLayoutData(gd);
- new Widgets.IntegerTextEntryHandler(previewSizeArea, false, 2) {
- @Override
- public void applyValue(long value) {
- clamp(previewSizeArea, value);
- }
- };
-
- Label label = new Label(group, SWT.NONE);
- label.setText("[ 0-10 ]");
- label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- }
-
- private void clamp(Text text, long value) {
- if (value < 0) {
- previewSizeArea.setText(Integer.toString(0));
- }
- if (value > 10) {
- previewSizeArea.setText(Integer.toString(10));
- }
- }
-
- private void createDescriptionArea(Composite parent) {
- Group group = new Group(parent, SWT.NONE);
- group.setLayout(new GridLayout());
- group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- group.setFont(parent.getFont());
- group.setText(REPORT_DESCRIPTION);
-
- descriptionArea = new Text(group, SWT.WRAP | SWT.MULTI);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
- gd.heightHint = 100;
- gd.widthHint = 100;
- descriptionArea.setLayoutData(gd);
- descriptionArea.setEditable(false);
- }
-
- private void createFormatArea(Composite parent) {
- Group group = new Group(parent, SWT.NONE);
- group.setLayout(new GridLayout());
- group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
- group.setFont(parent.getFont());
- group.setText(FORMAT_TITLE);
-
- this.formatButtons = new HashMap<OutputFormat, Button>();
- for (OutputFormat format : OutputFormat.values()) {
- Button button = new Button(group, SWT.RADIO);
- button.setText(format.name());
- button.setData(format);
- if (format.equals(OutputFormat.HTML)) {
- button.setSelection(true);
- }
- button.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- Button button = (Button) e.getSource();
- if (button.getSelection() != false) {
- setReportFormat((OutputFormat) button.getData());
- }
- }
- });
- formatButtons.put(format, button);
- }
- }
-
- private void createPreviewArea(Composite parent) {
- Group group = new Group(parent, SWT.NONE);
- group.setLayout(new GridLayout());
- group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- group.setFont(parent.getFont());
- group.setText(PREVIEW_TITLE);
- previewPanel = new PreviewPanel(group, SWT.NONE);
- }
-
- private void attachListeners() {
- listSelectionPanel.addDoubleClickListener(new IDoubleClickListener() {
- @SuppressWarnings("unchecked")
- public void doubleClick(DoubleClickEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- if (selection != null) {
- Pair<String, String> item = (Pair<String, String>) selection.getFirstElement();
- if (item != null) {
- selectedReportId = item.getFirst();
- }
- }
- okPressed();
- }
- });
-
- selectionChangedListener = new SelectionChangedListener();
- listSelectionPanel.addSelectionChangedListener(selectionChangedListener);
- }
-
- public String getReportSelected() {
- return selectedReportId;
- }
-
- public String getReportFormat() {
- return selectedReportFormat.name();
- }
-
- private void setReportFormat(OutputFormat reportFormat) {
- this.selectedReportFormat = reportFormat;
- selectionChangedListener.selectionChanged(null);
- }
-
- private PanelEnum asPanelEnum(OutputFormat format) {
- PanelEnum toReturn = PanelEnum.DEFAULT;
- switch (format) {
- case HTML:
- case PDF:
- case EXCEL:
- case RTF:
- toReturn = PanelEnum.BROWSER;
- break;
- default:
- toReturn = PanelEnum.DEFAULT;
- break;
- }
- return toReturn;
- }
-
- private void updatePanel(final PanelEnum panelId, final URI uri, final String description, final List<IFile> oldIFiles) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- previewPanel.updatePreview(panelId, uri);
- previewPanel.setDisplay(panelId);
- descriptionArea.setText(description);
- }
- });
- cleanUp(oldIFiles);
- }
-
- private int getPreviewSize() {
- int toReturn = DEFAULT_PREVIEW_SIZE;
- String value = previewSizeArea.getText();
- try {
- toReturn = Integer.parseInt(value);
- } catch (Exception ex) {
- toReturn = DEFAULT_PREVIEW_SIZE;
- updatePreviewSizeValue(toReturn);
- }
- return toReturn;
- }
-
- private void updatePreviewSizeValue(final int value) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- previewSizeArea.setText(Integer.toString(value));
- }
- });
- }
-
- private void generatePreview(final OutputFormat outputFormat, final String reportId, final ITestRunReport report) throws URISyntaxException, OseeStateException {
- String urlRequest = HttpReportRequest.getUrl(reportId, outputFormat.name(), "local", getPreviewSize());
- String fileName = OutputFactory.getOutputFilename(outputFormat, reportId);
- switch (outputFormat) {
- case HTML:
- updatePanel(asPanelEnum(outputFormat), new URI(urlRequest), report.getDescription(), filesToDelete);
- break;
- default:
- remoteFileToLocal(outputFormat, urlRequest, fileName, report);
- break;
- }
- }
-
- private void remoteFileToLocal(final OutputFormat outputFormat, final String urlRequest, final String fileName, final ITestRunReport report) {
- RemoteResourceRequestJob requestJob = new RemoteResourceRequestJob(urlRequest, fileName);
- requestJob.addJobChangeListener(new PreviewUpdateJobChangeListener(report, outputFormat));
- requestJob.getDownloadedFile();
- requestJob.schedule();
- }
-
- private final class SelectionChangedListener implements ISelectionChangedListener {
- @SuppressWarnings("unchecked")
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = listSelectionPanel.getSelection();
- if (selection != null) {
- Pair<String, String> item = (Pair<String, String>) selection.getFirstElement();
- if (item != null) {
- ITestRunReport report = ExtensionDefinedReports.getInstance().getReportGenerator(item.getFirst());
- if (report != null) {
- selectedReportId = item.getFirst();
- try {
- generatePreview(selectedReportFormat, selectedReportId, report);
- } catch (Exception ex) {
- OseeLog.log(OteUiDefinePlugin.class, Level.SEVERE, ex);
- }
- }
- }
- }
- }
- }
-
- private final class ListLabelProvider extends LabelProvider {
-
- @SuppressWarnings("unchecked")
- @Override
- public Image getImage(Object element) {
- Image toReturn = null;
- if (element instanceof Pair) {
- toReturn = ExtensionDefinedReports.getInstance().getImage(((Pair<String, String>) element).getFirst());
- }
- return toReturn;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public String getText(Object element) {
- if (element instanceof Pair) {
- return ((Pair<String, String>) element).getSecond();
- }
- return super.getText(element);
- }
- }
-
- private final class PreviewUpdateJobChangeListener extends JobChangeAdapter {
- private final ITestRunReport report;
- private final OutputFormat format;
-
- private PreviewUpdateJobChangeListener(ITestRunReport report, OutputFormat format) {
- this.report = report;
- this.format = format;
- }
-
- @Override
- public void done(IJobChangeEvent event) {
- IStatus status = event.getResult();
- if (status.equals(Status.OK_STATUS) || status.getCode() == Status.OK) {
- IFile iFile = ((RemoteResourceRequestJob) event.getJob()).getDownloadedFile();
- if (iFile != null) {
- updatePanel(asPanelEnum(format), iFile.getLocationURI(), report.getDescription(), filesToDelete);
- filesToDelete.add(iFile);
- }
- }
- }
- }
-
- private void cleanUp(final List<IFile> iFiles) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- for (IFile iFile : iFiles) {
- if (iFile != null && iFile.exists()) {
- try {
- iFile.delete(true, new NullProgressMonitor());
- filesToDelete.remove(iFile);
- } catch (CoreException ex) {
- // Do Nothing
- }
- }
- }
- }
- });
- }
+ private static final Image MESSAGE_IMAGE = ImageManager.getImage(OteDefineImage.COMMIT_WIZ);
+ private static final Image TITLE_BAR_IMAGE = ImageManager.getImage(OteDefineImage.COMMIT);
+
+ private static final String MESSAGE_TITLE = "Select a report";
+ private static final String TITLE_BAR_TEXT = "OSEE Test Run Reports";
+ private static final String MESSAGE = "The preview window displays an example of the selected report.";
+ private static final String REPORT_SELECTION_TITLE = "Select a Report";
+ private static final String PREVIEW_TITLE = "Preview";
+ private static final String FORMAT_TITLE = "Select a Format";
+ private static final String REPORT_DESCRIPTION = "Report Description";
+ private static final String PREVIEW_DESCRIPTION = "Enter Preview Size";
+
+ private static final String REPORT_STORE_ID = ReportsDialog.class.getName() + ".reportId";
+ private static final String FORMAT_STORE_ID = ReportsDialog.class.getName() + ".formatId";
+ private static final String PREVIEW_SIZE_STORE_ID = ReportsDialog.class.getName() + ".previewSize";
+
+ private static final int DEFAULT_PREVIEW_SIZE = 5;
+
+ private PreviewPanel previewPanel;
+ private org.eclipse.osee.ote.ui.define.panels.ListSelectionPanel listSelectionPanel;
+ private SelectionChangedListener selectionChangedListener;
+ private Text descriptionArea;
+ private Text previewSizeArea;
+ private String selectedReportId;
+ private OutputFormat selectedReportFormat;
+ private final List<IFile> filesToDelete;
+ private Map<OutputFormat, Button> formatButtons;
+
+ public ReportsDialog(Shell parent) {
+ super(parent);
+ this.filesToDelete = new ArrayList<IFile>();
+ setShellStyle(SWT.SHELL_TRIM);
+ }
+
+ @Override
+ protected Control createButtonBar(Composite parent) {
+ Label separator = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
+ return super.createButtonBar(parent);
+ }
+
+ /*
+ * @see Dialog#createDialogArea(Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite content = (Composite) super.createDialogArea(parent);
+
+ Composite composite = new Composite(content, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ composite.setFont(parent.getFont());
+
+ SashForm sash = new SashForm(composite, SWT.HORIZONTAL);
+ sash.setLayout(new GridLayout());
+ sash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ sash.setFont(parent.getFont());
+
+ createReportSelectionArea(sash);
+
+ Composite panel = new Composite(sash, SWT.NONE);
+ GridLayout gL1 = new GridLayout();
+ gL1.marginHeight = 0;
+ gL1.marginWidth = 0;
+ panel.setLayout(gL1);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ createFormatAndDescriptionArea(panel);
+ createPreviewArea(panel);
+ sash.setWeights(new int[] {1, 2});
+
+ setTitle(MESSAGE_TITLE);
+ setTitleImage(MESSAGE_IMAGE);
+ setMessage(MESSAGE);
+ getShell().setText(TITLE_BAR_TEXT);
+ getShell().setImage(TITLE_BAR_IMAGE);
+ attachListeners();
+ restoreDialog();
+ return sash;
+ }
+
+ private void restoreDialog() {
+ IDialogSettings settings = OteUiDefinePlugin.getInstance().getDialogSettings();
+ if (settings != null) {
+ String reportSelected = settings.get(REPORT_STORE_ID);
+ String format = settings.get(FORMAT_STORE_ID);
+
+ int value = 0;
+ try {
+ value = settings.getInt(PREVIEW_SIZE_STORE_ID);
+ } catch (Exception ex) {
+ value = DEFAULT_PREVIEW_SIZE;
+ }
+ clamp(previewSizeArea, value);
+
+ OutputFormat outputFormat = OutputFormat.HTML;
+ int index = 0;
+ if (Strings.isValid(reportSelected) && Strings.isValid(format)) {
+ Pair<String, String> pair = ExtensionDefinedReports.getInstance().getIdAndName(reportSelected);
+ index = listSelectionPanel.indexOf(pair);
+ outputFormat = OutputFormat.fromString(format);
+ }
+ if (index > -1) {
+ listSelectionPanel.setSelection(index);
+ }
+ setReportFormat(outputFormat);
+ for (OutputFormat key : formatButtons.keySet()) {
+ Button button = formatButtons.get(key);
+ button.setSelection(key.equals(outputFormat));
+ }
+ }
+ }
+
+ private void saveDialog() {
+ IDialogSettings settings = OteUiDefinePlugin.getInstance().getDialogSettings();
+ if (settings != null) {
+ String reportSelected = getReportSelected();
+ String format = getReportFormat();
+ int previewSize = getPreviewSize();
+ settings.put(REPORT_STORE_ID, reportSelected);
+ settings.put(FORMAT_STORE_ID, format);
+ settings.put(PREVIEW_SIZE_STORE_ID, previewSize);
+ }
+ }
+
+ @Override
+ protected void okPressed() {
+ saveDialog();
+ cleanUp(filesToDelete);
+ super.okPressed();
+ }
+
+ private void createReportSelectionArea(Composite parent) {
+ Group composite = new Group(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ composite.setFont(parent.getFont());
+ composite.setText(REPORT_SELECTION_TITLE);
+
+ listSelectionPanel = new ListSelectionPanel(composite, SWT.NONE, 300, 300, new ListLabelProvider());
+ listSelectionPanel.setSorter(new ViewerSorter() {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public int compare(Viewer viewer, Object o1, Object o2) {
+ Pair<String, String> pair1 = (Pair<String, String>) o1;
+ Pair<String, String> pair2 = (Pair<String, String>) o2;
+ return getComparator().compare(pair1.getSecond(), pair2.getSecond());
+ }
+
+ });
+ Pair<String, String>[] reportNames = ExtensionDefinedReports.getInstance().getIdsAndNames();
+ listSelectionPanel.setInput(reportNames);
+ listSelectionPanel.setSelection(0);
+ }
+
+ private void createFormatAndDescriptionArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gL = new GridLayout(2, false);
+ gL.marginHeight = 0;
+ gL.marginWidth = 0;
+ composite.setLayout(gL);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ createFormatArea(composite);
+
+ Composite panel = new Composite(composite, SWT.NONE);
+ GridLayout gL1 = new GridLayout();
+ gL1.marginHeight = 0;
+ gL1.marginWidth = 0;
+ panel.setLayout(gL1);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ createDescriptionArea(panel);
+ createPreviewSizeArea(panel);
+ }
+
+ private void createPreviewSizeArea(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout(2, false));
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ group.setFont(parent.getFont());
+ group.setText(PREVIEW_DESCRIPTION);
+
+ previewSizeArea = new Text(group, SWT.SINGLE | SWT.BORDER);
+ previewSizeArea.setTextLimit(2);
+ GridData gd = new GridData(SWT.RIGHT, SWT.FILL, false, false);
+ gd.heightHint = convertHeightInCharsToPixels(1);
+ gd.widthHint = convertWidthInCharsToPixels(4);
+ previewSizeArea.setLayoutData(gd);
+ new Widgets.IntegerTextEntryHandler(previewSizeArea, false, 2) {
+ @Override
+ public void applyValue(long value) {
+ clamp(previewSizeArea, value);
+ }
+ };
+
+ Label label = new Label(group, SWT.NONE);
+ label.setText("[ 0-10 ]");
+ label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ }
+
+ private void clamp(Text text, long value) {
+ if (value < 0) {
+ previewSizeArea.setText(Integer.toString(0));
+ }
+ if (value > 10) {
+ previewSizeArea.setText(Integer.toString(10));
+ }
+ }
+
+ private void createDescriptionArea(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ group.setFont(parent.getFont());
+ group.setText(REPORT_DESCRIPTION);
+
+ descriptionArea = new Text(group, SWT.WRAP | SWT.MULTI);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.heightHint = 100;
+ gd.widthHint = 100;
+ descriptionArea.setLayoutData(gd);
+ descriptionArea.setEditable(false);
+ }
+
+ private void createFormatArea(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ group.setFont(parent.getFont());
+ group.setText(FORMAT_TITLE);
+
+ this.formatButtons = new HashMap<OutputFormat, Button>();
+ for (OutputFormat format : OutputFormat.values()) {
+ Button button = new Button(group, SWT.RADIO);
+ button.setText(format.name());
+ button.setData(format);
+ if (format.equals(OutputFormat.HTML)) {
+ button.setSelection(true);
+ }
+ button.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Button button = (Button) e.getSource();
+ if (button.getSelection() != false) {
+ setReportFormat((OutputFormat) button.getData());
+ }
+ }
+ });
+ formatButtons.put(format, button);
+ }
+ }
+
+ private void createPreviewArea(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ group.setFont(parent.getFont());
+ group.setText(PREVIEW_TITLE);
+ previewPanel = new PreviewPanel(group, SWT.NONE);
+ }
+
+ private void attachListeners() {
+ listSelectionPanel.addDoubleClickListener(new IDoubleClickListener() {
+ @SuppressWarnings("unchecked")
+ public void doubleClick(DoubleClickEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ if (selection != null) {
+ Pair<String, String> item = (Pair<String, String>) selection.getFirstElement();
+ if (item != null) {
+ selectedReportId = item.getFirst();
+ }
+ }
+ okPressed();
+ }
+ });
+
+ selectionChangedListener = new SelectionChangedListener();
+ listSelectionPanel.addSelectionChangedListener(selectionChangedListener);
+ }
+
+ public String getReportSelected() {
+ return selectedReportId;
+ }
+
+ public String getReportFormat() {
+ return selectedReportFormat.name();
+ }
+
+ private void setReportFormat(OutputFormat reportFormat) {
+ this.selectedReportFormat = reportFormat;
+ selectionChangedListener.selectionChanged(null);
+ }
+
+ private PanelEnum asPanelEnum(OutputFormat format) {
+ PanelEnum toReturn = PanelEnum.DEFAULT;
+ switch (format) {
+ case HTML:
+ case PDF:
+ case EXCEL:
+ case RTF:
+ toReturn = PanelEnum.BROWSER;
+ break;
+ default:
+ toReturn = PanelEnum.DEFAULT;
+ break;
+ }
+ return toReturn;
+ }
+
+ private void updatePanel(final PanelEnum panelId, final URI uri, final String description, final List<IFile> oldIFiles) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ previewPanel.updatePreview(panelId, uri);
+ previewPanel.setDisplay(panelId);
+ descriptionArea.setText(description);
+ }
+ });
+ cleanUp(oldIFiles);
+ }
+
+ private int getPreviewSize() {
+ int toReturn = DEFAULT_PREVIEW_SIZE;
+ String value = previewSizeArea.getText();
+ try {
+ toReturn = Integer.parseInt(value);
+ } catch (Exception ex) {
+ toReturn = DEFAULT_PREVIEW_SIZE;
+ updatePreviewSizeValue(toReturn);
+ }
+ return toReturn;
+ }
+
+ private void updatePreviewSizeValue(final int value) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ previewSizeArea.setText(Integer.toString(value));
+ }
+ });
+ }
+
+ private void generatePreview(final OutputFormat outputFormat, final String reportId, final ITestRunReport report) throws URISyntaxException, OseeStateException {
+ String urlRequest = HttpReportRequest.getUrl(reportId, outputFormat.name(), "local", getPreviewSize());
+ String fileName = OutputFactory.getOutputFilename(outputFormat, reportId);
+ switch (outputFormat) {
+ case HTML:
+ updatePanel(asPanelEnum(outputFormat), new URI(urlRequest), report.getDescription(), filesToDelete);
+ break;
+ default:
+ remoteFileToLocal(outputFormat, urlRequest, fileName, report);
+ break;
+ }
+ }
+
+ private void remoteFileToLocal(final OutputFormat outputFormat, final String urlRequest, final String fileName, final ITestRunReport report) {
+ RemoteResourceRequestJob requestJob = new RemoteResourceRequestJob(urlRequest, fileName);
+ requestJob.addJobChangeListener(new PreviewUpdateJobChangeListener(report, outputFormat));
+ requestJob.getDownloadedFile();
+ requestJob.schedule();
+ }
+
+ private final class SelectionChangedListener implements ISelectionChangedListener {
+ @SuppressWarnings("unchecked")
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = listSelectionPanel.getSelection();
+ if (selection != null) {
+ Pair<String, String> item = (Pair<String, String>) selection.getFirstElement();
+ if (item != null) {
+ ITestRunReport report = ExtensionDefinedReports.getInstance().getReportGenerator(item.getFirst());
+ if (report != null) {
+ selectedReportId = item.getFirst();
+ try {
+ generatePreview(selectedReportFormat, selectedReportId, report);
+ } catch (Exception ex) {
+ OseeLog.log(OteUiDefinePlugin.class, Level.SEVERE, ex);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private final class ListLabelProvider extends LabelProvider {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Image getImage(Object element) {
+ Image toReturn = null;
+ if (element instanceof Pair) {
+ toReturn = ExtensionDefinedReports.getInstance().getImage(((Pair<String, String>) element).getFirst());
+ }
+ return toReturn;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public String getText(Object element) {
+ if (element instanceof Pair) {
+ return ((Pair<String, String>) element).getSecond();
+ }
+ return super.getText(element);
+ }
+ }
+
+ private final class PreviewUpdateJobChangeListener extends JobChangeAdapter {
+ private final ITestRunReport report;
+ private final OutputFormat format;
+
+ private PreviewUpdateJobChangeListener(ITestRunReport report, OutputFormat format) {
+ this.report = report;
+ this.format = format;
+ }
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ IStatus status = event.getResult();
+ if (status.equals(Status.OK_STATUS) || status.getCode() == Status.OK) {
+ IFile iFile = ((RemoteResourceRequestJob) event.getJob()).getDownloadedFile();
+ if (iFile != null) {
+ updatePanel(asPanelEnum(format), iFile.getLocationURI(), report.getDescription(), filesToDelete);
+ filesToDelete.add(iFile);
+ }
+ }
+ }
+ }
+
+ private void cleanUp(final List<IFile> iFiles) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ for (IFile iFile : iFiles) {
+ if (iFile != null && iFile.exists()) {
+ try {
+ iFile.delete(true, new NullProgressMonitor());
+ filesToDelete.remove(iFile);
+ } catch (CoreException ex) {
+ // Do Nothing
+ }
+ }
+ }
+ }
+ });
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/importer/ImportOutfileUIOperation.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/importer/ImportOutfileUIOperation.java
index be5399e3bdc..bd7eda8597b 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/importer/ImportOutfileUIOperation.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/importer/ImportOutfileUIOperation.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.define.importer;
-
+package org.eclipse.osee.ote.ui.define.importer;
+
import java.net.URI;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -18,108 +18,108 @@ import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.define.jobs.FindCommitableJob;
import org.eclipse.osee.ote.define.jobs.OutfileToArtifactJob;
import org.eclipse.osee.ote.ui.define.jobs.CommitTestRunJob;
import org.eclipse.osee.ote.ui.define.jobs.ReportErrorsJob;
import org.eclipse.osee.ote.ui.define.utilities.CommitConfiguration;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ImportOutfileUIOperation {
-
- private URI[] fileSystemObjects;
- private Branch selectedBranch;
-
- public ImportOutfileUIOperation(Branch selectedBranch, URI... fileSystemObjects) {
- this.fileSystemObjects = fileSystemObjects;
- this.selectedBranch = selectedBranch;
- }
-
- public boolean execute() {
- boolean toReturn = true;
- if (fileSystemObjects.length > 0) {
- launchImportJob();
- } else {
- toReturn = false;
- Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
- MessageDialog.openInformation(shell, "Information", "There were no resources currently selected for import.");
- }
- return toReturn;
- }
-
- private void launchImportJob() {
- OutfileToArtifactJob convertJob = new OutfileToArtifactJob(selectedBranch, fileSystemObjects);
- convertJob.addJobChangeListener(new JobChangeAdapter() {
-
- @Override
- public void done(IJobChangeEvent event) {
- if (wasJobSuccessful(event)) {
- OutfileToArtifactJob job = (OutfileToArtifactJob) event.getJob();
-
- URI[] itemsWithError = job.getUnparseableFiles();
- Artifact[] artifacts = job.getResults();
- // Report Parse Errors
- if (itemsWithError.length > 0) {
- reportFilesWithErrors(itemsWithError, artifacts);
- } else {
- launchFindCommitableJob(artifacts);
- }
- }
- }
- });
- convertJob.schedule();
- }
-
- private void launchCommitJob(final FindCommitableJob job) {
- Display.getDefault().asyncExec(new Runnable() {
-
- public void run() {
- CommitTestRunJob newJob =
- new CommitTestRunJob(job.getAll(), job.getCommitAllowed(), job.getCommitNotAllowed(),
- CommitConfiguration.isCommitOverrideAllowed());
- newJob.schedule();
- }
- });
- }
-
- private void launchFindCommitableJob(final Artifact[] artifacts) {
- // Find Commit Allowed
- FindCommitableJob commitableJob = new FindCommitableJob(artifacts);
- commitableJob.addJobChangeListener(new JobChangeAdapter() {
-
- @Override
- public void done(IJobChangeEvent event) {
- if (wasJobSuccessful(event)) {
- FindCommitableJob job = (FindCommitableJob) event.getJob();
- launchCommitJob(job);
- }
- }
- });
- commitableJob.schedule();
- }
-
- private void reportFilesWithErrors(final Object[] items, final Artifact[] artifacts) {
- String title = "Outfile Import Error";
- String message = "The following file(s) had errors during the parsing operation: ";
-
- JobChangeAdapter listener = new JobChangeAdapter() {
-
- @Override
- public void done(IJobChangeEvent event) {
- launchFindCommitableJob(artifacts);
- }
- };
-
- ReportErrorsJob.openError(title, message, listener, items);
- }
-
- private boolean wasJobSuccessful(IJobChangeEvent event) {
- IStatus status = event.getResult();
- return status.equals(Status.OK_STATUS) || status.equals(Status.OK);
- }
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ImportOutfileUIOperation {
+
+ private final URI[] fileSystemObjects;
+ private final Branch selectedBranch;
+
+ public ImportOutfileUIOperation(Branch selectedBranch, URI... fileSystemObjects) {
+ this.fileSystemObjects = fileSystemObjects;
+ this.selectedBranch = selectedBranch;
+ }
+
+ public boolean execute() {
+ boolean toReturn = true;
+ if (fileSystemObjects.length > 0) {
+ launchImportJob();
+ } else {
+ toReturn = false;
+ Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ MessageDialog.openInformation(shell, "Information", "There were no resources currently selected for import.");
+ }
+ return toReturn;
+ }
+
+ private void launchImportJob() {
+ OutfileToArtifactJob convertJob = new OutfileToArtifactJob(selectedBranch, fileSystemObjects);
+ convertJob.addJobChangeListener(new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ if (wasJobSuccessful(event)) {
+ OutfileToArtifactJob job = (OutfileToArtifactJob) event.getJob();
+
+ URI[] itemsWithError = job.getUnparseableFiles();
+ Artifact[] artifacts = job.getResults();
+ // Report Parse Errors
+ if (itemsWithError.length > 0) {
+ reportFilesWithErrors(itemsWithError, artifacts);
+ } else {
+ launchFindCommitableJob(artifacts);
+ }
+ }
+ }
+ });
+ convertJob.schedule();
+ }
+
+ private void launchCommitJob(final FindCommitableJob job) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ CommitTestRunJob newJob =
+ new CommitTestRunJob(job.getAll(), job.getCommitAllowed(), job.getCommitNotAllowed(),
+ CommitConfiguration.isCommitOverrideAllowed());
+ newJob.schedule();
+ }
+ });
+ }
+
+ private void launchFindCommitableJob(final Artifact[] artifacts) {
+ // Find Commit Allowed
+ FindCommitableJob commitableJob = new FindCommitableJob(artifacts);
+ commitableJob.addJobChangeListener(new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ if (wasJobSuccessful(event)) {
+ FindCommitableJob job = (FindCommitableJob) event.getJob();
+ launchCommitJob(job);
+ }
+ }
+ });
+ commitableJob.schedule();
+ }
+
+ private void reportFilesWithErrors(final Object[] items, final Artifact[] artifacts) {
+ String title = "Outfile Import Error";
+ String message = "The following file(s) had errors during the parsing operation: ";
+
+ JobChangeAdapter listener = new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ launchFindCommitableJob(artifacts);
+ }
+ };
+
+ ReportErrorsJob.openError(title, message, listener, items);
+ }
+
+ private boolean wasJobSuccessful(IJobChangeEvent event) {
+ IStatus status = event.getResult();
+ return status.equals(Status.OK_STATUS) || status.equals(Status.OK);
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/jobs/ReportErrorsJob.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/jobs/ReportErrorsJob.java
index cdb3a364455..0ad10beee3a 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/jobs/ReportErrorsJob.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/jobs/ReportErrorsJob.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.define.jobs;
-
+package org.eclipse.osee.ote.ui.define.jobs;
+
import java.util.Arrays;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -17,85 +17,87 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.UIJob;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ReportErrorsJob extends UIJob {
-
- private Object[] objectsWithErrors;
- private String message;
-
- private ReportErrorsJob(String title, String message, Object... objectsWithErrors) {
- super(title);
- setUser(false);
- setPriority(LONG);
- this.objectsWithErrors = objectsWithErrors;
- this.message = message;
- }
-
- public IStatus runInUIThread(IProgressMonitor monitor) {
- final String errorMessage = Arrays.deepToString(objectsWithErrors).replaceAll(",", ",\n");
- Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
- ResourceErrorDialog dialog = new ResourceErrorDialog(shell, getName(), message, errorMessage);
- dialog.open();
- return Status.OK_STATUS;
- }
-
- public static void openError(final String title, final String message, final Object... objectsWithErrors) {
- openError(title, message, null, objectsWithErrors);
- }
-
- public static void openError(final String title, final String message, final IJobChangeListener listener, final Object... objectsWithErrors) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- ReportErrorsJob errorDialog = new ReportErrorsJob(title, message, objectsWithErrors);
- if (listener != null) {
- errorDialog.addJobChangeListener(listener);
- }
- errorDialog.schedule();
- }
- });
- }
- private final class ResourceErrorDialog extends MessageDialog {
-
- private String errorMessage;
-
- public ResourceErrorDialog(Shell parentShell, String dialogTitle, String dialogMessage, String errorMessage) {
- super(parentShell, dialogTitle, PlatformUI.getWorkbench().getSharedImages().getImage(
- ISharedImages.IMG_OBJS_ERROR_TSK), dialogMessage, MessageDialog.ERROR,
- new String[] {IDialogConstants.OK_LABEL}, 0);
- this.errorMessage = errorMessage;
- }
-
- @Override
- protected Control createCustomArea(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setLayout(new GridLayout());
-
- Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
- data.heightHint = 300;
- data.widthHint = 300;
- data.minimumWidth = 300;
- data.minimumHeight = 300;
- text.setLayoutData(data);
- text.setEditable(false);
- text.setText(errorMessage);
- text.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_WHITE));
- return composite;
- }
- }
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ReportErrorsJob extends UIJob {
+
+ private final Object[] objectsWithErrors;
+ private final String message;
+
+ private ReportErrorsJob(String title, String message, Object... objectsWithErrors) {
+ super(title);
+ setUser(false);
+ setPriority(LONG);
+ this.objectsWithErrors = objectsWithErrors;
+ this.message = message;
+ }
+
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ final String errorMessage = Arrays.deepToString(objectsWithErrors).replaceAll(",", ",\n");
+ Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ ResourceErrorDialog dialog = new ResourceErrorDialog(shell, getName(), message, errorMessage);
+ dialog.open();
+ return Status.OK_STATUS;
+ }
+
+ public static void openError(final String title, final String message, final Object... objectsWithErrors) {
+ openError(title, message, null, objectsWithErrors);
+ }
+
+ public static void openError(final String title, final String message, final IJobChangeListener listener, final Object... objectsWithErrors) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ ReportErrorsJob errorDialog = new ReportErrorsJob(title, message, objectsWithErrors);
+ if (listener != null) {
+ errorDialog.addJobChangeListener(listener);
+ }
+ errorDialog.schedule();
+ }
+ });
+ }
+ private final class ResourceErrorDialog extends MessageDialog {
+
+ private final String errorMessage;
+
+ public ResourceErrorDialog(Shell parentShell, String dialogTitle, String dialogMessage, String errorMessage) {
+ super(parentShell, dialogTitle, PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_OBJS_ERROR_TSK), dialogMessage, MessageDialog.ERROR,
+ new String[] {IDialogConstants.OK_LABEL}, 0);
+ this.errorMessage = errorMessage;
+ }
+
+ @Override
+ protected Control createCustomArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ composite.setLayout(new GridLayout());
+
+ Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);
+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
+ data.heightHint = 300;
+ data.widthHint = 300;
+ data.minimumWidth = 300;
+ data.minimumHeight = 300;
+ text.setLayoutData(data);
+ text.setEditable(false);
+ text.setText(errorMessage);
+ text.setBackground(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ return composite;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/GrayableBranchSelectionComposite.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/GrayableBranchSelectionComposite.java
index 38245a9193c..de94b1893ab 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/GrayableBranchSelectionComposite.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/GrayableBranchSelectionComposite.java
@@ -17,8 +17,8 @@ import org.eclipse.osee.framework.skynet.core.event.IAccessControlEventListener;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.event2.AccessControlEvent;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.panels.BranchSelectSimpleComposite;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.SelectionAdapter;
@@ -28,7 +28,6 @@ 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.Label;
import org.eclipse.ui.ISharedImages;
@@ -39,180 +38,182 @@ import org.eclipse.ui.PlatformUI;
*/
public class GrayableBranchSelectionComposite extends Composite implements IAccessControlEventListener {
- private static final String GROUP_TEXT = "Upload results into OSEE";
- private static final String CHECK_BUTTON_TEXT = "Enable upload";
- private static final String CHECK_BUTTON_TOOL_TIP =
- "Select to store outfiles as Test Run Artifacts.\n" + "NOTE: User must be authenticated to create Artifacts.";
- private static final String AUTHENTICATION_WARNING_MESSAGE =
- "Authentication failure - Outfile upload not allowed. Double-Click on the lock icon at the bottom of the screen to authenticate.";
- private static final String FEATURE_DISABLED = "Feature disabled.";
-
- private BranchSelectSimpleComposite branchSelectComposite;
- private Button branchSelectEnabled;
- private Composite statusComposite;
- private Composite selectableComposite;
- private Label statusLabel;
- private StackLayout stackedLayout;
- private Group group;
- private boolean featureEnabled;
-
- public GrayableBranchSelectionComposite(Composite parent, int style) {
- super(parent, style);
- createControl(this);
- }
-
- @Override
- public void handleAccessControlArtifactsEvent(Sender sender, AccessControlEvent accessControlEvent) {
- if (accessControlEvent.getEventType() == AccessControlEventType.UserAuthenticated) {
- handleUserAuthenticated();
- }
- }
-
- private void createControl(Composite parent) {
- GridLayout gL = new GridLayout();
- gL.marginWidth = 0;
- gL.marginHeight = 0;
- parent.setLayout(gL);
- parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- group = new Group(parent, SWT.NONE);
- group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- stackedLayout = new StackLayout();
- group.setLayout(stackedLayout);
- group.setText(GROUP_TEXT);
-
- createStatusBar(group);
- createSelectableArea(group);
- handleBranchSelectEnabled(false);
- OseeEventManager.addListener(this);
- }
-
- private void createSelectableArea(Composite parent) {
- selectableComposite = new Composite(parent, SWT.NONE);
- selectableComposite.setLayout(new GridLayout());
- selectableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- branchSelectEnabled = new Button(selectableComposite, SWT.CHECK);
- branchSelectEnabled.setText(CHECK_BUTTON_TEXT);
- branchSelectEnabled.setToolTipText(CHECK_BUTTON_TOOL_TIP);
-
- branchSelectEnabled.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleBranchSelectEnabled(branchSelectEnabled.getSelection());
- }
- });
- this.branchSelectComposite =
- BranchSelectSimpleComposite.createWorkingBranchSelectComposite(selectableComposite, SWT.NONE);
- }
-
- private void createStatusBar(Composite parent) {
- statusComposite = new Composite(parent, SWT.BORDER);
- statusComposite.setLayout(new GridLayout(2, false));
- statusComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
- statusComposite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- statusComposite.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
-
- Label imageLabel = new Label(statusComposite, SWT.NONE);
- imageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
- imageLabel.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
- imageLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- imageLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
-
- statusLabel = new Label(statusComposite, SWT.NONE);
- statusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- statusLabel.setText("");
- statusLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- statusLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
- }
-
- private void handleBranchSelectEnabled(boolean isSelected) {
- setSelectable(true);
- if (ClientSessionManager.isSessionValid() != true) {
- statusLabel.setText(AUTHENTICATION_WARNING_MESSAGE);
- setSelectable(false);
- isSelected = false;
- }
- branchSelectEnabled.setSelection(isSelected);
- branchSelectComposite.setEnabled(isSelected);
- for (Control control : branchSelectComposite.getChildren()) {
- control.setEnabled(isSelected);
- }
- }
-
- public Branch getSelectedBranch() {
- return branchSelectComposite.getSelectedBranch();
- }
-
- public boolean isBranchSelectEnabled() {
- return branchSelectEnabled.getSelection();
- }
-
- public void setFeatureEnabled(final boolean isEnabled) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- featureEnabled = isEnabled;
- handleBranchSelectEnabled(false);
- statusLabel.setText(featureEnabled != true ? FEATURE_DISABLED : "");
- setEnabled(featureEnabled);
- setSelectable(featureEnabled);
- }
- });
- }
-
- private boolean isFeatureEnabled() {
- return featureEnabled;
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- for (Control child : group.getChildren()) {
- child.setEnabled(enabled);
- }
- branchSelectEnabled.setEnabled(enabled);
- }
-
- public String[] getBranchIds() {
- return branchSelectComposite.getBranchIds();
- }
-
- public void restoreWidgetValues(boolean saveAsArtifact, String[] branchIds, String lastSelected) {
- branchSelectEnabled.setSelection(saveAsArtifact && ClientSessionManager.isSessionValid());
- branchSelectComposite.restoreWidgetValues(branchIds, lastSelected);
- }
-
- private void setSelectable(final boolean isSelectable) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (isSelectable != false) {
- stackedLayout.topControl = selectableComposite;
- } else {
- stackedLayout.topControl = statusComposite;
- }
- group.layout();
- }
- });
- }
-
- @Override
- public void dispose() {
- OseeEventManager.removeListener(this);
- super.dispose();
- }
-
- private void handleUserAuthenticated() {
- Displays.ensureInDisplayThread(new Runnable() {
- @Override
- public void run() {
- if (branchSelectEnabled != null && branchSelectEnabled.isDisposed() != true && isFeatureEnabled() != false) {
- handleBranchSelectEnabled(branchSelectEnabled.getSelection());
- }
- }
- });
- }
-
- public boolean runOnEventInDisplayThread() {
- return true;
- }
+ private static final String GROUP_TEXT = "Upload results into OSEE";
+ private static final String CHECK_BUTTON_TEXT = "Enable upload";
+ private static final String CHECK_BUTTON_TOOL_TIP =
+ "Select to store outfiles as Test Run Artifacts.\n" + "NOTE: User must be authenticated to create Artifacts.";
+ private static final String AUTHENTICATION_WARNING_MESSAGE =
+ "Authentication failure - Outfile upload not allowed. Double-Click on the lock icon at the bottom of the screen to authenticate.";
+ private static final String FEATURE_DISABLED = "Feature disabled.";
+
+ private BranchSelectSimpleComposite branchSelectComposite;
+ private Button branchSelectEnabled;
+ private Composite statusComposite;
+ private Composite selectableComposite;
+ private Label statusLabel;
+ private StackLayout stackedLayout;
+ private Group group;
+ private boolean featureEnabled;
+
+ public GrayableBranchSelectionComposite(Composite parent, int style) {
+ super(parent, style);
+ createControl(this);
+ }
+
+ @Override
+ public void handleAccessControlArtifactsEvent(Sender sender, AccessControlEvent accessControlEvent) {
+ if (accessControlEvent.getEventType() == AccessControlEventType.UserAuthenticated) {
+ handleUserAuthenticated();
+ }
+ }
+
+ private void createControl(Composite parent) {
+ GridLayout gL = new GridLayout();
+ gL.marginWidth = 0;
+ gL.marginHeight = 0;
+ parent.setLayout(gL);
+ parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ group = new Group(parent, SWT.NONE);
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ stackedLayout = new StackLayout();
+ group.setLayout(stackedLayout);
+ group.setText(GROUP_TEXT);
+
+ createStatusBar(group);
+ createSelectableArea(group);
+ handleBranchSelectEnabled(false);
+ OseeEventManager.addListener(this);
+ }
+
+ private void createSelectableArea(Composite parent) {
+ selectableComposite = new Composite(parent, SWT.NONE);
+ selectableComposite.setLayout(new GridLayout());
+ selectableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ branchSelectEnabled = new Button(selectableComposite, SWT.CHECK);
+ branchSelectEnabled.setText(CHECK_BUTTON_TEXT);
+ branchSelectEnabled.setToolTipText(CHECK_BUTTON_TOOL_TIP);
+
+ branchSelectEnabled.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleBranchSelectEnabled(branchSelectEnabled.getSelection());
+ }
+ });
+ this.branchSelectComposite =
+ BranchSelectSimpleComposite.createWorkingBranchSelectComposite(selectableComposite, SWT.NONE);
+ }
+
+ private void createStatusBar(Composite parent) {
+ statusComposite = new Composite(parent, SWT.BORDER);
+ statusComposite.setLayout(new GridLayout(2, false));
+ statusComposite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
+ statusComposite.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ statusComposite.setForeground(Displays.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+
+ Label imageLabel = new Label(statusComposite, SWT.NONE);
+ imageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
+ imageLabel.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
+ imageLabel.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ imageLabel.setForeground(Displays.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+
+ statusLabel = new Label(statusComposite, SWT.NONE);
+ statusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ statusLabel.setText("");
+ statusLabel.setBackground(Displays.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ statusLabel.setForeground(Displays.getSystemColor(SWT.COLOR_RED));
+ }
+
+ private void handleBranchSelectEnabled(boolean isSelected) {
+ setSelectable(true);
+ if (ClientSessionManager.isSessionValid() != true) {
+ statusLabel.setText(AUTHENTICATION_WARNING_MESSAGE);
+ setSelectable(false);
+ isSelected = false;
+ }
+ branchSelectEnabled.setSelection(isSelected);
+ branchSelectComposite.setEnabled(isSelected);
+ for (Control control : branchSelectComposite.getChildren()) {
+ control.setEnabled(isSelected);
+ }
+ }
+
+ public Branch getSelectedBranch() {
+ return branchSelectComposite.getSelectedBranch();
+ }
+
+ public boolean isBranchSelectEnabled() {
+ return branchSelectEnabled.getSelection();
+ }
+
+ public void setFeatureEnabled(final boolean isEnabled) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ featureEnabled = isEnabled;
+ handleBranchSelectEnabled(false);
+ statusLabel.setText(featureEnabled != true ? FEATURE_DISABLED : "");
+ setEnabled(featureEnabled);
+ setSelectable(featureEnabled);
+ }
+ });
+ }
+
+ private boolean isFeatureEnabled() {
+ return featureEnabled;
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ for (Control child : group.getChildren()) {
+ child.setEnabled(enabled);
+ }
+ branchSelectEnabled.setEnabled(enabled);
+ }
+
+ public String[] getBranchIds() {
+ return branchSelectComposite.getBranchIds();
+ }
+
+ public void restoreWidgetValues(boolean saveAsArtifact, String[] branchIds, String lastSelected) {
+ branchSelectEnabled.setSelection(saveAsArtifact && ClientSessionManager.isSessionValid());
+ branchSelectComposite.restoreWidgetValues(branchIds, lastSelected);
+ }
+
+ private void setSelectable(final boolean isSelectable) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (isSelectable != false) {
+ stackedLayout.topControl = selectableComposite;
+ } else {
+ stackedLayout.topControl = statusComposite;
+ }
+ group.layout();
+ }
+ });
+ }
+
+ @Override
+ public void dispose() {
+ OseeEventManager.removeListener(this);
+ super.dispose();
+ }
+
+ private void handleUserAuthenticated() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (branchSelectEnabled != null && branchSelectEnabled.isDisposed() != true && isFeatureEnabled() != false) {
+ handleBranchSelectEnabled(branchSelectEnabled.getSelection());
+ }
+ }
+ });
+ }
+
+ public boolean runOnEventInDisplayThread() {
+ return true;
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/PreviewPanel.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/PreviewPanel.java
index 501dfea4495..ea7780ba909 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/PreviewPanel.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/panels/PreviewPanel.java
@@ -8,11 +8,12 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.define.panels;
-
+package org.eclipse.osee.ote.ui.define.panels;
+
import java.net.URI;
import java.util.logging.Level;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.ui.define.OteUiDefinePlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
@@ -25,89 +26,90 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Roberto E. Escobar
- */
-public class PreviewPanel extends Composite {
- private static final String PREVIEW_DEFAULT_TITLE = "Preview Not Available";
-
- public enum PanelEnum {
- DEFAULT, BROWSER;
- }
-
- private Composite stackedComposite;
- private StackLayout stackLayout;
- private Composite defaultComposite;
- private Browser browser;
-
- public PreviewPanel(Composite parent, int style) {
- super(parent, style);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- this.setLayout(layout);
- this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- createControl(this);
- }
-
- private void createControl(Composite parent) {
- stackedComposite = new Composite(parent, SWT.BORDER);
- stackLayout = new StackLayout();
- stackLayout.marginWidth = 0;
- stackLayout.marginHeight = 0;
- stackedComposite.setLayout(stackLayout);
- stackedComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- createBrowserArea(stackedComposite);
- createPreviewNotAllowed(stackedComposite);
- }
-
- private void createBrowserArea(Composite parent) {
- browser = new Browser(parent, SWT.EMBEDDED | SWT.BORDER);
- browser.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
- browser.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
- }
-
- private void createPreviewNotAllowed(Composite parent) {
- defaultComposite = new Composite(parent, SWT.BORDER);
- defaultComposite.setLayout(new GridLayout());
- defaultComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- defaultComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- Label label = new Label(defaultComposite, SWT.NONE);
- Font font = new Font(PlatformUI.getWorkbench().getDisplay(), "Courier New", 10, SWT.BOLD);
- label.setFont(font);
- label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
- label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
- label.setText(PREVIEW_DEFAULT_TITLE);
- label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- private Control getControl(PanelEnum panelId) {
- Control control = defaultComposite;
- if (panelId.equals(PanelEnum.BROWSER)) {
- control = browser;
- }
- return control;
- }
-
- public void setDisplay(final PanelEnum panelId) {
- Control control = getControl(panelId);
- stackLayout.topControl = control;
- stackedComposite.layout();
- stackedComposite.getParent().layout();
- getParent().layout();
- getParent().getParent().layout();
- }
-
- public void updatePreview(final PanelEnum panelId, final URI uri) {
- try {
- if (panelId.equals(PanelEnum.BROWSER)) {
- browser.setUrl(uri.toURL().toString());
- }
- } catch (Exception ex) {
- OseeLog.log(OteUiDefinePlugin.class, Level.SEVERE, String.format("Error Updating Preview [%s]", panelId), ex);
- }
- }
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class PreviewPanel extends Composite {
+ private static final String PREVIEW_DEFAULT_TITLE = "Preview Not Available";
+
+ public enum PanelEnum {
+ DEFAULT,
+ BROWSER;
+ }
+
+ private Composite stackedComposite;
+ private StackLayout stackLayout;
+ private Composite defaultComposite;
+ private Browser browser;
+
+ public PreviewPanel(Composite parent, int style) {
+ super(parent, style);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ this.setLayout(layout);
+ this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ createControl(this);
+ }
+
+ private void createControl(Composite parent) {
+ stackedComposite = new Composite(parent, SWT.BORDER);
+ stackLayout = new StackLayout();
+ stackLayout.marginWidth = 0;
+ stackLayout.marginHeight = 0;
+ stackedComposite.setLayout(stackLayout);
+ stackedComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ createBrowserArea(stackedComposite);
+ createPreviewNotAllowed(stackedComposite);
+ }
+
+ private void createBrowserArea(Composite parent) {
+ browser = new Browser(parent, SWT.EMBEDDED | SWT.BORDER);
+ browser.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
+ browser.setBackground(Displays.getSystemColor(SWT.COLOR_GREEN));
+ }
+
+ private void createPreviewNotAllowed(Composite parent) {
+ defaultComposite = new Composite(parent, SWT.BORDER);
+ defaultComposite.setLayout(new GridLayout());
+ defaultComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ defaultComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+
+ Label label = new Label(defaultComposite, SWT.NONE);
+ Font font = new Font(PlatformUI.getWorkbench().getDisplay(), "Courier New", 10, SWT.BOLD);
+ label.setFont(font);
+ label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
+ label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
+ label.setText(PREVIEW_DEFAULT_TITLE);
+ label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
+ }
+
+ private Control getControl(PanelEnum panelId) {
+ Control control = defaultComposite;
+ if (panelId.equals(PanelEnum.BROWSER)) {
+ control = browser;
+ }
+ return control;
+ }
+
+ public void setDisplay(final PanelEnum panelId) {
+ Control control = getControl(panelId);
+ stackLayout.topControl = control;
+ stackedComposite.layout();
+ stackedComposite.getParent().layout();
+ getParent().layout();
+ getParent().getParent().layout();
+ }
+
+ public void updatePreview(final PanelEnum panelId, final URI uri) {
+ try {
+ if (panelId.equals(PanelEnum.BROWSER)) {
+ browser.setUrl(uri.toURL().toString());
+ }
+ } catch (Exception ex) {
+ OseeLog.log(OteUiDefinePlugin.class, Level.SEVERE, String.format("Error Updating Preview [%s]", panelId), ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/reports/HttpReportRequest.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/reports/HttpReportRequest.java
index 92140cc26a4..410f1fff885 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/reports/HttpReportRequest.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/reports/HttpReportRequest.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.define.reports;
-
+package org.eclipse.osee.ote.ui.define.reports;
+
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
@@ -26,6 +26,7 @@ import org.eclipse.osee.framework.core.client.server.IHttpServerRequest;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.define.artifacts.TestRunOperator;
import org.eclipse.osee.ote.ui.define.OteUiDefinePlugin;
import org.eclipse.osee.ote.ui.define.reports.output.IReportWriter;
@@ -33,133 +34,134 @@ import org.eclipse.osee.ote.ui.define.reports.output.OutputFactory;
import org.eclipse.osee.ote.ui.define.reports.output.OutputFormat;
import org.eclipse.osee.ote.ui.define.utilities.SelectionHelper;
import org.eclipse.osee.ote.ui.define.views.TestRunView;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @author Roberto E. Escobar
- */
-public class HttpReportRequest implements IHttpServerRequest {
- private static final String REQUEST_TYPE = "GET.REPORT";
- private static final String REPORT_ID = "id";
- private static final String REPORT_FORMAT = "format";
- private static final String REPORT_SOURCE = "source";
- private static final String PREVIEW_SIZE = "preview";
-
- public String getRequestType() {
- return REQUEST_TYPE;
- }
-
- public static String getUrl(String id, String format, String source) throws OseeStateException {
- return getUrl(id, format, source, -1);
- }
-
- public static String getUrl(String id, String format, String source, int preview) throws OseeStateException {
- Map<String, String> parameters = new HashMap<String, String>();
- parameters.put(REPORT_ID, id);
- parameters.put(REPORT_FORMAT, format);
- parameters.put(REPORT_SOURCE, source);
- if (preview > -1) {
- parameters.put(PREVIEW_SIZE, Integer.toString(preview));
- }
- return HttpUrlBuilderClient.getInstance().getUrlForLocalSkynetHttpServer(HttpReportRequest.REQUEST_TYPE, parameters);
- }
-
- public void processRequest(HttpRequest httpRequest, HttpResponse httpResponse) {
- if (httpRequest.getOriginatingAddress().isLoopbackAddress()) {
- String reportId = httpRequest.getParameter(REPORT_ID);
- String format = httpRequest.getParameter(REPORT_FORMAT);
-
- try {
- OutputFormat outputFormat = OutputFormat.fromString(format);
- ITestRunReport report = ExtensionDefinedReports.getInstance().getReportGenerator(reportId);
- report.gatherData(new NullProgressMonitor(), getSourceData(httpRequest));
-
- IReportWriter writer = OutputFactory.getReportWriter(outputFormat);
- writer.writeTitle(report.getTitle());
- writer.writeHeader(report.getHeader());
- String[][] body = report.getBody();
- for (int index = 0; index < body.length; index++) {
- writer.writeRow(body[index]);
- }
- report.clear();
-
- if (outputFormat.equals(OutputFormat.HTML) != true) {
- httpResponse.setReponseHeader("Accept-Ranges", "bytes");
- httpResponse.setContentEncoding("ISO-8859-1");
- String fileName = URLEncoder.encode(OutputFactory.getOutputFilename(outputFormat, reportId), "UTF-8");
- httpResponse.setContentDisposition(String.format("attachment; filename=%s", fileName));
- }
- httpResponse.setContentType(OutputFactory.getContentType(outputFormat));
- httpResponse.sendResponseHeaders(200, writer.length());
- writer.writeToOutput(httpResponse.getOutputStream());
-
- } catch (Exception ex) {
- handleException(httpRequest, httpResponse, ex);
- }
- }
- }
-
- private TestRunOperator[] getSourceData(HttpRequest httpRequest) {
- String source = httpRequest.getParameter(REPORT_SOURCE);
-
- List<TestRunOperator> toReturn = new ArrayList<TestRunOperator>();
- if (source.equals("local")) {
- LocalSourceSelection selection = new LocalSourceSelection();
- Display.getDefault().asyncExec(selection);
- TestRunOperator[] data = selection.getArtifacts();
- addData(httpRequest, data, toReturn);
- }
- return toReturn.toArray(new TestRunOperator[toReturn.size()]);
- }
-
- private void addData(HttpRequest httpRequest, TestRunOperator[] source, List<TestRunOperator> destination) {
- String previewSize = httpRequest.getParameter(PREVIEW_SIZE);
- if (Strings.isValid(previewSize)) {
- int size = 5;
- try {
- size = Integer.parseInt(previewSize);
- } catch (Exception ex) {
- size = 5;
- }
- if (size > source.length) {
- size = source.length;
- }
- for (int index = 0; index < size; index++) {
- destination.add(source[index]);
- }
- } else {
- destination.addAll(Arrays.asList(source));
- }
- }
-
- private void handleException(HttpRequest httpRequest, HttpResponse httpResponse, Exception ex) {
- OseeLog.log(OteUiDefinePlugin.class, Level.SEVERE, "Exception occurred.", ex);
- }
-
- private final class LocalSourceSelection implements Runnable {
-
- private TestRunOperator[] artifacts;
- private boolean done = false;
-
- public TestRunOperator[] getArtifacts() {
- while (this.isDone() != true)
- ;
- return artifacts;
- }
-
- public void run() {
- done = false;
- List<TestRunOperator> toReturn = new ArrayList<TestRunOperator>();
- StructuredViewer viewer = TestRunView.getViewer();
- if (viewer != null) {
- toReturn.addAll(SelectionHelper.getInstance().getSelections(viewer));
- }
- artifacts = toReturn.toArray(new TestRunOperator[toReturn.size()]);
- done = true;
- }
-
- public boolean isDone() {
- return done;
- }
- }
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class HttpReportRequest implements IHttpServerRequest {
+ private static final String REQUEST_TYPE = "GET.REPORT";
+ private static final String REPORT_ID = "id";
+ private static final String REPORT_FORMAT = "format";
+ private static final String REPORT_SOURCE = "source";
+ private static final String PREVIEW_SIZE = "preview";
+
+ public String getRequestType() {
+ return REQUEST_TYPE;
+ }
+
+ public static String getUrl(String id, String format, String source) throws OseeStateException {
+ return getUrl(id, format, source, -1);
+ }
+
+ public static String getUrl(String id, String format, String source, int preview) throws OseeStateException {
+ Map<String, String> parameters = new HashMap<String, String>();
+ parameters.put(REPORT_ID, id);
+ parameters.put(REPORT_FORMAT, format);
+ parameters.put(REPORT_SOURCE, source);
+ if (preview > -1) {
+ parameters.put(PREVIEW_SIZE, Integer.toString(preview));
+ }
+ return HttpUrlBuilderClient.getInstance().getUrlForLocalSkynetHttpServer(HttpReportRequest.REQUEST_TYPE,
+ parameters);
+ }
+
+ public void processRequest(HttpRequest httpRequest, HttpResponse httpResponse) {
+ if (httpRequest.getOriginatingAddress().isLoopbackAddress()) {
+ String reportId = httpRequest.getParameter(REPORT_ID);
+ String format = httpRequest.getParameter(REPORT_FORMAT);
+
+ try {
+ OutputFormat outputFormat = OutputFormat.fromString(format);
+ ITestRunReport report = ExtensionDefinedReports.getInstance().getReportGenerator(reportId);
+ report.gatherData(new NullProgressMonitor(), getSourceData(httpRequest));
+
+ IReportWriter writer = OutputFactory.getReportWriter(outputFormat);
+ writer.writeTitle(report.getTitle());
+ writer.writeHeader(report.getHeader());
+ String[][] body = report.getBody();
+ for (int index = 0; index < body.length; index++) {
+ writer.writeRow(body[index]);
+ }
+ report.clear();
+
+ if (outputFormat.equals(OutputFormat.HTML) != true) {
+ httpResponse.setReponseHeader("Accept-Ranges", "bytes");
+ httpResponse.setContentEncoding("ISO-8859-1");
+ String fileName = URLEncoder.encode(OutputFactory.getOutputFilename(outputFormat, reportId), "UTF-8");
+ httpResponse.setContentDisposition(String.format("attachment; filename=%s", fileName));
+ }
+ httpResponse.setContentType(OutputFactory.getContentType(outputFormat));
+ httpResponse.sendResponseHeaders(200, writer.length());
+ writer.writeToOutput(httpResponse.getOutputStream());
+
+ } catch (Exception ex) {
+ handleException(httpRequest, httpResponse, ex);
+ }
+ }
+ }
+
+ private TestRunOperator[] getSourceData(HttpRequest httpRequest) {
+ String source = httpRequest.getParameter(REPORT_SOURCE);
+
+ List<TestRunOperator> toReturn = new ArrayList<TestRunOperator>();
+ if (source.equals("local")) {
+ LocalSourceSelection selection = new LocalSourceSelection();
+ Displays.ensureInDisplayThread(selection);
+ TestRunOperator[] data = selection.getArtifacts();
+ addData(httpRequest, data, toReturn);
+ }
+ return toReturn.toArray(new TestRunOperator[toReturn.size()]);
+ }
+
+ private void addData(HttpRequest httpRequest, TestRunOperator[] source, List<TestRunOperator> destination) {
+ String previewSize = httpRequest.getParameter(PREVIEW_SIZE);
+ if (Strings.isValid(previewSize)) {
+ int size = 5;
+ try {
+ size = Integer.parseInt(previewSize);
+ } catch (Exception ex) {
+ size = 5;
+ }
+ if (size > source.length) {
+ size = source.length;
+ }
+ for (int index = 0; index < size; index++) {
+ destination.add(source[index]);
+ }
+ } else {
+ destination.addAll(Arrays.asList(source));
+ }
+ }
+
+ private void handleException(HttpRequest httpRequest, HttpResponse httpResponse, Exception ex) {
+ OseeLog.log(OteUiDefinePlugin.class, Level.SEVERE, "Exception occurred.", ex);
+ }
+
+ private final class LocalSourceSelection implements Runnable {
+
+ private TestRunOperator[] artifacts;
+ private boolean done = false;
+
+ public TestRunOperator[] getArtifacts() {
+ while (this.isDone() != true) {
+ ;
+ }
+ return artifacts;
+ }
+
+ public void run() {
+ done = false;
+ List<TestRunOperator> toReturn = new ArrayList<TestRunOperator>();
+ StructuredViewer viewer = TestRunView.getViewer();
+ if (viewer != null) {
+ toReturn.addAll(SelectionHelper.getInstance().getSelections(viewer));
+ }
+ artifacts = toReturn.toArray(new TestRunOperator[toReturn.size()]);
+ done = true;
+ }
+
+ public boolean isDone() {
+ return done;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/XViewerDataManager.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/XViewerDataManager.java
index 0b617214888..4081cb455b4 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/XViewerDataManager.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/XViewerDataManager.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.define.viewers;
-
+package org.eclipse.osee.ote.ui.define.viewers;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -24,250 +24,251 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.skynet.artifact.massEditor.MassXViewerFactory;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.define.artifacts.TestRunOperator;
import org.eclipse.osee.ote.ui.define.viewers.data.ArtifactItem;
import org.eclipse.osee.ote.ui.define.viewers.data.BranchItem;
import org.eclipse.osee.ote.ui.define.viewers.data.DataItem;
import org.eclipse.osee.ote.ui.define.viewers.data.ScriptItem;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TreeItem;
-
-/**
- * @author Roberto E. Escobar
- */
-public class XViewerDataManager {
-
- private final XViewer xViewer;
- private final List<DataItem> commitableItems;
- private final List<DataItem> uncommitableItems;
- private final Map<Branch, DataItem> branchMap;
- private final List<DataItem> backingData;
- private final Collection<IDataChangedListener> listeners;
- private boolean isInitialized;
-
- public XViewerDataManager(XViewer xViewer) {
- super();
- this.backingData = new ArrayList<DataItem>();
- this.isInitialized = false;
- this.xViewer = xViewer;
- this.branchMap = new HashMap<Branch, DataItem>();
- this.commitableItems = new ArrayList<DataItem>();
- this.uncommitableItems = new ArrayList<DataItem>();
- this.listeners = Collections.synchronizedSet(new HashSet<IDataChangedListener>());
- }
-
- private void ensureInitialized() {
- if (isInitialized != true) {
- isInitialized = true;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- xViewer.setInput(backingData);
- }
- });
- }
- }
-
- public void addArtifacts(IProgressMonitor monitor, final List<Artifact> artifacts) throws OseeCoreException, AttributeDoesNotExist {
- if (branchMap.isEmpty()) {
- if (xViewer.getXViewerFactory() instanceof MassXViewerFactory) {
- ((MassXViewerFactory) xViewer.getXViewerFactory()).registerAllAttributeColumnsForArtifacts(artifacts, true);
- }
- }
- int total = artifacts.size();
- for (int index = 0; index < artifacts.size(); index++) {
- Artifact artifact = artifacts.get(index);
- monitor.subTask(String.format("Adding to Table: [%s] [%s of %s]", artifact.getName(), index + 1,
- total));
-
- DataItem branchItem = getBranchItem(artifact);
- DataItem scriptItem = getScriptItem(branchItem, artifact);
-
- ArtifactItem tempItem = new ArtifactItem(xViewer, artifact, null);
-
- DataItem itemFound = scriptItem.getChild(tempItem.getKey());
- if (itemFound == null) {
- scriptItem.addChild(tempItem.getKey(), tempItem);
- tempItem.setParent(scriptItem);
- TestRunOperator operator = tempItem.getOperator();
- if (operator.isFromLocalWorkspace()) {
- if (operator.isCommitAllowed()) {
- commitableItems.add(tempItem);
- } else {
- uncommitableItems.add(tempItem);
- }
- }
- }
- monitor.worked(1);
- }
-
- refresh();
- }
-
- private void refresh() {
- ensureInitialized();
- notifyOnDataChanged();
-
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- xViewer.refresh();
- };
- });
- }
-
- private DataItem getScriptItem(DataItem branchItem, Artifact artifact) throws OseeCoreException {
- TestRunOperator testRunArtifact = new TestRunOperator(artifact);
- DataItem tempItem = new ScriptItem(testRunArtifact.getScriptUrl(), testRunArtifact.getScriptRevision(), null);
- DataItem scriptItem = branchItem.getChild(tempItem.getKey());
- if (scriptItem == null) {
- scriptItem = tempItem;
- scriptItem.setParent(branchItem);
- branchItem.addChild(scriptItem.getKey(), scriptItem);
- }
- return scriptItem;
- }
-
- private DataItem getBranchItem(Artifact artifact) {
- Branch branch = artifact.getBranch();
- DataItem toReturn = branchMap.get(branch);
- if (toReturn == null) {
- toReturn = new BranchItem(branch, null);
- branchMap.put(branch, toReturn);
- backingData.add(toReturn);
- }
- return toReturn;
- }
-
- private void removeHelper(DataItem item) {
- if (item != null) {
- DataItem parent = item.getParent();
- if (parent != null) {
- parent.removeChild(item);
- if (parent.hasChildren() != true) {
- removeHelper(parent);
- parent.dispose();
- }
- } else {
- branchMap.remove(item.getKey());
- backingData.remove(item);
- }
- }
- }
-
- public void removeSelected() {
- List<DataItem> items = getSelected();
- for (DataItem item : items) {
- removeHelper(item);
- item.dispose();
- commitableItems.remove(item);
- uncommitableItems.remove(item);
- }
- refresh();
- }
-
- public void removeAll() {
- commitableItems.clear();
- uncommitableItems.clear();
- for (DataItem dataItem : branchMap.values()) {
- dataItem.dispose();
- }
- branchMap.clear();
- backingData.clear();
- refresh();
- }
-
- public Control getControl() {
- return xViewer.getTree();
- }
-
- private List<DataItem> getSelected() {
- List<DataItem> toReturn = new ArrayList<DataItem>();
- TreeItem items[] = xViewer.getTree().getSelection();
- if (items.length > 0) {
- for (TreeItem item : items) {
- toReturn.add((DataItem) item.getData());
- }
- }
- return toReturn;
- }
-
- public List<Artifact> getSelectedArtifacts() {
- List<Artifact> toReturn = new ArrayList<Artifact>();
- for (DataItem item : getSelected()) {
- Object object = item.getData();
- if (object instanceof Artifact) {
- toReturn.add((Artifact) object);
- }
- }
- return toReturn;
- }
-
- public Artifact[] getUnCommitable() {
- return getArtifactsFromDataItemList(uncommitableItems);
- }
-
- public Artifact[] getAllCommitable() {
- return getArtifactsFromDataItemList(commitableItems);
- }
-
- private Artifact[] getArtifactsFromDataItemList(List<DataItem> sourceList) {
- List<Artifact> toReturn = new ArrayList<Artifact>();
- for (DataItem item : sourceList) {
- toReturn.add((Artifact) (item.getData()));
- }
- return toReturn.toArray(new Artifact[toReturn.size()]);
- }
-
- public Artifact[] getSelectedForCommit() {
- List<Artifact> toReturn = new ArrayList<Artifact>();
- for (DataItem item : getSelected()) {
- if (commitableItems.contains(item)) {
- toReturn.add((Artifact) (item.getData()));
- }
- }
- return toReturn.toArray(new Artifact[toReturn.size()]);
- }
-
- public void removeFromCommitable(final Collection<Artifact> artifacts) {
- removeArtifactsFromDataItemList(commitableItems, artifacts);
- removeArtifactsFromDataItemList(uncommitableItems, artifacts);
- refresh();
- }
-
- private void removeArtifactsFromDataItemList(List<DataItem> sourceList, final Collection<Artifact> artifactsToRemove) {
- List<DataItem> itemsToRemove = new ArrayList<DataItem>();
- for (DataItem item : sourceList) {
- Object object = item.getData();
- if (artifactsToRemove.contains(object)) {
- itemsToRemove.add(item);
- }
- }
- sourceList.removeAll(itemsToRemove);
- }
-
- private void notifyOnDataChanged() {
- synchronized (listeners) {
- for (IDataChangedListener listener : listeners) {
- listener.onDataChanged();
- }
- }
- }
-
- public void registerListener(IDataChangedListener listener) {
- synchronized (listeners) {
- listeners.add(listener);
- }
- }
-
- public void deRegisterListener(IDataChangedListener listener) {
- synchronized (listeners) {
- if (listeners.contains(listener)) {
- listeners.remove(listener);
- }
- }
- }
-
- public boolean isEmpty() {
- return branchMap.isEmpty();
- }
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class XViewerDataManager {
+
+ private final XViewer xViewer;
+ private final List<DataItem> commitableItems;
+ private final List<DataItem> uncommitableItems;
+ private final Map<Branch, DataItem> branchMap;
+ private final List<DataItem> backingData;
+ private final Collection<IDataChangedListener> listeners;
+ private boolean isInitialized;
+
+ public XViewerDataManager(XViewer xViewer) {
+ super();
+ this.backingData = new ArrayList<DataItem>();
+ this.isInitialized = false;
+ this.xViewer = xViewer;
+ this.branchMap = new HashMap<Branch, DataItem>();
+ this.commitableItems = new ArrayList<DataItem>();
+ this.uncommitableItems = new ArrayList<DataItem>();
+ this.listeners = Collections.synchronizedSet(new HashSet<IDataChangedListener>());
+ }
+
+ private void ensureInitialized() {
+ if (isInitialized != true) {
+ isInitialized = true;
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ xViewer.setInput(backingData);
+ }
+ });
+ }
+ }
+
+ public void addArtifacts(IProgressMonitor monitor, final List<Artifact> artifacts) throws OseeCoreException, AttributeDoesNotExist {
+ if (branchMap.isEmpty()) {
+ if (xViewer.getXViewerFactory() instanceof MassXViewerFactory) {
+ ((MassXViewerFactory) xViewer.getXViewerFactory()).registerAllAttributeColumnsForArtifacts(artifacts, true);
+ }
+ }
+ int total = artifacts.size();
+ for (int index = 0; index < artifacts.size(); index++) {
+ Artifact artifact = artifacts.get(index);
+ monitor.subTask(String.format("Adding to Table: [%s] [%s of %s]", artifact.getName(), index + 1, total));
+
+ DataItem branchItem = getBranchItem(artifact);
+ DataItem scriptItem = getScriptItem(branchItem, artifact);
+
+ ArtifactItem tempItem = new ArtifactItem(xViewer, artifact, null);
+
+ DataItem itemFound = scriptItem.getChild(tempItem.getKey());
+ if (itemFound == null) {
+ scriptItem.addChild(tempItem.getKey(), tempItem);
+ tempItem.setParent(scriptItem);
+ TestRunOperator operator = tempItem.getOperator();
+ if (operator.isFromLocalWorkspace()) {
+ if (operator.isCommitAllowed()) {
+ commitableItems.add(tempItem);
+ } else {
+ uncommitableItems.add(tempItem);
+ }
+ }
+ }
+ monitor.worked(1);
+ }
+
+ refresh();
+ }
+
+ private void refresh() {
+ ensureInitialized();
+ notifyOnDataChanged();
+
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ xViewer.refresh();
+ };
+ });
+ }
+
+ private DataItem getScriptItem(DataItem branchItem, Artifact artifact) throws OseeCoreException {
+ TestRunOperator testRunArtifact = new TestRunOperator(artifact);
+ DataItem tempItem = new ScriptItem(testRunArtifact.getScriptUrl(), testRunArtifact.getScriptRevision(), null);
+ DataItem scriptItem = branchItem.getChild(tempItem.getKey());
+ if (scriptItem == null) {
+ scriptItem = tempItem;
+ scriptItem.setParent(branchItem);
+ branchItem.addChild(scriptItem.getKey(), scriptItem);
+ }
+ return scriptItem;
+ }
+
+ private DataItem getBranchItem(Artifact artifact) {
+ Branch branch = artifact.getBranch();
+ DataItem toReturn = branchMap.get(branch);
+ if (toReturn == null) {
+ toReturn = new BranchItem(branch, null);
+ branchMap.put(branch, toReturn);
+ backingData.add(toReturn);
+ }
+ return toReturn;
+ }
+
+ private void removeHelper(DataItem item) {
+ if (item != null) {
+ DataItem parent = item.getParent();
+ if (parent != null) {
+ parent.removeChild(item);
+ if (parent.hasChildren() != true) {
+ removeHelper(parent);
+ parent.dispose();
+ }
+ } else {
+ branchMap.remove(item.getKey());
+ backingData.remove(item);
+ }
+ }
+ }
+
+ public void removeSelected() {
+ List<DataItem> items = getSelected();
+ for (DataItem item : items) {
+ removeHelper(item);
+ item.dispose();
+ commitableItems.remove(item);
+ uncommitableItems.remove(item);
+ }
+ refresh();
+ }
+
+ public void removeAll() {
+ commitableItems.clear();
+ uncommitableItems.clear();
+ for (DataItem dataItem : branchMap.values()) {
+ dataItem.dispose();
+ }
+ branchMap.clear();
+ backingData.clear();
+ refresh();
+ }
+
+ public Control getControl() {
+ return xViewer.getTree();
+ }
+
+ private List<DataItem> getSelected() {
+ List<DataItem> toReturn = new ArrayList<DataItem>();
+ TreeItem items[] = xViewer.getTree().getSelection();
+ if (items.length > 0) {
+ for (TreeItem item : items) {
+ toReturn.add((DataItem) item.getData());
+ }
+ }
+ return toReturn;
+ }
+
+ public List<Artifact> getSelectedArtifacts() {
+ List<Artifact> toReturn = new ArrayList<Artifact>();
+ for (DataItem item : getSelected()) {
+ Object object = item.getData();
+ if (object instanceof Artifact) {
+ toReturn.add((Artifact) object);
+ }
+ }
+ return toReturn;
+ }
+
+ public Artifact[] getUnCommitable() {
+ return getArtifactsFromDataItemList(uncommitableItems);
+ }
+
+ public Artifact[] getAllCommitable() {
+ return getArtifactsFromDataItemList(commitableItems);
+ }
+
+ private Artifact[] getArtifactsFromDataItemList(List<DataItem> sourceList) {
+ List<Artifact> toReturn = new ArrayList<Artifact>();
+ for (DataItem item : sourceList) {
+ toReturn.add((Artifact) (item.getData()));
+ }
+ return toReturn.toArray(new Artifact[toReturn.size()]);
+ }
+
+ public Artifact[] getSelectedForCommit() {
+ List<Artifact> toReturn = new ArrayList<Artifact>();
+ for (DataItem item : getSelected()) {
+ if (commitableItems.contains(item)) {
+ toReturn.add((Artifact) (item.getData()));
+ }
+ }
+ return toReturn.toArray(new Artifact[toReturn.size()]);
+ }
+
+ public void removeFromCommitable(final Collection<Artifact> artifacts) {
+ removeArtifactsFromDataItemList(commitableItems, artifacts);
+ removeArtifactsFromDataItemList(uncommitableItems, artifacts);
+ refresh();
+ }
+
+ private void removeArtifactsFromDataItemList(List<DataItem> sourceList, final Collection<Artifact> artifactsToRemove) {
+ List<DataItem> itemsToRemove = new ArrayList<DataItem>();
+ for (DataItem item : sourceList) {
+ Object object = item.getData();
+ if (artifactsToRemove.contains(object)) {
+ itemsToRemove.add(item);
+ }
+ }
+ sourceList.removeAll(itemsToRemove);
+ }
+
+ private void notifyOnDataChanged() {
+ synchronized (listeners) {
+ for (IDataChangedListener listener : listeners) {
+ listener.onDataChanged();
+ }
+ }
+ }
+
+ public void registerListener(IDataChangedListener listener) {
+ synchronized (listeners) {
+ listeners.add(listener);
+ }
+ }
+
+ public void deRegisterListener(IDataChangedListener listener) {
+ synchronized (listeners) {
+ if (listeners.contains(listener)) {
+ listeners.remove(listener);
+ }
+ }
+ }
+
+ public boolean isEmpty() {
+ return branchMap.isEmpty();
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/LaunchReportsAction.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/LaunchReportsAction.java
index ccb77e68893..c00f8ce48ca 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/LaunchReportsAction.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/LaunchReportsAction.java
@@ -8,49 +8,50 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.define.viewers.actions;
-
+package org.eclipse.osee.ote.ui.define.viewers.actions;
+
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.window.Window;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.ui.define.dialogs.ReportsDialog;
import org.eclipse.osee.ote.ui.define.utilities.EditorUtility;
import org.eclipse.osee.ote.ui.define.utilities.SelectionHelper;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Roberto E. Escobar
- */
-public class LaunchReportsAction extends AbstractActionHandler {
-
- public LaunchReportsAction(StructuredViewer viewer, String text) throws Exception {
- super(viewer, text);
- }
-
- public LaunchReportsAction(StructuredViewer viewer, String text, ImageDescriptor image) throws Exception {
- super(viewer, text, image);
- }
-
- @Override
- public void run() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- ReportsDialog dialog = new ReportsDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
- int result = dialog.open();
- if (result == Window.OK) {
- String reportId = dialog.getReportSelected();
- String format = dialog.getReportFormat();
- EditorUtility.openEditor(reportId, format);
- }
- }
- });
- }
-
- @Override
- public void updateState() {
- if (getViewer() != null) {
- setEnabled(SelectionHelper.getInstance().getSelections(getViewer()).size() > 0);
- }
- }
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class LaunchReportsAction extends AbstractActionHandler {
+
+ public LaunchReportsAction(StructuredViewer viewer, String text) throws Exception {
+ super(viewer, text);
+ }
+
+ public LaunchReportsAction(StructuredViewer viewer, String text, ImageDescriptor image) throws Exception {
+ super(viewer, text, image);
+ }
+
+ @Override
+ public void run() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ ReportsDialog dialog = new ReportsDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
+ int result = dialog.open();
+ if (result == Window.OK) {
+ String reportId = dialog.getReportSelected();
+ String format = dialog.getReportFormat();
+ EditorUtility.openEditor(reportId, format);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void updateState() {
+ if (getViewer() != null) {
+ setEnabled(SelectionHelper.getInstance().getSelections(getViewer()).size() > 0);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/OpenAssociatedOutfile.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/OpenAssociatedOutfile.java
index 31b15d657bd..d0aef4694cc 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/OpenAssociatedOutfile.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/actions/OpenAssociatedOutfile.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.define.viewers.actions;
-
+package org.eclipse.osee.ote.ui.define.viewers.actions;
+
import java.net.URI;
import java.util.logging.Level;
import org.eclipse.core.filesystem.EFS;
@@ -17,61 +17,62 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.define.artifacts.TestRunOperator;
import org.eclipse.osee.ote.ui.define.OteUiDefinePlugin;
import org.eclipse.osee.ote.ui.define.utilities.SelectionHelper;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
-
-/**
- * @author Roberto E. Escobar
- */
-public class OpenAssociatedOutfile extends AbstractActionHandler {
-
- public OpenAssociatedOutfile(StructuredViewer viewer, String text) throws Exception {
- super(viewer, text);
- }
-
- public OpenAssociatedOutfile(StructuredViewer viewer, String text, ImageDescriptor image) throws Exception {
- super(viewer, text, image);
- }
-
- @Override
- public void updateState() {
- TestRunOperator artifact = SelectionHelper.getInstance().getSelection(getViewer());
- setEnabled(artifact != null);
- }
-
- @Override
- public void run() {
- TestRunOperator operator = SelectionHelper.getInstance().getSelection(getViewer());
- try {
- String targetFile = operator.getOutfileUrl();
- openEditorUtility(new URI(targetFile));
- } catch (Exception ex) {
- handleException(ex);
- }
- }
-
- private void openEditorUtility(final URI resource) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IDE.openEditorOnFileStore(page, EFS.getStore(resource));
- } catch (Exception ex) {
- handleException(ex);
- }
- }
- });
- }
-
- private void handleException(Exception ex) {
- OseeLog.log(OteUiDefinePlugin.class, Level.WARNING, "Unable to open outfile.", ex);
- Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
- MessageDialog.openError(shell, "Open Outfile", "Unable to open outfile.");
- }
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OpenAssociatedOutfile extends AbstractActionHandler {
+
+ public OpenAssociatedOutfile(StructuredViewer viewer, String text) throws Exception {
+ super(viewer, text);
+ }
+
+ public OpenAssociatedOutfile(StructuredViewer viewer, String text, ImageDescriptor image) throws Exception {
+ super(viewer, text, image);
+ }
+
+ @Override
+ public void updateState() {
+ TestRunOperator artifact = SelectionHelper.getInstance().getSelection(getViewer());
+ setEnabled(artifact != null);
+ }
+
+ @Override
+ public void run() {
+ TestRunOperator operator = SelectionHelper.getInstance().getSelection(getViewer());
+ try {
+ String targetFile = operator.getOutfileUrl();
+ openEditorUtility(new URI(targetFile));
+ } catch (Exception ex) {
+ handleException(ex);
+ }
+ }
+
+ private void openEditorUtility(final URI resource) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IDE.openEditorOnFileStore(page, EFS.getStore(resource));
+ } catch (Exception ex) {
+ handleException(ex);
+ }
+ }
+ });
+ }
+
+ private void handleException(Exception ex) {
+ OseeLog.log(OteUiDefinePlugin.class, Level.WARNING, "Unable to open outfile.", ex);
+ Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ MessageDialog.openError(shell, "Open Outfile", "Unable to open outfile.");
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/data/ArtifactItem.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/data/ArtifactItem.java
index 6f166679e34..bde10c7d19e 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/data/ArtifactItem.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/viewers/data/ArtifactItem.java
@@ -32,8 +32,8 @@ import org.eclipse.osee.framework.skynet.core.event.Sender;
import org.eclipse.osee.framework.skynet.core.event2.ArtifactEvent;
import org.eclipse.osee.framework.skynet.core.event2.artifact.IArtifactEventListener;
import org.eclipse.osee.framework.skynet.core.event2.filter.IEventFilter;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
import org.eclipse.osee.framework.ui.skynet.ArtifactImageManager;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.OverlayImage;
import org.eclipse.osee.framework.ui.swt.OverlayImage.Location;
diff --git a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/views/TestRunView.java b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/views/TestRunView.java
index 3a831743d9f..0728ec1add3 100644
--- a/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/views/TestRunView.java
+++ b/plugins/org.eclipse.osee.ote.ui.define/src/org/eclipse/osee/ote/ui/define/views/TestRunView.java
@@ -27,7 +27,7 @@ import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.IActionable;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
-import org.eclipse.osee.framework.ui.plugin.util.Displays;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.ote.ui.define.OteDefineImage;
import org.eclipse.osee.ote.ui.define.OteUiDefinePlugin;
@@ -42,7 +42,6 @@ import org.eclipse.swt.events.KeyEvent;
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.Tree;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PlatformUI;
@@ -53,227 +52,229 @@ import org.eclipse.ui.part.ViewPart;
* @author Roberto E. Escobar
*/
public class TestRunView extends ViewPart implements IActionable, IDataChangedListener {
- public static final String VIEW_ID = TestRunView.class.getName();
- private static final String BEGIN_MESSAGE =
- "To begin, drag and drop a test run artifact from artifact explorer or from an artifact search result window. Alternatively, you can drag and drop a test outfile onto this view.";
-
- private Action expandAction, collapseAction, refreshAction;
- private static TestRunXViewer viewer = null;
- @SuppressWarnings("unused")
- private IHandlerService handlerService;
- private ShowOnlyLatestRuns latestRunFilter;
- private boolean isFilterOn;
-
- // private static final String FLAT_KEY = "flat";
-
- @Override
- public void createPartControl(Composite parent) {
- parent.setLayout(new GridLayout());
-
- PlatformUI.getWorkbench().getService(IHandlerService.class);
- handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
-
- viewer = new TestRunXViewer(parent);
- Tree tree = viewer.getTree();
- GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
- gridData.minimumHeight = 350;
- tree.setLayoutData(gridData);
- tree.setHeaderVisible(true);
- tree.setLinesVisible(true);
- tree.setFont(parent.getFont());
-
- parent.layout();
- createActions();
- createMenus();
- createToolbar();
-
- latestRunFilter = new ShowOnlyLatestRuns();
- isFilterOn = false;
- viewer.registerListener(this);
- viewer.getTree().addKeyListener(new KeyAdapter() {
-
- @Override
- public void keyPressed(KeyEvent event) {
- if (event.stateMask == SWT.CTRL && (event.keyCode == 'A' || event.keyCode == 'a')) {
- Object object = event.getSource();
- if (object instanceof Tree) {
- Tree tree = (Tree) object;
- tree.selectAll();
- }
- }
- }
- });
- onDataChanged();
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.osee.ote.ui.define.testRunView");
- }
-
- @Override
- public void setFocus() {
- }
-
- public String getActionDescription() {
- return "";
- }
-
- protected void createActions() {
- expandAction = new Action("Expand All") {
-
- @Override
- public void run() {
- viewer.getTree().setRedraw(false);
- viewer.expandAll();
- viewer.getTree().setRedraw(true);
- }
- };
- expandAction.setImageDescriptor(ImageManager.getImageDescriptor(OteDefineImage.EXPAND_STATE));
- expandAction.setToolTipText("Expand All");
-
- collapseAction = new Action("Collapse All") {
-
- @Override
- public void run() {
- viewer.getTree().setRedraw(false);
- viewer.collapseAll();
- viewer.getTree().setRedraw(true);
- }
- };
- collapseAction.setImageDescriptor(ImageManager.getImageDescriptor(OteDefineImage.COLLAPSE_STATE));
- collapseAction.setToolTipText("Collapse All");
-
- refreshAction = new Action("Refresh") {
-
- @Override
- public void run() {
- Displays.ensureInDisplayThread(new Runnable() {
- public void run() {
- viewer.refresh();
- };
- });
- }
- };
- refreshAction.setToolTipText("Refresh Table");
- refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
-
- }
-
- private void createMenus() {
- MenuManager menuManager = new MenuManager();
- getSite().registerContextMenu(VIEW_ID, menuManager, viewer);
- menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menuManager.setParent(getViewSite().getActionBars().getMenuManager());
- fillMenu(menuManager);
- getSite().setSelectionProvider(viewer);
- OseeUiActions.addBugToViewToolbar(this, this, OteUiDefinePlugin.getInstance(), VIEW_ID, "Test Run View");
- }
-
- private void fillMenu(IMenuManager menuManager) {
- menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- private void createToolbar() {
- IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
- toolbarManager.add(refreshAction);
- toolbarManager.add(expandAction);
- toolbarManager.add(collapseAction);
- }
-
- public void setDescription(final String message) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- setContentDescription(message);
- }
- });
- }
-
- public void onDataChanged() {
- String message = BEGIN_MESSAGE;
- Object object = viewer.getInput();
- if (object != null && object instanceof Collection<?>) {
- if (!((Collection<?>) object).isEmpty()) {
- message = "";
- }
- }
- setDescription(message);
- }
-
- public static StructuredViewer getViewer() {
- return viewer;
- }
-
- public void presentGroupedByBranch() {
- BranchItem.setGroupModeEnabled(true);
- viewer.refresh();
- }
-
- public void presentGroupedByScript() {
- BranchItem.setGroupModeEnabled(false);
- viewer.refresh();
- }
-
- public void presentWithShortNames() {
- ScriptItem.setFullDescriptionModeEnabled(false);
- ArtifactItem.setFullDescriptionModeEnabled(false);
- viewer.refresh();
- }
-
- public void presentWithLongNames() {
- ScriptItem.setFullDescriptionModeEnabled(true);
- ArtifactItem.setFullDescriptionModeEnabled(true);
- viewer.refresh();
- }
-
- public void toggleFilter() {
- latestRunFilter.clear();
- if (isFilterOn != true) {
- isFilterOn = true;
- viewer.addFilter(latestRunFilter);
- } else {
- isFilterOn = false;
- viewer.removeFilter(latestRunFilter);
- }
- viewer.refresh();
- }
-
- private final class ShowOnlyLatestRuns extends ViewerFilter {
- private final Map<String, ArtifactItem> latestMap = new HashMap<String, ArtifactItem>();
-
- @Override
- public Object[] filter(Viewer viewer, Object parent, Object[] elements) {
- return super.filter(viewer, parent, elements);
- }
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- boolean toReturn = false;
- if (element instanceof ArtifactItem) {
- ArtifactItem item1 = (ArtifactItem) element;
- String name = item1.getOperator().getDescriptiveName();
-
- ArtifactItem item2 = latestMap.get(name);
- if (item2 == null) {
- latestMap.put(name, item1);
- toReturn = true;
- } else {
- try {
- Date date1 = item1.getOperator().getEndDate();
- Date date2 = item2.getOperator().getEndDate();
- if (date1.after(date2) || date1.equals(date2)) {
- latestMap.put(name, item1);
- toReturn = true;
- }
- } catch (Exception ex) {
- OseeLog.log(OteUiDefinePlugin.class, Level.WARNING, "Error comparing run dates.", ex);
- }
- }
- } else {
- toReturn = true;
- }
- return toReturn;
- }
-
- public void clear() {
- latestMap.clear();
- }
- }
+ public static final String VIEW_ID = TestRunView.class.getName();
+ private static final String BEGIN_MESSAGE =
+ "To begin, drag and drop a test run artifact from artifact explorer or from an artifact search result window. Alternatively, you can drag and drop a test outfile onto this view.";
+
+ private Action expandAction, collapseAction, refreshAction;
+ private static TestRunXViewer viewer = null;
+ @SuppressWarnings("unused")
+ private IHandlerService handlerService;
+ private ShowOnlyLatestRuns latestRunFilter;
+ private boolean isFilterOn;
+
+ // private static final String FLAT_KEY = "flat";
+
+ @Override
+ public void createPartControl(Composite parent) {
+ parent.setLayout(new GridLayout());
+
+ PlatformUI.getWorkbench().getService(IHandlerService.class);
+ handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
+
+ viewer = new TestRunXViewer(parent);
+ Tree tree = viewer.getTree();
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gridData.minimumHeight = 350;
+ tree.setLayoutData(gridData);
+ tree.setHeaderVisible(true);
+ tree.setLinesVisible(true);
+ tree.setFont(parent.getFont());
+
+ parent.layout();
+ createActions();
+ createMenus();
+ createToolbar();
+
+ latestRunFilter = new ShowOnlyLatestRuns();
+ isFilterOn = false;
+ viewer.registerListener(this);
+ viewer.getTree().addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyPressed(KeyEvent event) {
+ if (event.stateMask == SWT.CTRL && (event.keyCode == 'A' || event.keyCode == 'a')) {
+ Object object = event.getSource();
+ if (object instanceof Tree) {
+ Tree tree = (Tree) object;
+ tree.selectAll();
+ }
+ }
+ }
+ });
+ onDataChanged();
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.osee.ote.ui.define.testRunView");
+ }
+
+ @Override
+ public void setFocus() {
+ }
+
+ public String getActionDescription() {
+ return "";
+ }
+
+ protected void createActions() {
+ expandAction = new Action("Expand All") {
+
+ @Override
+ public void run() {
+ viewer.getTree().setRedraw(false);
+ viewer.expandAll();
+ viewer.getTree().setRedraw(true);
+ }
+ };
+ expandAction.setImageDescriptor(ImageManager.getImageDescriptor(OteDefineImage.EXPAND_STATE));
+ expandAction.setToolTipText("Expand All");
+
+ collapseAction = new Action("Collapse All") {
+
+ @Override
+ public void run() {
+ viewer.getTree().setRedraw(false);
+ viewer.collapseAll();
+ viewer.getTree().setRedraw(true);
+ }
+ };
+ collapseAction.setImageDescriptor(ImageManager.getImageDescriptor(OteDefineImage.COLLAPSE_STATE));
+ collapseAction.setToolTipText("Collapse All");
+
+ refreshAction = new Action("Refresh") {
+
+ @Override
+ public void run() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ public void run() {
+ viewer.refresh();
+ };
+ });
+ }
+ };
+ refreshAction.setToolTipText("Refresh Table");
+ refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
+
+ }
+
+ private void createMenus() {
+ MenuManager menuManager = new MenuManager();
+ getSite().registerContextMenu(VIEW_ID, menuManager, viewer);
+ menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ menuManager.setParent(getViewSite().getActionBars().getMenuManager());
+ fillMenu(menuManager);
+ getSite().setSelectionProvider(viewer);
+ OseeUiActions.addBugToViewToolbar(this, this, OteUiDefinePlugin.getInstance(), VIEW_ID, "Test Run View");
+ }
+
+ private void fillMenu(IMenuManager menuManager) {
+ menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+
+ private void createToolbar() {
+ IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
+ toolbarManager.add(refreshAction);
+ toolbarManager.add(expandAction);
+ toolbarManager.add(collapseAction);
+ }
+
+ public void setDescription(final String message) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ setContentDescription(message);
+ }
+ });
+ }
+
+ @Override
+ public void onDataChanged() {
+ String message = BEGIN_MESSAGE;
+ Object object = viewer.getInput();
+ if (object != null && object instanceof Collection<?>) {
+ if (!((Collection<?>) object).isEmpty()) {
+ message = "";
+ }
+ }
+ setDescription(message);
+ }
+
+ public static StructuredViewer getViewer() {
+ return viewer;
+ }
+
+ public void presentGroupedByBranch() {
+ BranchItem.setGroupModeEnabled(true);
+ viewer.refresh();
+ }
+
+ public void presentGroupedByScript() {
+ BranchItem.setGroupModeEnabled(false);
+ viewer.refresh();
+ }
+
+ public void presentWithShortNames() {
+ ScriptItem.setFullDescriptionModeEnabled(false);
+ ArtifactItem.setFullDescriptionModeEnabled(false);
+ viewer.refresh();
+ }
+
+ public void presentWithLongNames() {
+ ScriptItem.setFullDescriptionModeEnabled(true);
+ ArtifactItem.setFullDescriptionModeEnabled(true);
+ viewer.refresh();
+ }
+
+ public void toggleFilter() {
+ latestRunFilter.clear();
+ if (isFilterOn != true) {
+ isFilterOn = true;
+ viewer.addFilter(latestRunFilter);
+ } else {
+ isFilterOn = false;
+ viewer.removeFilter(latestRunFilter);
+ }
+ viewer.refresh();
+ }
+
+ private final class ShowOnlyLatestRuns extends ViewerFilter {
+ private final Map<String, ArtifactItem> latestMap = new HashMap<String, ArtifactItem>();
+
+ @Override
+ public Object[] filter(Viewer viewer, Object parent, Object[] elements) {
+ return super.filter(viewer, parent, elements);
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ boolean toReturn = false;
+ if (element instanceof ArtifactItem) {
+ ArtifactItem item1 = (ArtifactItem) element;
+ String name = item1.getOperator().getDescriptiveName();
+
+ ArtifactItem item2 = latestMap.get(name);
+ if (item2 == null) {
+ latestMap.put(name, item1);
+ toReturn = true;
+ } else {
+ try {
+ Date date1 = item1.getOperator().getEndDate();
+ Date date2 = item2.getOperator().getEndDate();
+ if (date1.after(date2) || date1.equals(date2)) {
+ latestMap.put(name, item1);
+ toReturn = true;
+ }
+ } catch (Exception ex) {
+ OseeLog.log(OteUiDefinePlugin.class, Level.WARNING, "Error comparing run dates.", ex);
+ }
+ }
+ } else {
+ toReturn = true;
+ }
+ return toReturn;
+ }
+
+ public void clear() {
+ latestMap.clear();
+ }
+ }
}
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
index 8ce5297ecd4..50fbe32d2c0 100644
--- 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
@@ -25,13 +25,13 @@ 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.Displays;
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;
@@ -41,245 +41,246 @@ import org.eclipse.ui.PlatformUI;
*/
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();
- }
+ 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(Displays.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() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ 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/TestServerConsoleServiceRenderer.java b/plugins/org.eclipse.osee.ote.ui.host.cmd/src/org/eclipse/osee/ote/ui/host/cmd/TestServerConsoleServiceRenderer.java
index 96dcab31f96..b7bb1badb4f 100644
--- 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
@@ -20,6 +20,7 @@ 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.Displays;
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;
@@ -39,164 +40,163 @@ 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();
- }
+ private IHostTestEnvironment testService;
+ private Group composite;
+ private final Hashtable<ITestEnvironment, IRemoteCommandConsole> consoles;
+ private volatile IRemoteCommandConsole selectedConsole;
+ private Text outputTxt;
+ private Text inputTxt;
+ private Button sendCmdBtn;
+ private EnvironmentViewer envViewer;
+ private final 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(Displays.getSystemColor(SWT.COLOR_BLACK));
+ outputTxt.setForeground(Displays.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() {
+ @Override
+ 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.message/src/org/eclipse/osee/ote/ui/message/tree/MessageUpdateListener.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/tree/MessageUpdateListener.java
index 0805d8a106f..9d302d17630 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/tree/MessageUpdateListener.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/tree/MessageUpdateListener.java
@@ -8,103 +8,100 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.message.tree;
-
+package org.eclipse.osee.ote.ui.message.tree;
+
import java.util.LinkedList;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.client.msg.core.AbstractMessageListener;
import org.eclipse.osee.ote.client.msg.core.IMessageSubscription;
import org.eclipse.osee.ote.message.MessageSystemException;
import org.eclipse.osee.ote.message.data.MessageData;
import org.eclipse.osee.ote.message.enums.DataType;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @author Ken J. Aguilar
- *
- */
-public class MessageUpdateListener extends AbstractMessageListener {
-
- private final WatchedMessageNode node;
- private final TreeViewer viewer;
-
- private final class NodeUpdate implements Runnable {
-
- private final AbstractTreeNode[] nodes;
-
- NodeUpdate(AbstractTreeNode[] nodes) {
- this.nodes = nodes;
- }
-
- @Override
- public void run() {
+
+/**
+ * @author Ken J. Aguilar
+ */
+public class MessageUpdateListener extends AbstractMessageListener {
+
+ private final WatchedMessageNode node;
+ private final TreeViewer viewer;
+
+ private final class NodeUpdate implements Runnable {
+
+ private final AbstractTreeNode[] nodes;
+
+ NodeUpdate(AbstractTreeNode[] nodes) {
+ this.nodes = nodes;
+ }
+
+ @Override
+ public void run() {
for (AbstractTreeNode node : nodes) {
viewer.refresh(node, true);
- }
- }
-
- };
-
- public MessageUpdateListener(TreeViewer viewer, WatchedMessageNode node) {
- super(node.getSubscription());
- this.viewer = viewer;
- this.node = node;
- }
-
- @Override
- public void onDataAvailable(MessageData data, DataType type) throws MessageSystemException {
- if (type == getSubscription().getMemType()) {
- node.incrementCounter();
- }
- }
-
- @Override
- public void subscriptionActivated(IMessageSubscription subscription) {
- update(node);
- }
-
- @Override
- public void subscriptionInvalidated(IMessageSubscription subscription) {
- String reason = subscription.getMessageClassName() + " does not exist";
- LinkedList<AbstractTreeNode> list = new LinkedList<AbstractTreeNode>();
- list.add(node);
- node.collectDescendants(list);
-
- for (AbstractTreeNode child : list) {
- child.setEnabled(false);
- child.setDisabledReason(reason);
- }
- update(list.toArray(new AbstractTreeNode[list.size()]));
-
- }
-
- @Override
- public void subscriptionNotSupported(IMessageSubscription subscription) {
- update(node);
- }
-
- @Override
- public void subscriptionResolved(IMessageSubscription subscription) {
- super.subscriptionResolved(subscription);
- node.setResolved(true);
- update(node);
- }
-
- @Override
- public void subscriptionUnresolved(IMessageSubscription subscription) {
- super.subscriptionUnresolved(subscription);
- node.setResolved(false);
- update(node);
- }
-
- private void update(AbstractTreeNode[] nodes) {
- Display.getDefault().asyncExec(new NodeUpdate(nodes));
- }
-
- private void update(AbstractTreeNode node) {
- Display.getDefault().asyncExec(new NodeUpdate(new AbstractTreeNode[] { node }));
- }
-
-
-
-}
+ }
+ }
+
+ };
+
+ public MessageUpdateListener(TreeViewer viewer, WatchedMessageNode node) {
+ super(node.getSubscription());
+ this.viewer = viewer;
+ this.node = node;
+ }
+
+ @Override
+ public void onDataAvailable(MessageData data, DataType type) throws MessageSystemException {
+ if (type == getSubscription().getMemType()) {
+ node.incrementCounter();
+ }
+ }
+
+ @Override
+ public void subscriptionActivated(IMessageSubscription subscription) {
+ update(node);
+ }
+
+ @Override
+ public void subscriptionInvalidated(IMessageSubscription subscription) {
+ String reason = subscription.getMessageClassName() + " does not exist";
+ LinkedList<AbstractTreeNode> list = new LinkedList<AbstractTreeNode>();
+ list.add(node);
+ node.collectDescendants(list);
+
+ for (AbstractTreeNode child : list) {
+ child.setEnabled(false);
+ child.setDisabledReason(reason);
+ }
+ update(list.toArray(new AbstractTreeNode[list.size()]));
+
+ }
+
+ @Override
+ public void subscriptionNotSupported(IMessageSubscription subscription) {
+ update(node);
+ }
+
+ @Override
+ public void subscriptionResolved(IMessageSubscription subscription) {
+ super.subscriptionResolved(subscription);
+ node.setResolved(true);
+ update(node);
+ }
+
+ @Override
+ public void subscriptionUnresolved(IMessageSubscription subscription) {
+ super.subscriptionUnresolved(subscription);
+ node.setResolved(false);
+ update(node);
+ }
+
+ private void update(AbstractTreeNode[] nodes) {
+ Displays.ensureInDisplayThread(new NodeUpdate(nodes));
+ }
+
+ private void update(AbstractTreeNode node) {
+ Displays.ensureInDisplayThread(new NodeUpdate(new AbstractTreeNode[] {node}));
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/tree/MessageWatchLabelProvider.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/tree/MessageWatchLabelProvider.java
index 5aabe892c57..b0b2f9b08f2 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/tree/MessageWatchLabelProvider.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/tree/MessageWatchLabelProvider.java
@@ -13,46 +13,50 @@ package org.eclipse.osee.ote.ui.message.tree;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.nebula.widgets.xviewer.XViewerColumn;
import org.eclipse.nebula.widgets.xviewer.XViewerLabelProvider;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.ui.message.messageXViewer.MessageXViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
public class MessageWatchLabelProvider extends XViewerLabelProvider {
- public MessageWatchLabelProvider(MessageXViewer viewer) {
- super(viewer);
- }
+ public MessageWatchLabelProvider(MessageXViewer viewer) {
+ super(viewer);
+ }
- @Override
- public Image getColumnImage(Object element, XViewerColumn col, int columnIndex) {
- assert element instanceof AbstractTreeNode;
- return ((AbstractTreeNode) element).getImage(col);
- }
+ @Override
+ public Image getColumnImage(Object element, XViewerColumn col, int columnIndex) {
+ assert element instanceof AbstractTreeNode;
+ return ((AbstractTreeNode) element).getImage(col);
+ }
- public void addListener(ILabelProviderListener listener) {
- }
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ }
- public void dispose() {
+ @Override
+ public void dispose() {
- }
+ }
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
- public void removeListener(ILabelProviderListener listener) {
- }
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ }
- @Override
- public String getColumnText(Object element, XViewerColumn col, int columnIndex) throws Exception {
- return ((AbstractTreeNode) element).getLabel(col);
- }
+ @Override
+ public String getColumnText(Object element, XViewerColumn col, int columnIndex) throws Exception {
+ return ((AbstractTreeNode) element).getLabel(col);
+ }
- @Override
- public Color getForeground(Object element, XViewerColumn col, int columnIndex) {
- AbstractTreeNode node = (AbstractTreeNode) element;
- return node.isEnabled() ? null : Display.getDefault().getSystemColor(SWT.COLOR_RED);
- }
+ @Override
+ public Color getForeground(Object element, XViewerColumn col, int columnIndex) {
+ AbstractTreeNode node = (AbstractTreeNode) element;
+ return node.isEnabled() ? null : Displays.getSystemColor(SWT.COLOR_RED);
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/view/MessageView.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/view/MessageView.java
index 4c4fd0bd2e4..ff7c1d07594 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/view/MessageView.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/view/MessageView.java
@@ -34,6 +34,7 @@ import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.IActionable;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.osee.ote.service.IMessageDictionary;
@@ -67,7 +68,6 @@ 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.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
@@ -80,504 +80,503 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
public class MessageView extends ViewPart implements IActionable, IMessageDictionaryListener {
- protected TreeViewer treeViewer;
- protected Text searchText;
- protected MessageViewLabelProvider labelProvider;
-
- protected Action expandAction, collapseAction, refreshAction, filterByName, bugAction;
- protected ViewerSorter nameSorter;
- public static final String VIEW_ID = "org.eclipse.osee.ote.ui.message.view.MessageView";
- private Label startLabel;
- private Label versionLbl;
- private Composite parentComposite;
- private Button searchButton;
- private int numMessages = 0;
- private int numElements = 0;
- private MessageTreeBuilder treeBuilder;
-
- public MessageView() {
- super();
- }
-
- @Override
- public void createPartControl(Composite parent) {
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.verticalSpacing = 0;
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- parent.setLayout(layout);
- parentComposite = new Composite(parent, SWT.NONE);
- GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
- parentComposite.setLayoutData(layoutData);
- Widgets.setFormLayout(parentComposite, 5, 5);
-
- startLabel = new Label(parentComposite, SWT.LEFT);
- Widgets.attachToParent(startLabel, SWT.TOP, 0, 0);
- Widgets.attachToParent(startLabel, SWT.LEFT, 0, 0);
- Widgets.attachToParent(startLabel, SWT.RIGHT, 50, 0);
-
- versionLbl = new Label(parentComposite, SWT.CENTER);
- Widgets.attachToParent(versionLbl, SWT.TOP, 0, 0);
- Widgets.attachToParent(versionLbl, SWT.LEFT, 50, 5);
- Widgets.attachToParent(versionLbl, SWT.RIGHT, 100, 0);
-
- // Create the tree treeViewer as a child of the composite parent
- treeViewer = new TreeViewer(parentComposite);
- treeViewer.setContentProvider(new MessageContentProvider());
- labelProvider = new MessageViewLabelProvider();
- treeViewer.setLabelProvider(labelProvider);
- final Tree tree = treeViewer.getTree();
- Widgets.attachToControl(tree, startLabel, SWT.TOP, SWT.BOTTOM, 5);
- Widgets.attachToParent(tree, SWT.BOTTOM, 100, -50);
- Widgets.attachToParent(tree, SWT.LEFT, 0, 0);
- Widgets.attachToParent(tree, SWT.RIGHT, 100, 0);
- treeViewer.setUseHashlookup(true);
- // tree.setMenu(getPopupMenu(parent));
- tree.addMouseListener(new MouseAdapter() {
-
- @Override
- public void mouseDown(MouseEvent e) {
- if (e.button == 3) {
- Point p = new Point(e.x, e.y);
- final Menu contextMenu = getPopupMenu(tree.getParent());
- if (contextMenu != null) {
- p = tree.toDisplay(p);
- contextMenu.setLocation(p);
- contextMenu.setVisible(true);
-
- Activator.getDefault().setHelp(contextMenu, "messageViewWatch", "org.eclipse.osee.framework.help.ui");
- }
- }
- }
-
- });
- treeBuilder = new MessageTreeBuilder();
- /*
- * Create a text field to be used for filtering the elements displayed by the tree treeViewer
- */
- Group grp = new Group(parentComposite, SWT.NONE);
- Widgets.attachToControl(grp, tree, SWT.TOP, SWT.BOTTOM, 5);
- Widgets.attachToParent(grp, SWT.LEFT, 0, 0);
- Widgets.attachToParent(grp, SWT.RIGHT, 100, 0);
- layout = new GridLayout();
- layout.numColumns = 3;
- grp.setLayout(layout);
- Label l = new Label(grp, SWT.NULL);
- l.setText("Search:");
- l.setToolTipText("Enter a regular expression filter.\nEnter space to see all.");
-
- searchText = new Text(grp, SWT.SINGLE | SWT.BORDER);
- searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- searchText.addTraverseListener(new TraverseListener() {
-
- public void keyTraversed(TraverseEvent event) {
- if (event.detail == SWT.TRAVERSE_RETURN) {
- search(searchText.getText());
- }
- }
-
- });
-
- searchText.addVerifyListener(new VerifyListener() {
- public void verifyText(VerifyEvent e) {
- char chr = e.character;
- if (chr >= 'a' && chr <= 'z') {
- final char[] chars = new char[] {chr};
- e.text = new String(chars).toUpperCase();
- }
- }
- });
-
- searchButton = new Button(grp, SWT.PUSH);
- searchButton.setText("Go");
- searchButton.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- search(searchText.getText());
- }
- });
-
- // Create menu, toolbars, filters, sorters.
- createFiltersAndSorters();
- createActions();
- createMenus();
- createToolbar();
-
- treeViewer.setSorter(nameSorter);
- treeViewer.expandToLevel(0);
-
- RootNode root = new RootNode("empty");
- /*
- * instantiate dummy nodes since the first time these classes are instantiated must be from a
- * UI thread.
- */
- MessageNode msgNode = new MessageNode("osee.test.msg.pubsub.DUMMY_MSG", null);
- ElementPath obj = new ElementPath();
- obj.add("DUMMY");
- ElementNode node = new ElementNode(obj);
- msgNode.addChild(node);
- treeViewer.setInput(root);
- setHelpContexts();
- setLibraryUnloadedState();
- Activator.getDefault().getOteClientService().addDictionaryListener(this);
- }
-
- private void setHelpContexts() {
- Activator.getDefault().setHelp(parentComposite.getParent(), "messageView", "org.eclipse.osee.framework.help.ui");
- Activator.getDefault().setHelp(searchButton, "messageViewSearch", "org.eclipse.osee.framework.help.ui");
- Activator.getDefault().setHelp(searchText, "messageViewSearch", "org.eclipse.osee.framework.help.ui");
- }
-
- /**
- * sets the filter for searches
- */
- private void search(final String searchPattern) {
- final Color bgColor = treeViewer.getTree().getBackground();
- treeViewer.getTree().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- searchText.setEnabled(false);
- searchButton.setEnabled(false);
- final Job searchJob = new Job("Searching Message.jar") {
-
- @Override
- public IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("searching jar", numElements);
- try {
- String searchTxt = searchPattern;
- if (searchPattern.equals("")) {
- searchTxt = ".*";
- }
- try {
- final Pattern pattern = Pattern.compile(searchTxt);
- final Collection<Map.Entry<String, ArrayList<String>>> map = treeBuilder.getMessages();
- if (map.size() > 0) {
- final RootNode root = new RootNode("root");
- for (Map.Entry<String, ArrayList<String>> entry : map) {
- final String name = entry.getKey().substring(entry.getKey().lastIndexOf('.') + 1);
- final Matcher matcher = pattern.matcher(name);
-
- if (matcher.matches()) {
- MessageNode msgNode = new MessageNode(entry.getKey());
- root.addChild(msgNode);
- for (String elementName : entry.getValue()) {
- ElementPath obj = new ElementPath(msgNode.getMessageClassName(), elementName);
- ElementNode node = new ElementNode(obj);
- msgNode.addChild(node);
- }
- } else {
- LinkedList<String> matches = new LinkedList<String>();
- for (String elementName : entry.getValue()) {
- if (pattern.matcher(elementName).matches()) {
- matches.add(elementName);
- }
- }
- if (!matches.isEmpty()) {
- MessageNode msgNode = new MessageNode(entry.getKey());
- root.addChild(msgNode);
- for (String elementName : matches) {
- ElementPath obj = new ElementPath(msgNode.getMessageClassName(), elementName);
- ElementNode node = new ElementNode(obj);
- msgNode.addChild(node);
- }
- }
- }
- monitor.worked(entry.getValue().size());
- }
-
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
-
- treeViewer.setInput(root);
- if (!root.hasChildren()) {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Search",
- "No matches found for pattern " + searchPattern);
- }
- }
-
- });
- } else {
- Display.getDefault().asyncExec(new Runnable() {
-
- public void run() {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Search",
- "There are no messages available for searching");
- }
- });
- }
- } catch (final PatternSyntaxException e) {
- Display.getDefault().asyncExec(new Runnable() {
-
- public void run() {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Search Error", e.getMessage());
-
- }
- });
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, "", null);
- }
- return new Status(IStatus.OK, Activator.PLUGIN_ID, IStatus.OK, "", null);
- } catch (Throwable t) {
- OseeLog.log(Activator.class, Level.SEVERE, "exception during search operation", t);
- return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, IStatus.CANCEL, "", t);
- } finally {
- monitor.done();
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- treeViewer.getTree().setBackground(bgColor);
- searchText.setEnabled(true);
- searchButton.setEnabled(true);
- }
- });
- }
- }
-
- };
- searchJob.setUser(true);
- searchJob.schedule();
- }
-
- private Menu getPopupMenu(final Composite composite) {
- final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
- final AbstractTreeNode node = (AbstractTreeNode) selection.getFirstElement();
- final Menu previewMenu = new Menu(composite);
-
- // if there's nothing selected in the tree, no need to display a menu.
- if (node == null) {
- return null;
- }
-
- MenuItem item = new MenuItem(previewMenu, SWT.CASCADE);
- item.setText("Watch");
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- WatchView watchView = (WatchView) page.findView(WatchView.VIEW_ID);
- if (watchView == null) {
- watchView = launchMessageWatch(page);
- }
- if (watchView != null) {
- final Iterator<?> iter = selection.iterator();
- AddWatchParameter addWatchParam = new AddWatchParameter();
- while (iter.hasNext()) {
- final AbstractTreeNode node = (AbstractTreeNode) iter.next();
- if (node instanceof MessageNode) {
- addWatchParam.addMessage(((MessageNode) node).getMessageClassName());
- } else if (node instanceof ElementNode) {
- addWatchParam.addMessage(((ElementNode) node).getElementPath().getMessageName(),
- ((ElementNode) node).getElementPath());
- }
- }
- watchView.addWatchMessage(addWatchParam);
- watchView.refresh();
- }
- } catch (RuntimeException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, "exception during attempt to watch", ex);
- }
- }
- });
-
- if (node instanceof MessageNode) {
- item = new MenuItem(previewMenu, SWT.CASCADE);
- item.setText("Watch All");
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- try {
- final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- WatchView watchView = (WatchView) page.findView(WatchView.VIEW_ID);
- if (watchView == null) {
- watchView = launchMessageWatch(page);
- }
- if (watchView != null) {
- final Iterator<?> iter = selection.iterator();
- final RootNode root = (RootNode) treeViewer.getInput();
- AddWatchParameter parameter = new AddWatchParameter();
- while (iter.hasNext()) {
- final AbstractTreeNode node = (AbstractTreeNode) iter.next();
- if (node.getParent() == root) {
- if (node instanceof MessageNode) {
- parameter.addMessage(((MessageNode) node).getMessageClassName());
- for (AbstractTreeNode child : node.getChildren()) {
- ElementPath obj =
- new ElementPath(((MessageNode) node).getMessageClassName(), child.getName());
- parameter.addMessage(((MessageNode) node).getMessageClassName(), obj);
- }
- }
- } else {
- MessageNode parent = (MessageNode) node.getParent();
- if (!parameter.containsMessage(parent.getName())) {
- for (int index = 0; index < parent.getChildren().size(); index++) {
- ElementPath obj = new ElementPath(parent.getMessageClassName(), node.getName());
- parameter.addMessage(parent.getMessageClassName(), obj);
- }
- }
- }
- }
-
- watchView.addWatchMessage(parameter);
- watchView.refresh();
- }
- } catch (RuntimeException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, "Exception during attempt to watch all", ex);
- }
- }
- });
- }
-
- return previewMenu;
- }
-
- private WatchView launchMessageWatch(IWorkbenchPage page) {
- WatchView watchView = null;
- try {
- watchView = (WatchView) page.showView(WatchView.VIEW_ID);
- } catch (PartInitException e1) {
- MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Launch Error",
- "Couldn't Launch MsgWatch " + e1.getMessage());
- return null;
- }
- return watchView;
- }
-
- protected void createFiltersAndSorters() {
- nameSorter = new MessageTreeSorter();
- }
-
- protected void createActions() {
- final TreeViewer ftv = treeViewer;
- expandAction = new Action("Expand All") {
-
- @Override
- public void run() {
- treeViewer.getTree().setRedraw(false);
- ftv.expandAll();
- treeViewer.getTree().setRedraw(true);
- }
- };
- expandAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.EXPAND_STATE));
- expandAction.setToolTipText("Expand All");
-
- collapseAction = new Action("Collapse All") {
-
- @Override
- public void run() {
- treeViewer.getTree().setRedraw(false);
- ftv.collapseAll();
- treeViewer.getTree().setRedraw(true);
- }
- };
- collapseAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.COLLAPSE_STATE));
- collapseAction.setToolTipText("Collapse All");
-
- refreshAction = new Action("Reload Messages from JAR") {
-
- @Override
- public void run() {
- search(".*");
- }
- };
- refreshAction.setToolTipText("Reload Messages from JAR");
- refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.REFRESH));
-
- OseeUiActions.addBugToViewToolbar(this, this, Activator.getDefault(), VIEW_ID, "Message View");
- }
-
- protected void createMenus() {
- IMenuManager rootMenuManager = getViewSite().getActionBars().getMenuManager();
- rootMenuManager.setRemoveAllWhenShown(true);
- rootMenuManager.addMenuListener(new IMenuListener() {
-
- public void menuAboutToShow(IMenuManager mgr) {
- fillMenu(mgr);
- }
- });
- fillMenu(rootMenuManager);
- }
-
- protected void fillMenu(IMenuManager rootMenuManager) {
- rootMenuManager.add(refreshAction);
- rootMenuManager.add(expandAction);
- rootMenuManager.add(collapseAction);
- }
-
- protected void createToolbar() {
- IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
- toolbarManager.add(refreshAction);
- toolbarManager.add(expandAction);
- toolbarManager.add(collapseAction);
- // toolbarManager.add(bugAction);
- }
-
- /*
- * @see IWorkbenchPart#setFocus()
- */
- @Override
- public void setFocus() {
- parentComposite.setFocus();
- }
-
- public String getActionDescription() {
- return "";
- }
-
- @Override
- public void onDictionaryLoaded(final IMessageDictionary dictionary) {
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- try {
- startLabel.setText("processing library...");
- treeViewer.getTree().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- treeBuilder.clear();
- dictionary.generateMessageIndex(treeBuilder);
- numMessages = treeBuilder.getNumMessages();
- numElements = treeBuilder.getNumElements();
- versionLbl.setText(dictionary.getMessageLibraryVersion());
- versionLbl.setToolTipText(String.format("#Messages: %d, #Elements: %d", numMessages, numElements));
- searchText.setEnabled(true);
- startLabel.setText("Ready for query");
- } catch (Exception e) {
- OseeLog.log(Activator.class, Level.SEVERE, "Problem during message jar processing", e);
- }
- }
- });
- }
-
- @Override
- public void onDictionaryUnloaded(IMessageDictionary dictionary) {
- Display.getDefault().syncExec(new Runnable() {
-
- @Override
- public void run() {
- setLibraryUnloadedState();
- }
-
- });
-
- }
-
- private void setLibraryUnloadedState() {
- if (treeViewer.getTree().isDisposed() || startLabel.isDisposed() || versionLbl.isDisposed() || searchText.isDisposed()) {
- return;
- }
- treeViewer.getTree().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
- startLabel.setText("message library not detected");
- treeViewer.setInput(null);
- versionLbl.setText("");
- versionLbl.setToolTipText("");
- searchText.setEnabled(false);
- }
-
- @Override
- public void dispose() {
- super.dispose();
- Activator.getDefault().getOteClientService().removeDictionaryListener(this);
- }
+ protected TreeViewer treeViewer;
+ protected Text searchText;
+ protected MessageViewLabelProvider labelProvider;
+
+ protected Action expandAction, collapseAction, refreshAction, filterByName, bugAction;
+ protected ViewerSorter nameSorter;
+ public static final String VIEW_ID = "org.eclipse.osee.ote.ui.message.view.MessageView";
+ private Label startLabel;
+ private Label versionLbl;
+ private Composite parentComposite;
+ private Button searchButton;
+ private int numMessages = 0;
+ private int numElements = 0;
+ private MessageTreeBuilder treeBuilder;
+
+ public MessageView() {
+ super();
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.verticalSpacing = 0;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ parent.setLayout(layout);
+ parentComposite = new Composite(parent, SWT.NONE);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ parentComposite.setLayoutData(layoutData);
+ Widgets.setFormLayout(parentComposite, 5, 5);
+
+ startLabel = new Label(parentComposite, SWT.LEFT);
+ Widgets.attachToParent(startLabel, SWT.TOP, 0, 0);
+ Widgets.attachToParent(startLabel, SWT.LEFT, 0, 0);
+ Widgets.attachToParent(startLabel, SWT.RIGHT, 50, 0);
+
+ versionLbl = new Label(parentComposite, SWT.CENTER);
+ Widgets.attachToParent(versionLbl, SWT.TOP, 0, 0);
+ Widgets.attachToParent(versionLbl, SWT.LEFT, 50, 5);
+ Widgets.attachToParent(versionLbl, SWT.RIGHT, 100, 0);
+
+ // Create the tree treeViewer as a child of the composite parent
+ treeViewer = new TreeViewer(parentComposite);
+ treeViewer.setContentProvider(new MessageContentProvider());
+ labelProvider = new MessageViewLabelProvider();
+ treeViewer.setLabelProvider(labelProvider);
+ final Tree tree = treeViewer.getTree();
+ Widgets.attachToControl(tree, startLabel, SWT.TOP, SWT.BOTTOM, 5);
+ Widgets.attachToParent(tree, SWT.BOTTOM, 100, -50);
+ Widgets.attachToParent(tree, SWT.LEFT, 0, 0);
+ Widgets.attachToParent(tree, SWT.RIGHT, 100, 0);
+ treeViewer.setUseHashlookup(true);
+ // tree.setMenu(getPopupMenu(parent));
+ tree.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (e.button == 3) {
+ Point p = new Point(e.x, e.y);
+ final Menu contextMenu = getPopupMenu(tree.getParent());
+ if (contextMenu != null) {
+ p = tree.toDisplay(p);
+ contextMenu.setLocation(p);
+ contextMenu.setVisible(true);
+
+ Activator.getDefault().setHelp(contextMenu, "messageViewWatch", "org.eclipse.osee.framework.help.ui");
+ }
+ }
+ }
+
+ });
+ treeBuilder = new MessageTreeBuilder();
+ /*
+ * Create a text field to be used for filtering the elements displayed by the tree treeViewer
+ */
+ Group grp = new Group(parentComposite, SWT.NONE);
+ Widgets.attachToControl(grp, tree, SWT.TOP, SWT.BOTTOM, 5);
+ Widgets.attachToParent(grp, SWT.LEFT, 0, 0);
+ Widgets.attachToParent(grp, SWT.RIGHT, 100, 0);
+ layout = new GridLayout();
+ layout.numColumns = 3;
+ grp.setLayout(layout);
+ Label l = new Label(grp, SWT.NULL);
+ l.setText("Search:");
+ l.setToolTipText("Enter a regular expression filter.\nEnter space to see all.");
+
+ searchText = new Text(grp, SWT.SINGLE | SWT.BORDER);
+ searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ searchText.addTraverseListener(new TraverseListener() {
+
+ public void keyTraversed(TraverseEvent event) {
+ if (event.detail == SWT.TRAVERSE_RETURN) {
+ search(searchText.getText());
+ }
+ }
+
+ });
+
+ searchText.addVerifyListener(new VerifyListener() {
+ public void verifyText(VerifyEvent e) {
+ char chr = e.character;
+ if (chr >= 'a' && chr <= 'z') {
+ final char[] chars = new char[] {chr};
+ e.text = new String(chars).toUpperCase();
+ }
+ }
+ });
+
+ searchButton = new Button(grp, SWT.PUSH);
+ searchButton.setText("Go");
+ searchButton.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ search(searchText.getText());
+ }
+ });
+
+ // Create menu, toolbars, filters, sorters.
+ createFiltersAndSorters();
+ createActions();
+ createMenus();
+ createToolbar();
+
+ treeViewer.setSorter(nameSorter);
+ treeViewer.expandToLevel(0);
+
+ RootNode root = new RootNode("empty");
+ /*
+ * instantiate dummy nodes since the first time these classes are instantiated must be from a UI thread.
+ */
+ MessageNode msgNode = new MessageNode("osee.test.msg.pubsub.DUMMY_MSG", null);
+ ElementPath obj = new ElementPath();
+ obj.add("DUMMY");
+ ElementNode node = new ElementNode(obj);
+ msgNode.addChild(node);
+ treeViewer.setInput(root);
+ setHelpContexts();
+ setLibraryUnloadedState();
+ Activator.getDefault().getOteClientService().addDictionaryListener(this);
+ }
+
+ private void setHelpContexts() {
+ Activator.getDefault().setHelp(parentComposite.getParent(), "messageView", "org.eclipse.osee.framework.help.ui");
+ Activator.getDefault().setHelp(searchButton, "messageViewSearch", "org.eclipse.osee.framework.help.ui");
+ Activator.getDefault().setHelp(searchText, "messageViewSearch", "org.eclipse.osee.framework.help.ui");
+ }
+
+ /**
+ * sets the filter for searches
+ */
+ private void search(final String searchPattern) {
+ final Color bgColor = treeViewer.getTree().getBackground();
+ treeViewer.getTree().setBackground(Displays.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+ searchText.setEnabled(false);
+ searchButton.setEnabled(false);
+ final Job searchJob = new Job("Searching Message.jar") {
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("searching jar", numElements);
+ try {
+ String searchTxt = searchPattern;
+ if (searchPattern.equals("")) {
+ searchTxt = ".*";
+ }
+ try {
+ final Pattern pattern = Pattern.compile(searchTxt);
+ final Collection<Map.Entry<String, ArrayList<String>>> map = treeBuilder.getMessages();
+ if (map.size() > 0) {
+ final RootNode root = new RootNode("root");
+ for (Map.Entry<String, ArrayList<String>> entry : map) {
+ final String name = entry.getKey().substring(entry.getKey().lastIndexOf('.') + 1);
+ final Matcher matcher = pattern.matcher(name);
+
+ if (matcher.matches()) {
+ MessageNode msgNode = new MessageNode(entry.getKey());
+ root.addChild(msgNode);
+ for (String elementName : entry.getValue()) {
+ ElementPath obj = new ElementPath(msgNode.getMessageClassName(), elementName);
+ ElementNode node = new ElementNode(obj);
+ msgNode.addChild(node);
+ }
+ } else {
+ LinkedList<String> matches = new LinkedList<String>();
+ for (String elementName : entry.getValue()) {
+ if (pattern.matcher(elementName).matches()) {
+ matches.add(elementName);
+ }
+ }
+ if (!matches.isEmpty()) {
+ MessageNode msgNode = new MessageNode(entry.getKey());
+ root.addChild(msgNode);
+ for (String elementName : matches) {
+ ElementPath obj = new ElementPath(msgNode.getMessageClassName(), elementName);
+ ElementNode node = new ElementNode(obj);
+ msgNode.addChild(node);
+ }
+ }
+ }
+ monitor.worked(entry.getValue().size());
+ }
+
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+
+ treeViewer.setInput(root);
+ if (!root.hasChildren()) {
+ MessageDialog.openError(Displays.getActiveShell(), "Search",
+ "No matches found for pattern " + searchPattern);
+ }
+ }
+
+ });
+ } else {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openError(Displays.getActiveShell(), "Search",
+ "There are no messages available for searching");
+ }
+ });
+ }
+ } catch (final PatternSyntaxException e) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openError(Displays.getActiveShell(), "Search Error", e.getMessage());
+
+ }
+ });
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, "", null);
+ }
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, IStatus.OK, "", null);
+ } catch (Throwable t) {
+ OseeLog.log(Activator.class, Level.SEVERE, "exception during search operation", t);
+ return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, IStatus.CANCEL, "", t);
+ } finally {
+ monitor.done();
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ treeViewer.getTree().setBackground(bgColor);
+ searchText.setEnabled(true);
+ searchButton.setEnabled(true);
+ }
+ });
+ }
+ }
+
+ };
+ searchJob.setUser(true);
+ searchJob.schedule();
+ }
+
+ private Menu getPopupMenu(final Composite composite) {
+ final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
+ final AbstractTreeNode node = (AbstractTreeNode) selection.getFirstElement();
+ final Menu previewMenu = new Menu(composite);
+
+ // if there's nothing selected in the tree, no need to display a menu.
+ if (node == null) {
+ return null;
+ }
+
+ MenuItem item = new MenuItem(previewMenu, SWT.CASCADE);
+ item.setText("Watch");
+ item.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ WatchView watchView = (WatchView) page.findView(WatchView.VIEW_ID);
+ if (watchView == null) {
+ watchView = launchMessageWatch(page);
+ }
+ if (watchView != null) {
+ final Iterator<?> iter = selection.iterator();
+ AddWatchParameter addWatchParam = new AddWatchParameter();
+ while (iter.hasNext()) {
+ final AbstractTreeNode node = (AbstractTreeNode) iter.next();
+ if (node instanceof MessageNode) {
+ addWatchParam.addMessage(((MessageNode) node).getMessageClassName());
+ } else if (node instanceof ElementNode) {
+ addWatchParam.addMessage(((ElementNode) node).getElementPath().getMessageName(),
+ ((ElementNode) node).getElementPath());
+ }
+ }
+ watchView.addWatchMessage(addWatchParam);
+ watchView.refresh();
+ }
+ } catch (RuntimeException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "exception during attempt to watch", ex);
+ }
+ }
+ });
+
+ if (node instanceof MessageNode) {
+ item = new MenuItem(previewMenu, SWT.CASCADE);
+ item.setText("Watch All");
+ item.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ WatchView watchView = (WatchView) page.findView(WatchView.VIEW_ID);
+ if (watchView == null) {
+ watchView = launchMessageWatch(page);
+ }
+ if (watchView != null) {
+ final Iterator<?> iter = selection.iterator();
+ final RootNode root = (RootNode) treeViewer.getInput();
+ AddWatchParameter parameter = new AddWatchParameter();
+ while (iter.hasNext()) {
+ final AbstractTreeNode node = (AbstractTreeNode) iter.next();
+ if (node.getParent() == root) {
+ if (node instanceof MessageNode) {
+ parameter.addMessage(((MessageNode) node).getMessageClassName());
+ for (AbstractTreeNode child : node.getChildren()) {
+ ElementPath obj =
+ new ElementPath(((MessageNode) node).getMessageClassName(), child.getName());
+ parameter.addMessage(((MessageNode) node).getMessageClassName(), obj);
+ }
+ }
+ } else {
+ MessageNode parent = (MessageNode) node.getParent();
+ if (!parameter.containsMessage(parent.getName())) {
+ for (int index = 0; index < parent.getChildren().size(); index++) {
+ ElementPath obj = new ElementPath(parent.getMessageClassName(), node.getName());
+ parameter.addMessage(parent.getMessageClassName(), obj);
+ }
+ }
+ }
+ }
+
+ watchView.addWatchMessage(parameter);
+ watchView.refresh();
+ }
+ } catch (RuntimeException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "Exception during attempt to watch all", ex);
+ }
+ }
+ });
+ }
+
+ return previewMenu;
+ }
+
+ private WatchView launchMessageWatch(IWorkbenchPage page) {
+ WatchView watchView = null;
+ try {
+ watchView = (WatchView) page.showView(WatchView.VIEW_ID);
+ } catch (PartInitException e1) {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Launch Error",
+ "Couldn't Launch MsgWatch " + e1.getMessage());
+ return null;
+ }
+ return watchView;
+ }
+
+ protected void createFiltersAndSorters() {
+ nameSorter = new MessageTreeSorter();
+ }
+
+ protected void createActions() {
+ final TreeViewer ftv = treeViewer;
+ expandAction = new Action("Expand All") {
+
+ @Override
+ public void run() {
+ treeViewer.getTree().setRedraw(false);
+ ftv.expandAll();
+ treeViewer.getTree().setRedraw(true);
+ }
+ };
+ expandAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.EXPAND_STATE));
+ expandAction.setToolTipText("Expand All");
+
+ collapseAction = new Action("Collapse All") {
+
+ @Override
+ public void run() {
+ treeViewer.getTree().setRedraw(false);
+ ftv.collapseAll();
+ treeViewer.getTree().setRedraw(true);
+ }
+ };
+ collapseAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.COLLAPSE_STATE));
+ collapseAction.setToolTipText("Collapse All");
+
+ refreshAction = new Action("Reload Messages from JAR") {
+
+ @Override
+ public void run() {
+ search(".*");
+ }
+ };
+ refreshAction.setToolTipText("Reload Messages from JAR");
+ refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.REFRESH));
+
+ OseeUiActions.addBugToViewToolbar(this, this, Activator.getDefault(), VIEW_ID, "Message View");
+ }
+
+ protected void createMenus() {
+ IMenuManager rootMenuManager = getViewSite().getActionBars().getMenuManager();
+ rootMenuManager.setRemoveAllWhenShown(true);
+ rootMenuManager.addMenuListener(new IMenuListener() {
+
+ public void menuAboutToShow(IMenuManager mgr) {
+ fillMenu(mgr);
+ }
+ });
+ fillMenu(rootMenuManager);
+ }
+
+ protected void fillMenu(IMenuManager rootMenuManager) {
+ rootMenuManager.add(refreshAction);
+ rootMenuManager.add(expandAction);
+ rootMenuManager.add(collapseAction);
+ }
+
+ protected void createToolbar() {
+ IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
+ toolbarManager.add(refreshAction);
+ toolbarManager.add(expandAction);
+ toolbarManager.add(collapseAction);
+ // toolbarManager.add(bugAction);
+ }
+
+ /*
+ * @see IWorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ parentComposite.setFocus();
+ }
+
+ public String getActionDescription() {
+ return "";
+ }
+
+ @Override
+ public void onDictionaryLoaded(final IMessageDictionary dictionary) {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ startLabel.setText("processing library...");
+ treeViewer.getTree().setBackground(Displays.getSystemColor(SWT.COLOR_WHITE));
+ treeBuilder.clear();
+ dictionary.generateMessageIndex(treeBuilder);
+ numMessages = treeBuilder.getNumMessages();
+ numElements = treeBuilder.getNumElements();
+ versionLbl.setText(dictionary.getMessageLibraryVersion());
+ versionLbl.setToolTipText(String.format("#Messages: %d, #Elements: %d", numMessages, numElements));
+ searchText.setEnabled(true);
+ startLabel.setText("Ready for query");
+ } catch (Exception e) {
+ OseeLog.log(Activator.class, Level.SEVERE, "Problem during message jar processing", e);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onDictionaryUnloaded(IMessageDictionary dictionary) {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ setLibraryUnloadedState();
+ }
+
+ });
+
+ }
+
+ private void setLibraryUnloadedState() {
+ if (treeViewer.getTree().isDisposed() || startLabel.isDisposed() || versionLbl.isDisposed() || searchText.isDisposed()) {
+ return;
+ }
+ treeViewer.getTree().setBackground(Displays.getSystemColor(SWT.COLOR_GRAY));
+ startLabel.setText("message library not detected");
+ treeViewer.setInput(null);
+ versionLbl.setText("");
+ versionLbl.setToolTipText("");
+ searchText.setEnabled(false);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ Activator.getDefault().getOteClientService().removeDictionaryListener(this);
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/DetailsBox.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/DetailsBox.java
index a330a033b44..ced8e3e4275 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/DetailsBox.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/DetailsBox.java
@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IRegistryEventListener;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.ote.message.Message;
import org.eclipse.osee.ote.message.data.MessageData;
@@ -41,7 +42,6 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.osgi.framework.Bundle;
@@ -50,318 +50,319 @@ import org.osgi.framework.Bundle;
* @author Ken J. Aguilar
*/
public class DetailsBox implements IRegistryEventListener {
- private static final String EXTENSION_POINT_ID = "org.eclipse.osee.ote.ui.message.detailsProvider";
- private static final String ELEMENT = "TabProvider";
- private static final String PAYLOAD_TXT = "\npayload:\n 0: ";
- private static final String HEADER_TXT = "header:\n 0: ";
- private static int HEX_DUMP_BYTES_PER_ROW = 16;
- private static int HEX_DUMP_CHARS_PER_BYTE = 3;
-
- /**
- * number of characters that lead each row in the hex dump, these characters represent the byte offset indicator for
- * each hex row
- */
- private static int HEX_DUMP_PREFIX_CHARS = 8;
- private static int HEX_DUMP_NON_PREFIX_CHAR = HEX_DUMP_BYTES_PER_ROW * HEX_DUMP_CHARS_PER_BYTE;
- /**
- * total number of characters per hex dump row including the newline character
- */
- private static int HEX_DUMP_LINE_WIDTH = HEX_DUMP_PREFIX_CHARS + HEX_DUMP_NON_PREFIX_CHAR + 1;
-
- private final TabFolder infoFolder;
- private final TabItem hexDumpTab;
- private final StyledText hexDumpTxt;
- private final Font courier;
- private final Image hexImg;
- private final StringBuilder strBuilder = new StringBuilder(8500);
- private TabItem selectedTab;
- private final HashMap<String, TabItem> detailsProviderMap = new HashMap<String, TabItem>();
-
- private static final String[] hexTbl = new String[256];
-
- static {
- for (int i = 0; i < 256; i++) {
- hexTbl[i] = String.format("%02X ", i);
- }
- }
-
- public DetailsBox(Composite parent) {
- hexImg = ImageManager.getImage(OteMessageImage.HEX);
- courier = new Font(parent.getDisplay(), "Courier", 10, SWT.NORMAL);
- /* Create Text box to display values of selected messages */
- infoFolder = new TabFolder(parent, SWT.BORDER);
-
- hexDumpTab = new TabItem(infoFolder, SWT.NONE);
- hexDumpTab.setText("Hex Dump");
- hexDumpTab.setImage(hexImg);
- hexDumpTab.setToolTipText("displays hex dump of currently selected message");
- hexDumpTxt =
- new StyledText(infoFolder, SWT.DOUBLE_BUFFERED | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
- hexDumpTxt.setFont(courier);
- hexDumpTab.setControl(hexDumpTxt);
-
- installExtensionRegistryListener();
-
- infoFolder.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedTab = (TabItem) e.item;
- }
- });
- selectedTab = infoFolder.getItem(infoFolder.getSelectionIndex());
- }
-
- /**
- * display details about specified node
- *
- * @param node node whose details will be displayed in the detail window of the GUI
- */
- public void setDetailText(final AbstractTreeNode node) {
- if (selectedTab == null) {
- return;
- }
- if (selectedTab == hexDumpTab) {
- renderHex(node);
- } else {
- DetailsProvider provider = (DetailsProvider) selectedTab.getControl();
- provider.render(node);
- }
-
- }
-
- public void dispose() {
- courier.dispose();
- }
-
- private void renderHex(AbstractTreeNode node) {
- if (!node.isEnabled()) {
- hexDumpTxt.setText(node.getName() + "\nDISABLED: " + node.getDisabledReason());
- return;
- }
- final INodeVisitor<Object> visitor = new INodeVisitor<Object>() {
- public Object elementNode(final ElementNode node) {
- hexDumpTxt.setStyleRange(null);
- WatchedMessageNode msgNode = (WatchedMessageNode) node.getMessageNode();
- if (!msgNode.getSubscription().isResolved()) {
- hexDumpTxt.setText(node.getName() + " not found in library");
- return null;
- }
- final Message<?, ?, ?> msg = msgNode.getSubscription().getMessage();
- if (msg.isDestroyed()) {
- return null;
- }
- hexDumpTxt.setRedraw(false);
- int payloadStart = printByteDump(msg);
-
- Element e = msg.getElement(node.getElementPath().getElementPath());
- if (e != null) {
- if (!e.isNonMappingElement()) {
- MessageData data = msg.getActiveDataSource();
- int headerSize = data.getMsgHeader() == null ? 0 : data.getMsgHeader().getHeaderSize();
- if (e.getByteOffset() >= data.getCurrentLength() - headerSize) {
- hexDumpTxt.setText("element outside of current message size");
- hexDumpTxt.setRedraw(true);
- return null;
- }
- StyleRange range = new StyleRange();
- range.background = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
- range.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
- int offset = e.getByteOffset() + e.getMsb() / 8;
- range.length = (e.getLsb() - e.getMsb() + 8) / 8 * HEX_DUMP_CHARS_PER_BYTE - 1;
- int line = offset / HEX_DUMP_BYTES_PER_ROW * HEX_DUMP_LINE_WIDTH;
- int lineIndent = offset % HEX_DUMP_BYTES_PER_ROW * HEX_DUMP_CHARS_PER_BYTE;
- range.start = line + lineIndent + payloadStart;
- if (HEX_DUMP_PREFIX_CHARS + lineIndent + range.length >= HEX_DUMP_LINE_WIDTH) {
- int remaing = range.length - (HEX_DUMP_LINE_WIDTH - lineIndent - 9);
- StyleRange[] ranges = new StyleRange[remaing / HEX_DUMP_NON_PREFIX_CHAR + 2];
- ranges[0] = range;
- range.length -= remaing;
- int c = 1;
- while (remaing > 0) {
- StyleRange newRange = new StyleRange();
- ranges[c] = newRange;
- newRange.background = range.background;
- newRange.foreground = range.foreground;
- newRange.start = line + c * HEX_DUMP_LINE_WIDTH + payloadStart;
- newRange.length = remaing < HEX_DUMP_NON_PREFIX_CHAR ? remaing : HEX_DUMP_NON_PREFIX_CHAR;
- remaing -= newRange.length;
- c++;
- }
- hexDumpTxt.setStyleRanges(ranges);
- } else {
- hexDumpTxt.setStyleRange(range);
- }
- hexDumpTxt.setTopIndex(msg.getHeaderSize() / HEX_DUMP_BYTES_PER_ROW + offset / HEX_DUMP_BYTES_PER_ROW + 2);
- hexDumpTxt.setRedraw(true);
- }
- }
-
- return node;
- }
-
- public Object messageNode(final MessageNode node) {
- WatchedMessageNode msgNode = (WatchedMessageNode) node;
- final Message<?, ?, ?> msg = msgNode.getSubscription().getMessage();
- if (msg != null && !msg.isDestroyed()) {
- hexDumpTxt.setRedraw(false);
- printByteDump(msg);
- hexDumpTxt.setStyleRange(null);
- hexDumpTxt.setRedraw(true);
- }
- return node;
- }
-
- public Object rootNode(RootNode node) {
- return node;
- }
-
- };
- node.visit(visitor);
- }
-
- /**
- * writes message data to a buffer in hex format
- *
- * @param data
- * @param offset
- */
- private int printByteDump(Message<?, ?, ?> msg) {
- strBuilder.setLength(0);
- int ypos = hexDumpTxt.getTopIndex();
- int xpos = hexDumpTxt.getHorizontalIndex();
- int cursorPos = hexDumpTxt.getCaretOffset();
- final byte[] data = msg.getData();
- int columnCount = 0;
- strBuilder.append(HEADER_TXT);
- for (int i = 0; i < msg.getHeaderSize(); i++) {
- if (columnCount == HEX_DUMP_BYTES_PER_ROW) {
- strBuilder.append('\n').append(String.format("%5d: ", i));
- columnCount = 0;
- }
- strBuilder.append(hexTbl[data[i] & 0xFF]);
- columnCount++;
- }
- strBuilder.append(PAYLOAD_TXT);
- int payloadStart = strBuilder.length();
- columnCount = 0;
- for (int i = msg.getHeaderSize(); i < msg.getHeaderSize() + msg.getPayloadSize(); i++) {
- if (columnCount == HEX_DUMP_BYTES_PER_ROW) {
- strBuilder.append('\n').append(String.format("%5d: ", i - msg.getHeaderSize()));
- columnCount = 0;
- }
- strBuilder.append(hexTbl[data[i] & 0xFF]);
- columnCount++;
- }
- strBuilder.append('\n');
- hexDumpTxt.setText(strBuilder.toString());
- hexDumpTxt.setTopIndex(ypos);
- hexDumpTxt.setHorizontalIndex(xpos);
- hexDumpTxt.setCaretOffset(cursorPos);
- return payloadStart;
- }
-
- private void installExtensionRegistryListener() {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- if (extensionRegistry == null) {
- throw new IllegalStateException("The extension registry is unavailable");
- }
-
- IExtensionPoint point = extensionRegistry.getExtensionPoint(EXTENSION_POINT_ID);
- if (point == null) {
- return;
- }
- added(point.getExtensions());
- extensionRegistry.addListener(this, EXTENSION_POINT_ID);
- }
-
- @Override
- public void added(IExtension[] extensions) {
- final List<IConfigurationElement> newElements = new LinkedList<IConfigurationElement>();
- for (IExtension extension : extensions) {
- for (IConfigurationElement element : extension.getConfigurationElements()) {
- if (element.getName().equals(ELEMENT)) {
- newElements.add(element);
- }
- }
- }
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- for (IConfigurationElement element : newElements) {
- String className = element.getAttribute("className");
- String bundleName = element.getContributor().getName();
- Bundle bundle = Platform.getBundle(bundleName);
- if (bundle == null) {
- OseeLog.log(DetailsBox.class, Level.SEVERE, String.format(
- "no bundle found for name %s while handling extension element %s", bundleName,
- element.getName()));
- return;
- }
- try {
- Class<?> clazz = bundle.loadClass(className);
- Class<? extends DetailsProvider> detailsClazz = clazz.asSubclass(DetailsProvider.class);
- Constructor<? extends DetailsProvider> constructor =
- detailsClazz.getConstructor(Composite.class, int.class);
- try {
- DetailsProvider provider = constructor.newInstance(infoFolder, SWT.NONE);
- TabItem newTab = new TabItem(infoFolder, SWT.NONE);
- newTab.setText(provider.getTabText());
- newTab.setToolTipText(provider.getTabToolTipText());
- newTab.setControl(provider);
- detailsProviderMap.put(element.getDeclaringExtension().getUniqueIdentifier(), newTab);
- } catch (Exception ex) {
- OseeLog.log(DetailsBox.class, Level.SEVERE, String.format("failed to install details provider"));
- }
- } catch (ClassCastException ex) {
- OseeLog.log(DetailsBox.class, Level.SEVERE, String.format(
- "the class named %s is not a subclass of %s", className, DetailsProvider.class.getName()));
- } catch (ClassNotFoundException ex) {
- OseeLog.log(DetailsBox.class, Level.SEVERE, String.format("no class found named %s in bundle %s",
- className, bundleName));
- } catch (NoSuchMethodException ex) {
- OseeLog.log(DetailsBox.class, Level.SEVERE, String.format(
- "can't find appropriate constructor for %s", className));
- }
- }
- }
- });
-
- }
-
- @Override
- public void added(IExtensionPoint[] points) {
-
- }
-
- @Override
- public void removed(IExtension[] extensions) {
- final List<TabItem> removedElements = new LinkedList<TabItem>();
- for (IExtension extension : extensions) {
- TabItem item = detailsProviderMap.get(extension.getUniqueIdentifier());
- if (item != null) {
- removedElements.add(item);
- }
- }
-
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
-
- for (TabItem item : removedElements) {
- if (selectedTab == item) {
- selectedTab = null;
- infoFolder.setSelection(hexDumpTab);
- }
- item.dispose();
- }
- }
- });
- }
-
- @Override
- public void removed(IExtensionPoint[] arg0) {
- }
+ private static final String EXTENSION_POINT_ID = "org.eclipse.osee.ote.ui.message.detailsProvider";
+ private static final String ELEMENT = "TabProvider";
+ private static final String PAYLOAD_TXT = "\npayload:\n 0: ";
+ private static final String HEADER_TXT = "header:\n 0: ";
+ private static int HEX_DUMP_BYTES_PER_ROW = 16;
+ private static int HEX_DUMP_CHARS_PER_BYTE = 3;
+
+ /**
+ * number of characters that lead each row in the hex dump, these characters represent the byte offset indicator for
+ * each hex row
+ */
+ private static int HEX_DUMP_PREFIX_CHARS = 8;
+ private static int HEX_DUMP_NON_PREFIX_CHAR = HEX_DUMP_BYTES_PER_ROW * HEX_DUMP_CHARS_PER_BYTE;
+ /**
+ * total number of characters per hex dump row including the newline character
+ */
+ private static int HEX_DUMP_LINE_WIDTH = HEX_DUMP_PREFIX_CHARS + HEX_DUMP_NON_PREFIX_CHAR + 1;
+
+ private final TabFolder infoFolder;
+ private final TabItem hexDumpTab;
+ private final StyledText hexDumpTxt;
+ private final Font courier;
+ private final Image hexImg;
+ private final StringBuilder strBuilder = new StringBuilder(8500);
+ private TabItem selectedTab;
+ private final HashMap<String, TabItem> detailsProviderMap = new HashMap<String, TabItem>();
+
+ private static final String[] hexTbl = new String[256];
+
+ static {
+ for (int i = 0; i < 256; i++) {
+ hexTbl[i] = String.format("%02X ", i);
+ }
+ }
+
+ public DetailsBox(Composite parent) {
+ hexImg = ImageManager.getImage(OteMessageImage.HEX);
+ courier = new Font(parent.getDisplay(), "Courier", 10, SWT.NORMAL);
+ /* Create Text box to display values of selected messages */
+ infoFolder = new TabFolder(parent, SWT.BORDER);
+
+ hexDumpTab = new TabItem(infoFolder, SWT.NONE);
+ hexDumpTab.setText("Hex Dump");
+ hexDumpTab.setImage(hexImg);
+ hexDumpTab.setToolTipText("displays hex dump of currently selected message");
+ hexDumpTxt =
+ new StyledText(infoFolder, SWT.DOUBLE_BUFFERED | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
+ hexDumpTxt.setFont(courier);
+ hexDumpTab.setControl(hexDumpTxt);
+
+ installExtensionRegistryListener();
+
+ infoFolder.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ selectedTab = (TabItem) e.item;
+ }
+ });
+ selectedTab = infoFolder.getItem(infoFolder.getSelectionIndex());
+ }
+
+ /**
+ * display details about specified node
+ *
+ * @param node node whose details will be displayed in the detail window of the GUI
+ */
+ public void setDetailText(final AbstractTreeNode node) {
+ if (selectedTab == null) {
+ return;
+ }
+ if (selectedTab == hexDumpTab) {
+ renderHex(node);
+ } else {
+ DetailsProvider provider = (DetailsProvider) selectedTab.getControl();
+ provider.render(node);
+ }
+
+ }
+
+ public void dispose() {
+ courier.dispose();
+ }
+
+ private void renderHex(AbstractTreeNode node) {
+ if (!node.isEnabled()) {
+ hexDumpTxt.setText(node.getName() + "\nDISABLED: " + node.getDisabledReason());
+ return;
+ }
+ final INodeVisitor<Object> visitor = new INodeVisitor<Object>() {
+ public Object elementNode(final ElementNode node) {
+ hexDumpTxt.setStyleRange(null);
+ WatchedMessageNode msgNode = (WatchedMessageNode) node.getMessageNode();
+ if (!msgNode.getSubscription().isResolved()) {
+ hexDumpTxt.setText(node.getName() + " not found in library");
+ return null;
+ }
+ final Message<?, ?, ?> msg = msgNode.getSubscription().getMessage();
+ if (msg.isDestroyed()) {
+ return null;
+ }
+ hexDumpTxt.setRedraw(false);
+ int payloadStart = printByteDump(msg);
+
+ Element e = msg.getElement(node.getElementPath().getElementPath());
+ if (e != null) {
+ if (!e.isNonMappingElement()) {
+ MessageData data = msg.getActiveDataSource();
+ int headerSize = data.getMsgHeader() == null ? 0 : data.getMsgHeader().getHeaderSize();
+ if (e.getByteOffset() >= data.getCurrentLength() - headerSize) {
+ hexDumpTxt.setText("element outside of current message size");
+ hexDumpTxt.setRedraw(true);
+ return null;
+ }
+ StyleRange range = new StyleRange();
+ range.background = Displays.getSystemColor(SWT.COLOR_GRAY);
+ range.foreground = Displays.getSystemColor(SWT.COLOR_BLACK);
+ int offset = e.getByteOffset() + e.getMsb() / 8;
+ range.length = (e.getLsb() - e.getMsb() + 8) / 8 * HEX_DUMP_CHARS_PER_BYTE - 1;
+ int line = offset / HEX_DUMP_BYTES_PER_ROW * HEX_DUMP_LINE_WIDTH;
+ int lineIndent = offset % HEX_DUMP_BYTES_PER_ROW * HEX_DUMP_CHARS_PER_BYTE;
+ range.start = line + lineIndent + payloadStart;
+ if (HEX_DUMP_PREFIX_CHARS + lineIndent + range.length >= HEX_DUMP_LINE_WIDTH) {
+ int remaing = range.length - (HEX_DUMP_LINE_WIDTH - lineIndent - 9);
+ StyleRange[] ranges = new StyleRange[remaing / HEX_DUMP_NON_PREFIX_CHAR + 2];
+ ranges[0] = range;
+ range.length -= remaing;
+ int c = 1;
+ while (remaing > 0) {
+ StyleRange newRange = new StyleRange();
+ ranges[c] = newRange;
+ newRange.background = range.background;
+ newRange.foreground = range.foreground;
+ newRange.start = line + c * HEX_DUMP_LINE_WIDTH + payloadStart;
+ newRange.length = remaing < HEX_DUMP_NON_PREFIX_CHAR ? remaing : HEX_DUMP_NON_PREFIX_CHAR;
+ remaing -= newRange.length;
+ c++;
+ }
+ hexDumpTxt.setStyleRanges(ranges);
+ } else {
+ hexDumpTxt.setStyleRange(range);
+ }
+ hexDumpTxt.setTopIndex(msg.getHeaderSize() / HEX_DUMP_BYTES_PER_ROW + offset / HEX_DUMP_BYTES_PER_ROW + 2);
+ hexDumpTxt.setRedraw(true);
+ }
+ }
+
+ return node;
+ }
+
+ public Object messageNode(final MessageNode node) {
+ WatchedMessageNode msgNode = (WatchedMessageNode) node;
+ final Message<?, ?, ?> msg = msgNode.getSubscription().getMessage();
+ if (msg != null && !msg.isDestroyed()) {
+ hexDumpTxt.setRedraw(false);
+ printByteDump(msg);
+ hexDumpTxt.setStyleRange(null);
+ hexDumpTxt.setRedraw(true);
+ }
+ return node;
+ }
+
+ public Object rootNode(RootNode node) {
+ return node;
+ }
+
+ };
+ node.visit(visitor);
+ }
+
+ /**
+ * writes message data to a buffer in hex format
+ *
+ * @param data
+ * @param offset
+ */
+ private int printByteDump(Message<?, ?, ?> msg) {
+ strBuilder.setLength(0);
+ int ypos = hexDumpTxt.getTopIndex();
+ int xpos = hexDumpTxt.getHorizontalIndex();
+ int cursorPos = hexDumpTxt.getCaretOffset();
+ final byte[] data = msg.getData();
+ int columnCount = 0;
+ strBuilder.append(HEADER_TXT);
+ for (int i = 0; i < msg.getHeaderSize(); i++) {
+ if (columnCount == HEX_DUMP_BYTES_PER_ROW) {
+ strBuilder.append('\n').append(String.format("%5d: ", i));
+ columnCount = 0;
+ }
+ strBuilder.append(hexTbl[data[i] & 0xFF]);
+ columnCount++;
+ }
+ strBuilder.append(PAYLOAD_TXT);
+ int payloadStart = strBuilder.length();
+ columnCount = 0;
+ for (int i = msg.getHeaderSize(); i < msg.getHeaderSize() + msg.getPayloadSize(); i++) {
+ if (columnCount == HEX_DUMP_BYTES_PER_ROW) {
+ strBuilder.append('\n').append(String.format("%5d: ", i - msg.getHeaderSize()));
+ columnCount = 0;
+ }
+ strBuilder.append(hexTbl[data[i] & 0xFF]);
+ columnCount++;
+ }
+ strBuilder.append('\n');
+ hexDumpTxt.setText(strBuilder.toString());
+ hexDumpTxt.setTopIndex(ypos);
+ hexDumpTxt.setHorizontalIndex(xpos);
+ hexDumpTxt.setCaretOffset(cursorPos);
+ return payloadStart;
+ }
+
+ private void installExtensionRegistryListener() {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ if (extensionRegistry == null) {
+ throw new IllegalStateException("The extension registry is unavailable");
+ }
+
+ IExtensionPoint point = extensionRegistry.getExtensionPoint(EXTENSION_POINT_ID);
+ if (point == null) {
+ return;
+ }
+ added(point.getExtensions());
+ extensionRegistry.addListener(this, EXTENSION_POINT_ID);
+ }
+
+ @Override
+ public void added(IExtension[] extensions) {
+ final List<IConfigurationElement> newElements = new LinkedList<IConfigurationElement>();
+ for (IExtension extension : extensions) {
+ for (IConfigurationElement element : extension.getConfigurationElements()) {
+ if (element.getName().equals(ELEMENT)) {
+ newElements.add(element);
+ }
+ }
+ }
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ for (IConfigurationElement element : newElements) {
+ String className = element.getAttribute("className");
+ String bundleName = element.getContributor().getName();
+ Bundle bundle = Platform.getBundle(bundleName);
+ if (bundle == null) {
+ OseeLog.log(DetailsBox.class, Level.SEVERE, String.format(
+ "no bundle found for name %s while handling extension element %s", bundleName,
+ element.getName()));
+ return;
+ }
+ try {
+ Class<?> clazz = bundle.loadClass(className);
+ Class<? extends DetailsProvider> detailsClazz = clazz.asSubclass(DetailsProvider.class);
+ Constructor<? extends DetailsProvider> constructor =
+ detailsClazz.getConstructor(Composite.class, int.class);
+ try {
+ DetailsProvider provider = constructor.newInstance(infoFolder, SWT.NONE);
+ TabItem newTab = new TabItem(infoFolder, SWT.NONE);
+ newTab.setText(provider.getTabText());
+ newTab.setToolTipText(provider.getTabToolTipText());
+ newTab.setControl(provider);
+ detailsProviderMap.put(element.getDeclaringExtension().getUniqueIdentifier(), newTab);
+ } catch (Exception ex) {
+ OseeLog.log(DetailsBox.class, Level.SEVERE, String.format("failed to install details provider"));
+ }
+ } catch (ClassCastException ex) {
+ OseeLog.log(
+ DetailsBox.class,
+ Level.SEVERE,
+ String.format("the class named %s is not a subclass of %s", className,
+ DetailsProvider.class.getName()));
+ } catch (ClassNotFoundException ex) {
+ OseeLog.log(DetailsBox.class, Level.SEVERE,
+ String.format("no class found named %s in bundle %s", className, bundleName));
+ } catch (NoSuchMethodException ex) {
+ OseeLog.log(DetailsBox.class, Level.SEVERE,
+ String.format("can't find appropriate constructor for %s", className));
+ }
+ }
+ }
+ });
+
+ }
+
+ @Override
+ public void added(IExtensionPoint[] points) {
+
+ }
+
+ @Override
+ public void removed(IExtension[] extensions) {
+ final List<TabItem> removedElements = new LinkedList<TabItem>();
+ for (IExtension extension : extensions) {
+ TabItem item = detailsProviderMap.get(extension.getUniqueIdentifier());
+ if (item != null) {
+ removedElements.add(item);
+ }
+ }
+
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+
+ for (TabItem item : removedElements) {
+ if (selectedTab == item) {
+ selectedTab = null;
+ infoFolder.setSelection(hexDumpTab);
+ }
+ item.dispose();
+ }
+ }
+ });
+ }
+
+ @Override
+ public void removed(IExtensionPoint[] arg0) {
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/ViewRefresher.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/ViewRefresher.java
index 9694c79ddda..4a8e2e321bc 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/ViewRefresher.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/ViewRefresher.java
@@ -19,11 +19,11 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.osee.framework.jdk.core.util.benchmark.Benchmark;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.ui.message.tree.AbstractTreeNode;
import org.eclipse.osee.ote.ui.message.tree.MessageNode;
import org.eclipse.osee.ote.ui.message.tree.WatchList;
import org.eclipse.osee.ote.ui.message.tree.WatchedMessageNode;
-import org.eclipse.swt.widgets.Display;
/**
* @author Andrew M. Finkbeiner
@@ -91,10 +91,10 @@ public class ViewRefresher implements Runnable {
for (MessageNode node : list.getMessages()) {
((WatchedMessageNode) node).determineDeltas(deltas);
}
- Display.getDefault().syncExec(task);
+ Displays.pendInDisplayThread(task);
benchMark.endSample();
- } catch (Throwable th) {
+ } catch (Throwable th) {
th.printStackTrace();
}
}
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java
index 28f73b0a857..9486d63aef9 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java
@@ -57,6 +57,7 @@ import org.eclipse.osee.framework.plugin.core.util.Jobs;
import org.eclipse.osee.framework.plugin.core.util.OseeData;
import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.OseeUiActivator;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.osee.ote.client.msg.IOteMessageService;
@@ -104,7 +105,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
@@ -120,894 +120,909 @@ import org.osgi.framework.Bundle;
*/
public final class WatchView extends ViewPart implements IActionable, IMessageDictionaryListener, ITestConnectionListener, IOteMessageClientView {
- protected static final OseeUiActivator plugin = Activator.getDefault();
-
- private MessageXViewer treeViewer;
-
- private final ClientMessageServiceTracker msgServiceTracker;
- private Label statusTxt;
-
- private final File watchFile;
- private Button recordButton;
- private final Benchmark benchMark = new Benchmark("Message Watch Update Time");
-
- private static final Pattern elmPattern = Pattern.compile("^(osee\\.test\\.core\\.message\\.[^.]+\\..+)\\.(.+)$");
- private static final Pattern msgPattern = Pattern.compile("^(osee\\.test\\.core\\.message\\.[^.]+\\..+)$");
-
- public static final String VIEW_ID = "org.eclipse.osee.ote.ui.message.watch.WatchView";
-
- private DetailsBox detailsBox;
- final IUdpTransferListener recBtnListener = new IUdpTransferListener() {
-
- public void onTransferComplete(final TransferConfig config) {
- OseeLog.log(Activator.class, Level.INFO, "file transfer complete");
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- openInfo("Message Recorder",
- "Message recording file " + config.getFileName() + " is now ready for opening");
- }
- });
- }
-
- public void onTransferException(final TransferConfig config, final Throwable t) {
- OseeLog.log(Activator.class, Level.SEVERE, "problems writing to recorder output file " + config.getFileName(),
- t);
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- recordButton.setSelection(false);
- openInfo("Message Recorder",
- "An exception occurred while writing to recorder output file " + config.getFileName());
- }
- });
- }
- };
-
- private IOteMessageService messageService = null;
-
- private final SelectionListener recBtnHandler = new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (recordButton.getSelection()) {
-
- RecordingWizard recordingWizard = new RecordingWizard(watchList);
- final WizardDialog recdialog = new WizardDialog(Display.getDefault().getActiveShell(), recordingWizard);
- int recResult = recdialog.open();
- if (Window.OK == recResult) {
- try {
- saveWatchFile();
- messageService.startRecording(recordingWizard.getFileName(),
- recordingWizard.getFilteredMessageRecordDetails()).addListener(recBtnListener);
- } catch (FileNotFoundException ex) {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Recording Error",
- "Failed to open file for writing. " + "Make sure its not being used by another application");
- recordButton.setSelection(false);
- } catch (Throwable ex) {
- OseeLog.log(Activator.class, Level.SEVERE, "Failed to start message recording", ex);
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Recording Error",
- "Exception ocurred while recording. see error log");
- recordButton.setSelection(false);
- }
- } else {
- recordButton.setSelection(false);
- }
- } else {
- try {
- messageService.stopRecording();
- } catch (IOException ioe) {
- OseeLog.log(Activator.class, Level.WARNING, "problem when attempting to stop recording", ioe);
- } catch (Throwable t) {
- OseeLog.log(Activator.class, Level.SEVERE, "problem when attempting to stop recording", t);
- }
- }
- }
- };
-
- private static enum Status {
- /**
- * no active test manager
- */
- NO_TEST_MANAGER("No test manager running"),
- /**
- * active test manager but not connected to a host
- */
- NOT_CONNECTED("%s: Not connected to a host"),
- /**
- * active test manager and connected to a host
- */
- CONNECTED("Connected to %s (%s)");
-
- private final String txt;
-
- Status(final String txt) {
- this.txt = txt;
- }
-
- public String asString(Object... args) {
- return String.format(txt, args);
- }
-
- }
-
- private Composite parentComposite;
- private WatchList watchList;
-
- public WatchView() {
- watchFile = OseeData.getFile("msgWatch.txt");
- msgServiceTracker = new ClientMessageServiceTracker(Activator.getDefault().getBundle().getBundleContext(), this);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- /**
- *
- */
- public void createPartControl(Composite parent) {
- final int numColumns = 4;
-
- parentComposite = parent;
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- layout.verticalSpacing = 0;
- layout.marginWidth = 5;
- layout.marginHeight = 5;
- parent.setLayout(layout);
-
- Label label = new Label(parent, SWT.RIGHT);
- label.setText("Status:");
- Widgets.positionGridItem(label, false, false, SWT.END, SWT.CENTER, 1);
-
- statusTxt = new Label(parent, SWT.READ_ONLY);
- statusTxt.setText(Status.NO_TEST_MANAGER.asString());
- Widgets.positionGridItem(statusTxt, false, false, SWT.FILL, SWT.BEGINNING, 3);
-
- Composite buttons = new Composite(parent, SWT.NONE);
- buttons.setLayout(new RowLayout(SWT.HORIZONTAL));
-
- recordButton = new Button(buttons, SWT.TOGGLE);
- recordButton.setText("REC");
- recordButton.setToolTipText("Record the messages and elements currently shown in Message Watch.");
- recordButton.addSelectionListener(recBtnHandler);
- recordButton.setEnabled(false);
-
- IExtension[] extensions =
- Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.osee.ote.ui.message.ToolbarItem").getExtensions();
- for (IExtension ext : extensions) {
- for (IConfigurationElement el : ext.getConfigurationElements()) {
- if (el.getName().equals("ToolbarItem")) {
- String actionClass = el.getAttribute("Action");
- String icon = el.getAttribute("Icon");
- String btnLabel = el.getAttribute("Label");
- String tooltip = el.getAttribute("Tooltip");
-
- Class<? extends Action> clazz;
- try {
- Bundle bundle = Platform.getBundle(el.getContributor().getName());
- clazz = bundle.loadClass(actionClass).asSubclass(Action.class);
-
- Action action = clazz.newInstance();
- ActionButton btn =
- new ActionButton(buttons, SWT.PUSH, action, btnLabel, el.getContributor().getName());
- btn.setToolTipText(tooltip);
-
- if (icon != null) {
- URL url = bundle.getEntry(icon);
- if (url == null) {
- throw new IllegalArgumentException(String.format("Invalid icon path [{%s}/%s]",
- el.getContributor().getName(), icon));
- } else {
- ImageDescriptor desc = ImageDescriptor.createFromURL(url);
- Image img = desc.createImage();
- if (img == null) {
- throw new IllegalArgumentException(String.format("Unable to create Image from [{%s}/%s]",
- el.getContributor().getName(), icon));
- } else {
- btn.setImage(img);
- }
- }
- }
- } catch (InvalidRegistryObjectException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- } catch (ClassNotFoundException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- } catch (InstantiationException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- } catch (IllegalAccessException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- } catch (IllegalArgumentException ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- }
- }
- }
-
- final SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
- // sashForm.SASH_WIDTH = 1;
- Widgets.positionGridItem(sashForm, true, true, SWT.FILL, SWT.FILL, numColumns);
-
- Composite comp = new Composite(sashForm, SWT.NONE);
- comp.setLayout(new GridLayout(1, false));
- GridData gd = new GridData(GridData.FILL_BOTH);
- comp.setLayoutData(gd);
-
- // Create the tree treeViewer as a child of the composite parent
- treeViewer =
- new MessageXViewer(comp,
- SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.DOUBLE_BUFFERED);
- GridData layoutData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
- layoutData.horizontalSpan = numColumns;
- treeViewer.getControl().setLayoutData(layoutData);
- watchList = new WatchList(this);
- treeViewer.setContentProvider(watchList);
- treeViewer.setLabelProvider(new MessageWatchLabelProvider(treeViewer));
- treeViewer.setUseHashlookup(true);
-
- treeViewer.getTree().setHeaderVisible(true);
- treeViewer.getTree().setLinesVisible(true);
-
- detailsBox = new DetailsBox(sashForm);
-
- sashForm.setWeights(new int[] {75, 25});
- // Add Listeners to the Tree
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- private AbstractTreeNode lastNodeSelected = null;
-
- public void selectionChanged(SelectionChangedEvent event) {
- final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
-
- final AbstractTreeNode node = (AbstractTreeNode) selection.getFirstElement();
- if (node != null && node != lastNodeSelected) {
- if (lastNodeSelected != null) {
- lastNodeSelected.setSelected(false);
- }
- node.setSelected(true);
- try {
- setDetailText(node);
- } catch (ArrayIndexOutOfBoundsException t) {
- // throw if there is an error in the message jar
- // (usually... )
- final String msg =
- String.format("Problems occurred when trying to display details for %s: (See Error Log)",
- node.getName());
- OseeLog.log(Activator.class, Level.SEVERE, "Error while displaying details for " + node.getName(), t);
- openInfo("Possible Message JAR Error", msg);
- }
- lastNodeSelected = node;
- }
- }
- });
- treeViewer.getTree().addMouseListener(new MouseAdapter() {
-
- @Override
- public void mouseDown(MouseEvent e) {
- if (e.button == 3) {
- showContextMenu(new Point(e.x, e.y));
- }
- }
- });
-
- // Create menu, toolbars, filters, sorters.
- createToolBar();
-
- getSite().setSelectionProvider(treeViewer);
-
- treeViewer.addCustomizeToViewToolbar(this);
- OseeUiActions.addBugToViewToolbar(this, this, Activator.getDefault(), VIEW_ID, "Message Watch");
-
- createMenuActions();
-
- setHelpContexts();
- setNoLibraryStatus();
- IOteClientService clientService = Activator.getDefault().getOteClientService();
- if (clientService == null) {
- throw new IllegalStateException("cannot acquire ote client service");
- }
- msgServiceTracker.open(true);
- clientService.addDictionaryListener(this);
- clientService.addConnectionListener(this);
- loadWatchFile();
- }
-
- @Override
- public void dispose() {
- if (detailsBox != null) {
- detailsBox.dispose();
- }
- msgServiceTracker.close();
- Activator.getDefault().getOteClientService().removeConnectionListener(WatchView.this);
- Activator.getDefault().getOteClientService().removeDictionaryListener(WatchView.this);
- super.dispose();
- }
-
- public void createToolBar() {
- Action expandAction = new Action("Expand All") {
-
- @Override
- public void run() {
- treeViewer.getTree().setRedraw(false);
- treeViewer.expandAll();
- treeViewer.getTree().setRedraw(true);
- }
- };
- expandAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.EXPAND_STATE));
- expandAction.setToolTipText("Expand All");
-
- Action showNameAction = new Action("Show Names", SWT.TOGGLE) {
-
- @Override
- public void run() {
- treeViewer.refresh();
- }
- };
- showNameAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.SHOW_NAMES));
- showNameAction.setToolTipText("Show Message Names");
-
- Action collapseAction = new Action("Collapse All") {
-
- @Override
- public void run() {
- treeViewer.getTree().setRedraw(false);
- treeViewer.collapseAll();
- treeViewer.getTree().setRedraw(true);
- }
- };
- collapseAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.COLLAPSE_STATE));
- collapseAction.setToolTipText("Collapse All");
-
- Action deleteAction = new Action("Delete") {
- @Override
- public void run() {
- final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
- watchList.deleteSelection(selection);
- }
- };
-
- deleteAction.setToolTipText("Delete");
-
- deleteAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.DELETE));
-
- Action deleteAllAction = new Action("Delete All") {
-
- @Override
- public void run() {
- if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
- "Delete All", "Delete All Watch Items?")) {
- watchList.deleteAll();
- saveWatchFile();
- }
- }
- };
- deleteAllAction.setToolTipText("Delete All");
- deleteAllAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.DELETE_ALL));
-
- Action refreshAction = new Action("Refresh") {
- @Override
- public void run() {
- treeViewer.refresh();
- }
- };
- refreshAction.setToolTipText("refresh");
- refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.REFRESH));
-
- Action saveAction = new Action("Save Items") {
- private String saveFilePath = null;
- private String lastSaveFileName = null;
-
- @Override
- public void run() {
- final FileDialog dialog = new FileDialog(treeViewer.getTree().getShell(), SWT.SAVE);
- dialog.setFilterExtensions(new String[] {"*.mwi"});
- if (saveFilePath == null) {
- saveFilePath = OseeData.getPath().toOSString();
- }
- if (lastSaveFileName == null) {
- lastSaveFileName = "msgWatchItems.mwi";
- }
- dialog.setFilterPath(saveFilePath);
- dialog.setFileName(lastSaveFileName);
-
- String selectedFile = dialog.open();
- if (selectedFile != null) {
- if (!selectedFile.endsWith(".mwi")) {
- selectedFile += ".mwi";
- }
- final File saveFile = new File(selectedFile);
- saveFilePath = saveFile.getAbsolutePath();
- lastSaveFileName = saveFile.getName();
- saveWatchFile(saveFile);
- }
- }
- };
- saveAction.setToolTipText("Save Watch Items");
- saveAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.SAVE));
-
- Action loadAction = new Action("Load Items") {
- private String loadFilePath = null;
- private String lastLoadFileName = null;
-
- @Override
- public void run() {
- final FileDialog dialog = new FileDialog(treeViewer.getTree().getShell(), SWT.OPEN);
- dialog.setFilterExtensions(new String[] {"*.mwi"});
- if (loadFilePath == null) {
- loadFilePath = OseeData.getPath().toOSString();
- }
- if (lastLoadFileName != null) {
- dialog.setFileName(lastLoadFileName);
- }
-
- dialog.setFilterPath(loadFilePath);
-
- String selectedFile = dialog.open();
- if (selectedFile != null) {
- if (!selectedFile.endsWith(".mwi")) {
- selectedFile += ".mwi";
- }
- final File loadFile = new File(selectedFile);
- loadFilePath = loadFile.getAbsolutePath();
- lastLoadFileName = loadFile.getName();
- loadWatchFile(loadFile);
- }
- }
- };
- loadAction.setToolTipText("Load Watch Items");
- loadAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.OPEN));
- IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
- toolbarManager.add(showNameAction);
- toolbarManager.add(refreshAction);
- toolbarManager.add(expandAction);
- toolbarManager.add(collapseAction);
- toolbarManager.add(deleteAction);
- toolbarManager.add(deleteAllAction);
- toolbarManager.add(saveAction);
- toolbarManager.add(loadAction);
- }
-
- private void setHelpContexts() {
- Activator.getDefault().setHelp(parentComposite, "messageWatch", "org.eclipse.osee.framework.help.ui");
- }
-
- @Override
- public void setFocus() {
- // Set focus so that context sensitive help will work as soon as this
- // view is selected.
- parentComposite.setFocus();
- }
-
- /**
- * display details about specified node
- *
- * @param node node whose details will be displayed in the detail window of the GUI
- */
- public void setDetailText(final AbstractTreeNode node) {
- detailsBox.setDetailText(node);
- }
-
- /**
- * shows a context menu depending on the point
- *
- * @param p
- */
- void showContextMenu(Point p) {
- final Tree tree = treeViewer.getTree();
- final Menu contextMenu = getPopupMenu(tree.getParent());
- if (contextMenu != null) {
- p = tree.toDisplay(p);
- contextMenu.setLocation(p);
- contextMenu.setVisible(true);
- }
- }
-
- public void addWatchMessage(final AddWatchParameter parameter) {
- for (String message : parameter.getMessages()) {
- Collection<ElementPath> elements = parameter.getMessageElements(message);
- OseeLog.log(Activator.class, Level.FINEST, String.format("Watch request for message %s", message));
- try {
- if (elements == null) {
- elements = new ArrayList<ElementPath>();
- }
- watchList.createElements(message, elements);
- } catch (ClassNotFoundException ex1) {
- if (openProceedWithProcessing("Could not find a class definition for " + message + "\n Do you wish to continue")) {
- continue;
- } else {
- return;
- }
- } catch (InstantiationException ex1) {
- if (openProceedWithProcessing("failed to instantiate " + message + "\n Do you wish to continue")) {
- continue;
- } else {
- return;
- }
- } catch (Exception ex1) {
- OseeLog.log(Activator.class, Level.SEVERE, "failed to create message node", ex1);
- if (openProceedWithProcessing("Error processing " + message + ". See Error Log for details.\n Do you wish to continue")) {
- continue;
- } else {
- return;
- }
- }
- }
- treeViewer.refresh();
- }
-
- public void refresh() {
- treeViewer.refresh();
- saveWatchFile();
- }
-
- /**
- * Convienence method. Opens an info dialog
- *
- * @param title
- * @param message
- */
- private void openInfo(final String title, final String message) {
- MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message);
- }
-
- private boolean openProceedWithProcessing(final String message) {
- MessageDialog dialog =
- new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Proceed?", null,
- message, MessageDialog.QUESTION, new String[] {"Continue processing with next message",
- "End message processing"}, 0);
- return dialog.open() == MessageDialog.OK;
- }
-
- private void onDisconnected() {
- OseeLog.log(Activator.class, Level.INFO, "Entered onDisconnected()");
- if (!recordButton.isDisposed()) {
- recordButton.setSelection(false);
- }
- try {
- if (Benchmark.isBenchmarkingEnabled()) {
- OseeLog.log(Activator.class, Level.INFO, String.format("%s: # samples=%d, max=%d, min=%d, avg=%d",
- benchMark.getName(), benchMark.getTotalSamples(), benchMark.getLongestSample(),
- benchMark.getShortestSample(), benchMark.getAverage()));
- }
- } catch (Throwable t) {
- OseeLog.log(Activator.class, Level.WARNING, "Exception during disconnect", t);
- }
-
- }
-
- private Menu getPopupMenu(final Composite composite) {
- Menu menu = treeViewer.getMenuManager().createContextMenu(composite);
- return menu;
- }
-
- public void loadWatchFile() {
- loadWatchFile(watchFile);
- }
-
- public void loadWatchFile(final File watchFile) {
- if (watchFile != null && watchFile.exists()) {
- final Job job = new Job("Loading watch file") {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- String text = AFile.readFile(watchFile);
- final String[] msgs = text.split("\n");
- monitor.beginTask("loading watch elements", msgs.length + 10);
- try {
- if (msgs.length > 0) {
- if (msgs[0].equals("version=2.0")) {
- final Map<String, ArrayList<ElementPath>> pathsToAdd =
- new HashMap<String, ArrayList<ElementPath>>();
- final List<ElementPath> recBodyElementsToAdd = new ArrayList<ElementPath>();
- final List<ElementPath> recHeaderElementsToAdd = new ArrayList<ElementPath>();
- final Set<String> recHeaderHex = new HashSet<String>();
- final Set<String> recBodyHex = new HashSet<String>();
- for (int i = 1; i < msgs.length; i++) {
- if (msgs[i].startsWith("#rec#")) {
- // #rec#,message,[body|header|bodyHex|
- // headerHex],[boolean|path]
- String[] els = msgs[i].split(",");
- if (els.length == 4) {
- String message = els[1];
- String type = els[2];
- String value = els[3];
- if (type.equals("body")) {
- recBodyElementsToAdd.add(new ElementPath(value));
- } else if (type.equals("header")) {
- recHeaderElementsToAdd.add(new ElementPath(value));
- } else if (type.equals("headerHex")) {
- if (Boolean.parseBoolean(value)) {
- recHeaderHex.add(message);
- }
- } else if (type.equals("bodyHex")) {
- if (Boolean.parseBoolean(value)) {
- recBodyHex.add(message);
- }
- }
- }
- monitor.worked(1);
- } else {
- ElementPath path = new ElementPath(msgs[i]);
- ArrayList<ElementPath> collection = pathsToAdd.get(path.getMessageName());
- if (collection == null) {
- collection = new ArrayList<ElementPath>();
- pathsToAdd.put(path.getMessageName(), collection);
- }
- collection.add(path);
- monitor.worked(1);
- }
- }
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- try {
- treeViewer.getTree().setRedraw(false);
- addWatchMessage(new AddWatchParameter(pathsToAdd));
- for (ElementPath path : recBodyElementsToAdd) {
- WatchedMessageNode msgNode = watchList.getMessageNode(path.getMessageName());
- if (msgNode != null) {
- msgNode.getRecordingState().addBody(path);
- }
- }
- for (ElementPath path : recHeaderElementsToAdd) {
- WatchedMessageNode msgNode = watchList.getMessageNode(path.getMessageName());
- if (msgNode != null) {
- msgNode.getRecordingState().addHeader(path);
- }
- }
- for (String msg : recBodyHex) {
- WatchedMessageNode msgNode = watchList.getMessageNode(msg);
- if (msgNode != null) {
- msgNode.getRecordingState().setBodyDump(true);
- }
- }
- for (String msg : recHeaderHex) {
- WatchedMessageNode msgNode = watchList.getMessageNode(msg);
- if (msgNode != null) {
- msgNode.getRecordingState().setHeaderDump(true);
- }
- }
- } finally {
- treeViewer.getTree().setRedraw(true);
- treeViewer.refresh();
- }
- }
- });
-
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- saveWatchFile();
- treeViewer.refresh();
- }
- });
- monitor.worked(10);
- } else {
-
- for (String msg : msgs) {
- // final Matcher jarMatch =
- // jarPattern.matcher(msg);
- final Matcher elmMatch = elmPattern.matcher(msg);
- final Matcher msgMatch = msgPattern.matcher(msg);
-
- if (elmMatch.find()) {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- String msg = elmMatch.group(1);
- String elm = elmMatch.group(2);
- ElementPath element = new ElementPath(msg, elm);
- AddWatchParameter parameter = new AddWatchParameter(elmMatch.group(1), element);
- addWatchMessage(parameter);
- }
- });
- } else if (msgMatch.find()) {
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- addWatchMessage(new AddWatchParameter(msgMatch.group(1)));
- }
- });
- }
- monitor.worked(1);
- }
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- saveWatchFile();
- treeViewer.refresh();
- }
- });
- monitor.worked(10);
-
- }
- }
- } catch (Throwable t) {
- OseeLog.log(Activator.class, Level.SEVERE, "error loading watch file", t);
- return org.eclipse.core.runtime.Status.CANCEL_STATUS;
- } finally {
- monitor.done();
- }
- return org.eclipse.core.runtime.Status.OK_STATUS;
- }
- };
- Jobs.startJob(job);
- }
- }
-
- public void saveWatchFile() {
- saveWatchFile(watchFile);
- }
-
- public void saveWatchFile(File watchFile) {
- if (watchFile == null) {
- return;
- }
- try {
- final FileWriter fw = new FileWriter(watchFile);
- fw.write("version=2.0\n");
- for (MessageNode treeItem : watchList.getMessages()) {
- WatchedMessageNode msg = (WatchedMessageNode) treeItem;
- msg.getRecordingState().write(fw);
- LinkedList<ElementNode> descendants = new LinkedList<ElementNode>();
- msg.collectDescendants(descendants);
- if (descendants.isEmpty()) {
- fw.write(msg.getMessageClassName());
- fw.write('\n');
- } else {
- for (ElementNode el : descendants) {
- fw.write(el.getElementPath().asString());
- fw.write('\n');
- }
- }
- }
- fw.close();
- } catch (Exception e) {
- OseeLog.log(Activator.class, Level.SEVERE, "failed to write watch file at " + watchFile.getAbsolutePath(), e);
- }
- }
-
- public TreeViewer getTreeViewer() {
- return treeViewer;
- }
-
- public String getActionDescription() {
- return "";
- }
-
- public void updateMenuActions(final IMenuManager mm) {
-
- final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
- if (selection.size() > 0) {
- final AbstractTreeNode node = (AbstractTreeNode) selection.getFirstElement();
- node.visit(new INodeVisitor<Object>() {
-
- public Object elementNode(ElementNode node) {
- if (selection.size() == 1) {
- mm.insertBefore(XViewer.MENU_GROUP_PRE, new SetValueAction(node));
- mm.insertBefore(XViewer.MENU_GROUP_PRE, new ZeroizeElementAction(node));
- }
- return null;
- }
-
- public Object messageNode(MessageNode node) {
- if (selection.size() == 1) {
- WatchedMessageNode msgNode = (WatchedMessageNode) node;
- mm.insertBefore(XViewer.MENU_GROUP_PRE, new WatchElementAction(WatchView.this,
- (WatchedMessageNode) node));
- mm.insertBefore(XViewer.MENU_GROUP_PRE, new Separator());
- mm.insertBefore(XViewer.MENU_GROUP_PRE, SetDataSourceMenu.createMenu(msgNode));
- mm.insertBefore(XViewer.MENU_GROUP_PRE, SetMessageModeMenu.createMenu(msgNode));
- mm.insertBefore(XViewer.MENU_GROUP_PRE, new SendMessageAction(msgNode));
- mm.insertBefore(XViewer.MENU_GROUP_PRE, new ZeroizeMessageAction(msgNode));
- }
- return null;
- }
-
- public Object rootNode(RootNode node) {
- return null;
- }
-
- });
- mm.insertBefore(XViewer.MENU_GROUP_PRE, new ClearUpdatesAction(watchList, selection));
- mm.insertBefore(XViewer.MENU_GROUP_PRE, new DeleteSelectionAction(watchList, selection));
- }
- mm.insertBefore(XViewer.MENU_GROUP_PRE, new Separator());
- }
-
- public void createMenuActions() {
- MenuManager mm = treeViewer.getMenuManager();
- mm.createContextMenu(treeViewer.getControl());
- mm.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- updateMenuActions(manager);
- }
- });
-
- }
-
- @Override
- public void onPostConnect(final ConnectionEvent event) {
- OseeLog.log(Activator.class, Level.INFO, "Entered onConnectionEstablished()");
-
- if (event.getEnvironment() instanceof ITestEnvironmentMessageSystem) {
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- recordButton.setEnabled(true);
- watchList.clearAllUpdateCounters();
- }
- });
- }
- }
-
- @Override
- public void onPreDisconnect(ConnectionEvent event) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- recordButton.setEnabled(false);
- onDisconnected();
- }
- });
- }
-
- @Override
- public void onDictionaryLoaded(final IMessageDictionary dictionary) {
-
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- statusTxt.setText("loaded with " + dictionary.getMessageLibraryVersion());
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, "exception while processing library", ex);
- }
- }
- });
- }
-
- @Override
- public void onDictionaryUnloaded(IMessageDictionary dictionary) {
- // our node factory's dictionary is being unloaded
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- setNoLibraryStatus();
- }
- });
- }
-
- private void setNoLibraryStatus() {
- statusTxt.setText("no library detected");
- }
-
- @Override
- public void onConnectionLost(IServiceConnector connector) {
- }
-
- @Override
- public void oteMessageServiceAcquired(final IOteMessageService service) {
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
-
- @Override
- public void run() {
- messageService = service;
- recordButton.setEnabled(true);
- treeViewer.setInput(service);
- }
- });
- }
-
- @Override
- public void oteMessageServiceReleased() {
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
-
- @Override
- public void run() {
- if (!recordButton.isDisposed()) {
- recordButton.setEnabled(false);
- }
- if (!treeViewer.getControl().isDisposed()) {
- treeViewer.setInput(null);
- }
- messageService = null;
- }
- });
- }
+ protected static final OseeUiActivator plugin = Activator.getDefault();
+
+ private MessageXViewer treeViewer;
+
+ private final ClientMessageServiceTracker msgServiceTracker;
+ private Label statusTxt;
+
+ private final File watchFile;
+ private Button recordButton;
+ private final Benchmark benchMark = new Benchmark("Message Watch Update Time");
+
+ private static final Pattern elmPattern = Pattern.compile("^(osee\\.test\\.core\\.message\\.[^.]+\\..+)\\.(.+)$");
+ private static final Pattern msgPattern = Pattern.compile("^(osee\\.test\\.core\\.message\\.[^.]+\\..+)$");
+
+ public static final String VIEW_ID = "org.eclipse.osee.ote.ui.message.watch.WatchView";
+
+ private DetailsBox detailsBox;
+ final IUdpTransferListener recBtnListener = new IUdpTransferListener() {
+
+ @Override
+ public void onTransferComplete(final TransferConfig config) {
+ OseeLog.log(Activator.class, Level.INFO, "file transfer complete");
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ openInfo("Message Recorder",
+ "Message recording file " + config.getFileName() + " is now ready for opening");
+ }
+ });
+ }
+
+ @Override
+ public void onTransferException(final TransferConfig config, final Throwable t) {
+ OseeLog.log(Activator.class, Level.SEVERE, "problems writing to recorder output file " + config.getFileName(),
+ t);
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ recordButton.setSelection(false);
+ openInfo("Message Recorder",
+ "An exception occurred while writing to recorder output file " + config.getFileName());
+ }
+ });
+ }
+ };
+
+ private IOteMessageService messageService = null;
+
+ private final SelectionListener recBtnHandler = new SelectionListener() {
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (recordButton.getSelection()) {
+
+ RecordingWizard recordingWizard = new RecordingWizard(watchList);
+ final WizardDialog recdialog = new WizardDialog(Displays.getActiveShell(), recordingWizard);
+ int recResult = recdialog.open();
+ if (Window.OK == recResult) {
+ try {
+ saveWatchFile();
+ messageService.startRecording(recordingWizard.getFileName(),
+ recordingWizard.getFilteredMessageRecordDetails()).addListener(recBtnListener);
+ } catch (FileNotFoundException ex) {
+ MessageDialog.openError(Displays.getActiveShell(), "Recording Error",
+ "Failed to open file for writing. " + "Make sure its not being used by another application");
+ recordButton.setSelection(false);
+ } catch (Throwable ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "Failed to start message recording", ex);
+ MessageDialog.openError(Displays.getActiveShell(), "Recording Error",
+ "Exception ocurred while recording. see error log");
+ recordButton.setSelection(false);
+ }
+ } else {
+ recordButton.setSelection(false);
+ }
+ } else {
+ try {
+ messageService.stopRecording();
+ } catch (IOException ioe) {
+ OseeLog.log(Activator.class, Level.WARNING, "problem when attempting to stop recording", ioe);
+ } catch (Throwable t) {
+ OseeLog.log(Activator.class, Level.SEVERE, "problem when attempting to stop recording", t);
+ }
+ }
+ }
+ };
+
+ private static enum Status {
+ /**
+ * no active test manager
+ */
+ NO_TEST_MANAGER("No test manager running"),
+ /**
+ * active test manager but not connected to a host
+ */
+ NOT_CONNECTED("%s: Not connected to a host"),
+ /**
+ * active test manager and connected to a host
+ */
+ CONNECTED("Connected to %s (%s)");
+
+ private final String txt;
+
+ Status(final String txt) {
+ this.txt = txt;
+ }
+
+ public String asString(Object... args) {
+ return String.format(txt, args);
+ }
+
+ }
+
+ private Composite parentComposite;
+ private WatchList watchList;
+
+ public WatchView() {
+ watchFile = OseeData.getFile("msgWatch.txt");
+ msgServiceTracker = new ClientMessageServiceTracker(Activator.getDefault().getBundle().getBundleContext(), this);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ /**
+ *
+ */
+ public void createPartControl(Composite parent) {
+ final int numColumns = 4;
+
+ parentComposite = parent;
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = numColumns;
+ layout.verticalSpacing = 0;
+ layout.marginWidth = 5;
+ layout.marginHeight = 5;
+ parent.setLayout(layout);
+
+ Label label = new Label(parent, SWT.RIGHT);
+ label.setText("Status:");
+ Widgets.positionGridItem(label, false, false, SWT.END, SWT.CENTER, 1);
+
+ statusTxt = new Label(parent, SWT.READ_ONLY);
+ statusTxt.setText(Status.NO_TEST_MANAGER.asString());
+ Widgets.positionGridItem(statusTxt, false, false, SWT.FILL, SWT.BEGINNING, 3);
+
+ Composite buttons = new Composite(parent, SWT.NONE);
+ buttons.setLayout(new RowLayout(SWT.HORIZONTAL));
+
+ recordButton = new Button(buttons, SWT.TOGGLE);
+ recordButton.setText("REC");
+ recordButton.setToolTipText("Record the messages and elements currently shown in Message Watch.");
+ recordButton.addSelectionListener(recBtnHandler);
+ recordButton.setEnabled(false);
+
+ IExtension[] extensions =
+ Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.osee.ote.ui.message.ToolbarItem").getExtensions();
+ for (IExtension ext : extensions) {
+ for (IConfigurationElement el : ext.getConfigurationElements()) {
+ if (el.getName().equals("ToolbarItem")) {
+ String actionClass = el.getAttribute("Action");
+ String icon = el.getAttribute("Icon");
+ String btnLabel = el.getAttribute("Label");
+ String tooltip = el.getAttribute("Tooltip");
+
+ Class<? extends Action> clazz;
+ try {
+ Bundle bundle = Platform.getBundle(el.getContributor().getName());
+ clazz = bundle.loadClass(actionClass).asSubclass(Action.class);
+
+ Action action = clazz.newInstance();
+ ActionButton btn =
+ new ActionButton(buttons, SWT.PUSH, action, btnLabel, el.getContributor().getName());
+ btn.setToolTipText(tooltip);
+
+ if (icon != null) {
+ URL url = bundle.getEntry(icon);
+ if (url == null) {
+ throw new IllegalArgumentException(String.format("Invalid icon path [{%s}/%s]",
+ el.getContributor().getName(), icon));
+ } else {
+ ImageDescriptor desc = ImageDescriptor.createFromURL(url);
+ Image img = desc.createImage();
+ if (img == null) {
+ throw new IllegalArgumentException(String.format("Unable to create Image from [{%s}/%s]",
+ el.getContributor().getName(), icon));
+ } else {
+ btn.setImage(img);
+ }
+ }
+ }
+ } catch (InvalidRegistryObjectException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ } catch (ClassNotFoundException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ } catch (InstantiationException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ } catch (IllegalAccessException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ } catch (IllegalArgumentException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+ }
+ }
+
+ final SashForm sashForm = new SashForm(parent, SWT.VERTICAL);
+ // sashForm.SASH_WIDTH = 1;
+ Widgets.positionGridItem(sashForm, true, true, SWT.FILL, SWT.FILL, numColumns);
+
+ Composite comp = new Composite(sashForm, SWT.NONE);
+ comp.setLayout(new GridLayout(1, false));
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ comp.setLayoutData(gd);
+
+ // Create the tree treeViewer as a child of the composite parent
+ treeViewer =
+ new MessageXViewer(comp,
+ SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.DOUBLE_BUFFERED);
+ GridData layoutData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
+ layoutData.horizontalSpan = numColumns;
+ treeViewer.getControl().setLayoutData(layoutData);
+ watchList = new WatchList(this);
+ treeViewer.setContentProvider(watchList);
+ treeViewer.setLabelProvider(new MessageWatchLabelProvider(treeViewer));
+ treeViewer.setUseHashlookup(true);
+
+ treeViewer.getTree().setHeaderVisible(true);
+ treeViewer.getTree().setLinesVisible(true);
+
+ detailsBox = new DetailsBox(sashForm);
+
+ sashForm.setWeights(new int[] {75, 25});
+ // Add Listeners to the Tree
+ treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ private AbstractTreeNode lastNodeSelected = null;
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
+
+ final AbstractTreeNode node = (AbstractTreeNode) selection.getFirstElement();
+ if (node != null && node != lastNodeSelected) {
+ if (lastNodeSelected != null) {
+ lastNodeSelected.setSelected(false);
+ }
+ node.setSelected(true);
+ try {
+ setDetailText(node);
+ } catch (ArrayIndexOutOfBoundsException t) {
+ // throw if there is an error in the message jar
+ // (usually... )
+ final String msg =
+ String.format("Problems occurred when trying to display details for %s: (See Error Log)",
+ node.getName());
+ OseeLog.log(Activator.class, Level.SEVERE, "Error while displaying details for " + node.getName(), t);
+ openInfo("Possible Message JAR Error", msg);
+ }
+ lastNodeSelected = node;
+ }
+ }
+ });
+ treeViewer.getTree().addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (e.button == 3) {
+ showContextMenu(new Point(e.x, e.y));
+ }
+ }
+ });
+
+ // Create menu, toolbars, filters, sorters.
+ createToolBar();
+
+ getSite().setSelectionProvider(treeViewer);
+
+ treeViewer.addCustomizeToViewToolbar(this);
+ OseeUiActions.addBugToViewToolbar(this, this, Activator.getDefault(), VIEW_ID, "Message Watch");
+
+ createMenuActions();
+
+ setHelpContexts();
+ setNoLibraryStatus();
+ IOteClientService clientService = Activator.getDefault().getOteClientService();
+ if (clientService == null) {
+ throw new IllegalStateException("cannot acquire ote client service");
+ }
+ msgServiceTracker.open(true);
+ clientService.addDictionaryListener(this);
+ clientService.addConnectionListener(this);
+ loadWatchFile();
+ }
+
+ @Override
+ public void dispose() {
+ if (detailsBox != null) {
+ detailsBox.dispose();
+ }
+ msgServiceTracker.close();
+ Activator.getDefault().getOteClientService().removeConnectionListener(WatchView.this);
+ Activator.getDefault().getOteClientService().removeDictionaryListener(WatchView.this);
+ super.dispose();
+ }
+
+ public void createToolBar() {
+ Action expandAction = new Action("Expand All") {
+
+ @Override
+ public void run() {
+ treeViewer.getTree().setRedraw(false);
+ treeViewer.expandAll();
+ treeViewer.getTree().setRedraw(true);
+ }
+ };
+ expandAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.EXPAND_STATE));
+ expandAction.setToolTipText("Expand All");
+
+ Action showNameAction = new Action("Show Names", SWT.TOGGLE) {
+
+ @Override
+ public void run() {
+ treeViewer.refresh();
+ }
+ };
+ showNameAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.SHOW_NAMES));
+ showNameAction.setToolTipText("Show Message Names");
+
+ Action collapseAction = new Action("Collapse All") {
+
+ @Override
+ public void run() {
+ treeViewer.getTree().setRedraw(false);
+ treeViewer.collapseAll();
+ treeViewer.getTree().setRedraw(true);
+ }
+ };
+ collapseAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.COLLAPSE_STATE));
+ collapseAction.setToolTipText("Collapse All");
+
+ Action deleteAction = new Action("Delete") {
+ @Override
+ public void run() {
+ final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
+ watchList.deleteSelection(selection);
+ }
+ };
+
+ deleteAction.setToolTipText("Delete");
+
+ deleteAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.DELETE));
+
+ Action deleteAllAction = new Action("Delete All") {
+
+ @Override
+ public void run() {
+ if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "Delete All", "Delete All Watch Items?")) {
+ watchList.deleteAll();
+ saveWatchFile();
+ }
+ }
+ };
+ deleteAllAction.setToolTipText("Delete All");
+ deleteAllAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.DELETE_ALL));
+
+ Action refreshAction = new Action("Refresh") {
+ @Override
+ public void run() {
+ treeViewer.refresh();
+ }
+ };
+ refreshAction.setToolTipText("refresh");
+ refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.REFRESH));
+
+ Action saveAction = new Action("Save Items") {
+ private String saveFilePath = null;
+ private String lastSaveFileName = null;
+
+ @Override
+ public void run() {
+ final FileDialog dialog = new FileDialog(treeViewer.getTree().getShell(), SWT.SAVE);
+ dialog.setFilterExtensions(new String[] {"*.mwi"});
+ if (saveFilePath == null) {
+ saveFilePath = OseeData.getPath().toOSString();
+ }
+ if (lastSaveFileName == null) {
+ lastSaveFileName = "msgWatchItems.mwi";
+ }
+ dialog.setFilterPath(saveFilePath);
+ dialog.setFileName(lastSaveFileName);
+
+ String selectedFile = dialog.open();
+ if (selectedFile != null) {
+ if (!selectedFile.endsWith(".mwi")) {
+ selectedFile += ".mwi";
+ }
+ final File saveFile = new File(selectedFile);
+ saveFilePath = saveFile.getAbsolutePath();
+ lastSaveFileName = saveFile.getName();
+ saveWatchFile(saveFile);
+ }
+ }
+ };
+ saveAction.setToolTipText("Save Watch Items");
+ saveAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.SAVE));
+
+ Action loadAction = new Action("Load Items") {
+ private String loadFilePath = null;
+ private String lastLoadFileName = null;
+
+ @Override
+ public void run() {
+ final FileDialog dialog = new FileDialog(treeViewer.getTree().getShell(), SWT.OPEN);
+ dialog.setFilterExtensions(new String[] {"*.mwi"});
+ if (loadFilePath == null) {
+ loadFilePath = OseeData.getPath().toOSString();
+ }
+ if (lastLoadFileName != null) {
+ dialog.setFileName(lastLoadFileName);
+ }
+
+ dialog.setFilterPath(loadFilePath);
+
+ String selectedFile = dialog.open();
+ if (selectedFile != null) {
+ if (!selectedFile.endsWith(".mwi")) {
+ selectedFile += ".mwi";
+ }
+ final File loadFile = new File(selectedFile);
+ loadFilePath = loadFile.getAbsolutePath();
+ lastLoadFileName = loadFile.getName();
+ loadWatchFile(loadFile);
+ }
+ }
+ };
+ loadAction.setToolTipText("Load Watch Items");
+ loadAction.setImageDescriptor(ImageManager.getImageDescriptor(OteMessageImage.OPEN));
+ IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager();
+ toolbarManager.add(showNameAction);
+ toolbarManager.add(refreshAction);
+ toolbarManager.add(expandAction);
+ toolbarManager.add(collapseAction);
+ toolbarManager.add(deleteAction);
+ toolbarManager.add(deleteAllAction);
+ toolbarManager.add(saveAction);
+ toolbarManager.add(loadAction);
+ }
+
+ private void setHelpContexts() {
+ Activator.getDefault().setHelp(parentComposite, "messageWatch", "org.eclipse.osee.framework.help.ui");
+ }
+
+ @Override
+ public void setFocus() {
+ // Set focus so that context sensitive help will work as soon as this
+ // view is selected.
+ parentComposite.setFocus();
+ }
+
+ /**
+ * display details about specified node
+ *
+ * @param node node whose details will be displayed in the detail window of the GUI
+ */
+ public void setDetailText(final AbstractTreeNode node) {
+ detailsBox.setDetailText(node);
+ }
+
+ /**
+ * shows a context menu depending on the point
+ *
+ * @param p
+ */
+ void showContextMenu(Point p) {
+ final Tree tree = treeViewer.getTree();
+ final Menu contextMenu = getPopupMenu(tree.getParent());
+ if (contextMenu != null) {
+ p = tree.toDisplay(p);
+ contextMenu.setLocation(p);
+ contextMenu.setVisible(true);
+ }
+ }
+
+ public void addWatchMessage(final AddWatchParameter parameter) {
+ for (String message : parameter.getMessages()) {
+ Collection<ElementPath> elements = parameter.getMessageElements(message);
+ OseeLog.log(Activator.class, Level.FINEST, String.format("Watch request for message %s", message));
+ try {
+ if (elements == null) {
+ elements = new ArrayList<ElementPath>();
+ }
+ watchList.createElements(message, elements);
+ } catch (ClassNotFoundException ex1) {
+ if (openProceedWithProcessing("Could not find a class definition for " + message + "\n Do you wish to continue")) {
+ continue;
+ } else {
+ return;
+ }
+ } catch (InstantiationException ex1) {
+ if (openProceedWithProcessing("failed to instantiate " + message + "\n Do you wish to continue")) {
+ continue;
+ } else {
+ return;
+ }
+ } catch (Exception ex1) {
+ OseeLog.log(Activator.class, Level.SEVERE, "failed to create message node", ex1);
+ if (openProceedWithProcessing("Error processing " + message + ". See Error Log for details.\n Do you wish to continue")) {
+ continue;
+ } else {
+ return;
+ }
+ }
+ }
+ treeViewer.refresh();
+ }
+
+ public void refresh() {
+ treeViewer.refresh();
+ saveWatchFile();
+ }
+
+ /**
+ * Convienence method. Opens an info dialog
+ *
+ * @param title
+ * @param message
+ */
+ private void openInfo(final String title, final String message) {
+ MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, message);
+ }
+
+ private boolean openProceedWithProcessing(final String message) {
+ MessageDialog dialog =
+ new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Proceed?", null,
+ message, MessageDialog.QUESTION, new String[] {"Continue processing with next message",
+ "End message processing"}, 0);
+ return dialog.open() == MessageDialog.OK;
+ }
+
+ private void onDisconnected() {
+ OseeLog.log(Activator.class, Level.INFO, "Entered onDisconnected()");
+ if (!recordButton.isDisposed()) {
+ recordButton.setSelection(false);
+ }
+ try {
+ if (Benchmark.isBenchmarkingEnabled()) {
+ OseeLog.log(Activator.class, Level.INFO, String.format("%s: # samples=%d, max=%d, min=%d, avg=%d",
+ benchMark.getName(), benchMark.getTotalSamples(), benchMark.getLongestSample(),
+ benchMark.getShortestSample(), benchMark.getAverage()));
+ }
+ } catch (Throwable t) {
+ OseeLog.log(Activator.class, Level.WARNING, "Exception during disconnect", t);
+ }
+
+ }
+
+ private Menu getPopupMenu(final Composite composite) {
+ Menu menu = treeViewer.getMenuManager().createContextMenu(composite);
+ return menu;
+ }
+
+ public void loadWatchFile() {
+ loadWatchFile(watchFile);
+ }
+
+ public void loadWatchFile(final File watchFile) {
+ if (watchFile != null && watchFile.exists()) {
+ final Job job = new Job("Loading watch file") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ String text = AFile.readFile(watchFile);
+ final String[] msgs = text.split("\n");
+ monitor.beginTask("loading watch elements", msgs.length + 10);
+ try {
+ if (msgs.length > 0) {
+ if (msgs[0].equals("version=2.0")) {
+ final Map<String, ArrayList<ElementPath>> pathsToAdd =
+ new HashMap<String, ArrayList<ElementPath>>();
+ final List<ElementPath> recBodyElementsToAdd = new ArrayList<ElementPath>();
+ final List<ElementPath> recHeaderElementsToAdd = new ArrayList<ElementPath>();
+ final Set<String> recHeaderHex = new HashSet<String>();
+ final Set<String> recBodyHex = new HashSet<String>();
+ for (int i = 1; i < msgs.length; i++) {
+ if (msgs[i].startsWith("#rec#")) {
+ // #rec#,message,[body|header|bodyHex|
+ // headerHex],[boolean|path]
+ String[] els = msgs[i].split(",");
+ if (els.length == 4) {
+ String message = els[1];
+ String type = els[2];
+ String value = els[3];
+ if (type.equals("body")) {
+ recBodyElementsToAdd.add(new ElementPath(value));
+ } else if (type.equals("header")) {
+ recHeaderElementsToAdd.add(new ElementPath(value));
+ } else if (type.equals("headerHex")) {
+ if (Boolean.parseBoolean(value)) {
+ recHeaderHex.add(message);
+ }
+ } else if (type.equals("bodyHex")) {
+ if (Boolean.parseBoolean(value)) {
+ recBodyHex.add(message);
+ }
+ }
+ }
+ monitor.worked(1);
+ } else {
+ ElementPath path = new ElementPath(msgs[i]);
+ ArrayList<ElementPath> collection = pathsToAdd.get(path.getMessageName());
+ if (collection == null) {
+ collection = new ArrayList<ElementPath>();
+ pathsToAdd.put(path.getMessageName(), collection);
+ }
+ collection.add(path);
+ monitor.worked(1);
+ }
+ }
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ treeViewer.getTree().setRedraw(false);
+ addWatchMessage(new AddWatchParameter(pathsToAdd));
+ for (ElementPath path : recBodyElementsToAdd) {
+ WatchedMessageNode msgNode = watchList.getMessageNode(path.getMessageName());
+ if (msgNode != null) {
+ msgNode.getRecordingState().addBody(path);
+ }
+ }
+ for (ElementPath path : recHeaderElementsToAdd) {
+ WatchedMessageNode msgNode = watchList.getMessageNode(path.getMessageName());
+ if (msgNode != null) {
+ msgNode.getRecordingState().addHeader(path);
+ }
+ }
+ for (String msg : recBodyHex) {
+ WatchedMessageNode msgNode = watchList.getMessageNode(msg);
+ if (msgNode != null) {
+ msgNode.getRecordingState().setBodyDump(true);
+ }
+ }
+ for (String msg : recHeaderHex) {
+ WatchedMessageNode msgNode = watchList.getMessageNode(msg);
+ if (msgNode != null) {
+ msgNode.getRecordingState().setHeaderDump(true);
+ }
+ }
+ } finally {
+ treeViewer.getTree().setRedraw(true);
+ treeViewer.refresh();
+ }
+ }
+ });
+
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ saveWatchFile();
+ treeViewer.refresh();
+ }
+ });
+ monitor.worked(10);
+ } else {
+
+ for (String msg : msgs) {
+ // final Matcher jarMatch =
+ // jarPattern.matcher(msg);
+ final Matcher elmMatch = elmPattern.matcher(msg);
+ final Matcher msgMatch = msgPattern.matcher(msg);
+
+ if (elmMatch.find()) {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ String msg = elmMatch.group(1);
+ String elm = elmMatch.group(2);
+ ElementPath element = new ElementPath(msg, elm);
+ AddWatchParameter parameter = new AddWatchParameter(elmMatch.group(1), element);
+ addWatchMessage(parameter);
+ }
+ });
+ } else if (msgMatch.find()) {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ addWatchMessage(new AddWatchParameter(msgMatch.group(1)));
+ }
+ });
+ }
+ monitor.worked(1);
+ }
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ saveWatchFile();
+ treeViewer.refresh();
+ }
+ });
+ monitor.worked(10);
+
+ }
+ }
+ } catch (Throwable t) {
+ OseeLog.log(Activator.class, Level.SEVERE, "error loading watch file", t);
+ return org.eclipse.core.runtime.Status.CANCEL_STATUS;
+ } finally {
+ monitor.done();
+ }
+ return org.eclipse.core.runtime.Status.OK_STATUS;
+ }
+ };
+ Jobs.startJob(job);
+ }
+ }
+
+ public void saveWatchFile() {
+ saveWatchFile(watchFile);
+ }
+
+ public void saveWatchFile(File watchFile) {
+ if (watchFile == null) {
+ return;
+ }
+ try {
+ final FileWriter fw = new FileWriter(watchFile);
+ fw.write("version=2.0\n");
+ for (MessageNode treeItem : watchList.getMessages()) {
+ WatchedMessageNode msg = (WatchedMessageNode) treeItem;
+ msg.getRecordingState().write(fw);
+ LinkedList<ElementNode> descendants = new LinkedList<ElementNode>();
+ msg.collectDescendants(descendants);
+ if (descendants.isEmpty()) {
+ fw.write(msg.getMessageClassName());
+ fw.write('\n');
+ } else {
+ for (ElementNode el : descendants) {
+ fw.write(el.getElementPath().asString());
+ fw.write('\n');
+ }
+ }
+ }
+ fw.close();
+ } catch (Exception e) {
+ OseeLog.log(Activator.class, Level.SEVERE, "failed to write watch file at " + watchFile.getAbsolutePath(), e);
+ }
+ }
+
+ public TreeViewer getTreeViewer() {
+ return treeViewer;
+ }
+
+ @Override
+ public String getActionDescription() {
+ return "";
+ }
+
+ public void updateMenuActions(final IMenuManager mm) {
+
+ final IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
+ if (selection.size() > 0) {
+ final AbstractTreeNode node = (AbstractTreeNode) selection.getFirstElement();
+ node.visit(new INodeVisitor<Object>() {
+
+ @Override
+ public Object elementNode(ElementNode node) {
+ if (selection.size() == 1) {
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, new SetValueAction(node));
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, new ZeroizeElementAction(node));
+ }
+ return null;
+ }
+
+ @Override
+ public Object messageNode(MessageNode node) {
+ if (selection.size() == 1) {
+ WatchedMessageNode msgNode = (WatchedMessageNode) node;
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, new WatchElementAction(WatchView.this,
+ (WatchedMessageNode) node));
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, new Separator());
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, SetDataSourceMenu.createMenu(msgNode));
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, SetMessageModeMenu.createMenu(msgNode));
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, new SendMessageAction(msgNode));
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, new ZeroizeMessageAction(msgNode));
+ }
+ return null;
+ }
+
+ @Override
+ public Object rootNode(RootNode node) {
+ return null;
+ }
+
+ });
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, new ClearUpdatesAction(watchList, selection));
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, new DeleteSelectionAction(watchList, selection));
+ }
+ mm.insertBefore(XViewer.MENU_GROUP_PRE, new Separator());
+ }
+
+ public void createMenuActions() {
+ MenuManager mm = treeViewer.getMenuManager();
+ mm.createContextMenu(treeViewer.getControl());
+ mm.addMenuListener(new IMenuListener() {
+ @Override
+ public void menuAboutToShow(IMenuManager manager) {
+ updateMenuActions(manager);
+ }
+ });
+
+ }
+
+ @Override
+ public void onPostConnect(final ConnectionEvent event) {
+ OseeLog.log(Activator.class, Level.INFO, "Entered onConnectionEstablished()");
+
+ if (event.getEnvironment() instanceof ITestEnvironmentMessageSystem) {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ recordButton.setEnabled(true);
+ watchList.clearAllUpdateCounters();
+ }
+ });
+ }
+ }
+
+ @Override
+ public void onPreDisconnect(ConnectionEvent event) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ recordButton.setEnabled(false);
+ onDisconnected();
+ }
+ });
+ }
+
+ @Override
+ public void onDictionaryLoaded(final IMessageDictionary dictionary) {
+
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ statusTxt.setText("loaded with " + dictionary.getMessageLibraryVersion());
+ } catch (Exception ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, "exception while processing library", ex);
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onDictionaryUnloaded(IMessageDictionary dictionary) {
+ // our node factory's dictionary is being unloaded
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ setNoLibraryStatus();
+ }
+ });
+ }
+
+ private void setNoLibraryStatus() {
+ statusTxt.setText("no library detected");
+ }
+
+ @Override
+ public void onConnectionLost(IServiceConnector connector) {
+ }
+
+ @Override
+ public void oteMessageServiceAcquired(final IOteMessageService service) {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ messageService = service;
+ recordButton.setEnabled(true);
+ treeViewer.setInput(service);
+ }
+ });
+ }
+
+ @Override
+ public void oteMessageServiceReleased() {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (!recordButton.isDisposed()) {
+ recordButton.setEnabled(false);
+ }
+ if (!treeViewer.getControl().isDisposed()) {
+ treeViewer.setInput(null);
+ }
+ messageService = null;
+ }
+ });
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SendMessageAction.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SendMessageAction.java
index 5d680dd4244..95a77507e9c 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SendMessageAction.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SendMessageAction.java
@@ -8,40 +8,38 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.message.watch.action;
-
+package org.eclipse.osee.ote.ui.message.watch.action;
+
import java.util.logging.Level;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.message.tool.MessageMode;
import org.eclipse.osee.ote.ui.message.tree.WatchedMessageNode;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @author Ken J. Aguilar
- *
- */
-public class SendMessageAction extends Action {
- private final WatchedMessageNode msgNode;
-
- public SendMessageAction(WatchedMessageNode msgNode) {
- super("Send");
- this.msgNode = msgNode;
- setEnabled(msgNode.isEnabled() && msgNode.getSubscription().getMessageMode() == MessageMode.WRITER && msgNode.getSubscription().isActive());
-
- }
-
- @Override
- public void run() {
- try {
- msgNode.getSubscription().send();
- } catch (Exception e) {
- String message = "could not send the message " + msgNode.getMessageClassName();
- OseeLog.log(SendMessageAction.class, Level.SEVERE, message, e);
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Send Message", message + ". Check error log for trace");
- }
- }
-
-
-}
+
+/**
+ * @author Ken J. Aguilar
+ */
+public class SendMessageAction extends Action {
+ private final WatchedMessageNode msgNode;
+
+ public SendMessageAction(WatchedMessageNode msgNode) {
+ super("Send");
+ this.msgNode = msgNode;
+ setEnabled(msgNode.isEnabled() && msgNode.getSubscription().getMessageMode() == MessageMode.WRITER && msgNode.getSubscription().isActive());
+
+ }
+
+ @Override
+ public void run() {
+ try {
+ msgNode.getSubscription().send();
+ } catch (Exception e) {
+ String message = "could not send the message " + msgNode.getMessageClassName();
+ OseeLog.log(SendMessageAction.class, Level.SEVERE, message, e);
+ MessageDialog.openError(Displays.getActiveShell(), "Send Message", message + ". Check error log for trace");
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SetValueAction.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SetValueAction.java
index cf2bb19495a..a54fda9030a 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SetValueAction.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/SetValueAction.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.message.Message;
import org.eclipse.osee.ote.message.elements.Element;
import org.eclipse.osee.ote.message.elements.EnumeratedElement;
@@ -28,116 +29,118 @@ import org.eclipse.osee.ote.message.tool.MessageMode;
import org.eclipse.osee.ote.ui.message.internal.Activator;
import org.eclipse.osee.ote.ui.message.tree.ElementNode;
import org.eclipse.osee.ote.ui.message.tree.WatchedMessageNode;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.dialogs.ListDialog;
/**
* @author Ken J. Aguilar
*/
public class SetValueAction extends Action {
- private final WatchedMessageNode msgNode;
- private final ElementNode node;
-
- public SetValueAction(ElementNode node) {
- super("Set Value");
- this.node = node;
- msgNode = (WatchedMessageNode) node.getMessageNode();
- setEnabled(node.isEnabled() && msgNode.getSubscription().getMessageMode() == MessageMode.WRITER && msgNode.getSubscription().isActive());
- }
-
- @Override
- public void run() {
- Message<?,?,?> msg = msgNode.getSubscription().getMessage();
- List<Object> path = node.getElementPath().getElementPath();
- Element element = msg.getElement(path);
- if (element instanceof EnumeratedElement<?>) {
- final EnumeratedElement<?> enumElement = (EnumeratedElement<?>) element;
- try {
- final Enum<?>[] values = enumElement.getEnumValues();
- int width = 0;
- for (Enum<?> val : values) {
- width = val.toString().length() > width ? val.toString().length() : width;
- }
-
- final ListDialog dialog = new ListDialog(Display.getDefault().getActiveShell());
- dialog.setInput(values);
- dialog.setTitle("Set Value");
- dialog.setAddCancelButton(true);
- dialog.setWidthInChars(width + 5);
- dialog.setMessage(element.getFullName() + "\nSelect New Value");
- dialog.setContentProvider(new ITreeContentProvider() {
-
- public Object[] getChildren(Object parentElement) {
- return null;
- }
-
- public Object getParent(Object element) {
- return values;
- }
-
- public boolean hasChildren(Object element) {
- return false;
- }
-
- public Object[] getElements(Object inputElement) {
- return values;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- });
-
- dialog.setLabelProvider(new LabelProvider() {
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
- });
-
- int result = dialog.open();
- if (result == Window.OK) {
- final Object[] objs = dialog.getResult();
- if (objs.length == 1) {
- final String value = ((Enum<?>) objs[0]).name();
- msgNode.getSubscription().setElementValue(path, value);
- }
- }
- } catch (Throwable t) {
- final String logMsg =
- String.format("Exception while attempting to set element %s of message %s", element.getName(),
- msg.getName());
- OseeLog.log(Activator.class, Level.SEVERE, logMsg, t);
- }
-
- } else {
- InputDialog dialog =
- new InputDialog(Display.getDefault().getActiveShell(), "Set " + element.getFullName(),
- "Enter set value", "0", new IInputValidator() {
-
- @Override
- public String isValid(String newText) {
- // No Error accept all values;
- return null;
- }
- });
-
- // final EntryDialog dialog =
- // new EntryDialog(Display.getDefault().getActiveShell(), "Set " + element.getFullName(), null,
- // "Enter set value", MessageDialog.QUESTION, new String[] {"Ok", "Cancel"}, 0);
- if (dialog.open() == 0) {
- try {
- final String val = dialog.getValue();
- msgNode.getSubscription().setElementValue(path, val);
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, String.format(
- "Unable to set the %s element for the message %s", element.getName(), msg.getName()), ex);
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", "Could not set value");
- }
- }
- }
- }
+ private final WatchedMessageNode msgNode;
+ private final ElementNode node;
+
+ public SetValueAction(ElementNode node) {
+ super("Set Value");
+ this.node = node;
+ msgNode = (WatchedMessageNode) node.getMessageNode();
+ setEnabled(node.isEnabled() && msgNode.getSubscription().getMessageMode() == MessageMode.WRITER && msgNode.getSubscription().isActive());
+ }
+
+ @Override
+ public void run() {
+ Message<?, ?, ?> msg = msgNode.getSubscription().getMessage();
+ List<Object> path = node.getElementPath().getElementPath();
+ Element element = msg.getElement(path);
+ if (element instanceof EnumeratedElement<?>) {
+ final EnumeratedElement<?> enumElement = (EnumeratedElement<?>) element;
+ try {
+ final Enum<?>[] values = enumElement.getEnumValues();
+ int width = 0;
+ for (Enum<?> val : values) {
+ width = val.toString().length() > width ? val.toString().length() : width;
+ }
+
+ final ListDialog dialog = new ListDialog(Displays.getActiveShell());
+ dialog.setInput(values);
+ dialog.setTitle("Set Value");
+ dialog.setAddCancelButton(true);
+ dialog.setWidthInChars(width + 5);
+ dialog.setMessage(element.getFullName() + "\nSelect New Value");
+ dialog.setContentProvider(new ITreeContentProvider() {
+
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+
+ public Object getParent(Object element) {
+ return values;
+ }
+
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return values;
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ });
+
+ dialog.setLabelProvider(new LabelProvider() {
+ @Override
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+ });
+
+ int result = dialog.open();
+ if (result == Window.OK) {
+ final Object[] objs = dialog.getResult();
+ if (objs.length == 1) {
+ final String value = ((Enum<?>) objs[0]).name();
+ msgNode.getSubscription().setElementValue(path, value);
+ }
+ }
+ } catch (Throwable t) {
+ final String logMsg =
+ String.format("Exception while attempting to set element %s of message %s", element.getName(),
+ msg.getName());
+ OseeLog.log(Activator.class, Level.SEVERE, logMsg, t);
+ }
+
+ } else {
+ InputDialog dialog =
+ new InputDialog(Displays.getActiveShell(), "Set " + element.getFullName(), "Enter set value", "0",
+ new IInputValidator() {
+
+ @Override
+ public String isValid(String newText) {
+ // No Error accept all values;
+ return null;
+ }
+ });
+
+ // final EntryDialog dialog =
+ // new EntryDialog(Displays.getActiveShell(), "Set " + element.getFullName(), null,
+ // "Enter set value", MessageDialog.QUESTION, new String[] {"Ok", "Cancel"}, 0);
+ if (dialog.open() == 0) {
+ try {
+ final String val = dialog.getValue();
+ msgNode.getSubscription().setElementValue(path, val);
+ } catch (Exception ex) {
+ OseeLog.log(
+ Activator.class,
+ Level.SEVERE,
+ String.format("Unable to set the %s element for the message %s", element.getName(),
+ msg.getName()), ex);
+ MessageDialog.openError(Displays.getActiveShell(), "Error", "Could not set value");
+ }
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/WatchElementAction.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/WatchElementAction.java
index c871f34c256..888381edeb6 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/WatchElementAction.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/WatchElementAction.java
@@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.LinkedList;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.window.Window;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.ote.client.msg.core.IMessageSubscription;
import org.eclipse.osee.ote.message.Message;
@@ -27,89 +28,88 @@ import org.eclipse.osee.ote.ui.message.watch.ChildElementNodeLabelProvider;
import org.eclipse.osee.ote.ui.message.watch.ChildSelectCheckedTreeSelectionDialog;
import org.eclipse.osee.ote.ui.message.watch.ElementPath;
import org.eclipse.osee.ote.ui.message.watch.WatchView;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
/**
* @author Andrew M. Finkbeiner
*/
public class WatchElementAction extends Action {
- private final WatchView watchView;
+ private final WatchView watchView;
- private final WatchedMessageNode msgNode;
+ private final WatchedMessageNode msgNode;
- public WatchElementAction(WatchView watchView, WatchedMessageNode node) {
- super("Watch Element", Action.AS_PUSH_BUTTON);
- setToolTipText("loads additional message elements");
- this.watchView = watchView;
- this.msgNode = node;
- setEnabled(node.isEnabled() && node.getSubscription().isResolved());
- }
+ public WatchElementAction(WatchView watchView, WatchedMessageNode node) {
+ super("Watch Element", Action.AS_PUSH_BUTTON);
+ setToolTipText("loads additional message elements");
+ this.watchView = watchView;
+ this.msgNode = node;
+ setEnabled(node.isEnabled() && node.getSubscription().isResolved());
+ }
- @Override
- public void run() {
- final String msgName = msgNode.getMessageClassName();
- final LinkedList<Element> list = new LinkedList<Element>();
- boolean needsTreeView = false;
+ @Override
+ public void run() {
+ final String msgName = msgNode.getMessageClassName();
+ final LinkedList<Element> list = new LinkedList<Element>();
+ boolean needsTreeView = false;
- IMessageSubscription subscription = msgNode.getSubscription();
- Message<?, ?, ?> message = subscription.getMessage();
- Collection<Element> msgElements = message.getElements();
+ IMessageSubscription subscription = msgNode.getSubscription();
+ Message<?, ?, ?> message = subscription.getMessage();
+ Collection<Element> msgElements = message.getElements();
- for (final Element element : msgElements) {
- if (element instanceof RecordElement) {
- needsTreeView = true;
- list.add(element);
- } else if (msgNode.findChildElement(new ElementPath(element.getElementPath())) == null) {
- list.add(element);
- }
- }
- if (needsTreeView) {
- ChildSelectCheckedTreeSelectionDialog dialog =
- new ChildSelectCheckedTreeSelectionDialog(Display.getDefault().getActiveShell(),
- new ChildElementNodeLabelProvider(), new ChildElementNodeContentProvider());
- dialog.setTitle(msgNode.getName());
+ for (final Element element : msgElements) {
+ if (element instanceof RecordElement) {
+ needsTreeView = true;
+ list.add(element);
+ } else if (msgNode.findChildElement(new ElementPath(element.getElementPath())) == null) {
+ list.add(element);
+ }
+ }
+ if (needsTreeView) {
+ ChildSelectCheckedTreeSelectionDialog dialog =
+ new ChildSelectCheckedTreeSelectionDialog(Displays.getActiveShell(),
+ new ChildElementNodeLabelProvider(), new ChildElementNodeContentProvider());
+ dialog.setTitle(msgNode.getName());
- dialog.setImage(ImageManager.getImage(OteMessageImage.GEAR));
- dialog.setEmptyListMessage("No matching message elements");
- dialog.setInput(msgNode);
- dialog.setMessage("Select elements to watch.");
- if (dialog.open() == Window.OK) {
- Object[] additions = dialog.getResult();
- if (additions.length > 0) {
- AddWatchParameter parameter = new AddWatchParameter();
- for (Object elem : additions) {
- if (!(elem instanceof RecordElement)) {
- parameter.addMessage(msgName, new ElementPath(((Element) elem).getElementPath()));
- }
- }
- watchView.addWatchMessage(parameter);
- watchView.getTreeViewer().refresh(msgNode);
- watchView.saveWatchFile();
- }
- }
- } else {
- final Element[] elements = list.toArray(new Element[list.size()]);
- ElementListSelectionDialog dialog =
- new ElementListSelectionDialog(Display.getDefault().getActiveShell(), new ElementLabelProvider());
- dialog.setMultipleSelection(true);
- dialog.setTitle(msgNode.getName());
- dialog.setImage(ImageManager.getImage(OteMessageImage.GEAR));
- dialog.setMessage("Select element to watch. (? matches any character, * matches any string)");
- dialog.setEmptySelectionMessage("No matching message elements");
- dialog.setElements(elements);
- if (dialog.open() == Window.OK) {
- Object[] additions = dialog.getResult();
- if (additions.length > 0) {
- AddWatchParameter parameter = new AddWatchParameter();
- for (Object elem : additions) {
- parameter.addMessage(msgName, new ElementPath(((Element) elem).getElementPath()));
- }
- watchView.addWatchMessage(parameter);
- watchView.getTreeViewer().refresh(msgNode);
- watchView.saveWatchFile();
- }
- }
- }
- }
+ dialog.setImage(ImageManager.getImage(OteMessageImage.GEAR));
+ dialog.setEmptyListMessage("No matching message elements");
+ dialog.setInput(msgNode);
+ dialog.setMessage("Select elements to watch.");
+ if (dialog.open() == Window.OK) {
+ Object[] additions = dialog.getResult();
+ if (additions.length > 0) {
+ AddWatchParameter parameter = new AddWatchParameter();
+ for (Object elem : additions) {
+ if (!(elem instanceof RecordElement)) {
+ parameter.addMessage(msgName, new ElementPath(((Element) elem).getElementPath()));
+ }
+ }
+ watchView.addWatchMessage(parameter);
+ watchView.getTreeViewer().refresh(msgNode);
+ watchView.saveWatchFile();
+ }
+ }
+ } else {
+ final Element[] elements = list.toArray(new Element[list.size()]);
+ ElementListSelectionDialog dialog =
+ new ElementListSelectionDialog(Displays.getActiveShell(), new ElementLabelProvider());
+ dialog.setMultipleSelection(true);
+ dialog.setTitle(msgNode.getName());
+ dialog.setImage(ImageManager.getImage(OteMessageImage.GEAR));
+ dialog.setMessage("Select element to watch. (? matches any character, * matches any string)");
+ dialog.setEmptySelectionMessage("No matching message elements");
+ dialog.setElements(elements);
+ if (dialog.open() == Window.OK) {
+ Object[] additions = dialog.getResult();
+ if (additions.length > 0) {
+ AddWatchParameter parameter = new AddWatchParameter();
+ for (Object elem : additions) {
+ parameter.addMessage(msgName, new ElementPath(((Element) elem).getElementPath()));
+ }
+ watchView.addWatchMessage(parameter);
+ watchView.getTreeViewer().refresh(msgNode);
+ watchView.saveWatchFile();
+ }
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeElementAction.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeElementAction.java
index 6fc4d14ff3c..090167ab4ff 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeElementAction.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeElementAction.java
@@ -8,44 +8,42 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.message.watch.action;
-
+package org.eclipse.osee.ote.ui.message.watch.action;
+
import java.util.List;
import java.util.logging.Level;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.message.tool.MessageMode;
import org.eclipse.osee.ote.ui.message.tree.ElementNode;
import org.eclipse.osee.ote.ui.message.tree.WatchedMessageNode;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @author Ken J. Aguilar
- *
- */
-public class ZeroizeElementAction extends Action {
-
- private final WatchedMessageNode msgNode;
- private final List<Object> path;
-
- public ZeroizeElementAction(ElementNode node) {
- super("Zeroize Element");
- this.msgNode = (WatchedMessageNode) node.getMessageNode();
- setEnabled(node.isEnabled() && msgNode.getSubscription().getMessageMode() == MessageMode.WRITER);
- path = node.getElementPath().getElementPath();
- }
-
- @Override
- public void run() {
- try {
- msgNode.getSubscription().zeroize(path);
- } catch (Exception e) {
- String message = "could not zeroize the message " + msgNode.getMessageClassName();
- OseeLog.log(ZeroizeElementAction.class, Level.SEVERE, message, e);
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Zeroize Error", message + ". See error log for trace");
- }
- }
-
-
-}
+
+/**
+ * @author Ken J. Aguilar
+ */
+public class ZeroizeElementAction extends Action {
+
+ private final WatchedMessageNode msgNode;
+ private final List<Object> path;
+
+ public ZeroizeElementAction(ElementNode node) {
+ super("Zeroize Element");
+ this.msgNode = (WatchedMessageNode) node.getMessageNode();
+ setEnabled(node.isEnabled() && msgNode.getSubscription().getMessageMode() == MessageMode.WRITER);
+ path = node.getElementPath().getElementPath();
+ }
+
+ @Override
+ public void run() {
+ try {
+ msgNode.getSubscription().zeroize(path);
+ } catch (Exception e) {
+ String message = "could not zeroize the message " + msgNode.getMessageClassName();
+ OseeLog.log(ZeroizeElementAction.class, Level.SEVERE, message, e);
+ MessageDialog.openError(Displays.getActiveShell(), "Zeroize Error", message + ". See error log for trace");
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeMessageAction.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeMessageAction.java
index 0af6b91477b..4d311c4a57e 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeMessageAction.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/action/ZeroizeMessageAction.java
@@ -8,40 +8,38 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.message.watch.action;
-
+package org.eclipse.osee.ote.ui.message.watch.action;
+
import java.util.logging.Level;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.message.tool.MessageMode;
import org.eclipse.osee.ote.ui.message.tree.WatchedMessageNode;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @author Ken J. Aguilar
- *
- */
-public class ZeroizeMessageAction extends Action {
-
- private final WatchedMessageNode msgNode;
-
- public ZeroizeMessageAction(WatchedMessageNode msgNode) {
- super("Zeroize " + msgNode.getName());
- this.msgNode = msgNode;
- setEnabled(msgNode.isEnabled() && msgNode.getSubscription().getMessageMode() == MessageMode.WRITER && msgNode.getSubscription().isActive());
- }
-
- @Override
- public void run() {
- try {
- msgNode.getSubscription().zeroize(null);
- } catch (Exception e) {
- String message = "could not zeroize the message " + msgNode.getMessageClassName();
- OseeLog.log(ZeroizeMessageAction.class, Level.SEVERE, message, e);
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Zeroize Error", message + ". See error log for trace");
- }
- }
-
-
-}
+
+/**
+ * @author Ken J. Aguilar
+ */
+public class ZeroizeMessageAction extends Action {
+
+ private final WatchedMessageNode msgNode;
+
+ public ZeroizeMessageAction(WatchedMessageNode msgNode) {
+ super("Zeroize " + msgNode.getName());
+ this.msgNode = msgNode;
+ setEnabled(msgNode.isEnabled() && msgNode.getSubscription().getMessageMode() == MessageMode.WRITER && msgNode.getSubscription().isActive());
+ }
+
+ @Override
+ public void run() {
+ try {
+ msgNode.getSubscription().zeroize(null);
+ } catch (Exception e) {
+ String message = "could not zeroize the message " + msgNode.getMessageClassName();
+ OseeLog.log(ZeroizeMessageAction.class, Level.SEVERE, message, e);
+ MessageDialog.openError(Displays.getActiveShell(), "Zeroize Error", message + ". See error log for trace");
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/recording/RecordingFilePage.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/recording/RecordingFilePage.java
index 96225c09ef4..ea698c52cf0 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/recording/RecordingFilePage.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/recording/RecordingFilePage.java
@@ -8,11 +8,12 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.message.watch.recording;
-
+package org.eclipse.osee.ote.ui.message.watch.recording;
+
import java.io.File;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.Widgets;
import org.eclipse.osee.ote.ui.message.internal.Activator;
import org.eclipse.swt.SWT;
@@ -20,100 +21,96 @@ 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.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-
-public class RecordingFilePage extends WizardPage {
+
+public class RecordingFilePage extends WizardPage {
private static final String SECTION = "ote.ui.message.settings.section";
private static final String PATH_KEY = "ote.ui.message.settings.rec_file_path";
-
- private String selectedFile;
- private Text filePathTxt;
-
- public RecordingFilePage() {
- super("filePage");
- setTitle("Select A File");
- setDescription("This is the file that will contain the recorded data.");
- }
-
- @Override
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- Widgets.setFormLayout(composite);
- Label fileLbl = new Label(composite, SWT.RIGHT);
- fileLbl.setText("Path:");
- filePathTxt = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
- Button filePickBtn = new Button(composite, SWT.PUSH);
-
- Widgets.attachToParent(filePickBtn, SWT.RIGHT, 100, -10);
- Widgets.attachToParent(filePickBtn, SWT.TOP, 50, 0);
-
- Widgets.attachToParent(fileLbl, SWT.LEFT, 0, 10);
-
- Widgets.attachToControl(filePathTxt, filePickBtn, SWT.RIGHT, SWT.LEFT,
- -5);
- Widgets.attachToControl(filePathTxt, filePickBtn, SWT.TOP, SWT.CENTER,
- 0);
- Widgets.attachToControl(filePathTxt, fileLbl, SWT.LEFT, SWT.RIGHT, 5);
-
- Widgets.attachToControl(fileLbl, filePathTxt, SWT.TOP, SWT.CENTER, 0);
-
- filePickBtn.setText("Browse...");
- filePickBtn.addSelectionListener(new SelectionAdapter() {
-
- @Override
+
+ private String selectedFile;
+ private Text filePathTxt;
+
+ public RecordingFilePage() {
+ super("filePage");
+ setTitle("Select A File");
+ setDescription("This is the file that will contain the recorded data.");
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ Widgets.setFormLayout(composite);
+ Label fileLbl = new Label(composite, SWT.RIGHT);
+ fileLbl.setText("Path:");
+ filePathTxt = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
+ Button filePickBtn = new Button(composite, SWT.PUSH);
+
+ Widgets.attachToParent(filePickBtn, SWT.RIGHT, 100, -10);
+ Widgets.attachToParent(filePickBtn, SWT.TOP, 50, 0);
+
+ Widgets.attachToParent(fileLbl, SWT.LEFT, 0, 10);
+
+ Widgets.attachToControl(filePathTxt, filePickBtn, SWT.RIGHT, SWT.LEFT, -5);
+ Widgets.attachToControl(filePathTxt, filePickBtn, SWT.TOP, SWT.CENTER, 0);
+ Widgets.attachToControl(filePathTxt, fileLbl, SWT.LEFT, SWT.RIGHT, 5);
+
+ Widgets.attachToControl(fileLbl, filePathTxt, SWT.TOP, SWT.CENTER, 0);
+
+ filePickBtn.setText("Browse...");
+ filePickBtn.addSelectionListener(new SelectionAdapter() {
+
+ @Override
public void widgetSelected(SelectionEvent e) {
IDialogSettings settings = Activator.getDefault().getDialogSettings();
IDialogSettings section = settings.getSection(SECTION);
if (section == null) {
section = settings.addNewSection(SECTION);
}
-
- FileDialog dialog = new FileDialog(Display.getDefault()
- .getActiveShell(), SWT.SAVE);
+
+ FileDialog dialog = new FileDialog(Displays.getActiveShell(), SWT.SAVE);
String path = section.get(PATH_KEY);
if (path != null) {
File file = new File(path);
if (file.exists() && file.isDirectory()) {
dialog.setFilterPath(path);
}
- }
- dialog.setFilterExtensions(new String[]{"*.csv"});
- String result = dialog.open();
+ }
+ dialog.setFilterExtensions(new String[] {"*.csv"});
+ String result = dialog.open();
if (result != null) {
File file = new File(result);
section.put(PATH_KEY, file.getParent());
-
- int filterIndex = dialog.getFilterIndex();
- String[] extensions = dialog.getFilterExtensions();
- if(filterIndex >= 0 && filterIndex < extensions.length){
- if(!result.endsWith(extensions[filterIndex].substring(1))){
- result = result + extensions[filterIndex].substring(1);
- }
- }
- selectedFile = result;
- selectSource();
- }
- }
-
- });
- if (selectedFile != null) {
- selectSource();
- } else {
- setPageComplete(false);
- }
- setControl(composite);
- }
-
- private void selectSource() {
- filePathTxt.setText(selectedFile);
- setPageComplete(true);
- }
-
- public String getFileName(){
- return filePathTxt.getText();
- }
-
-}
+
+ int filterIndex = dialog.getFilterIndex();
+ String[] extensions = dialog.getFilterExtensions();
+ if (filterIndex >= 0 && filterIndex < extensions.length) {
+ if (!result.endsWith(extensions[filterIndex].substring(1))) {
+ result = result + extensions[filterIndex].substring(1);
+ }
+ }
+ selectedFile = result;
+ selectSource();
+ }
+ }
+
+ });
+ if (selectedFile != null) {
+ selectSource();
+ } else {
+ setPageComplete(false);
+ }
+ setControl(composite);
+ }
+
+ private void selectSource() {
+ filePathTxt.setText(selectedFile);
+ setPageComplete(true);
+ }
+
+ public String getFileName() {
+ return filePathTxt.getText();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/actions/OpenMuxViewAction.java b/plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/actions/OpenMuxViewAction.java
index c25410c9444..f15b84790af 100644
--- a/plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/actions/OpenMuxViewAction.java
+++ b/plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/actions/OpenMuxViewAction.java
@@ -8,31 +8,27 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.mux.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.osee.ote.ui.mux.view.MuxView;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-public class OpenMuxViewAction extends Action {
-
- public OpenMuxViewAction() {
- super("Open Mux View");
- }
-
- @Override
- public void run() {
- try {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage().showView(MuxView.VIEW_ID);
- } catch (Exception e) {
- MessageDialog.openError(Display.getDefault().getActiveShell(),
- "Error", "got an exception");
- }
- }
-
-
-
-}
+package org.eclipse.osee.ote.ui.mux.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osee.framework.ui.swt.Displays;
+import org.eclipse.osee.ote.ui.mux.view.MuxView;
+import org.eclipse.ui.PlatformUI;
+
+public class OpenMuxViewAction extends Action {
+
+ public OpenMuxViewAction() {
+ super("Open Mux View");
+ }
+
+ @Override
+ public void run() {
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(MuxView.VIEW_ID);
+ } catch (Exception e) {
+ MessageDialog.openError(Displays.getActiveShell(), "Error", "got an exception");
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/view/MuxView.java b/plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/view/MuxView.java
index 42813d05915..e38c1a4513d 100644
--- a/plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/view/MuxView.java
+++ b/plugins/org.eclipse.osee.ote.ui.mux/src/org/eclipse/osee/ote/ui/mux/view/MuxView.java
@@ -28,6 +28,7 @@ import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.osee.connection.service.IServiceConnector;
import org.eclipse.osee.framework.jdk.core.util.network.PortUtil;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.PeriodicDisplayTask;
import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment;
import org.eclipse.osee.ote.message.IInstrumentationRegistrationListener;
@@ -89,847 +90,844 @@ import org.eclipse.ui.part.ViewPart;
*/
public class MuxView extends ViewPart implements ITestConnectionListener, IInstrumentationRegistrationListener, Remote {
- private TableViewer msgViewer1, msgViewer2, msgViewer3, msgViewer5;
- private TableViewer dataViewer1, dataViewer2, dataViewer3, dataViewer5;
- private MessageModel chan1Msgs, chan2Msgs, chan3Msgs, chan5Msgs;
- private DatawordModel chan1Dwrds, chan2Dwrds, chan3Dwrds, chan5Dwrds;
- private IOInstrumentation muxProbe;
- private PeriodicDisplayTask task;
- private ListenerThread thread;
- private int port;
- private int selectedChannel;
- private int selectedRt;
- private int selectedTR;
- private int selectedSubaddr;
- private final static Color GRAY = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
- private final static Color WHITE = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
-
- private IInstrumentationRegistrationListener exportedThis;
-
- public static final String VIEW_ID = "osee.test.muxTool.views.MuxView";
- class NameSorter extends ViewerSorter {
- }
-
- /**
- * The constructor.
- */
- public MuxView() {
- super();
- }
-
- /**
- * This is a callback that will allow us to create the viewers and initialize them.
- */
- @Override
- public void createPartControl(Composite parent) {
- final TabFolder tabFolder = new TabFolder(parent, SWT.WRAP);
- tabFolder.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- switch (tabFolder.getSelectionIndex()) {
- case 0:
- selectedChannel = 1;
- break;
- case 1:
- selectedChannel = 2;
- break;
- case 2:
- selectedChannel = 3;
- break;
- case 3:
- selectedChannel = 5;
- break;
- default:
- selectedChannel = 1;
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- // Setup Channel 1 display
- TabItem chan1Tab = new TabItem(tabFolder, SWT.NONE);
- chan1Tab.setText("Channel 1");
- Composite chan1TabComp = new Composite(tabFolder, SWT.NONE);
- chan1Tab.setControl(chan1TabComp);
- GridLayout chan1Layout = new GridLayout(1, false);
- chan1TabComp.setLayout(chan1Layout);
-
- msgViewer1 = new TableViewer(chan1TabComp, SWT.BORDER | SWT.FULL_SELECTION);
- msgViewer1.setLabelProvider(new MuxMsgLabelProvider());
- msgViewer1.setSorter(new NameSorter());
- msgViewer1.setContentProvider(new MuxMsgContentProvider());
-
- createMsgTable(msgViewer1);
-
- Composite bottom1 = new Composite(chan1TabComp, SWT.NONE);
- bottom1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- bottom1.setLayout(new GridLayout(2, false));
-
- Composite data1 = new Composite(bottom1, SWT.NONE);
- RowLayout dataLayout1 = new RowLayout(SWT.HORIZONTAL);
- data1.setLayout(dataLayout1);
-
- Composite labels1 = new Composite(data1, SWT.NONE);
- RowLayout labelLayout1 = new RowLayout(SWT.VERTICAL);
- labelLayout1.marginTop = 5;
- labelLayout1.spacing = 1;
- labels1.setLayout(labelLayout1);
- Label label1_1 = new Label(labels1, SWT.NONE);
- label1_1.setText("Datawords 1-8");
- Label label2_1 = new Label(labels1, SWT.NONE);
- label2_1.setText("Datawords 9-16");
- Label label3_1 = new Label(labels1, SWT.NONE);
- label3_1.setText("Datawords 17-24");
- Label label4_1 = new Label(labels1, SWT.NONE);
- label4_1.setText("Datawords 25-32");
-
- Composite datawords1 = new Composite(data1, SWT.NONE);
- datawords1.setLayout(new GridLayout(1, false));
- dataViewer1 = new TableViewer(datawords1, SWT.BORDER | SWT.FULL_SELECTION);
- dataViewer1.setContentProvider(new DatawordContentProvider());
- dataViewer1.setLabelProvider(new DatawordLabelProvider());
- createDwordTable(dataViewer1);
- msgViewer1.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- MessageNode node = (MessageNode) selection.getFirstElement();
- if (node != null) {
- selectedRt = node.getRt();
- selectedTR = node.getTransmitReceive();
- selectedSubaddr = node.getSubaddress();
- chan1Dwrds.setCurrentNode(node.getName());
- }
- }
- });
- final Button reset1 = new Button(bottom1, SWT.PUSH);
- reset1.setText("Reset Display");
- reset1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL));
- reset1.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedRt = 0;
- selectedTR = 0;
- selectedSubaddr = 0;
- chan1Msgs.removeMessages();
- chan1Dwrds.setCurrentNode(null);
- }
- });
-
- // Setup Channel 2 display
- TabItem chan2Tab = new TabItem(tabFolder, SWT.NONE);
- chan2Tab.setText("Channel 2");
- Composite chan2TabComp = new Composite(tabFolder, SWT.NONE);
- chan2Tab.setControl(chan2TabComp);
- GridLayout chan2Layout = new GridLayout(1, false);
- chan2TabComp.setLayout(chan2Layout);
- msgViewer2 = new TableViewer(chan2TabComp, SWT.BORDER | SWT.FULL_SELECTION);
- msgViewer2.setContentProvider(new MuxMsgContentProvider());
- msgViewer2.setLabelProvider(new MuxMsgLabelProvider());
- msgViewer2.setSorter(new NameSorter());
- createMsgTable(msgViewer2);
- Composite bottom2 = new Composite(chan2TabComp, SWT.NONE);
- bottom2.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- bottom2.setLayout(new GridLayout(2, false));
-
- Composite data2 = new Composite(bottom2, SWT.NONE);
- RowLayout dataLayout2 = new RowLayout(SWT.HORIZONTAL);
- data2.setLayout(dataLayout2);
-
- Composite labels2 = new Composite(data2, SWT.NONE);
- RowLayout lableLayout2 = new RowLayout(SWT.VERTICAL);
- lableLayout2.marginTop = 5;
- lableLayout2.spacing = 1;
- labels2.setLayout(lableLayout2);
- Label label1_2 = new Label(labels2, SWT.NONE);
- label1_2.setText("Datawords 1-8");
- Label label2_2 = new Label(labels2, SWT.NONE);
- label2_2.setText("Datawords 9-16");
- Label label3_2 = new Label(labels2, SWT.NONE);
- label3_2.setText("Datawords 17-24");
- Label label4_2 = new Label(labels2, SWT.NONE);
- label4_2.setText("Datawords 25-32");
-
- Composite datawords2 = new Composite(data2, SWT.NONE);
- datawords2.setLayout(new GridLayout(1, false));
- dataViewer2 = new TableViewer(datawords2, SWT.BORDER | SWT.FULL_SELECTION);
- dataViewer2.setContentProvider(new DatawordContentProvider());
- dataViewer2.setLabelProvider(new DatawordLabelProvider());
- createDwordTable(dataViewer2);
- msgViewer2.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- MessageNode node = (MessageNode) selection.getFirstElement();
- if (node != null) {
- selectedRt = node.getRt();
- selectedTR = node.getTransmitReceive();
- selectedSubaddr = node.getSubaddress();
- chan2Dwrds.setCurrentNode(node.getName());
- }
- }
- });
- final Button reset2 = new Button(bottom2, SWT.PUSH);
- reset2.setText("Reset Display");
- reset2.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL));
- reset2.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedRt = 0;
- selectedTR = 0;
- selectedSubaddr = 0;
- chan2Msgs.removeMessages();
- chan2Dwrds.setCurrentNode(null);
- }
- });
-
- // Setup Channel 3 display
- TabItem chan3Tab = new TabItem(tabFolder, SWT.NONE);
- chan3Tab.setText("Channel 3");
- Composite chan3TabComp = new Composite(tabFolder, SWT.NONE);
- chan3Tab.setControl(chan3TabComp);
- GridLayout chan3Layout = new GridLayout(1, false);
- chan3TabComp.setLayout(chan3Layout);
- msgViewer3 = new TableViewer(chan3TabComp, SWT.BORDER | SWT.FULL_SELECTION);
- msgViewer3.setContentProvider(new MuxMsgContentProvider());
- msgViewer3.setLabelProvider(new MuxMsgLabelProvider());
- msgViewer3.setSorter(new NameSorter());
- createMsgTable(msgViewer3);
- Composite bottom3 = new Composite(chan3TabComp, SWT.NONE);
- bottom3.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- bottom3.setLayout(new GridLayout(2, false));
-
- Composite data3 = new Composite(bottom3, SWT.NONE);
- RowLayout dataLayout3 = new RowLayout(SWT.HORIZONTAL);
- data3.setLayout(dataLayout3);
-
- Composite labels3 = new Composite(data3, SWT.NONE);
- RowLayout lableLayout3 = new RowLayout(SWT.VERTICAL);
- lableLayout3.marginTop = 5;
- lableLayout3.spacing = 1;
- labels3.setLayout(lableLayout3);
- Label label1_3 = new Label(labels3, SWT.NONE);
- label1_3.setText("Datawords 1-8");
- Label label2_3 = new Label(labels3, SWT.NONE);
- label2_3.setText("Datawords 9-16");
- Label label3_3 = new Label(labels3, SWT.NONE);
- label3_3.setText("Datawords 17-24");
- Label label4_3 = new Label(labels3, SWT.NONE);
- label4_3.setText("Datawords 25-32");
-
- Composite datawords3 = new Composite(data3, SWT.NONE);
- datawords3.setLayout(new GridLayout(1, false));
- dataViewer3 = new TableViewer(datawords3, SWT.BORDER | SWT.FULL_SELECTION);
- dataViewer3.setContentProvider(new DatawordContentProvider());
- dataViewer3.setLabelProvider(new DatawordLabelProvider());
- createDwordTable(dataViewer3);
- msgViewer3.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- MessageNode node = (MessageNode) selection.getFirstElement();
- if (node != null) {
- selectedRt = node.getRt();
- selectedTR = node.getTransmitReceive();
- selectedSubaddr = node.getSubaddress();
- chan3Dwrds.setCurrentNode(node.getName());
- }
- }
- });
- final Button reset3 = new Button(bottom3, SWT.PUSH);
- reset3.setText("Reset Display");
- reset3.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL));
- reset3.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedRt = 0;
- selectedTR = 0;
- selectedSubaddr = 0;
- chan3Msgs.removeMessages();
- chan3Dwrds.setCurrentNode(null);
- }
- });
-
- // Setup Channel 5 display
- TabItem chan5Tab = new TabItem(tabFolder, SWT.NONE);
- chan5Tab.setText("Channel 5");
- Composite chan5TabComp = new Composite(tabFolder, SWT.NONE);
- chan5Tab.setControl(chan5TabComp);
- GridLayout chan5Layout = new GridLayout(1, false);
- chan5TabComp.setLayout(chan5Layout);
- msgViewer5 = new TableViewer(chan5TabComp, SWT.BORDER | SWT.FULL_SELECTION);
- msgViewer5.setContentProvider(new MuxMsgContentProvider());
- msgViewer5.setLabelProvider(new MuxMsgLabelProvider());
- msgViewer5.setSorter(new NameSorter());
- createMsgTable(msgViewer5);
- Composite bottom5 = new Composite(chan5TabComp, SWT.NONE);
- bottom5.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- bottom5.setLayout(new GridLayout(2, false));
-
- Composite data5 = new Composite(bottom5, SWT.NONE);
- RowLayout dataLayout5 = new RowLayout(SWT.HORIZONTAL);
- data5.setLayout(dataLayout5);
-
- Composite labels5 = new Composite(data5, SWT.NONE);
- RowLayout lableLayout5 = new RowLayout(SWT.VERTICAL);
- lableLayout5.marginTop = 5;
- lableLayout5.spacing = 1;
- labels5.setLayout(lableLayout5);
- Label label1_5 = new Label(labels5, SWT.NONE);
- label1_5.setText("Datawords 1-8");
- Label label2_5 = new Label(labels5, SWT.NONE);
- label2_5.setText("Datawords 9-16");
- Label label3_5 = new Label(labels5, SWT.NONE);
- label3_5.setText("Datawords 17-24");
- Label label4_5 = new Label(labels5, SWT.NONE);
- label4_5.setText("Datawords 25-32");
-
- Composite datawords5 = new Composite(data5, SWT.NONE);
- datawords5.setLayout(new GridLayout(1, false));
- dataViewer5 = new TableViewer(datawords5, SWT.BORDER | SWT.FULL_SELECTION);
- dataViewer5.setContentProvider(new DatawordContentProvider());
- dataViewer5.setLabelProvider(new DatawordLabelProvider());
- createDwordTable(dataViewer5);
- msgViewer5.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- MessageNode node = (MessageNode) selection.getFirstElement();
- if (node != null) {
- selectedRt = node.getRt();
- selectedTR = node.getTransmitReceive();
- selectedSubaddr = node.getSubaddress();
- chan5Dwrds.setCurrentNode(node.getName());
- }
- }
- });
- final Button reset5 = new Button(bottom5, SWT.PUSH);
- reset5.setText("Reset Display");
- reset5.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL));
- reset5.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedRt = 0;
- selectedTR = 0;
- selectedSubaddr = 0;
- chan5Msgs.removeMessages();
- chan5Dwrds.setCurrentNode(null);
- }
- });
- msgViewer1.setInput(chan1Msgs = new MessageModel());
- dataViewer1.setInput(chan1Dwrds = new DatawordModel());
- msgViewer2.setInput(chan2Msgs = new MessageModel());
- dataViewer2.setInput(chan2Dwrds = new DatawordModel());
- msgViewer3.setInput(chan3Msgs = new MessageModel());
- dataViewer3.setInput(chan3Dwrds = new DatawordModel());
- msgViewer5.setInput(chan5Msgs = new MessageModel());
- dataViewer5.setInput(chan5Dwrds = new DatawordModel());
- updateColors(false);
- try {
- thread = new ListenerThread();
- } catch (Exception e) {
- OseeLog.log(MuxView.class, Level.SEVERE, "Mux View could not start listening thread", e);
- MessageDialog.openError(parent.getShell(), "Error", "Mux View could not initialize. See Error Log for details");
- return;
- }
- thread.start();
-
- task = new PeriodicDisplayTask(Display.getDefault(), 333) {
- @Override
- protected void update() {
- try {
- msgViewer1.refresh();
- dataViewer1.refresh();
- msgViewer2.refresh();
- dataViewer2.refresh();
- msgViewer3.refresh();
- dataViewer3.refresh();
- msgViewer5.refresh();
- dataViewer5.refresh();
- } catch (Throwable t) {
- OseeLog.log(MuxToolPlugin.class, Level.SEVERE, "problems refreshing viewer", t);
- stop();
- }
- }
- };
- task.start();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.osee.ote.ui.mux.muxView");
- MuxToolPlugin.getDefault().getOteClientService().addConnectionListener(this);
- }
-
- /**
- * Create the Mux Message Tree
- */
- private void createMsgTable(TableViewer parent) {
- final Table table = parent.getTable();
- GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
- int height = table.getItemHeight() * 20;
- Rectangle trim = table.computeTrim(0, 0, 0, height);
- gridData.heightHint = trim.height;
- table.setLayoutData(gridData);
- table.setHeaderVisible(true);
- TableColumn column = new TableColumn(table, SWT.CENTER, 0);
- column.setText("Message");
- column.setWidth(70);
- column = new TableColumn(table, SWT.CENTER, 1);
- column.setText("RT-RT");
- column.setWidth(60);
- column = new TableColumn(table, SWT.CENTER, 2);
- column.setText("Word Cnt");
- column.setWidth(70);
- column = new TableColumn(table, SWT.CENTER, 3);
- column.setText("StatusWd");
- column.setWidth(70);
- column = new TableColumn(table, SWT.CENTER, 4);
- column.setText("Emulation");
- column.setWidth(70);
- column = new TableColumn(table, SWT.CENTER, 5);
- column.setText("Bus");
- column.setWidth(50);
- column = new TableColumn(table, SWT.CENTER, 6);
- column.setText("Activity");
- column.setWidth(60);
- column = new TableColumn(table, SWT.CENTER, 7);
- column.setText("Error Cnt");
- column.setWidth(70);
- column = new TableColumn(table, SWT.CENTER, 8);
- column.setText("Error Type");
- column.setWidth(150);
-
- table.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseDown(final MouseEvent event) {
- if (event.button == 3) {
- Menu menu = new Menu(table.getShell(), SWT.POP_UP);
- MenuItem enableBoth = new MenuItem(menu, SWT.PUSH);
- enableBoth.setText("Emulate RT (Pri + Sec)");
- enableBoth.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (muxProbe != null) {
- byte[] cmd = new byte[4];
- cmd[0] = 'R'; // RT simulation cmd
- cmd[1] = (byte) selectedChannel;
- cmd[2] = (byte) selectedRt;
- cmd[3] = (byte) 3;
- try {
- muxProbe.command(cmd);
- } catch (RemoteException ex) {
- OseeLog.log(MuxToolPlugin.class, Level.WARNING,
- "MuxView unable to send RT simulation command");
- }
- }
- }
- });
- MenuItem enableA = new MenuItem(menu, SWT.PUSH);
- enableA.setText("Emulate RT (Pri Only)");
- enableA.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (muxProbe != null) {
- byte[] cmd = new byte[4];
- cmd[0] = 'R'; // RT simulation cmd
- cmd[1] = (byte) selectedChannel;
- cmd[2] = (byte) selectedRt;
- cmd[3] = (byte) 1;
- try {
- muxProbe.command(cmd);
- } catch (RemoteException ex) {
- OseeLog.log(MuxToolPlugin.class, Level.WARNING,
- "MuxView unable to send RT simulation command");
- }
- }
- }
- });
- MenuItem enableB = new MenuItem(menu, SWT.PUSH);
- enableB.setText("Emulate RT (Sec only)");
- enableB.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (muxProbe != null) {
- byte[] cmd = new byte[4];
- cmd[0] = 'R'; // RT simulation cmd
- cmd[1] = (byte) selectedChannel;
- cmd[2] = (byte) selectedRt;
- cmd[3] = (byte) 2;
- try {
- muxProbe.command(cmd);
- } catch (RemoteException ex) {
- OseeLog.log(MuxToolPlugin.class, Level.WARNING,
- "MuxView unable to send RT simulation command");
- }
- }
- }
- });
- new MenuItem(menu, SWT.SEPARATOR);
- MenuItem disableBoth = new MenuItem(menu, SWT.PUSH);
- disableBoth.setText("Monitor RT (Pri + Sec)");
- disableBoth.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (muxProbe != null) {
- byte[] cmd = new byte[4];
- cmd[0] = 'R'; // RT simulation cmd
- cmd[1] = (byte) selectedChannel;
- cmd[2] = (byte) selectedRt;
- cmd[3] = (byte) 0;
- try {
- muxProbe.command(cmd);
- } catch (RemoteException ex) {
- OseeLog.log(MuxToolPlugin.class, Level.WARNING,
- "MuxView unable to send RT simulation command");
- }
- }
- }
- });
-
- // draws pop up menu:
- Point pt = new Point(event.x, event.y);
- pt = table.toDisplay(pt);
- menu.setLocation(pt.x, pt.y);
- menu.setVisible(true);
- }
- }
- });
-
- }
-
- /**
- * Create the Datawords Tree
- */
- private void createDwordTable(final TableViewer parent) {
- final Table table = parent.getTable();
- GridData gridData = new GridData();
- int height = table.getItemHeight() * 2;
- Rectangle trim = table.computeTrim(0, 0, 0, height);
- gridData.heightHint = trim.height;
- table.setLayoutData(gridData);
- table.setHeaderVisible(false);
- table.setLinesVisible(true);
-
- TableColumn column = new TableColumn(table, SWT.CENTER, 0);
- column.setWidth(50);
- column = new TableColumn(table, SWT.CENTER, 1);
- column.setWidth(50);
- column = new TableColumn(table, SWT.CENTER, 2);
- column.setWidth(50);
- column = new TableColumn(table, SWT.CENTER, 3);
- column.setWidth(50);
- column = new TableColumn(table, SWT.CENTER, 4);
- column.setWidth(50);
- column = new TableColumn(table, SWT.CENTER, 5);
- column.setWidth(50);
- column = new TableColumn(table, SWT.CENTER, 6);
- column.setWidth(50);
- column = new TableColumn(table, SWT.CENTER, 7);
- column.setWidth(50);
-
- table.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
-
- final TableCursor cursor = new TableCursor(table, SWT.NONE);
- final ControlEditor editor = new ControlEditor(cursor);
- editor.grabHorizontal = true;
- editor.grabVertical = true;
-
- cursor.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- final Text text = new Text(cursor, SWT.NONE);
- text.setTextLimit(4);
- TableItem row = cursor.getRow();
- int column = cursor.getColumn();
- text.setText(row.getText(column));
- text.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- // close the text editor and copy the data over
- // when the user hits "ENTER"
- if (e.character == SWT.CR) {
- TableItem row = cursor.getRow();
- int column = cursor.getColumn();
- int newVal = Integer.parseInt(text.getText(), 16);
- row.setText(column, text.getText());
- text.dispose();
- cursor.dispose();
- if (muxProbe != null) {
- byte[] cmd = new byte[100];
- int index = 0;
- cmd[index++] = 'S'; // set 1553 data cmd
- cmd[index++] = (byte) selectedChannel;
- cmd[index++] = (byte) selectedRt;
- cmd[index++] = (byte) selectedTR;
- cmd[index++] = (byte) selectedSubaddr;
- Object[] o = ((DatawordModel) parent.getInput()).getChildren();
- ((RowNode) o[table.indexOf(row)]).setDataword(newVal, column);
- for (Object r : o) {
- for (int i = 0; i < 16; i++) {
- cmd[index++] = ((RowNode) r).getDatabyte(i);
- }
- }
- try {
- muxProbe.command(cmd);
- } catch (RemoteException ex) {
- OseeLog.log(MuxToolPlugin.class, Level.WARNING,
- "MuxView unable to send RT simulation command");
- }
- }
- }
- // close the text editor when the user hits
- // "ESC"
- if (e.character == SWT.ESC) {
- text.dispose();
- cursor.dispose();
- }
- // allow only hexadecimal characters, backspace,
- // delete,
- // left and right arrow keys
- if (e.character >= 0x30 && e.character <= 0x39 || e.character >= 0x41 && e.character <= 0x46 || e.character >= 0x61 && e.character <= 0x66 || e.character == SWT.BS || e.character == SWT.DEL || e.keyCode == SWT.ARROW_LEFT || e.keyCode == SWT.ARROW_RIGHT) {
- e.doit = true;
- } else {
- e.doit = false;
- }
- }
- });
- // close the text editor when the user clicks away
- text.addFocusListener(new FocusAdapter() {
- @Override
- public void focusLost(FocusEvent e) {
- text.dispose();
- cursor.dispose();
- }
- });
- editor.setEditor(text);
- text.setFocus();
- }
- });
- table.deselectAll();
- }
- });
- }
-
- /**
- * Passing the focus request to the viewer's control.
- */
- @Override
- public void setFocus() {
- // msgViewer1.getControl().setFocus();
- }
-
- @Override
- public void dispose() {
- MuxToolPlugin.getDefault().getOteClientService().removeConnectionListener(this);
- ITestEnvironment env = MuxToolPlugin.getDefault().getOteClientService().getConnectedEnvironment();
- if (env != null) {
- try {
- ((ITestEnvironmentMessageSystem) env).removeInstrumentationRegistrationListener(exportedThis);
- } catch (RemoteException ex) {
- OseeLog.log(MuxView.class, Level.WARNING, "could not deregister instrumentation registration listener", ex);
- }
- IServiceConnector connector = MuxToolPlugin.getDefault().getOteClientService().getConnector();
- try {
- connector.unexport(this);
- } catch (Exception ex) {
- OseeLog.log(MuxView.class, Level.WARNING, "could not unexport this", ex);
- }
- }
- if (muxProbe != null) {
- try {
- muxProbe.unregister(thread.address);
- } catch (RemoteException ex) {
- OseeLog.log(MuxView.class, Level.WARNING, "could not disconnect from mux probe", ex);
- }
- muxProbe = null;
- }
- if (task != null) {
- task.stop();
- }
- thread.shutdown();
-
- super.dispose();
- }
-
- class ListenerThread extends Thread {
- private volatile boolean done = false;
- private final DatagramChannel channel;
- private final InetSocketAddress address;
-
- public ListenerThread() throws IOException {
- super("Mux View Listener Thread");
- channel = DatagramChannel.open();
- port = PortUtil.getInstance().getValidPort();
- address = new InetSocketAddress(InetAddress.getLocalHost(), port);
- channel.socket().bind(address);
- OseeLog.log(MuxToolPlugin.class, Level.INFO,
- "MuxView connection - host: " + address.getHostName() + " port: " + address.getPort());
- }
-
- @Override
- public void run() {
- final ByteBuffer buffer = ByteBuffer.wrap(new byte[256]);
- try {
- while (!done) {
- buffer.clear();
- channel.receive(buffer);
- buffer.flip();
- switch (buffer.array()[0]) {
- case 1:
- chan1Msgs.onDataAvailable(buffer);
- chan1Dwrds.onDataAvailable(buffer);
- break;
- case 2:
- chan2Msgs.onDataAvailable(buffer);
- chan2Dwrds.onDataAvailable(buffer);
- break;
- case 3:
- chan3Msgs.onDataAvailable(buffer);
- chan3Dwrds.onDataAvailable(buffer);
- break;
- case 5:
- chan5Msgs.onDataAvailable(buffer);
- chan5Dwrds.onDataAvailable(buffer);
- }
- }
- } catch (InterruptedIOException e) {
- Thread.currentThread().interrupt();
- } catch (IOException e) {
- if (!isInterrupted()) {
- OseeLog.log(MuxToolPlugin.class, Level.SEVERE, "Interrupted", e);
- }
- } finally {
- try {
- channel.close();
- } catch (IOException e) {
- // do nothing
- }
- }
- }
-
- public void shutdown() {
- done = true;
- interrupt();
- try {
- thread.join(5000);
- assert !channel.isOpen();
- } catch (InterruptedException e) {
- OseeLog.log(MuxView.class, Level.SEVERE, "could not join wiht listener thread", e);
- }
- }
- }
-
- @Override
- public void onConnectionLost(IServiceConnector connector) {
- handleConnectionLostStatus();
- }
-
- @Override
- public void onPostConnect(final ConnectionEvent event) {
- final ITestEnvironmentMessageSystem environment = (ITestEnvironmentMessageSystem) event.getEnvironment();
- if (environment != null) {
- // we are connected
- try {
- exportedThis = (IInstrumentationRegistrationListener) event.getConnector().findExport(MuxView.this);
- if (exportedThis == null) {
- exportedThis = (IInstrumentationRegistrationListener) event.getConnector().export(MuxView.this);
- }
- environment.addInstrumentationRegistrationListener(exportedThis);
- } catch (Exception ex) {
- OseeLog.log(MuxView.class, Level.SEVERE, "could not register for instrumentation events", ex);
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Connect Error",
- "Could not register for instrumentation events. See Error Log for details");
- }
-
- });
-
- }
- }
-
- }
-
- private void detach() {
-
- }
-
- @Override
- public void onPreDisconnect(ConnectionEvent event) {
- final ITestEnvironmentMessageSystem environment = (ITestEnvironmentMessageSystem) event.getEnvironment();
- try {
- environment.removeInstrumentationRegistrationListener(exportedThis);
- } catch (RemoteException ex1) {
- OseeLog.log(MuxToolPlugin.class, Level.SEVERE, "Problem unregistering instrumentation registration listener",
- ex1);
- }
-
- if (muxProbe != null) {
- try {
- muxProbe.unregister(thread.address);
- } catch (RemoteException ex) {
- OseeLog.log(MuxToolPlugin.class, Level.SEVERE, "Problem unregistering socket address", ex);
- } finally {
- muxProbe = null;
- }
- }
- handleConnectionLostStatus();
- }
-
- private void handleConnectionLostStatus() {
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- updateColors(false);
- // we are not connected
- if (task != null) {
- task.stop();
- }
- }
- });
- }
-
- private void updateColors(boolean connected) {
- msgViewer1.getTable().setBackground(connected ? WHITE : GRAY);
- msgViewer2.getTable().setBackground(connected ? WHITE : GRAY);
- msgViewer3.getTable().setBackground(connected ? WHITE : GRAY);
- msgViewer5.getTable().setBackground(connected ? WHITE : GRAY);
- dataViewer1.getTable().setBackground(connected ? WHITE : GRAY);
- dataViewer2.getTable().setBackground(connected ? WHITE : GRAY);
- dataViewer3.getTable().setBackground(connected ? WHITE : GRAY);
- dataViewer5.getTable().setBackground(connected ? WHITE : GRAY);
- }
-
- @Override
- public void onDeregistered(String name) throws RemoteException {
- if (muxProbe != null && name.equals("MUXIO")) {
- muxProbe = null;
- handleConnectionLostStatus();
- }
- }
-
- @Override
- public void onRegistered(String name, IOInstrumentation instrumentation) throws RemoteException {
- try {
- if (muxProbe == null && name.equals("MUXIO")) {
- muxProbe = instrumentation;
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- if (task != null) {
- task.start();
- }
- updateColors(true);
- }
-
- });
- muxProbe.register(thread.address);
-
- }
- } catch (RemoteException ex) {
- OseeLog.log(MuxToolPlugin.class, Level.SEVERE,
- "Problem registering socket address with remote instrumentation service", ex);
- }
-
- }
+ private TableViewer msgViewer1, msgViewer2, msgViewer3, msgViewer5;
+ private TableViewer dataViewer1, dataViewer2, dataViewer3, dataViewer5;
+ private MessageModel chan1Msgs, chan2Msgs, chan3Msgs, chan5Msgs;
+ private DatawordModel chan1Dwrds, chan2Dwrds, chan3Dwrds, chan5Dwrds;
+ private IOInstrumentation muxProbe;
+ private PeriodicDisplayTask task;
+ private ListenerThread thread;
+ private int port;
+ private int selectedChannel;
+ private int selectedRt;
+ private int selectedTR;
+ private int selectedSubaddr;
+ private final static Color GRAY = Displays.getSystemColor(SWT.COLOR_GRAY);
+ private final static Color WHITE = Displays.getSystemColor(SWT.COLOR_WHITE);
+
+ private IInstrumentationRegistrationListener exportedThis;
+
+ public static final String VIEW_ID = "osee.test.muxTool.views.MuxView";
+ class NameSorter extends ViewerSorter {
+ }
+
+ /**
+ * The constructor.
+ */
+ public MuxView() {
+ super();
+ }
+
+ /**
+ * This is a callback that will allow us to create the viewers and initialize them.
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ final TabFolder tabFolder = new TabFolder(parent, SWT.WRAP);
+ tabFolder.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ switch (tabFolder.getSelectionIndex()) {
+ case 0:
+ selectedChannel = 1;
+ break;
+ case 1:
+ selectedChannel = 2;
+ break;
+ case 2:
+ selectedChannel = 3;
+ break;
+ case 3:
+ selectedChannel = 5;
+ break;
+ default:
+ selectedChannel = 1;
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ // Setup Channel 1 display
+ TabItem chan1Tab = new TabItem(tabFolder, SWT.NONE);
+ chan1Tab.setText("Channel 1");
+ Composite chan1TabComp = new Composite(tabFolder, SWT.NONE);
+ chan1Tab.setControl(chan1TabComp);
+ GridLayout chan1Layout = new GridLayout(1, false);
+ chan1TabComp.setLayout(chan1Layout);
+
+ msgViewer1 = new TableViewer(chan1TabComp, SWT.BORDER | SWT.FULL_SELECTION);
+ msgViewer1.setLabelProvider(new MuxMsgLabelProvider());
+ msgViewer1.setSorter(new NameSorter());
+ msgViewer1.setContentProvider(new MuxMsgContentProvider());
+
+ createMsgTable(msgViewer1);
+
+ Composite bottom1 = new Composite(chan1TabComp, SWT.NONE);
+ bottom1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ bottom1.setLayout(new GridLayout(2, false));
+
+ Composite data1 = new Composite(bottom1, SWT.NONE);
+ RowLayout dataLayout1 = new RowLayout(SWT.HORIZONTAL);
+ data1.setLayout(dataLayout1);
+
+ Composite labels1 = new Composite(data1, SWT.NONE);
+ RowLayout labelLayout1 = new RowLayout(SWT.VERTICAL);
+ labelLayout1.marginTop = 5;
+ labelLayout1.spacing = 1;
+ labels1.setLayout(labelLayout1);
+ Label label1_1 = new Label(labels1, SWT.NONE);
+ label1_1.setText("Datawords 1-8");
+ Label label2_1 = new Label(labels1, SWT.NONE);
+ label2_1.setText("Datawords 9-16");
+ Label label3_1 = new Label(labels1, SWT.NONE);
+ label3_1.setText("Datawords 17-24");
+ Label label4_1 = new Label(labels1, SWT.NONE);
+ label4_1.setText("Datawords 25-32");
+
+ Composite datawords1 = new Composite(data1, SWT.NONE);
+ datawords1.setLayout(new GridLayout(1, false));
+ dataViewer1 = new TableViewer(datawords1, SWT.BORDER | SWT.FULL_SELECTION);
+ dataViewer1.setContentProvider(new DatawordContentProvider());
+ dataViewer1.setLabelProvider(new DatawordLabelProvider());
+ createDwordTable(dataViewer1);
+ msgViewer1.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ MessageNode node = (MessageNode) selection.getFirstElement();
+ if (node != null) {
+ selectedRt = node.getRt();
+ selectedTR = node.getTransmitReceive();
+ selectedSubaddr = node.getSubaddress();
+ chan1Dwrds.setCurrentNode(node.getName());
+ }
+ }
+ });
+ final Button reset1 = new Button(bottom1, SWT.PUSH);
+ reset1.setText("Reset Display");
+ reset1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL));
+ reset1.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ selectedRt = 0;
+ selectedTR = 0;
+ selectedSubaddr = 0;
+ chan1Msgs.removeMessages();
+ chan1Dwrds.setCurrentNode(null);
+ }
+ });
+
+ // Setup Channel 2 display
+ TabItem chan2Tab = new TabItem(tabFolder, SWT.NONE);
+ chan2Tab.setText("Channel 2");
+ Composite chan2TabComp = new Composite(tabFolder, SWT.NONE);
+ chan2Tab.setControl(chan2TabComp);
+ GridLayout chan2Layout = new GridLayout(1, false);
+ chan2TabComp.setLayout(chan2Layout);
+ msgViewer2 = new TableViewer(chan2TabComp, SWT.BORDER | SWT.FULL_SELECTION);
+ msgViewer2.setContentProvider(new MuxMsgContentProvider());
+ msgViewer2.setLabelProvider(new MuxMsgLabelProvider());
+ msgViewer2.setSorter(new NameSorter());
+ createMsgTable(msgViewer2);
+ Composite bottom2 = new Composite(chan2TabComp, SWT.NONE);
+ bottom2.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ bottom2.setLayout(new GridLayout(2, false));
+
+ Composite data2 = new Composite(bottom2, SWT.NONE);
+ RowLayout dataLayout2 = new RowLayout(SWT.HORIZONTAL);
+ data2.setLayout(dataLayout2);
+
+ Composite labels2 = new Composite(data2, SWT.NONE);
+ RowLayout lableLayout2 = new RowLayout(SWT.VERTICAL);
+ lableLayout2.marginTop = 5;
+ lableLayout2.spacing = 1;
+ labels2.setLayout(lableLayout2);
+ Label label1_2 = new Label(labels2, SWT.NONE);
+ label1_2.setText("Datawords 1-8");
+ Label label2_2 = new Label(labels2, SWT.NONE);
+ label2_2.setText("Datawords 9-16");
+ Label label3_2 = new Label(labels2, SWT.NONE);
+ label3_2.setText("Datawords 17-24");
+ Label label4_2 = new Label(labels2, SWT.NONE);
+ label4_2.setText("Datawords 25-32");
+
+ Composite datawords2 = new Composite(data2, SWT.NONE);
+ datawords2.setLayout(new GridLayout(1, false));
+ dataViewer2 = new TableViewer(datawords2, SWT.BORDER | SWT.FULL_SELECTION);
+ dataViewer2.setContentProvider(new DatawordContentProvider());
+ dataViewer2.setLabelProvider(new DatawordLabelProvider());
+ createDwordTable(dataViewer2);
+ msgViewer2.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ MessageNode node = (MessageNode) selection.getFirstElement();
+ if (node != null) {
+ selectedRt = node.getRt();
+ selectedTR = node.getTransmitReceive();
+ selectedSubaddr = node.getSubaddress();
+ chan2Dwrds.setCurrentNode(node.getName());
+ }
+ }
+ });
+ final Button reset2 = new Button(bottom2, SWT.PUSH);
+ reset2.setText("Reset Display");
+ reset2.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL));
+ reset2.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ selectedRt = 0;
+ selectedTR = 0;
+ selectedSubaddr = 0;
+ chan2Msgs.removeMessages();
+ chan2Dwrds.setCurrentNode(null);
+ }
+ });
+
+ // Setup Channel 3 display
+ TabItem chan3Tab = new TabItem(tabFolder, SWT.NONE);
+ chan3Tab.setText("Channel 3");
+ Composite chan3TabComp = new Composite(tabFolder, SWT.NONE);
+ chan3Tab.setControl(chan3TabComp);
+ GridLayout chan3Layout = new GridLayout(1, false);
+ chan3TabComp.setLayout(chan3Layout);
+ msgViewer3 = new TableViewer(chan3TabComp, SWT.BORDER | SWT.FULL_SELECTION);
+ msgViewer3.setContentProvider(new MuxMsgContentProvider());
+ msgViewer3.setLabelProvider(new MuxMsgLabelProvider());
+ msgViewer3.setSorter(new NameSorter());
+ createMsgTable(msgViewer3);
+ Composite bottom3 = new Composite(chan3TabComp, SWT.NONE);
+ bottom3.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ bottom3.setLayout(new GridLayout(2, false));
+
+ Composite data3 = new Composite(bottom3, SWT.NONE);
+ RowLayout dataLayout3 = new RowLayout(SWT.HORIZONTAL);
+ data3.setLayout(dataLayout3);
+
+ Composite labels3 = new Composite(data3, SWT.NONE);
+ RowLayout lableLayout3 = new RowLayout(SWT.VERTICAL);
+ lableLayout3.marginTop = 5;
+ lableLayout3.spacing = 1;
+ labels3.setLayout(lableLayout3);
+ Label label1_3 = new Label(labels3, SWT.NONE);
+ label1_3.setText("Datawords 1-8");
+ Label label2_3 = new Label(labels3, SWT.NONE);
+ label2_3.setText("Datawords 9-16");
+ Label label3_3 = new Label(labels3, SWT.NONE);
+ label3_3.setText("Datawords 17-24");
+ Label label4_3 = new Label(labels3, SWT.NONE);
+ label4_3.setText("Datawords 25-32");
+
+ Composite datawords3 = new Composite(data3, SWT.NONE);
+ datawords3.setLayout(new GridLayout(1, false));
+ dataViewer3 = new TableViewer(datawords3, SWT.BORDER | SWT.FULL_SELECTION);
+ dataViewer3.setContentProvider(new DatawordContentProvider());
+ dataViewer3.setLabelProvider(new DatawordLabelProvider());
+ createDwordTable(dataViewer3);
+ msgViewer3.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ MessageNode node = (MessageNode) selection.getFirstElement();
+ if (node != null) {
+ selectedRt = node.getRt();
+ selectedTR = node.getTransmitReceive();
+ selectedSubaddr = node.getSubaddress();
+ chan3Dwrds.setCurrentNode(node.getName());
+ }
+ }
+ });
+ final Button reset3 = new Button(bottom3, SWT.PUSH);
+ reset3.setText("Reset Display");
+ reset3.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL));
+ reset3.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ selectedRt = 0;
+ selectedTR = 0;
+ selectedSubaddr = 0;
+ chan3Msgs.removeMessages();
+ chan3Dwrds.setCurrentNode(null);
+ }
+ });
+
+ // Setup Channel 5 display
+ TabItem chan5Tab = new TabItem(tabFolder, SWT.NONE);
+ chan5Tab.setText("Channel 5");
+ Composite chan5TabComp = new Composite(tabFolder, SWT.NONE);
+ chan5Tab.setControl(chan5TabComp);
+ GridLayout chan5Layout = new GridLayout(1, false);
+ chan5TabComp.setLayout(chan5Layout);
+ msgViewer5 = new TableViewer(chan5TabComp, SWT.BORDER | SWT.FULL_SELECTION);
+ msgViewer5.setContentProvider(new MuxMsgContentProvider());
+ msgViewer5.setLabelProvider(new MuxMsgLabelProvider());
+ msgViewer5.setSorter(new NameSorter());
+ createMsgTable(msgViewer5);
+ Composite bottom5 = new Composite(chan5TabComp, SWT.NONE);
+ bottom5.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ bottom5.setLayout(new GridLayout(2, false));
+
+ Composite data5 = new Composite(bottom5, SWT.NONE);
+ RowLayout dataLayout5 = new RowLayout(SWT.HORIZONTAL);
+ data5.setLayout(dataLayout5);
+
+ Composite labels5 = new Composite(data5, SWT.NONE);
+ RowLayout lableLayout5 = new RowLayout(SWT.VERTICAL);
+ lableLayout5.marginTop = 5;
+ lableLayout5.spacing = 1;
+ labels5.setLayout(lableLayout5);
+ Label label1_5 = new Label(labels5, SWT.NONE);
+ label1_5.setText("Datawords 1-8");
+ Label label2_5 = new Label(labels5, SWT.NONE);
+ label2_5.setText("Datawords 9-16");
+ Label label3_5 = new Label(labels5, SWT.NONE);
+ label3_5.setText("Datawords 17-24");
+ Label label4_5 = new Label(labels5, SWT.NONE);
+ label4_5.setText("Datawords 25-32");
+
+ Composite datawords5 = new Composite(data5, SWT.NONE);
+ datawords5.setLayout(new GridLayout(1, false));
+ dataViewer5 = new TableViewer(datawords5, SWT.BORDER | SWT.FULL_SELECTION);
+ dataViewer5.setContentProvider(new DatawordContentProvider());
+ dataViewer5.setLabelProvider(new DatawordLabelProvider());
+ createDwordTable(dataViewer5);
+ msgViewer5.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ MessageNode node = (MessageNode) selection.getFirstElement();
+ if (node != null) {
+ selectedRt = node.getRt();
+ selectedTR = node.getTransmitReceive();
+ selectedSubaddr = node.getSubaddress();
+ chan5Dwrds.setCurrentNode(node.getName());
+ }
+ }
+ });
+ final Button reset5 = new Button(bottom5, SWT.PUSH);
+ reset5.setText("Reset Display");
+ reset5.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.GRAB_HORIZONTAL));
+ reset5.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ selectedRt = 0;
+ selectedTR = 0;
+ selectedSubaddr = 0;
+ chan5Msgs.removeMessages();
+ chan5Dwrds.setCurrentNode(null);
+ }
+ });
+ msgViewer1.setInput(chan1Msgs = new MessageModel());
+ dataViewer1.setInput(chan1Dwrds = new DatawordModel());
+ msgViewer2.setInput(chan2Msgs = new MessageModel());
+ dataViewer2.setInput(chan2Dwrds = new DatawordModel());
+ msgViewer3.setInput(chan3Msgs = new MessageModel());
+ dataViewer3.setInput(chan3Dwrds = new DatawordModel());
+ msgViewer5.setInput(chan5Msgs = new MessageModel());
+ dataViewer5.setInput(chan5Dwrds = new DatawordModel());
+ updateColors(false);
+ try {
+ thread = new ListenerThread();
+ } catch (Exception e) {
+ OseeLog.log(MuxView.class, Level.SEVERE, "Mux View could not start listening thread", e);
+ MessageDialog.openError(parent.getShell(), "Error", "Mux View could not initialize. See Error Log for details");
+ return;
+ }
+ thread.start();
+
+ task = new PeriodicDisplayTask(Display.getDefault(), 333) {
+ @Override
+ protected void update() {
+ try {
+ msgViewer1.refresh();
+ dataViewer1.refresh();
+ msgViewer2.refresh();
+ dataViewer2.refresh();
+ msgViewer3.refresh();
+ dataViewer3.refresh();
+ msgViewer5.refresh();
+ dataViewer5.refresh();
+ } catch (Throwable t) {
+ OseeLog.log(MuxToolPlugin.class, Level.SEVERE, "problems refreshing viewer", t);
+ stop();
+ }
+ }
+ };
+ task.start();
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.osee.ote.ui.mux.muxView");
+ MuxToolPlugin.getDefault().getOteClientService().addConnectionListener(this);
+ }
+
+ /**
+ * Create the Mux Message Tree
+ */
+ private void createMsgTable(TableViewer parent) {
+ final Table table = parent.getTable();
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
+ int height = table.getItemHeight() * 20;
+ Rectangle trim = table.computeTrim(0, 0, 0, height);
+ gridData.heightHint = trim.height;
+ table.setLayoutData(gridData);
+ table.setHeaderVisible(true);
+ TableColumn column = new TableColumn(table, SWT.CENTER, 0);
+ column.setText("Message");
+ column.setWidth(70);
+ column = new TableColumn(table, SWT.CENTER, 1);
+ column.setText("RT-RT");
+ column.setWidth(60);
+ column = new TableColumn(table, SWT.CENTER, 2);
+ column.setText("Word Cnt");
+ column.setWidth(70);
+ column = new TableColumn(table, SWT.CENTER, 3);
+ column.setText("StatusWd");
+ column.setWidth(70);
+ column = new TableColumn(table, SWT.CENTER, 4);
+ column.setText("Emulation");
+ column.setWidth(70);
+ column = new TableColumn(table, SWT.CENTER, 5);
+ column.setText("Bus");
+ column.setWidth(50);
+ column = new TableColumn(table, SWT.CENTER, 6);
+ column.setText("Activity");
+ column.setWidth(60);
+ column = new TableColumn(table, SWT.CENTER, 7);
+ column.setText("Error Cnt");
+ column.setWidth(70);
+ column = new TableColumn(table, SWT.CENTER, 8);
+ column.setText("Error Type");
+ column.setWidth(150);
+
+ table.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(final MouseEvent event) {
+ if (event.button == 3) {
+ Menu menu = new Menu(table.getShell(), SWT.POP_UP);
+ MenuItem enableBoth = new MenuItem(menu, SWT.PUSH);
+ enableBoth.setText("Emulate RT (Pri + Sec)");
+ enableBoth.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (muxProbe != null) {
+ byte[] cmd = new byte[4];
+ cmd[0] = 'R'; // RT simulation cmd
+ cmd[1] = (byte) selectedChannel;
+ cmd[2] = (byte) selectedRt;
+ cmd[3] = (byte) 3;
+ try {
+ muxProbe.command(cmd);
+ } catch (RemoteException ex) {
+ OseeLog.log(MuxToolPlugin.class, Level.WARNING,
+ "MuxView unable to send RT simulation command");
+ }
+ }
+ }
+ });
+ MenuItem enableA = new MenuItem(menu, SWT.PUSH);
+ enableA.setText("Emulate RT (Pri Only)");
+ enableA.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (muxProbe != null) {
+ byte[] cmd = new byte[4];
+ cmd[0] = 'R'; // RT simulation cmd
+ cmd[1] = (byte) selectedChannel;
+ cmd[2] = (byte) selectedRt;
+ cmd[3] = (byte) 1;
+ try {
+ muxProbe.command(cmd);
+ } catch (RemoteException ex) {
+ OseeLog.log(MuxToolPlugin.class, Level.WARNING,
+ "MuxView unable to send RT simulation command");
+ }
+ }
+ }
+ });
+ MenuItem enableB = new MenuItem(menu, SWT.PUSH);
+ enableB.setText("Emulate RT (Sec only)");
+ enableB.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (muxProbe != null) {
+ byte[] cmd = new byte[4];
+ cmd[0] = 'R'; // RT simulation cmd
+ cmd[1] = (byte) selectedChannel;
+ cmd[2] = (byte) selectedRt;
+ cmd[3] = (byte) 2;
+ try {
+ muxProbe.command(cmd);
+ } catch (RemoteException ex) {
+ OseeLog.log(MuxToolPlugin.class, Level.WARNING,
+ "MuxView unable to send RT simulation command");
+ }
+ }
+ }
+ });
+ new MenuItem(menu, SWT.SEPARATOR);
+ MenuItem disableBoth = new MenuItem(menu, SWT.PUSH);
+ disableBoth.setText("Monitor RT (Pri + Sec)");
+ disableBoth.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (muxProbe != null) {
+ byte[] cmd = new byte[4];
+ cmd[0] = 'R'; // RT simulation cmd
+ cmd[1] = (byte) selectedChannel;
+ cmd[2] = (byte) selectedRt;
+ cmd[3] = (byte) 0;
+ try {
+ muxProbe.command(cmd);
+ } catch (RemoteException ex) {
+ OseeLog.log(MuxToolPlugin.class, Level.WARNING,
+ "MuxView unable to send RT simulation command");
+ }
+ }
+ }
+ });
+
+ // draws pop up menu:
+ Point pt = new Point(event.x, event.y);
+ pt = table.toDisplay(pt);
+ menu.setLocation(pt.x, pt.y);
+ menu.setVisible(true);
+ }
+ }
+ });
+
+ }
+
+ /**
+ * Create the Datawords Tree
+ */
+ private void createDwordTable(final TableViewer parent) {
+ final Table table = parent.getTable();
+ GridData gridData = new GridData();
+ int height = table.getItemHeight() * 2;
+ Rectangle trim = table.computeTrim(0, 0, 0, height);
+ gridData.heightHint = trim.height;
+ table.setLayoutData(gridData);
+ table.setHeaderVisible(false);
+ table.setLinesVisible(true);
+
+ TableColumn column = new TableColumn(table, SWT.CENTER, 0);
+ column.setWidth(50);
+ column = new TableColumn(table, SWT.CENTER, 1);
+ column.setWidth(50);
+ column = new TableColumn(table, SWT.CENTER, 2);
+ column.setWidth(50);
+ column = new TableColumn(table, SWT.CENTER, 3);
+ column.setWidth(50);
+ column = new TableColumn(table, SWT.CENTER, 4);
+ column.setWidth(50);
+ column = new TableColumn(table, SWT.CENTER, 5);
+ column.setWidth(50);
+ column = new TableColumn(table, SWT.CENTER, 6);
+ column.setWidth(50);
+ column = new TableColumn(table, SWT.CENTER, 7);
+ column.setWidth(50);
+
+ table.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+
+ final TableCursor cursor = new TableCursor(table, SWT.NONE);
+ final ControlEditor editor = new ControlEditor(cursor);
+ editor.grabHorizontal = true;
+ editor.grabVertical = true;
+
+ cursor.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ final Text text = new Text(cursor, SWT.NONE);
+ text.setTextLimit(4);
+ TableItem row = cursor.getRow();
+ int column = cursor.getColumn();
+ text.setText(row.getText(column));
+ text.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ // close the text editor and copy the data over
+ // when the user hits "ENTER"
+ if (e.character == SWT.CR) {
+ TableItem row = cursor.getRow();
+ int column = cursor.getColumn();
+ int newVal = Integer.parseInt(text.getText(), 16);
+ row.setText(column, text.getText());
+ text.dispose();
+ cursor.dispose();
+ if (muxProbe != null) {
+ byte[] cmd = new byte[100];
+ int index = 0;
+ cmd[index++] = 'S'; // set 1553 data cmd
+ cmd[index++] = (byte) selectedChannel;
+ cmd[index++] = (byte) selectedRt;
+ cmd[index++] = (byte) selectedTR;
+ cmd[index++] = (byte) selectedSubaddr;
+ Object[] o = ((DatawordModel) parent.getInput()).getChildren();
+ ((RowNode) o[table.indexOf(row)]).setDataword(newVal, column);
+ for (Object r : o) {
+ for (int i = 0; i < 16; i++) {
+ cmd[index++] = ((RowNode) r).getDatabyte(i);
+ }
+ }
+ try {
+ muxProbe.command(cmd);
+ } catch (RemoteException ex) {
+ OseeLog.log(MuxToolPlugin.class, Level.WARNING,
+ "MuxView unable to send RT simulation command");
+ }
+ }
+ }
+ // close the text editor when the user hits
+ // "ESC"
+ if (e.character == SWT.ESC) {
+ text.dispose();
+ cursor.dispose();
+ }
+ // allow only hexadecimal characters, backspace,
+ // delete,
+ // left and right arrow keys
+ if (e.character >= 0x30 && e.character <= 0x39 || e.character >= 0x41 && e.character <= 0x46 || e.character >= 0x61 && e.character <= 0x66 || e.character == SWT.BS || e.character == SWT.DEL || e.keyCode == SWT.ARROW_LEFT || e.keyCode == SWT.ARROW_RIGHT) {
+ e.doit = true;
+ } else {
+ e.doit = false;
+ }
+ }
+ });
+ // close the text editor when the user clicks away
+ text.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusLost(FocusEvent e) {
+ text.dispose();
+ cursor.dispose();
+ }
+ });
+ editor.setEditor(text);
+ text.setFocus();
+ }
+ });
+ table.deselectAll();
+ }
+ });
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ @Override
+ public void setFocus() {
+ // msgViewer1.getControl().setFocus();
+ }
+
+ @Override
+ public void dispose() {
+ MuxToolPlugin.getDefault().getOteClientService().removeConnectionListener(this);
+ ITestEnvironment env = MuxToolPlugin.getDefault().getOteClientService().getConnectedEnvironment();
+ if (env != null) {
+ try {
+ ((ITestEnvironmentMessageSystem) env).removeInstrumentationRegistrationListener(exportedThis);
+ } catch (RemoteException ex) {
+ OseeLog.log(MuxView.class, Level.WARNING, "could not deregister instrumentation registration listener", ex);
+ }
+ IServiceConnector connector = MuxToolPlugin.getDefault().getOteClientService().getConnector();
+ try {
+ connector.unexport(this);
+ } catch (Exception ex) {
+ OseeLog.log(MuxView.class, Level.WARNING, "could not unexport this", ex);
+ }
+ }
+ if (muxProbe != null) {
+ try {
+ muxProbe.unregister(thread.address);
+ } catch (RemoteException ex) {
+ OseeLog.log(MuxView.class, Level.WARNING, "could not disconnect from mux probe", ex);
+ }
+ muxProbe = null;
+ }
+ if (task != null) {
+ task.stop();
+ }
+ thread.shutdown();
+
+ super.dispose();
+ }
+
+ class ListenerThread extends Thread {
+ private volatile boolean done = false;
+ private final DatagramChannel channel;
+ private final InetSocketAddress address;
+
+ public ListenerThread() throws IOException {
+ super("Mux View Listener Thread");
+ channel = DatagramChannel.open();
+ port = PortUtil.getInstance().getValidPort();
+ address = new InetSocketAddress(InetAddress.getLocalHost(), port);
+ channel.socket().bind(address);
+ OseeLog.log(MuxToolPlugin.class, Level.INFO,
+ "MuxView connection - host: " + address.getHostName() + " port: " + address.getPort());
+ }
+
+ @Override
+ public void run() {
+ final ByteBuffer buffer = ByteBuffer.wrap(new byte[256]);
+ try {
+ while (!done) {
+ buffer.clear();
+ channel.receive(buffer);
+ buffer.flip();
+ switch (buffer.array()[0]) {
+ case 1:
+ chan1Msgs.onDataAvailable(buffer);
+ chan1Dwrds.onDataAvailable(buffer);
+ break;
+ case 2:
+ chan2Msgs.onDataAvailable(buffer);
+ chan2Dwrds.onDataAvailable(buffer);
+ break;
+ case 3:
+ chan3Msgs.onDataAvailable(buffer);
+ chan3Dwrds.onDataAvailable(buffer);
+ break;
+ case 5:
+ chan5Msgs.onDataAvailable(buffer);
+ chan5Dwrds.onDataAvailable(buffer);
+ }
+ }
+ } catch (InterruptedIOException e) {
+ Thread.currentThread().interrupt();
+ } catch (IOException e) {
+ if (!isInterrupted()) {
+ OseeLog.log(MuxToolPlugin.class, Level.SEVERE, "Interrupted", e);
+ }
+ } finally {
+ try {
+ channel.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+ }
+ }
+
+ public void shutdown() {
+ done = true;
+ interrupt();
+ try {
+ thread.join(5000);
+ assert !channel.isOpen();
+ } catch (InterruptedException e) {
+ OseeLog.log(MuxView.class, Level.SEVERE, "could not join wiht listener thread", e);
+ }
+ }
+ }
+
+ @Override
+ public void onConnectionLost(IServiceConnector connector) {
+ handleConnectionLostStatus();
+ }
+
+ @Override
+ public void onPostConnect(final ConnectionEvent event) {
+ final ITestEnvironmentMessageSystem environment = (ITestEnvironmentMessageSystem) event.getEnvironment();
+ if (environment != null) {
+ // we are connected
+ try {
+ exportedThis = (IInstrumentationRegistrationListener) event.getConnector().findExport(MuxView.this);
+ if (exportedThis == null) {
+ exportedThis = (IInstrumentationRegistrationListener) event.getConnector().export(MuxView.this);
+ }
+ environment.addInstrumentationRegistrationListener(exportedThis);
+ } catch (Exception ex) {
+ OseeLog.log(MuxView.class, Level.SEVERE, "could not register for instrumentation events", ex);
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openError(Displays.getActiveShell(), "Connect Error",
+ "Could not register for instrumentation events. See Error Log for details");
+ }
+
+ });
+
+ }
+ }
+
+ }
+
+ private void detach() {
+
+ }
+
+ @Override
+ public void onPreDisconnect(ConnectionEvent event) {
+ final ITestEnvironmentMessageSystem environment = (ITestEnvironmentMessageSystem) event.getEnvironment();
+ try {
+ environment.removeInstrumentationRegistrationListener(exportedThis);
+ } catch (RemoteException ex1) {
+ OseeLog.log(MuxToolPlugin.class, Level.SEVERE, "Problem unregistering instrumentation registration listener",
+ ex1);
+ }
+
+ if (muxProbe != null) {
+ try {
+ muxProbe.unregister(thread.address);
+ } catch (RemoteException ex) {
+ OseeLog.log(MuxToolPlugin.class, Level.SEVERE, "Problem unregistering socket address", ex);
+ } finally {
+ muxProbe = null;
+ }
+ }
+ handleConnectionLostStatus();
+ }
+
+ private void handleConnectionLostStatus() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ updateColors(false);
+ // we are not connected
+ if (task != null) {
+ task.stop();
+ }
+ }
+ });
+ }
+
+ private void updateColors(boolean connected) {
+ msgViewer1.getTable().setBackground(connected ? WHITE : GRAY);
+ msgViewer2.getTable().setBackground(connected ? WHITE : GRAY);
+ msgViewer3.getTable().setBackground(connected ? WHITE : GRAY);
+ msgViewer5.getTable().setBackground(connected ? WHITE : GRAY);
+ dataViewer1.getTable().setBackground(connected ? WHITE : GRAY);
+ dataViewer2.getTable().setBackground(connected ? WHITE : GRAY);
+ dataViewer3.getTable().setBackground(connected ? WHITE : GRAY);
+ dataViewer5.getTable().setBackground(connected ? WHITE : GRAY);
+ }
+
+ @Override
+ public void onDeregistered(String name) throws RemoteException {
+ if (muxProbe != null && name.equals("MUXIO")) {
+ muxProbe = null;
+ handleConnectionLostStatus();
+ }
+ }
+
+ @Override
+ public void onRegistered(String name, IOInstrumentation instrumentation) throws RemoteException {
+ try {
+ if (muxProbe == null && name.equals("MUXIO")) {
+ muxProbe = instrumentation;
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ if (task != null) {
+ task.start();
+ }
+ updateColors(true);
+ }
+
+ });
+ muxProbe.register(thread.address);
+
+ }
+ } catch (RemoteException ex) {
+ OseeLog.log(MuxToolPlugin.class, Level.SEVERE,
+ "Problem registering socket address with remote instrumentation service", ex);
+ }
+
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchDecorator.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchDecorator.java
index a741d8089d4..1dbd56c393f 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchDecorator.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchDecorator.java
@@ -20,51 +20,52 @@ import org.eclipse.jface.viewers.ILightweightLabelDecorator;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.ote.ui.test.manager.OteTestManagerImage;
import org.eclipse.osee.ote.ui.test.manager.batches.util.SelectionUtil;
import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IDecoratorManager;
/**
* @author Roberto E. Escobar
*/
public class TestBatchDecorator extends LabelProvider implements ILightweightLabelDecorator {
- private static final String DECORATOR_ID = "org.eclipse.osee.ote.ui.test.manager.decorator";
- private static final ImageDescriptor IMAGE = ImageManager.getImageDescriptor(OteTestManagerImage.TEST);
+ private static final String DECORATOR_ID = "org.eclipse.osee.ote.ui.test.manager.decorator";
+ private static final ImageDescriptor IMAGE = ImageManager.getImageDescriptor(OteTestManagerImage.TEST);
- public void decorate(Object element, IDecoration decoration) {
- try {
- IProject project = null;
- if (element instanceof IJavaProject) {
- project = ((IJavaProject) element).getProject();
- } else {
- project = (IProject) element;
- }
- if (project.isOpen() && project.hasNature(TestBatchProjectNature.NATURE_ID)) {
- decoration.addOverlay(IMAGE);
- }
- } catch (Exception ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, SelectionUtil.getStatusMessages(ex));
- }
- }
+ public void decorate(Object element, IDecoration decoration) {
+ try {
+ IProject project = null;
+ if (element instanceof IJavaProject) {
+ project = ((IJavaProject) element).getProject();
+ } else {
+ project = (IProject) element;
+ }
+ if (project.isOpen() && project.hasNature(TestBatchProjectNature.NATURE_ID)) {
+ decoration.addOverlay(IMAGE);
+ }
+ } catch (Exception ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, SelectionUtil.getStatusMessages(ex));
+ }
+ }
- private void startDecoratorUpdate(IProject project) {
- final LabelProviderChangedEvent evnt = new LabelProviderChangedEvent(this, project);
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- fireLabelProviderChanged(evnt);
- }
- });
- }
+ private void startDecoratorUpdate(IProject project) {
+ final LabelProviderChangedEvent evnt = new LabelProviderChangedEvent(this, project);
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ fireLabelProviderChanged(evnt);
+ }
+ });
+ }
- public static void performLabelDecoratorUpdate(IProject project) {
- IDecoratorManager decoratorManager = TestManagerPlugin.getInstance().getWorkbench().getDecoratorManager();
- IBaseLabelProvider provider = decoratorManager.getBaseLabelProvider(DECORATOR_ID);
- if (provider != null) {
- TestBatchDecorator decorator = (TestBatchDecorator) provider;
- decorator.startDecoratorUpdate(project);
- }
- }
+ public static void performLabelDecoratorUpdate(IProject project) {
+ IDecoratorManager decoratorManager = TestManagerPlugin.getInstance().getWorkbench().getDecoratorManager();
+ IBaseLabelProvider provider = decoratorManager.getBaseLabelProvider(DECORATOR_ID);
+ if (provider != null) {
+ TestBatchDecorator decorator = (TestBatchDecorator) provider;
+ decorator.startDecoratorUpdate(project);
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchProjectNature.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchProjectNature.java
index 2bffb82bef0..600a4ad4a34 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchProjectNature.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/batches/TestBatchProjectNature.java
@@ -26,210 +26,215 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.ui.test.manager.batches.navigate.TestBatchRegistry;
import org.eclipse.osee.ote.ui.test.manager.batches.navigate.TestBatchSetupViewItems;
import org.eclipse.osee.ote.ui.test.manager.batches.util.ResourceFinder;
import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin;
-import org.eclipse.swt.widgets.Display;
/**
* @author Roberto E. Escobar
*/
public class TestBatchProjectNature implements IProjectNature {
- public static final String NATURE_ID = "org.eclipse.osee.ote.ui.test.manager.TestBatchProjectNature";
- private IProject project;
- private final ResourceFinder resourceFinder;
- private final IResourceChangeListener resourceChangeListener;
- private final IResourceChangeListener projectClosedListener;
- private final IResourceChangeListener projectDeletedListener;
- private final FindResourceWorker worker;
-
- public TestBatchProjectNature() {
- this.resourceFinder = new ResourceFinder();
- this.resourceChangeListener = new TestBatchResourceChangeListener();
- this.projectClosedListener = new TestBatchProjectClosedListener();
- this.projectDeletedListener = new TestBatchProjectDeletedListener();
- this.worker = new FindResourceWorker(this);
- }
-
- @Override
- public void configure() throws CoreException {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
- workspace.addResourceChangeListener(projectClosedListener, IResourceChangeEvent.PRE_CLOSE);
- workspace.addResourceChangeListener(projectDeletedListener, IResourceChangeEvent.PRE_DELETE);
- ResourcesPlugin.getWorkspace().getRoot().getWorkspace().run(worker, new NullProgressMonitor());
- }
-
- @Override
- public void deconfigure() throws CoreException {
- TestBatchRegistry registry = TestBatchSetupViewItems.getInstance().getRegistry();
- for (String key : resourceFinder.getIds()) {
- registry.deregisterTestBatch(key);
- }
- TestBatchDecorator.performLabelDecoratorUpdate(project);
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.removeResourceChangeListener(resourceChangeListener);
- workspace.removeResourceChangeListener(projectClosedListener);
- workspace.removeResourceChangeListener(projectDeletedListener);
- }
-
- @Override
- public IProject getProject() {
- return this.project;
- }
-
- @Override
- public void setProject(IProject project) {
- this.project = project;
- }
-
- public ResourceFinder getResourceFinder() {
- return resourceFinder;
- }
-
- public FindResourceWorker getWorker() {
- return worker;
- }
-
- public static void initializeProjectSet() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (IProject project : projects) {
- try {
- if (project != null && project.isOpen() == true) {
- IProjectNature nature = project.getNature(TestBatchProjectNature.NATURE_ID);
- if (nature != null) {
- nature.configure();
- }
- }
- } catch (CoreException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Error initializing project nature", ex);
- }
- }
- }
- });
- }
-
- private final class TestBatchProjectDeletedListener implements IResourceChangeListener {
-
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- IResource resource = event.getResource();
- if (resource != null) {
- IProject project = resource.getProject();
- if (project != null) {
- final IProjectNature nature = project.getNature(NATURE_ID);
- if (nature != null) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- TestBatchProjectNature batchProjectNature = (TestBatchProjectNature) nature;
- TestBatchRegistry registry = TestBatchSetupViewItems.getInstance().getRegistry();
- for (String key : batchProjectNature.getResourceFinder().getIds()) {
- registry.deregisterTestBatch(key);
- }
- }
- });
- }
- }
- }
- } catch (CoreException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Error during resource change event", ex);
- }
- }
-
- }
-
- private final class TestBatchProjectClosedListener implements IResourceChangeListener {
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- IResource resource = event.getResource();
- if (resource != null) {
- IProject project = resource.getProject();
- if (project != null) {
- final IProjectNature nature = project.getNature(NATURE_ID);
- if (nature != null) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- TestBatchProjectNature tbpNature = (TestBatchProjectNature) nature;
- TestBatchRegistry registry = TestBatchSetupViewItems.getInstance().getRegistry();
- for (String key : tbpNature.getResourceFinder().getIds()) {
- registry.deregisterTestBatch(key);
- }
- }
- });
- }
- }
- }
- } catch (CoreException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Error during resource change event", ex);
- }
- }
- }
-
- private final class TestBatchResourceChangeListener implements IResourceChangeListener {
- @Override
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- IResourceDelta delta = event.getDelta();
- IResourceDelta[] children = delta.getAffectedChildren();
- for (IResourceDelta childDelta : children) {
- IResource resource = childDelta.getResource();
- if (resource != null) {
- IProject project = resource.getProject();
- if (project != null) {
- if (project.isOpen() != false && project.isNatureEnabled(NATURE_ID)) {
- final IProjectNature nature = project.getNature(NATURE_ID);
- if (nature != null) {
- handleProjectFilesChanging((TestBatchProjectNature) nature);
- }
- }
- }
- }
- }
- } catch (CoreException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Error during resource change event", ex);
- }
- }
-
- private void handleProjectFilesChanging(final TestBatchProjectNature nature) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- nature.getWorker().run(new NullProgressMonitor());
- } catch (CoreException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
- }
- }
- });
- }
- };
-
- private final class FindResourceWorker implements IWorkspaceRunnable {
-
- private final TestBatchProjectNature nature;
-
- public FindResourceWorker(TestBatchProjectNature nature) {
- this.nature = nature;
- }
-
- @Override
- public void run(IProgressMonitor monitor) throws CoreException {
- ResourceFinder finder = nature.getResourceFinder();
- finder.findBatchAndProjectFiles(nature.getProject());
- TestBatchRegistry registry = TestBatchSetupViewItems.getInstance().getRegistry();
- for (String key : finder.getIds()) {
- Pair<IFile, IFile> fileSet = finder.getFileSet(key);
- registry.registerTestBatch(key, fileSet.getFirst().getLocationURI(), fileSet.getSecond().getLocationURI());
- }
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- TestBatchDecorator.performLabelDecoratorUpdate(nature.getProject());
- }
- });
- }
- }
+ public static final String NATURE_ID = "org.eclipse.osee.ote.ui.test.manager.TestBatchProjectNature";
+ private IProject project;
+ private final ResourceFinder resourceFinder;
+ private final IResourceChangeListener resourceChangeListener;
+ private final IResourceChangeListener projectClosedListener;
+ private final IResourceChangeListener projectDeletedListener;
+ private final FindResourceWorker worker;
+
+ public TestBatchProjectNature() {
+ this.resourceFinder = new ResourceFinder();
+ this.resourceChangeListener = new TestBatchResourceChangeListener();
+ this.projectClosedListener = new TestBatchProjectClosedListener();
+ this.projectDeletedListener = new TestBatchProjectDeletedListener();
+ this.worker = new FindResourceWorker(this);
+ }
+
+ @Override
+ public void configure() throws CoreException {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ workspace.addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
+ workspace.addResourceChangeListener(projectClosedListener, IResourceChangeEvent.PRE_CLOSE);
+ workspace.addResourceChangeListener(projectDeletedListener, IResourceChangeEvent.PRE_DELETE);
+ ResourcesPlugin.getWorkspace().getRoot().getWorkspace().run(worker, new NullProgressMonitor());
+ }
+
+ @Override
+ public void deconfigure() throws CoreException {
+ TestBatchRegistry registry = TestBatchSetupViewItems.getInstance().getRegistry();
+ for (String key : resourceFinder.getIds()) {
+ registry.deregisterTestBatch(key);
+ }
+ TestBatchDecorator.performLabelDecoratorUpdate(project);
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ workspace.removeResourceChangeListener(resourceChangeListener);
+ workspace.removeResourceChangeListener(projectClosedListener);
+ workspace.removeResourceChangeListener(projectDeletedListener);
+ }
+
+ @Override
+ public IProject getProject() {
+ return this.project;
+ }
+
+ @Override
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+ public ResourceFinder getResourceFinder() {
+ return resourceFinder;
+ }
+
+ public FindResourceWorker getWorker() {
+ return worker;
+ }
+
+ public static void initializeProjectSet() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (IProject project : projects) {
+ try {
+ if (project != null && project.isOpen() == true) {
+ IProjectNature nature = project.getNature(TestBatchProjectNature.NATURE_ID);
+ if (nature != null) {
+ nature.configure();
+ }
+ }
+ } catch (CoreException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Error initializing project nature", ex);
+ }
+ }
+ }
+ });
+ }
+
+ private final class TestBatchProjectDeletedListener implements IResourceChangeListener {
+
+ @Override
+ public void resourceChanged(IResourceChangeEvent event) {
+ try {
+ IResource resource = event.getResource();
+ if (resource != null) {
+ IProject project = resource.getProject();
+ if (project != null) {
+ final IProjectNature nature = project.getNature(NATURE_ID);
+ if (nature != null) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ TestBatchProjectNature batchProjectNature = (TestBatchProjectNature) nature;
+ TestBatchRegistry registry = TestBatchSetupViewItems.getInstance().getRegistry();
+ for (String key : batchProjectNature.getResourceFinder().getIds()) {
+ registry.deregisterTestBatch(key);
+ }
+ }
+ });
+ }
+ }
+ }
+ } catch (CoreException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Error during resource change event", ex);
+ }
+ }
+
+ }
+
+ private final class TestBatchProjectClosedListener implements IResourceChangeListener {
+ @Override
+ public void resourceChanged(IResourceChangeEvent event) {
+ try {
+ IResource resource = event.getResource();
+ if (resource != null) {
+ IProject project = resource.getProject();
+ if (project != null) {
+ final IProjectNature nature = project.getNature(NATURE_ID);
+ if (nature != null) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ TestBatchProjectNature tbpNature = (TestBatchProjectNature) nature;
+ TestBatchRegistry registry = TestBatchSetupViewItems.getInstance().getRegistry();
+ for (String key : tbpNature.getResourceFinder().getIds()) {
+ registry.deregisterTestBatch(key);
+ }
+ }
+ });
+ }
+ }
+ }
+ } catch (CoreException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Error during resource change event", ex);
+ }
+ }
+ }
+
+ private final class TestBatchResourceChangeListener implements IResourceChangeListener {
+ @Override
+ public void resourceChanged(IResourceChangeEvent event) {
+ try {
+ IResourceDelta delta = event.getDelta();
+ IResourceDelta[] children = delta.getAffectedChildren();
+ for (IResourceDelta childDelta : children) {
+ IResource resource = childDelta.getResource();
+ if (resource != null) {
+ IProject project = resource.getProject();
+ if (project != null) {
+ if (project.isOpen() != false && project.isNatureEnabled(NATURE_ID)) {
+ final IProjectNature nature = project.getNature(NATURE_ID);
+ if (nature != null) {
+ handleProjectFilesChanging((TestBatchProjectNature) nature);
+ }
+ }
+ }
+ }
+ }
+ } catch (CoreException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Error during resource change event", ex);
+ }
+ }
+
+ private void handleProjectFilesChanging(final TestBatchProjectNature nature) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ nature.getWorker().run(new NullProgressMonitor());
+ } catch (CoreException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
+ }
+ }
+ });
+ }
+ };
+
+ private final class FindResourceWorker implements IWorkspaceRunnable {
+
+ private final TestBatchProjectNature nature;
+
+ public FindResourceWorker(TestBatchProjectNature nature) {
+ this.nature = nature;
+ }
+
+ @Override
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ResourceFinder finder = nature.getResourceFinder();
+ finder.findBatchAndProjectFiles(nature.getProject());
+ TestBatchRegistry registry = TestBatchSetupViewItems.getInstance().getRegistry();
+ for (String key : finder.getIds()) {
+ Pair<IFile, IFile> fileSet = finder.getFileSet(key);
+ registry.registerTestBatch(key, fileSet.getFirst().getLocationURI(), fileSet.getSecond().getLocationURI());
+ }
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ TestBatchDecorator.performLabelDecoratorUpdate(nature.getProject());
+ }
+ });
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java
index b4bb056e169..e0a2b207f3d 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/configuration/pages/LoadScriptPage.java
@@ -25,12 +25,12 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.framework.jdk.core.util.xml.Jaxp;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.ui.test.manager.configuration.ILoadConfig;
import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin;
import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage;
import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTableViewer;
import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask;
-import org.eclipse.swt.widgets.Display;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -38,118 +38,119 @@ import org.xml.sax.SAXException;
public class LoadScriptPage implements ILoadConfig, ScriptPageConstants {
- private final ScriptPage scriptPage;
- private final ScriptTableViewer scriptTableViewer;
- private final Vector<ScriptTask> scriptTasks;
-
- public LoadScriptPage(ScriptPage tmPage) {
- this.scriptPage = tmPage;
- this.scriptTableViewer = scriptPage.getScriptTableViewer();
- scriptTasks = new Vector<ScriptTask>();
- }
-
- public void loadConfiguration(final File toProcess) throws Exception {
-
- Job job = new Job(String.format("Loading Script Run List [%s]", toProcess.getName())) {
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- Document doc;
- try {
- doc = Jaxp.readXmlDocument(toProcess);
- parseConfig(doc);
-
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- scriptTableViewer.loadTasksFromList(scriptTasks);
- scriptTableViewer.refresh();
- debug(toProcess.getAbsolutePath());
- }
- });
- } catch (ParserConfigurationException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
- } catch (SAXException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
- } catch (IOException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
- }
-
- return Status.OK_STATUS;
- }
-
- };
- job.schedule();
- }
-
- private void debug(String val) {
- OseeLog.log(TestManagerPlugin.class, Level.INFO, "Loaded From: " + val);
- }
-
- private void parseConfig(Document doc) {
- NodeList nl = doc.getElementsByTagName(ScriptPageConstants.SCRIPTPAGE_CONFIG);
-
- for (int i = 0; i < nl.getLength(); i++) {
- Element element = (Element) nl.item(i);
- parseMiscellaneousInfo(element);
- parseScriptEntries(element);
- }
- }
-
- private void parseMiscellaneousInfo(Element element) {
- // Iterator iterator = node.getDescendants(new RegExElementFilter(
- // Pattern.compile(ScriptPageConstants.SERVICES_ENTRY)));
- // while (iterator.hasNext()) {
- // Element child = (Element) iterator.next();
- // TODO load miscellaneous information to page
- // }
- }
-
- private class LoadScriptHelper implements Runnable {
- private boolean stopLoading = false;
- private final String path;
-
- public LoadScriptHelper(String path) {
- this.path = path;
- }
-
- public void run() {
- if (!MessageDialog.openQuestion(
- Display.getDefault().getActiveShell(),
- "Script not found",
- "The script " + path + " was not found in this workspace. Do you want to continue loading from the script list file. ")) {
- stopLoading = true;
- }
- }
-
- public boolean stop() {
- return stopLoading;
- }
- }
-
- private void parseScriptEntries(Element element) {
- NodeList nl = element.getElementsByTagName(ScriptPageConstants.SCRIPT_ENTRY);
- String alternatePath = scriptPage.getTestManager().getAlternateOutputDir();
- for (int i = 0; i < nl.getLength(); i++) {
- Element child = (Element) nl.item(i);
- final String path = Jaxp.getChildText(child, ScriptPageConstants.RAW_FILENAME_FIELD);
- String runnable = Jaxp.getChildText(child, ScriptPageConstants.RUNNABLE_FIELD);
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
- if (file.exists()) {
- try {
- ScriptTask task = new ScriptTask(file.getLocation().toString(), alternatePath);
- task.setRun(Boolean.parseBoolean(runnable));
- scriptTasks.add(task);
- } catch (NullPointerException e) {
- e.printStackTrace();
- }
- } else {
- LoadScriptHelper helper = new LoadScriptHelper(path);
- Display.getDefault().syncExec(helper);
- if (helper.stop()) {
- break;
- }
- }
- }
- }
+ private final ScriptPage scriptPage;
+ private final ScriptTableViewer scriptTableViewer;
+ private final Vector<ScriptTask> scriptTasks;
+
+ public LoadScriptPage(ScriptPage tmPage) {
+ this.scriptPage = tmPage;
+ this.scriptTableViewer = scriptPage.getScriptTableViewer();
+ scriptTasks = new Vector<ScriptTask>();
+ }
+
+ public void loadConfiguration(final File toProcess) throws Exception {
+
+ Job job = new Job(String.format("Loading Script Run List [%s]", toProcess.getName())) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ Document doc;
+ try {
+ doc = Jaxp.readXmlDocument(toProcess);
+ parseConfig(doc);
+
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ scriptTableViewer.loadTasksFromList(scriptTasks);
+ scriptTableViewer.refresh();
+ debug(toProcess.getAbsolutePath());
+ }
+ });
+ } catch (ParserConfigurationException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
+ } catch (SAXException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
+ } catch (IOException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ };
+ job.schedule();
+ }
+
+ private void debug(String val) {
+ OseeLog.log(TestManagerPlugin.class, Level.INFO, "Loaded From: " + val);
+ }
+
+ private void parseConfig(Document doc) {
+ NodeList nl = doc.getElementsByTagName(ScriptPageConstants.SCRIPTPAGE_CONFIG);
+
+ for (int i = 0; i < nl.getLength(); i++) {
+ Element element = (Element) nl.item(i);
+ parseMiscellaneousInfo(element);
+ parseScriptEntries(element);
+ }
+ }
+
+ private void parseMiscellaneousInfo(Element element) {
+ // Iterator iterator = node.getDescendants(new RegExElementFilter(
+ // Pattern.compile(ScriptPageConstants.SERVICES_ENTRY)));
+ // while (iterator.hasNext()) {
+ // Element child = (Element) iterator.next();
+ // TODO load miscellaneous information to page
+ // }
+ }
+
+ private class LoadScriptHelper implements Runnable {
+ private boolean stopLoading = false;
+ private final String path;
+
+ public LoadScriptHelper(String path) {
+ this.path = path;
+ }
+
+ public void run() {
+ if (!MessageDialog.openQuestion(
+ Displays.getActiveShell(),
+ "Script not found",
+ "The script " + path + " was not found in this workspace. Do you want to continue loading from the script list file. ")) {
+ stopLoading = true;
+ }
+ }
+
+ public boolean stop() {
+ return stopLoading;
+ }
+ }
+
+ private void parseScriptEntries(Element element) {
+ NodeList nl = element.getElementsByTagName(ScriptPageConstants.SCRIPT_ENTRY);
+ String alternatePath = scriptPage.getTestManager().getAlternateOutputDir();
+ for (int i = 0; i < nl.getLength(); i++) {
+ Element child = (Element) nl.item(i);
+ final String path = Jaxp.getChildText(child, ScriptPageConstants.RAW_FILENAME_FIELD);
+ String runnable = Jaxp.getChildText(child, ScriptPageConstants.RUNNABLE_FIELD);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path));
+ if (file.exists()) {
+ try {
+ ScriptTask task = new ScriptTask(file.getLocation().toString(), alternatePath);
+ task.setRun(Boolean.parseBoolean(runnable));
+ scriptTasks.add(task);
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ } else {
+ LoadScriptHelper helper = new LoadScriptHelper(path);
+ Displays.pendInDisplayThread(helper);
+ if (helper.stop()) {
+ break;
+ }
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptManager.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptManager.java
index d41059dfbe8..83f6edbc1ed 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptManager.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/ScriptManager.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.test.manager.connection;
-
+package org.eclipse.osee.ote.ui.test.manager.connection;
+
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.HashSet;
@@ -24,6 +24,7 @@ import java.util.logging.Level;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.core.environment.UserTestSessionKey;
import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment;
import org.eclipse.osee.ote.core.environment.status.IServiceStatusListener;
@@ -35,12 +36,11 @@ import org.eclipse.osee.ote.ui.test.manager.jobs.StoreOutfileJob;
import org.eclipse.osee.ote.ui.test.manager.models.OutputModelJob;
import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask;
import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask.ScriptStatusEnum;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public abstract class ScriptManager implements Runnable {
+
+/**
+ * @author Andrew M. Finkbeiner
+ */
+public abstract class ScriptManager implements Runnable {
private final Map<String, ScriptTask> guidToScriptTask = new HashMap<String, ScriptTask>();
private TestManagerStatusListener statusListenerImpl;
private final TestManagerEditor testManager;
@@ -63,80 +63,80 @@ public abstract class ScriptManager implements Runnable {
Thread th = new Thread(r, "TM Table updater");
th.setDaemon(true);
return th;
- }
-
+ }
+
});
updater.scheduleAtFixedRate(this, 0, 2000, TimeUnit.MILLISECONDS);
OutputModelJob.createSingleton(this);
- }
-
- public abstract void abortScript(boolean isBatchAbort) throws RemoteException;
-
+ }
+
+ public abstract void abortScript(boolean isBatchAbort) throws RemoteException;
+
public void notifyScriptDequeued(String className) {
ScriptTask task = guidToScriptTask.get(className);
if (task != null) {
guidToScriptTask.remove(task);
}
- }
-
+ }
+
/**
- * This should be called after the environment is received in order to
- * configure necessary items.
+ * This should be called after the environment is received in order to configure necessary items.
*
* @return null if successful, otherwise a string describing the error
* @throws RemoteException
*/
- public boolean connect(ConnectionEvent event) {
-
+ public boolean connect(ConnectionEvent event) {
+
connectedEnv = event.getEnvironment();
sessionKey = event.getSessionKey();
try {
/*
* Setup the status listener for commands
*/
- statusListenerImpl = new TestManagerStatusListener(testManager, this);
-
+ statusListenerImpl = new TestManagerStatusListener(testManager, this);
+
connectedEnv.addStatusListener((IServiceStatusListener) event.getConnector().export(statusListenerImpl));
return false;
} catch (Exception e) {
TestManagerPlugin.log(Level.SEVERE, "failed to connect script manager", e);
return true;
}
- }
-
+ }
+
/**
- * This should NOT be called directly, users should call the HostDataStore's
- * disconnect.
+ * This should NOT be called directly, users should call the HostDataStore's disconnect.
*/
public boolean disconnect(ConnectionEvent event) {
connectedEnv = null;
sessionKey = null;
guidToScriptTask.clear();
- try {
-
- event.getEnvironment().removeStatusListener((IServiceStatusListener) event.getConnector().findExport(statusListenerImpl));
+ try {
+
+ event.getEnvironment().removeStatusListener(
+ (IServiceStatusListener) event.getConnector().findExport(statusListenerImpl));
return false;
} catch (RemoteException e) {
TestManagerPlugin.log(Level.INFO, "problems removing listener", e);
return true;
}
- }
-
+ }
+
public boolean onConnectionLost() {
connectedEnv = null;
sessionKey = null;
guidToScriptTask.clear();
- return false;
- }
-
+ return false;
+ }
+
public ScriptTask getScriptTask(String name) {
- return guidToScriptTask.get(name);
- }
-
+ return guidToScriptTask.get(name);
+ }
+
public void notifyScriptQueued(GUID theGUID, final ScriptTask script) {
guidToScriptTask.put(script.getScriptModel().getTestClass(), script);
script.setStatus(ScriptStatusEnum.IN_QUEUE);
- Display.getDefault().asyncExec(new Runnable() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
public void run() {
if (stv.getControl().isDisposed()) {
return;
@@ -144,10 +144,11 @@ public abstract class ScriptManager implements Runnable {
stv.refresh(script);
}
});
- }
-
+ }
+
public void updateScriptTableViewer(final ScriptTask task) {
- Display.getDefault().asyncExec(new Runnable() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
public void run() {
if (stv.getControl().isDisposed()) {
return;
@@ -155,24 +156,26 @@ public abstract class ScriptManager implements Runnable {
stv.refresh(task);
}
});
- }
-
+ }
+
public void updateScriptTableViewerTimed(ScriptTask task) {
updateScriptTable = true;
synchronized (tasksToUpdate) {
tasksToUpdate.add(task);
}
- }
-
+ }
+
+ @Override
public void run() {
if (updateScriptTable) {
updateScriptTable = false;
- Display.getDefault().asyncExec(new Runnable() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
public void run() {
synchronized (tasksToUpdate) {
if (stv.getControl().isDisposed()) {
return;
- }
+ }
for (ScriptTask task : tasksToUpdate) {
stv.refresh(task);
}
@@ -185,31 +188,33 @@ public abstract class ScriptManager implements Runnable {
protected TestManagerEditor getTestManagerEditor() {
return testManager;
- }
-
- public abstract void addTestsToQueue(List<ScriptTask> scripts);
-
+ }
+
+ public abstract void addTestsToQueue(List<ScriptTask> scripts);
+
/**
* @param task
*/
public void notifyScriptStart(final ScriptTask task) {
task.setStatus(ScriptStatusEnum.RUNNING);
- Display.getDefault().asyncExec(new Runnable() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
public void run() {
stv.refresh(task);
}
});
- }
-
- public void storeOutFile(ScriptTask task, TestComplete testComplete, boolean isValidRun) {
+ }
+
+ public void storeOutFile(ScriptTask task, TestComplete testComplete, boolean isValidRun) {
if (task.getScriptModel() != null) {
- Job job = new StoreOutfileJob(connectedEnv, testManager, this, task, testComplete.getClientOutfilePath(), testComplete.getServerOutfilePath(),
- isValidRun);
+ Job job =
+ new StoreOutfileJob(connectedEnv, testManager, this, task, testComplete.getClientOutfilePath(),
+ testComplete.getServerOutfilePath(), isValidRun);
StoreOutfileJob.scheduleJob(job);
}
- }
-
- protected UserTestSessionKey getSessionKey() {
+ }
+
+ protected UserTestSessionKey getSessionKey() {
return sessionKey;
- }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerServiceStatusDataVisitor.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerServiceStatusDataVisitor.java
index c6c16ba5e02..2da232cbb5c 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerServiceStatusDataVisitor.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/connection/TestManagerServiceStatusDataVisitor.java
@@ -18,6 +18,7 @@ import java.util.logging.Level;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.IHealthStatus;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.core.environment.status.CommandAdded;
import org.eclipse.osee.ote.core.environment.status.CommandEndedStatusEnum;
import org.eclipse.osee.ote.core.environment.status.CommandRemoved;
@@ -37,318 +38,318 @@ import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor;
import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin;
import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask;
import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask.ScriptStatusEnum;
-import org.eclipse.swt.widgets.Display;
/**
* @author Roberto E. Escobar
*/
final class TestManagerServiceStatusDataVisitor implements IServiceStatusDataVisitor {
- private final ScriptManager scriptManager;
- private final TestManagerEditor testManagerEditor;
- private final ExecutorService executor;
+ private final ScriptManager scriptManager;
+ private final TestManagerEditor testManagerEditor;
+ private final ExecutorService executor;
- protected TestManagerServiceStatusDataVisitor(ScriptManager scriptManager, TestManagerEditor testManagerEditor) {
- this.scriptManager = scriptManager;
- this.testManagerEditor = testManagerEditor;
- executor = Executors.newSingleThreadExecutor();
+ protected TestManagerServiceStatusDataVisitor(ScriptManager scriptManager, TestManagerEditor testManagerEditor) {
+ this.scriptManager = scriptManager;
+ this.testManagerEditor = testManagerEditor;
+ executor = Executors.newSingleThreadExecutor();
- }
+ }
- public void asCommandAdded(final CommandAdded commandAdded) {
- executor.submit(new StatusBoardRecieveEvent<CommandAdded>(commandAdded) {
- @Override
- public void run() {
- checkServiceStatusDataValid(commandAdded);
- logServiceStatusData(commandAdded);
- final ScriptTask task = getScriptTask(commandAdded);
- if (task != null) {
- task.setStatus(ScriptStatusEnum.IN_QUEUE);
- scriptManager.updateScriptTableViewer(task);
- }
- }
- });
- logExecutorSize();
- }
+ public void asCommandAdded(final CommandAdded commandAdded) {
+ executor.submit(new StatusBoardRecieveEvent<CommandAdded>(commandAdded) {
+ @Override
+ public void run() {
+ checkServiceStatusDataValid(commandAdded);
+ logServiceStatusData(commandAdded);
+ final ScriptTask task = getScriptTask(commandAdded);
+ if (task != null) {
+ task.setStatus(ScriptStatusEnum.IN_QUEUE);
+ scriptManager.updateScriptTableViewer(task);
+ }
+ }
+ });
+ logExecutorSize();
+ }
- public void asCommandRemoved(final CommandRemoved commandRemoved) {
- executor.submit(new StatusBoardRecieveEvent<CommandRemoved>(commandRemoved) {
- @Override
- public void run() {
- checkServiceStatusDataValid(commandRemoved);
- logServiceStatusData(commandRemoved);
+ public void asCommandRemoved(final CommandRemoved commandRemoved) {
+ executor.submit(new StatusBoardRecieveEvent<CommandRemoved>(commandRemoved) {
+ @Override
+ public void run() {
+ checkServiceStatusDataValid(commandRemoved);
+ logServiceStatusData(commandRemoved);
- final ScriptTask task = getScriptTask(commandRemoved);
- if (task != null) {
- CommandEndedStatusEnum cmdStat = commandRemoved.getReason();
- if (cmdStat.equals(CommandEndedStatusEnum.ABORTED)) {
- logOnConsole(Level.SEVERE, String.format("Test Aborted: [%s]", task.getName()));
- task.setStatus(ScriptStatusEnum.CANCELLED);
- }
- notifyExecutionComplete(task);
- // userEnvironment.notifyScriptDequeued(task.getGuid());
- scriptManager.updateScriptTableViewer(task);
- }
- }
- });
- logExecutorSize();
- }
+ final ScriptTask task = getScriptTask(commandRemoved);
+ if (task != null) {
+ CommandEndedStatusEnum cmdStat = commandRemoved.getReason();
+ if (cmdStat.equals(CommandEndedStatusEnum.ABORTED)) {
+ logOnConsole(Level.SEVERE, String.format("Test Aborted: [%s]", task.getName()));
+ task.setStatus(ScriptStatusEnum.CANCELLED);
+ }
+ notifyExecutionComplete(task);
+ // userEnvironment.notifyScriptDequeued(task.getGuid());
+ scriptManager.updateScriptTableViewer(task);
+ }
+ }
+ });
+ logExecutorSize();
+ }
- public void asEnvironmentError(final EnvironmentError environmentError) {
- executor.submit(new StatusBoardRecieveEvent<EnvironmentError>(environmentError) {
- @Override
- public void run() {
- checkServiceStatusDataValid(environmentError);
+ public void asEnvironmentError(final EnvironmentError environmentError) {
+ executor.submit(new StatusBoardRecieveEvent<EnvironmentError>(environmentError) {
+ @Override
+ public void run() {
+ checkServiceStatusDataValid(environmentError);
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE,
- "errorOccured: " + environmentError.getErr().getMessage());
- environmentError.getErr().printStackTrace();
- final String msg = Lib.exceptionToString(environmentError.getErr());
- logOnConsole(Level.SEVERE, String.format("Test Environment Error: [%s]", msg));
- disconnectOnError(msg);
- }
- });
- logExecutorSize();
- }
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE,
+ "errorOccured: " + environmentError.getErr().getMessage());
+ environmentError.getErr().printStackTrace();
+ final String msg = Lib.exceptionToString(environmentError.getErr());
+ logOnConsole(Level.SEVERE, String.format("Test Environment Error: [%s]", msg));
+ disconnectOnError(msg);
+ }
+ });
+ logExecutorSize();
+ }
- public void asSequentialCommandBegan(final SequentialCommandBegan sequentialCommandBegan) {
- executor.submit(new StatusBoardRecieveEvent<SequentialCommandBegan>(sequentialCommandBegan) {
- @Override
- public void run() {
- checkServiceStatusDataValid(sequentialCommandBegan);
- logServiceStatusData(sequentialCommandBegan);
+ public void asSequentialCommandBegan(final SequentialCommandBegan sequentialCommandBegan) {
+ executor.submit(new StatusBoardRecieveEvent<SequentialCommandBegan>(sequentialCommandBegan) {
+ @Override
+ public void run() {
+ checkServiceStatusDataValid(sequentialCommandBegan);
+ logServiceStatusData(sequentialCommandBegan);
- final ScriptTask task = getScriptTask(sequentialCommandBegan);
- if (task != null && task.getScriptModel() != null) {
- OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("Script Task: [%s]", task));
- logOnConsole(Level.INFO, String.format("Test Starting: [%s]", task.getName()));
- task.setStatus(ScriptStatusEnum.RUNNING);
- scriptManager.updateScriptTableViewer(task);
- }
- }
- });
- logExecutorSize();
- }
+ final ScriptTask task = getScriptTask(sequentialCommandBegan);
+ if (task != null && task.getScriptModel() != null) {
+ OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("Script Task: [%s]", task));
+ logOnConsole(Level.INFO, String.format("Test Starting: [%s]", task.getName()));
+ task.setStatus(ScriptStatusEnum.RUNNING);
+ scriptManager.updateScriptTableViewer(task);
+ }
+ }
+ });
+ logExecutorSize();
+ }
- public void asSequentialCommandEnded(final SequentialCommandEnded sequentialCommandEnded) {
+ public void asSequentialCommandEnded(final SequentialCommandEnded sequentialCommandEnded) {
- executor.submit(new StatusBoardRecieveEvent<SequentialCommandEnded>(sequentialCommandEnded) {
- @Override
- public void run() {
- checkServiceStatusDataValid(sequentialCommandEnded);
- logServiceStatusData(sequentialCommandEnded);
- final ScriptTask task = getScriptTask(sequentialCommandEnded);
- if (task != null) {
- OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("Script Task: [%s]", task));
- CommandEndedStatusEnum cmdStat = sequentialCommandEnded.getStatus();
- switch (cmdStat) {
- case ABORTED:
- logOnConsole(Level.SEVERE, String.format("Test Aborted: [%s]", task.getName()));
- task.setStatus(ScriptStatusEnum.CANCELLED);
- break;
- case EXCEPTION:
- task.setStatus(ScriptStatusEnum.CANCELLED);
- logOnConsole(Level.SEVERE,
- String.format("Test Aborted: [%s] - Exception Occurred", task.getName()));
- break;
- case HUNG:
- task.setStatus(ScriptStatusEnum.CANCELLED);
- logOnConsole(Level.SEVERE, String.format("Test Hung: [%s]", task.getName()));
- break;
- case RAN_TO_COMPLETION:
- task.setStatus(ScriptStatusEnum.COMPLETE);
- break;
- default:
- task.setStatus(ScriptStatusEnum.COMPLETE);
- logOnConsole(Level.SEVERE, String.format("Test Ended Unexpectedly: [%s]", task.getName()));
- break;
- }
- // onOutfileSave(task, sequentialCommandEnded.getDescription(),
- // isValidRun);
- logOnConsole(Level.INFO, String.format("Test Completed: [%s]", task.getName()));
- notifyExecutionComplete(task);
- // userEnvironment.notifyScriptDequeued(task.getGuid());
- scriptManager.updateScriptTableViewer(task);
- }
- }
- });
- logExecutorSize();
- }
+ executor.submit(new StatusBoardRecieveEvent<SequentialCommandEnded>(sequentialCommandEnded) {
+ @Override
+ public void run() {
+ checkServiceStatusDataValid(sequentialCommandEnded);
+ logServiceStatusData(sequentialCommandEnded);
+ final ScriptTask task = getScriptTask(sequentialCommandEnded);
+ if (task != null) {
+ OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("Script Task: [%s]", task));
+ CommandEndedStatusEnum cmdStat = sequentialCommandEnded.getStatus();
+ switch (cmdStat) {
+ case ABORTED:
+ logOnConsole(Level.SEVERE, String.format("Test Aborted: [%s]", task.getName()));
+ task.setStatus(ScriptStatusEnum.CANCELLED);
+ break;
+ case EXCEPTION:
+ task.setStatus(ScriptStatusEnum.CANCELLED);
+ logOnConsole(Level.SEVERE,
+ String.format("Test Aborted: [%s] - Exception Occurred", task.getName()));
+ break;
+ case HUNG:
+ task.setStatus(ScriptStatusEnum.CANCELLED);
+ logOnConsole(Level.SEVERE, String.format("Test Hung: [%s]", task.getName()));
+ break;
+ case RAN_TO_COMPLETION:
+ task.setStatus(ScriptStatusEnum.COMPLETE);
+ break;
+ default:
+ task.setStatus(ScriptStatusEnum.COMPLETE);
+ logOnConsole(Level.SEVERE, String.format("Test Ended Unexpectedly: [%s]", task.getName()));
+ break;
+ }
+ // onOutfileSave(task, sequentialCommandEnded.getDescription(),
+ // isValidRun);
+ logOnConsole(Level.INFO, String.format("Test Completed: [%s]", task.getName()));
+ notifyExecutionComplete(task);
+ // userEnvironment.notifyScriptDequeued(task.getGuid());
+ scriptManager.updateScriptTableViewer(task);
+ }
+ }
+ });
+ logExecutorSize();
+ }
- public void asTestPointUpdate(final TestPointUpdate testPointUpdate) {
- executor.submit(new StatusBoardRecieveEvent<TestPointUpdate>(testPointUpdate) {
- @Override
- public void run() {
- checkServiceStatusDataValid(testPointUpdate);
- final ScriptTask task = scriptManager.getScriptTask(testPointUpdate.getClassName());
- // final ScriptTask task = getScriptTask(testPointUpdate);
- if (task != null) {
- task.getScriptModel().getOutputModel().setPassedTestPoints(testPointUpdate.getPass());
- task.getScriptModel().getOutputModel().setFailedTestPoints(testPointUpdate.getFail());
- scriptManager.updateScriptTableViewerTimed(task);
- } else {
- OseeLog.log(TestManagerPlugin.class, Level.WARNING, "testPointsUpdated: task is null");
- }
- }
- });
- logExecutorSize();
- }
+ public void asTestPointUpdate(final TestPointUpdate testPointUpdate) {
+ executor.submit(new StatusBoardRecieveEvent<TestPointUpdate>(testPointUpdate) {
+ @Override
+ public void run() {
+ checkServiceStatusDataValid(testPointUpdate);
+ final ScriptTask task = scriptManager.getScriptTask(testPointUpdate.getClassName());
+ // final ScriptTask task = getScriptTask(testPointUpdate);
+ if (task != null) {
+ task.getScriptModel().getOutputModel().setPassedTestPoints(testPointUpdate.getPass());
+ task.getScriptModel().getOutputModel().setFailedTestPoints(testPointUpdate.getFail());
+ scriptManager.updateScriptTableViewerTimed(task);
+ } else {
+ OseeLog.log(TestManagerPlugin.class, Level.WARNING, "testPointsUpdated: task is null");
+ }
+ }
+ });
+ logExecutorSize();
+ }
- private synchronized void logOnConsole(final Level level, final String msg) {
- if (level.equals(Level.SEVERE)) {
- TestManagerPlugin.getInstance().getOteConsoleService().writeError(msg);
- } else {
- TestManagerPlugin.getInstance().getOteConsoleService().write(msg);
- }
- }
+ private synchronized void logOnConsole(final Level level, final String msg) {
+ if (level.equals(Level.SEVERE)) {
+ TestManagerPlugin.getInstance().getOteConsoleService().writeError(msg);
+ } else {
+ TestManagerPlugin.getInstance().getOteConsoleService().write(msg);
+ }
+ }
- private void checkServiceStatusDataValid(IServiceStatusData statusData) {
- if (statusData == null) {
- throw new IllegalArgumentException(String.format("Error [%s] was null.", IServiceStatusData.class.getName()));
- }
- }
+ private void checkServiceStatusDataValid(IServiceStatusData statusData) {
+ if (statusData == null) {
+ throw new IllegalArgumentException(String.format("Error [%s] was null.", IServiceStatusData.class.getName()));
+ }
+ }
- private void disconnectOnError(final String cause) {
- Display.getDefault().asyncExec(new Runnable() {
+ private void disconnectOnError(final String cause) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ TestManagerPlugin.getInstance().getOteConsoleService().writeError(cause);
+ }
+ });
+ }
- public void run() {
- TestManagerPlugin.getInstance().getOteConsoleService().writeError(cause);
- }
- });
- }
+ private void logServiceStatusData(IServiceStatusDataCommand statusData) {
+ OseeLog.log(TestManagerPlugin.class, Level.FINE,
+ String.format("%s: %s ", statusData.getClass().getName(), statusData.getDescription()));
+ }
- private void logServiceStatusData(IServiceStatusDataCommand statusData) {
- OseeLog.log(TestManagerPlugin.class, Level.FINE, String.format("%s: %s ", statusData.getClass().getName(),
- statusData.getDescription()));
- }
+ private ScriptTask getScriptTask(IServiceStatusDataCommand statusData) {
+ // statusData.getDescription().getDescription()
+ return scriptManager.getScriptTask(statusData.getDescription().getDescription());
+ }
- private ScriptTask getScriptTask(IServiceStatusDataCommand statusData) {
- // statusData.getDescription().getDescription()
- return scriptManager.getScriptTask(statusData.getDescription().getDescription());
- }
+ private void notifyExecutionComplete(ScriptTask scriptTask) {
+ // if (userEnvironment.getLastGUIDToRun() != null &&
+ // scriptTask.getGuid().equals(userEnvironment.getLastGUIDToRun())) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ testManagerEditor.executionCompleted();
+ }
+ });
+ logExecutorSize();
+ // }
+ }
- private void notifyExecutionComplete(ScriptTask scriptTask) {
- // if (userEnvironment.getLastGUIDToRun() != null &&
- // scriptTask.getGuid().equals(userEnvironment.getLastGUIDToRun())) {
- Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void asTestServerCommandComplete(final TestServerCommandComplete end) {
- public void run() {
- testManagerEditor.executionCompleted();
- }
- });
- logExecutorSize();
- // }
- }
+ executor.submit(new StatusBoardRecieveEvent<TestServerCommandComplete>(end) {
+ @Override
+ public void run() {
+ try {
+ ITestCommandResult result = end.getHandle().get();
+ TestCommandStatus status = result.getStatus();
+ Throwable th = result.getThrowable();
+ if (th != null) {
+ th.printStackTrace();
+ }
+ if (status != null) {
+ System.out.println(status.name());
+ }
+ } catch (RemoteException ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
+ }
- public void asTestServerCommandComplete(final TestServerCommandComplete end) {
+ notifyExecutionComplete(null);
+ }
+ });
+ logExecutorSize();
+ }
- executor.submit(new StatusBoardRecieveEvent<TestServerCommandComplete>(end) {
- @Override
- public void run() {
- try {
- ITestCommandResult result = end.getHandle().get();
- TestCommandStatus status = result.getStatus();
- Throwable th = result.getThrowable();
- if (th != null) {
- th.printStackTrace();
- }
- if (status != null) {
- System.out.println(status.name());
- }
- } catch (RemoteException ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
- }
+ public void asTestComplete(final TestComplete testComplete) {
+ executor.submit(new StatusBoardRecieveEvent<TestComplete>(testComplete) {
+ @Override
+ public void run() {
+ ScriptTask task = scriptManager.getScriptTask(testComplete.getClassName());
+ if (task != null) {
+ OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("Script Task: [%s]", task));
+ boolean isValidRun = true;
+ CommandEndedStatusEnum cmdStat = testComplete.getStatus();
+ switch (cmdStat) {
+ case ABORTED:
+ logOnConsole(Level.SEVERE, String.format("Test Aborted: [%s]", task.getName()));
+ for (IHealthStatus status : testComplete.getHealthStatus()) {
+ String msg;
+ if (status.getException() != null) {
+ msg = Lib.exceptionToString(status.getException());
+ } else {
+ msg = status.getMessage();
+ }
+ logOnConsole(status.getLevel(), msg);
+ }
+ task.setStatus(ScriptStatusEnum.CANCELLED);
+ break;
+ case EXCEPTION:
+ task.setStatus(ScriptStatusEnum.CANCELLED);
+ logOnConsole(Level.SEVERE,
+ String.format("Test Exception: [%s] - Exception Occurred", task.getName()));
+ StringBuilder sb = new StringBuilder();
+ try {
+ for (IHealthStatus status : testComplete.getHealthStatus()) {
+ if (status.getException() != null) {
+ sb.append(Lib.exceptionToString(status.getException()));
+ } else if (status.getLevel().intValue() >= Level.SEVERE.intValue()) {
+ sb.append(status.getMessage());
+ }
+ }
+ logOnConsole(Level.SEVERE, sb.toString());
+ } catch (Throwable th) {
+ th.printStackTrace();
+ }
+ break;
+ case HUNG:
+ task.setStatus(ScriptStatusEnum.CANCELLED);
+ logOnConsole(Level.SEVERE, String.format("Test Hung: [%s]", task.getName()));
+ break;
+ case RAN_TO_COMPLETION:
+ task.setStatus(ScriptStatusEnum.COMPLETE);
+ break;
+ default:
+ task.setStatus(ScriptStatusEnum.COMPLETE);
+ logOnConsole(Level.SEVERE, String.format("Test Ended Unexpectedly: [%s]", task.getName()));
+ isValidRun = false;
+ break;
+ }
+ scriptManager.storeOutFile(task, testComplete, isValidRun);
+ logOnConsole(Level.INFO, String.format("Test Completed: [%s]", task.getName()));
- notifyExecutionComplete(null);
- }
- });
- logExecutorSize();
- }
+ scriptManager.notifyScriptDequeued(testComplete.getClassName());
+ scriptManager.updateScriptTableViewer(task);
- public void asTestComplete(final TestComplete testComplete) {
- executor.submit(new StatusBoardRecieveEvent<TestComplete>(testComplete) {
- @Override
- public void run() {
- ScriptTask task = scriptManager.getScriptTask(testComplete.getClassName());
- if (task != null) {
- OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("Script Task: [%s]", task));
- boolean isValidRun = true;
- CommandEndedStatusEnum cmdStat = testComplete.getStatus();
- switch (cmdStat) {
- case ABORTED:
- logOnConsole(Level.SEVERE, String.format("Test Aborted: [%s]", task.getName()));
- for (IHealthStatus status : testComplete.getHealthStatus()) {
- String msg;
- if (status.getException() != null) {
- msg = Lib.exceptionToString(status.getException());
- } else {
- msg = status.getMessage();
- }
- logOnConsole(status.getLevel(), msg);
- }
- task.setStatus(ScriptStatusEnum.CANCELLED);
- break;
- case EXCEPTION:
- task.setStatus(ScriptStatusEnum.CANCELLED);
- logOnConsole(Level.SEVERE, String.format("Test Exception: [%s] - Exception Occurred",
- task.getName()));
- StringBuilder sb = new StringBuilder();
- try {
- for (IHealthStatus status : testComplete.getHealthStatus()) {
- if (status.getException() != null) {
- sb.append(Lib.exceptionToString(status.getException()));
- } else if (status.getLevel().intValue() >= Level.SEVERE.intValue()) {
- sb.append(status.getMessage());
- }
- }
- logOnConsole(Level.SEVERE, sb.toString());
- } catch (Throwable th) {
- th.printStackTrace();
- }
- break;
- case HUNG:
- task.setStatus(ScriptStatusEnum.CANCELLED);
- logOnConsole(Level.SEVERE, String.format("Test Hung: [%s]", task.getName()));
- break;
- case RAN_TO_COMPLETION:
- task.setStatus(ScriptStatusEnum.COMPLETE);
- break;
- default:
- task.setStatus(ScriptStatusEnum.COMPLETE);
- logOnConsole(Level.SEVERE, String.format("Test Ended Unexpectedly: [%s]", task.getName()));
- isValidRun = false;
- break;
- }
- scriptManager.storeOutFile(task, testComplete, isValidRun);
- logOnConsole(Level.INFO, String.format("Test Completed: [%s]", task.getName()));
+ }
+ }
+ });
+ logExecutorSize();
+ }
- scriptManager.notifyScriptDequeued(testComplete.getClassName());
- scriptManager.updateScriptTableViewer(task);
+ public void asTestStart(final TestStart testStart) {
+ executor.submit(new StatusBoardRecieveEvent<TestStart>(testStart) {
+ @Override
+ public void run() {
+ ScriptTask task = scriptManager.getScriptTask(testStart.getTestClassName());
+ if (task != null) {
+ scriptManager.notifyScriptStart(task);
+ logOnConsole(Level.INFO, String.format("Test Started: [%s]", task.getName()));
+ }
+ }
+ });
+ logExecutorSize();
+ }
- }
- }
- });
- logExecutorSize();
- }
-
- public void asTestStart(final TestStart testStart) {
- executor.submit(new StatusBoardRecieveEvent<TestStart>(testStart) {
- @Override
- public void run() {
- ScriptTask task = scriptManager.getScriptTask(testStart.getTestClassName());
- if (task != null) {
- scriptManager.notifyScriptStart(task);
- logOnConsole(Level.INFO, String.format("Test Started: [%s]", task.getName()));
- }
- }
- });
- logExecutorSize();
- }
-
- private void logExecutorSize() {
- if (executor instanceof ThreadPoolExecutor) {
- OseeLog.log(TestManagerServiceStatusDataVisitor.class, Level.FINE, String.format(
- "Current StatusBoard Executor Size [%d]", ((ThreadPoolExecutor) executor).getQueue().size()));
- }
- }
+ private void logExecutorSize() {
+ if (executor instanceof ThreadPoolExecutor) {
+ OseeLog.log(TestManagerServiceStatusDataVisitor.class, Level.FINE, String.format(
+ "Current StatusBoard Executor Size [%d]", ((ThreadPoolExecutor) executor).getQueue().size()));
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditor.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditor.java
index db7d45161c7..8d6ed8b4c0f 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditor.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/core/TestManagerEditor.java
@@ -31,6 +31,7 @@ import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.plugin.core.IActionable;
import org.eclipse.osee.framework.plugin.core.util.OseeData;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.ote.core.environment.interfaces.IHostTestEnvironment;
import org.eclipse.osee.ote.core.environment.interfaces.ITestEnvironment;
@@ -44,7 +45,6 @@ import org.eclipse.osee.ote.ui.test.manager.util.ClassServerInst;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -64,534 +64,534 @@ import org.eclipse.ui.part.MultiPageEditorPart;
* </ul>
*/
public abstract class TestManagerEditor extends MultiPageEditorPart implements IActionable, ITestConnectionListener {
- private static final Image errorImage = ImageManager.getImage(OteTestManagerImage.ERROR);
- public static final String namespace = "org.eclipse.osee.ote.ui.test.manager.editors.TestManagerEditor";
-
- public final QualifiedName clearCaseViewName = new QualifiedName(namespace, "CLEARCASEVIEW");
- public final QualifiedName configFileName = new QualifiedName(namespace, "CONFIGFILENAME");
- public final QualifiedName ofpQualName = new QualifiedName(namespace, "OFP");
- public final QualifiedName scriptsQualName = new QualifiedName(namespace, "SCRIPTS");
-
- private boolean fileIsDirty = false;
-
- private boolean fileWasSaved = false;
-
- private int lastPageIndex = 0;
-
- private final TestManagerModel model;
-
- private boolean reloadSourcePage = false;
-
- private int scriptPageIndex;
-
- private TextEditor sourceEditor;
-
- private int sourcePage;
-
- private final ITestManagerFactory testManagerFactory;
-
- private IFile thisIFile = null;
-
- private String xmlText;
-
- private final IPropertyStore propertyStore;
-
- private final PageManager pageManager;
-
- private ITestEnvironment connectedEnv = null;
- private IServiceConnector connector = null;
- private IHostTestEnvironment connectedHost;
-
- public TestManagerEditor(final ITestManagerFactory testManagerFactory) {
- super();
-
- this.testManagerFactory = testManagerFactory;
- this.pageManager = new PageManager(testManagerFactory, this);
- this.model = new TestManagerModel();
- this.propertyStore = new PropertyStore(testManagerFactory.getClass().getSimpleName());
- }
-
- public void activateScriptsPage() {
- setActivePage(scriptPageIndex);
- }
-
- public void addFile(String fullPath) {
- pageManager.getScriptPage().addFile(fullPath);
- }
-
- @Override
- public void dispose() {
- super.dispose();
- TestManagerPlugin.getInstance().getOteClientService().removeConnectionListener(this);
- try {
- pageManager.dispose();
- } catch (Throwable t) {
- TestManagerPlugin.log(Level.SEVERE, "exception while disposing test manager", t);
- }
- }
-
- /**
- * Saves the multi-page editor's document.
- */
- @Override
- public void doSave(IProgressMonitor monitor) {
- if (getActivePage() != sourcePage) {
- pageSourceLoad();
- }
- getEditor(sourcePage).doSave(monitor);
- fileIsDirty = false;
- fileWasSaved = true;
- doSave();
- firePropertyChange(PROP_DIRTY);
- }
-
- /**
- * Saves the multi-page editor's document as another file. Also updates the text for page 0's tab, and updates this
- * multi-page editor's input to correspond to the nested editor's.
- */
- @Override
- public void doSaveAs() {
- if (getActivePage() != sourcePage) {
- pageSourceLoad();
- }
- IEditorPart editor = getEditor(sourcePage);
- editor.doSaveAs();
- setPageText(sourcePage, "Source");
- setInput(editor.getEditorInput());
- readXmlData();
- doSave();
- }
-
- protected void registerPage(int pageNumber, String pageName) {
- setPageText(pageNumber, pageName);
- }
-
- public void executionCompleted() {
- pageManager.getScriptPage().onScriptRunning(false);
- }
-
- public void fireSaveNeeded() {
- fileIsDirty = true;
- firePropertyChange(PROP_DIRTY);
- }
-
- public String getAlternateOutputDir() {
- String scriptOutput = "";
-
- IPropertyStore propertyStore = getPropertyStore();
- scriptOutput = propertyStore.get(TestManagerStorageKeys.SCRIPT_OUTPUT_DIRECTORY_KEY);
- if (scriptOutput == null) {
- scriptOutput = "";
- // TODO: Escobar
- // try {
- // IEditorInput coreinput = getEditorInput();
- // if (coreinput instanceof IFileEditorInput) {
- // scriptOutput =
- // thisIFile.getPersistentProperty(scriptOutputQualName);
- // } else if (coreinput instanceof TestManagerInput) {
- // TestManagerInput input = (TestManagerInput) getEditorInput();
- // scriptOutput =
- // input.getValue(scriptOutputQualName.getLocalName());
- // }
- //
- // scriptOutput =
- // thisIFile.getPersistentProperty(scriptOutputQualName);
- // } catch (CoreException e) {
- // e.printStackTrace();
- // }
- }
- return scriptOutput;
- }
-
- public String getDefaultConfigPath() {
- Location user = Platform.getUserLocation();
- String path = user.getURL().getPath();
- File file = new File(path + File.separator + "org.eclipse.osee.ote.ui.test.manager");
- file.mkdirs();
- file =
- new File(
- path + File.separator + "org.eclipse.osee.ote.ui.test.manager" + File.separator + this.getClass().getName() + ".scriptConfig.xml");
- file.getParentFile().mkdirs();
- return file.getAbsolutePath();
- }
-
- /**
- * @return Returns the model.
- */
- public TestManagerModel getModel() {
- return model;
- }
-
- public String getName() {
- return this.getTitle();
- }
-
- public ClassServerInst getScriptClassServer() {
- return ClassServerInst.getInstance();
- }
-
- public ITestManagerFactory getTestManagerFactory() {
- return testManagerFactory;
- }
-
- @Override
- public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
- if (!(editorInput instanceof IFileEditorInput || editorInput instanceof TestManagerInput || editorInput instanceof IEditorInput)) {
- throw new PartInitException("Invalid Input: Must be IFileEditorInput");
- }
- super.init(site, editorInput);
- }
-
- @Override
- public boolean isDirty() {
- if (super.isDirty()) {
- return true;
- }
- return fileIsDirty;
- }
-
- @Override
- public boolean isSaveAsAllowed() {
- return true;
- }
-
- /**
- * Retrieves the value for the key. See <code>storeValue</code>. If the key could not be found, an empty string is
- * returned.
- *
- * @param key The <code>QualifiedName</code> whose value is to be retrieved.
- * @return The value of key, or an empty string if the key does not exist.
- */
- public String loadValue(QualifiedName key) {
- TestManagerPlugin.log(Level.INFO, "loadValue: " + key.getQualifier());
- try {
- IEditorInput coreinput = getEditorInput();
- if (coreinput instanceof IFileEditorInput) {
- return thisIFile.getPersistentProperty(key);
- } else if (coreinput instanceof TestManagerInput) {
- TestManagerInput input = (TestManagerInput) getEditorInput();
- return input.getValue(key.getLocalName());
- }
- } catch (CoreException ex) {
- TestManagerPlugin.log(Level.SEVERE, "Can't get value: " + ex);
- }
- return "";
- }
-
- public void setPageError(int page, boolean set) {
- if (set) {
- setPageImage(page, errorImage);
- } else {
- setPageImage(page, null);
- }
- }
-
- /**
- * Stores the value for the key. The key should be one of the publicly available <code>QualifiedName</code>'s in
- * <code>this</code>.
- *
- * @param key The <code>QualifiedName</code> associated with the value to be stored
- * @param value What will be stored under the key.
- */
- public void storeValue(QualifiedName key, String value) {
- TestManagerPlugin.log(Level.INFO, "storeValue: " + key.getQualifier());
- try {
- IEditorInput coreinput = getEditorInput();
- if (coreinput instanceof IFileEditorInput) {
- thisIFile.setPersistentProperty(key, value);
- } else if (coreinput instanceof TestManagerInput) {
- TestManagerInput input = (TestManagerInput) getEditorInput();
- input.storeValue(key.getLocalName(), value);
- }
- } catch (Exception ex) {
- TestManagerPlugin.log(Level.SEVERE, "Can't set value: " + ex);
- }
- }
-
- private void pageSourceCheck() {
- setPageError(sourcePage, model.hasParseExceptions());
- }
-
- private void readXmlData() {
- TestManagerPlugin.log(Level.INFO, "readXmlData");
- IEditorInput coreinput = getEditorInput();
- if (coreinput instanceof IFileEditorInput) {
- IFileEditorInput input = (IFileEditorInput) getEditorInput();
- thisIFile = input.getFile();
- String name = thisIFile.getName();
- this.setPartName(name);
- model.setConfiguration(name);
- if (thisIFile != null) {
- IPath containerPath = thisIFile.getRawLocation();
- model.filename = containerPath.toOSString();
- try {
-
- xmlText = Lib.inputStreamToString(thisIFile.getContents());
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- } else {
- TestManagerPlugin.log(Level.SEVERE, "Can't open xml file!");
- }
- } else if (coreinput instanceof TestManagerInput) {
- TestManagerInput input = (TestManagerInput) getEditorInput();
- String name = "TestManager";
- this.setPartName(name);
- model.setConfiguration(name);
- xmlText = input.getDefaultXML();
- }
- }
-
- /**
- * Creates the pages of the multi-page editor.
- */
- @Override
- protected void createPages() {
- readXmlData();
-
- if (model.setFromXml(xmlText)) {
- pageManager.createPages(getContainer());
- pageSourceCreate();
-
- fileIsDirty = false;
- reloadSourcePage = false;
- pageSourceCheck();
- restoreSettings();
- }
- // If parse errors, send to sourcePage and set error on page
- else {
- if (sourceEditor == null) {
- pageSourceCreate();
- setActivePage(sourcePage);
- return;
- }
- pageSourceCheck();
- setPageImage(sourcePage, errorImage);
- setActivePage(sourcePage);
- }
- fileIsDirty = false;
- firePropertyChange(PROP_DIRTY);
- TestManagerPlugin.getInstance().getOteClientService().addConnectionListener(this);
- }
-
- protected void handleSelection() {
- fireSaveNeeded();
- reloadSourcePage = true;
- }
-
- /**
- * reloads pages as necessary
- */
- @Override
- protected void pageChange(int newPageIndex) {
- // NOTE: Hosts page will be updated continuously, even it if it is not
- // the current page.
- // so it is unnecessary to update it on pageChange.
-
- super.pageChange(newPageIndex);
- if (newPageIndex == sourcePage) {
- pageSourceLoad();
- } else {
- if (sourceEditor == null) {
- return;
- }
- String newXml = sourceEditor.getDocumentProvider().getDocument(sourceEditor.getEditorInput()).get();
- if (sourceEditor.isDirty() || fileWasSaved) {
- fileWasSaved = false;
- // If we just came from sourcePage, re-parse
- if (lastPageIndex == sourcePage) {
- // if parse error, goto source and error
- if (!model.setFromXml(newXml)) {
- setActivePage(sourcePage);
- setPageError(sourcePage, true);
- MessageDialog.openError(getSite().getShell(), "Source Page Error",
- "Error parsing Source page\n\n" + model.getParseExceptions());
- return;
- }
- setPageError(sourcePage, false);
- }
- }
- }
- lastPageIndex = newPageIndex;
- }
-
- void pageSourceCreate() {
- try {
- if (getEditorInput() instanceof IFileEditorInput) {
- sourceEditor = new TextEditor();
- int index = addPage(sourceEditor, getEditorInput());
- sourcePage = index;
- setPageText(sourcePage, "Source");
- }
- } catch (PartInitException e) {
- TestManagerPlugin.log(Level.SEVERE, "Error creating nested text editor", e);
- ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus());
- }
- }
-
- void pageSourceLoad() {
- if (reloadSourcePage) {
- sourceEditor.getDocumentProvider().getDocument(sourceEditor.getEditorInput()).set(model.getRawXml());
- reloadSourcePage = false;
- }
- pageSourceCheck();
- }
-
- public void doSave() {
- readXmlData();
- model.setFromXml(xmlText);
- pageManager.save();
- OutputStream outputStream = null;
- try {
- File file = OseeData.getFile("testManagerSettings.xml");
- outputStream = new FileOutputStream(file);
- getPropertyStore().save(outputStream);
- } catch (Exception ex) {
- TestManagerPlugin.log(Level.SEVERE, "Error storing settings.", ex);
- } finally {
- if (outputStream != null) {
- try {
- outputStream.close();
- } catch (IOException ex) {
- TestManagerPlugin.log(Level.WARNING, "Error closing stream during settings storage.", ex);
- }
- }
- }
- }
-
- public void restoreSettings() {
- InputStream inputStream = null;
- try {
- File file = OseeData.getFile("testManagerSettings.xml");
- inputStream = new FileInputStream(file);
- getPropertyStore().load(inputStream);
- pageManager.restore();
- } catch (Exception ex) {
- TestManagerPlugin.log(Level.WARNING, "Stored settings not available. Using defaults.", ex);
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (IOException ex) {
- TestManagerPlugin.log(Level.WARNING, "Error closing stream while loading settings.", ex);
- }
- }
- }
- }
-
- public IPropertyStore getPropertyStore() {
- return propertyStore;
- }
-
- public PageManager getPageManager() {
- return pageManager;
- }
-
- public String getActionDescription() {
- String version =
- (String) Platform.getBundle("org.eclipse.osee.ote.ui.test.manager").getHeaders().get("Bundle-Version");
- String serverVersion = "";
- try {
- serverVersion = (String) Platform.getBundle("org.eclipse.osee.ote.core").getHeaders().get("Bundle-Version");
- } catch (Exception ex) {
- // do nothing
- }
- StringBuilder builder = new StringBuilder();
- builder.append("Problem found on OSEE TM Version: ");
- builder.append(version);
- builder.append("\nServer Version: ");
- builder.append(serverVersion);
- builder.append("\nTM File: ");
- builder.append(getTitle());
- builder.append("\n");
- builder.append("OFP: \"");
- builder.append(pageManager.getScriptPage().getOFP());
- builder.append("\"\n");
- builder.append("Scripts: \n");
- builder.append(pageManager.getScriptPage().getScripts());
- builder.append("\n");
-
- builder.append(getPropertyStore().toString());
-
- return builder.toString();
- }
-
- @Override
- public void onConnectionLost(IServiceConnector connector) {
- connectedEnv = null;
- connector = null;
- boolean problemEncountered = pageManager.onConnectionLost();
- if (problemEncountered) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Disconnect Error",
- "Test manager has encountered a problem while processing the disconnect event. See Error Log for details");
- }
- });
- }
- connectedHost = null;
- }
-
- @Override
- public void onPostConnect(ConnectionEvent event) {
- connectedEnv = event.getEnvironment();
- connectedHost = event.getHostEnvironment();
- connector = event.getConnector();
- boolean problemEncountered = pageManager.onPostConnect(event);
- if (problemEncountered) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Connection Error",
- "Test manager has encountered a problem while processing the connection event. See Error Log for details");
- }
- });
- }
- }
-
- @Override
- public void onPreDisconnect(ConnectionEvent event) {
- event.getEnvironment();
- connectedEnv = null;
-
- connector = null;
- boolean problemEncountered = pageManager.onPreDisconnect(event);
- if (problemEncountered) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Disconnect Error",
- "Test manager has encountered a problem while processing the disconnect event. See Error Log for details");
- }
- });
- }
- connectedHost = null;
- }
-
- public boolean isConnected() {
- return connectedEnv != null;
- }
-
- public ITestEnvironment getConnectedEnvironment() {
- return connectedEnv;
- }
-
- public IHostTestEnvironment getConnectedHostEnvironment(){
- return connectedHost;
- }
-
- public IServiceConnector getConnector() {
- return connector;
- }
-
- public abstract void createHostWidget(Composite parent);
-
- /**
- * @param array
- */
- public void addFiles(String[] files) {
- pageManager.getScriptPage().addFiles(files);
- }
+ private static final Image errorImage = ImageManager.getImage(OteTestManagerImage.ERROR);
+ public static final String namespace = "org.eclipse.osee.ote.ui.test.manager.editors.TestManagerEditor";
+
+ public final QualifiedName clearCaseViewName = new QualifiedName(namespace, "CLEARCASEVIEW");
+ public final QualifiedName configFileName = new QualifiedName(namespace, "CONFIGFILENAME");
+ public final QualifiedName ofpQualName = new QualifiedName(namespace, "OFP");
+ public final QualifiedName scriptsQualName = new QualifiedName(namespace, "SCRIPTS");
+
+ private boolean fileIsDirty = false;
+
+ private boolean fileWasSaved = false;
+
+ private int lastPageIndex = 0;
+
+ private final TestManagerModel model;
+
+ private boolean reloadSourcePage = false;
+
+ private int scriptPageIndex;
+
+ private TextEditor sourceEditor;
+
+ private int sourcePage;
+
+ private final ITestManagerFactory testManagerFactory;
+
+ private IFile thisIFile = null;
+
+ private String xmlText;
+
+ private final IPropertyStore propertyStore;
+
+ private final PageManager pageManager;
+
+ private ITestEnvironment connectedEnv = null;
+ private IServiceConnector connector = null;
+ private IHostTestEnvironment connectedHost;
+
+ public TestManagerEditor(final ITestManagerFactory testManagerFactory) {
+ super();
+
+ this.testManagerFactory = testManagerFactory;
+ this.pageManager = new PageManager(testManagerFactory, this);
+ this.model = new TestManagerModel();
+ this.propertyStore = new PropertyStore(testManagerFactory.getClass().getSimpleName());
+ }
+
+ public void activateScriptsPage() {
+ setActivePage(scriptPageIndex);
+ }
+
+ public void addFile(String fullPath) {
+ pageManager.getScriptPage().addFile(fullPath);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ TestManagerPlugin.getInstance().getOteClientService().removeConnectionListener(this);
+ try {
+ pageManager.dispose();
+ } catch (Throwable t) {
+ TestManagerPlugin.log(Level.SEVERE, "exception while disposing test manager", t);
+ }
+ }
+
+ /**
+ * Saves the multi-page editor's document.
+ */
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ if (getActivePage() != sourcePage) {
+ pageSourceLoad();
+ }
+ getEditor(sourcePage).doSave(monitor);
+ fileIsDirty = false;
+ fileWasSaved = true;
+ doSave();
+ firePropertyChange(PROP_DIRTY);
+ }
+
+ /**
+ * Saves the multi-page editor's document as another file. Also updates the text for page 0's tab, and updates this
+ * multi-page editor's input to correspond to the nested editor's.
+ */
+ @Override
+ public void doSaveAs() {
+ if (getActivePage() != sourcePage) {
+ pageSourceLoad();
+ }
+ IEditorPart editor = getEditor(sourcePage);
+ editor.doSaveAs();
+ setPageText(sourcePage, "Source");
+ setInput(editor.getEditorInput());
+ readXmlData();
+ doSave();
+ }
+
+ protected void registerPage(int pageNumber, String pageName) {
+ setPageText(pageNumber, pageName);
+ }
+
+ public void executionCompleted() {
+ pageManager.getScriptPage().onScriptRunning(false);
+ }
+
+ public void fireSaveNeeded() {
+ fileIsDirty = true;
+ firePropertyChange(PROP_DIRTY);
+ }
+
+ public String getAlternateOutputDir() {
+ String scriptOutput = "";
+
+ IPropertyStore propertyStore = getPropertyStore();
+ scriptOutput = propertyStore.get(TestManagerStorageKeys.SCRIPT_OUTPUT_DIRECTORY_KEY);
+ if (scriptOutput == null) {
+ scriptOutput = "";
+ // TODO: Escobar
+ // try {
+ // IEditorInput coreinput = getEditorInput();
+ // if (coreinput instanceof IFileEditorInput) {
+ // scriptOutput =
+ // thisIFile.getPersistentProperty(scriptOutputQualName);
+ // } else if (coreinput instanceof TestManagerInput) {
+ // TestManagerInput input = (TestManagerInput) getEditorInput();
+ // scriptOutput =
+ // input.getValue(scriptOutputQualName.getLocalName());
+ // }
+ //
+ // scriptOutput =
+ // thisIFile.getPersistentProperty(scriptOutputQualName);
+ // } catch (CoreException e) {
+ // e.printStackTrace();
+ // }
+ }
+ return scriptOutput;
+ }
+
+ public String getDefaultConfigPath() {
+ Location user = Platform.getUserLocation();
+ String path = user.getURL().getPath();
+ File file = new File(path + File.separator + "org.eclipse.osee.ote.ui.test.manager");
+ file.mkdirs();
+ file =
+ new File(
+ path + File.separator + "org.eclipse.osee.ote.ui.test.manager" + File.separator + this.getClass().getName() + ".scriptConfig.xml");
+ file.getParentFile().mkdirs();
+ return file.getAbsolutePath();
+ }
+
+ /**
+ * @return Returns the model.
+ */
+ public TestManagerModel getModel() {
+ return model;
+ }
+
+ public String getName() {
+ return this.getTitle();
+ }
+
+ public ClassServerInst getScriptClassServer() {
+ return ClassServerInst.getInstance();
+ }
+
+ public ITestManagerFactory getTestManagerFactory() {
+ return testManagerFactory;
+ }
+
+ @Override
+ public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
+ if (!(editorInput instanceof IFileEditorInput || editorInput instanceof TestManagerInput || editorInput instanceof IEditorInput)) {
+ throw new PartInitException("Invalid Input: Must be IFileEditorInput");
+ }
+ super.init(site, editorInput);
+ }
+
+ @Override
+ public boolean isDirty() {
+ if (super.isDirty()) {
+ return true;
+ }
+ return fileIsDirty;
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /**
+ * Retrieves the value for the key. See <code>storeValue</code>. If the key could not be found, an empty string is
+ * returned.
+ *
+ * @param key The <code>QualifiedName</code> whose value is to be retrieved.
+ * @return The value of key, or an empty string if the key does not exist.
+ */
+ public String loadValue(QualifiedName key) {
+ TestManagerPlugin.log(Level.INFO, "loadValue: " + key.getQualifier());
+ try {
+ IEditorInput coreinput = getEditorInput();
+ if (coreinput instanceof IFileEditorInput) {
+ return thisIFile.getPersistentProperty(key);
+ } else if (coreinput instanceof TestManagerInput) {
+ TestManagerInput input = (TestManagerInput) getEditorInput();
+ return input.getValue(key.getLocalName());
+ }
+ } catch (CoreException ex) {
+ TestManagerPlugin.log(Level.SEVERE, "Can't get value: " + ex);
+ }
+ return "";
+ }
+
+ public void setPageError(int page, boolean set) {
+ if (set) {
+ setPageImage(page, errorImage);
+ } else {
+ setPageImage(page, null);
+ }
+ }
+
+ /**
+ * Stores the value for the key. The key should be one of the publicly available <code>QualifiedName</code>'s in
+ * <code>this</code>.
+ *
+ * @param key The <code>QualifiedName</code> associated with the value to be stored
+ * @param value What will be stored under the key.
+ */
+ public void storeValue(QualifiedName key, String value) {
+ TestManagerPlugin.log(Level.INFO, "storeValue: " + key.getQualifier());
+ try {
+ IEditorInput coreinput = getEditorInput();
+ if (coreinput instanceof IFileEditorInput) {
+ thisIFile.setPersistentProperty(key, value);
+ } else if (coreinput instanceof TestManagerInput) {
+ TestManagerInput input = (TestManagerInput) getEditorInput();
+ input.storeValue(key.getLocalName(), value);
+ }
+ } catch (Exception ex) {
+ TestManagerPlugin.log(Level.SEVERE, "Can't set value: " + ex);
+ }
+ }
+
+ private void pageSourceCheck() {
+ setPageError(sourcePage, model.hasParseExceptions());
+ }
+
+ private void readXmlData() {
+ TestManagerPlugin.log(Level.INFO, "readXmlData");
+ IEditorInput coreinput = getEditorInput();
+ if (coreinput instanceof IFileEditorInput) {
+ IFileEditorInput input = (IFileEditorInput) getEditorInput();
+ thisIFile = input.getFile();
+ String name = thisIFile.getName();
+ this.setPartName(name);
+ model.setConfiguration(name);
+ if (thisIFile != null) {
+ IPath containerPath = thisIFile.getRawLocation();
+ model.filename = containerPath.toOSString();
+ try {
+
+ xmlText = Lib.inputStreamToString(thisIFile.getContents());
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ } else {
+ TestManagerPlugin.log(Level.SEVERE, "Can't open xml file!");
+ }
+ } else if (coreinput instanceof TestManagerInput) {
+ TestManagerInput input = (TestManagerInput) getEditorInput();
+ String name = "TestManager";
+ this.setPartName(name);
+ model.setConfiguration(name);
+ xmlText = input.getDefaultXML();
+ }
+ }
+
+ /**
+ * Creates the pages of the multi-page editor.
+ */
+ @Override
+ protected void createPages() {
+ readXmlData();
+
+ if (model.setFromXml(xmlText)) {
+ pageManager.createPages(getContainer());
+ pageSourceCreate();
+
+ fileIsDirty = false;
+ reloadSourcePage = false;
+ pageSourceCheck();
+ restoreSettings();
+ }
+ // If parse errors, send to sourcePage and set error on page
+ else {
+ if (sourceEditor == null) {
+ pageSourceCreate();
+ setActivePage(sourcePage);
+ return;
+ }
+ pageSourceCheck();
+ setPageImage(sourcePage, errorImage);
+ setActivePage(sourcePage);
+ }
+ fileIsDirty = false;
+ firePropertyChange(PROP_DIRTY);
+ TestManagerPlugin.getInstance().getOteClientService().addConnectionListener(this);
+ }
+
+ protected void handleSelection() {
+ fireSaveNeeded();
+ reloadSourcePage = true;
+ }
+
+ /**
+ * reloads pages as necessary
+ */
+ @Override
+ protected void pageChange(int newPageIndex) {
+ // NOTE: Hosts page will be updated continuously, even it if it is not
+ // the current page.
+ // so it is unnecessary to update it on pageChange.
+
+ super.pageChange(newPageIndex);
+ if (newPageIndex == sourcePage) {
+ pageSourceLoad();
+ } else {
+ if (sourceEditor == null) {
+ return;
+ }
+ String newXml = sourceEditor.getDocumentProvider().getDocument(sourceEditor.getEditorInput()).get();
+ if (sourceEditor.isDirty() || fileWasSaved) {
+ fileWasSaved = false;
+ // If we just came from sourcePage, re-parse
+ if (lastPageIndex == sourcePage) {
+ // if parse error, goto source and error
+ if (!model.setFromXml(newXml)) {
+ setActivePage(sourcePage);
+ setPageError(sourcePage, true);
+ MessageDialog.openError(getSite().getShell(), "Source Page Error",
+ "Error parsing Source page\n\n" + model.getParseExceptions());
+ return;
+ }
+ setPageError(sourcePage, false);
+ }
+ }
+ }
+ lastPageIndex = newPageIndex;
+ }
+
+ void pageSourceCreate() {
+ try {
+ if (getEditorInput() instanceof IFileEditorInput) {
+ sourceEditor = new TextEditor();
+ int index = addPage(sourceEditor, getEditorInput());
+ sourcePage = index;
+ setPageText(sourcePage, "Source");
+ }
+ } catch (PartInitException e) {
+ TestManagerPlugin.log(Level.SEVERE, "Error creating nested text editor", e);
+ ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus());
+ }
+ }
+
+ void pageSourceLoad() {
+ if (reloadSourcePage) {
+ sourceEditor.getDocumentProvider().getDocument(sourceEditor.getEditorInput()).set(model.getRawXml());
+ reloadSourcePage = false;
+ }
+ pageSourceCheck();
+ }
+
+ public void doSave() {
+ readXmlData();
+ model.setFromXml(xmlText);
+ pageManager.save();
+ OutputStream outputStream = null;
+ try {
+ File file = OseeData.getFile("testManagerSettings.xml");
+ outputStream = new FileOutputStream(file);
+ getPropertyStore().save(outputStream);
+ } catch (Exception ex) {
+ TestManagerPlugin.log(Level.SEVERE, "Error storing settings.", ex);
+ } finally {
+ if (outputStream != null) {
+ try {
+ outputStream.close();
+ } catch (IOException ex) {
+ TestManagerPlugin.log(Level.WARNING, "Error closing stream during settings storage.", ex);
+ }
+ }
+ }
+ }
+
+ public void restoreSettings() {
+ InputStream inputStream = null;
+ try {
+ File file = OseeData.getFile("testManagerSettings.xml");
+ inputStream = new FileInputStream(file);
+ getPropertyStore().load(inputStream);
+ pageManager.restore();
+ } catch (Exception ex) {
+ TestManagerPlugin.log(Level.WARNING, "Stored settings not available. Using defaults.", ex);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException ex) {
+ TestManagerPlugin.log(Level.WARNING, "Error closing stream while loading settings.", ex);
+ }
+ }
+ }
+ }
+
+ public IPropertyStore getPropertyStore() {
+ return propertyStore;
+ }
+
+ public PageManager getPageManager() {
+ return pageManager;
+ }
+
+ public String getActionDescription() {
+ String version =
+ (String) Platform.getBundle("org.eclipse.osee.ote.ui.test.manager").getHeaders().get("Bundle-Version");
+ String serverVersion = "";
+ try {
+ serverVersion = (String) Platform.getBundle("org.eclipse.osee.ote.core").getHeaders().get("Bundle-Version");
+ } catch (Exception ex) {
+ // do nothing
+ }
+ StringBuilder builder = new StringBuilder();
+ builder.append("Problem found on OSEE TM Version: ");
+ builder.append(version);
+ builder.append("\nServer Version: ");
+ builder.append(serverVersion);
+ builder.append("\nTM File: ");
+ builder.append(getTitle());
+ builder.append("\n");
+ builder.append("OFP: \"");
+ builder.append(pageManager.getScriptPage().getOFP());
+ builder.append("\"\n");
+ builder.append("Scripts: \n");
+ builder.append(pageManager.getScriptPage().getScripts());
+ builder.append("\n");
+
+ builder.append(getPropertyStore().toString());
+
+ return builder.toString();
+ }
+
+ @Override
+ public void onConnectionLost(IServiceConnector connector) {
+ connectedEnv = null;
+ connector = null;
+ boolean problemEncountered = pageManager.onConnectionLost();
+ if (problemEncountered) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openError(Displays.getActiveShell(), "Disconnect Error",
+ "Test manager has encountered a problem while processing the disconnect event. See Error Log for details");
+ }
+ });
+ }
+ connectedHost = null;
+ }
+
+ @Override
+ public void onPostConnect(ConnectionEvent event) {
+ connectedEnv = event.getEnvironment();
+ connectedHost = event.getHostEnvironment();
+ connector = event.getConnector();
+ boolean problemEncountered = pageManager.onPostConnect(event);
+ if (problemEncountered) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openError(Displays.getActiveShell(), "Connection Error",
+ "Test manager has encountered a problem while processing the connection event. See Error Log for details");
+ }
+ });
+ }
+ }
+
+ @Override
+ public void onPreDisconnect(ConnectionEvent event) {
+ event.getEnvironment();
+ connectedEnv = null;
+
+ connector = null;
+ boolean problemEncountered = pageManager.onPreDisconnect(event);
+ if (problemEncountered) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ MessageDialog.openError(Displays.getActiveShell(), "Disconnect Error",
+ "Test manager has encountered a problem while processing the disconnect event. See Error Log for details");
+ }
+ });
+ }
+ connectedHost = null;
+ }
+
+ public boolean isConnected() {
+ return connectedEnv != null;
+ }
+
+ public ITestEnvironment getConnectedEnvironment() {
+ return connectedEnv;
+ }
+
+ public IHostTestEnvironment getConnectedHostEnvironment() {
+ return connectedHost;
+ }
+
+ public IServiceConnector getConnector() {
+ return connector;
+ }
+
+ public abstract void createHostWidget(Composite parent);
+
+ /**
+ * @param array
+ */
+ public void addFiles(String[] files) {
+ pageManager.getScriptPage().addFiles(files);
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/ScriptRunJob.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/ScriptRunJob.java
index 5367e82a330..6a716bbfecd 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/ScriptRunJob.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/ScriptRunJob.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.test.manager.jobs;
-
+package org.eclipse.osee.ote.ui.test.manager.jobs;
+
import java.io.File;
import java.util.LinkedList;
import java.util.List;
@@ -20,128 +20,127 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.ote.ui.test.manager.core.TestManagerEditor;
import org.eclipse.osee.ote.ui.test.manager.internal.TestManagerPlugin;
import org.eclipse.osee.ote.ui.test.manager.pages.ScriptPage;
import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ScriptRunJob extends Job {
- private static final String JOB_NAME = "Script Run Job";
-
- private final TestManagerEditor testManagerEditor;
- private final List<ScriptTask> runTasks;
-
- public ScriptRunJob(TestManagerEditor testManagerEditor) {
- super(JOB_NAME);
- this.testManagerEditor = testManagerEditor;
- this.testManagerEditor.doSave();
- ScriptPage scriptPage = getScriptPage();
- scriptPage.getScriptTableViewer().refresh();
- this.runTasks = scriptPage.getScriptTableViewer().getRunTasks();
- }
-
- public IStatus verifyOutfileLocations() {
- final LinkedList<IStatus> failedLocations = new LinkedList<IStatus>();
- for (ScriptTask task : runTasks) {
- final String fileName = task.getScriptModel().getOutputModel().getRawFilename();
- final File file = new File(fileName);
- if (file.exists() && (!file.canWrite() || !file.canRead())) {
- failedLocations.add(new Status(Status.ERROR, TestManagerPlugin.PLUGIN_ID, "could not access " + fileName));
- } else if (!file.getParentFile().canWrite()) {
- failedLocations.add(new Status(Status.ERROR, TestManagerPlugin.PLUGIN_ID, "could not access " + fileName));
- }
- }
- if (failedLocations.isEmpty()) {
- return Status.OK_STATUS;
- } else {
- return new Status(Status.ERROR, TestManagerPlugin.PLUGIN_ID, "unable to access out files") {
-
- @Override
- public boolean isMultiStatus() {
- return true;
- }
-
- @Override
- public IStatus[] getChildren() {
- return failedLocations.toArray(new IStatus[failedLocations.size()]);
- }
-
- };
- }
- }
-
- @Override
- public IStatus run(IProgressMonitor monitor) {
- IStatus toReturn = Status.CANCEL_STATUS;
- final IStatus status = verifyOutfileLocations();
-
- if (status != Status.OK_STATUS) {
- Display.getDefault().syncExec(new Runnable() {
-
- @Override
- public void run() {
- ErrorDialog.openError(
- Display.getDefault().getActiveShell(),
- "Script Run Error",
- "Could not access some out file locations. Check access permissions. Click Details to see a list of failed locations",
- status, -1);
- }
-
- });
-
- return Status.OK_STATUS;
- }
-
- long time = System.currentTimeMillis();
-
- clearMarkers();
- getScriptPage().onScriptRunning(true);
-
- long elapsed = System.currentTimeMillis() - time;
- OseeLog.log(TestManagerPlugin.class, Level.FINE, String.format("%d milliseconds to initialize the running of scripts.", elapsed));
- OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("%d scripts have been batched.", runTasks.size()));
-
- Display.getDefault().syncExec(new Runnable() {
-
- @Override
- public void run() {
- getScriptPage().getScriptManager().addTestsToQueue(runTasks);
- }
-
- });
- toReturn = Status.OK_STATUS;
- return toReturn;
- }
-
- private ScriptPage getScriptPage() {
- return this.testManagerEditor.getPageManager().getScriptPage();
- }
-
- public boolean isRunAllowed() {
-
- return this.testManagerEditor.getPageManager().areSettingsValidForRun();
-
- }
-
- private void clearMarkers() {
- // TODO can we somehow wait until the script is actually run to remove
- // the markers? Otherwise if the run is aborted before the script
- // runs...
-
- // Remove markers from scripts to be run
- // for (ScriptTask task : runTasks) {
- // try {
- // MarkerSupport.deleteMarkersFromInputFile(task.getScriptModel().getIFile());
- // }
- // catch (Exception ex) {
- // OseeLog.log(Activator.class, Level.SEVERE, "Unable to clear the tests markers before
- // running the test.", ex);
- // }
- // }
- }
-
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ScriptRunJob extends Job {
+ private static final String JOB_NAME = "Script Run Job";
+
+ private final TestManagerEditor testManagerEditor;
+ private final List<ScriptTask> runTasks;
+
+ public ScriptRunJob(TestManagerEditor testManagerEditor) {
+ super(JOB_NAME);
+ this.testManagerEditor = testManagerEditor;
+ this.testManagerEditor.doSave();
+ ScriptPage scriptPage = getScriptPage();
+ scriptPage.getScriptTableViewer().refresh();
+ this.runTasks = scriptPage.getScriptTableViewer().getRunTasks();
+ }
+
+ public IStatus verifyOutfileLocations() {
+ final LinkedList<IStatus> failedLocations = new LinkedList<IStatus>();
+ for (ScriptTask task : runTasks) {
+ final String fileName = task.getScriptModel().getOutputModel().getRawFilename();
+ final File file = new File(fileName);
+ if (file.exists() && (!file.canWrite() || !file.canRead())) {
+ failedLocations.add(new Status(Status.ERROR, TestManagerPlugin.PLUGIN_ID, "could not access " + fileName));
+ } else if (!file.getParentFile().canWrite()) {
+ failedLocations.add(new Status(Status.ERROR, TestManagerPlugin.PLUGIN_ID, "could not access " + fileName));
+ }
+ }
+ if (failedLocations.isEmpty()) {
+ return Status.OK_STATUS;
+ } else {
+ return new Status(Status.ERROR, TestManagerPlugin.PLUGIN_ID, "unable to access out files") {
+
+ @Override
+ public boolean isMultiStatus() {
+ return true;
+ }
+
+ @Override
+ public IStatus[] getChildren() {
+ return failedLocations.toArray(new IStatus[failedLocations.size()]);
+ }
+
+ };
+ }
+ }
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) {
+ IStatus toReturn = Status.CANCEL_STATUS;
+ final IStatus status = verifyOutfileLocations();
+
+ if (status != Status.OK_STATUS) {
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ ErrorDialog.openError(
+ Displays.getActiveShell(),
+ "Script Run Error",
+ "Could not access some out file locations. Check access permissions. Click Details to see a list of failed locations",
+ status, -1);
+ }
+
+ });
+
+ return Status.OK_STATUS;
+ }
+
+ long time = System.currentTimeMillis();
+
+ clearMarkers();
+ getScriptPage().onScriptRunning(true);
+
+ long elapsed = System.currentTimeMillis() - time;
+ OseeLog.log(TestManagerPlugin.class, Level.FINE,
+ String.format("%d milliseconds to initialize the running of scripts.", elapsed));
+ OseeLog.log(TestManagerPlugin.class, Level.INFO, String.format("%d scripts have been batched.", runTasks.size()));
+
+ Displays.pendInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ getScriptPage().getScriptManager().addTestsToQueue(runTasks);
+ }
+
+ });
+ toReturn = Status.OK_STATUS;
+ return toReturn;
+ }
+
+ private ScriptPage getScriptPage() {
+ return this.testManagerEditor.getPageManager().getScriptPage();
+ }
+
+ public boolean isRunAllowed() {
+
+ return this.testManagerEditor.getPageManager().areSettingsValidForRun();
+
+ }
+
+ private void clearMarkers() {
+ // TODO can we somehow wait until the script is actually run to remove
+ // the markers? Otherwise if the run is aborted before the script
+ // runs...
+
+ // Remove markers from scripts to be run
+ // for (ScriptTask task : runTasks) {
+ // try {
+ // MarkerSupport.deleteMarkersFromInputFile(task.getScriptModel().getIFile());
+ // }
+ // catch (Exception ex) {
+ // OseeLog.log(Activator.class, Level.SEVERE, "Unable to clear the tests markers before
+ // running the test.", ex);
+ // }
+ // }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/StoreOutfileJob.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/StoreOutfileJob.java
index 57ccf219a0b..1bbecc39cee 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/StoreOutfileJob.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/jobs/StoreOutfileJob.java
@@ -38,133 +38,129 @@ import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask;
*/
public class StoreOutfileJob extends Job {
- private final ScriptManager userEnvironment;
- private final ScriptTask scriptTask;
- private final boolean isValidRun;
- private final TestManagerEditor testManagerEditor;
- private final ITestEnvironment env;
+ private final ScriptManager userEnvironment;
+ private final ScriptTask scriptTask;
+ private final boolean isValidRun;
+ private final TestManagerEditor testManagerEditor;
+ private final ITestEnvironment env;
- private final String clientOutfilePath;
+ private final String clientOutfilePath;
- private final String serverOutfilePath;
+ private final String serverOutfilePath;
- public StoreOutfileJob(ITestEnvironment env, TestManagerEditor testManagerEditor, ScriptManager userEnvironment, ScriptTask scriptTask, String clientOutfilePath, String serverOutfilePath, boolean isValidRun) {
- super("Store: " + scriptTask.getName());
- this.env = env;
- this.scriptTask = scriptTask;
- this.testManagerEditor = testManagerEditor;
- this.userEnvironment = userEnvironment;
- this.isValidRun = isValidRun;
- this.clientOutfilePath = clientOutfilePath;
- this.serverOutfilePath = serverOutfilePath;
- }
+ public StoreOutfileJob(ITestEnvironment env, TestManagerEditor testManagerEditor, ScriptManager userEnvironment, ScriptTask scriptTask, String clientOutfilePath, String serverOutfilePath, boolean isValidRun) {
+ super("Store: " + scriptTask.getName());
+ this.env = env;
+ this.scriptTask = scriptTask;
+ this.testManagerEditor = testManagerEditor;
+ this.userEnvironment = userEnvironment;
+ this.isValidRun = isValidRun;
+ this.clientOutfilePath = clientOutfilePath;
+ this.serverOutfilePath = serverOutfilePath;
+ }
- public static void scheduleJob(Job job) {
- job.setUser(false);
- job.setPriority(Job.SHORT);
- job.schedule();
- }
+ public static void scheduleJob(Job job) {
+ job.setUser(false);
+ job.setPriority(Job.SHORT);
+ job.schedule();
+ }
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- if (isValidRun == true) {
- try {
- storeOutfile(scriptTask);
- } catch (Exception e) {
- return new Status(Status.ERROR, TestManagerPlugin.PLUGIN_ID, "Failed to write out file to workspace", e);
- }
- }
- // scriptTask.computeExists();
- userEnvironment.updateScriptTableViewer(scriptTask);
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- // Display.getDefault().asyncExec(new Runnable() {
- // public void run() {
- processOutFile(scriptTask);
- // }
- // });
- } catch (Exception ex) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
- }
- return Status.OK_STATUS;
- }
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ if (isValidRun == true) {
+ try {
+ storeOutfile(scriptTask);
+ } catch (Exception e) {
+ return new Status(Status.ERROR, TestManagerPlugin.PLUGIN_ID, "Failed to write out file to workspace", e);
+ }
+ }
+ // scriptTask.computeExists();
+ userEnvironment.updateScriptTableViewer(scriptTask);
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ processOutFile(scriptTask);
+ } catch (Exception ex) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, ex);
+ }
+ return Status.OK_STATUS;
+ }
- public void processOutFile(ScriptTask task) {
- OseeLog.log(TestManagerPlugin.class, Level.INFO, "Processing Outfile: " + task.getName());
- // task.computeExists();
- File xmlSourceFile = task.getScriptModel().getOutputModel().getFile();
- IFile javaSourceIFile = task.getScriptModel().getIFile();
+ public void processOutFile(ScriptTask task) {
+ OseeLog.log(TestManagerPlugin.class, Level.INFO, "Processing Outfile: " + task.getName());
+ // task.computeExists();
+ File xmlSourceFile = task.getScriptModel().getOutputModel().getFile();
+ IFile javaSourceIFile = task.getScriptModel().getIFile();
- if (!xmlSourceFile.exists()) {
- TestManagerPlugin.getInstance().getOteConsoleService().writeError("Output File Not Created");
- } else {
- // Refresh the parent so the workspace knows the new tmo file exists
- AWorkspace.refreshResource(javaSourceIFile);
- task.getScriptModel().getOutputModel().updateTestPointsFromOutfile();
- int failedPoints = task.getScriptModel().getOutputModel().getFailedTestPoints();
- userEnvironment.updateScriptTableViewer(scriptTask);
- if (failedPoints > 0) {
- // Print fails in red, but don't force the console to popup
- TestManagerPlugin.getInstance().getOteConsoleService().write(
- String.format("Test Point Failures => %s[%d]", task.getName(), failedPoints),
- OseeConsole.CONSOLE_ERROR, false);
- }
- }
- }
+ if (!xmlSourceFile.exists()) {
+ TestManagerPlugin.getInstance().getOteConsoleService().writeError("Output File Not Created");
+ } else {
+ // Refresh the parent so the workspace knows the new tmo file exists
+ AWorkspace.refreshResource(javaSourceIFile);
+ task.getScriptModel().getOutputModel().updateTestPointsFromOutfile();
+ int failedPoints = task.getScriptModel().getOutputModel().getFailedTestPoints();
+ userEnvironment.updateScriptTableViewer(scriptTask);
+ if (failedPoints > 0) {
+ // Print fails in red, but don't force the console to popup
+ TestManagerPlugin.getInstance().getOteConsoleService().write(
+ String.format("Test Point Failures => %s[%d]", task.getName(), failedPoints),
+ OseeConsole.CONSOLE_ERROR, false);
+ }
+ }
+ }
- private boolean isKeepSavedOutfileEnabled() {
- return testManagerEditor.getPropertyStore().getBoolean(TestManagerStorageKeys.KEEP_OLD_OUTFILE_COPIES_ENABLED_KEY);
- }
+ private boolean isKeepSavedOutfileEnabled() {
+ return testManagerEditor.getPropertyStore().getBoolean(TestManagerStorageKeys.KEEP_OLD_OUTFILE_COPIES_ENABLED_KEY);
+ }
- private void storeOutfile(ScriptTask scriptTask) throws Exception {
- if (clientOutfilePath.equals(serverOutfilePath) != true) {
- // the paths are different so we need to copy the file
- byte[] outBytes = env.getScriptOutfile(serverOutfilePath);
- if (outBytes != null && outBytes.length > 0) {
+ private void storeOutfile(ScriptTask scriptTask) throws Exception {
+ if (clientOutfilePath.equals(serverOutfilePath) != true) {
+ // the paths are different so we need to copy the file
+ byte[] outBytes = env.getScriptOutfile(serverOutfilePath);
+ if (outBytes != null && outBytes.length > 0) {
- if (isKeepSavedOutfileEnabled()) {
- moveOutputToNextAvailableSpot(scriptTask);
- }
- // else {
- // task.getScriptModel().getOutputModel().getIFile().delete(true, null);
- // }
- IFile file = AIFile.constructIFile(clientOutfilePath);
- if (file != null) {
- AIFile.writeToFile(file, new ByteArrayInputStream(outBytes));
- MarkerPlugin.getDefault().addMarkers(file);
- } else {
- Lib.writeBytesToFile(outBytes, new File(clientOutfilePath));
- }
- }
- }
- }
+ if (isKeepSavedOutfileEnabled()) {
+ moveOutputToNextAvailableSpot(scriptTask);
+ }
+ // else {
+ // task.getScriptModel().getOutputModel().getIFile().delete(true, null);
+ // }
+ IFile file = AIFile.constructIFile(clientOutfilePath);
+ if (file != null) {
+ AIFile.writeToFile(file, new ByteArrayInputStream(outBytes));
+ MarkerPlugin.getDefault().addMarkers(file);
+ } else {
+ Lib.writeBytesToFile(outBytes, new File(clientOutfilePath));
+ }
+ }
+ }
+ }
- private void moveOutputToNextAvailableSpot(ScriptTask task) {
- OutputModel outputModel = task.getScriptModel().getOutputModel();
- File oldFile = outputModel.getFile();
- if (oldFile != null && oldFile.exists() && oldFile.isFile() && oldFile.canRead()) {
- String outputExtension = "." + outputModel.getFileExtension();
- int fileNum = 1;
- File destFile =
- new File(oldFile.getAbsoluteFile().toString().replaceFirst(outputExtension,
- "." + fileNum + outputExtension));
- if (destFile.exists()) {
- while (destFile.exists()) {
- fileNum++;
- destFile =
- new File(oldFile.getAbsoluteFile().toString().replaceFirst(outputExtension,
- "." + fileNum + outputExtension));
- }
- }
- try {
- Lib.copyFile(oldFile, destFile);
- } catch (IOException e2) {
- OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Failed to move output file to next available spot", e2);
- }
- }
- }
+ private void moveOutputToNextAvailableSpot(ScriptTask task) {
+ OutputModel outputModel = task.getScriptModel().getOutputModel();
+ File oldFile = outputModel.getFile();
+ if (oldFile != null && oldFile.exists() && oldFile.isFile() && oldFile.canRead()) {
+ String outputExtension = "." + outputModel.getFileExtension();
+ int fileNum = 1;
+ File destFile =
+ new File(oldFile.getAbsoluteFile().toString().replaceFirst(outputExtension,
+ "." + fileNum + outputExtension));
+ if (destFile.exists()) {
+ while (destFile.exists()) {
+ fileNum++;
+ destFile =
+ new File(oldFile.getAbsoluteFile().toString().replaceFirst(outputExtension,
+ "." + fileNum + outputExtension));
+ }
+ }
+ try {
+ Lib.copyFile(oldFile, destFile);
+ } catch (IOException e2) {
+ OseeLog.log(TestManagerPlugin.class, Level.SEVERE, "Failed to move output file to next available spot", e2);
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/ScriptPage.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/ScriptPage.java
index c41a48b1750..3e25d48db1f 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/ScriptPage.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/ScriptPage.java
@@ -19,6 +19,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.plugin.OseeUiActivator;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.ote.service.ConnectionEvent;
import org.eclipse.osee.ote.ui.test.manager.OteTestManagerImage;
@@ -39,7 +40,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
@@ -49,421 +49,419 @@ import org.eclipse.ui.PlatformUI;
public abstract class ScriptPage extends TestManagerPage {
- private static final String NOT_CONNECTED = "<< NOT_CONNECTED >>";
-
- public enum UpdateableLabel {
- HOSTLABEL,
- CONFIGPATHLABEL;
- }
-
- public static final OseeUiActivator plugin = TestManagerPlugin.getInstance();
- private static final String pageName = "Scripts";
- private ToolItem abortButton;
- private ToolItem abortBatchButton;
- private CoolBar coolBar;
- private ToolItem deleteButton;
- private Label hostConnectLabel;
- private LoadWidget loadWidget;
- protected ToolItem runButton;
- private SaveWidget saveWidget;
- private ScriptTableViewer scriptTable;
- private StatusWindowWidget statusWindow;
- private final TestManagerEditor testManagerEditor;
-
- public ScriptPage(Composite parent, int style, TestManagerEditor parentTestManager) {
- super(parent, style, parentTestManager);
- this.testManagerEditor = parentTestManager;
- }
-
- public void addFile(String fullPath) {
- scriptTable.addFile(fullPath);
- }
-
- @Override
- public void createPage() {
- super.createPage();
- Composite parent = (Composite) getContent();
- coolBar = new CoolBar(parent, SWT.FLAT);
-
- createControlsToolBar(coolBar);
- createConfigurationToolBar(coolBar);
- packCoolBar();
-
- SashForm sashForm = new SashForm(parent, SWT.NONE);
- sashForm.setLayout(new GridLayout());
- sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- sashForm.setOrientation(SWT.VERTICAL);
- sashForm.SASH_WIDTH = 3;
-
- createScriptTableSection(sashForm);
- createStatusWindow(sashForm);
-
- sashForm.setWeights(new int[] {8, 2});
- computeScrollSize();
-
- TestManagerPlugin.getInstance().setHelp(this, "tm_scripts_page", "org.eclipse.osee.framework.help.ui");
- }
-
- public void loadStorageString() {
- scriptTable.loadStorageString(testManagerEditor.loadValue(testManagerEditor.scriptsQualName));
- }
-
- @Override
- public void dispose() {
- scriptTable.dispose();
- testManagerEditor.storeValue(testManagerEditor.scriptsQualName, scriptTable.getStorageString());
- OseeLog.log(TestManagerPlugin.class, Level.INFO, "ScriptPage Dispose Called");
- super.dispose();
- }
-
- public CoolBar getCoolBar() {
- return coolBar;
- }
-
- public String getOFP() {
- if (hostConnectLabel == null) {
- return "";
- }
- return hostConnectLabel.getText();
- }
-
- @Override
- public String getPageName() {
- return pageName;
- }
-
- public String getScripts() {
- if (scriptTable == null) {
- return "";
- } else if (scriptTable.getTaskList() == null) {
- return "";
- }
- return scriptTable.getTaskList().toString();
- }
-
- public ScriptTableViewer getScriptTableViewer() {
- return scriptTable;
- }
-
- public StatusWindowWidget getStatusWindow() {
- return statusWindow;
- }
-
- public void onScriptRunning(final boolean running) {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (running) {
- runButton.setEnabled(false);
- abortButton.setEnabled(true);
- abortBatchButton.setEnabled(true);
- } else {
- runButton.setEnabled(true);
- abortButton.setEnabled(false);
- abortBatchButton.setEnabled(false);
- }
- }
- });
- }
-
- public void packCoolBar() {
- Point size = this.getSize();
- coolBar.setSize(coolBar.computeSize(size.x, size.y));
- }
-
- private void createConfigurationToolBar(CoolBar coolBar) {
- CoolItem configCoolItem = new CoolItem(coolBar, SWT.NONE);
- ToolBar configToolBar = new ToolBar(coolBar, SWT.FLAT | SWT.HORIZONTAL);
-
- saveWidget = new SaveWidget(this);
- saveWidget.createToolItem(configToolBar);
-
- loadWidget = new LoadWidget(this);
- loadWidget.createToolItem(configToolBar);
-
- deleteButton = new ToolItem(configToolBar, SWT.PUSH | SWT.CENTER);
- deleteButton.setImage(ImageManager.getImage(OteTestManagerImage.FILE_DELETE));
- deleteButton.setToolTipText("Deletes Selected (highlighted) Scripts");
- deleteButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleDeleteButton();
- }
- });
- deleteButton.addListener(SWT.MouseUp, new Listener() {
- public void handleEvent(Event e) {
- if (e.button == 3) {
- handleDeleteButton();
- }
- }
- });
-
- configToolBar.pack();
-
- Point size = configToolBar.getSize();
- configCoolItem.setControl(configToolBar);
- configCoolItem.setSize(configCoolItem.computeSize(size.x, size.y));
- configCoolItem.setMinimumSize(size);
- }
-
- private void createControlsToolBar(CoolBar coolBar) {
- CoolItem controlsCoolItem = new CoolItem(coolBar, SWT.NONE);
- ToolBar controlsToolBar = new ToolBar(coolBar, SWT.FLAT | SWT.HORIZONTAL);
-
- runButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER);
- runButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_RUN_EXEC));
- runButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_RUN_EXEC));
- runButton.setToolTipText("Runs the Checked Scripts");
- runButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleRunButton();
- }
- });
- runButton.addListener(SWT.MouseUp, new Listener() {
- public void handleEvent(Event e) {
- if (e.button == 3) {
- handleRunButton();
- }
- }
- });
- runButton.setEnabled(false);
-
- // Create and configure the "Abort" button
- abortButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER);
- abortButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_ABORT_STOP));
- abortButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_ABORT_STOP));
- abortButton.setToolTipText("Abort Currently Running Script");
- abortButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleAbortButton();
- abortBatchButton.setEnabled(false);
- abortButton.setEnabled(false);
- Timer timer = new Timer();
- timer.schedule(new EnabledAbortsTimer(), 30000);
- }
- });
- abortButton.addListener(SWT.MouseUp, new Listener() {
- public void handleEvent(Event e) {
- if (e.button == 3) {
- handleAbortButton();
- abortBatchButton.setEnabled(false);
- abortButton.setEnabled(false);
- Timer timer = new Timer();
- timer.schedule(new EnabledAbortsTimer(), 30000);
- }
- }
- });
- abortButton.setEnabled(false);
-
- abortBatchButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER);
- abortBatchButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_BATCH_ABORT_STOP));
- abortBatchButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_BATCH_ABORT_STOP));
- abortBatchButton.setToolTipText("Abort Script Batch");
- abortBatchButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleBatchAbortButton();
- abortBatchButton.setEnabled(false);
- abortButton.setEnabled(false);
- Timer timer = new Timer();
- timer.schedule(new EnabledAbortsTimer(), 30000);
- }
- });
- abortBatchButton.addListener(SWT.MouseUp, new Listener() {
- public void handleEvent(Event e) {
- if (e.button == 3) {
- handleBatchAbortButton();
- abortBatchButton.setEnabled(false);
- abortButton.setEnabled(false);
- Timer timer = new Timer();
- timer.schedule(new EnabledAbortsTimer(), 30000);
- }
- }
- });
- abortBatchButton.setEnabled(false);
-
- controlsToolBar.pack();
-
- Point size = controlsToolBar.getSize();
- controlsCoolItem.setControl(controlsToolBar);
- controlsCoolItem.setSize(controlsCoolItem.computeSize(size.x, size.y));
- controlsCoolItem.setMinimumSize(size);
- }
-
- private void createScriptTableSection(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- scriptTable = new ScriptTableViewer(composite, this.getTestManager());
- // scriptTable.addDisposeListener(new DisposeListener() {
- // public void widgetDisposed(DisposeEvent e) {
- // testManagerEditor.storeValue(testManagerEditor.scriptsQualName, scriptTable.getStorageString());
- // }
- // });
-
- }
-
- private void createStatusWindow(Composite parent) {
- statusWindow = new StatusWindowWidget(parent);
-
- statusWindow.setLabelAndValue(UpdateableLabel.HOSTLABEL.name(), "Selected Host", NOT_CONNECTED, SWT.BOLD,
- SWT.COLOR_DARK_RED);
-
- String selectedFile = testManagerEditor.loadValue(testManagerEditor.configFileName);
- if (selectedFile == null || selectedFile.equals("")) {
- selectedFile = testManagerEditor.getDefaultConfigPath();
- testManagerEditor.storeValue(testManagerEditor.configFileName, selectedFile);
- }
- OseeLog.log(TestManagerPlugin.class, Level.INFO, "The default config is: " + selectedFile);
-
- statusWindow.setLabelAndValue(UpdateableLabel.CONFIGPATHLABEL.name(), "Config File Path", selectedFile);
-
- saveWidget.setStatusLabel(statusWindow);
- loadWidget.setStatusLabel(statusWindow);
-
- // // Status ICON Labels
- // connectStatusIconLabel = new
- // Label(statusWindow.getStatusIconComposite(), SWT.NONE);
- // hostWidget.setConnectStatusLabel(connectStatusIconLabel);
- // connectStatusIconLabel.setVisible(false);
-
- statusWindow.refresh();
- }
-
- // TODO this stuff needs some updating too...
- protected void handleAbortButton() {
- TestManagerPlugin.getInstance().getOteConsoleService().write("Aborting Test Script...");
- try {
- getScriptManager().abortScript(false);
- } catch (RemoteException e) {
- TestManagerPlugin.getInstance().getOteConsoleService().writeError(Lib.exceptionToString(e));
- }
- }
-
- // TODO this stuff needs some updating too...
- protected void handleBatchAbortButton() {
- TestManagerPlugin.getInstance().getOteConsoleService().write("Aborting Test Script Batch...");
- try {
- getScriptManager().abortScript(true);
- } catch (RemoteException e) {
- TestManagerPlugin.getInstance().getOteConsoleService().writeError(Lib.exceptionToString(e));
- }
- }
-
- private void handleDeleteButton() {
- scriptTable.removeSelectedTasks();
- }
-
- private void handleRunButton() {
- ScriptRunJob runJob = new ScriptRunJob(getTestManager());
- if (runJob.isRunAllowed()) {
- runJob.setPriority(Job.LONG);
- runJob.setUser(true);
- runJob.schedule();
- } else {
- MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", "Test Manager Settings Error");
- }
- }
-
- private class EnabledAbortsTimer extends TimerTask {
-
- @Override
- public void run() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- try {
- if (!runButton.isEnabled()) {
- abortBatchButton.setEnabled(true);
- abortButton.setEnabled(true);
- }
- } catch (Throwable th) {
-
- }
- }
- });
-
- }
-
- }
-
- @Override
- public boolean areSettingsValidForRun() {
- return getScriptTableViewer().getRunTasks().size() > 0;
- }
-
- @Override
- public String getErrorMessage() {
- StringBuilder builder = new StringBuilder();
- if (getScriptTableViewer().getRunTasks().size() <= 0) {
- builder.append("Scripts not selected.");
- }
- return builder.toString();
- }
-
- @Override
- public boolean onConnection(final ConnectionEvent event) {
- boolean result = getScriptManager().connect(event);
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- runButton.setEnabled(true);
- abortButton.setEnabled(false);
- abortBatchButton.setEnabled(false);
- scriptTable.onConnectionChanged(true);
- statusWindow.setValue(UpdateableLabel.HOSTLABEL.name(), event.getProperties().getStation(), SWT.BOLD,
- SWT.COLOR_DARK_GREEN);
- statusWindow.refresh();
- }
-
- });
- return result;
- }
-
- @Override
- public boolean onDisconnect(ConnectionEvent event) {
- boolean result = getScriptManager().disconnect(event);
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- runButton.setEnabled(false);
- abortButton.setEnabled(false);
- abortBatchButton.setEnabled(false);
- scriptTable.onConnectionChanged(false);
- statusWindow.setValue(UpdateableLabel.HOSTLABEL.name(), NOT_CONNECTED, SWT.BOLD, SWT.COLOR_DARK_RED);
- statusWindow.refresh();
- }
- });
- return result;
- }
-
- @Override
- public boolean onConnectionLost() {
- boolean result = getScriptManager().onConnectionLost();
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- runButton.setEnabled(false);
- abortButton.setEnabled(false);
- abortBatchButton.setEnabled(false);
- scriptTable.onConnectionChanged(false);
- statusWindow.setValue(UpdateableLabel.HOSTLABEL.name(), NOT_CONNECTED, SWT.BOLD, SWT.COLOR_DARK_RED);
- statusWindow.refresh();
- }
- });
- return result;
- }
-
- public abstract ScriptManager getScriptManager();
-
- /**
- * @param files
- */
- public void addFiles(String[] files) {
- scriptTable.addFiles(files);
- }
+ private static final String NOT_CONNECTED = "<< NOT_CONNECTED >>";
+
+ public enum UpdateableLabel {
+ HOSTLABEL,
+ CONFIGPATHLABEL;
+ }
+
+ public static final OseeUiActivator plugin = TestManagerPlugin.getInstance();
+ private static final String pageName = "Scripts";
+ private ToolItem abortButton;
+ private ToolItem abortBatchButton;
+ private CoolBar coolBar;
+ private ToolItem deleteButton;
+ private Label hostConnectLabel;
+ private LoadWidget loadWidget;
+ protected ToolItem runButton;
+ private SaveWidget saveWidget;
+ private ScriptTableViewer scriptTable;
+ private StatusWindowWidget statusWindow;
+ private final TestManagerEditor testManagerEditor;
+
+ public ScriptPage(Composite parent, int style, TestManagerEditor parentTestManager) {
+ super(parent, style, parentTestManager);
+ this.testManagerEditor = parentTestManager;
+ }
+
+ public void addFile(String fullPath) {
+ scriptTable.addFile(fullPath);
+ }
+
+ @Override
+ public void createPage() {
+ super.createPage();
+ Composite parent = (Composite) getContent();
+ coolBar = new CoolBar(parent, SWT.FLAT);
+
+ createControlsToolBar(coolBar);
+ createConfigurationToolBar(coolBar);
+ packCoolBar();
+
+ SashForm sashForm = new SashForm(parent, SWT.NONE);
+ sashForm.setLayout(new GridLayout());
+ sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ sashForm.setOrientation(SWT.VERTICAL);
+ sashForm.SASH_WIDTH = 3;
+
+ createScriptTableSection(sashForm);
+ createStatusWindow(sashForm);
+
+ sashForm.setWeights(new int[] {8, 2});
+ computeScrollSize();
+
+ TestManagerPlugin.getInstance().setHelp(this, "tm_scripts_page", "org.eclipse.osee.framework.help.ui");
+ }
+
+ public void loadStorageString() {
+ scriptTable.loadStorageString(testManagerEditor.loadValue(testManagerEditor.scriptsQualName));
+ }
+
+ @Override
+ public void dispose() {
+ scriptTable.dispose();
+ testManagerEditor.storeValue(testManagerEditor.scriptsQualName, scriptTable.getStorageString());
+ OseeLog.log(TestManagerPlugin.class, Level.INFO, "ScriptPage Dispose Called");
+ super.dispose();
+ }
+
+ public CoolBar getCoolBar() {
+ return coolBar;
+ }
+
+ public String getOFP() {
+ if (hostConnectLabel == null) {
+ return "";
+ }
+ return hostConnectLabel.getText();
+ }
+
+ @Override
+ public String getPageName() {
+ return pageName;
+ }
+
+ public String getScripts() {
+ if (scriptTable == null) {
+ return "";
+ } else if (scriptTable.getTaskList() == null) {
+ return "";
+ }
+ return scriptTable.getTaskList().toString();
+ }
+
+ public ScriptTableViewer getScriptTableViewer() {
+ return scriptTable;
+ }
+
+ public StatusWindowWidget getStatusWindow() {
+ return statusWindow;
+ }
+
+ public void onScriptRunning(final boolean running) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (running) {
+ runButton.setEnabled(false);
+ abortButton.setEnabled(true);
+ abortBatchButton.setEnabled(true);
+ } else {
+ runButton.setEnabled(true);
+ abortButton.setEnabled(false);
+ abortBatchButton.setEnabled(false);
+ }
+ }
+ });
+ }
+
+ public void packCoolBar() {
+ Point size = this.getSize();
+ coolBar.setSize(coolBar.computeSize(size.x, size.y));
+ }
+
+ private void createConfigurationToolBar(CoolBar coolBar) {
+ CoolItem configCoolItem = new CoolItem(coolBar, SWT.NONE);
+ ToolBar configToolBar = new ToolBar(coolBar, SWT.FLAT | SWT.HORIZONTAL);
+
+ saveWidget = new SaveWidget(this);
+ saveWidget.createToolItem(configToolBar);
+
+ loadWidget = new LoadWidget(this);
+ loadWidget.createToolItem(configToolBar);
+
+ deleteButton = new ToolItem(configToolBar, SWT.PUSH | SWT.CENTER);
+ deleteButton.setImage(ImageManager.getImage(OteTestManagerImage.FILE_DELETE));
+ deleteButton.setToolTipText("Deletes Selected (highlighted) Scripts");
+ deleteButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleDeleteButton();
+ }
+ });
+ deleteButton.addListener(SWT.MouseUp, new Listener() {
+ public void handleEvent(Event e) {
+ if (e.button == 3) {
+ handleDeleteButton();
+ }
+ }
+ });
+
+ configToolBar.pack();
+
+ Point size = configToolBar.getSize();
+ configCoolItem.setControl(configToolBar);
+ configCoolItem.setSize(configCoolItem.computeSize(size.x, size.y));
+ configCoolItem.setMinimumSize(size);
+ }
+
+ private void createControlsToolBar(CoolBar coolBar) {
+ CoolItem controlsCoolItem = new CoolItem(coolBar, SWT.NONE);
+ ToolBar controlsToolBar = new ToolBar(coolBar, SWT.FLAT | SWT.HORIZONTAL);
+
+ runButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER);
+ runButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_RUN_EXEC));
+ runButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_RUN_EXEC));
+ runButton.setToolTipText("Runs the Checked Scripts");
+ runButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleRunButton();
+ }
+ });
+ runButton.addListener(SWT.MouseUp, new Listener() {
+ public void handleEvent(Event e) {
+ if (e.button == 3) {
+ handleRunButton();
+ }
+ }
+ });
+ runButton.setEnabled(false);
+
+ // Create and configure the "Abort" button
+ abortButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER);
+ abortButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_ABORT_STOP));
+ abortButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_ABORT_STOP));
+ abortButton.setToolTipText("Abort Currently Running Script");
+ abortButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleAbortButton();
+ abortBatchButton.setEnabled(false);
+ abortButton.setEnabled(false);
+ Timer timer = new Timer();
+ timer.schedule(new EnabledAbortsTimer(), 30000);
+ }
+ });
+ abortButton.addListener(SWT.MouseUp, new Listener() {
+ public void handleEvent(Event e) {
+ if (e.button == 3) {
+ handleAbortButton();
+ abortBatchButton.setEnabled(false);
+ abortButton.setEnabled(false);
+ Timer timer = new Timer();
+ timer.schedule(new EnabledAbortsTimer(), 30000);
+ }
+ }
+ });
+ abortButton.setEnabled(false);
+
+ abortBatchButton = new ToolItem(controlsToolBar, SWT.PUSH | SWT.CENTER);
+ abortBatchButton.setImage(ImageManager.getImage(OteTestManagerImage.SEL_BATCH_ABORT_STOP));
+ abortBatchButton.setDisabledImage(ImageManager.getImage(OteTestManagerImage.UNSEL_BATCH_ABORT_STOP));
+ abortBatchButton.setToolTipText("Abort Script Batch");
+ abortBatchButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleBatchAbortButton();
+ abortBatchButton.setEnabled(false);
+ abortButton.setEnabled(false);
+ Timer timer = new Timer();
+ timer.schedule(new EnabledAbortsTimer(), 30000);
+ }
+ });
+ abortBatchButton.addListener(SWT.MouseUp, new Listener() {
+ public void handleEvent(Event e) {
+ if (e.button == 3) {
+ handleBatchAbortButton();
+ abortBatchButton.setEnabled(false);
+ abortButton.setEnabled(false);
+ Timer timer = new Timer();
+ timer.schedule(new EnabledAbortsTimer(), 30000);
+ }
+ }
+ });
+ abortBatchButton.setEnabled(false);
+
+ controlsToolBar.pack();
+
+ Point size = controlsToolBar.getSize();
+ controlsCoolItem.setControl(controlsToolBar);
+ controlsCoolItem.setSize(controlsCoolItem.computeSize(size.x, size.y));
+ controlsCoolItem.setMinimumSize(size);
+ }
+
+ private void createScriptTableSection(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ scriptTable = new ScriptTableViewer(composite, this.getTestManager());
+ // scriptTable.addDisposeListener(new DisposeListener() {
+ // public void widgetDisposed(DisposeEvent e) {
+ // testManagerEditor.storeValue(testManagerEditor.scriptsQualName, scriptTable.getStorageString());
+ // }
+ // });
+
+ }
+
+ private void createStatusWindow(Composite parent) {
+ statusWindow = new StatusWindowWidget(parent);
+
+ statusWindow.setLabelAndValue(UpdateableLabel.HOSTLABEL.name(), "Selected Host", NOT_CONNECTED, SWT.BOLD,
+ SWT.COLOR_DARK_RED);
+
+ String selectedFile = testManagerEditor.loadValue(testManagerEditor.configFileName);
+ if (selectedFile == null || selectedFile.equals("")) {
+ selectedFile = testManagerEditor.getDefaultConfigPath();
+ testManagerEditor.storeValue(testManagerEditor.configFileName, selectedFile);
+ }
+ OseeLog.log(TestManagerPlugin.class, Level.INFO, "The default config is: " + selectedFile);
+
+ statusWindow.setLabelAndValue(UpdateableLabel.CONFIGPATHLABEL.name(), "Config File Path", selectedFile);
+
+ saveWidget.setStatusLabel(statusWindow);
+ loadWidget.setStatusLabel(statusWindow);
+
+ // // Status ICON Labels
+ // connectStatusIconLabel = new
+ // Label(statusWindow.getStatusIconComposite(), SWT.NONE);
+ // hostWidget.setConnectStatusLabel(connectStatusIconLabel);
+ // connectStatusIconLabel.setVisible(false);
+
+ statusWindow.refresh();
+ }
+
+ // TODO this stuff needs some updating too...
+ protected void handleAbortButton() {
+ TestManagerPlugin.getInstance().getOteConsoleService().write("Aborting Test Script...");
+ try {
+ getScriptManager().abortScript(false);
+ } catch (RemoteException e) {
+ TestManagerPlugin.getInstance().getOteConsoleService().writeError(Lib.exceptionToString(e));
+ }
+ }
+
+ // TODO this stuff needs some updating too...
+ protected void handleBatchAbortButton() {
+ TestManagerPlugin.getInstance().getOteConsoleService().write("Aborting Test Script Batch...");
+ try {
+ getScriptManager().abortScript(true);
+ } catch (RemoteException e) {
+ TestManagerPlugin.getInstance().getOteConsoleService().writeError(Lib.exceptionToString(e));
+ }
+ }
+
+ private void handleDeleteButton() {
+ scriptTable.removeSelectedTasks();
+ }
+
+ private void handleRunButton() {
+ ScriptRunJob runJob = new ScriptRunJob(getTestManager());
+ if (runJob.isRunAllowed()) {
+ runJob.setPriority(Job.LONG);
+ runJob.setUser(true);
+ runJob.schedule();
+ } else {
+ MessageDialog.openError(Displays.getActiveShell(), "Error", "Test Manager Settings Error");
+ }
+ }
+
+ private class EnabledAbortsTimer extends TimerTask {
+
+ @Override
+ public void run() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if (!runButton.isEnabled()) {
+ abortBatchButton.setEnabled(true);
+ abortButton.setEnabled(true);
+ }
+ } catch (Throwable th) {
+
+ }
+ }
+ });
+
+ }
+
+ }
+
+ @Override
+ public boolean areSettingsValidForRun() {
+ return getScriptTableViewer().getRunTasks().size() > 0;
+ }
+
+ @Override
+ public String getErrorMessage() {
+ StringBuilder builder = new StringBuilder();
+ if (getScriptTableViewer().getRunTasks().size() <= 0) {
+ builder.append("Scripts not selected.");
+ }
+ return builder.toString();
+ }
+
+ @Override
+ public boolean onConnection(final ConnectionEvent event) {
+ boolean result = getScriptManager().connect(event);
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ runButton.setEnabled(true);
+ abortButton.setEnabled(false);
+ abortBatchButton.setEnabled(false);
+ scriptTable.onConnectionChanged(true);
+ statusWindow.setValue(UpdateableLabel.HOSTLABEL.name(), event.getProperties().getStation(), SWT.BOLD,
+ SWT.COLOR_DARK_GREEN);
+ statusWindow.refresh();
+ }
+
+ });
+ return result;
+ }
+
+ @Override
+ public boolean onDisconnect(ConnectionEvent event) {
+ boolean result = getScriptManager().disconnect(event);
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ runButton.setEnabled(false);
+ abortButton.setEnabled(false);
+ abortBatchButton.setEnabled(false);
+ scriptTable.onConnectionChanged(false);
+ statusWindow.setValue(UpdateableLabel.HOSTLABEL.name(), NOT_CONNECTED, SWT.BOLD, SWT.COLOR_DARK_RED);
+ statusWindow.refresh();
+ }
+ });
+ return result;
+ }
+
+ @Override
+ public boolean onConnectionLost() {
+ boolean result = getScriptManager().onConnectionLost();
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ runButton.setEnabled(false);
+ abortButton.setEnabled(false);
+ abortBatchButton.setEnabled(false);
+ scriptTable.onConnectionChanged(false);
+ statusWindow.setValue(UpdateableLabel.HOSTLABEL.name(), NOT_CONNECTED, SWT.BOLD, SWT.COLOR_DARK_RED);
+ statusWindow.refresh();
+ }
+ });
+ return result;
+ }
+
+ public abstract ScriptManager getScriptManager();
+
+ /**
+ * @param files
+ */
+ public void addFiles(String[] files) {
+ scriptTable.addFiles(files);
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/StatusWindowWidget.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/StatusWindowWidget.java
index 71e656c8344..7bf6ea2c998 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/StatusWindowWidget.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/pages/StatusWindowWidget.java
@@ -8,128 +8,128 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.test.manager.pages;
-
+package org.eclipse.osee.ote.ui.test.manager.pages;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.FormattedText;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * @author Roberto E. Escobar
- */
-public class StatusWindowWidget {
- private Map<String, Map<EntryAttribute, Object>> labelValueMap;
- private List<String> keys;
- private FormattedText statusTextArea;
-
- private enum EntryAttribute {
- LABEL, VALUE, STYLE, COLOR;
- }
-
- public StatusWindowWidget(Composite parent) {
- keys = new ArrayList<String>();
- labelValueMap = new HashMap<String, Map<EntryAttribute, Object>>();
- statusTextArea = new FormattedText(parent, SWT.BORDER, SWT.DEFAULT, SWT.DEFAULT, false);
- statusTextArea.setTextAreaBackground(SWT.COLOR_WHITE);
- }
-
- public void setLabelAndValue(String key, String label, String value, int style, int color) {
- if (!keys.contains(key)) {
- keys.add(key);
- }
- Map<EntryAttribute, Object> entry = new HashMap<EntryAttribute, Object>();
- entry.put(EntryAttribute.LABEL, label);
- entry.put(EntryAttribute.VALUE, value);
- entry.put(EntryAttribute.STYLE, new Integer(style));
- entry.put(EntryAttribute.COLOR, new Integer(color));
-
- labelValueMap.put(key, entry);
- }
-
- public void setLabelAndValue(String key, String label, String value) {
- setLabelAndValue(key, label, value, SWT.NORMAL, SWT.COLOR_BLACK);
- }
-
- public String getValue(String key) {
- Map<EntryAttribute, Object> entry = labelValueMap.get(key);
- EntryAttribute attribute = EntryAttribute.VALUE;
- return ((entry != null && entry.get(attribute) != null) ? (String) entry.get(attribute) : "");
- }
-
- public String getLabel(String key) {
- Map<EntryAttribute, Object> entry = labelValueMap.get(key);
- EntryAttribute attribute = EntryAttribute.LABEL;
- return ((entry != null && entry.get(attribute) != null) ? (String) entry.get(attribute) : "");
- }
-
- public void setLabel(String key, String label) {
- Map<EntryAttribute, Object> entry = labelValueMap.get(key);
- if (entry != null) {
- entry.put(EntryAttribute.LABEL, label);
- }
- else {
- setLabelAndValue(key, label, "");
- }
- }
-
- public void setValueStyle(String key, int style) {
- Map<EntryAttribute, Object> entry = labelValueMap.get(key);
- if (entry != null) {
- entry.put(EntryAttribute.STYLE, new Integer(style));
- }
- }
-
- public void setValueColor(String key, int color) {
- Map<EntryAttribute, Object> entry = labelValueMap.get(key);
- if (entry != null) {
- entry.put(EntryAttribute.STYLE, new Integer(color));
- }
- }
-
- public void setValue(String key, String value, int style, int color) {
- Map<EntryAttribute, Object> entry = labelValueMap.get(key);
- if (entry != null) {
- entry.put(EntryAttribute.VALUE, value);
- entry.put(EntryAttribute.STYLE, new Integer(style));
- entry.put(EntryAttribute.COLOR, new Integer(color));
- }
- else {
- setLabelAndValue(key, "", value, style, color);
- }
- }
-
- public void setValue(String key, String value) {
- Map<EntryAttribute, Object> entry = labelValueMap.get(key);
- if (entry != null) {
- entry.put(EntryAttribute.VALUE, value);
- }
- else {
- setLabelAndValue(key, "", value);
- }
- }
-
- public void refresh() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- statusTextArea.clearTextArea();
- for (String key : keys) {
- Map<EntryAttribute, Object> entry = labelValueMap.get(key);
- if (entry != null) {
- String label = (String) entry.get(EntryAttribute.LABEL);
- String value = (String) entry.get(EntryAttribute.VALUE);
- Integer style = (Integer) entry.get(EntryAttribute.STYLE);
- Integer color = (Integer) entry.get(EntryAttribute.COLOR);
- statusTextArea.addText("\t" + label + ": ", SWT.BOLD, SWT.COLOR_DARK_BLUE);
- statusTextArea.addText(value + "\n", style, color);
- }
- }
- }
- });
- }
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class StatusWindowWidget {
+ private final Map<String, Map<EntryAttribute, Object>> labelValueMap;
+ private final List<String> keys;
+ private final FormattedText statusTextArea;
+
+ private enum EntryAttribute {
+ LABEL,
+ VALUE,
+ STYLE,
+ COLOR;
+ }
+
+ public StatusWindowWidget(Composite parent) {
+ keys = new ArrayList<String>();
+ labelValueMap = new HashMap<String, Map<EntryAttribute, Object>>();
+ statusTextArea = new FormattedText(parent, SWT.BORDER, SWT.DEFAULT, SWT.DEFAULT, false);
+ statusTextArea.setTextAreaBackground(SWT.COLOR_WHITE);
+ }
+
+ public void setLabelAndValue(String key, String label, String value, int style, int color) {
+ if (!keys.contains(key)) {
+ keys.add(key);
+ }
+ Map<EntryAttribute, Object> entry = new HashMap<EntryAttribute, Object>();
+ entry.put(EntryAttribute.LABEL, label);
+ entry.put(EntryAttribute.VALUE, value);
+ entry.put(EntryAttribute.STYLE, new Integer(style));
+ entry.put(EntryAttribute.COLOR, new Integer(color));
+
+ labelValueMap.put(key, entry);
+ }
+
+ public void setLabelAndValue(String key, String label, String value) {
+ setLabelAndValue(key, label, value, SWT.NORMAL, SWT.COLOR_BLACK);
+ }
+
+ public String getValue(String key) {
+ Map<EntryAttribute, Object> entry = labelValueMap.get(key);
+ EntryAttribute attribute = EntryAttribute.VALUE;
+ return ((entry != null && entry.get(attribute) != null) ? (String) entry.get(attribute) : "");
+ }
+
+ public String getLabel(String key) {
+ Map<EntryAttribute, Object> entry = labelValueMap.get(key);
+ EntryAttribute attribute = EntryAttribute.LABEL;
+ return ((entry != null && entry.get(attribute) != null) ? (String) entry.get(attribute) : "");
+ }
+
+ public void setLabel(String key, String label) {
+ Map<EntryAttribute, Object> entry = labelValueMap.get(key);
+ if (entry != null) {
+ entry.put(EntryAttribute.LABEL, label);
+ } else {
+ setLabelAndValue(key, label, "");
+ }
+ }
+
+ public void setValueStyle(String key, int style) {
+ Map<EntryAttribute, Object> entry = labelValueMap.get(key);
+ if (entry != null) {
+ entry.put(EntryAttribute.STYLE, new Integer(style));
+ }
+ }
+
+ public void setValueColor(String key, int color) {
+ Map<EntryAttribute, Object> entry = labelValueMap.get(key);
+ if (entry != null) {
+ entry.put(EntryAttribute.STYLE, new Integer(color));
+ }
+ }
+
+ public void setValue(String key, String value, int style, int color) {
+ Map<EntryAttribute, Object> entry = labelValueMap.get(key);
+ if (entry != null) {
+ entry.put(EntryAttribute.VALUE, value);
+ entry.put(EntryAttribute.STYLE, new Integer(style));
+ entry.put(EntryAttribute.COLOR, new Integer(color));
+ } else {
+ setLabelAndValue(key, "", value, style, color);
+ }
+ }
+
+ public void setValue(String key, String value) {
+ Map<EntryAttribute, Object> entry = labelValueMap.get(key);
+ if (entry != null) {
+ entry.put(EntryAttribute.VALUE, value);
+ } else {
+ setLabelAndValue(key, "", value);
+ }
+ }
+
+ public void refresh() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ statusTextArea.clearTextArea();
+ for (String key : keys) {
+ Map<EntryAttribute, Object> entry = labelValueMap.get(key);
+ if (entry != null) {
+ String label = (String) entry.get(EntryAttribute.LABEL);
+ String value = (String) entry.get(EntryAttribute.VALUE);
+ Integer style = (Integer) entry.get(EntryAttribute.STYLE);
+ Integer color = (Integer) entry.get(EntryAttribute.COLOR);
+ statusTextArea.addText("\t" + label + ": ", SWT.BOLD, SWT.COLOR_DARK_BLUE);
+ statusTextArea.addText(value + "\n", style, color);
+ }
+ }
+ }
+ });
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageDataViewer.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageDataViewer.java
index c03d0777bb3..f177d534e3e 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageDataViewer.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageDataViewer.java
@@ -8,9 +8,10 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.test.manager.preferences.environment;
-
+package org.eclipse.osee.ote.ui.test.manager.preferences.environment;
+
import java.util.ArrayList;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
@@ -18,120 +19,118 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
-
-/**
- * @author Roberto E. Escobar
- */
-public class EnvironmentPageDataViewer {
-
- private Group environmentVariable;
- private EnvironmentPreferenceNode nodeToDisplay;
- private ArrayList<StyleRange> styleArray;
- private StyledText textArea;
-
- public EnvironmentPageDataViewer(Composite parent) {
- createArea(parent);
- styleArray = new ArrayList<StyleRange>();
- }
-
- public void clearTextArea() {
- textArea.setText("");
- styleArray.clear();
- textArea.redraw();
- }
-
- public void setNodeToDisplay(EnvironmentPreferenceNode nodeToDisplay) {
- this.nodeToDisplay = nodeToDisplay;
- update();
- }
-
- public void setTitleName(String name) {
- environmentVariable.setText("Preview Environment Variable: " + name);
- environmentVariable.redraw();
- }
-
- public void update() {
- clearTextArea();
- if (nodeToDisplay != null) {
- setTitleName(nodeToDisplay.getEnvName());
- addEntry(nodeToDisplay.getEnvName(), nodeToDisplay.getValue());
- }
- else {
- setTitleName("NONE SELECTED");
- }
- }
-
- private void addEntry(String name, String value) {
- addEntryName(name);
- addEntryValue(value);
- }
-
- private void addEntryName(String name) {
- if (name != null) {
- String temp = textArea.getText();
- temp += "\n\t";
- int startIndex = temp.length();
- temp += name;
- textArea.setText(temp);
- StyleRange tempStyle = new StyleRange();
- styleArray.add(tempStyle);
- tempStyle.fontStyle = SWT.BOLD;
- tempStyle.start = startIndex;
- tempStyle.length = name.length();
- tempStyle.underline = true;
- tempStyle.foreground = Display.getDefault().getSystemColor(SWT.COLOR_DARK_BLUE);
- textArea.setStyleRanges(styleArray.toArray(new StyleRange[styleArray.size()]));
- textArea.redraw();
- }
- }
-
- private void addEntryValue(String value) {
- if (value != null) {
- String temp = textArea.getText();
- temp += " = ";
- int startIndex = temp.length();
- String toAdd = value.replaceAll(":", ":\n\t\t");
- temp += toAdd;
- textArea.setText(temp + "\n");
- StyleRange tempStyle = new StyleRange();
- styleArray.add(tempStyle);
- tempStyle.fontStyle = SWT.ITALIC;
- tempStyle.start = startIndex;
- tempStyle.length = toAdd.length();
- tempStyle.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
- textArea.setStyleRanges(styleArray.toArray(new StyleRange[styleArray.size()]));
- textArea.redraw();
- }
- }
-
- private Control createArea(Composite parent) {
- GridData d = new GridData(GridData.FILL_BOTH);
-
- environmentVariable = new Group(parent, SWT.NONE);
- environmentVariable.setText("Preview Environment Variable:");
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 1;
- environmentVariable.setLayout(gridLayout);
- environmentVariable.setLayoutData(d);
-
- Composite topLevelComposite = new Composite(environmentVariable, SWT.NONE);
- gridLayout = new GridLayout();
- gridLayout.numColumns = 1;
- topLevelComposite.setLayout(gridLayout);
- topLevelComposite.setLayoutData(d);
- topLevelComposite.setToolTipText("Select a Value From the Tree to Display");
-
- textArea = new StyledText(topLevelComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- textArea.setEditable(false);
- GridLayout gL = new GridLayout();
- gL.numColumns = 1;
- textArea.setLayout(gL);
- textArea.setLayoutData(d);
- textArea.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- textArea.setToolTipText("Select a Value From the Tree to Display");
-
- return parent;
- }
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class EnvironmentPageDataViewer {
+
+ private Group environmentVariable;
+ private EnvironmentPreferenceNode nodeToDisplay;
+ private final ArrayList<StyleRange> styleArray;
+ private StyledText textArea;
+
+ public EnvironmentPageDataViewer(Composite parent) {
+ createArea(parent);
+ styleArray = new ArrayList<StyleRange>();
+ }
+
+ public void clearTextArea() {
+ textArea.setText("");
+ styleArray.clear();
+ textArea.redraw();
+ }
+
+ public void setNodeToDisplay(EnvironmentPreferenceNode nodeToDisplay) {
+ this.nodeToDisplay = nodeToDisplay;
+ update();
+ }
+
+ public void setTitleName(String name) {
+ environmentVariable.setText("Preview Environment Variable: " + name);
+ environmentVariable.redraw();
+ }
+
+ public void update() {
+ clearTextArea();
+ if (nodeToDisplay != null) {
+ setTitleName(nodeToDisplay.getEnvName());
+ addEntry(nodeToDisplay.getEnvName(), nodeToDisplay.getValue());
+ } else {
+ setTitleName("NONE SELECTED");
+ }
+ }
+
+ private void addEntry(String name, String value) {
+ addEntryName(name);
+ addEntryValue(value);
+ }
+
+ private void addEntryName(String name) {
+ if (name != null) {
+ String temp = textArea.getText();
+ temp += "\n\t";
+ int startIndex = temp.length();
+ temp += name;
+ textArea.setText(temp);
+ StyleRange tempStyle = new StyleRange();
+ styleArray.add(tempStyle);
+ tempStyle.fontStyle = SWT.BOLD;
+ tempStyle.start = startIndex;
+ tempStyle.length = name.length();
+ tempStyle.underline = true;
+ tempStyle.foreground = Displays.getSystemColor(SWT.COLOR_DARK_BLUE);
+ textArea.setStyleRanges(styleArray.toArray(new StyleRange[styleArray.size()]));
+ textArea.redraw();
+ }
+ }
+
+ private void addEntryValue(String value) {
+ if (value != null) {
+ String temp = textArea.getText();
+ temp += " = ";
+ int startIndex = temp.length();
+ String toAdd = value.replaceAll(":", ":\n\t\t");
+ temp += toAdd;
+ textArea.setText(temp + "\n");
+ StyleRange tempStyle = new StyleRange();
+ styleArray.add(tempStyle);
+ tempStyle.fontStyle = SWT.ITALIC;
+ tempStyle.start = startIndex;
+ tempStyle.length = toAdd.length();
+ tempStyle.foreground = Displays.getSystemColor(SWT.COLOR_BLACK);
+ textArea.setStyleRanges(styleArray.toArray(new StyleRange[styleArray.size()]));
+ textArea.redraw();
+ }
+ }
+
+ private Control createArea(Composite parent) {
+ GridData d = new GridData(GridData.FILL_BOTH);
+
+ environmentVariable = new Group(parent, SWT.NONE);
+ environmentVariable.setText("Preview Environment Variable:");
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ environmentVariable.setLayout(gridLayout);
+ environmentVariable.setLayoutData(d);
+
+ Composite topLevelComposite = new Composite(environmentVariable, SWT.NONE);
+ gridLayout = new GridLayout();
+ gridLayout.numColumns = 1;
+ topLevelComposite.setLayout(gridLayout);
+ topLevelComposite.setLayoutData(d);
+ topLevelComposite.setToolTipText("Select a Value From the Tree to Display");
+
+ textArea = new StyledText(topLevelComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ textArea.setEditable(false);
+ GridLayout gL = new GridLayout();
+ gL.numColumns = 1;
+ textArea.setLayout(gL);
+ textArea.setLayoutData(d);
+ textArea.setBackground(Displays.getSystemColor(SWT.COLOR_WHITE));
+ textArea.setToolTipText("Select a Value From the Tree to Display");
+
+ return parent;
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageEventHandler.java b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageEventHandler.java
index 0f1b791ce58..e2687135ea4 100644
--- a/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageEventHandler.java
+++ b/plugins/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/preferences/environment/EnvironmentPageEventHandler.java
@@ -8,8 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ote.ui.test.manager.preferences.environment;
-
+package org.eclipse.osee.ote.ui.test.manager.preferences.environment;
+
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
@@ -20,108 +20,105 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
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.Displays;
import org.eclipse.osee.ote.ui.test.manager.util.EnvVariableDetailsDialogHelper;
import org.eclipse.osee.ote.ui.test.manager.util.EnvVariableDialogHelper;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * @author Roberto E. Escobar
- */
-public class EnvironmentPageEventHandler {
-
- private EnvironmentPreferenceNode currentSelection;
- private EnvironmentPageDataViewer environmentPageDataViewer;
- private ArrayList<EnvironmentPreferenceNode> treeInputList;
- private CheckboxTreeViewer treeViewer;
-
- public EnvironmentPageEventHandler(Composite parent, CheckboxTreeViewer treeViewer,
- ArrayList<EnvironmentPreferenceNode> treeInputList) {
- this.treeViewer = treeViewer;
- this.treeInputList = treeInputList;
- this.environmentPageDataViewer = new EnvironmentPageDataViewer(parent);
- }
-
- public void editEnvVariable(EnvironmentPreferenceNode node) {
- EnvVariableDetailsDialogHelper selection = new EnvVariableDetailsDialogHelper(node.getEnvName(), node.getValue());
- Display.getDefault().syncExec(selection);
- if (selection.getResult() != Window.CANCEL) {
- node.setValue(selection.getSelection());
- environmentPageDataViewer.update();
- }
- }
-
- public void handleAddEnvironmentVariableEvent() {
- EnvVariableDialogHelper selection = new EnvVariableDialogHelper();
- Display.getDefault().syncExec(selection);
- if (selection.getResult() != Window.CANCEL) {
- this.addEnvironmentVariable(selection.getSelection());
- treeViewer.refresh();
- }
- }
-
- public void handleCheckStateChangeEvent(CheckStateChangedEvent event) {
- Object obj = event.getElement();
- if (obj != null) {
- EnvironmentPreferenceNode tempSelection = null;
-
- if (obj instanceof EnvironmentPreferenceNode) {
- tempSelection = (EnvironmentPreferenceNode) obj;
- tempSelection.setChecked(event.getChecked());
- currentSelection = tempSelection;
- environmentPageDataViewer.setNodeToDisplay(currentSelection);
- }
- }
- }
-
- public void handleEditVariableEvent() {
- ISelection sel = this.treeViewer.getSelection();
- if (!sel.isEmpty()) {
- TreeObject selectedItem = (TreeObject) ((StructuredSelection) sel).getFirstElement();
- if (selectedItem instanceof EnvironmentPreferenceNode) {
- editEnvVariable((EnvironmentPreferenceNode) selectedItem);
- }
- }
- }
-
- public void handleRemoveSelectedViewEvent() {
- StructuredSelection sel = (StructuredSelection) treeViewer.getSelection();
- if (!sel.isEmpty()) {
- Iterator<?> it = sel.iterator();
- while (it.hasNext()) {
- TreeObject leaf = (TreeObject) it.next();
- if (leaf instanceof TreeParent) {
- treeInputList.remove(leaf);
- environmentPageDataViewer.setNodeToDisplay(null);
- }
- else {
- leaf.getParent().removeChild(leaf);
- environmentPageDataViewer.update();
- }
- }
- treeViewer.refresh();
- }
- }
-
- public void handleTreeSelectionEvent(SelectionChangedEvent event) {
- ISelection sel = event.getSelection();
- if (!sel.isEmpty()) {
- TreeObject selectedItem = (TreeObject) ((StructuredSelection) sel).getFirstElement();
-
- EnvironmentPreferenceNode tempSelection = null;
-
- if (selectedItem instanceof EnvironmentPreferenceNode) {
- tempSelection = (EnvironmentPreferenceNode) selectedItem;
- currentSelection = tempSelection;
- environmentPageDataViewer.setNodeToDisplay(currentSelection);
- }
- treeViewer.refresh();
- }
- }
-
- private void addEnvironmentVariable(String name) {
- EnvironmentPreferenceNode node = new EnvironmentPreferenceNode(name);
- treeInputList.add(node);
- }
-}
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class EnvironmentPageEventHandler {
+
+ private EnvironmentPreferenceNode currentSelection;
+ private final EnvironmentPageDataViewer environmentPageDataViewer;
+ private final ArrayList<EnvironmentPreferenceNode> treeInputList;
+ private final CheckboxTreeViewer treeViewer;
+
+ public EnvironmentPageEventHandler(Composite parent, CheckboxTreeViewer treeViewer, ArrayList<EnvironmentPreferenceNode> treeInputList) {
+ this.treeViewer = treeViewer;
+ this.treeInputList = treeInputList;
+ this.environmentPageDataViewer = new EnvironmentPageDataViewer(parent);
+ }
+
+ public void editEnvVariable(EnvironmentPreferenceNode node) {
+ EnvVariableDetailsDialogHelper selection = new EnvVariableDetailsDialogHelper(node.getEnvName(), node.getValue());
+ Displays.pendInDisplayThread(selection);
+ if (selection.getResult() != Window.CANCEL) {
+ node.setValue(selection.getSelection());
+ environmentPageDataViewer.update();
+ }
+ }
+
+ public void handleAddEnvironmentVariableEvent() {
+ EnvVariableDialogHelper selection = new EnvVariableDialogHelper();
+ Displays.pendInDisplayThread(selection);
+ if (selection.getResult() != Window.CANCEL) {
+ this.addEnvironmentVariable(selection.getSelection());
+ treeViewer.refresh();
+ }
+ }
+
+ public void handleCheckStateChangeEvent(CheckStateChangedEvent event) {
+ Object obj = event.getElement();
+ if (obj != null) {
+ EnvironmentPreferenceNode tempSelection = null;
+
+ if (obj instanceof EnvironmentPreferenceNode) {
+ tempSelection = (EnvironmentPreferenceNode) obj;
+ tempSelection.setChecked(event.getChecked());
+ currentSelection = tempSelection;
+ environmentPageDataViewer.setNodeToDisplay(currentSelection);
+ }
+ }
+ }
+
+ public void handleEditVariableEvent() {
+ ISelection sel = this.treeViewer.getSelection();
+ if (!sel.isEmpty()) {
+ TreeObject selectedItem = (TreeObject) ((StructuredSelection) sel).getFirstElement();
+ if (selectedItem instanceof EnvironmentPreferenceNode) {
+ editEnvVariable((EnvironmentPreferenceNode) selectedItem);
+ }
+ }
+ }
+
+ public void handleRemoveSelectedViewEvent() {
+ StructuredSelection sel = (StructuredSelection) treeViewer.getSelection();
+ if (!sel.isEmpty()) {
+ Iterator<?> it = sel.iterator();
+ while (it.hasNext()) {
+ TreeObject leaf = (TreeObject) it.next();
+ if (leaf instanceof TreeParent) {
+ treeInputList.remove(leaf);
+ environmentPageDataViewer.setNodeToDisplay(null);
+ } else {
+ leaf.getParent().removeChild(leaf);
+ environmentPageDataViewer.update();
+ }
+ }
+ treeViewer.refresh();
+ }
+ }
+
+ public void handleTreeSelectionEvent(SelectionChangedEvent event) {
+ ISelection sel = event.getSelection();
+ if (!sel.isEmpty()) {
+ TreeObject selectedItem = (TreeObject) ((StructuredSelection) sel).getFirstElement();
+
+ EnvironmentPreferenceNode tempSelection = null;
+
+ if (selectedItem instanceof EnvironmentPreferenceNode) {
+ tempSelection = (EnvironmentPreferenceNode) selectedItem;
+ currentSelection = tempSelection;
+ environmentPageDataViewer.setNodeToDisplay(currentSelection);
+ }
+ treeViewer.refresh();
+ }
+ }
+
+ private void addEnvironmentVariable(String name) {
+ EnvironmentPreferenceNode node = new EnvironmentPreferenceNode(name);
+ treeInputList.add(node);
+ }
+}
diff --git a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateView.java b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateView.java
index d0e857ae793..c6d7344cba2 100644
--- a/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateView.java
+++ b/plugins/org.eclipse.osee.ote.ui/src/org/eclipse/osee/ote/ui/navigate/OteNavigateView.java
@@ -22,11 +22,11 @@ import org.eclipse.osee.framework.ui.plugin.OseeUiActions;
import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
+import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.ote.ui.internal.TestCoreGuiPlugin;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
@@ -37,88 +37,90 @@ import org.eclipse.ui.part.ViewPart;
*/
public class OteNavigateView extends ViewPart implements IActionable {
- public static final String VIEW_ID = "org.eclipse.osee.ote.ui.navigate.OteNavigateView";
- private XNavigateComposite xNavComp;
-
- /**
- * The constructor.
- */
- public OteNavigateView() {
- }
-
- @Override
- public void setFocus() {
- }
-
- /*
- * @see IWorkbenchPart#createPartControl(Composite)
- */
- @Override
- public void createPartControl(Composite parent) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.osee.ote.ui.oteNavigator");
- xNavComp = new XNavigateComposite(new OteNavigateViewItems(), parent, SWT.NONE);
-
- xNavComp.getFilteredTree().getViewer().setSorter(new OteNavigateViewerSorter());
-
- createActions();
- xNavComp.refresh();
-
- addExtensionPointListenerBecauseOfWorkspaceLoading();
- }
-
- private void addExtensionPointListenerBecauseOfWorkspaceLoading() {
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- extensionRegistry.addListener(new IRegistryEventListener() {
- @Override
- public void added(IExtension[] extensions) {
- refresh();
- }
-
- @Override
- public void added(IExtensionPoint[] extensionPoints) {
- refresh();
- }
-
- @Override
- public void removed(IExtension[] extensions) {
- refresh();
- }
-
- @Override
- public void removed(IExtensionPoint[] extensionPoints) {
- refresh();
- }
- }, "org.eclipse.osee.framework.ui.plugin.XNavigateItem");
- }
-
- protected void createActions() {
- Action refreshAction = new Action("Refresh") {
-
- @Override
- public void run() {
- xNavComp.refresh();
- }
- };
- refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
- refreshAction.setToolTipText("Refresh");
-
- OseeUiActions.addBugToViewToolbar(this, this, TestCoreGuiPlugin.getDefault(), VIEW_ID, "OTE Navigator");
-
- }
-
- public String getActionDescription() {
- IStructuredSelection sel = (IStructuredSelection) xNavComp.getFilteredTree().getViewer().getSelection();
- if (sel.iterator().hasNext()) {
- return String.format("Currently Selected - %s", ((XNavigateItem) sel.iterator().next()).getName());
- }
- return "";
- }
-
- public void refresh() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- xNavComp.refresh();
- }
- });
- }
+ public static final String VIEW_ID = "org.eclipse.osee.ote.ui.navigate.OteNavigateView";
+ private XNavigateComposite xNavComp;
+
+ /**
+ * The constructor.
+ */
+ public OteNavigateView() {
+ }
+
+ @Override
+ public void setFocus() {
+ }
+
+ /*
+ * @see IWorkbenchPart#createPartControl(Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.eclipse.osee.ote.ui.oteNavigator");
+ xNavComp = new XNavigateComposite(new OteNavigateViewItems(), parent, SWT.NONE);
+
+ xNavComp.getFilteredTree().getViewer().setSorter(new OteNavigateViewerSorter());
+
+ createActions();
+ xNavComp.refresh();
+
+ addExtensionPointListenerBecauseOfWorkspaceLoading();
+ }
+
+ private void addExtensionPointListenerBecauseOfWorkspaceLoading() {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ extensionRegistry.addListener(new IRegistryEventListener() {
+ @Override
+ public void added(IExtension[] extensions) {
+ refresh();
+ }
+
+ @Override
+ public void added(IExtensionPoint[] extensionPoints) {
+ refresh();
+ }
+
+ @Override
+ public void removed(IExtension[] extensions) {
+ refresh();
+ }
+
+ @Override
+ public void removed(IExtensionPoint[] extensionPoints) {
+ refresh();
+ }
+ }, "org.eclipse.osee.framework.ui.plugin.XNavigateItem");
+ }
+
+ protected void createActions() {
+ Action refreshAction = new Action("Refresh") {
+
+ @Override
+ public void run() {
+ xNavComp.refresh();
+ }
+ };
+ refreshAction.setImageDescriptor(ImageManager.getImageDescriptor(PluginUiImage.REFRESH));
+ refreshAction.setToolTipText("Refresh");
+
+ OseeUiActions.addBugToViewToolbar(this, this, TestCoreGuiPlugin.getDefault(), VIEW_ID, "OTE Navigator");
+
+ }
+
+ @Override
+ public String getActionDescription() {
+ IStructuredSelection sel = (IStructuredSelection) xNavComp.getFilteredTree().getViewer().getSelection();
+ if (sel.iterator().hasNext()) {
+ return String.format("Currently Selected - %s", ((XNavigateItem) sel.iterator().next()).getName());
+ }
+ return "";
+ }
+
+ public void refresh() {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+ xNavComp.refresh();
+ }
+ });
+ }
} \ No newline at end of file

Back to the top