aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Bruch2012-08-25 06:12:17 (EDT)
committerMarcel Bruch2012-08-25 06:12:17 (EDT)
commitcab2e19bb91ccf09930a438066d58cab36734a03 (patch)
treebc65cdec9661bf63e04de29985c1ecda891d6653
parent8588cbd9684a2629ae733571a3d0a17e9df6b6f1 (diff)
downloadorg.eclipse.recommenders-cab2e19bb91ccf09930a438066d58cab36734a03.zip
org.eclipse.recommenders-cab2e19bb91ccf09930a438066d58cab36734a03.tar.gz
org.eclipse.recommenders-cab2e19bb91ccf09930a438066d58cab36734a03.tar.bz2
[extdoc] simplified extdoc provider architecture.refs/changes/62/6562/3
There is only one provider shown at a time. Scheduler, extdoc eventbus and the like have been removed. There is no timeout checking anymore. This change became necessary as (i) the delays and (ii) rendering issues caused by code search engines was too large and (iii) the extdoc provider was never properly working in this setup. Implementation notes: Drag'n Drop for sorting providers as well as storing the order on reopen has been temporarily removed. I plan that Patrick and Olav implement these small features in October. Change-Id: Id48e4c322eedcfb2b172496d711c9c4d3efb63f4
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/plugin.xml53
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/extdoc/rcp/providers/ExtdocProvider.java24
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/ProviderConfigurationPersistenceService.java77
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/JavadocProvider.java (renamed from plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/javadoc/JavadocProvider.java)74
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/OverridesProvider.java (renamed from plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/subclassing/OverridesProvider.java)18
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/SelfCallsProvider.java (renamed from plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/subclassing/SelfCallsProvider.java)22
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/StaticHooksFinder.java (renamed from plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/hooks/StaticHooksFinder.java)43
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/examples/ExamplesProvider.java87
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/Events.java139
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionScheduler.java305
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocIconLoader.java57
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocPreferences.java (renamed from plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/PreferencesFacade.java)6
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocUtils.java15
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocView.java238
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/OrderChangeHandler.java127
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ProviderContentPart.java483
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ProviderOverviewPart.java194
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/SubscriptionManager.java (renamed from plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/SubscriptionManager.java)16
-rw-r--r--plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/wiring/ExtdocModule.java49
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/extdoc/rcp/PlaceholderTest.java20
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/ProviderConfigurationPersistenceServiceTest.java136
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/FastProvider.java39
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/ProviderWithoutData.java29
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowAndFailingProvider.java29
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowProvider.java36
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowProviderWithoutData.java29
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/TooSlowProvider.java37
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/VerySlowProvider.java37
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/BusSpyThatAlsoChecksForUiThread.java148
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionSchedulerFixture.java176
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionSchedulerTest.java265
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/ExtdocProviderTest.java (renamed from tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/ExtdocProviderTest.java)2
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/ExtdocViewTest.java (renamed from tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ExtdocViewTest.java)2
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/JavaSelectionTestUtils.java (renamed from tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/helper/JavaSelectionTestUtils.java)2
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/ProviderImplementation.java (renamed from tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/helper/ProviderImplementation.java)2
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/SubscriptionManagerTest.java (renamed from tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/SubscriptionManagerTest.java)23
-rw-r--r--tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/SubscriptionVerifier.java (renamed from tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/helper/SubscriptionVerifier.java)2
37 files changed, 328 insertions, 2713 deletions
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/plugin.xml b/plugins/org.eclipse.recommenders.extdoc.rcp/plugin.xml
index 08e20ce..5ee316b 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/plugin.xml
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/plugin.xml
@@ -9,7 +9,7 @@
class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.ui.ExtdocView"
icon="icons/extdoc.png"
id="org.eclipse.recommenders.extdoc.rcp.ExtdocView"
- name="Extdoc View"
+ name="Extdoc"
restorable="true">
</view>
</extension>
@@ -22,30 +22,47 @@
<extension
point="org.eclipse.recommenders.extdoc.rcp.provider">
<provider
- class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.providers.javadoc.JavadocProvider"
+ class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.providers.JavadocProvider"
image="icons/provider.javadoc.gif"
- name="Javadoc">
- </provider>
+ name="Javadoc"/>
<provider
- class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.providers.subclassing.OverridesProvider"
+ class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.providers.OverridesProvider"
image="icons/provider.subclassing.gif"
- name="Overrides">
- </provider>
+ name="Overrides"/>
<provider
- class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.providers.subclassing.SelfCallsProvider"
+ class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.providers.SelfCallsProvider"
image="icons/provider.subclassing-patterns.gif"
- name="Self Calls">
- </provider>
- <provider
- class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.providers.examples.ExamplesProvider"
- image="icons/provider.examples.gif"
- name="Snippets">
- </provider>
+ name="Self Calls"/>
<provider
- class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.providers.hooks.StaticHooksFinder"
+ class="org.eclipse.recommenders.injection.ExtensionFactory:org.eclipse.recommenders.internal.extdoc.rcp.providers.StaticHooksFinder"
image="icons/provider.hooks.png"
- name="Static Hooks">
- </provider>
+ name="Static Hooks"/>
</extension>
+ <extension point="org.eclipse.ui.bindings">
+ <key
+ commandId="org.eclipse.ui.views.showView"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M2+M3+Q E">
+ <parameter
+ id="org.eclipse.ui.views.showView.viewId"
+ value="org.eclipse.recommenders.extdoc.rcp.ExtdocView">
+ </parameter>
+ </key>
+ <key
+ platform="carbon"
+ sequence="M2+M3+Q E"
+ commandId=""
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+ <key
+ commandId="org.eclipse.ui.views.showView"
+ platform="carbon"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="COMMAND+ALT+Q E">
+ <parameter
+ id="org.eclipse.ui.views.showView.viewId"
+ value="org.eclipse.recommenders.extdoc.rcp.ExtdocView">
+ </parameter>
+ </key>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/extdoc/rcp/providers/ExtdocProvider.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/extdoc/rcp/providers/ExtdocProvider.java
index e66ee53..19a4ad2 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/extdoc/rcp/providers/ExtdocProvider.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/extdoc/rcp/providers/ExtdocProvider.java
@@ -16,8 +16,32 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.recommenders.utils.Throws;
import org.eclipse.swt.widgets.Display;
+/**
+ * Base class to use when implementing your own extended Javadoc provider. Subclasses should provide one of more public
+ * methods annotated with {@link JavaSelectionSubscriber} and a signature of
+ *
+ * <pre>
+ * @JavaSelectionSubsriber
+ * public void anyMethodName(AnySubtypeOfIJavaElement selectedElement, JavaSelectionEvent selection, Composite parent) {
+ * ..
+ * }
+ * </pre>
+ *
+ * to respond to selection events in the IDE.
+ *
+ * <p>
+ * Note that it these call back methods are always called on a background thread. It's up to the provider to call any UI
+ * operation in the UI thread. Providers may use {@link #runSyncInUiThread(Runnable)} for that purpose as convenient
+ * shortcut.
+ * </p>
+ * @see org.eclipse.recommenders.extdoc.rcp.provider extension point for details on how to register a new provider
+ */
public abstract class ExtdocProvider {
+ @Deprecated
+ /**
+ * Used to indicate whether an extdoc provider has some content to display. This is not needed anymore since v1.1.
+ */
public enum Status {
OK, NOT_AVAILABLE
}
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/ProviderConfigurationPersistenceService.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/ProviderConfigurationPersistenceService.java
deleted file mode 100644
index 921718b..0000000
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/ProviderConfigurationPersistenceService.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.preferences;
-
-import java.util.List;
-
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderActivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDeactivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderOrderChangedEvent;
-
-import com.google.common.eventbus.Subscribe;
-import com.google.inject.Inject;
-
-public class ProviderConfigurationPersistenceService {
-
- private final PreferencesFacade preferences;
- private List<ExtdocProvider> providers;
-
- @Inject
- public ProviderConfigurationPersistenceService(final PreferencesFacade preferences) {
- this.preferences = preferences;
- }
-
- public void initializeProviderConfiguration(final List<ExtdocProvider> providers) {
- this.providers = providers;
- loadNamesAndReorderList();
- loadEnablement();
- }
-
- private void loadNamesAndReorderList() {
- final String[] orderedProviderNames = preferences.loadOrderedProviderNames();
- for (int i = orderedProviderNames.length - 1; i >= 0; i--) {
- moveToTopIfNameExists(orderedProviderNames[i]);
- }
- }
-
- private void moveToTopIfNameExists(final String nameToMove) {
- for (final ExtdocProvider p : providers) {
- if (nameToMove.equals(p.getDescription().getName())) {
- providers.remove(p);
- providers.add(0, p);
- return;
- }
- }
- }
-
- private void loadEnablement() {
- for (final ExtdocProvider p : providers) {
- final boolean isEnabledInPrefs = preferences.isProviderEnabled(p);
- p.setEnabled(isEnabledInPrefs);
- }
- }
-
- @Subscribe
- public void onEvent(final ProviderOrderChangedEvent e) {
- preferences.storeOrderedProviders(providers);
- }
-
- @Subscribe
- public void onEvent(final ProviderActivationEvent e) {
- preferences.storeProviderEnablement(providers);
- }
-
- @Subscribe
- public void onEvent(final ProviderDeactivationEvent e) {
- preferences.storeProviderEnablement(providers);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/javadoc/JavadocProvider.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/JavadocProvider.java
index 89b5620..cfaca58 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/javadoc/JavadocProvider.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/JavadocProvider.java
@@ -10,17 +10,14 @@
* Sebastian Proksch - integrated into new eventbus system
* Marcel Bruch - changed to own browser-based implementation
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.javadoc;
+package org.eclipse.recommenders.internal.extdoc.rcp.providers;
import static org.eclipse.recommenders.internal.rcp.providers.JavaSelectionUtils.resolveSelectionLocationFromJavaElement;
-import static org.eclipse.recommenders.utils.Throws.throwUnreachable;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.runtime.Platform;
@@ -47,10 +44,7 @@ import org.eclipse.recommenders.utils.names.VmTypeName;
import org.eclipse.recommenders.utils.rcp.JavaElementResolver;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
-import org.eclipse.swt.browser.ProgressAdapter;
-import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
@@ -74,76 +68,41 @@ public final class JavadocProvider extends ExtdocProvider {
}
@JavaSelectionSubscriber
- public Status onCompilationUnitSelection(final ITypeRoot root, final JavaSelectionEvent selection,
+ public void onCompilationUnitSelection(final ITypeRoot root, final JavaSelectionEvent selection,
final Composite parent) throws JavaModelException {
final IType type = root.findPrimaryType();
if (type != null) {
render(type, parent);
}
- return Status.OK;
}
@JavaSelectionSubscriber
- public Status onTypeSelection(final IType type, final JavaSelectionEvent selection, final Composite parent)
+ public void onTypeSelection(final IType type, final JavaSelectionEvent selection, final Composite parent)
throws JavaModelException {
render(type, parent);
- return Status.OK;
}
@JavaSelectionSubscriber
- public Status onMethodSelection(final IMethod method, final JavaSelectionEvent selection, final Composite parent)
+ public void onMethodSelection(final IMethod method, final JavaSelectionEvent selection, final Composite parent)
throws JavaModelException {
render(method, parent);
- return Status.OK;
}
@JavaSelectionSubscriber
- public Status onFieldSelection(final IField field, final JavaSelectionEvent selection, final Composite parent)
+ public void onFieldSelection(final IField field, final JavaSelectionEvent selection, final Composite parent)
throws JavaModelException {
render(field, parent);
- return Status.OK;
}
- private Status render(final IMember element, final Composite parent) throws JavaModelException {
+ private void render(final IMember element, final Composite parent) throws JavaModelException {
final String html = findJavadoc(element);
- final CountDownLatch latch = new CountDownLatch(1);
runSyncInUiThread(new Runnable() {
@Override
public void run() {
final Browser browser = new Browser(parent, SWT.NONE);
- final Point maxBrowserSize = findParentWithSizeInformation(parent);
-
- final GridData browserLayoutData = new GridData(maxBrowserSize.x, 0);
- browser.setLayoutData(browserLayoutData);
- browser.setSize(maxBrowserSize.x, 0);
+ browser.setLayoutData(new GridData(GridData.FILL_BOTH));
browser.setText(html);
- browser.addProgressListener(new ProgressAdapter() {
- @Override
- public void completed(final ProgressEvent event) {
- browser.removeProgressListener(this);
- browser.getDisplay().timerExec(5, new Runnable() {
-
- @Override
- public void run() {
- final String script = "function getDocHeight() { var D = document; return Math.max( Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),Math.max(D.body.clientHeight, D.documentElement.clientHeight));} return getDocHeight();";
- Double result = (Double) browser.evaluate(script);
- if (result == null) {
- // terminate re-layout operation if browser
- // widget fails to compute its size
- result = Double.valueOf(SWT.DEFAULT);
- }
- final int height = (int) Math.ceil(result.doubleValue());
- final int width = maxBrowserSize.x;
- final Point computeSize = browser.computeSize(width, height);
- browserLayoutData.widthHint = computeSize.x;
- browserLayoutData.heightHint = computeSize.y;
- browser.setSize(computeSize);
- latch.countDown();
- }
- });
- };
- });
browser.addLocationListener(JavaElementLinks
.createLocationListener(new JavaElementLinks.ILinkHandler() {
@@ -151,9 +110,7 @@ public final class JavadocProvider extends ExtdocProvider {
public void handleDeclarationLink(final IJavaElement target) {
try {
JavaUI.openInEditor(target);
- } catch (final PartInitException e) {
- JavaPlugin.log(e);
- } catch (final JavaModelException e) {
+ } catch (final Exception e) {
JavaPlugin.log(e);
}
}
@@ -205,22 +162,7 @@ public final class JavadocProvider extends ExtdocProvider {
}));
}
- private Point findParentWithSizeInformation(Composite parent) {
- while (parent != null) {
- final Point size = parent.getSize();
- if (size.x > 0) {
- return size;
- }
- parent = parent.getParent();
- }
- throw throwUnreachable();
- }
});
- try {
- latch.await(10, TimeUnit.SECONDS);
- } catch (final InterruptedException e) {
- }
- return Status.OK;
}
private static final String fgStyleSheet = loadStyleSheet();
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/subclassing/OverridesProvider.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/OverridesProvider.java
index 5cbdd48..e5b9fa3 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/subclassing/OverridesProvider.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/OverridesProvider.java
@@ -8,7 +8,7 @@
* Contributors:
* Stefan Henss - initial API and implementation.
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.subclassing;
+package org.eclipse.recommenders.internal.extdoc.rcp.providers;
import static com.google.common.collect.Collections2.filter;
import static com.google.common.collect.Lists.newLinkedList;
@@ -80,22 +80,19 @@ public final class OverridesProvider extends ExtdocProvider {
}
@JavaSelectionSubscriber
- public Status onTypeRootSelection(final ITypeRoot root, final JavaSelectionEvent event, final Composite parent)
+ public void onTypeRootSelection(final ITypeRoot root, final JavaSelectionEvent event, final Composite parent)
throws ExecutionException {
final IType type = root.findPrimaryType();
if (type != null) {
- return onTypeSelection(type, event, parent);
+ onTypeSelection(type, event, parent);
}
- return Status.NOT_AVAILABLE;
}
@JavaSelectionSubscriber
- public Status onTypeSelection(final IType type, final JavaSelectionEvent event, final Composite parent)
+ public void onTypeSelection(final IType type, final JavaSelectionEvent event, final Composite parent)
throws ExecutionException {
- boolean hasData = false;
- hasData |= renderClassOverrideDirectives(type, parent);
- hasData |= renderClassOverridesPatterns(type, parent);
- return hasData ? Status.OK : Status.NOT_AVAILABLE;
+ renderClassOverrideDirectives(type, parent);
+ renderClassOverridesPatterns(type, parent);
}
private boolean renderClassOverrideDirectives(final IType type, final Composite parent) throws ExecutionException {
@@ -155,6 +152,7 @@ public final class OverridesProvider extends ExtdocProvider {
label.setText(message);
setInfoForegroundColor(label);
setInfoBackgroundColor(label);
+ label.setFont(JFaceResources.getDialogFont());
}
private void addDirectives() {
@@ -257,6 +255,7 @@ public final class OverridesProvider extends ExtdocProvider {
final Table table = new Table(group, SWT.NONE | SWT.HIDE_SELECTION);
table.setBackground(ExtdocUtils.createColor(SWT.COLOR_INFO_BACKGROUND));
table.setLayoutData(GridDataFactory.fillDefaults().indent(10, 0).create());
+ table.setFont(JFaceResources.getDialogFont());
final TableColumn column1 = new TableColumn(table, SWT.NONE);
final TableColumn column2 = new TableColumn(table, SWT.NONE);
final TableColumn column3 = new TableColumn(table, SWT.NONE);
@@ -274,7 +273,6 @@ public final class OverridesProvider extends ExtdocProvider {
item.setText(new String[] { phraseText, "override", bar.getText(), stats });
item.setFont(0, JFaceResources.getBannerFont());
item.setForeground(createColor(COLOR_INFO_FOREGROUND));
-
final TableEditor editor = new TableEditor(table);
editor.grabHorizontal = editor.grabVertical = true;
editor.setEditor(bar, item, 2);
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/subclassing/SelfCallsProvider.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/SelfCallsProvider.java
index c09c955..7a332b9 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/subclassing/SelfCallsProvider.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/SelfCallsProvider.java
@@ -8,7 +8,7 @@
* Contributors:
* Stefan Henss - initial API and implementation.
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.subclassing;
+package org.eclipse.recommenders.internal.extdoc.rcp.providers;
import static java.lang.String.format;
import static org.eclipse.recommenders.internal.extdoc.rcp.ui.ExtdocUtils.setInfoBackgroundColor;
@@ -22,6 +22,7 @@ import javax.inject.Inject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeRoot;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.recommenders.extdoc.ClassSelfcallDirectives;
import org.eclipse.recommenders.extdoc.MethodSelfcallDirectives;
import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
@@ -60,37 +61,32 @@ public final class SelfCallsProvider extends ExtdocProvider {
}
@JavaSelectionSubscriber
- public Status onTypeRootSelection(final ITypeRoot root, final JavaSelectionEvent event, final Composite parent)
+ public void onTypeRootSelection(final ITypeRoot root, final JavaSelectionEvent event, final Composite parent)
throws ExecutionException {
final IType type = root.findPrimaryType();
if (type != null) {
- return onTypeSelection(type, event, parent);
+ onTypeSelection(type, event, parent);
}
- return Status.NOT_AVAILABLE;
}
@JavaSelectionSubscriber
- public Status onTypeSelection(final IType type, final JavaSelectionEvent event, final Composite parent)
+ public void onTypeSelection(final IType type, final JavaSelectionEvent event, final Composite parent)
throws ExecutionException {
Optional<ClassSelfcallDirectives> model = cStore.aquireModel(type);
- if (!model.isPresent()) {
- return Status.NOT_AVAILABLE;
+ if (model.isPresent()) {
+ runSyncInUiThread(new TypeSelfcallDirectivesRenderer(type, model.get(), parent));
}
- runSyncInUiThread(new TypeSelfcallDirectivesRenderer(type, model.get(), parent));
- return Status.OK;
}
@JavaSelectionSubscriber
- public Status onMethodSelection(final IMethod method, final JavaSelectionEvent event, final Composite parent) {
+ public void onMethodSelection(final IMethod method, final JavaSelectionEvent event, final Composite parent) {
for (IMethod current = method; current != null; current = JdtUtils.findOverriddenMethod(current).orNull()) {
final Optional<MethodSelfcallDirectives> selfcalls = mStore.aquireModel(current);
if (selfcalls.isPresent()) {
runSyncInUiThread(new MethodSelfcallDirectivesRenderer(method, selfcalls.get(), parent));
- return Status.OK;
}
}
- return Status.NOT_AVAILABLE;
}
private class TypeSelfcallDirectivesRenderer implements Runnable {
@@ -127,6 +123,7 @@ public final class SelfCallsProvider extends ExtdocProvider {
label.setText(message);
setInfoForegroundColor(label);
setInfoBackgroundColor(label);
+ label.setFont(JFaceResources.getDialogFont());
}
private void addDirectives() {
@@ -172,6 +169,7 @@ public final class SelfCallsProvider extends ExtdocProvider {
label.setText(message);
setInfoForegroundColor(label);
setInfoBackgroundColor(label);
+ label.setFont(JFaceResources.getDialogFont());
}
private void addDirectives() {
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/hooks/StaticHooksFinder.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/StaticHooksFinder.java
index baccbc4..878db2e 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/hooks/StaticHooksFinder.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/StaticHooksFinder.java
@@ -8,7 +8,7 @@
* Contributors:
* Marcel Bruch - initial API and implementation.
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.hooks;
+package org.eclipse.recommenders.internal.extdoc.rcp.providers;
import static com.google.common.base.Optional.absent;
import static com.google.common.base.Optional.of;
@@ -38,13 +38,13 @@ import org.eclipse.jdt.core.ITypeRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.util.JdtFlags;
import org.eclipse.jdt.ui.JavaElementLabels;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
import org.eclipse.recommenders.internal.extdoc.rcp.ui.ExtdocUtils;
import org.eclipse.recommenders.rcp.RecommendersPlugin;
import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
import org.eclipse.recommenders.utils.IOUtils;
-import org.eclipse.recommenders.utils.rcp.JavaElementResolver;
import org.eclipse.recommenders.utils.rcp.JdtUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyleRange;
@@ -98,6 +98,7 @@ public class StaticHooksFinder extends ExtdocProvider {
styleRange.length = typeLabelEnd - typeLabelBegin;
styleRange.fontStyle = SWT.BOLD;
styleRange.data = type;
+ styleRange.font = JFaceResources.getHeaderFont();
typeRanges.add(styleRange);
sb.append(IOUtils.LINE_SEPARATOR);
for (final IMethod method : index.get(type)) {
@@ -111,6 +112,7 @@ public class StaticHooksFinder extends ExtdocProvider {
methodStyleRange.length = methodLabelEnd - methodLabelBegin;
methodStyleRange.data = method;
methodStyleRange.underline = true;
+ methodStyleRange.font = JFaceResources.getDialogFont();
// methodStyleRange.fontStyle = SWT.BOLD;
methodStyleRange.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
typeRanges.add(methodStyleRange);
@@ -211,33 +213,6 @@ public class StaticHooksFinder extends ExtdocProvider {
}
}
- // final GridDataFactory labelFactory = GridDataFactory.swtDefaults().indent(3, 5);
- // for (final IType type : index.keySet()) {
- // labelFactory.applyTo(createLabel(container, type.getFullyQualifiedName() + ":", true, false,
- // SWT.COLOR_BLACK, true));
- // final Table table = new Table(container, SWT.NONE | SWT.HIDE_SELECTION);
- // table.setBackground(ExtdocUtils.createColor(SWT.COLOR_INFO_BACKGROUND));
- // table.setLayoutData(GridDataFactory.fillDefaults().indent(10, 0).create());
- // final TableColumn column1 = new TableColumn(table, SWT.NONE);
- //
- // for (final IMethod method : index.get(type)) {
- // // final Link l = createMethodLink(container, method, workspaceBus);
- // // linkFactory.applyTo(l);
- //
- // final Link bar = createMethodLink(table, method, workspaceBus);
- // final TableItem item = new TableItem(table, SWT.NONE);
- // item.setText(new String[] { bar.getText() });
- // item.setFont(0, JFaceResources.getBannerFont());
- // final TableEditor editor = new TableEditor(table);
- // editor.grabHorizontal = editor.grabVertical = true;
- // editor.setEditor(bar, item, 0);
- //
- // }
- // column1.pack();
- //
- // }
- // }
-
private final class MethodNameComparator implements Comparator<IMethod> {
@Override
public int compare(final IMethod o1, final IMethod o2) {
@@ -256,18 +231,16 @@ public class StaticHooksFinder extends ExtdocProvider {
}
}
- private final JavaElementResolver resolver;
private final EventBus workspaceBus;
@Inject
- public StaticHooksFinder(final JavaElementResolver resolver, final EventBus workspaceBus) {
- this.resolver = resolver;
+ public StaticHooksFinder(final EventBus workspaceBus) {
this.workspaceBus = workspaceBus;
}
@JavaSelectionSubscriber
- public Status onPackageRootSelection(final IPackageFragmentRoot root, final JavaSelectionEvent event,
+ public void onPackageRootSelection(final IPackageFragmentRoot root, final JavaSelectionEvent event,
final Composite parent) throws ExecutionException {
final TreeMultimap<IType, IMethod> index = TreeMultimap.create(new TypeNameComparator(),
@@ -284,11 +257,10 @@ public class StaticHooksFinder extends ExtdocProvider {
RecommendersPlugin.logError(x, "Failed to determine static members for %s", root.getElementName());
}
runSyncInUiThread(new HooksRendererRunnable(index, parent));
- return Status.OK;
}
@JavaSelectionSubscriber
- public Status onPackageSelection(final IPackageFragment pkg, final JavaSelectionEvent event, final Composite parent)
+ public void onPackageSelection(final IPackageFragment pkg, final JavaSelectionEvent event, final Composite parent)
throws ExecutionException {
final TreeMultimap<IType, IMethod> index = TreeMultimap.create(new TypeNameComparator(),
@@ -300,7 +272,6 @@ public class StaticHooksFinder extends ExtdocProvider {
}
runSyncInUiThread(new HooksRendererRunnable(index, parent));
- return Status.OK;
}
private void findStaticHooks(final IPackageFragment pkg, final TreeMultimap<IType, IMethod> index)
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/examples/ExamplesProvider.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/examples/ExamplesProvider.java
deleted file mode 100644
index a6b32df..0000000
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/examples/ExamplesProvider.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * Copyright (c) 2011 Stefan Henss.
- * 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:
- * Stefan Henss - initial API and implementation.
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.examples;
-
-import static org.eclipse.recommenders.internal.extdoc.rcp.ui.ExtdocUtils.createSourceCodeArea;
-import static org.eclipse.recommenders.internal.extdoc.rcp.ui.ExtdocUtils.setInfoBackgroundColor;
-
-import javax.inject.Inject;
-
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeRoot;
-import org.eclipse.recommenders.extdoc.CodeExamples;
-import org.eclipse.recommenders.extdoc.CodeSnippet;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.recommenders.utils.names.ITypeName;
-import org.eclipse.recommenders.utils.rcp.JavaElementResolver;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-public final class ExamplesProvider extends ExtdocProvider {
-
- private final JavaElementResolver resolver;
-
- @Inject
- public ExamplesProvider(final JavaElementResolver resolver) {
- this.resolver = resolver;
-
- }
-
- @JavaSelectionSubscriber
- public Status onTypeRootSelection(final ITypeRoot root, final JavaSelectionEvent event, final Composite parent) {
- final IType type = root.findPrimaryType();
- if (type != null) {
- return onTypeSelection(type, event, parent);
- }
- return Status.NOT_AVAILABLE;
- }
-
- @JavaSelectionSubscriber
- public Status onTypeSelection(final IType type, final JavaSelectionEvent event, final Composite parent) {
- final ITypeName typeName = resolver.toRecType(type);
- return Status.NOT_AVAILABLE;
- }
-
- private class TypeSelfcallDirectivesRenderer implements Runnable {
-
- private final CodeExamples examples;
- private final Composite parent;
- private Composite container;
-
- public TypeSelfcallDirectivesRenderer(final IType type, final CodeExamples examples, final Composite parent) {
- this.examples = examples;
- this.parent = parent;
- }
-
- @Override
- public void run() {
- createContainer();
- addDirectives();
- }
-
- private void createContainer() {
- container = new Composite(parent, SWT.NONE);
- setInfoBackgroundColor(container);
- container.setLayout(new GridLayout());
- }
-
- private void addDirectives() {
-
- for (final CodeSnippet snippet : examples.getExamples()) {
- createSourceCodeArea(container, snippet.getCode());
- }
- }
- }
-
-}
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/Events.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/Events.java
deleted file mode 100644
index f465110..0000000
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/Events.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling;
-
-import static org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals;
-import static org.apache.commons.lang3.builder.HashCodeBuilder.reflectionHashCode;
-
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-
-public class Events {
-
- public static abstract class ExtdocEvent {
- @Override
- public boolean equals(final Object obj) {
- return reflectionEquals(this, obj);
- }
-
- @Override
- public int hashCode() {
- return reflectionHashCode(this);
- }
- }
-
- public static abstract class ProviderStatusEvent extends ExtdocEvent {
- public final ExtdocProvider provider;
-
- public ProviderStatusEvent(final ExtdocProvider provider) {
- this.provider = provider;
- }
- }
-
- public static class NewSelectionEvent extends ExtdocEvent {
-
- public final JavaSelectionEvent selection;
-
- public NewSelectionEvent(final JavaSelectionEvent selection) {
- this.selection = selection;
- }
- }
-
- public static class ProviderActivationEvent extends ProviderStatusEvent {
-
- public ProviderActivationEvent(final ExtdocProvider provider) {
- super(provider);
- }
- }
-
- public static class ProviderDeactivationEvent extends ProviderStatusEvent {
- public ProviderDeactivationEvent(final ExtdocProvider provider) {
- super(provider);
- }
- }
-
- public static class ProviderDelayedEvent extends ProviderStatusEvent {
-
- public ProviderDelayedEvent(final ExtdocProvider provider) {
- super(provider);
- }
- }
-
- public static class ProviderFailedEvent extends ProviderStatusEvent {
-
- public final Throwable throwable;
-
- public ProviderFailedEvent(final ExtdocProvider provider, final Throwable throwable) {
- super(provider);
- this.throwable = throwable;
- }
- }
-
- public static class ProviderFinishedEvent extends ProviderStatusEvent {
-
- public ProviderFinishedEvent(final ExtdocProvider provider) {
- super(provider);
- }
- }
-
- public static class ProviderFinishedLateEvent extends ProviderStatusEvent {
-
- public ProviderFinishedLateEvent(final ExtdocProvider provider) {
- super(provider);
- }
- }
-
- public static class ProviderNotAvailableEvent extends ProviderStatusEvent {
- public final boolean hasFinishedLate;
-
- public ProviderNotAvailableEvent(final ExtdocProvider provider) {
- this(provider, false);
- }
-
- public ProviderNotAvailableEvent(final ExtdocProvider provider, final boolean hasFinishedLate) {
- super(provider);
- this.hasFinishedLate = hasFinishedLate;
- }
- }
-
- public static class ProviderOrderChangedEvent extends ExtdocEvent {
-
- public final ExtdocProvider provider;
- public final ExtdocProvider reference;
- public final int oldIndex;
- public final int newIndex;
-
- public ProviderOrderChangedEvent(final ExtdocProvider provider, final ExtdocProvider reference,
- final int oldIndex, final int newIndex) {
- this.provider = provider;
- this.reference = reference;
- this.oldIndex = oldIndex;
- this.newIndex = newIndex;
- }
- }
-
- public static class ProviderSelectionEvent extends ProviderStatusEvent {
-
- public ProviderSelectionEvent(final ExtdocProvider provider) {
- super(provider);
- }
- }
-
- public static class ProviderStartedEvent extends ProviderStatusEvent {
-
- public ProviderStartedEvent(final ExtdocProvider provider) {
- super(provider);
- }
- }
-
- public static class RenderNowEvent extends ExtdocEvent {
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionScheduler.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionScheduler.java
deleted file mode 100644
index 885475e..0000000
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionScheduler.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling;
-
-import static com.google.common.collect.Maps.newHashMap;
-import static com.google.common.util.concurrent.MoreExecutors.listeningDecorator;
-import static java.lang.Thread.MIN_PRIORITY;
-import static org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider.Status.NOT_AVAILABLE;
-import static org.eclipse.recommenders.utils.Checks.cast;
-import static org.eclipse.recommenders.utils.Executors.coreThreadsTimoutExecutor;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Future;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider.Status;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.NewSelectionEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderActivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDeactivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDelayedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFailedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFinishedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFinishedLateEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderNotAvailableEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderStartedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.RenderNowEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.ui.ProviderContentPart;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.recommenders.utils.annotations.Testing;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-import com.google.common.base.Optional;
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.Subscribe;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-
-public class ProviderExecutionScheduler {
-
- @Testing("visibility allows to set test values")
- protected static int RENDER_TIMEOUT_IN_MS = 4000;
- private static final int NUMBER_OF_THREADS = 7;
-
- private static int poolId;
-
- private static ListeningExecutorService createListeningThreadPool(final int numberOfThreads) {
- final String threadPoolId = "Recommenders-extdoc-pool-" + poolId++ + "thread-";
- final ThreadPoolExecutor pool = coreThreadsTimoutExecutor(NUMBER_OF_THREADS, MIN_PRIORITY, threadPoolId);
- final ListeningExecutorService listeningPool = listeningDecorator(pool);
- return listeningPool;
- }
-
- private final ListeningExecutorService pool;
- private final Map<ExtdocProvider, Future<?>> futures;
-
- private final List<ExtdocProvider> providers;
- private final SubscriptionManager subscriptionManager;
- private final ProviderContentPart contentPart;
- private EventBus extdocBus;
-
- private Boolean isAlreadyRendered = false;
- private JavaSelectionEvent currentSelection;
- private final CountDownLatch latch;
-
- public ProviderExecutionScheduler(final List<ExtdocProvider> providers,
- final SubscriptionManager subscriptionManager, final ProviderContentPart contentPart,
- final EventBus extdocBus) {
- this.providers = providers;
- this.extdocBus = extdocBus;
- this.subscriptionManager = subscriptionManager;
- this.contentPart = contentPart;
-
- pool = createListeningThreadPool(NUMBER_OF_THREADS);
- futures = newHashMap();
- extdocBus.register(this);
-
- // ensure latch is always initialized to handle race condition in case
- // of an early dispose
- latch = new CountDownLatch(providers.size());
- }
-
- public void scheduleOnSelection(final JavaSelectionEvent selection) {
- this.currentSelection = selection;
- createNewRenderingPanelInUiThread();
- postInUiThread(new NewSelectionEvent(selection));
-
- for (final ExtdocProvider provider : providers) {
- if (!provider.isEnabled()) {
- latch.countDown();
- continue;
- }
-
- final Composite composite = contentPart.getRenderingArea(provider);
- final Optional<Method> optMethod = subscriptionManager.findSubscribedMethod(provider, selection);
-
- if (optMethod.isPresent()) {
- final OnSelectionCallable callable = new OnSelectionCallable(provider, optMethod.get(), selection,
- composite, latch);
- try {
-
- final ListenableFuture<?> future = pool.submit(callable);
- futures.put(provider, future);
- } catch (final RejectedExecutionException e) {
- // happens if scheduler is already disposed
- latch.countDown();
- }
- } else {
- postInUiThread(new ProviderNotAvailableEvent(provider));
- latch.countDown();
- }
- }
-
- blockUntilAllFinishedOrRenderTimeout();
- postProviderDelayedEventsForLateProviders();
- triggerRenderNow();
- }
-
- private void createNewRenderingPanelInUiThread() {
- // if (contentPart.isDisposed()) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- contentPart.createNewRenderingPanel();
- }
- });
- // }
- }
-
- protected void blockUntilAllFinishedOrRenderTimeout() {
- try {
- latch.await(RENDER_TIMEOUT_IN_MS, TimeUnit.MILLISECONDS);
- } catch (final InterruptedException e) {
- // ignore
- }
- }
-
- private void postProviderDelayedEventsForLateProviders() {
- for (final ExtdocProvider provider : providers) {
- final Future<?> future = futures.get(provider);
- if (future != null && !future.isDone()) {
- postInUiThread(new ProviderDelayedEvent(provider));
- }
- }
- }
-
- private void triggerRenderNow() {
- postInUiThread(new RenderNowEvent());
- isAlreadyRendered = true;
- }
-
- @Subscribe
- public void onEvent(final ProviderActivationEvent e) {
- if (isRunning(e.provider)) {
- return;
- }
-
- final Composite composite = contentPart.getRenderingArea(e.provider);
- final Optional<Method> optMethod = subscriptionManager.findSubscribedMethod(e.provider, currentSelection);
-
- if (optMethod.isPresent()) {
- final OnActivationCallable callable = new OnActivationCallable(e.provider, optMethod.get(),
- currentSelection, composite);
- if (pool.isShutdown()) {
- return;
- }
- final ListenableFuture<?> future = pool.submit(callable);
- futures.put(e.provider, future);
-
- } else {
- postInUiThread(new ProviderNotAvailableEvent(e.provider));
- }
- }
-
- private boolean isRunning(final ExtdocProvider p) {
- return futures.containsKey(p);
- }
-
- @Subscribe
- public void onEvent(final ProviderDeactivationEvent e) {
- final Future<?> future = futures.get(e.provider);
- if (future != null) {
- future.cancel(true);
- }
- }
-
- public void dispose() {
- pool.shutdownNow();
- // pool = null;
- extdocBus.unregister(this);
- extdocBus = new EventBus();
- countLatchToZero();
- }
-
- private void countLatchToZero() {
- for (int i = 0; i < providers.size(); i++) {
- latch.countDown();
- }
- }
-
- private void postInUiThread(final Object event) {
- // Display.getDefault().asyncExec(new Runnable() {
- // @Override
- // public void run() {
- extdocBus.post(event);
- // }
- // });
- }
-
- private class OnActivationCallable implements Callable<Void> {
-
- private final ExtdocProvider provider;
- private final Method method;
- private final JavaSelectionEvent selection;
- private final Composite composite;
-
- public OnActivationCallable(final ExtdocProvider provider, final Method method,
- final JavaSelectionEvent selection, final Composite composite) {
- this.provider = provider;
- this.method = method;
- this.selection = selection;
- this.composite = composite;
- }
-
- @Override
- public Void call() throws Exception {
- postInUiThread(new ProviderStartedEvent(provider));
-
- try {
- final Status returnStatus = invokeProvider();
- if (NOT_AVAILABLE.equals(returnStatus)) {
- postInUiThread(new ProviderNotAvailableEvent(provider, isTooLate()));
- } else if (isTooLate()) {
- postInUiThread(new ProviderFinishedLateEvent(provider));
- } else {
- postInUiThread(new ProviderFinishedEvent(provider));
- }
- } catch (final InterruptedException e) {
- // this happens on cancel request. don't propagate
- } catch (final InvocationTargetException e) {
- // unwrap to increase testability
- postInUiThread(new ProviderFailedEvent(provider, e.getTargetException()));
- } catch (final Exception e) {
- postInUiThread(new ProviderFailedEvent(provider, e));
- }
-
- futures.remove(provider);
- return null;
- }
-
- protected boolean isTooLate() {
- return false;
- }
-
- private Status invokeProvider() throws Exception {
- if (!method.isAccessible()) {
- method.setAccessible(true);
- }
- final Object returnValue = method.invoke(provider, selection.getElement(), selection, composite);
- final Status status = cast(returnValue);
- return status;
- }
- }
-
- private class OnSelectionCallable extends OnActivationCallable {
- private final CountDownLatch latch;
-
- public OnSelectionCallable(final ExtdocProvider provider, final Method method,
- final JavaSelectionEvent selection, final Composite composite, final CountDownLatch latch) {
- super(provider, method, selection, composite);
- this.latch = latch;
- }
-
- @Override
- public Void call() throws Exception {
- try {
- super.call();
- return null;
- } finally {
- latch.countDown();
- }
- }
-
- @Override
- protected boolean isTooLate() {
- return isAlreadyRendered;
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocIconLoader.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocIconLoader.java
deleted file mode 100644
index db77971..0000000
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocIconLoader.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.ui;
-
-import static java.lang.String.format;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.recommenders.internal.extdoc.rcp.wiring.ExtdocPlugin;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-public class ExtdocIconLoader {
-
- public enum Icon {
- STARTED, DELAYED, FAILED, NOT_AVAILABLE,
- }
-
- public Image getImage(final Icon icon) {
- switch (icon) {
- case STARTED:
- return getImageFromFile("loading.png");
- case DELAYED:
- return getSharedImage(ISharedImages.IMG_OBJS_WARN_TSK);
- case FAILED:
- return getSharedImage(ISharedImages.IMG_OBJS_ERROR_TSK);
- case NOT_AVAILABLE:
- return getImageFromFile("not_available.png");
- default:
- return null;
- }
- }
-
- private static Image getSharedImage(final String img) {
- return PlatformUI.getWorkbench().getSharedImages().getImage(img);
- }
-
- private static Image getImageFromFile(final String iconName) {
- final String path = format("icons/%s", iconName);
- final ImageDescriptor imageDescriptor = AbstractUIPlugin
- .imageDescriptorFromPlugin(ExtdocPlugin.PLUGIN_ID, path);
- if (imageDescriptor == null) {
- return getSharedImage(ISharedImages.IMG_TOOL_DELETE);
- } else {
- return imageDescriptor.createImage();
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/PreferencesFacade.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocPreferences.java
index f27d433..2214fe8 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/PreferencesFacade.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocPreferences.java
@@ -8,7 +8,7 @@
* Contributors:
* Sebastian Proksch - initial API and implementation
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.preferences;
+package org.eclipse.recommenders.internal.extdoc.rcp.ui;
import static java.lang.Integer.parseInt;
@@ -22,7 +22,7 @@ import org.eclipse.recommenders.internal.extdoc.rcp.wiring.ExtdocPlugin;
import org.eclipse.recommenders.utils.Throws;
import org.osgi.service.prefs.BackingStoreException;
-public class PreferencesFacade {
+public class ExtdocPreferences {
private final IEclipsePreferences preferences;
@@ -30,7 +30,7 @@ public class PreferencesFacade {
private static final String DISABLED_PROVIDERS = "disabledProviders";
private static final String SASH_WEIGHTS = "sashWeights";
- public PreferencesFacade() {
+ public ExtdocPreferences() {
preferences = InstanceScope.INSTANCE.getNode(ExtdocPlugin.PLUGIN_ID);
}
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocUtils.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocUtils.java
index 29d20a1..5493949 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocUtils.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocUtils.java
@@ -67,12 +67,18 @@ import com.google.common.eventbus.EventBus;
public final class ExtdocUtils {
static final Font CODEFONT = JFaceResources.getTextFont();
- private static final Font BOLDFONT = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
+ private static final Font BOLDFONT = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
private static final Map<Integer, Color> COLORCACHE = new HashMap<Integer, Color>();
private ExtdocUtils() {
}
+ public static void disposeChildren(Composite parent) {
+ for (Control c : parent.getChildren()) {
+ c.dispose();
+ }
+ }
+
public static void setInfoBackgroundColor(final Control c) {
final Display display = c.getDisplay();
final Color color = display.getSystemColor(COLOR_INFO_BACKGROUND);
@@ -108,6 +114,8 @@ public final class ExtdocUtils {
table.setBackground(createColor(COLOR_INFO_BACKGROUND));
table.setForeground(createColor(COLOR_INFO_FOREGROUND));
table.setLayoutData(GridDataFactory.fillDefaults().indent(10, 0).create());
+ table.setFont(JFaceResources.getDialogFont());
+
final TableColumn column1 = new TableColumn(table, SWT.NONE);
final TableColumn column2 = new TableColumn(table, SWT.NONE);
final TableColumn column3 = new TableColumn(table, SWT.NONE);
@@ -126,7 +134,7 @@ public final class ExtdocUtils {
final Link bar = createMethodLink(table, method, resolver, bus);
final TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[] { phraseText, middlePhrase, bar.getText(), stats });
- item.setFont(0, JFaceResources.getBannerFont());
+ item.setFont(0, JFaceResources.getHeaderFont());
final TableEditor editor = new TableEditor(table);
editor.grabHorizontal = editor.grabVertical = true;
editor.setEditor(bar, item, 2);
@@ -150,6 +158,7 @@ public final class ExtdocUtils {
link.setText(text);
link.setBackground(ExtdocUtils.createColor(SWT.COLOR_INFO_BACKGROUND));
link.setToolTipText(tooltip);
+ link.setFont(JFaceResources.getDialogFont());
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
@@ -168,6 +177,7 @@ public final class ExtdocUtils {
final Link link = new Link(parent, SWT.NONE);
link.setText(text);
link.setBackground(ExtdocUtils.createColor(SWT.COLOR_INFO_BACKGROUND));
+ link.setFont(JFaceResources.getDialogFont());
link.setToolTipText(tooltip);
link.addSelectionListener(new SelectionAdapter() {
@Override
@@ -216,6 +226,7 @@ public final class ExtdocUtils {
public static CLabel createCLabel(final Composite parent, final String text, final boolean bold, final Image image) {
final CLabel label = new CLabel(parent, SWT.NONE);
+ setInfoBackgroundColor(label);
label.setText(text);
if (bold) {
label.setFont(BOLDFONT);
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocView.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocView.java
index da8857c..2fc5da3 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocView.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ExtdocView.java
@@ -10,27 +10,46 @@
*/
package org.eclipse.recommenders.internal.extdoc.rcp.ui;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.List;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.ui.JavaElementLabelProvider;
+import org.eclipse.jdt.ui.JavaElementLabels;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.internal.extdoc.rcp.preferences.PreferencesFacade;
-import org.eclipse.recommenders.internal.extdoc.rcp.preferences.ProviderConfigurationPersistenceService;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.ProviderExecutionScheduler;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.SubscriptionManager;
import org.eclipse.recommenders.internal.extdoc.rcp.wiring.ExtdocModule.Extdoc;
+import org.eclipse.recommenders.rcp.RecommendersPlugin;
import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
import org.eclipse.recommenders.utils.rcp.PartListener2Adapter;
+import org.eclipse.recommenders.utils.rcp.RCPUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.part.ViewPart;
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
@@ -39,65 +58,117 @@ import com.google.inject.Inject;
public class ExtdocView extends ViewPart {
public static final String ID = "org.eclipse.recommenders.extdoc.rcp.ExtdocView";
+
private final EventBus workspaceBus;
- private final EventBus extdocBus;
private final SubscriptionManager subscriptionManager;
private final List<ExtdocProvider> providers;
- private final PreferencesFacade preferences;
- private final ProviderOverviewPart overviewPart;
- private final ProviderContentPart contentPart;
+ private final ExtdocPreferences preferences;
+
+ private static final long LABEL_FLAGS = JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.M_PRE_RETURNTYPE
+ | JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_PARAMETER_NAMES
+ | JavaElementLabels.M_EXCEPTIONS | JavaElementLabels.F_PRE_TYPE_SIGNATURE
+ | JavaElementLabels.T_TYPE_PARAMETERS;
+
+ private final JavaElementLabelProvider labelProvider = new JavaElementLabelProvider((int) LABEL_FLAGS);
- private ProviderExecutionScheduler scheduler;
- private final Lock schedulerLock = new ReentrantLock();
- private SashForm sashForm;
- protected boolean visible = true;
+ private SashForm sash;
+ private ScrolledComposite scrollable;
+ private Composite content;
+ private TableViewer viewer;
+
+ private boolean visible = true;
+
+ private ExtdocProvider activeProvider;
+ private JavaSelectionEvent activeSelection;
@Inject
- public ExtdocView(final EventBus workspaceBus, @Extdoc final EventBus extdocBus,
- final SubscriptionManager subscriptionManager, final ExtdocIconLoader iconLoader,
- final List<ExtdocProvider> providers, final PreferencesFacade preferences,
- final ProviderOverviewPart overviewPart, final ProviderContentPart contentPart,
- final ProviderConfigurationPersistenceService ps) {
+ public ExtdocView(final EventBus workspaceBus, final SubscriptionManager subscriptionManager,
+ final List<ExtdocProvider> providers, final ExtdocPreferences preferences) {
this.workspaceBus = workspaceBus;
- this.extdocBus = extdocBus;
this.subscriptionManager = subscriptionManager;
this.providers = providers;
this.preferences = preferences;
- this.overviewPart = overviewPart;
- this.contentPart = contentPart;
}
@Override
public void createPartControl(final Composite parent) {
- createUiElements(parent);
- subscribeToEventBusses();
+ createSash(parent);
+ createProviderOverview();
+ createContentArea();
+ addVisibilityListener();
+ applyUiPreferences();
+ workspaceBus.register(this);
+ }
- addPartListener();
+ private void createSash(final Composite parent) {
+ sash = new SashForm(parent, SWT.SMOOTH);
+ sash.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
+ sash.addDisposeListener(new DisposeListener() {
+ @Override
+ public void widgetDisposed(final DisposeEvent e) {
+ preferences.storeSashWeights(sash.getWeights());
+ }
+ });
}
- private void createUiElements(final Composite parent) {
- sashForm = new SashForm(parent, SWT.SMOOTH);
- sashForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
+ private void createProviderOverview() {
+ viewer = new TableViewer(sash);
+ viewer.setContentProvider(new ArrayContentProvider());
+ viewer.setLabelProvider(new LabelProvider() {
- overviewPart.createControl(sashForm);
- contentPart.createControl(sashForm);
+ @Override
+ public String getText(Object element) {
+ return ((ExtdocProvider) element).getDescription().getName();
+ }
- sashForm.setWeights(preferences.loadSashWeights());
- sashForm.addDisposeListener(new DisposeListener() {
@Override
- public void widgetDisposed(final DisposeEvent e) {
- preferences.storeSashWeights(sashForm.getWeights());
+ public Image getImage(Object element) {
+ return ((ExtdocProvider) element).getDescription().getImage();
+ }
+ });
+ viewer.setInput(providers);
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ ExtdocProvider newProvider = RCPUtils.<ExtdocProvider> first(event.getSelection()).orNull();
+ if (newProvider == activeProvider) {
+ return;
+ }
+ activeProvider = newProvider;
+ Job job = new Job("Update Extdoc") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ onJavaSelection(activeSelection);
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem(true);
+ job.schedule();
}
});
+ viewer.setSelection(new StructuredSelection(Iterables.getFirst(providers, null)));
}
- private void subscribeToEventBusses() {
- extdocBus.register(contentPart);
- extdocBus.register(overviewPart);
- workspaceBus.register(this);
+ private void createContentArea() {
+ scrollable = new ScrolledComposite(sash, SWT.H_SCROLL | SWT.V_SCROLL);
+ scrollable.getVerticalBar().setIncrement(20);
+ scrollable.setExpandHorizontal(true);
+ scrollable.setExpandVertical(true);
+ content = new Composite(scrollable, SWT.NONE);
+ content.setLayout(new GridLayout());
+ content.setFont(JFaceResources.getDialogFont());
+ ExtdocUtils.setInfoBackgroundColor(content);
+
+ scrollable.setContent(content);
+ }
+
+ private void applyUiPreferences() {
+ sash.setWeights(preferences.loadSashWeights());
}
- private void addPartListener() {
+ private void addVisibilityListener() {
getViewSite().getPage().addPartListener(new PartListener2Adapter() {
@Override
@@ -123,47 +194,86 @@ public class ExtdocView extends ViewPart {
@Override
public void dispose() {
- unsubscribeFromEventBusses();
- disposeScheduler();
- super.dispose();
- }
-
- private void unsubscribeFromEventBusses() {
- extdocBus.unregister(contentPart);
- extdocBus.unregister(overviewPart);
workspaceBus.unregister(this);
+ super.dispose();
}
@Subscribe
@AllowConcurrentEvents
public void onJavaSelection(final JavaSelectionEvent selection) {
- if (visible) {
- disposeScheduler();
- scheduleNewSelection(selection);
+ this.activeSelection = selection;
+ if (visible && activeProvider != null && activeSelection != null) {
+ try {
+ disposeOldContentAndDisableRedrawOnContentArea();
+ runProvider(selection);
+ refreshAndEnableDrawContentArea();
+ } catch (Exception e) {
+ RecommendersPlugin.logError(e, "Exception during view update." + selection);
+ }
}
}
- // it might be necessary to add a lock here... a synchronized method is not
- // possible as this method would block the "syncScheduling" method
- private void disposeScheduler() {
- if (scheduler != null) {
- scheduler.dispose();
- scheduler = null;
+ private void runProvider(JavaSelectionEvent selection) throws IllegalAccessException, InvocationTargetException {
+ Optional<Method> opt = subscriptionManager.findSubscribedMethod(activeProvider, selection);
+ if (opt.isPresent()) {
+ Method method = opt.get();
+ IJavaElement element = selection.getElement();
+ method.invoke(activeProvider, element, selection, content);
}
}
- private void scheduleNewSelection(final JavaSelectionEvent selection) {
- try {
- schedulerLock.lock();
- scheduler = new ProviderExecutionScheduler(providers, subscriptionManager, contentPart, extdocBus);
- scheduler.scheduleOnSelection(selection);
- } finally {
- schedulerLock.unlock();
+ private void refreshAndEnableDrawContentArea() {
+ content.getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ Point size = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ scrollable.setMinSize(size);
+ content.layout();
+ // content.setRedraw(true);
+ }
+ });
+ }
+
+ private void disposeOldContentAndDisableRedrawOnContentArea() {
+ content.getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ // content.setRedraw(false);
+ ExtdocUtils.disposeChildren(content);
+ addCurrentSelectionHeader();
+ }
+ });
+ }
+
+ private void addCurrentSelectionHeader() {
+ final IJavaElement element = activeSelection.getElement();
+ final String text;
+ switch (element.getElementType()) {
+ case IJavaElement.PACKAGE_FRAGMENT_ROOT:
+ case IJavaElement.PACKAGE_FRAGMENT:
+ text = element.getElementName();
+ break;
+ case IJavaElement.LOCAL_VARIABLE:
+ text = JavaElementLabels.getElementLabel(element, JavaElementLabels.F_PRE_TYPE_SIGNATURE
+ | JavaElementLabels.F_POST_QUALIFIED);
+ break;
+ default:
+ text = JavaElementLabels.getElementLabel(element, LABEL_FLAGS);
+ break;
}
+ Composite header = new Composite(content, SWT.NONE);
+ ExtdocUtils.setInfoBackgroundColor(header);
+ header.setLayout(new GridLayout(2, false));
+ new Label(header, SWT.NONE).setImage(labelProvider.getImage(element));
+ Label name = new Label(header, SWT.NONE);
+ name.setText(text);
+ name.setFont(JFaceResources.getHeaderFont());
}
@Override
public void setFocus() {
- contentPart.setFocus();
+ viewer.getControl().setFocus();
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/OrderChangeHandler.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/OrderChangeHandler.java
deleted file mode 100644
index 191539e..0000000
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/OrderChangeHandler.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.ui;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-import java.util.List;
-
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSource;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.DropTargetAdapter;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Widget;
-
-public class OrderChangeHandler extends DropTargetAdapter implements DragSourceListener {
-
- public interface OrderChangedListener {
- public void orderChanged(int oldIndex, int newIndex);
- }
-
- private final Table table;
- private TableItem dragSourceItem;
-
- private final List<OrderChangedListener> listeners = newArrayList();
-
- public static OrderChangeHandler enable(final Table table) {
- return new OrderChangeHandler(table);
- }
-
- private OrderChangeHandler(final Table table) {
- this.table = table;
-
- final Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
- final int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
-
- final DragSource source = new DragSource(table, operations);
- source.setTransfer(types);
- source.addDragListener(this);
-
- final DropTarget target = new DropTarget(table, operations);
- target.setTransfer(types);
- target.addDropListener(this);
- }
-
- public void addListener(final OrderChangedListener listener) {
- listeners.add(listener);
- }
-
- public void removeListener(final OrderChangedListener listener) {
- listeners.remove(listener);
- }
-
- private void notifyAll(final int oldIndex, final int newIndex) {
- for (final OrderChangedListener listener : listeners) {
- listener.orderChanged(oldIndex, newIndex);
- }
- }
-
- @Override
- public void dragStart(final DragSourceEvent event) {
- final TableItem[] selection = table.getSelection();
- dragSourceItem = selection[0];
- }
-
- @Override
- public void dragSetData(final DragSourceEvent event) {
- event.data = dragSourceItem.getText();
- }
-
- @Override
- public void dragFinished(final DragSourceEvent event) {
- table.deselectAll();
- dragSourceItem = null;
- }
-
- @Override
- public void dragOver(final DropTargetEvent event) {
- event.feedback = DND.FEEDBACK_INSERT_BEFORE;
- }
-
- @Override
- public void drop(final DropTargetEvent event) {
- final boolean isDraggingFromWithinTable = dragSourceItem != null;
- if (isDraggingFromWithinTable) {
- final Widget dropTargetItem = event.item;
-
- final int selIndex = findIndex(dragSourceItem, table);
- int dropIndex = findIndex(dropTargetItem, table);
-
- if (dropIndex > selIndex) {
- dropIndex--;
- }
-
- if (dropIndex != selIndex) {
- notifyAll(selIndex, dropIndex);
- }
- } else {
- // "sorry, dragged from outside"
- }
- }
-
- private int findIndex(final Widget dropTarget, final Table table) {
- int index = 0;
- for (final TableItem item : table.getItems()) {
- if (item.equals(dropTarget)) {
- return index;
- }
- index++;
- }
- return index;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ProviderContentPart.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ProviderContentPart.java
deleted file mode 100644
index 4d00f19..0000000
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ProviderContentPart.java
+++ /dev/null
@@ -1,483 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.ui;
-
-import static java.lang.String.format;
-import static org.eclipse.recommenders.internal.extdoc.rcp.ui.ExtdocUtils.setInfoBackgroundColor;
-import static org.eclipse.recommenders.internal.extdoc.rcp.ui.ExtdocUtils.setInfoForegroundColor;
-import static org.eclipse.recommenders.rcp.RecommendersPlugin.logWarning;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.ui.JavaElementLabelProvider;
-import org.eclipse.jdt.ui.JavaElementLabels;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.NewSelectionEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDeactivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDelayedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFailedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFinishedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFinishedLateEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderNotAvailableEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderOrderChangedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderSelectionEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderStatusEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.RenderNowEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.wiring.ExtdocPlugin;
-import org.eclipse.recommenders.rcp.RecommendersPlugin;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-
-import com.google.common.base.Throwables;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-import com.google.common.eventbus.Subscribe;
-import com.google.inject.Inject;
-
-public class ProviderContentPart {
-
- private final List<ExtdocProvider> providers;
-
- private Composite stack;
- private StackLayout stackLayout;
-
- private Composite container;
- private Composite visiblePanel;
- private Composite renderingPanel;
- private ScrolledComposite scrollingComposite;
- private Composite scrolledContent;
-
- private static final long LABEL_FLAGS = JavaElementLabels.ALL_FULLY_QUALIFIED | JavaElementLabels.M_PRE_RETURNTYPE
- | JavaElementLabels.M_PARAMETER_TYPES | JavaElementLabels.M_PARAMETER_NAMES
- | JavaElementLabels.M_EXCEPTIONS | JavaElementLabels.F_PRE_TYPE_SIGNATURE
- | JavaElementLabels.T_TYPE_PARAMETERS;
-
- // using class instead of instances to be sure that only one provider of a given type exists. We have rendering
- // issues and this is used as an additional check:
- private Map<ExtdocProvider, ProviderArea> providerAreas;
- private CLabel selectionStatus;
- private final JavaElementLabelProvider labelProvider;
-
- private final GridLayoutFactory defaultGridLayoutFactory = GridLayoutFactory.fillDefaults().spacing(0, 0);
- private final GridDataFactory defaultGridDataFactory = GridDataFactory.fillDefaults().grab(true, true);
-
- private HashMultimap<Class<? extends ExtdocProvider>, Class<?>> providerEvents;
-
- @Inject
- public ProviderContentPart(final List<ExtdocProvider> providers) {
- this.providers = ImmutableList.copyOf(providers);
- this.labelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT);
- }
-
- public void createControl(final Composite parent) {
- container = new Composite(parent, SWT.NONE);
- container.setLayout(defaultGridLayoutFactory.create());
-
- createScrollingComposite();
- createScrolledContent();
- createStack();
-
- createWaitingScreen();
- createNewRenderingPanel();
-
- stackLayout.topControl = visiblePanel;
- }
-
- private void createScrollingComposite() {
- scrollingComposite = new ScrolledComposite(container, SWT.V_SCROLL | SWT.H_SCROLL);
- scrollingComposite.setLayout(defaultGridLayoutFactory.create());
- scrollingComposite.setLayoutData(defaultGridDataFactory.create());
- scrollingComposite.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- scrollingComposite.setExpandVertical(true);
- scrollingComposite.setExpandHorizontal(true);
- scrollingComposite.getVerticalBar().setIncrement(50);
- scrollingComposite.getHorizontalBar().setIncrement(50);
-
- }
-
- private void createScrolledContent() {
- scrolledContent = new Composite(scrollingComposite, SWT.NONE);
- scrolledContent.setLayout(defaultGridLayoutFactory.create());
-
- scrolledContent.addListener(SWT.Resize, new Listener() {
-
- @Override
- public void handleEvent(final Event event) {
- resizeScrolledComposite();
- }
- });
-
- scrollingComposite.setContent(scrolledContent);
- }
-
- private void resizeScrolledComposite() {
- final int newWidth = scrolledContent.getSize().x;
- final Point newSize = scrolledContent.computeSize(newWidth, SWT.DEFAULT);
- scrollingComposite.setMinHeight(newSize.y);
- }
-
- private void createStack() {
- stack = new Composite(scrolledContent, SWT.NONE);
- stack.setLayoutData(defaultGridDataFactory.create());
-
- stackLayout = new StackLayout();
- stack.setLayout(stackLayout);
- }
-
- private void createWaitingScreen() {
- visiblePanel = new Composite(stack, SWT.NONE);
- visiblePanel.setLayout(new FillLayout());
- visiblePanel.setBackground(container.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- final Label l = new Label(visiblePanel, SWT.NONE);
- l.setText("waiting for selection...");
- }
-
- public void setFocus() {
- visiblePanel.setFocus();
- }
-
- public Composite getRenderingArea(final ExtdocProvider p) {
- return providerAreas.get(p).getContentArea();
- }
-
- public void createNewRenderingPanel() {
- renderingPanel = new Composite(stack, SWT.NONE);
- renderingPanel.setRedraw(false);
- renderingPanel.setBackground(renderingPanel.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- renderingPanel.setLayout(defaultGridLayoutFactory.create());
-
- createSelectionInfoArea();
- providerAreas = Maps.newHashMap();
- providerEvents = HashMultimap.create();
-
- for (final ExtdocProvider p : providers) {
- final ProviderArea providerArea = new ProviderArea(p);
- providerArea.createControl(renderingPanel);
- providerAreas.put(p, providerArea);
- }
-
- // renderingPanel.layout();
- }
-
- private void createSelectionInfoArea() {
- final Composite selectionArea = new Composite(renderingPanel, SWT.NONE);
- setInfoBackgroundColor(selectionArea);
-
- selectionArea.setLayout(defaultGridLayoutFactory.create());
- selectionArea.setLayoutData(defaultGridDataFactory.grab(true, false).create());
-
- selectionStatus = new CLabel(selectionArea, SWT.NONE);
- setInfoBackgroundColor(selectionStatus);
- setInfoForegroundColor(selectionArea);
- selectionStatus.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
- selectionStatus.setBackground(selectionArea.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- @Subscribe
- public void onEvent(final NewSelectionEvent e) {
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- updateSelectionStatus(e.selection);
- }
- });
- }
-
- private void updateSelectionStatus(final JavaSelectionEvent selection) {
- final IJavaElement element = selection.getElement();
-
- final String text;
- switch (element.getElementType()) {
- case IJavaElement.PACKAGE_FRAGMENT_ROOT:
- case IJavaElement.PACKAGE_FRAGMENT:
- text = element.getElementName();
- break;
- case IJavaElement.LOCAL_VARIABLE:
- text = JavaElementLabels.getElementLabel(element, JavaElementLabels.F_PRE_TYPE_SIGNATURE
- | JavaElementLabels.F_POST_QUALIFIED);
- break;
- default:
- text = JavaElementLabels.getElementLabel(element, LABEL_FLAGS);
- break;
- }
- selectionStatus.setText(text);
- selectionStatus.setImage(labelProvider.getImage(element));
- }
-
- @Subscribe
- public void onEvent(final RenderNowEvent e) {
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- makeRenderingPanelVisible();
- relayout();
- scrollToTop();
- renderingPanel.setRedraw(true);
- }
- });
- }
-
- private void scrollToTop() {
- scrollingComposite.setOrigin(0, 0);
- }
-
- private void makeRenderingPanelVisible() {
- stackLayout.topControl = renderingPanel;
- visiblePanel.dispose();
- visiblePanel = renderingPanel;
- }
-
- private void relayout() {
- resizeScrolledComposite();
- stack.layout();
- }
-
- @Subscribe
- public void onEvent(final ProviderNotAvailableEvent e) {
- recordProviderEvent(e);
- asyncExec(new Runnable() {
-
- @Override
- public void run() {
- final ProviderArea area = providerAreas.get(e.provider);
-
- if (e.hasFinishedLate) {
- area.setStatus("provider finished without data");
- area.showStatus();
- } else {
- area.hide();
- }
- }
- });
- }
-
- private void asyncExec(final Runnable runnable) {
- container.getDisplay().asyncExec(runnable);
- }
-
- @Subscribe
- public void onEvent(final ProviderSelectionEvent e) {
- recordProviderEvent(e);
-
- asyncExec(new Runnable() {
-
- @Override
- public void run() {
- final ProviderArea area = providerAreas.get(e.provider);
- scrollingComposite.setOrigin(area.getLocation());
- }
- });
- }
-
- @Subscribe
- public void onEvent(final ProviderFinishedEvent e) {
- if (hasSentFinishedEventBefore(e.provider)) {
- return;
- }
- recordProviderEvent(e);
-
- asyncExec(new Runnable() {
-
- @Override
- public void run() {
- final ProviderArea area = providerAreas.get(e.provider);
- area.showContent();
-
- }
- });
- }
-
- @Subscribe
- public void onEvent(final ProviderDelayedEvent e) {
- if (isProviderFinishedAlready(e)) {
- return;
- }
- recordProviderEvent(e);
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- final ProviderArea area = providerAreas.get(e.provider);
- area.setStatus("provider is delayed...");
- area.showStatus();
- }
- });
- }
-
- private boolean isProviderFinishedAlready(final ProviderDelayedEvent e) {
- // due to concurrency there might be milliseconds that may cause a layout glitch: a provider rendered the
- // contents already but the scheduler finds this provider to be failed. This is checked as handled here.
- // TODO: is there a better way to handle this in the scheduler?
- final Class<?>[] finishedEvents = { ProviderFinishedEvent.class, ProviderFinishedLateEvent.class,
- ProviderFailedEvent.class, ProviderNotAvailableEvent.class };
- return providerEventsContainsAnyOf(e.provider, finishedEvents);
- }
-
- private boolean providerEventsContainsAnyOf(final ExtdocProvider provider, final Class<?>... events) {
- for (final Class<?> e : events) {
- if (providerEvents.containsEntry(provider.getClass(), e)) {
- return true;
- }
- }
- return false;
- }
-
- @Subscribe
- public void onEvent(final ProviderFinishedLateEvent e) {
- if (hasSentFinishedEventBefore(e.provider)) {
- return;
- }
- recordProviderEvent(e);
-
- Display.getDefault().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- final ProviderArea area = providerAreas.get(e.provider);
- final String statusMessage = "provider finished late <a>show</a>";
- area.setStatusWithCallback(statusMessage, new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent e) {
- area.showContent();
- relayout();
- }
- });
- area.showStatus();
- area.layout();
- }
- });
- }
-
- private void recordProviderEvent(final ProviderStatusEvent e) {
- providerEvents.put(e.provider.getClass(), e.getClass());
- }
-
- private boolean hasSentFinishedEventBefore(final ExtdocProvider provider) {
- if (providerEventsContainsAnyOf(provider, ProviderFinishedEvent.class, ProviderFinishedLateEvent.class,
- ProviderNotAvailableEvent.class)) {
- logWarning(
- "Provider %s send 'ProviderFinishedLateEvent' but send other finished events before. Rejecting further paint events.",
- provider.getClass());
- return true;
- }
- return false;
- }
-
- @Subscribe
- public void onEvent(final ProviderFailedEvent e) {
- recordProviderEvent(e);
-
- asyncExec(new Runnable() {
-
- @Override
- public void run() {
-
- final ProviderArea area = providerAreas.get(e.provider);
- final String statusMessage = "provider failed <a>show exception</a>";
- area.setStatusWithCallback(statusMessage, new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent event) {
- // REVIEW: TODO: printing the potentially LARGE stacktrace
- // looked odd... details view of ErrorDialog is
- // odd too. What to do?
- // final String details =
- // Throwables.getStackTraceAsString(e.exception);
- final String providerName = e.provider.getDescription().getName();
-
- final String dialogTitle = format("Extdoc Provider '%s' Failure", providerName);
- final String errorMessage = findFirstNonNullErrorMessage(e.throwable);
- final String rootCauseMessage = Throwables.getRootCause(e.throwable).getMessage();
-
- final Status status = new Status(IStatus.ERROR, ExtdocPlugin.PLUGIN_ID, errorMessage,
- e.throwable);
- final String message = format(
- "Provider %s failed with the following message: %s - %s\n\nSee error log for more details.",
- providerName, errorMessage, rootCauseMessage);
- RecommendersPlugin.logError(new Exception(e.throwable), message);
- ErrorDialog.openError(container.getShell(), dialogTitle, message, status);
- }
-
- private String findFirstNonNullErrorMessage(final Throwable exception) {
- final List<Throwable> causalChain = Throwables.getCausalChain(exception);
- String errorMessage = null;
- for (final Throwable t : causalChain) {
- errorMessage = t.getMessage();
- if (errorMessage != null) {
- break;
- }
- }
- return errorMessage;
- }
- });
- area.showStatus();
- }
- });
- }
-
- @Subscribe
- public void onEvent(final ProviderOrderChangedEvent e) {
- asyncExec(new Runnable() {
-
- @Override
- public void run() {
- final ProviderArea areaToMove = providerAreas.get(e.provider);
- final ProviderArea areaRef = providerAreas.get(e.reference);
-
- final boolean isAbove = e.oldIndex > e.newIndex;
- if (isAbove) {
- areaToMove.moveAbove(areaRef);
- } else {
- areaToMove.moveBelow(areaRef);
- }
- relayout();
- }
- });
- }
-
- @Subscribe
- public void onEvent(final ProviderDeactivationEvent e) {
- asyncExec(new Runnable() {
-
- @Override
- public void run() {
- final ProviderArea area = providerAreas.get(e.provider);
- area.hide();
- area.cleanup();
- area.layout();
- relayout();
- }
- });
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ProviderOverviewPart.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ProviderOverviewPart.java
deleted file mode 100644
index 64e47d5..0000000
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/ProviderOverviewPart.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.ui;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.NewSelectionEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderActivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDeactivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderOrderChangedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderSelectionEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.ui.OrderChangeHandler.OrderChangedListener;
-import org.eclipse.recommenders.internal.extdoc.rcp.wiring.ExtdocModule.Extdoc;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import com.google.common.collect.Maps;
-import com.google.common.eventbus.EventBus;
-import com.google.common.eventbus.Subscribe;
-import com.google.inject.Inject;
-
-public class ProviderOverviewPart {
-
- private final EventBus bus;
- private final List<ExtdocProvider> providers;
-
- private Table table;
- private final Map<ExtdocProvider, TableItem> provider2item = Maps.newHashMap();
-
- @Inject
- public ProviderOverviewPart(@Extdoc final EventBus bus, final List<ExtdocProvider> providers) {
- this.bus = bus;
- this.providers = providers;
- }
-
- public void createControl(final Composite parent) {
- final Composite tableContent = new Composite(parent, SWT.NONE);
- tableContent.setLayout(GridLayoutFactory.fillDefaults().create());
-
- table = new Table(tableContent, SWT.CHECK);
- table.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
- table.addListener(SWT.Selection,
- createListenerThatSeparatesCheckAndSelectionEventsAndPropagatesThemToTheSelectedItem());
-
- for (final ExtdocProvider p : providers) {
- final TableItem item = createItemForProvider(p);
- provider2item.put(p, item);
- }
- addDragAndDropSupport();
- }
-
- private Listener createListenerThatSeparatesCheckAndSelectionEventsAndPropagatesThemToTheSelectedItem() {
- return new Listener() {
- @Override
- public void handleEvent(final Event event) {
- if (event.detail == SWT.CHECK) {
- event.item.notifyListeners(SWT.CHECK, event);
- } else {
- event.item.notifyListeners(SWT.Selection, event);
- }
- }
- };
- }
-
- private TableItem createItemForProvider(final ExtdocProvider provider) {
- final TableItem item = new TableItem(table, SWT.NONE);
- item.setText(provider.getDescription().getName());
- item.setImage(provider.getDescription().getImage());
- item.setChecked(provider.isEnabled());
-
- item.addListener(SWT.CHECK, new Listener() {
- @Override
- public void handleEvent(final Event event) {
- final boolean isChecked = item.getChecked();
- provider.setEnabled(isChecked);
- if (isChecked) {
- bus.post(new ProviderActivationEvent(provider));
- } else {
- bus.post(new ProviderDeactivationEvent(provider));
- }
-
- }
- });
-
- item.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(final Event event) {
- final boolean isChecked = item.getChecked();
- if (isChecked) {
- bus.post(new ProviderSelectionEvent(provider));
- }
- }
- });
- return item;
- }
-
- private void addDragAndDropSupport() {
- final OrderChangeHandler handler = OrderChangeHandler.enable(table);
- handler.addListener(new OrderChangedListener() {
- @Override
- public void orderChanged(final int oldIndex, final int newIndex) {
- final ExtdocProvider providerReference = providers.get(newIndex);
- final ExtdocProvider movedProvider = providers.remove(oldIndex);
- providers.add(newIndex, movedProvider);
- bus.post(new ProviderOrderChangedEvent(movedProvider, providerReference, oldIndex, newIndex));
-
- for (final ExtdocProvider p : providers) {
- final TableItem oldItem = provider2item.get(p);
- final TableItem newItem = createItemForProvider(p);
- provider2item.put(p, newItem);
-
- newItem.setForeground(oldItem.getForeground());
- newItem.setImage(oldItem.getImage());
- oldItem.dispose();
- }
- }
- });
- }
-
- @Subscribe
- public void onEvent(final NewSelectionEvent e) {
- Display.getDefault().syncExec(new Runnable() {
-
- @Override
- public void run() {
- for (final ExtdocProvider p : providers) {
- final TableItem oldItem = provider2item.get(p);
- provider2item.put(p, createItemForProvider(p));
- oldItem.dispose();
- }
- }
- });
- }
-
- // @Subscribe
- // public void onEvent(final ProviderNotAvailableEvent e) {
- // // final TableItem tableItem = provider2item.get(e.provider);
- // // tableItem.setImage(iconLoader.getImage(Icon.NOT_AVAILABLE));
- // // tableItem.setForeground(new Color(table.getDisplay(), 180, 180, 180));
- // }
- //
- // @Subscribe
- // public void onEvent(final ProviderDeactivationEvent e) {
- // // final TableItem tableItem = provider2item.get(e.provider);
- // // tableItem.setImage(e.provider.getDescription().getImage());
- // }
- //
- // @Subscribe
- // public void onEvent(final ProviderStartedEvent e) {
- // // final TableItem tableItem = provider2item.get(e.provider);
- // // tableItem.setImage(iconLoader.getImage(Icon.STARTED));
- // }
- //
- // @Subscribe
- // public void onEvent(final ProviderFinishedEvent e) {
- // // final TableItem tableItem = provider2item.get(e.provider);
- // // tableItem.setImage(e.provider.getDescription().getImage());
- // }
- //
- // @Subscribe
- // public void onEvent(final ProviderDelayedEvent e) {
- // // final TableItem tableItem = provider2item.get(e.provider);
- // // tableItem.setImage(iconLoader.getImage(Icon.DELAYED));
- // }
- //
- // @Subscribe
- // public void onEvent(final ProviderFinishedLateEvent e) {
- // // final TableItem tableItem = provider2item.get(e.provider);
- // // tableItem.setImage(e.provider.getDescription().getImage());
- // }
- //
- // @Subscribe
- // public void onEvent(final ProviderFailedEvent e) {
- // // final TableItem tableItem = provider2item.get(e.provider);
- // // tableItem.setImage(iconLoader.getImage(Icon.FAILED));
- // }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/SubscriptionManager.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/SubscriptionManager.java
index ee1bad4..458b599 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/SubscriptionManager.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ui/SubscriptionManager.java
@@ -8,7 +8,7 @@
* Contributors:
* Sebastian Proksch - initial API and implementation
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling;
+package org.eclipse.recommenders.internal.extdoc.rcp.ui;
import static com.google.common.base.Optional.absent;
import static com.google.common.base.Optional.of;
@@ -85,7 +85,6 @@ public class SubscriptionManager {
ensureFirstParameterTypeIsJavaElement(params, m);
ensureSecondParameterTypeIsJavaSelectionEvent(params, m);
ensureThirdParameterTypeIsComposite(params, m);
- ensureThatAStatusIsReturned(m);
}
private static void ensureParameterLengthIsThree(final Class<?>[] params, final Method m) {
@@ -115,12 +114,6 @@ public class SubscriptionManager {
}
}
- private static void ensureThatAStatusIsReturned(Method m) {
- Class<?> actualType = m.getReturnType();
- Class<?> expectedType = Status.class;
- Checks.ensureEquals(actualType, expectedType, "subscribing methods need to return " + expectedType);
- }
-
private void addSubscription(final ExtdocProvider provider, final Method method,
final JavaSelectionSubscriber annotation) {
final JavaSelectionLocation[] locs = annotation.value();
@@ -140,14 +133,11 @@ public class SubscriptionManager {
}
/**
- * Returns a method of the given provider that is subscribed for the
- * selection event - or <em>absent</em> if none is found. If the
- * subscription of multiple methods overlaps, no guarantee is given which
- * method is returned
+ * Returns a method of the given provider that is subscribed for the selection event - or <em>absent</em> if none is
+ * found. If the subscription of multiple methods overlaps, no guarantee is given which method is returned
*/
public Optional<Method> findSubscribedMethod(final ExtdocProvider provider, final JavaSelectionEvent selection) {
for (final Subscription s : subscriptions.keySet()) {
-
if (s.isInterestedIn(selection)) {
for (final Tuple<ExtdocProvider, Method> t : subscriptions.get(s)) {
if (provider.equals(t.getFirst())) {
diff --git a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/wiring/ExtdocModule.java b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/wiring/ExtdocModule.java
index 5f16900..206467d 100644
--- a/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/wiring/ExtdocModule.java
+++ b/plugins/org.eclipse.recommenders.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/wiring/ExtdocModule.java
@@ -16,6 +16,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -23,9 +25,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProviderDescription;
-import org.eclipse.recommenders.internal.extdoc.rcp.preferences.PreferencesFacade;
-import org.eclipse.recommenders.internal.extdoc.rcp.preferences.ProviderConfigurationPersistenceService;
-import org.eclipse.recommenders.internal.extdoc.rcp.ui.ExtdocIconLoader;
+import org.eclipse.recommenders.internal.extdoc.rcp.ui.ExtdocPreferences;
import org.eclipse.recommenders.internal.extdoc.rcp.wiring.ManualModelStoreWiring.ClassOverridesModelStore;
import org.eclipse.recommenders.internal.extdoc.rcp.wiring.ManualModelStoreWiring.ClassOverridesPatternsModelStore;
import org.eclipse.recommenders.internal.extdoc.rcp.wiring.ManualModelStoreWiring.ClassSelfcallsModelStore;
@@ -47,22 +47,11 @@ public class ExtdocModule extends AbstractModule {
@Override
protected void configure() {
- bind(ExtdocIconLoader.class).in(Scopes.SINGLETON);
- bind(PreferencesFacade.class).in(Scopes.SINGLETON);
- bind(ProviderConfigurationPersistenceService.class).in(Scopes.SINGLETON);
-
+ bind(ExtdocPreferences.class).in(Scopes.SINGLETON);
bind(ClassOverridesPatternsModelStore.class).in(Scopes.SINGLETON);
bind(ClassOverridesModelStore.class).in(Scopes.SINGLETON);
bind(ClassSelfcallsModelStore.class).in(Scopes.SINGLETON);
bind(MethodSelfcallsModelStore.class).in(Scopes.SINGLETON);
-
- }
-
- @Provides
- @Singleton
- @Extdoc
- EventBus provideEventBus() {
- return new EventBus("extdoc-eventbus");
}
@Provides
@@ -74,17 +63,15 @@ public class ExtdocModule extends AbstractModule {
@Provides
@Singleton
- List<ExtdocProvider> provideProviders(@Extdoc final EventBus extdocBus,
- final ProviderConfigurationPersistenceService providerService) {
+ List<ExtdocProvider> provideProviders() {
final List<ExtdocProvider> providers = instantiateProvidersFromRegistry();
- providerService.initializeProviderConfiguration(providers);
- extdocBus.register(providerService);
return providers;
}
static List<ExtdocProvider> instantiateProvidersFromRegistry() {
- final IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(
- "org.eclipse.recommenders.extdoc.rcp.provider");
+ final IConfigurationElement[] elements =
+ Platform.getExtensionRegistry()
+ .getConfigurationElementsFor("org.eclipse.recommenders.extdoc.rcp.provider");
final List<ExtdocProvider> providers = Lists.newLinkedList();
for (final IConfigurationElement element : elements) {
@@ -93,6 +80,22 @@ public class ExtdocModule extends AbstractModule {
providers.add(opt.get());
}
}
+
+ Collections.sort(providers, new Comparator<ExtdocProvider>() {
+
+ @Override
+ public int compare(ExtdocProvider o1, ExtdocProvider o2) {
+ String n1 = o1.getDescription().getName();
+ String n2 = o2.getDescription().getName();
+ if (n1.equals("Javadoc")) {
+ return -1;
+ } else if (n2.equals("Javadoc")) {
+ return 1;
+ } else {
+ return n1.compareTo(n2);
+ }
+ }
+ });
return providers;
}
@@ -107,7 +110,9 @@ public class ExtdocModule extends AbstractModule {
provider.setDescription(description);
return Optional.of(provider);
} catch (final Exception e) {
- RecommendersPlugin.logError(e, "failed to instantiate provider %s:%s", pluginId,
+ RecommendersPlugin.logError(e,
+ "failed to instantiate provider %s:%s",
+ pluginId,
element.getAttribute("class"));
return Optional.absent();
}
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/extdoc/rcp/PlaceholderTest.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/extdoc/rcp/PlaceholderTest.java
deleted file mode 100644
index e8fd6b6..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/extdoc/rcp/PlaceholderTest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright (c) 2011 Stefan Henss.
- * 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:
- * Stefan Henss - initial API and implementation.
- */
-package org.eclipse.recommenders.extdoc.rcp;
-
-import org.junit.Test;
-
-public final class PlaceholderTest {
-
- @Test
- public void dummy() {
- }
-}
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/ProviderConfigurationPersistenceServiceTest.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/ProviderConfigurationPersistenceServiceTest.java
deleted file mode 100644
index 7bbeeb2..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/preferences/ProviderConfigurationPersistenceServiceTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.preferences;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProviderDescription;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderActivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDeactivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderOrderChangedEvent;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ProviderConfigurationPersistenceServiceTest {
-
- private List<ExtdocProvider> providers;
- private PreferencesFacade preferences;
-
- public ProviderConfigurationPersistenceService sut;
-
- @Before
- public void setup() {
- providers = newArrayList();
- mockPreferences();
-
- sut = new ProviderConfigurationPersistenceService(preferences);
- }
-
- @Test
- public void providersAreSortedOnInit() {
- providers.add(mockProvider("b", true));
- providers.add(mockProvider("c", true));
- providers.add(mockProvider("a", true));
-
- sut.initializeProviderConfiguration(providers);
-
- assertOrder("a", "b", "c");
- }
-
- @Test
- public void missingProvidersAreSimpleLeftOutOnInit() {
- providers.add(mockProvider("b", true));
- providers.add(mockProvider("a", true));
-
- sut.initializeProviderConfiguration(providers);
-
- assertOrder("a", "b");
- }
-
- @Test
- public void newProvidersAreAppendedToTheEnd() {
- providers.add(mockProvider("b", true));
- providers.add(mockProvider("a", true));
- providers.add(mockProvider("d", true));
-
- sut.initializeProviderConfiguration(providers);
-
- assertOrder("a", "b", "d");
- }
-
- @Test
- public void enablementIsLoadedOnInit() {
- ExtdocProvider enabledProvider = mockProvider("a", true);
- providers.add(enabledProvider);
- ExtdocProvider disabledProvider = mockProvider("b", false);
- providers.add(disabledProvider);
-
- sut.initializeProviderConfiguration(providers);
-
- verify(enabledProvider).setEnabled(true);
- verify(disabledProvider).setEnabled(false);
- }
-
- @Test
- public void orderChangeIsPersisted() {
- sut.initializeProviderConfiguration(providers);
- sut.onEvent(mock(ProviderOrderChangedEvent.class));
- verify(preferences).storeOrderedProviders(providers);
- }
-
- @Test
- public void providerActivationIsPersisted() {
- sut.initializeProviderConfiguration(providers);
- sut.onEvent(mock(ProviderActivationEvent.class));
- verify(preferences).storeProviderEnablement(providers);
- }
-
- @Test
- public void providerDeactivationIsPersisted() {
- sut.initializeProviderConfiguration(providers);
- sut.onEvent(mock(ProviderDeactivationEvent.class));
- verify(preferences).storeProviderEnablement(providers);
- }
-
- private void mockPreferences() {
- preferences = mock(PreferencesFacade.class);
- when(preferences.loadOrderedProviderNames()).thenReturn(new String[] { "a", "b", "c" });
- }
-
- private ExtdocProvider mockProvider(String name, boolean isEnabled) {
- ExtdocProvider provider = mock(ExtdocProvider.class);
-
- when(provider.isEnabled()).thenReturn(isEnabled);
-
- ExtdocProviderDescription desc = new ExtdocProviderDescription(name, null);
- when(provider.getDescription()).thenReturn(desc);
-
- when(preferences.isProviderEnabled(provider)).thenReturn(isEnabled);
-
- return provider;
- }
-
- private void assertOrder(String... orderedNames) {
- int idx = 0;
- for (ExtdocProvider provider : providers) {
- String actual = provider.getDescription().getName();
- String expected = orderedNames[idx++];
- assertEquals(expected, actual);
- }
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/FastProvider.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/FastProvider.java
deleted file mode 100644
index 2fe5ec4..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/FastProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.debug;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-public final class FastProvider extends ExtdocProvider {
-
- @JavaSelectionSubscriber(JavaSelectionLocation.METHOD_BODY)
- public Status displayProposalsForType(final IJavaElement element, final JavaSelectionEvent selection,
- final Composite parent) {
-
- // ... logic that does not need to run in the ui thread
-
- runSyncInUiThread(new Runnable() {
- @Override
- public void run() {
- final Label l = new Label(parent, SWT.NONE);
- l.setText("fast provider was here! :>");
- }
- });
- return Status.OK;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/ProviderWithoutData.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/ProviderWithoutData.java
deleted file mode 100644
index 890d3d6..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/ProviderWithoutData.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.debug;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.swt.widgets.Composite;
-
-public class ProviderWithoutData extends ExtdocProvider {
-
- @JavaSelectionSubscriber
- public Status displayProposalsForType(final IJavaElement element, final JavaSelectionEvent selection,
- final Composite parent) throws InterruptedException {
- // No data available for selection...
- Thread.sleep(1000);
- return Status.NOT_AVAILABLE;
- }
-
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowAndFailingProvider.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowAndFailingProvider.java
deleted file mode 100644
index ff9ac11..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowAndFailingProvider.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.debug;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.recommenders.utils.Throws;
-import org.eclipse.swt.widgets.Composite;
-
-public final class SlowAndFailingProvider extends ExtdocProvider {
-
- @JavaSelectionSubscriber
- public Status displayProposalsForType(final IJavaElement element, final JavaSelectionEvent selection,
- final Composite parent) throws InterruptedException {
- Thread.sleep(1500);
- Throws.throwNotImplemented();
- return Status.OK;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowProvider.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowProvider.java
deleted file mode 100644
index 887d05f..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowProvider.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.debug;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-public final class SlowProvider extends ExtdocProvider {
-
- @JavaSelectionSubscriber
- public Status displayProposalsForType(final IJavaElement element, final JavaSelectionEvent selection,
- final Composite parent) throws InterruptedException {
- Thread.sleep(1000);
- runSyncInUiThread(new Runnable() {
- @Override
- public void run() {
- final Label l = new Label(parent, SWT.NONE);
- l.setText("Slooooow provider was here! :>");
- }
- });
- return Status.OK;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowProviderWithoutData.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowProviderWithoutData.java
deleted file mode 100644
index f125643..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/SlowProviderWithoutData.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.debug;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.swt.widgets.Composite;
-
-public class SlowProviderWithoutData extends ExtdocProvider {
-
- @JavaSelectionSubscriber
- public Status displayProposalsForType(final IJavaElement element, final JavaSelectionEvent selection,
- final Composite parent) throws InterruptedException {
- // No data available for selection...
- Thread.sleep(3000);
- return Status.NOT_AVAILABLE;
- }
-
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/TooSlowProvider.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/TooSlowProvider.java
deleted file mode 100644
index 2fcfa1e..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/TooSlowProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.debug;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-public final class TooSlowProvider extends ExtdocProvider {
-
- @JavaSelectionSubscriber(JavaSelectionLocation.METHOD_BODY)
- public Status displayProposalsForType(final IJavaElement element, final JavaSelectionEvent selection,
- final Composite parent) throws InterruptedException {
- Thread.sleep(10000);
- runSyncInUiThread(new Runnable() {
- @Override
- public void run() {
- final Label l = new Label(parent, SWT.NONE);
- l.setText("Too slow provider was here! :>");
- }
- });
- return Status.OK;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/VerySlowProvider.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/VerySlowProvider.java
deleted file mode 100644
index 17a224a..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/debug/VerySlowProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.providers.debug;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-public final class VerySlowProvider extends ExtdocProvider {
-
- @JavaSelectionSubscriber(JavaSelectionLocation.METHOD_BODY)
- public Status displayProposalsForType(final IJavaElement element, final JavaSelectionEvent selection,
- final Composite parent) throws InterruptedException {
- Thread.sleep(3000);
- runSyncInUiThread(new Runnable() {
- @Override
- public void run() {
- final Label l = new Label(parent, SWT.NONE);
- l.setText("Veeeery slow provider was here! :>");
- }
- });
- return Status.OK;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/BusSpyThatAlsoChecksForUiThread.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/BusSpyThatAlsoChecksForUiThread.java
deleted file mode 100644
index 1147667..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/BusSpyThatAlsoChecksForUiThread.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling;
-
-import static com.google.common.collect.Lists.newLinkedList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.NewSelectionEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderActivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDeactivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDelayedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFailedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFinishedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFinishedLateEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderNotAvailableEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderOrderChangedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderSelectionEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderStartedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.RenderNowEvent;
-import org.eclipse.swt.widgets.Display;
-
-import com.google.common.eventbus.Subscribe;
-
-public class BusSpyThatAlsoChecksForUiThread {
-
- private final List<Object> _events = newLinkedList();
-
- public synchronized List<Object> getEvents() {
- return _events;
- }
-
- private void add(final Object event) {
- // ensureCurrentThreadIsUiThread();
- getEvents().add(event);
- }
-
- private void ensureCurrentThreadIsUiThread() {
- final Thread actual = Thread.currentThread();
- final Thread uiThread = Display.getCurrent().getThread();
- assertSame(uiThread, actual);
- }
-
- /**
- * asserts that the expected event was posted
- */
- public void assertEvent(final Object expected) {
- assertFalse(getEvents().isEmpty());
- assertTrue("no matching event found", getEvents().remove(expected));
- }
-
- /**
- * asserts that the expected event was posted as the next event
- */
- public void assertNextEvent(final Object expected) {
- assertFalse(getEvents().isEmpty());
- final Object actual = getEvents().remove(0);
- assertEquals(expected, actual);
- }
-
- public void assertNoMoreEvents() {
- assertTrue(getEvents().isEmpty());
- }
-
- @Subscribe
- public void on(final NewSelectionEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderActivationEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderDeactivationEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderDelayedEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderFailedEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderFinishedEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderFinishedLateEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderNotAvailableEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderOrderChangedEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderSelectionEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final ProviderStartedEvent e) {
- add(e);
- }
-
- @Subscribe
- public void on(final RenderNowEvent e) {
- add(e);
- }
-
- @Override
- public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
-
- @Override
- public boolean equals(final Object obj) {
- return EqualsBuilder.reflectionEquals(this, obj);
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionSchedulerFixture.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionSchedulerFixture.java
deleted file mode 100644
index 65b57a1..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionSchedulerFixture.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling;
-
-import static com.google.common.collect.Maps.newHashMap;
-import static java.util.Arrays.asList;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.TYPE_IN_TYPE_DECLARATION;
-import static org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation.METHOD_BODY;
-import static org.eclipse.recommenders.utils.Checks.ensureIsNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.internal.extdoc.rcp.ui.ProviderContentPart;
-import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
-import org.eclipse.swt.widgets.Composite;
-
-import com.google.common.collect.Lists;
-import com.google.common.eventbus.EventBus;
-
-public class ProviderExecutionSchedulerFixture {
-
- protected static final int RENDER_TIMEOUT = 125;
- protected static final int TIME_OF_SLOW_PROVIDERS = 250;
-
- public static final JavaSelectionEvent SELECTION = TYPE_IN_TYPE_DECLARATION;
-
- public final ExtdocProviderHelper happyPathProvider;
- public final ExtdocProviderHelper failingProvider;
- public final ExtdocProviderHelper unavailableProvider;
- public final ExtdocProviderHelper slowProvider;
- public final ExtdocProviderHelper slowFailingProvider;
- public final ExtdocProviderHelper slowUnavailableProvider;
- public final ExtdocProviderHelper uninterestedProvider;
-
- public final EventBus bus;
- public final EventBus mockBus;
- public final ProviderContentPart contentPart;
-
- public final Map<ExtdocProviderHelper, Composite> composites = newHashMap();
-
- public RuntimeException lastThrownException;
-
- public ProviderExecutionSchedulerFixture() {
-
- bus = new EventBus();
- mockBus = mock(EventBus.class);
- contentPart = mock(ProviderContentPart.class);
-
- happyPathProvider = createProvider(false, false, true);
- failingProvider = createProvider(false, true, true);
- unavailableProvider = createProvider(false, false, false);
- slowProvider = createProvider(true, false, true);
- slowFailingProvider = createProvider(true, true, true);
- slowUnavailableProvider = createProvider(true, false, false);
- uninterestedProvider = new ExtdocProviderHelper() {
- @Override
- @JavaSelectionSubscriber(METHOD_BODY)
- public Status methodToCall(final IJavaElement e, final JavaSelectionEvent s, final Composite p)
- throws InterruptedException {
- countExecution();
- return Status.OK;
- }
- };
- registerCompositeForProvider(uninterestedProvider);
-
- }
-
- private ExtdocProviderHelper createProvider(final Boolean shouldSleep, final boolean shouldCrash,
- final boolean isAvailable) {
-
- final ExtdocProviderHelper provider = new ExtdocProviderHelper() {
- @Override
- @JavaSelectionSubscriber
- public Status methodToCall(final IJavaElement e, final JavaSelectionEvent s, final Composite c)
- throws InterruptedException {
- selection = s;
- composite = c;
-
- countExecution();
-
- if (shouldSleep) {
- Thread.sleep(TIME_OF_SLOW_PROVIDERS);
- }
-
- if (shouldCrash) {
- lastThrownException = new RuntimeException("some exception that occurs on execution");
- throw lastThrownException;
- }
-
- if (isAvailable) {
- return Status.OK;
- } else {
- return Status.NOT_AVAILABLE;
- }
- }
- };
- registerCompositeForProvider(provider);
-
- return provider;
- }
-
- private void registerCompositeForProvider(final ExtdocProviderHelper provider) {
- final Composite c = mock(Composite.class);
- when(contentPart.getRenderingArea(provider)).thenReturn(c);
- composites.put(provider, c);
- }
-
- public ProviderExecutionScheduler createScheduler(final ExtdocProvider... providerArray) {
- final List<ExtdocProvider> providers = asList(providerArray);
- final ProviderExecutionScheduler scheduler = new ProviderExecutionScheduler(providers, new SubscriptionManager(
- providers), contentPart, bus) {
- {
- RENDER_TIMEOUT_IN_MS = RENDER_TIMEOUT;
- }
- };
- return scheduler;
- }
-
- public ProviderExecutionScheduler createSchedulerWithMockedBus() {
- final List<ExtdocProvider> providers = Lists.newArrayList();
- final SubscriptionManager subscriptionManager = mock(SubscriptionManager.class);
- final ProviderContentPart contentPart = mock(ProviderContentPart.class);
- return new ProviderExecutionScheduler(providers, subscriptionManager, contentPart, mockBus);
- }
-
- public static abstract class ExtdocProviderHelper extends ExtdocProvider {
- int counter = 0;
- JavaSelectionEvent selection;
- Composite composite;
-
- public void countExecution() {
- counter++;
- }
-
- public void assertExecution() {
- assertTrue(counter > 0);
- }
-
- public void assertExecution(final int times) {
- assertTrue(counter == times);
- }
-
- public void assertParameters(final JavaSelectionEvent selection, final Composite composite) {
- ensureIsNotNull(this.selection, "selection must be remembered in helper implementation");
- assertEquals(selection, this.selection);
-
- ensureIsNotNull(this.composite, "composite must be remembered in helper implementation");
- assertEquals(composite, this.composite);
- }
-
- public abstract Status methodToCall(IJavaElement e, JavaSelectionEvent s, Composite p)
- throws InterruptedException;
- }
-
- public Composite getComposite(final ExtdocProviderHelper provider) {
- final Composite c = composites.get(provider);
- ensureIsNotNull(c);
- return c;
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionSchedulerTest.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionSchedulerTest.java
deleted file mode 100644
index cedb399..0000000
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/ProviderExecutionSchedulerTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * Copyright (c) 2010, 2011 Darmstadt University of Technology.
- * 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:
- * Sebastian Proksch - initial API and implementation
- */
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling;
-
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.ProviderExecutionSchedulerFixture.RENDER_TIMEOUT;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.ProviderExecutionSchedulerFixture.SELECTION;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.ProviderExecutionSchedulerFixture.TIME_OF_SLOW_PROVIDERS;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.verify;
-
-import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.NewSelectionEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderActivationEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderDelayedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFailedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFinishedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderFinishedLateEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderNotAvailableEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.ProviderStartedEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.Events.RenderNowEvent;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.ProviderExecutionSchedulerFixture.ExtdocProviderHelper;
-import org.eclipse.recommenders.utils.Throws;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class ProviderExecutionSchedulerTest {
-
- ProviderExecutionSchedulerFixture fixture;
- BusSpyThatAlsoChecksForUiThread spy;
- ProviderExecutionScheduler sut;
-
- @Before
- public void setup() {
- fixture = new ProviderExecutionSchedulerFixture();
- spy = new BusSpyThatAlsoChecksForUiThread();
- fixture.bus.register(spy);
- }
-
- @Test
- @Ignore
- public void assertTestIsNotRunInUIThread() {
- final Thread actual = Thread.currentThread();
- final Thread unexpected = Display.getDefault().getThread();
- assertNotSame(unexpected, actual);
- }
-
- @Test
- public void ensureSchedulerRegisteresOnEventbus() {
- sut = fixture.createSchedulerWithMockedBus();
- verify(fixture.mockBus).register(sut);
- }
-
- @Test
- public void ensureSchedulerUnregisteresFromEventbusOnDispose() {
- sut = fixture.createSchedulerWithMockedBus();
- sut.dispose();
- verify(fixture.mockBus).unregister(sut);
- }
-
- @Test
- public void providersAreExecuted() throws InterruptedException {
- createSchedulerFireSelectionAndWait(fixture.happyPathProvider);
- assertExecution(fixture.happyPathProvider);
- }
-
- @Test
- public void providersAreExecutedOnActivation() {
- createSchedulerFireAsActivationAndWait(fixture.happyPathProvider);
- assertExecution(fixture.happyPathProvider);
- }
-
- @Test
- public void renderingPanelsAreCreatedOnNewSelection() throws InterruptedException {
- createSchedulerFireSelectionAndWait(fixture.happyPathProvider);
- verify(fixture.contentPart).createNewRenderingPanel();
- }
-
- @Test
- public void correctParametersAreProvidedToListeners() {
- createSchedulerFireSelectionAndWait(fixture.happyPathProvider, fixture.slowProvider);
-
- assertParameters(fixture.happyPathProvider);
- assertParameters(fixture.slowProvider);
- }
-
- @Test
- public void processingOfHappyPathProvider() {
- createSchedulerFireSelectionAndWait(fixture.happyPathProvider);
-
- spy.assertNextEvent(new NewSelectionEvent(SELECTION));
- spy.assertNextEvent(new ProviderStartedEvent(fixture.happyPathProvider));
- spy.assertNextEvent(new ProviderFinishedEvent(fixture.happyPathProvider));
- spy.assertNextEvent(new RenderNowEvent());
- spy.assertNoMoreEvents();
- }
-
- @Test
- public void processingOfSlowProvider() {
- createSchedulerFireSelectionAndWait(fixture.slowProvider);
-
- spy.assertNextEvent(new NewSelectionEvent(SELECTION));
- spy.assertNextEvent(new ProviderStartedEvent(fixture.slowProvider));
- spy.assertNextEvent(new ProviderDelayedEvent(fixture.slowProvider));
- spy.assertNextEvent(new RenderNowEvent());
- spy.assertNextEvent(new ProviderFinishedLateEvent(fixture.slowProvider));
- spy.assertNoMoreEvents();
- }
-
- @Test
- public void processingOfFailingProvider() {
- createSchedulerFireSelectionAndWait(fixture.failingProvider);
-
- spy.assertNextEvent(new NewSelectionEvent(SELECTION));
- spy.assertNextEvent(new ProviderStartedEvent(fixture.failingProvider));
- spy.assertNextEvent(new ProviderFailedEvent(fixture.failingProvider, fixture.lastThrownException));
- spy.assertNextEvent(new RenderNowEvent());
- spy.assertNoMoreEvents();
- }
-
- @Test
- public void processingOfSlowFailingProvider() {
- createSchedulerFireSelectionAndWait(fixture.slowFailingProvider);
-
- spy.assertNextEvent(new NewSelectionEvent(SELECTION));
- spy.assertNextEvent(new ProviderStartedEvent(fixture.slowFailingProvider));
- spy.assertNextEvent(new ProviderDelayedEvent(fixture.slowFailingProvider));
- spy.assertNextEvent(new RenderNowEvent());
- spy.assertNextEvent(new ProviderFailedEvent(fixture.slowFailingProvider, fixture.lastThrownException));
- spy.assertNoMoreEvents();
- }
-
- @Test
- public void processingOfUnavailableProvider() {
- createSchedulerFireSelectionAndWait(fixture.unavailableProvider);
-
- spy.assertNextEvent(new NewSelectionEvent(SELECTION));
- spy.assertNextEvent(new ProviderStartedEvent(fixture.unavailableProvider));
- spy.assertNextEvent(new ProviderNotAvailableEvent(fixture.unavailableProvider));
- spy.assertNextEvent(new RenderNowEvent());
- spy.assertNoMoreEvents();
- }
-
- @Test
- public void processingOfSlowUnavailableProvider() {
- createSchedulerFireSelectionAndWait(fixture.slowUnavailableProvider);
-
- spy.assertNextEvent(new NewSelectionEvent(SELECTION));
- spy.assertNextEvent(new ProviderStartedEvent(fixture.slowUnavailableProvider));
- spy.assertNextEvent(new ProviderDelayedEvent(fixture.slowUnavailableProvider));
- spy.assertNextEvent(new RenderNowEvent());
- spy.assertNextEvent(new ProviderNotAvailableEvent(fixture.slowUnavailableProvider, true));
- spy.assertNoMoreEvents();
- }
-
- @Test
- public void processingOfUninterestedProvider() {
- createSchedulerFireSelectionAndWait(fixture.uninterestedProvider);
-
- spy.assertNextEvent(new NewSelectionEvent(SELECTION));
- spy.assertNextEvent(new ProviderNotAvailableEvent(fixture.uninterestedProvider));
- spy.assertNextEvent(new RenderNowEvent());
- spy.assertNoMoreEvents();
- }
-
- @Test
- public void processingOfUninterestedProviderOnActivation() {
- createSchedulerFireAsActivationAndWait(fixture.uninterestedProvider);
-
- spy.assertNextEvent(new NewSelectionEvent(SELECTION));
- spy.assertNextEvent(new RenderNowEvent());
- spy.assertNextEvent(new ProviderNotAvailableEvent(fixture.uninterestedProvider));
- spy.assertNoMoreEvents();
- }
-
- @Test
- public void complexExampleContainsAllExpectedEvents() {
- createSchedulerFireSelectionAndWait(fixture.happyPathProvider, fixture.failingProvider, fixture.slowProvider,
- fixture.slowUnavailableProvider);
-
- spy.assertNextEvent(new NewSelectionEvent(SELECTION));
-
- spy.assertEvent(new ProviderStartedEvent(fixture.happyPathProvider));
- spy.assertEvent(new ProviderStartedEvent(fixture.failingProvider));
- spy.assertEvent(new ProviderStartedEvent(fixture.slowProvider));
- spy.assertEvent(new ProviderStartedEvent(fixture.slowUnavailableProvider));
-
- spy.assertEvent(new ProviderFinishedEvent(fixture.happyPathProvider));
- spy.assertEvent(new ProviderFailedEvent(fixture.failingProvider, fixture.lastThrownException));
- spy.assertEvent(new ProviderDelayedEvent(fixture.slowProvider));
- spy.assertEvent(new ProviderDelayedEvent(fixture.slowUnavailableProvider));
-
- spy.assertNextEvent(new RenderNowEvent());
-
- spy.assertEvent(new ProviderFinishedLateEvent(fixture.slowProvider));
- spy.assertEvent(new ProviderNotAvailableEvent(fixture.slowUnavailableProvider, true));
-
- spy.assertNoMoreEvents();
- }
-
- @Test
- public void renderTimeoutIsShortenedIfAllProvidersFinishEarly() {
- final long startTime = System.currentTimeMillis();
- createSchedulerAndFireSelection(fixture.happyPathProvider, fixture.failingProvider,
- fixture.uninterestedProvider, fixture.unavailableProvider);
- final long duration = System.currentTimeMillis() - startTime;
- assertTrue(duration < RENDER_TIMEOUT);
- }
-
- private void createSchedulerAndFireSelection(final ExtdocProviderHelper... providers) {
- sut = fixture.createScheduler(providers);
- sut.scheduleOnSelection(SELECTION);
- }
-
- private void createSchedulerFireSelectionAndWait(final ExtdocProviderHelper... providers) {
- createSchedulerAndFireSelection(providers);
- waitForFinish();
- }
-
- private void createSchedulerFireAsActivationAndWait(final ExtdocProviderHelper... providers) {
- for (final ExtdocProvider provider : providers) {
- provider.setEnabled(false);
- }
- createSchedulerFireSelectionAndWait(providers);
- for (final ExtdocProvider provider : providers) {
- provider.setEnabled(false);
- sut.onEvent(new ProviderActivationEvent(provider));
- }
- waitForFinish();
- }
-
- private void waitForFinish() {
-
- try {
- Thread.sleep(TIME_OF_SLOW_PROVIDERS + 200);
- } catch (final InterruptedException e) {
- Throws.throwUnhandledException(e);
- }
-
- // needed to run as junit (non plugin) test
- // while (Display.getDefault().readAndDispatch()) {
- // ;
- // }
- }
-
- private void assertExecution(final ExtdocProviderHelper provider) {
- provider.assertExecution(1);
- }
-
- private void assertParameters(final ExtdocProviderHelper provider) {
- final Composite composite = fixture.getComposite(provider);
- provider.assertParameters(SELECTION, composite);
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/ExtdocProviderTest.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/ExtdocProviderTest.java
index 6ff0667..4de5153 100644
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/providers/ExtdocProviderTest.java
+++ b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/ExtdocProviderTest.java
@@ -8,7 +8,7 @@
* Contributors:
* Sebastian Proksch - initial API and implementation
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.providers;
+package org.eclipse.recommenders.tests.extdoc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ExtdocViewTest.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/ExtdocViewTest.java
index ce9acf3..c040565 100644
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/ExtdocViewTest.java
+++ b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/ExtdocViewTest.java
@@ -1,4 +1,4 @@
-package org.eclipse.recommenders.internal.extdoc.rcp;
+package org.eclipse.recommenders.tests.extdoc;
import static org.junit.Assert.assertNotNull;
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/helper/JavaSelectionTestUtils.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/JavaSelectionTestUtils.java
index 2abd6a3..4193fe9 100644
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/helper/JavaSelectionTestUtils.java
+++ b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/JavaSelectionTestUtils.java
@@ -8,7 +8,7 @@
* Contributors:
* Sebastian Proksch - initial API and implementation
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper;
+package org.eclipse.recommenders.tests.extdoc;
import static org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation.METHOD_BODY;
import static org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation.METHOD_DECLARATION;
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/helper/ProviderImplementation.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/ProviderImplementation.java
index 9bf3083..32680e1 100644
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/helper/ProviderImplementation.java
+++ b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/ProviderImplementation.java
@@ -8,7 +8,7 @@
* Contributors:
* Sebastian Proksch - initial API and implementation
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper;
+package org.eclipse.recommenders.tests.extdoc;
import static org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation.TYPE_DECLARATION;
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/SubscriptionManagerTest.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/SubscriptionManagerTest.java
index 71891ef..b9b6dc8 100644
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/SubscriptionManagerTest.java
+++ b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/SubscriptionManagerTest.java
@@ -8,22 +8,22 @@
* Contributors:
* Sebastian Proksch - initial API and implementation
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling;
+package org.eclipse.recommenders.tests.extdoc;
import static java.util.Arrays.asList;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.ANNOTATION_IN_METHOD_DECLARATION;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.METHOD_IN_METHOD_BODY;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.METHOD_IN_METHOD_DECLARATION;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.TYPE_IN_METHOD_BODY;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.TYPE_IN_METHOD_DECLARATION_PARAMS;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.TYPE_IN_METHOD_DECLARATION_THROWS;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.TYPE_IN_TYPE_DECLARATION;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.TYPE_IN_TYPE_DECLARATION_EXTENDS;
-import static org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.JavaSelectionTestUtils.TYPE_IN_TYPE_DECLARATION_IMPLEMENTS;
import static org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation.METHOD_BODY;
import static org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation.METHOD_DECLARATION;
import static org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation.TYPE_DECLARATION;
import static org.eclipse.recommenders.rcp.events.JavaSelectionEvent.JavaSelectionLocation.TYPE_DECLARATION_EXTENDS;
+import static org.eclipse.recommenders.tests.extdoc.JavaSelectionTestUtils.ANNOTATION_IN_METHOD_DECLARATION;
+import static org.eclipse.recommenders.tests.extdoc.JavaSelectionTestUtils.METHOD_IN_METHOD_BODY;
+import static org.eclipse.recommenders.tests.extdoc.JavaSelectionTestUtils.METHOD_IN_METHOD_DECLARATION;
+import static org.eclipse.recommenders.tests.extdoc.JavaSelectionTestUtils.TYPE_IN_METHOD_BODY;
+import static org.eclipse.recommenders.tests.extdoc.JavaSelectionTestUtils.TYPE_IN_METHOD_DECLARATION_PARAMS;
+import static org.eclipse.recommenders.tests.extdoc.JavaSelectionTestUtils.TYPE_IN_METHOD_DECLARATION_THROWS;
+import static org.eclipse.recommenders.tests.extdoc.JavaSelectionTestUtils.TYPE_IN_TYPE_DECLARATION;
+import static org.eclipse.recommenders.tests.extdoc.JavaSelectionTestUtils.TYPE_IN_TYPE_DECLARATION_EXTENDS;
+import static org.eclipse.recommenders.tests.extdoc.JavaSelectionTestUtils.TYPE_IN_TYPE_DECLARATION_IMPLEMENTS;
import java.lang.reflect.Method;
import java.util.List;
@@ -33,8 +33,7 @@ import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.recommenders.extdoc.rcp.providers.ExtdocProvider;
import org.eclipse.recommenders.extdoc.rcp.providers.JavaSelectionSubscriber;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.ProviderImplementation;
-import org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper.SubscriptionVerifier;
+import org.eclipse.recommenders.internal.extdoc.rcp.ui.SubscriptionManager;
import org.eclipse.recommenders.rcp.events.JavaSelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.junit.Before;
diff --git a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/helper/SubscriptionVerifier.java b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/SubscriptionVerifier.java
index 2456130..2abd3e5 100644
--- a/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/internal/extdoc/rcp/scheduling/helper/SubscriptionVerifier.java
+++ b/tests/org.eclipse.recommenders.tests.extdoc.rcp/src/org/eclipse/recommenders/tests/extdoc/SubscriptionVerifier.java
@@ -8,7 +8,7 @@
* Contributors:
* Sebastian Proksch - initial API and implementation
*/
-package org.eclipse.recommenders.internal.extdoc.rcp.scheduling.helper;
+package org.eclipse.recommenders.tests.extdoc;
import static org.eclipse.recommenders.utils.Checks.ensureIsNotNull;
import static org.junit.Assert.assertEquals;