diff options
author | Eike Stepper | 2015-10-29 08:05:31 +0000 |
---|---|---|
committer | Eike Stepper | 2015-10-29 08:05:31 +0000 |
commit | a3efb6b470d0dbaf1cc34ce75544b354984625fd (patch) | |
tree | ba5a0acede7354f251d86385a79c47c75057cc2e /plugins/org.eclipse.oomph.util/src/org | |
parent | 9336e1cfafc30d4f1ee04925bd15fd7de684d0ca (diff) | |
download | org.eclipse.oomph-a3efb6b470d0dbaf1cc34ce75544b354984625fd.tar.gz org.eclipse.oomph-a3efb6b470d0dbaf1cc34ce75544b354984625fd.tar.xz org.eclipse.oomph-a3efb6b470d0dbaf1cc34ce75544b354984625fd.zip |
[480952] Suppress inactive repository lists from targlets on the confirmation and progress pages
https://bugs.eclipse.org/bugs/show_bug.cgi?id=480952
Diffstat (limited to 'plugins/org.eclipse.oomph.util/src/org')
-rw-r--r-- | plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/SuppressHint.java | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/SuppressHint.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/SuppressHint.java new file mode 100644 index 000000000..5aebf8f74 --- /dev/null +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/SuppressHint.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2015 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.oomph.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.emf.common.util.EList; + +import java.util.Iterator; + +/** + * An instance of this {@link Adapter} attached to a {@link Notifier} serves as a hint that the notifier should be suppressed from the UI. + * + * @author Eike Stepper + */ +public class SuppressHint extends AdapterImpl +{ + public static final SuppressHint INSTANCE = new SuppressHint(); + + protected SuppressHint() + { + } + + public static boolean isSuppressed(Object object) + { + if (object instanceof Notifier) + { + Notifier notifier = (Notifier)object; + EList<Adapter> adapters = notifier.eAdapters(); + + for (Adapter adapter : adapters) + { + if (adapter instanceof SuppressHint) + { + return true; + } + } + } + + return false; + } + + public static void setSuppressed(Object object, boolean suppressed) + { + if (object instanceof Notifier) + { + Notifier notifier = (Notifier)object; + EList<Adapter> adapters = notifier.eAdapters(); + + if (suppressed) + { + for (Adapter adapter : notifier.eAdapters()) + { + if (adapter instanceof SuppressHint) + { + return; + } + } + + adapters.add(INSTANCE); + } + else + { + for (Iterator<Adapter> it = adapters.iterator(); it.hasNext();) + { + Adapter adapter = it.next(); + if (adapter instanceof SuppressHint) + { + it.remove(); + } + } + } + } + } +} |