summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Roldan Betancort2008-12-11 07:27:48 (EST)
committerVictor Roldan Betancort2008-12-11 07:27:48 (EST)
commit5cc28537fd5cdf015fd98af184ad90e0df334d85 (patch)
tree0a0a38b6615d2caf2d877a1a7aa444ea53a8a077
parent97245a797cb48729d90e2fb5c68e5be1bbd0e8b9 (diff)
downloadcdo-5cc28537fd5cdf015fd98af184ad90e0df334d85.zip
cdo-5cc28537fd5cdf015fd98af184ad90e0df334d85.tar.gz
cdo-5cc28537fd5cdf015fd98af184ad90e0df334d85.tar.bz2
[205663] [UI] Make autoReload in CDOEditor configurable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205663
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOUIPreferencePage.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java103
3 files changed, 96 insertions, 24 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
index d865b30..7218773 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/bundle/OM.java
@@ -4,9 +4,10 @@
* 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:
* Eike Stepper - initial API and implementation
+ * Victor Roldan Betancort - maintenance
**************************************************************************/
package org.eclipse.emf.cdo.internal.ui.bundle;
@@ -56,6 +57,9 @@ public abstract class OM
public static final OMPreference<Boolean> PREF_AUTOMATIC_PACKAGE_REGISTY = //
PREFS.init("PREF_AUTOMATIC_PACKAGE_REGISTY", true); //$NON-NLS-1$
+ public static final OMPreference<Boolean> PREF_EDITOR_AUTO_RELOAD = //
+ PREFS.init("PREF_EDITOR_AUTO_RELOAD", true); //$NON-NLS-1$
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOUIPreferencePage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOUIPreferencePage.java
index ea55fbf..efc6cce 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOUIPreferencePage.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOUIPreferencePage.java
@@ -4,9 +4,10 @@
* 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:
* Eike Stepper - initial API and implementation
+ * Victor Roldan Betancort - maintenance
**************************************************************************/
package org.eclipse.emf.cdo.internal.ui.preferences;
@@ -23,6 +24,7 @@ import org.eclipse.jface.fieldassist.SimpleContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@@ -36,6 +38,8 @@ public class CDOUIPreferencePage extends OMPreferencePage
{
private TextAndDisable decoration;
+ private Button autoReload;
+
public CDOUIPreferencePage()
{
super(OM.PREFS);
@@ -64,6 +68,9 @@ public class CDOUIPreferencePage extends OMPreferencePage
new ContentAssistCommandAdapter(text, contentAdapter, provider, null, new char[] { '$' }, true);
UIUtil.addDecorationMargin(text);
+ autoReload = new Button(composite, SWT.CHECK);
+ autoReload.setText("Enable CDOEditor Auto-Reload");
+
initValues();
return composite;
}
@@ -71,12 +78,14 @@ public class CDOUIPreferencePage extends OMPreferencePage
protected void initValues()
{
decoration.setValue(OM.PREF_LABEL_DECORATION.getValue());
+ autoReload.setSelection(OM.PREF_EDITOR_AUTO_RELOAD.getValue());
}
@Override
public boolean performOk()
{
OM.PREF_LABEL_DECORATION.setValue(decoration.getValue());
+ OM.PREF_EDITOR_AUTO_RELOAD.setValue(autoReload.getSelection());
return super.performOk();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java
index c54dfd1..a21746d 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOEventHandler.java
@@ -4,10 +4,11 @@
* 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:
* Eike Stepper - initial API and implementation
* Simon McDuff - maintenance
+ * Victor Roldan Betancort - maintenance
**************************************************************************/
package org.eclipse.emf.cdo.ui;
@@ -19,6 +20,7 @@ import org.eclipse.emf.cdo.CDOTransactionStartedEvent;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.CDOViewInvalidationEvent;
import org.eclipse.emf.cdo.internal.ui.ItemsProcessor;
+import org.eclipse.emf.cdo.internal.ui.bundle.OM;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
@@ -27,6 +29,7 @@ import org.eclipse.net4j.util.container.IContainerEvent;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
+import org.eclipse.net4j.util.om.pref.OMPreferencesChangeEvent;
import org.eclipse.jface.viewers.TreeViewer;
@@ -91,25 +94,7 @@ public class CDOEventHandler
// }
// else
{
- try
- {
- treeViewer.getControl().getDisplay().syncExec(new Runnable()
- {
- public void run()
- {
- try
- {
- treeViewer.refresh(true);
- }
- catch (Exception ignore)
- {
- }
- }
- });
- }
- catch (Exception ignore)
- {
- }
+ refreshTreeViewer();
}
viewDirtyStateChanged();
@@ -126,10 +111,27 @@ public class CDOEventHandler
}
};
+ private IListener preferenceListener = new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ @SuppressWarnings("unchecked")
+ OMPreferencesChangeEvent<Boolean> preferenceChangeEvent = (OMPreferencesChangeEvent<Boolean>)event;
+ if (OM.PREF_EDITOR_AUTO_RELOAD.getName().equals(preferenceChangeEvent.getPreference().getName()))
+ {
+ if (preferenceChangeEvent.getNewValue().booleanValue())
+ {
+ refreshTreeViewer();
+ }
+ }
+ }
+ };
+
public CDOEventHandler(CDOView view, TreeViewer treeViewer)
{
this.view = view;
this.treeViewer = treeViewer;
+ wirePreferences();
view.getSession().addListener(sessionListener);
view.addListener(viewListener);
}
@@ -146,6 +148,7 @@ public class CDOEventHandler
}
}
+ unwirePreferences();
view = null;
treeViewer = null;
}
@@ -160,7 +163,10 @@ public class CDOEventHandler
return treeViewer;
}
- public void setViewer(TreeViewer viewer)
+ /**
+ * @since 2.0
+ */
+ public void setTreeViewer(TreeViewer viewer)
{
treeViewer = viewer;
}
@@ -168,6 +174,56 @@ public class CDOEventHandler
/**
* @since 2.0
*/
+ public void refreshTreeViewer()
+ {
+ try
+ {
+ treeViewer.getControl().getDisplay().syncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ treeViewer.refresh(true);
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ });
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+
+ /**
+ * @since 2.0
+ */
+ public boolean isAutoReloadEnabled()
+ {
+ return OM.PREF_EDITOR_AUTO_RELOAD.getValue();
+ }
+
+ /**
+ * @since 2.0
+ */
+ protected void wirePreferences()
+ {
+ OM.PREFS.addListener(preferenceListener);
+ }
+
+ /**
+ * @since 2.0
+ */
+ protected void unwirePreferences()
+ {
+ OM.PREFS.removeListener(preferenceListener);
+ }
+
+ /**
+ * @since 2.0
+ */
protected void viewInvalidated(Set<? extends CDOObject> dirtyObjects)
{
new ItemsProcessor(view)
@@ -176,7 +232,10 @@ public class CDOEventHandler
protected void processCDOObject(TreeViewer viewer, InternalCDOObject cdoObject)
{
objectInvalidated(cdoObject);
- viewer.refresh(cdoObject.cdoInternalInstance(), true);
+ if (isAutoReloadEnabled())
+ {
+ viewer.refresh(cdoObject.cdoInternalInstance(), true);
+ }
}
}.processCDOObjects(treeViewer, dirtyObjects);
}