Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-12-20 11:12:33 +0000
committerUwe Stieber2012-12-20 11:12:33 +0000
commitad7953bf7567ac0b7f11a0e12a956a310453406f (patch)
treeccb3b2e8b478832cd5647ca70d90b6f60bc89004 /target_explorer/plugins/org.eclipse.tcf.te.ui.forms
parentd43770e9ef134030741133f460098f640dc54a9a (diff)
downloadorg.eclipse.tcf-ad7953bf7567ac0b7f11a0e12a956a310453406f.tar.gz
org.eclipse.tcf-ad7953bf7567ac0b7f11a0e12a956a310453406f.tar.xz
org.eclipse.tcf-ad7953bf7567ac0b7f11a0e12a956a310453406f.zip
Target Explorer: Added sections dirty and stale state tracing capabilities
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.ui.forms')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.forms/.options3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.forms/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/activator/UIPlugin.java144
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/interfaces/tracing/ITraceIds.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java72
5 files changed, 179 insertions, 67 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/.options b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/.options
new file mode 100644
index 000000000..2f1a5f3be
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/.options
@@ -0,0 +1,3 @@
+org.eclipse.tcf.te.ui.forms/debugmode = 0
+org.eclipse.tcf.te.ui.forms/trace/sections/dirtyState = false
+org.eclipse.tcf.te.ui.forms/trace/sections/staleState = false
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/META-INF/MANIFEST.MF
index c35b81dc4..0494b2517 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/META-INF/MANIFEST.MF
@@ -16,4 +16,5 @@ Bundle-Vendor: %providerName
Export-Package: org.eclipse.tcf.te.ui.forms,
org.eclipse.tcf.te.ui.forms.activator;x-internal:=true,
org.eclipse.tcf.te.ui.forms.blocks,
+ org.eclipse.tcf.te.ui.forms.interfaces.tracing,
org.eclipse.tcf.te.ui.forms.parts
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/activator/UIPlugin.java
index 7fd33a7b0..2bb7c5fa9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/activator/UIPlugin.java
@@ -1,64 +1,80 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.forms.activator;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class UIPlugin extends AbstractUIPlugin {
- // The shared instance
- private static UIPlugin plugin;
-
- /**
- * The constructor
- */
- public UIPlugin() {
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static UIPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Convenience method which returns the unique identifier of this plugin.
- */
- public static String getUniqueIdentifier() {
- if (getDefault() != null && getDefault().getBundle() != null) {
- return getDefault().getBundle().getSymbolicName();
- }
- return "org.eclipse.tcf.te.ui.forms"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.forms.activator;
+
+import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class UIPlugin extends AbstractUIPlugin {
+ // The shared instance
+ private static UIPlugin plugin;
+ // The trace handler instance
+ private static volatile TraceHandler traceHandler;
+
+ /**
+ * The constructor
+ */
+ public UIPlugin() {
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static UIPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Convenience method which returns the unique identifier of this plugin.
+ */
+ public static String getUniqueIdentifier() {
+ if (getDefault() != null && getDefault().getBundle() != null) {
+ return getDefault().getBundle().getSymbolicName();
+ }
+ return "org.eclipse.tcf.te.ui.forms"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the bundles trace handler.
+ *
+ * @return The bundles trace handler.
+ */
+ public static TraceHandler getTraceHandler() {
+ if (traceHandler == null) {
+ traceHandler = new TraceHandler(getUniqueIdentifier());
+ }
+ return traceHandler;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ traceHandler = null;
+ super.stop(context);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/interfaces/tracing/ITraceIds.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/interfaces/tracing/ITraceIds.java
new file mode 100644
index 000000000..abe521b6d
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/interfaces/tracing/ITraceIds.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.forms.interfaces.tracing;
+
+/**
+ * Plug-in trace slot identifiers.
+ */
+public interface ITraceIds {
+
+ /**
+ * If activated, tracing information about the section dirty state is printed out.
+ */
+ public static String TRACE_SECTIONS_DIRTY_STATE = "trace/sections/dirtyState"; //$NON-NLS-1$
+
+ /**
+ * If activated, tracing information about the section stale state is printed out.
+ */
+ public static String TRACE_SECTIONS_STALE_STATE = "trace/sections/staleState"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java
index a3bc6938b..4806babe8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java
@@ -30,6 +30,8 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
+import org.eclipse.tcf.te.ui.forms.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.forms.interfaces.tracing.ITraceIds;
import org.eclipse.tcf.te.ui.jface.interfaces.IValidatable;
import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.forms.AbstractFormPart;
@@ -216,6 +218,11 @@ public abstract class AbstractSection extends SectionPart implements IAdaptable,
* @param dirty <code>True</code> to mark the section dirty, <code>false</code> otherwise.
*/
public final void markDirty(boolean dirty) {
+ if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_SECTIONS_DIRTY_STATE)) {
+ UIPlugin.getTraceHandler().trace("markDirty: Set dirty state to " + dirty, //$NON-NLS-1$
+ ITraceIds.TRACE_SECTIONS_DIRTY_STATE, this);
+ }
+
if (dirty) markDirty();
else {
// For now, there is no direct way to reset the dirty state,
@@ -237,6 +244,38 @@ public abstract class AbstractSection extends SectionPart implements IAdaptable,
}
}
+ /**
+ * Marks the section stale or reset the stale state.
+ *
+ * @param stale <code>True</code> to mark the section stale, <code>false</code> otherwise.
+ */
+ public final void markStale(boolean stale) {
+ if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_SECTIONS_STALE_STATE)) {
+ UIPlugin.getTraceHandler().trace("markStale: Set stale state to " + stale, //$NON-NLS-1$
+ ITraceIds.TRACE_SECTIONS_STALE_STATE, this);
+ }
+
+ if (stale) markStale();
+ else {
+ // For now, there is no direct way to reset the stale state,
+ // and the refresh() method is setting back both flags (stale and dirty).
+ // Plus, refresh() might be overwritten to refresh the widget content
+ // from the data itself, what will trigger an stack overflow after all.
+ try {
+ final Field f = AbstractFormPart.class.getDeclaredField("stale"); //$NON-NLS-1$
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ @Override
+ public Object run() {
+ f.setAccessible(true);
+ return null;
+ }
+ });
+ f.setBoolean(this, stale);
+ if (getManagedForm() != null) getManagedForm().staleStateChanged();
+ } catch (Exception e) { /* ignored on purpose */ }
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
*/
@@ -244,8 +283,18 @@ public abstract class AbstractSection extends SectionPart implements IAdaptable,
public void commit(boolean onSave) {
// commit is reseting the dirty state
boolean hasBeenDirty = isDirty();
+ // Execute the commit
super.commit(onSave);
- if (hasBeenDirty) getManagedForm().dirtyStateChanged();
+ // signal the dirty state change to the manager form if
+ // it really has changed
+ if (hasBeenDirty) {
+ if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_SECTIONS_DIRTY_STATE)) {
+ UIPlugin.getTraceHandler().trace("Commit(" + onSave + ") reseted the dirty state to false.", //$NON-NLS-1$ //$NON-NLS-2$
+ ITraceIds.TRACE_SECTIONS_DIRTY_STATE, this);
+ }
+
+ getManagedForm().dirtyStateChanged();
+ }
}
/* (non-Javadoc)
@@ -256,9 +305,26 @@ public abstract class AbstractSection extends SectionPart implements IAdaptable,
// refresh is reseting both the stale and the dirty state
boolean hasBeenStale = isStale();
boolean hasBeenDirty = isDirty();
+
super.refresh();
- if (hasBeenStale) getManagedForm().staleStateChanged();
- if (hasBeenDirty) getManagedForm().dirtyStateChanged();
+
+ if (hasBeenStale) {
+ if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_SECTIONS_STALE_STATE)) {
+ UIPlugin.getTraceHandler().trace("refresh() reseted the stale state to false.", //$NON-NLS-1$
+ ITraceIds.TRACE_SECTIONS_STALE_STATE, this);
+ }
+
+ getManagedForm().staleStateChanged();
+ }
+
+ if (hasBeenDirty) {
+ if (UIPlugin.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_SECTIONS_DIRTY_STATE)) {
+ UIPlugin.getTraceHandler().trace("refresh() reseted the dirty state to false.", //$NON-NLS-1$
+ ITraceIds.TRACE_SECTIONS_DIRTY_STATE, this);
+ }
+
+ getManagedForm().dirtyStateChanged();
+ }
}
/* (non-Javadoc)

Back to the top