Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2017-03-31 14:14:09 +0000
committerGerrit Code Review @ Eclipse.org2017-04-27 13:12:13 +0000
commit71d46ac5a8601a33b6ff65a425098d42b22cdda0 (patch)
tree5e634cced0aa3f9f87dc024bab15a29fd0e6c8d0 /plugins/infra/services
parent59dad4f4d0ccb1900b1aa3f080c5209d4dc41441 (diff)
downloadorg.eclipse.papyrus-71d46ac5a8601a33b6ff65a425098d42b22cdda0.tar.gz
org.eclipse.papyrus-71d46ac5a8601a33b6ff65a425098d42b22cdda0.tar.xz
org.eclipse.papyrus-71d46ac5a8601a33b6ff65a425098d42b22cdda0.zip
Bug 512554 - [Architecture-General] No Disable Workspace Model Indexer facility
- Start indexing in the moment that a first demand for an index (instance of class CrossReferenceIndex) is done. - The ControlledUnitLabelDecorator is already used earlier (if the project explorer is open). With the patch, it will only start decorating, once indexing has been started, i.e. a Papyrus model is opened. This means that decorations are available late, but avoids starting the indexer almost immediately (for sporadic Papyrus users) - Increase wait timeout added in bug 512554: otherwise we might run regularly into a timeout due to class loading delays Change-Id: I9084f3c4f3023c25d32fa35ade7ae67900439eca
Diffstat (limited to 'plugins/infra/services')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/internal/ui/ControlledUnitLabelDecorator.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/internal/ui/ControlledUnitLabelDecorator.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/internal/ui/ControlledUnitLabelDecorator.java
index e80bbe48a12..53e7e60bbe8 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/internal/ui/ControlledUnitLabelDecorator.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/internal/ui/ControlledUnitLabelDecorator.java
@@ -27,6 +27,7 @@ import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.papyrus.infra.emf.internal.resource.CrossReferenceIndex;
+import org.eclipse.papyrus.infra.emf.internal.resource.index.IndexManager;
import org.eclipse.papyrus.infra.emf.resource.ICrossReferenceIndex;
import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile;
import org.eclipse.papyrus.infra.services.controlmode.ControlModePlugin;
@@ -50,12 +51,7 @@ public class ControlledUnitLabelDecorator extends BaseLabelProvider implements I
*/
public ControlledUnitLabelDecorator() {
super();
-
- // A very coarse-grained label change event
- index = CrossReferenceIndex.getInstance();
- unregisterHandler = CrossReferenceIndex.getInstance().onIndexChanged(
- __ -> fireLabelProviderChanged(new LabelProviderChangedEvent(this)),
- CoreExecutors.getUIExecutorService());
+ index = null;
}
@Override
@@ -72,13 +68,32 @@ public class ControlledUnitLabelDecorator extends BaseLabelProvider implements I
@Override
public void decorate(Object element, IDecoration decoration) {
- if (element instanceof IFile) {
- decorateFile((IFile) element, decoration);
- } else if (element instanceof IPapyrusFile) {
- decorateFile((IPapyrusFile) element, decoration);
+ if (IndexManager.getInstance().isStarted()) {
+ if (element instanceof IFile) {
+ checkIndex();
+ decorateFile((IFile) element, decoration);
+ } else if (element instanceof IPapyrusFile) {
+ checkIndex();
+ decorateFile((IPapyrusFile) element, decoration);
+ }
}
}
+ /**
+ * check whether index reference is already initialized, register listener
+ * and initialize index variable
+ */
+ private void checkIndex() {
+ if (index == null) {
+ index = CrossReferenceIndex.getInstance();
+
+ // A very coarse-grained label change event
+ unregisterHandler = ((CrossReferenceIndex) index).onIndexChanged(
+ __ -> fireLabelProviderChanged(new LabelProviderChangedEvent(this)),
+ CoreExecutors.getUIExecutorService());
+ }
+ }
+
private void decorateFile(IFile file, IDecoration decoration) {
ListenableFuture<SubunitKind> futureKind = getSubunitKind(file);
if (futureKind.isDone()) {

Back to the top