[367606] Share bundle info between Overview and Dependency Graph parts
diff --git a/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/dependencies/BundleDependencyEditorPage.java b/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/dependencies/BundleDependencyEditorPage.java
index 97f2483..acb669e 100644
--- a/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/dependencies/BundleDependencyEditorPage.java
+++ b/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/dependencies/BundleDependencyEditorPage.java
@@ -253,14 +253,10 @@
Object selection = ((IStructuredSelection) event.getSelection()).getFirstElement();
if (selection instanceof IBundle) {
IBundle bundle = (IBundle) selection;
- searchControl.getSearchText().setText(bundle.getSymbolicName() + " (" + bundle.getVersion() + ")");
- history.add(bundle.getSymbolicName() + " (" + bundle.getVersion() + ")");
- forwardAction.setEnabled(history.canForward());
- backAction.setEnabled(history.canBack());
- toolBarManager.update(true);
- new BundleDependencyUpdateJob(true).schedule();
+ setSelection(bundle);
}
}
+
});
toolBarManager = sform.getToolBarManager();
@@ -322,8 +318,7 @@
try {
Map<Long, IBundle> allBundles = admin.getBundles(monitor);
- contentProvider.setBundles(allBundles);
- viewer.setInput(allBundles.values());
+ refresh(allBundles);
} catch (CoreException e) {
EditorUIPlugin.log(e);
setStatus(e.getStatus());
@@ -378,6 +373,20 @@
});
}
+
+ private void setSelection(IBundle bundle) {
+ setSelection(bundle.getSymbolicName(), bundle.getVersion());
+ }
+
+ private void setSelection(String bundle, String version) {
+ String filterText = bundle + " (" + version + ")";
+ searchControl.getSearchText().setText(filterText);
+ history.add(filterText);
+ forwardAction.setEnabled(history.canForward());
+ backAction.setEnabled(history.canBack());
+ toolBarManager.update(true);
+ new BundleDependencyUpdateJob(true).schedule();
+ }
public AbstractZoomableViewer getZoomableViewer() {
return viewer;
@@ -423,19 +432,37 @@
}
public void showDependenciesForBundle(String bundle, String version) {
- this.searchControl.getSearchText().setText(bundle + " (" + version + ")");
- refreshAction.run();
+ setSelection(bundle, version);
}
public void openDependencyPage(IBundle bundle) {
+ BundleInformationEditorPage infoPage = openInformationPage();
+ if (infoPage != null) {
+ commandManager.getServerEditor().setActiveEditor(infoPage);
+ infoPage.showOverviewForBundle(bundle);
+ }
+ }
+
+ public void refresh(Map<Long, IBundle> bundles) {
+ if (bundles != null && !bundles.equals(viewer.getInput())) {
+ contentProvider.setBundles(bundles);
+ viewer.setInput(bundles.values());
+
+ BundleInformationEditorPage infoPage = openInformationPage();
+ if (infoPage != null) {
+ infoPage.refresh(bundles);
+ }
+ }
+ }
+
+ private BundleInformationEditorPage openInformationPage() {
IEditorPart[] parts = commandManager.getServerEditor().findEditors(getEditorInput());
for (IEditorPart part : parts) {
if (part instanceof BundleInformationEditorPage) {
- commandManager.getServerEditor().setActiveEditor(part);
- ((BundleInformationEditorPage) part).showOverviewForBundle(bundle);
- break;
+ return (BundleInformationEditorPage) part;
}
}
+ return null;
}
@Override
diff --git a/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/internal/overview/BundleInformationMasterDetailsBlock.java b/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/internal/overview/BundleInformationMasterDetailsBlock.java
index 807ecfd..18af1c6 100644
--- a/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/internal/overview/BundleInformationMasterDetailsBlock.java
+++ b/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/internal/overview/BundleInformationMasterDetailsBlock.java
@@ -139,8 +139,14 @@
* @param bundles
*/
public void refresh(Map<Long, IBundle> bundles) {
- masterPart.refresh(bundles);
- detailsPart.refresh(bundles);
+ if (masterPart.refresh(bundles)) {
+ detailsPart.refresh(bundles);
+
+ BundleDependencyEditorPage depPage = getDependencyPage();
+ if (depPage != null) {
+ depPage.refresh(bundles);
+ }
+ }
}
private void hookResizeListener() {
@@ -249,16 +255,23 @@
public void clear() {
masterPart.clear();
}
-
- public void openDependencyPage(String bundle, String version) {
+
+ private BundleDependencyEditorPage getDependencyPage() {
IEditorPart[] parts = serverEditor.findEditors(editorPage.getEditorInput());
for (IEditorPart part : parts) {
if (part instanceof BundleDependencyEditorPage) {
- serverEditor.setActiveEditor(part);
- ((BundleDependencyEditorPage) part).showDependenciesForBundle(bundle, version);
- break;
+ return (BundleDependencyEditorPage) part;
}
}
+ return null;
+ }
+
+ public void openDependencyPage(String bundle, String version) {
+ BundleDependencyEditorPage depPage = getDependencyPage();
+ if (depPage != null) {
+ serverEditor.setActiveEditor(depPage);
+ depPage.showDependenciesForBundle(bundle, version);
+ }
}
/**
diff --git a/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/internal/overview/BundleInformationMasterPart.java b/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/internal/overview/BundleInformationMasterPart.java
index 6173c14..317afc2 100644
--- a/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/internal/overview/BundleInformationMasterPart.java
+++ b/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/internal/overview/BundleInformationMasterPart.java
@@ -365,9 +365,13 @@
section.setTextClient(toolbar);
}
- public void refresh(Map<Long, IBundle> bundles) {
- super.refresh();
- bundleTableViewer.setInput(bundles);
+ public boolean refresh(Map<Long, IBundle> bundles) {
+ if (bundles != null && !bundles.equals(bundleTableViewer.getInput())) {
+ super.refresh();
+ bundleTableViewer.setInput(bundles);
+ return true;
+ }
+ return false;
}
public void clear() {
diff --git a/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/overview/BundleInformationEditorPage.java b/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/overview/BundleInformationEditorPage.java
index e69ae23..94c0bdc 100644
--- a/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/overview/BundleInformationEditorPage.java
+++ b/plugins/org.eclipse.libra.framework.editor.ui/src/org/eclipse/libra/framework/editor/ui/overview/BundleInformationEditorPage.java
@@ -11,20 +11,12 @@
*******************************************************************************/
package org.eclipse.libra.framework.editor.ui.overview;
-import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.libra.framework.editor.core.IOSGiFrameworkAdmin;
import org.eclipse.libra.framework.editor.core.model.IBundle;
import org.eclipse.libra.framework.editor.ui.internal.AbstractBundleEditorPage;
-import org.eclipse.libra.framework.editor.ui.internal.EditorUIPlugin;
import org.eclipse.libra.framework.editor.ui.internal.overview.BundleInformationMasterDetailsBlock;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.forms.ManagedForm;
@@ -85,34 +77,11 @@
}
public void showOverviewForBundle(final IBundle bundle) {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ masterDetailsBlock.setSelectedBundle(bundle);
+ }
- public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- monitor.beginTask("Updating bundle status from server", 1);
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- IOSGiFrameworkAdmin admin = (IOSGiFrameworkAdmin) masterDetailsBlock.getServer()
- .loadAdapter(IOSGiFrameworkAdmin.class, monitor);
- try {
- masterDetailsBlock.refresh(admin.getBundles(monitor));
- masterDetailsBlock.setSelectedBundle(bundle);
- } catch (CoreException e) {
- EditorUIPlugin.log(e);
- }
- }
- });
- monitor.worked(1);
- }
- };
-
- try {
- IRunnableContext context = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
- context.run(true, true, runnable);
- }
- catch (InvocationTargetException e1) {
- }
- catch (InterruptedException e2) {
- }
+ public void refresh(Map<Long, IBundle> bundles) {
+ masterDetailsBlock.refresh(bundles);
}
}