### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.runtime Index: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java diff -N src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java --- src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java 15 Nov 2007 17:44:31 -0000 1.56 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,621 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.eclipse.osgi.service.resolver.DisabledInfo; -import org.eclipse.osgi.service.resolver.PlatformAdmin; -import org.eclipse.osgi.service.resolver.ResolverError; -import org.eclipse.osgi.service.resolver.State; -import org.eclipse.osgi.service.resolver.VersionConstraint; -import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.internal.runtime.IHelpContextIds; -import org.eclipse.pde.internal.runtime.MessageHelper; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; -import org.eclipse.pde.internal.runtime.PDERuntimePlugin; -import org.eclipse.pde.internal.runtime.PDERuntimePluginImages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.XMLMemento; -import org.eclipse.ui.dialogs.FilteredTree; -import org.eclipse.ui.dialogs.PatternFilter; -import org.eclipse.ui.part.DrillDownAdapter; -import org.eclipse.ui.part.ViewPart; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; -import org.osgi.framework.Constants; -public class RegistryBrowser extends ViewPart { - - public static final String SHOW_RUNNING_PLUGINS = "RegistryView.showRunning.label"; //$NON-NLS-1$ - public static final String SHOW_ADVANCED_MODE = "RegistryView.showAdvancedMode.label"; //$NON-NLS-1$ - public static final String SHOW_EXTENSIONS_ONLY = "RegistryView.showExtensions.label"; //$NON-NLS-1$ - - private RegistryBrowserListener fListener; - private FilteredTree fFilteredTree; - private TreeViewer fTreeViewer; - private IMemento fMemento; - private int fTotalItems = 0; - - // menus and action items - private Action fRefreshAction; - private Action fShowPluginsAction; - private Action fCollapseAllAction; - private Action fShowAdvancedOperationsAction; - private Action fShowExtensionsOnlyAction; - - // advanced actions - private Action fStartAction; - private Action fStopAction; - private Action fEnableAction; - private Action fDisableAction; - private Action fDiagnoseAction; - - private DrillDownAdapter fDrillDownAdapter; - private ViewerFilter fActiveFilter = new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, Object element) { - if (element instanceof PluginObjectAdapter) - element = ((PluginObjectAdapter)element).getObject(); - if (element instanceof IExtensionPoint) - element = Platform.getBundle(((IExtensionPoint)element).getNamespaceIdentifier()); - else if (element instanceof IExtension) - element = Platform.getBundle(((IExtension)element).getNamespaceIdentifier()); - if (element instanceof Bundle) - return ((Bundle)element).getState() == Bundle.ACTIVE; - return true; - } - }; - - - /* - * customized DrillDownAdapter which modifies enabled state of showing active/inactive - * plug-ins action - see Bug 58467 - */ - class RegistryDrillDownAdapter extends DrillDownAdapter{ - public RegistryDrillDownAdapter(TreeViewer tree){ - super(tree); - } - - public void goInto() { - super.goInto(); - fShowPluginsAction.setEnabled(!canGoHome()); - } - - public void goBack() { - super.goBack(); - fShowPluginsAction.setEnabled(!canGoHome()); - } - - public void goHome() { - super.goHome(); - fShowPluginsAction.setEnabled(!canGoHome()); - } - - public void goInto(Object newInput) { - super.goInto(newInput); - fShowPluginsAction.setEnabled(!canGoHome()); - } - } - - public void init(IViewSite site, IMemento memento) throws PartInitException { - super.init(site, memento); - if (memento == null) - this.fMemento = XMLMemento.createWriteRoot("REGISTRYVIEW"); //$NON-NLS-1$ - else - this.fMemento = memento; - initializeMemento(); - - fListener = new RegistryBrowserListener(this); - } - - private void initializeMemento() { - // show all bundles by default (i.e. not just activated ones) - if (fMemento.getString(SHOW_RUNNING_PLUGINS) == null) - fMemento.putString(SHOW_RUNNING_PLUGINS, "false"); //$NON-NLS-1$ - if (fMemento.getString(SHOW_EXTENSIONS_ONLY) == null) - fMemento.putString(SHOW_EXTENSIONS_ONLY, "false"); //$NON-NLS-1$ - - // default to not showing advanced options to users - if (fMemento.getString(SHOW_ADVANCED_MODE) == null) - fMemento.putString(SHOW_ADVANCED_MODE, "false"); //$NON-NLS-1$ - } - - public void dispose() { - if (fListener != null) { - Platform.getExtensionRegistry().removeRegistryChangeListener(fListener); - PDERuntimePlugin.getDefault().getBundleContext().removeBundleListener(fListener); - } - super.dispose(); - } - - public void createPartControl(Composite parent) { - // create the sash form that will contain the tree viewer & text viewer - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - makeActions(); - createTreeViewer(composite); - fillToolBar(); - - PDERuntimePlugin.getDefault().getBundleContext().addBundleListener(fListener); - Platform.getExtensionRegistry().addRegistryChangeListener(fListener); - } - private void createTreeViewer(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - fFilteredTree = new RegistryFilteredTree(composite, SWT.MULTI, new PatternFilter()); - fFilteredTree.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); - Tree tree = fFilteredTree.getViewer().getTree(); - GridData gd = new GridData(GridData.FILL_BOTH); - fFilteredTree.setLayoutData(gd); - fTreeViewer = fFilteredTree.getViewer(); - fTreeViewer.setContentProvider(new RegistryBrowserContentProvider()); - fTreeViewer.setLabelProvider(new RegistryBrowserLabelProvider(fTreeViewer)); - fTreeViewer.setUseHashlookup(true); - fTreeViewer.setComparator(new ViewerComparator() { - public int compare(Viewer viewer, Object e1, Object e2) { - if (e1 instanceof PluginObjectAdapter) - e1 = ((PluginObjectAdapter)e1).getObject(); - if (e2 instanceof PluginObjectAdapter) - e2 = ((PluginObjectAdapter)e2).getObject(); - if (e1 instanceof IBundleFolder && e2 instanceof IBundleFolder) - return ((IBundleFolder)e1).getFolderId() - ((IBundleFolder)e2).getFolderId(); - if (e1 instanceof Bundle && e2 instanceof Bundle) { - e1 = ((Bundle)e1).getSymbolicName(); - e2 = ((Bundle)e2).getSymbolicName(); - } - return super.compare(viewer, e1, e2); - } - }); - if (fShowPluginsAction.isChecked()) - fTreeViewer.addFilter(fActiveFilter); - - updateItems(true); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(fTreeViewer.getControl(), IHelpContextIds.REGISTRY_VIEW); - - getViewSite().setSelectionProvider(fTreeViewer); - - MenuManager popupMenuManager = new MenuManager(); - IMenuListener listener = new IMenuListener() { - public void menuAboutToShow(IMenuManager mng) { - fillContextMenu(mng); - } - }; - popupMenuManager.setRemoveAllWhenShown(true); - popupMenuManager.addMenuListener(listener); - Menu menu = popupMenuManager.createContextMenu(tree); - tree.setMenu(menu); - } - - private PluginObjectAdapter[] getBundles() { - Bundle[] bundles = PDERuntimePlugin.getDefault().getBundleContext().getBundles(); - ArrayList list = new ArrayList(); - for (int i = 0; i < bundles.length; i++) - if (bundles[i].getHeaders().get(Constants.FRAGMENT_HOST) == null) - list.add(new PluginObjectAdapter(bundles[i])); - return (PluginObjectAdapter[]) list.toArray(new PluginObjectAdapter[list.size()]); - } - - private void fillToolBar(){ - fDrillDownAdapter = new RegistryDrillDownAdapter(fTreeViewer); - IActionBars bars = getViewSite().getActionBars(); - IToolBarManager mng = bars.getToolBarManager(); - fDrillDownAdapter.addNavigationActions(mng); - mng.add(fRefreshAction); - mng.add(new Separator()); - mng.add(fCollapseAllAction); - IMenuManager mgr = bars.getMenuManager(); - mgr.add(new Separator()); - mgr.add(fShowPluginsAction); - mgr.add(fShowExtensionsOnlyAction); - mgr.add(fShowAdvancedOperationsAction); - - } - public void fillContextMenu(IMenuManager manager) { - manager.add(fRefreshAction); - manager.add(new Separator()); - fDrillDownAdapter.addNavigationActions(manager); - manager.add(new Separator()); - // check if we should enable advanced actions - if(fShowAdvancedOperationsAction.isChecked() && isBundleSelected()) { - // control bundle state actions - if(selectedBundlesStopped()) - manager.add(fStartAction); - if(selectedBundlesStarted()) - manager.add(fStopAction); - - if(getSelectedBundles().size() == 1) - manager.add(fDiagnoseAction); - - // security related actions - if(selectedBundlesDisabled()) - manager.add(fEnableAction); - if(selectedBundlesEnabled()) - manager.add(fDisableAction); - } - - manager.add(new Separator()); - manager.add(fShowPluginsAction); - manager.add(fShowExtensionsOnlyAction); - manager.add(fShowAdvancedOperationsAction); - } - - public void saveState(IMemento memento) { - if (memento == null || fMemento == null || fTreeViewer == null) - return; - fMemento.putString(SHOW_RUNNING_PLUGINS, Boolean.toString(fShowPluginsAction.isChecked())); - fMemento.putString(SHOW_EXTENSIONS_ONLY, Boolean.toString(fShowExtensionsOnlyAction.isChecked())); - fMemento.putBoolean(SHOW_ADVANCED_MODE, fShowAdvancedOperationsAction.isChecked()); - memento.putMemento(fMemento); - } - - public void setFocus() { - fFilteredTree.getFilterControl().setFocus(); - } - - /* - * toolbar and context menu actions - */ - public void makeActions() { - fRefreshAction = new Action("refresh") { //$NON-NLS-1$ - public void run() { - BusyIndicator.showWhile(fTreeViewer.getTree().getDisplay(), new Runnable() { - public void run() { - updateItems(true); - } - }); - } - }; - fRefreshAction.setText(PDERuntimeMessages.RegistryView_refresh_label); - fRefreshAction.setToolTipText(PDERuntimeMessages.RegistryView_refresh_tooltip); - fRefreshAction.setImageDescriptor(PDERuntimePluginImages.DESC_REFRESH); - fRefreshAction.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_REFRESH_DISABLED); - - fShowPluginsAction = new Action(PDERuntimeMessages.RegistryView_showRunning_label){ - public void run() { - if (fShowPluginsAction.isChecked()) - fTreeViewer.addFilter(fActiveFilter); - else - fTreeViewer.removeFilter(fActiveFilter); - updateTitle(); - } - }; - fShowPluginsAction.setChecked(fMemento.getString(SHOW_RUNNING_PLUGINS).equals("true")); //$NON-NLS-1$ - - fShowExtensionsOnlyAction = new Action(PDERuntimeMessages.RegistryBrowser_showExtOnlyLabel) { - public void run() { - // refreshAction takes into account checked state of fShowExtensionsOnlyAction - // (via updateItems(true) - fRefreshAction.run(); - } - }; - fShowExtensionsOnlyAction.setChecked(fMemento.getString(SHOW_EXTENSIONS_ONLY).equals("true")); //$NON-NLS-1$ - - fShowAdvancedOperationsAction = new Action(PDERuntimeMessages.RegistryView_showAdvanced_label) { - public void run() {} - }; - fShowAdvancedOperationsAction.setChecked(fMemento.getString(SHOW_ADVANCED_MODE).equals("true")); //$NON-NLS-1$ - - fStartAction = new Action(PDERuntimeMessages.RegistryView_startAction_label) { - public void run() { - try { - List bundles = getSelectedBundles(); - for(Iterator it = bundles.iterator(); it.hasNext();) { - Bundle bundle = (Bundle) it.next(); - bundle.start(); - } - } catch (BundleException e) { - PDERuntimePlugin.log(e); - } - } - }; - - fStopAction = new Action(PDERuntimeMessages.RegistryView_stopAction_label) { - public void run() { - try { - List bundles = getSelectedBundles(); - for(Iterator it = bundles.iterator(); it.hasNext();) { - Bundle bundle = (Bundle) it.next(); - bundle.stop(); - } - } catch (BundleException e) { - PDERuntimePlugin.log(e); - } - } - }; - - fEnableAction = new Action(PDERuntimeMessages.RegistryView_enableAction_label) { - public void run() { - List bundles = getSelectedBundles(); - State state = PDERuntimePlugin.getDefault().getState(); - for(Iterator it = bundles.iterator(); it.hasNext();) { - Bundle bundle = (Bundle) it.next(); - BundleDescription desc = state.getBundle(bundle.getBundleId()); - DisabledInfo[] infos = state.getDisabledInfos(desc); - for (int i = 0; i < infos.length; i++) { - PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); - platformAdmin.removeDisabledInfo(infos[i]); - } - } - } - }; - - fDisableAction = new Action(PDERuntimeMessages.RegistryView_disableAction_label) { - public void run() { - List bundles = getSelectedBundles(); - State state = PDERuntimePlugin.getDefault().getState(); - for(Iterator it = bundles.iterator(); it.hasNext();) { - Bundle bundle = (Bundle) it.next(); - BundleDescription desc = state.getBundle(bundle.getBundleId()); - DisabledInfo info = new DisabledInfo("org.eclipse.pde.ui", "Disabled via PDE", desc); //$NON-NLS-1$ //$NON-NLS-2$ - PlatformAdmin platformAdmin = - PDERuntimePlugin.getDefault().getPlatformAdmin(); - platformAdmin.addDisabledInfo(info); - } - } - }; - - fDiagnoseAction = new Action(PDERuntimeMessages.RegistryView_diagnoseAction_label) { - public void run() { - List bundles = getSelectedBundles(); - State state = PDERuntimePlugin.getDefault().getState(); - for (Iterator it = bundles.iterator(); it.hasNext();) { - Bundle bundle = (Bundle) it.next(); - BundleDescription desc = state.getBundle(bundle.getBundleId()); - PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); - VersionConstraint[] unsatisfied = platformAdmin - .getStateHelper().getUnsatisfiedConstraints(desc); - ResolverError[] resolverErrors = platformAdmin.getState(false).getResolverErrors(desc); - MultiStatus problems = new MultiStatus(PDERuntimePlugin.ID, - IStatus.INFO, - PDERuntimeMessages.RegistryView_found_problems, - null); - for (int i = 0; i < resolverErrors.length; i++) { - if ((resolverErrors[i].getType() & (ResolverError.MISSING_FRAGMENT_HOST - | ResolverError.MISSING_GENERIC_CAPABILITY - | ResolverError.MISSING_IMPORT_PACKAGE | ResolverError.MISSING_REQUIRE_BUNDLE)) != 0) - continue; - IStatus status = new Status(IStatus.WARNING, - PDERuntimePlugin.ID, resolverErrors[i] - .toString()); - problems.add(status); - } - - for (int i = 0; i < unsatisfied.length; i++) { - IStatus status = new Status( - IStatus.WARNING, - PDERuntimePlugin.ID, - MessageHelper - .getResolutionFailureMessage(unsatisfied[i])); - problems.add(status); - } - Dialog dialog; - if (unsatisfied.length != 0 || resolverErrors.length != 0) { - dialog = new DiagnosticsDialog( - getSite().getShell(), - PDERuntimeMessages.RegistryView_diag_dialog_title, - null, problems, IStatus.WARNING); - dialog.open(); - } else { - MessageDialog - .openInformation( - getSite().getShell(), - PDERuntimeMessages.RegistryView_diag_dialog_title, - PDERuntimeMessages.RegistryView_no_unresolved_constraints); - } - - } - } - }; - - fCollapseAllAction = new Action("collapseAll"){ //$NON-NLS-1$ - public void run(){ - fTreeViewer.collapseAll(); - } - }; - fCollapseAllAction.setText(PDERuntimeMessages.RegistryView_collapseAll_label); - fCollapseAllAction.setImageDescriptor(PDERuntimePluginImages.DESC_COLLAPSE_ALL); - fCollapseAllAction.setToolTipText(PDERuntimeMessages.RegistryView_collapseAll_tooltip); - } - - protected void updateItems(boolean resetInput) { - Object[] input = null; - boolean extOnly = fShowExtensionsOnlyAction.isChecked(); - if (extOnly) - input = Platform.getExtensionRegistry().getExtensionPoints(); - else - input = getBundles(); - fListener.fExtOnly = extOnly; - fTotalItems = input.length; - if (resetInput) - fTreeViewer.setInput(new PluginObjectAdapter(input)); - updateTitle(); - } - - private void updateTitle(){ - setContentDescription(getTitleSummary()); - } - - protected Tree getUndisposedTree() { - if (fTreeViewer == null || fTreeViewer.getTree() == null || fTreeViewer.getTree().isDisposed()) - return null; - return fTreeViewer.getTree(); - } - - public String getTitleSummary(){ - Tree tree = getUndisposedTree(); - String type = fShowExtensionsOnlyAction.isChecked() ? PDERuntimeMessages.RegistryView_folders_extensionPoints : PDERuntimeMessages.RegistryBrowser_plugins; - if (tree == null) - return NLS.bind(PDERuntimeMessages.RegistryView_titleSummary, (new String[] {"0", "0", type})); //$NON-NLS-1$ //$NON-NLS-2$ - return NLS.bind(PDERuntimeMessages.RegistryView_titleSummary, (new String[] { - Integer.toString(tree.getItemCount()), - Integer.toString(fTotalItems), - type})); - } - - // TODO hackish, should rewrite - private boolean isBundleSelected() { - IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); - if(selection != null) { - Object[] elements = selection.toArray(); - for(int i = 0; i < elements.length; i++) { - if(elements[i] instanceof PluginObjectAdapter) { - PluginObjectAdapter adapter = (PluginObjectAdapter) elements[i]; - Object object = adapter.getObject(); - if(!(object instanceof Bundle)) - return false; - } else { - return false; - } - } - } - return true; - } - - private List getSelectedBundles() { - List bundles = new ArrayList(); - IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); - if(selection != null) { - Object[] elements = selection.toArray(); - for(int i = 0; i < elements.length; i++) { - if(elements[i] instanceof PluginObjectAdapter) { - PluginObjectAdapter adapter = (PluginObjectAdapter) elements[i]; - Object object = adapter.getObject(); - if(object instanceof Bundle) - bundles.add(object); - } - } - } - return bundles; - } - - private boolean selectedBundlesStarted() { - List bundles = getSelectedBundles(); - for(Iterator it = bundles.iterator(); it.hasNext();) { - Bundle bundle = (Bundle) it.next(); - if(bundle.getState() != Bundle.ACTIVE) - return false; - } - return true; - } - - private boolean selectedBundlesStopped() { - List bundles = getSelectedBundles(); - for(Iterator it = bundles.iterator(); it.hasNext();) { - Bundle bundle = (Bundle) it.next(); - if(bundle.getState() == Bundle.ACTIVE) - return false; - } - return true; - } - - private boolean selectedBundlesDisabled() { - List bundles = getSelectedBundles(); - for(Iterator it = bundles.iterator(); it.hasNext();) { - Bundle bundle = (Bundle) it.next(); - State state = - PDERuntimePlugin.getDefault().getState(); - BundleDescription desc = - state.getBundle(bundle.getBundleId()); - DisabledInfo[] infos = state.getDisabledInfos(desc); - if(infos.length == 0) - return false; - } - return true; - } - - private boolean selectedBundlesEnabled() { - List bundles = getSelectedBundles(); - for(Iterator it = bundles.iterator(); it.hasNext();) { - Bundle bundle = (Bundle) it.next(); - State state = - PDERuntimePlugin.getDefault().getState(); - BundleDescription desc = - state.getBundle(bundle.getBundleId()); - DisabledInfo[] infos = state.getDisabledInfos(desc); - if(infos.length > 0) - return false; - } - return true; - } - - protected void add(Object object) { - add(fTreeViewer.getInput(), object); - } - - protected void add(Object parent, Object object) { - if (fDrillDownAdapter.canGoHome()) - return; - fTotalItems += 1; - fTreeViewer.add(parent, object); - updateTitle(); - } - - protected void remove(Object object) { - if (fDrillDownAdapter.canGoHome()) - return; - fTotalItems -= 1; - fTreeViewer.remove(object); - updateTitle(); - } - - protected void update(Object object) { - fTreeViewer.update(object, null); - } - - protected void refresh(Object object) { - fTreeViewer.refresh(object); - } - - protected TreeItem[] getTreeItems() { - return fTreeViewer.getTree().getItems(); - } -} Index: src/org/eclipse/pde/internal/runtime/registry/RegistryFilteredTree.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/RegistryFilteredTree.java diff -N src/org/eclipse/pde/internal/runtime/registry/RegistryFilteredTree.java --- src/org/eclipse/pde/internal/runtime/registry/RegistryFilteredTree.java 29 Oct 2007 18:28:36 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.dialogs.FilteredTree; -import org.eclipse.ui.dialogs.PatternFilter; - -public class RegistryFilteredTree extends FilteredTree { - - public RegistryFilteredTree(Composite parent, int treeStyle, - PatternFilter filter) { - super(parent, treeStyle, filter); - } - - protected void createControl(Composite parent, int treeStyle) { - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - setLayout(layout); - setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - if (showFilterControls){ - filterComposite = new Composite(this, SWT.NONE); - GridLayout filterLayout = new GridLayout(2, false); - filterLayout.marginHeight = 4; - filterLayout.marginWidth = 3; - filterComposite.setLayout(filterLayout); - filterComposite.setFont(parent.getFont()); - - createFilterControls(filterComposite); - filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, - true, false)); - } - - treeComposite = new Composite(this, SWT.NONE); - GridLayout treeCompositeLayout = new GridLayout(); - treeCompositeLayout.marginHeight = 0; - treeCompositeLayout.marginWidth = 0; - treeComposite.setLayout(treeCompositeLayout); - GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); - treeComposite.setLayoutData(data); - createTreeControl(treeComposite, treeStyle); - } - -} Index: src/org/eclipse/pde/internal/runtime/registry/ConfigurationAttributeAdapter.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/ConfigurationAttributeAdapter.java diff -N src/org/eclipse/pde/internal/runtime/registry/ConfigurationAttributeAdapter.java --- src/org/eclipse/pde/internal/runtime/registry/ConfigurationAttributeAdapter.java 6 Mar 2006 14:50:59 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -public class ConfigurationAttributeAdapter extends ParentAdapter { - - public ConfigurationAttributeAdapter(Object object) { - super(object); - } - - protected Object[] createChildren() { - return null; - } - -} Index: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserListener.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserListener.java diff -N src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserListener.java --- src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserListener.java 15 Nov 2007 17:44:31 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,330 +0,0 @@ -package org.eclipse.pde.internal.runtime.registry; - -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionDelta; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IRegistryChangeEvent; -import org.eclipse.core.runtime.IRegistryChangeListener; -import org.eclipse.core.runtime.Platform; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleEvent; -import org.osgi.framework.BundleListener; - -public class RegistryBrowserListener implements IRegistryChangeListener, BundleListener { - - protected RegistryBrowser fBrowser; - protected boolean fExtOnly; - - protected RegistryBrowserListener(RegistryBrowser browser) { - fBrowser = browser; - } - - public void registryChanged(final IRegistryChangeEvent event) { - final Tree tree = fBrowser.getUndisposedTree(); - if (tree == null) - return; - - tree.getDisplay().asyncExec(new Runnable() { - public void run() { - IExtensionDelta[] deltas = event.getExtensionDeltas(); - for (int i = 0; i < deltas.length; i++) { - if (fExtOnly) - handleExtOnlyEvent(deltas[i]); - else - handleEvent(deltas[i]); - } - } - }); - } - - public void bundleChanged(final BundleEvent event) { - final Tree tree = fBrowser.getUndisposedTree(); - if (tree == null) - return; - - tree.getDisplay().asyncExec(new Runnable() { - public void run() { - if (fExtOnly) - handleExtOnlyEvent(event.getType(), event.getBundle()); - else - handleEvent(event.getType(), event.getBundle()); - } - }); - } - - private void handleEvent(IExtensionDelta delta) { - handleDelta(delta, false); - } - - private void handleExtOnlyEvent(IExtensionDelta delta) { - handleDelta(delta, true); - } - - - private void handleDelta(IExtensionDelta delta, boolean extOnly) { - IExtension ext = delta.getExtension(); - IExtensionPoint extPoint = delta.getExtensionPoint(); - // TODO fix this method (and addToTree/removeFromTree) - // bug 130655 - if (delta.getKind() == IExtensionDelta.ADDED) { - System.out.println("adding "); //$NON-NLS-1$ - if (ext != null) - System.out.println("ext: " + ext.getUniqueIdentifier() + "/" + ext.getLabel() + " : " + ext.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (extPoint != null) - System.out.println("extPoint: " + extPoint.getUniqueIdentifier()); //$NON-NLS-1$ - addExtensionObjectToTree(ext, extOnly); - addExtensionObjectToTree(extPoint, extOnly); -// addToTree(ext); -// addToTree(extPoint); - } else if (delta.getKind() == IExtensionDelta.REMOVED) { - System.out.println("removing "); //$NON-NLS-1$ - if (ext != null) - System.out.println("ext: " + ext.getUniqueIdentifier() + " : " + ext.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ //$NON-NLS-2$ - if (extPoint != null) - System.out.println("extPoint: " + extPoint.getUniqueIdentifier()); //$NON-NLS-1$ - removeFromTree(ext); - removeFromTree(extPoint); - } - } - -// private void addToTree(Object object) { -// String namespace = getNamespaceIdentifier(object); -// if (namespace == null) -// return; -// TreeItem[] items = fTreeViewer.getTree().getItems(); -// for (int i = 0; i < items.length; i++) { -// Object data = items[i].getData(); -// Object adapted = null; -// if (data instanceof PluginObjectAdapter) -// adapted = ((PluginObjectAdapter)data).getObject(); -// if (adapted instanceof Bundle && ((Bundle)adapted).getSymbolicName().equals(namespace)) { -// addBundleToTree(items[i], data, object); -// } -// } -// } - - - private void addExtensionObjectToTree(Object child, boolean extOnly) { - Object parent = null; - if (!extOnly) - parent = getAdoptingBundleParent(child); - else if (child instanceof IExtensionPoint) { - // add to root - fBrowser.add(child); - return; - } else if (child instanceof IExtension) { - // search all extensionPoints and return the correct one - String extPoint = ((IExtension)child).getExtensionPointUniqueIdentifier(); - TreeItem[] items = fBrowser.getTreeItems(); - for (int i = 0; i < items.length; i++) { - Object data = items[i].getData(); - if (data instanceof PluginObjectAdapter) - data = ((PluginObjectAdapter)data).getObject(); - if (data instanceof IExtensionPoint && - ((IExtensionPoint)data).getUniqueIdentifier().equals(extPoint)) { - parent = items[i].getData(); - break; - } - } - } - if (parent != null) - fBrowser.add(parent, child); - } - - private Object getAdoptingBundleParent(Object child) { - TreeItem bundleItem = findBundleItem(getNamespaceIdentifier(child)); - if (bundleItem != null) { - // TODO fix this - // remove this if (true) clause and return the proper parent - if (true) { - fBrowser.refresh(bundleItem.getData()); - fBrowser.updateItems(false); - return null; - } - TreeItem[] folders = bundleItem.getItems(); - for (int j = 0; j < folders.length; j++) { - // make sure to check extensionsOnlyMode() - // and add to root/proper extension if true - IBundleFolder folder = (IBundleFolder)folders[j].getData(); - if (correctFolder(folder, child)) - return folder; - } - // folder not found - 1st extension - refresh bundle item - // to rebuild folders - fBrowser.refresh(bundleItem.getData()); - } - return null; - } - - private TreeItem findBundleItem(String namespace) { - if (namespace == null) - return null; - TreeItem[] items = fBrowser.getTreeItems(); - for (int i = 0; i < items.length; i++) { - Object data = items[i].getData(); - if (data instanceof PluginObjectAdapter) - data = ((PluginObjectAdapter)data).getObject(); - if (data instanceof Bundle && ((Bundle)data).getSymbolicName().equals(namespace)) - return items[i]; - } - return null; - } - - -// private void addBundleToTree(TreeItem item, Object data, Object object) { -// // TODO fix this method -// if (true) { -// fTreeViewer.refresh(data); -// updateItems(false); -// return; -// } -// TreeItem[] folders = item.getItems(); -// for (int j = 0; j < folders.length; j++) { -// // make sure to check extensionsOnlyMode() -// // and add to root/proper extension if true -// IBundleFolder folder = (IBundleFolder)folders[j].getData(); -// if (correctFolder(folder, object)) { -// fTreeViewer.add(folder, object); -// return; -// } -// } -// // folder not found - 1st extension - refresh bundle item -// fTreeViewer.refresh(data); -// } - - private String getNamespaceIdentifier(Object object) { - if (object instanceof IExtensionPoint) - return ((IExtensionPoint)object).getNamespaceIdentifier(); - if (object instanceof IExtension) - return ((IExtension)object).getContributor().getName(); - return null; - } - - private boolean correctFolder(IBundleFolder folder, Object child) { - if (folder == null) - return false; - if (child instanceof IExtensionPoint) - return folder.getFolderId() == IBundleFolder.F_EXTENSION_POINTS; - if (child instanceof IExtension) - return folder.getFolderId() == IBundleFolder.F_EXTENSIONS; - return false; - } - - private void removeFromTree(Object object) { - String namespace = getNamespaceIdentifier(object); - if (namespace == null) - return; - TreeItem[] bundles = fBrowser.getTreeItems(); - for (int i = 0; i < bundles.length; i++) { - Object data = bundles[i].getData(); - Object adapted = null; - if (data instanceof PluginObjectAdapter) - adapted = ((PluginObjectAdapter)data).getObject(); - if (adapted instanceof Bundle && ((Bundle)adapted).getSymbolicName().equals(namespace)) { - TreeItem[] folders = bundles[i].getItems(); - // TODO fix this method - if (true) { - fBrowser.refresh(data); - fBrowser.updateItems(false); - return; - } - for (int j = 0; j < folders.length; j++) { - IBundleFolder folder = (IBundleFolder)folders[j].getData(); - if (correctFolder(folder, object)) { - fBrowser.remove(object); - return; - } - } - // folder not found - 1st extension - refresh bundle item - fBrowser.refresh(data); - } - } - } - - protected Object findTreeBundleData(Object searchData) { - Object data = null; - TreeItem[] items = fBrowser.getTreeItems(); - if (items == null) - return null; - for (int i = 0; i < items.length; i++) { - Object object = items[i].getData(); - data = object; - if (object instanceof PluginObjectAdapter) - object = ((PluginObjectAdapter) object).getObject(); - if (searchData.equals(object)) - return data; - } - return null; - } - - private void handleEvent(int changeType, Bundle bundle) { - Object data = findTreeBundleData(bundle); - switch (changeType) { - case BundleEvent.INSTALLED: - if (data == null) - fBrowser.add(new PluginObjectAdapter(bundle)); - break; - case BundleEvent.UNINSTALLED: - if (data != null) - fBrowser.remove(data); - break; - case BundleEvent.STARTED: - case BundleEvent.STOPPED: - case BundleEvent.UPDATED: - case BundleEvent.RESOLVED: - case BundleEvent.STARTING: - case BundleEvent.STOPPING: - case BundleEvent.UNRESOLVED: - case BundleEvent.LAZY_ACTIVATION: - if (data != null) - fBrowser.update(data); - break; - } - } - - private void handleExtOnlyEvent(int changeType, Bundle bundle) { - switch (changeType) { - case BundleEvent.INSTALLED: - case BundleEvent.UNINSTALLED: - // add/remove all extension points contributed by new bundle - IExtensionPoint[] points = Platform.getExtensionRegistry().getExtensionPoints(bundle.getSymbolicName()); - for (int i = 0; i < points.length; i++) { - Object pointData = findTreeBundleData(points[i]); - if (pointData == null) { - if (changeType == BundleEvent.INSTALLED) - fBrowser.add(new ExtensionPointAdapter(points[i])); - else // changeType == BundleEvent.UNINSTALLED - fBrowser.remove(pointData); - } - } - // add/remove all extensions contributed by new bundle - IExtension[] extensions = Platform.getExtensionRegistry().getExtensions(bundle.getSymbolicName()); - for (int i = 0; i < extensions.length; i++) { - String pointId = extensions[i].getExtensionPointUniqueIdentifier(); - if (changeType == BundleEvent.INSTALLED) { - IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(pointId); - Object pointData = findTreeBundleData(point); - if (pointData != null) - fBrowser.add(pointData, new ExtensionAdapter(extensions[i])); - } else { // changeType == BundleEvent.UNINSTALLED - Object extensionData = findTreeBundleData(extensions[i]); - if (extensionData != null) - fBrowser.remove(extensionData); - } - } - break; - case BundleEvent.STARTED: - case BundleEvent.STOPPED: - case BundleEvent.UPDATED: - case BundleEvent.RESOLVED: - case BundleEvent.STARTING: - case BundleEvent.STOPPING: - case BundleEvent.UNRESOLVED: - case BundleEvent.LAZY_ACTIVATION: - // nothing needs to be done for any other cases - break; - } - } -} Index: src/org/eclipse/pde/internal/runtime/registry/IBundleFolder.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/IBundleFolder.java diff -N src/org/eclipse/pde/internal/runtime/registry/IBundleFolder.java --- src/org/eclipse/pde/internal/runtime/registry/IBundleFolder.java 6 Mar 2006 14:50:59 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import org.eclipse.core.runtime.IAdaptable; -import org.osgi.framework.Bundle; - -public interface IBundleFolder extends IAdaptable { - public static final int F_LOCATION = 0; - public static final int F_EXTENSIONS = 1; - public static final int F_EXTENSION_POINTS = 2; - public static final int F_IMPORTS = 3; - public static final int F_LIBRARIES = 4; - public Object[] getChildren(); - int getFolderId(); - public Bundle getBundle(); -} Index: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java diff -N src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java --- src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java 15 Nov 2007 17:44:31 -0000 1.30 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,247 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import java.io.IOException; -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.osgi.service.resolver.BundleDescription; -import org.eclipse.osgi.service.resolver.PlatformAdmin; -import org.eclipse.osgi.service.resolver.State; -import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.internal.runtime.OverlayIcon; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; -import org.eclipse.pde.internal.runtime.PDERuntimePlugin; -import org.eclipse.pde.internal.runtime.PDERuntimePluginImages; -import org.eclipse.swt.graphics.Image; -import org.osgi.framework.Bundle; - -public class RegistryBrowserLabelProvider extends LabelProvider { - - private Image fPluginImage; - private Image fActivePluginImage; - private Image fUnresolvedPluginImage; - private Image fLibraryImage; - private Image fRuntimeImage; - private Image fGenericTagImage; - private Image fGenericAttrImage; - private Image fExtensionImage; - private Image fExtensionsImage; - private Image fExtensionPointImage; - private Image fExtensionPointsImage; - private Image fRequiresImage; - private Image fExpReqPluginImage; - private Image fReqPluginImage; - private Image fLocationImage; - private TreeViewer fViewer; - - public RegistryBrowserLabelProvider(TreeViewer viewer) { - fViewer = viewer; - fPluginImage = PDERuntimePluginImages.DESC_PLUGIN_OBJ.createImage(); - fReqPluginImage = PDERuntimePluginImages.DESC_REQ_PLUGIN_OBJ.createImage(); - fExtensionPointImage = PDERuntimePluginImages.DESC_EXT_POINT_OBJ.createImage(); - fExtensionPointsImage = PDERuntimePluginImages.DESC_EXT_POINTS_OBJ.createImage(); - fExtensionImage = PDERuntimePluginImages.DESC_EXTENSION_OBJ.createImage(); - fExtensionsImage = PDERuntimePluginImages.DESC_EXTENSIONS_OBJ.createImage(); - fRequiresImage = PDERuntimePluginImages.DESC_REQ_PLUGINS_OBJ.createImage(); - fLibraryImage = PDERuntimePluginImages.DESC_JAVA_LIB_OBJ.createImage(); - fGenericTagImage = PDERuntimePluginImages.DESC_GENERIC_XML_OBJ.createImage(); - fGenericAttrImage = PDERuntimePluginImages.DESC_ATTR_XML_OBJ.createImage(); - fRuntimeImage = PDERuntimePluginImages.DESC_RUNTIME_OBJ.createImage(); - fLocationImage = PDERuntimePluginImages.DESC_LOCATION.createImage(); - - ImageDescriptor activePluginDesc = - new OverlayIcon( - PDERuntimePluginImages.DESC_PLUGIN_OBJ, - new ImageDescriptor[][] {{ PDERuntimePluginImages.DESC_RUN_CO }}); - fActivePluginImage = activePluginDesc.createImage(); - - ImageDescriptor unresolvedPluginDesc = - new OverlayIcon( - PDERuntimePluginImages.DESC_PLUGIN_OBJ, - new ImageDescriptor[][] {{ PDERuntimePluginImages.DESC_ERROR_CO }}); - fUnresolvedPluginImage = unresolvedPluginDesc.createImage(); - - - ImageDescriptor exportedRequiresDesc = - new OverlayIcon( - PDERuntimePluginImages.DESC_REQ_PLUGIN_OBJ, - new ImageDescriptor[][] {{ PDERuntimePluginImages.DESC_EXPORT_CO }}); - fExpReqPluginImage = exportedRequiresDesc.createImage(); - - } - public void dispose() { - fPluginImage.dispose(); - fActivePluginImage.dispose(); - fUnresolvedPluginImage.dispose(); - fReqPluginImage.dispose(); - fExtensionPointImage.dispose(); - fExtensionPointsImage.dispose(); - fExtensionImage.dispose(); - fExtensionsImage.dispose(); - fRequiresImage.dispose(); - fExpReqPluginImage.dispose(); - fLibraryImage.dispose(); - fGenericTagImage.dispose(); - fGenericAttrImage.dispose(); - fRuntimeImage.dispose(); - fLocationImage.dispose(); - } - public Image getImage(Object element) { - if (element instanceof PluginObjectAdapter) - element = ((PluginObjectAdapter) element).getObject(); - - if (element instanceof Bundle) { - Bundle bundle = (Bundle) element; - switch (bundle.getState()) { - case Bundle.ACTIVE: - return fActivePluginImage; - case Bundle.UNINSTALLED: - return fUnresolvedPluginImage; - case Bundle.INSTALLED: - PlatformAdmin platformAdmin = - PDERuntimePlugin.getDefault().getPlatformAdmin(); - State state = platformAdmin.getState(false); - BundleDescription description = state.getBundle(bundle.getBundleId()); - if((state.getDisabledInfos(description)).length > 0) - return fUnresolvedPluginImage; - default: - return fPluginImage; - } - } - if (element instanceof IBundleFolder) { - int id = ((IBundleFolder) element).getFolderId(); - switch (id) { - case IBundleFolder.F_EXTENSIONS: - return fExtensionsImage; - case IBundleFolder.F_EXTENSION_POINTS: - return fExtensionPointsImage; - case IBundleFolder.F_IMPORTS: - return fRequiresImage; - case IBundleFolder.F_LIBRARIES: - return fRuntimeImage; - case IBundleFolder.F_LOCATION: - return fLocationImage; - } - return null; - } - if (element instanceof IExtension) - return fExtensionImage; - - if (element instanceof IExtensionPoint) - return fExtensionPointImage; - - if (element instanceof IBundlePrerequisite) - return ((IBundlePrerequisite)element).isExported() ? - fExpReqPluginImage : fReqPluginImage; - - if (element instanceof IBundleLibrary) - return fLibraryImage; - - if (element instanceof IConfigurationElement) - return fGenericTagImage; - - if (element instanceof IConfigurationAttribute) - return fGenericAttrImage; - - return null; - } - public String getText(Object element) { - if (element instanceof PluginObjectAdapter) - element = ((PluginObjectAdapter) element).getObject(); - if (element instanceof Bundle) { - String id = ((Bundle)element).getSymbolicName(); - String version = (String)((Bundle)element).getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); - if (version == null) - return id; - return id + " (" + version + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - if (element instanceof IBundleFolder) { - switch (((IBundleFolder) element).getFolderId()) { - case IBundleFolder.F_IMPORTS : - return PDERuntimeMessages.RegistryView_folders_imports; - case IBundleFolder.F_LIBRARIES : - return PDERuntimeMessages.RegistryView_folders_libraries; - case IBundleFolder.F_EXTENSION_POINTS : - return PDERuntimeMessages.RegistryView_folders_extensionPoints; - case IBundleFolder.F_EXTENSIONS : - return PDERuntimeMessages.RegistryView_folders_extensions; - case IBundleFolder.F_LOCATION: - Bundle bundle = ((IBundleFolder) element).getBundle(); - URL bundleEntry = bundle.getEntry("/"); //$NON-NLS-1$ - try { - bundleEntry = FileLocator.resolve(bundleEntry); - } catch (IOException e) { - } - IPath path = new Path(bundleEntry.getFile()); - String pathString = path.removeTrailingSeparator().toOSString(); - if (pathString.startsWith("file:")) //$NON-NLS-1$ - pathString = pathString.substring(5); - if (pathString.endsWith("!")) //$NON-NLS-1$ - pathString = pathString.substring(0, pathString.length() - 1); - return pathString; - } - } - if (element instanceof IExtension) { - if (((RegistryBrowserContentProvider)fViewer.getContentProvider()).isInExtensionSet) { - String name = ((IExtension) element).getLabel(); - String id = ((IExtension) element).getExtensionPointUniqueIdentifier(); - if (name != null && name.length() > 0) - return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_nameIdBind, id, name); - return id; - } - - String contributor = ((IExtension) element).getNamespaceIdentifier(); - return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_contributedBy, contributor); - - } - if (element instanceof IExtensionPoint) { - String id = ((IExtensionPoint)element).getUniqueIdentifier(); - String name = ((IExtensionPoint)element).getLabel(); - if (name != null && name.length() > 0) - return NLS.bind(PDERuntimeMessages.RegistryBrowserLabelProvider_nameIdBind, id, name); - return id; - } - if (element instanceof IBundlePrerequisite) - return ((IBundlePrerequisite) element).getLabel(); - - if (element instanceof IBundleLibrary) - return ((IBundleLibrary)element).getLibrary(); - - if (element instanceof IConfigurationElement) { - String label = ((IConfigurationElement) element).getAttribute("label"); //$NON-NLS-1$ - if (label == null) - label = ((IConfigurationElement) element).getName(); - - if (label == null) - label = ((IConfigurationElement) element).getAttribute("name"); //$NON-NLS-1$ - - if (label == null && ((IConfigurationElement) element).getAttribute("id") != null){ //$NON-NLS-1$ - String[] labelSplit = ((IConfigurationElement) element).getAttribute("id").split("\\."); //$NON-NLS-1$ //$NON-NLS-2$ - label = labelSplit.length == 0 ? null: labelSplit[labelSplit.length-1]; - } - return label; - } - if (element instanceof IConfigurationAttribute) - return ((IConfigurationAttribute)element).getLabel(); - - return super.getText(element); - } -} Index: src/org/eclipse/pde/internal/runtime/registry/ParentAdapter.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/ParentAdapter.java diff -N src/org/eclipse/pde/internal/runtime/registry/ParentAdapter.java --- src/org/eclipse/pde/internal/runtime/registry/ParentAdapter.java 29 Oct 2007 19:17:17 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -public abstract class ParentAdapter extends PluginObjectAdapter { - Object[] fChildren; - - public ParentAdapter(Object object) { - super(object); - } - - protected abstract Object[] createChildren(); - - public Object[] getChildren() { - if (fChildren == null) - fChildren = createChildren(); - return fChildren; - } -} Index: src/org/eclipse/pde/internal/runtime/registry/ConfigurationElementAdapter.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/ConfigurationElementAdapter.java diff -N src/org/eclipse/pde/internal/runtime/registry/ConfigurationElementAdapter.java --- src/org/eclipse/pde/internal/runtime/registry/ConfigurationElementAdapter.java 29 Oct 2007 19:17:18 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import org.eclipse.core.runtime.IConfigurationElement; - -public class ConfigurationElementAdapter extends ParentAdapter { - - class ConfigurationAttribute implements IConfigurationAttribute { - private String fLabel; - public ConfigurationAttribute(String name, String value) { - fLabel = name + " = " + value; //$NON-NLS-1$ - } - public String getLabel() { - return fLabel; - } - } - - public ConfigurationElementAdapter(Object object) { - super(object); - } - - protected Object[] createChildren() { - IConfigurationElement config = (IConfigurationElement) getObject(); - String[] atts = config.getAttributeNames(); - IConfigurationAttribute[] catts = new IConfigurationAttribute[atts.length]; - for (int i = 0; i < atts.length; i++) - catts[i] = new ConfigurationAttribute(atts[i], config.getAttribute(atts[i])); - IConfigurationElement[] children = config.getChildren(); - Object[] result = new Object[children.length + catts.length]; - for (int i = 0; i < children.length; i++) { - IConfigurationElement child = children[i]; - result[i] = new ConfigurationElementAdapter(child); - } - for (int i = 0; i < catts.length; i++) { - IConfigurationAttribute child = catts[i]; - result[children.length + i] = new ConfigurationAttributeAdapter(child); - } - return result; - } -} Index: src/org/eclipse/pde/internal/runtime/registry/PluginObjectAdapter.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/PluginObjectAdapter.java diff -N src/org/eclipse/pde/internal/runtime/registry/PluginObjectAdapter.java --- src/org/eclipse/pde/internal/runtime/registry/PluginObjectAdapter.java 29 Oct 2007 19:17:18 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import org.eclipse.core.runtime.PlatformObject; - -public class PluginObjectAdapter extends PlatformObject { - private Object fObject; - - public PluginObjectAdapter(Object object) { - this.fObject = object; - } - - public Object getObject() { - return fObject; - } -} Index: src/org/eclipse/pde/internal/runtime/registry/ExtensionPointAdapter.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/ExtensionPointAdapter.java diff -N src/org/eclipse/pde/internal/runtime/registry/ExtensionPointAdapter.java --- src/org/eclipse/pde/internal/runtime/registry/ExtensionPointAdapter.java 29 Oct 2007 19:17:18 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; - -public class ExtensionPointAdapter extends ParentAdapter { - - public ExtensionPointAdapter(Object object) { - super(object); - } - - protected Object[] createChildren() { - IExtensionPoint extensionPoint = (IExtensionPoint) getObject(); - - IExtension[] extensions = extensionPoint.getExtensions(); - Object[] result = new Object[extensions.length]; - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - result[i] = new ExtensionAdapter(extension); - } - return result; - } -} Index: src/org/eclipse/pde/internal/runtime/registry/ExtensionAdapter.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/ExtensionAdapter.java diff -N src/org/eclipse/pde/internal/runtime/registry/ExtensionAdapter.java --- src/org/eclipse/pde/internal/runtime/registry/ExtensionAdapter.java 29 Oct 2007 19:17:17 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; - -public class ExtensionAdapter extends ParentAdapter { - - public ExtensionAdapter(Object object) { - super(object); - } - - protected Object[] createChildren() { - IExtension extension = (IExtension) getObject(); - - IConfigurationElement[] elements = extension.getConfigurationElements(); - Object[] result = new ConfigurationElementAdapter[elements.length]; - for (int i = 0; i < elements.length; i++) { - IConfigurationElement config = elements[i]; - result[i] = new ConfigurationElementAdapter(config); - } - return result; - } -} Index: src/org/eclipse/pde/internal/runtime/registry/IBundlePrerequisite.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/IBundlePrerequisite.java diff -N src/org/eclipse/pde/internal/runtime/registry/IBundlePrerequisite.java --- src/org/eclipse/pde/internal/runtime/registry/IBundlePrerequisite.java 6 Mar 2006 14:50:59 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import org.eclipse.osgi.util.ManifestElement; - -public interface IBundlePrerequisite { - public ManifestElement getPrerequisite(); - public boolean isExported(); - public String getLabel(); -} Index: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java diff -N src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java --- src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java 15 Nov 2007 17:44:31 -0000 1.26 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,227 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; -import java.util.ArrayList; -import java.util.Hashtable; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.osgi.util.ManifestElement; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleException; -import org.osgi.framework.Constants; - -public class RegistryBrowserContentProvider implements ITreeContentProvider { - private Hashtable fPluginMap = new Hashtable(); - public boolean isInExtensionSet; - - - class BundleFolder implements IBundleFolder { - private int id; - private Bundle bundle; - public BundleFolder(Bundle pd, int id) { - this.bundle = pd; - this.id = id; - } - public Bundle getBundle() { - return bundle; - } - public Object[] getChildren() { - return getFolderChildren(bundle, id); - } - public int getFolderId() { - return id; - } - public Object getAdapter(Class key) { - return null; - } - } - - class BundlePrerequisite implements IBundlePrerequisite { - private ManifestElement underlyingElement; - public BundlePrerequisite(ManifestElement element) { - underlyingElement = element; - } - public ManifestElement getPrerequisite() { - return underlyingElement; - } - public boolean isExported() { - String visibility = underlyingElement.getDirective(Constants.VISIBILITY_DIRECTIVE); - return Constants.VISIBILITY_REEXPORT.equals(visibility); - } - public String getLabel() { - String version = underlyingElement.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE); - String value = underlyingElement.getValue(); - if (version == null) - return value; - if (Character.isDigit(version.charAt(0))) - version = '(' + version + ')'; - return value + ' ' + version; - } - } - - class BundleLibrary implements IBundleLibrary { - private ManifestElement underlyingElement; - public BundleLibrary(ManifestElement element) { - underlyingElement = element; - } - public String getLibrary() { - return underlyingElement.getValue(); - } - } - - - protected PluginObjectAdapter createAdapter(Object object, int id) { - if (id == IBundleFolder.F_EXTENSIONS) - return new ExtensionAdapter(object); - if (id == IBundleFolder.F_EXTENSION_POINTS) - return new ExtensionPointAdapter(object); - return new PluginObjectAdapter(object); - } - protected Object[] createPluginFolders(Bundle bundle) { - Object[] array = new Object[5]; - array[0] = new BundleFolder(bundle, IBundleFolder.F_LOCATION); - array[1] = new BundleFolder(bundle, IBundleFolder.F_IMPORTS); - array[2] = new BundleFolder(bundle, IBundleFolder.F_LIBRARIES); - array[3] = new BundleFolder(bundle, IBundleFolder.F_EXTENSION_POINTS); - array[4] = new BundleFolder(bundle, IBundleFolder.F_EXTENSIONS); - return array; - } - - public void dispose() { } - - public Object[] getElements(Object element) { - return getChildren(element); - } - - public Object[] getChildren(Object element) { - if (element == null) - return null; - - if (element instanceof ExtensionAdapter) - return ((ExtensionAdapter) element).getChildren(); - - isInExtensionSet = false; - if (element instanceof ExtensionPointAdapter) - return ((ExtensionPointAdapter) element).getChildren(); - - if (element instanceof ConfigurationElementAdapter) - return ((ConfigurationElementAdapter) element).getChildren(); - - if (element instanceof PluginObjectAdapter) - element = ((PluginObjectAdapter) element).getObject(); - - if (element instanceof Bundle) { - Bundle bundle = (Bundle) element; - String bundleID = new Long(bundle.getBundleId()).toString(); - Object[] folders = (Object[]) fPluginMap.get(bundleID); - if (folders == null) { - folders = createPluginFolders(bundle); - fPluginMap.put(bundleID, folders); - } else { - ArrayList folderList = new ArrayList(); - for (int i = 0; i < folders.length; i++) { - if (folders[i] != null - && ((IBundleFolder)folders[i]).getChildren() != null - || ((IBundleFolder)folders[i]).getFolderId() == IBundleFolder.F_LOCATION) - folderList.add(folders[i]); - } - folders = folderList.toArray(new Object[folderList.size()]); - } - return folders; - } - if (element instanceof IBundleFolder) { - IBundleFolder folder = (IBundleFolder) element; - isInExtensionSet = folder.getFolderId() == IBundleFolder.F_EXTENSIONS; - return ((IBundleFolder) element).getChildren(); - } - if (element instanceof IConfigurationElement) { - return ((IConfigurationElement) element).getChildren(); - } - if (element instanceof Object[]) { - return (Object[])element; - } - if (element instanceof IExtensionPoint) { - Object[] array = ((IExtensionPoint)element).getExtensions(); - Object[] result = null; - if (array != null && array.length > 0) { - result = new Object[array.length]; - for (int i = 0; i < array.length; i++) { - result[i] = createAdapter(array[i], IBundleFolder.F_EXTENSIONS); - } - } - return result; - } - return null; - } - - private Object[] getFolderChildren(Bundle bundle, int id) { - Object[] array = null; - String bundleId = bundle.getSymbolicName(); - switch (id) { - case IBundleFolder.F_EXTENSIONS : - array = Platform.getExtensionRegistry().getExtensions(bundleId); - break; - case IBundleFolder.F_EXTENSION_POINTS : - array = Platform.getExtensionRegistry().getExtensionPoints(bundleId); - break; - case IBundleFolder.F_IMPORTS : - array = getManifestHeaderArray(bundle, Constants.REQUIRE_BUNDLE); - break; - case IBundleFolder.F_LIBRARIES : - array = getManifestHeaderArray(bundle, Constants.BUNDLE_CLASSPATH); - break; - } - Object[] result = null; - if (array != null && array.length > 0) { - result = new Object[array.length]; - for (int i = 0; i < array.length; i++) { - result[i] = createAdapter(array[i], id); - } - } - return result; - } - public Object getParent(Object element) { - return null; - } - public boolean hasChildren(Object element) { - Object[] children = getChildren(element); - return children != null && children.length > 0; - } - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - private Object[] getManifestHeaderArray(Bundle bundle, String headerKey) { - String libraries = (String)bundle.getHeaders().get(headerKey); - try { - ManifestElement[] elements = ManifestElement.parseHeader(headerKey, libraries); - if (elements == null) - return null; - if (headerKey.equals(Constants.BUNDLE_CLASSPATH)) { - IBundleLibrary[] array = new IBundleLibrary[elements.length]; - for (int i = 0; i < elements.length; i++) - array[i] = new BundleLibrary(elements[i]); - return array; - } else if (headerKey.equals(Constants.REQUIRE_BUNDLE)) { - IBundlePrerequisite[] array = new IBundlePrerequisite[elements.length]; - for (int i = 0; i < elements.length; i++) - array[i] = new BundlePrerequisite(elements[i]); - return array; - } - } catch (BundleException e) { - } - return null; - } - -} Index: src/org/eclipse/pde/internal/runtime/registry/DiagnosticsDialog.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/DiagnosticsDialog.java diff -N src/org/eclipse/pde/internal/runtime/registry/DiagnosticsDialog.java --- src/org/eclipse/pde/internal/runtime/registry/DiagnosticsDialog.java 11 Nov 2007 20:32:48 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,44 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Benjamin Muskalla - bug 207831 - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -public class DiagnosticsDialog extends ErrorDialog { - - public DiagnosticsDialog(Shell parentShell, String dialogTitle, - String message, IStatus status, int displayMask) { - super(parentShell, dialogTitle, message, status, displayMask); - } - - protected Control createDialogArea(Composite parent) { - Control area = super.createDialogArea(parent); - createDropDownList((Composite) area); - return area; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, - true); - } - -} \ No newline at end of file Index: src/org/eclipse/pde/internal/runtime/registry/IConfigurationAttribute.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/IConfigurationAttribute.java diff -N src/org/eclipse/pde/internal/runtime/registry/IConfigurationAttribute.java --- src/org/eclipse/pde/internal/runtime/registry/IConfigurationAttribute.java 6 Mar 2006 14:50:59 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -public interface IConfigurationAttribute { - public String getLabel(); -} Index: src/org/eclipse/pde/internal/runtime/registry/IBundleLibrary.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/registry/IBundleLibrary.java diff -N src/org/eclipse/pde/internal/runtime/registry/IBundleLibrary.java --- src/org/eclipse/pde/internal/runtime/registry/IBundleLibrary.java 6 Mar 2006 14:50:59 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime.registry; - -public interface IBundleLibrary { - public String getLibrary(); -} Index: src/org/eclipse/pde/internal/runtime/spy/dialogs/SpyDialog.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/spy/dialogs/SpyDialog.java,v retrieving revision 1.11 diff -u -r1.11 SpyDialog.java --- src/org/eclipse/pde/internal/runtime/spy/dialogs/SpyDialog.java 12 Nov 2007 16:55:01 -0000 1.11 +++ src/org/eclipse/pde/internal/runtime/spy/dialogs/SpyDialog.java 19 Nov 2007 13:42:18 -0000 @@ -12,8 +12,8 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.dialogs.PopupDialog; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; -import org.eclipse.pde.internal.runtime.PDERuntimePluginImages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyMessages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyPluginImages; import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit; import org.eclipse.pde.internal.runtime.spy.sections.ActiveDialogPageSection; import org.eclipse.pde.internal.runtime.spy.sections.ActiveHelpSection; @@ -59,8 +59,8 @@ toolkit.decorateFormHeading(form.getForm()); // set title and image - form.setText(PDERuntimeMessages.SpyDialog_title); - Image image = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_SPY_OBJ); + form.setText(PDERuntimeSpyMessages.SpyDialog_title); + Image image = PDERuntimeSpyPluginImages.get(PDERuntimeSpyPluginImages.IMG_SPY_OBJ); form.setImage(image); TableWrapLayout layout = new TableWrapLayout(); Index: src/org/eclipse/pde/internal/runtime/PDERuntimeMessages.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/PDERuntimeMessages.java diff -N src/org/eclipse/pde/internal/runtime/PDERuntimeMessages.java --- src/org/eclipse/pde/internal/runtime/PDERuntimeMessages.java 15 Nov 2007 20:33:16 -0000 1.18 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime; - -import org.eclipse.osgi.util.NLS; - -public class PDERuntimeMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.pde.internal.runtime.pderuntimeresources";//$NON-NLS-1$ - - public static String RegistryView_refresh_label; - public static String RegistryView_refresh_tooltip; - public static String RegistryView_collapseAll_label; - public static String RegistryView_collapseAll_tooltip; - public static String RegistryView_folders_imports; - public static String RegistryView_folders_libraries; - public static String RegistryView_folders_extensionPoints; - public static String RegistryView_folders_extensions; - - public static String RegistryView_found_problems; - public static String RegistryView_showRunning_label; - public static String RegistryView_showAdvanced_label; - public static String RegistryView_titleSummary; - public static String RegistryView_startAction_label; - public static String RegistryView_stopAction_label; - public static String RegistryView_enableAction_label; - public static String RegistryView_diag_dialog_title; - - public static String RegistryView_diagnoseAction_label; - public static String RegistryView_disableAction_label; - public static String RegistryView_no_unresolved_constraints; - - public static String MessageHelper_missing_optional_required_bundle; - public static String MessageHelper_missing_required_bundle; - public static String MessageHelper_missing_imported_package; - public static String MessageHelper_missing_host; - - public static String RegistryBrowserLabelProvider_nameIdBind; - - public static String SpyDialog_title; - public static String SpyDialog_activeShell_title; - public static String SpyDialog_activeShell_desc; - public static String SpyDialog_activePart_title; - public static String SpyDialog_activePart_desc; - public static String SpyDialog_activeWizard_title; - public static String SpyDialog_activeWizard_desc; - public static String SpyDialog_activeMenuIds; - public static String SpyDialog_contributingPluginId_title; - public static String SpyDialog_contributingPluginId_desc; - public static String SpyDialog_activeSelection_title; - public static String SpyDialog_activeSelection_desc; - public static String SpyDialog_activeSelectionInterfaces_desc; - public static String SpyDialog_activeDialogPageSection_title; - public static String SpyDialog_activeDialogPageSection_title2; - public static String SpyDialog_activeDialogPageSection_desc; - public static String SpyDialog_activeHelpSection_title; - public static String SpyDialog_activeHelpSection_desc; - - public static String SpyFormToolkit_saveImageAs_title; - - public static String RegistryBrowser_showExtOnlyLabel; - public static String RegistryBrowser_plugins; - public static String RegistryBrowserLabelProvider_contributedBy; - - - static { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, PDERuntimeMessages.class); - } - -} Index: src/org/eclipse/pde/internal/runtime/pderuntimeresources.properties =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/pderuntimeresources.properties diff -N src/org/eclipse/pde/internal/runtime/pderuntimeresources.properties --- src/org/eclipse/pde/internal/runtime/pderuntimeresources.properties 15 Nov 2007 20:33:16 -0000 1.67 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,64 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2007 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# -# PDE Runtime resources -# - -RegistryView_refresh_label=&Refresh -RegistryView_refresh_tooltip=Refresh -RegistryView_collapseAll_label = &Collapse All -RegistryView_collapseAll_tooltip = Collapse All -RegistryView_folders_imports = Prerequisites -RegistryView_folders_libraries = Run-time Libraries -RegistryView_folders_extensionPoints = Extension Points -RegistryView_folders_extensions = Extensions -RegistryView_found_problems=The following problems were found: -RegistryView_showRunning_label = &Show Active Plug-ins Only -RegistryView_showAdvanced_label = Show Advanced &Operations -RegistryBrowser_showExtOnlyLabel=Extension Points / Extensions only -RegistryBrowser_plugins=plug-ins -RegistryBrowserLabelProvider_contributedBy=contributed by: {0} -RegistryBrowserLabelProvider_nameIdBind={0} [{1}] -RegistryView_titleSummary = Filter matched {0} of {1} {2}. -RegistryView_startAction_label = Start -RegistryView_stopAction_label = Stop -RegistryView_enableAction_label = Enable -RegistryView_diag_dialog_title=Diagnosis -RegistryView_diagnoseAction_label=Diagnose -RegistryView_disableAction_label = Disable -RegistryView_no_unresolved_constraints=No problems detected. - -MessageHelper_missing_optional_required_bundle=Missing optionally required bundle {0} -MessageHelper_missing_required_bundle=Missing required bundle {0} -MessageHelper_missing_imported_package=Missing imported package {0} -MessageHelper_missing_host=Missing host {0} - -# Plug-in Spy -SpyDialog_title = Plug-in Spy -SpyDialog_activeShell_title = Active Shell -SpyDialog_activeShell_desc = The active shell class: -SpyDialog_activeWizard_title = Active Wizard ({0}) -SpyDialog_activeWizard_desc = The active wizard class: -SpyDialog_activePart_title = Active Part ({0}) -SpyDialog_activePart_desc = The active {0} class: -SpyDialog_activeMenuIds = The active menu contribution identifiers: -SpyDialog_contributingPluginId_title = The contributing plug-in: -SpyDialog_contributingPluginId_desc = The active {0} identifier: -SpyDialog_activeSelection_title = Active Selection -SpyDialog_activeSelection_desc = The selection class: -SpyDialog_activeSelectionInterfaces_desc = The interfaces valid for the selection: -SpyDialog_activeDialogPageSection_title = Active Page ({0}) -SpyDialog_activeDialogPageSection_title2 = Active Page -SpyDialog_activeDialogPageSection_desc = The active page class: -SpyDialog_activeHelpSection_title = Active Help -SpyDialog_activeHelpSection_desc = The active help context identifiers: - -SpyFormToolkit_saveImageAs_title = Save Image As... \ No newline at end of file Index: src/org/eclipse/pde/internal/runtime/MessageHelper.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/MessageHelper.java diff -N src/org/eclipse/pde/internal/runtime/MessageHelper.java --- src/org/eclipse/pde/internal/runtime/MessageHelper.java 11 Nov 2007 20:32:48 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime; - -import org.eclipse.osgi.service.resolver.BundleSpecification; -import org.eclipse.osgi.service.resolver.ImportPackageSpecification; -import org.eclipse.osgi.service.resolver.VersionConstraint; -import org.eclipse.osgi.util.NLS; - -public class MessageHelper { - public static String getResolutionFailureMessage(VersionConstraint unsatisfied) { - if (unsatisfied.isResolved()) - throw new IllegalArgumentException(); - if (unsatisfied instanceof ImportPackageSpecification) - return NLS.bind(PDERuntimeMessages.MessageHelper_missing_imported_package, toString(unsatisfied)); - else if (unsatisfied instanceof BundleSpecification) { - if (((BundleSpecification) unsatisfied).isOptional()) - return NLS.bind(PDERuntimeMessages.MessageHelper_missing_optional_required_bundle, toString(unsatisfied)); - return NLS.bind(PDERuntimeMessages.MessageHelper_missing_required_bundle, toString(unsatisfied)); - } else - return NLS.bind(PDERuntimeMessages.MessageHelper_missing_host, toString(unsatisfied)); - } - - private static String toString(VersionConstraint constraint) { - org.eclipse.osgi.service.resolver.VersionRange versionRange = constraint.getVersionRange(); - if (versionRange == null) - return constraint.getName(); - return constraint.getName() + '_' + versionRange; - } - -} Index: src/org/eclipse/pde/internal/runtime/IHelpContextIds.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/IHelpContextIds.java diff -N src/org/eclipse/pde/internal/runtime/IHelpContextIds.java --- src/org/eclipse/pde/internal/runtime/IHelpContextIds.java 3 Oct 2007 15:04:24 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime; - -public interface IHelpContextIds { - public static final String PREFIX = "org.eclipse.pde.doc.user" + "."; //$NON-NLS-1$ //$NON-NLS-2$ - - public static final String REGISTRY_VIEW = PREFIX + "registry_view"; //$NON-NLS-1$ - -} Index: src/org/eclipse/pde/internal/runtime/PDERuntimePlugin.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/PDERuntimePlugin.java diff -N src/org/eclipse/pde/internal/runtime/PDERuntimePlugin.java --- src/org/eclipse/pde/internal/runtime/PDERuntimePlugin.java 15 Nov 2007 20:12:36 -0000 1.26 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.osgi.service.resolver.PlatformAdmin; -import org.eclipse.osgi.service.resolver.State; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.service.packageadmin.PackageAdmin; -import org.osgi.util.tracker.ServiceTracker; - -public class PDERuntimePlugin extends AbstractUIPlugin { - - public static final String ID = "org.eclipse.pde.runtime"; //$NON-NLS-1$ - - private static PDERuntimePlugin inst; - private BundleContext fContext; - private ServiceTracker packageAdminTracker; - private ServiceTracker platformAdminTracker; - - private static boolean isBundleAvailable(String bundleID) { - Bundle bundle = Platform.getBundle(bundleID); - return bundle != null - && (bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.RESOLVED)) != 0; - } - - public static final boolean HAS_IDE_BUNDLES; - static { - boolean result = false; - try { - result = isBundleAvailable("org.eclipse.core.resources") //$NON-NLS-1$ - && isBundleAvailable("org.eclipse.pde.core") //$NON-NLS-1$ - && isBundleAvailable("org.eclipse.jdt.core") //$NON-NLS-1$ - && isBundleAvailable("org.eclipse.help") //$NON-NLS-1$ - && isBundleAvailable("org.eclipse.pde.ui") //$NON-NLS-1$ - && isBundleAvailable("org.eclipse.jdt.ui"); //$NON-NLS-1$ - } catch (Throwable exception) {} - HAS_IDE_BUNDLES = result; - } - - public static IWorkbenchPage getActivePage() { - return getDefault().internalGetActivePage(); - } - - public static Shell getActiveWorkbenchShell() { - return getActiveWorkbenchWindow().getShell(); - } - - public static IWorkbenchWindow getActiveWorkbenchWindow() { - return getDefault().getWorkbench().getActiveWorkbenchWindow(); - } - - public PackageAdmin getPackageAdmin() { - if (packageAdminTracker == null) { - return null; - } - return (PackageAdmin) packageAdminTracker.getService(); - } - - public PlatformAdmin getPlatformAdmin() { - if (platformAdminTracker == null) { - return null; - } - return (PlatformAdmin) platformAdminTracker.getService(); - } - - public static PDERuntimePlugin getDefault() { - return inst; - } - - public static String getPluginId() { - return getDefault().getBundle().getSymbolicName(); - } - - public PDERuntimePlugin() { - inst = this; - } - - private IWorkbenchPage internalGetActivePage() { - return getWorkbench().getActiveWorkbenchWindow().getActivePage(); - } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - this.fContext = context; - - packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null); - packageAdminTracker.open(); - - platformAdminTracker = new ServiceTracker(context, PlatformAdmin.class.getName(), null); - platformAdminTracker.open(); - } - - public BundleContext getBundleContext() { - return this.fContext; - } - - public State getState() { - return getPlatformAdmin().getState(false); - } - - public static void log(Throwable e) { - if (e instanceof InvocationTargetException) - e = ((InvocationTargetException) e).getTargetException(); - IStatus status = null; - if (e instanceof CoreException) { - status = ((CoreException) e).getStatus(); - } else if (e.getMessage() != null) { - status = new Status( - IStatus.ERROR, - ID, - IStatus.OK, - e.getMessage(), - e); - } - if(status != null) - getDefault().getLog().log(status); - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - if (packageAdminTracker != null) { - packageAdminTracker.close(); - packageAdminTracker = null; - } - if (platformAdminTracker != null) { - platformAdminTracker.close(); - platformAdminTracker = null; - } - inst = null; - } - -} Index: src/org/eclipse/pde/internal/runtime/PDERuntimePluginImages.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/PDERuntimePluginImages.java diff -N src/org/eclipse/pde/internal/runtime/PDERuntimePluginImages.java --- src/org/eclipse/pde/internal/runtime/PDERuntimePluginImages.java 12 Nov 2007 16:33:25 -0000 1.37 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime; - -import java.net.URL; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; - -public class PDERuntimePluginImages { - - private static ImageRegistry PLUGIN_REGISTRY; - - public final static String ICONS_PATH = "icons/"; //$NON-NLS-1$ - - private static final String PATH_OBJ = ICONS_PATH + "obj16/"; //$NON-NLS-1$ - private static final String PATH_DCL = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$ - private static final String PATH_LCL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$ - private static final String PATH_OVR = ICONS_PATH + "ovr16/"; //$NON-NLS-1$ - - // Plug-in Spy related images - public static final String IMG_CLASS_OBJ = "class_obj.gif"; //$NON-NLS-1$ - public static final String IMG_INTERFACE_OBJ = "int_obj.gif"; //$NON-NLS-1$ - public static final String IMG_PLUGIN_OBJ = "plugin_obj.gif"; //$NON-NLS-1$ - public static final String IMG_SPY_OBJ = "pdespy_obj.gif"; //$NON-NLS-1$ - public static final String IMG_MENU_OBJ = "menu_obj.gif"; //$NON-NLS-1$ - public static final String IMG_ID_OBJ = "generic_xml_obj.gif"; //$NON-NLS-1$ - public static final String IMG_MENUSPY_OBJ = "menuspy_obj.gif"; //$NON-NLS-1$ - public static final String IMG_CONTEXTID_OBJ = "contextid_obj.gif"; //$NON-NLS-1$ - public static final String IMG_SAVE_IMAGE_AS_OBJ = "save_image_as_obj.gif"; //$NON-NLS-1$ - - public static final ImageDescriptor CLASS_OBJ = - create(PATH_OBJ, IMG_CLASS_OBJ); - public static final ImageDescriptor INTERFACE_OBJ = - create(PATH_OBJ, IMG_INTERFACE_OBJ); - public static final ImageDescriptor PLUGIN_OBJ = - create(PATH_OBJ, IMG_PLUGIN_OBJ); - public static final ImageDescriptor SPY_OBJ = - create(PATH_OBJ, IMG_SPY_OBJ); - public static final ImageDescriptor MENU_OBJ = - create(PATH_OBJ, IMG_MENU_OBJ); - public static final ImageDescriptor ID_OBJ = - create(PATH_OBJ, IMG_ID_OBJ); - public static final ImageDescriptor MENUSPY_OBJ = - create(PATH_OBJ, IMG_MENUSPY_OBJ); - public static final ImageDescriptor CONTEXTID_OBJ = - create(PATH_OBJ, IMG_CONTEXTID_OBJ); - public static final ImageDescriptor SAVE_IMAGE_AS_OBJ = - create(PATH_OBJ, IMG_SAVE_IMAGE_AS_OBJ); - - public static final ImageDescriptor DESC_REFRESH_DISABLED = - create(PATH_DCL, "refresh.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_REFRESH = - create(PATH_LCL, "refresh.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_COLLAPSE_ALL = - create(PATH_LCL, "collapseall.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_ERROR_ST_OBJ = - create(PATH_OBJ, "error_st_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_ERROR_STACK_OBJ = - create(PATH_OBJ, "error_stack.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_EXT_POINT_OBJ = - create(PATH_OBJ, "ext_point_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_EXT_POINTS_OBJ = - create(PATH_OBJ, "ext_points_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_EXTENSION_OBJ = - create(PATH_OBJ, "extension_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_EXTENSIONS_OBJ = - create(PATH_OBJ, "extensions_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_GENERIC_XML_OBJ = - create(PATH_OBJ, "generic_xml_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_ATTR_XML_OBJ = - create(PATH_OBJ, "attr_xml_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_INFO_ST_OBJ = - create(PATH_OBJ, "info_st_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_JAVA_LIB_OBJ = - create(PATH_OBJ, "java_lib_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_NATIVE_LIB_OBJ = - create(PATH_OBJ, "native_lib_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_OK_ST_OBJ = - create(PATH_OBJ, "ok_st_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_PLUGIN_OBJ = - create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_REQ_PLUGIN_OBJ = - create(PATH_OBJ, "req_plugin_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_REQ_PLUGINS_OBJ = - create(PATH_OBJ, "req_plugins_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_RUNTIME_OBJ = - create(PATH_OBJ, "runtime_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_WARNING_ST_OBJ = - create(PATH_OBJ, "warning_st_obj.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_LOCATION = - create(PATH_OBJ, "location_obj.gif"); //$NON-NLS-1$ - - /* - * Overlays - */ - public static final ImageDescriptor DESC_RUN_CO = - create(PATH_OVR, "run_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_EXPORT_CO = - create(PATH_OVR, "export_co.gif"); //$NON-NLS-1$ - public static final ImageDescriptor DESC_ERROR_CO = - create(PATH_OVR, "error_co.gif"); //$NON-NLS-1$ - - private static final void initialize() { - PLUGIN_REGISTRY = PDERuntimePlugin.getDefault().getImageRegistry(); - manage(IMG_CLASS_OBJ, CLASS_OBJ); - manage(IMG_INTERFACE_OBJ, INTERFACE_OBJ); - manage(IMG_PLUGIN_OBJ, PLUGIN_OBJ); - manage(IMG_SPY_OBJ, SPY_OBJ); - manage(IMG_MENU_OBJ, MENU_OBJ); - manage(IMG_ID_OBJ, ID_OBJ); - manage(IMG_MENUSPY_OBJ, MENUSPY_OBJ); - manage(IMG_CONTEXTID_OBJ, CONTEXTID_OBJ); - manage(IMG_SAVE_IMAGE_AS_OBJ, SAVE_IMAGE_AS_OBJ); - } - - private static ImageDescriptor create(String prefix, String name) { - return ImageDescriptor.createFromURL(makeIconURL(prefix, name)); - } - - public static Image get(String key) { - if (PLUGIN_REGISTRY==null) initialize(); - return PLUGIN_REGISTRY.get(key); - } - private static URL makeIconURL(String prefix, String name) { - String path = "$nl$/" + prefix + name; //$NON-NLS-1$ - return FileLocator.find(PDERuntimePlugin.getDefault().getBundle(), new Path(path), null); - } - public static Image manage(String key, ImageDescriptor desc) { - Image image = desc.createImage(); - PLUGIN_REGISTRY.put(key, image); - return image; - } - -} Index: src/org/eclipse/pde/internal/runtime/OverlayIcon.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/OverlayIcon.java diff -N src/org/eclipse/pde/internal/runtime/OverlayIcon.java --- src/org/eclipse/pde/internal/runtime/OverlayIcon.java 29 Oct 2007 19:17:40 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.runtime; - -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.Point; - - -public class OverlayIcon extends CompositeImageDescriptor { - - static final int DEFAULT_WIDTH= 16; - static final int DEFAULT_HEIGHT= 16; - - private Point fSize= null; - - private ImageDescriptor fBase; - private ImageDescriptor fOverlays[][]; - - public OverlayIcon(ImageDescriptor base, ImageDescriptor[][] overlays) { - fBase= base; - if (fBase == null) - fBase= ImageDescriptor.getMissingImageDescriptor(); - fOverlays= overlays; - fSize= new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT); - } - public OverlayIcon(ImageDescriptor base, ImageDescriptor[][] overlays, Point size) { - fBase= base; - if (fBase == null) - fBase= ImageDescriptor.getMissingImageDescriptor(); - fOverlays= overlays; - fSize= size; - } - protected void drawBottomLeft(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length= overlays.length; - int x= 0; - for (int i= 0; i < 3; i++) { - if (i < length && overlays[i] != null) { - ImageData id= overlays[i].getImageData(); - drawImage(id, x, getSize().y-id.height); - x+= id.width; - } - } - } - protected void drawBottomRight(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length= overlays.length; - int x= getSize().x; - for (int i= 2; i >= 0; i--) { - if (i < length && overlays[i] != null) { - ImageData id= overlays[i].getImageData(); - x-= id.width; - drawImage(id, x, getSize().y-id.height); - } - } - } - protected void drawCompositeImage(int width, int height) { - ImageData bg= fBase.getImageData(); - drawImage(bg, 0, 0); - - if (fOverlays != null) { - if (fOverlays.length > 0) - drawTopRight( fOverlays[0]); - - if (fOverlays.length > 1) - drawBottomRight(fOverlays[1]); - - if (fOverlays.length > 2) - drawBottomLeft(fOverlays[2]); - - if (fOverlays.length > 3) - drawTopLeft(fOverlays[3]); - } - } - protected void drawTopLeft(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length= overlays.length; - int x= 0; - for (int i= 0; i < 3; i++) { - if (i < length && overlays[i] != null) { - ImageData id= overlays[i].getImageData(); - drawImage(id, x, 0); - x+= id.width; - } - } - } - protected void drawTopRight(ImageDescriptor[] overlays) { - if (overlays == null) - return; - int length= overlays.length; - int x= getSize().x; - for (int i= 2; i >= 0; i--) { - if (i < length && overlays[i] != null) { - ImageData id= overlays[i].getImageData(); - x-= id.width; - drawImage(id, x, 0); - } - } - } - protected Point getSize() { - return fSize; - } -} Index: .project =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/.project,v retrieving revision 1.11 diff -u -r1.11 .project --- .project 10 May 2004 20:24:44 -0000 1.11 +++ .project 19 Nov 2007 13:42:17 -0000 @@ -1,28 +1,28 @@ - - - org.eclipse.pde.runtime - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - + + + org.eclipse.pde.runtime + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + Index: plugin.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/plugin.properties,v retrieving revision 1.18 diff -u -r1.18 plugin.properties --- plugin.properties 3 Oct 2007 15:22:42 -0000 1.18 +++ plugin.properties 19 Nov 2007 13:42:17 -0000 @@ -12,13 +12,8 @@ # plugin.xml properties # -name = Plug-in Development Environment Runtime +name = Plug-in Development Environment Runtime Spy provider-name = Eclipse.org -views.category.name = &PDE Runtime -views.registry.name= Plug-in Registry -ViewCommand.registryBrowser.name= Plug-in Registry -ViewCommand.registryBrowser.description= Show the Plug-in Registry - spy-category.name = Spy spy-command.name = Plug-in Spy Index: plugin.xml =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/plugin.xml,v retrieving revision 1.44 diff -u -r1.44 plugin.xml --- plugin.xml 3 Oct 2007 15:04:37 -0000 1.44 +++ plugin.xml 19 Nov 2007 13:42:17 -0000 @@ -5,27 +5,7 @@ - - - - - - - - Index: src/org/eclipse/pde/internal/runtime/spy/sections/ActiveWizardSection.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/spy/sections/ActiveWizardSection.java,v retrieving revision 1.4 diff -u -r1.4 ActiveWizardSection.java --- src/org/eclipse/pde/internal/runtime/spy/sections/ActiveWizardSection.java 12 Nov 2007 16:33:25 -0000 1.4 +++ src/org/eclipse/pde/internal/runtime/spy/sections/ActiveWizardSection.java 19 Nov 2007 13:42:19 -0000 @@ -15,8 +15,8 @@ import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; -import org.eclipse.pde.internal.runtime.PDERuntimePlugin; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyMessages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyPlugin; import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.forms.widgets.ExpandableComposite; @@ -58,15 +58,15 @@ StringBuffer buffer = new StringBuffer(); buffer.append("
"); //$NON-NLS-1$ - section.setText(NLS.bind(PDERuntimeMessages.SpyDialog_activeWizard_title, wizard.getWindowTitle())); + section.setText(NLS.bind(PDERuntimeSpyMessages.SpyDialog_activeWizard_title, wizard.getWindowTitle())); buffer.append(toolkit.createClassSection( text, - PDERuntimeMessages.SpyDialog_activeWizard_desc, + PDERuntimeSpyMessages.SpyDialog_activeWizard_desc, new Class[] { clazz })); PackageAdmin admin = - PDERuntimePlugin.getDefault().getPackageAdmin(); + PDERuntimeSpyPlugin.getDefault().getPackageAdmin(); Bundle bundle = admin.getBundle(clazz); toolkit.generatePluginDetailsText(bundle, null, "wizard", buffer, text); //$NON-NLS-1$ buffer.append("
"); //$NON-NLS-1$ Index: src/org/eclipse/pde/internal/runtime/spy/sections/ActiveDialogPageSection.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/spy/sections/ActiveDialogPageSection.java,v retrieving revision 1.3 diff -u -r1.3 ActiveDialogPageSection.java --- src/org/eclipse/pde/internal/runtime/spy/sections/ActiveDialogPageSection.java 12 Nov 2007 16:33:25 -0000 1.3 +++ src/org/eclipse/pde/internal/runtime/spy/sections/ActiveDialogPageSection.java 19 Nov 2007 13:42:19 -0000 @@ -15,8 +15,8 @@ import org.eclipse.jface.dialogs.IDialogPage; import org.eclipse.jface.dialogs.IPageChangeProvider; import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; -import org.eclipse.pde.internal.runtime.PDERuntimePlugin; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyMessages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyPlugin; import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.forms.widgets.ExpandableComposite; @@ -49,12 +49,12 @@ IDialogPage page = (IDialogPage) selectedPage; clazz = page.getClass(); section.setText(NLS.bind( - PDERuntimeMessages.SpyDialog_activeDialogPageSection_title, + PDERuntimeSpyMessages.SpyDialog_activeDialogPageSection_title, page.getTitle())); } else { clazz = selectedPage.getClass(); - section.setText(PDERuntimeMessages.SpyDialog_activeDialogPageSection_title2); + section.setText(PDERuntimeSpyMessages.SpyDialog_activeDialogPageSection_title2); } // the active page FormText text = toolkit.createFormText(section, true); @@ -69,11 +69,11 @@ buffer.append(toolkit.createClassSection( text, - PDERuntimeMessages.SpyDialog_activeDialogPageSection_desc, + PDERuntimeSpyMessages.SpyDialog_activeDialogPageSection_desc, new Class[] { clazz })); PackageAdmin admin = - PDERuntimePlugin.getDefault().getPackageAdmin(); + PDERuntimeSpyPlugin.getDefault().getPackageAdmin(); Bundle bundle = admin.getBundle(clazz); toolkit.generatePluginDetailsText(bundle, null, "dialog page", buffer, text); //$NON-NLS-1$ Index: src/org/eclipse/pde/internal/runtime/spy/sections/ActiveShellSection.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/spy/sections/ActiveShellSection.java,v retrieving revision 1.4 diff -u -r1.4 ActiveShellSection.java --- src/org/eclipse/pde/internal/runtime/spy/sections/ActiveShellSection.java 12 Nov 2007 16:33:25 -0000 1.4 +++ src/org/eclipse/pde/internal/runtime/spy/sections/ActiveShellSection.java 19 Nov 2007 13:42:19 -0000 @@ -11,7 +11,7 @@ package org.eclipse.pde.internal.runtime.spy.sections; import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyMessages; import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.forms.widgets.ExpandableComposite; @@ -35,7 +35,7 @@ ExpandableComposite.TITLE_BAR); section.clientVerticalSpacing = 9; - section.setText(PDERuntimeMessages.SpyDialog_activeShell_title); + section.setText(PDERuntimeSpyMessages.SpyDialog_activeShell_title); FormText text = toolkit.createFormText(section, true); section.setClient(text); @@ -49,7 +49,7 @@ buffer.append(toolkit.createClassSection( text, - PDERuntimeMessages.SpyDialog_activeShell_desc, + PDERuntimeSpyMessages.SpyDialog_activeShell_desc, new Class[] { clazz })); buffer.append(""); //$NON-NLS-1$ Index: src/org/eclipse/pde/internal/runtime/spy/sections/ActivePartSection.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/spy/sections/ActivePartSection.java,v retrieving revision 1.4 diff -u -r1.4 ActivePartSection.java --- src/org/eclipse/pde/internal/runtime/spy/sections/ActivePartSection.java 15 Nov 2007 20:26:38 -0000 1.4 +++ src/org/eclipse/pde/internal/runtime/spy/sections/ActivePartSection.java 19 Nov 2007 13:42:19 -0000 @@ -19,9 +19,8 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.runtime.Platform; import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; -import org.eclipse.pde.internal.runtime.PDERuntimePlugin; -import org.eclipse.pde.internal.runtime.PDERuntimePluginImages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyMessages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyPluginImages; import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.IEditorPart; @@ -51,7 +50,7 @@ ExpandableComposite.TITLE_BAR); section.setText(NLS.bind( - PDERuntimeMessages.SpyDialog_activePart_title, + PDERuntimeSpyMessages.SpyDialog_activePart_title, part.getSite().getRegisteredName())); FormText text = toolkit.createFormText(section, true); @@ -70,7 +69,7 @@ buffer.append( toolkit.createClassSection( text, - NLS.bind(PDERuntimeMessages.SpyDialog_activePart_desc, partType), + NLS.bind(PDERuntimeSpyMessages.SpyDialog_activePart_desc, partType), new Class[] { part.getClass() })); // time to analyze the contributing plug-in @@ -93,29 +92,29 @@ menuIds.addAll(extender.getMenuIds()); } buffer.append("

"); //$NON-NLS-1$ - buffer.append(PDERuntimeMessages.SpyDialog_activeMenuIds); + buffer.append(PDERuntimeSpyMessages.SpyDialog_activeMenuIds); buffer.append("

"); //$NON-NLS-1$ for (Iterator it = menuIds.iterator(); it.hasNext();) { buffer.append("
  • "); //$NON-NLS-1$ buffer.append(it.next().toString()); buffer.append("
  • "); //$NON-NLS-1$ } - Image menuImage = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_MENU_OBJ); + Image menuImage = PDERuntimeSpyPluginImages.get(PDERuntimeSpyPluginImages.IMG_MENU_OBJ); text.setImage("menu", menuImage); //$NON-NLS-1$ } } catch (SecurityException e) { - PDERuntimePlugin.log(e); + e.printStackTrace(); } catch (NoSuchFieldException e) { - PDERuntimePlugin.log(e); + e.printStackTrace(); } catch (IllegalArgumentException e) { - PDERuntimePlugin.log(e); + e.printStackTrace(); } catch (IllegalAccessException e) { - PDERuntimePlugin.log(e); + e.printStackTrace(); } buffer.append(""); //$NON-NLS-1$ - Image idImage = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_ID_OBJ); + Image idImage = PDERuntimeSpyPluginImages.get(PDERuntimeSpyPluginImages.IMG_ID_OBJ); text.setImage("id", idImage); //$NON-NLS-1$ text.setText(buffer.toString(), true, false); Index: src/org/eclipse/pde/internal/runtime/spy/sections/ActiveSelectionSection.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/spy/sections/ActiveSelectionSection.java,v retrieving revision 1.3 diff -u -r1.3 ActiveSelectionSection.java --- src/org/eclipse/pde/internal/runtime/spy/sections/ActiveSelectionSection.java 12 Nov 2007 16:33:25 -0000 1.3 +++ src/org/eclipse/pde/internal/runtime/spy/sections/ActiveSelectionSection.java 19 Nov 2007 13:42:19 -0000 @@ -13,7 +13,7 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyMessages; import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.forms.widgets.ExpandableComposite; @@ -41,7 +41,7 @@ Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR); section.clientVerticalSpacing = 9; - section.setText(PDERuntimeMessages.SpyDialog_activeSelection_title); + section.setText(PDERuntimeSpyMessages.SpyDialog_activeSelection_title); FormText text = toolkit.createFormText(section, true); section.setClient(text); @@ -55,11 +55,11 @@ buffer.append("
    "); //$NON-NLS-1$ buffer.append(toolkit.createClassSection( text, - PDERuntimeMessages.SpyDialog_activeSelection_desc, + PDERuntimeSpyMessages.SpyDialog_activeSelection_desc, new Class[] { clazz })); Class[] interfaces = clazz.getInterfaces(); - buffer.append(toolkit.createInterfaceSection(text, PDERuntimeMessages.SpyDialog_activeSelectionInterfaces_desc, interfaces)); + buffer.append(toolkit.createInterfaceSection(text, PDERuntimeSpyMessages.SpyDialog_activeSelectionInterfaces_desc, interfaces)); buffer.append("
    "); //$NON-NLS-1$ text.setText(buffer.toString(), true, false); Index: src/org/eclipse/pde/internal/runtime/spy/sections/ActiveHelpSection.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/spy/sections/ActiveHelpSection.java,v retrieving revision 1.10 diff -u -r1.10 ActiveHelpSection.java --- src/org/eclipse/pde/internal/runtime/spy/sections/ActiveHelpSection.java 15 Nov 2007 20:33:16 -0000 1.10 +++ src/org/eclipse/pde/internal/runtime/spy/sections/ActiveHelpSection.java 19 Nov 2007 13:42:19 -0000 @@ -17,9 +17,9 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.preference.IPreferencePage; import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; -import org.eclipse.pde.internal.runtime.PDERuntimePlugin; -import org.eclipse.pde.internal.runtime.PDERuntimePluginImages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyMessages; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyPlugin; +import org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyPluginImages; import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; @@ -70,7 +70,7 @@ if(helpBuffer != null && helpBuffer.length() > 0) { Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR); - section.setText(PDERuntimeMessages.SpyDialog_activeHelpSection_title); + section.setText(PDERuntimeSpyMessages.SpyDialog_activeHelpSection_title); section.clientVerticalSpacing = 9; FormText text = toolkit.createFormText(section, true); @@ -80,14 +80,11 @@ td.grabHorizontal = true; section.setLayoutData(td); - Image image = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_CONTEXTID_OBJ); + Image image = PDERuntimeSpyPluginImages.get(PDERuntimeSpyPluginImages.IMG_CONTEXTID_OBJ); text.setImage("contextid", image); //$NON-NLS-1$ StringBuffer buffer = new StringBuffer(); buffer.append("
    "); //$NON-NLS-1$ - buffer.append("

    "); //$NON-NLS-1$ - buffer.append(PDERuntimeMessages.SpyDialog_activeHelpSection_desc); - buffer.append("

    "); //$NON-NLS-1$ buffer.append(helpBuffer.toString()); buffer.append("
    "); //$NON-NLS-1$ String content = buffer.toString().replaceAll("&", "&"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -163,7 +160,7 @@ } else if(control != null) { // if we don't have org.eclipse.help, we will have problems when trying to load IContextProvider - if (!PDERuntimePlugin.HAS_IDE_BUNDLES) + if (!PDERuntimeSpyPlugin.HAS_IDE_BUNDLES) processChildren(control, buffer); else { IContextProvider provider = (IContextProvider)part.getAdapter(IContextProvider.class); Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/META-INF/MANIFEST.MF,v retrieving revision 1.21 diff -u -r1.21 MANIFEST.MF --- META-INF/MANIFEST.MF 15 Nov 2007 20:12:36 -0000 1.21 +++ META-INF/MANIFEST.MF 19 Nov 2007 13:42:17 -0000 @@ -1,9 +1,9 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name -Bundle-SymbolicName: org.eclipse.pde.runtime; singleton:=true +Bundle-SymbolicName: org.eclipse.pde.runtime.spy;singleton:=true Bundle-Version: 3.4.0.qualifier -Bundle-Activator: org.eclipse.pde.internal.runtime.PDERuntimePlugin +Bundle-Activator: org.eclipse.pde.internal.runtime.spy.PDERuntimeSpyPlugin Bundle-Vendor: %provider-name Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", @@ -15,11 +15,10 @@ org.eclipse.core.resources;bundle-version="[3.3.0,4.0.0)";resolution:=optional, org.eclipse.jdt.ui;bundle-version="[3.3.0,4.0.0)";resolution:=optional, org.eclipse.pde.ui;bundle-version="[3.3.0,4.0.0)";resolution:=optional, - org.eclipse.help;bundle-version="[3.3.0,4.0.0)";resolution:=optional + org.eclipse.help;bundle-version="[3.3.0,4.0.0)";resolution:=optional, + org.eclipse.jdt.launching Eclipse-LazyStart: true -Export-Package: org.eclipse.pde.internal.runtime;x-internal:=true, - org.eclipse.pde.internal.runtime.registry;x-internal:=true, - org.eclipse.pde.internal.runtime.spy;x-internal:=true, +Export-Package: org.eclipse.pde.internal.runtime.spy;x-internal:=true, org.eclipse.pde.internal.runtime.spy.dialogs;x-internal:=true, org.eclipse.pde.internal.runtime.spy.handlers;x-internal:=true, org.eclipse.pde.internal.runtime.spy.sections;x-internal:=true Index: src/org/eclipse/pde/internal/runtime/spy/SpyIDEUtil.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/spy/SpyIDEUtil.java,v retrieving revision 1.4 diff -u -r1.4 SpyIDEUtil.java --- src/org/eclipse/pde/internal/runtime/spy/SpyIDEUtil.java 15 Nov 2007 20:26:38 -0000 1.4 +++ src/org/eclipse/pde/internal/runtime/spy/SpyIDEUtil.java 19 Nov 2007 13:42:17 -0000 @@ -14,19 +14,26 @@ package org.eclipse.pde.internal.runtime.spy; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jdt.ui.JavaUI; +import org.eclipse.osgi.util.NLS; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.PluginRegistry; import org.eclipse.pde.internal.core.PDECore; import org.eclipse.pde.internal.core.SearchablePluginsManager; -import org.eclipse.pde.internal.runtime.PDERuntimePlugin; +import org.eclipse.pde.internal.core.util.CoreUtility; import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor; import org.eclipse.ui.PartInitException; @@ -42,7 +49,7 @@ SearchablePluginsManager manager = PDECore.getDefault() .getSearchablePluginsManager(); try { - manager.createProxyProject(new NullProgressMonitor()); + createProxyProject(new NullProgressMonitor()); manager.addToJavaSearch(new IPluginModelBase[] { model }); project = manager.getProxyProject(); } catch (CoreException e) {} @@ -51,14 +58,44 @@ openInEditor(project, clazz); } + private static IProject createProxyProject(IProgressMonitor monitor) throws CoreException { + IWorkspaceRoot root = PDECore.getWorkspace().getRoot(); + IProject project = + root.getProject(SearchablePluginsManager.PROXY_PROJECT_NAME); + if (project.exists()) { + if (!project.isOpen()) { + project.open(monitor); + } + return project; + } + + monitor.beginTask(NLS.bind(PDERuntimeSpyMessages.SpyIDEUtil_createProjectTaskName, SearchablePluginsManager.PROXY_PROJECT_NAME), 5); + project.create(new SubProgressMonitor(monitor, 1)); + project.open(new SubProgressMonitor(monitor, 1)); + CoreUtility.addNatureToProject(project, JavaCore.NATURE_ID, new SubProgressMonitor(monitor, 1)); + IJavaProject jProject = JavaCore.create(project); + jProject.setOutputLocation(project.getFullPath(), new SubProgressMonitor(monitor, 1)); + computeClasspath(jProject, new SubProgressMonitor(monitor, 1)); + return project; + } + + private static void computeClasspath(IJavaProject project, IProgressMonitor monitor) throws CoreException { + IClasspathEntry[] classpath = new IClasspathEntry[2]; + classpath[0] = JavaCore.newContainerEntry(JavaRuntime.newDefaultJREContainerPath()); + classpath[1] = JavaCore.newContainerEntry(PDECore.JAVA_SEARCH_CONTAINER_PATH); + try { + project.setRawClasspath(classpath, monitor); + } catch (JavaModelException e) {} + } + public static void openInEditor(IJavaProject project, String clazz) { try { IType type = project.findType(clazz); JavaUI.openInEditor(type, false, true); } catch (JavaModelException e) { - PDERuntimePlugin.log(e); + PDERuntimeSpyPlugin.log(e); } catch (PartInitException e) { - PDERuntimePlugin.log(e); + PDERuntimeSpyPlugin.log(e); } } Index: src/org/eclipse/pde/internal/runtime/spy/SpyFormToolkit.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/spy/SpyFormToolkit.java,v retrieving revision 1.7 diff -u -r1.7 SpyFormToolkit.java --- src/org/eclipse/pde/internal/runtime/spy/SpyFormToolkit.java 15 Nov 2007 20:12:36 -0000 1.7 +++ src/org/eclipse/pde/internal/runtime/spy/SpyFormToolkit.java 19 Nov 2007 13:42:17 -0000 @@ -19,9 +19,6 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ToolBarManager; import org.eclipse.osgi.util.NLS; -import org.eclipse.pde.internal.runtime.PDERuntimeMessages; -import org.eclipse.pde.internal.runtime.PDERuntimePlugin; -import org.eclipse.pde.internal.runtime.PDERuntimePluginImages; import org.eclipse.pde.internal.runtime.spy.dialogs.SpyDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; @@ -81,7 +78,7 @@ } public void run() { - FileDialog fileChooser = new FileDialog(PDERuntimePlugin.getActiveWorkbenchShell(), SWT.SAVE); + FileDialog fileChooser = new FileDialog(PDERuntimeSpyPlugin.getActiveWorkbenchShell(), SWT.SAVE); fileChooser.setFileName("image"); //$NON-NLS-1$ fileChooser.setFilterExtensions(new String[] { "*.png" }); //$NON-NLS-1$ fileChooser.setFilterNames(new String[] { "PNG (*.png)" }); //$NON-NLS-1$ @@ -123,7 +120,7 @@ public FormText createFormText(Composite parent, boolean trackFocus) { FormText text = super.createFormText(parent, trackFocus); - if (PDERuntimePlugin.HAS_IDE_BUNDLES) { + if (PDERuntimeSpyPlugin.HAS_IDE_BUNDLES) { text.addHyperlinkListener(new SpyHyperlinkAdapter(dialog)); } return text; @@ -140,7 +137,7 @@ createClassReference(buffer, clazzes[i]); buffer.append(""); //$NON-NLS-1$ } - Image image = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_INTERFACE_OBJ); + Image image = PDERuntimeSpyPluginImages.get(PDERuntimeSpyPluginImages.IMG_INTERFACE_OBJ); text.setImage("interface", image); //$NON-NLS-1$ } return buffer.toString(); @@ -157,7 +154,7 @@ createClassReference(buffer, clazzes[i]); buffer.append(""); //$NON-NLS-1$ } - Image image = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_CLASS_OBJ); + Image image = PDERuntimeSpyPluginImages.get(PDERuntimeSpyPluginImages.IMG_CLASS_OBJ); text.setImage("class", image); //$NON-NLS-1$ } return buffer.toString(); @@ -174,7 +171,7 @@ buffer.append(ids[i]); buffer.append(""); //$NON-NLS-1$ } - Image image = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_ID_OBJ); + Image image = PDERuntimeSpyPluginImages.get(PDERuntimeSpyPluginImages.IMG_ID_OBJ); text.setImage("id", image); //$NON-NLS-1$ } return buffer.toString(); @@ -202,7 +199,7 @@ private void createClassReference(StringBuffer buffer, Class clazz) { Bundle bundle = - PDERuntimePlugin.HAS_IDE_BUNDLES ? PDERuntimePlugin.getDefault().getPackageAdmin().getBundle(clazz) : null; + PDERuntimeSpyPlugin.HAS_IDE_BUNDLES ? PDERuntimeSpyPlugin.getDefault().getPackageAdmin().getBundle(clazz) : null; if (bundle != null) { bundleClassByName.put(clazz.getName(), bundle); @@ -222,10 +219,10 @@ .get(org.osgi.framework.Constants.BUNDLE_VERSION)); buffer.append("

    "); //$NON-NLS-1$ - buffer.append(PDERuntimeMessages.SpyDialog_contributingPluginId_title); + buffer.append(PDERuntimeSpyMessages.SpyDialog_contributingPluginId_title); buffer.append("

    "); //$NON-NLS-1$ buffer.append("
  • "); //$NON-NLS-1$ - if (PDERuntimePlugin.HAS_IDE_BUNDLES) { + if (PDERuntimeSpyPlugin.HAS_IDE_BUNDLES) { buffer.append(""); //$NON-NLS-1$ } buffer.append("
  • "); //$NON-NLS-1$ - Image pluginImage = PDERuntimePluginImages.get(PDERuntimePluginImages.IMG_PLUGIN_OBJ); + Image pluginImage = PDERuntimeSpyPluginImages.get(PDERuntimeSpyPluginImages.IMG_PLUGIN_OBJ); text.setImage("plugin", pluginImage); //$NON-NLS-1$ if (objectId != null) { buffer.append("

    "); //$NON-NLS-1$ - buffer.append(NLS.bind(PDERuntimeMessages.SpyDialog_contributingPluginId_desc, objectType)); + buffer.append(NLS.bind(PDERuntimeSpyMessages.SpyDialog_contributingPluginId_desc, objectType)); buffer.append("

    "); //$NON-NLS-1$ buffer.append("
  • "); //$NON-NLS-1$ buffer.append(objectId); @@ -291,8 +288,8 @@ return; ToolBarManager manager = createSectionToolbar(section); SaveImageAction action = new SaveImageAction(image); - action.setText(PDERuntimeMessages.SpyFormToolkit_saveImageAs_title); - action.setImageDescriptor(PDERuntimePluginImages.SAVE_IMAGE_AS_OBJ); + action.setText(PDERuntimeSpyMessages.SpyFormToolkit_saveImageAs_title); + action.setImageDescriptor(PDERuntimeSpyPluginImages.SAVE_IMAGE_AS_OBJ); manager.add(action); manager.update(true); } Index: src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyPluginImages.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyPluginImages.java diff -N src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyPluginImages.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyPluginImages.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,146 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.runtime.spy; + +import java.net.URL; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; + +public class PDERuntimeSpyPluginImages { + + private static ImageRegistry PLUGIN_REGISTRY; + + public final static String ICONS_PATH = "icons/"; //$NON-NLS-1$ + + private static final String PATH_OBJ = ICONS_PATH + "obj16/"; //$NON-NLS-1$ + private static final String PATH_DCL = ICONS_PATH + "dlcl16/"; //$NON-NLS-1$ + private static final String PATH_LCL = ICONS_PATH + "elcl16/"; //$NON-NLS-1$ + private static final String PATH_OVR = ICONS_PATH + "ovr16/"; //$NON-NLS-1$ + + // Plug-in Spy related images + public static final String IMG_CLASS_OBJ = "class_obj.gif"; //$NON-NLS-1$ + public static final String IMG_INTERFACE_OBJ = "int_obj.gif"; //$NON-NLS-1$ + public static final String IMG_PLUGIN_OBJ = "plugin_obj.gif"; //$NON-NLS-1$ + public static final String IMG_SPY_OBJ = "pdespy_obj.gif"; //$NON-NLS-1$ + public static final String IMG_MENU_OBJ = "menu_obj.gif"; //$NON-NLS-1$ + public static final String IMG_ID_OBJ = "generic_xml_obj.gif"; //$NON-NLS-1$ + public static final String IMG_MENUSPY_OBJ = "menuspy_obj.gif"; //$NON-NLS-1$ + public static final String IMG_CONTEXTID_OBJ = "contextid_obj.gif"; //$NON-NLS-1$ + public static final String IMG_SAVE_IMAGE_AS_OBJ = "save_image_as_obj.gif"; //$NON-NLS-1$ + + public static final ImageDescriptor CLASS_OBJ = + create(PATH_OBJ, IMG_CLASS_OBJ); + public static final ImageDescriptor INTERFACE_OBJ = + create(PATH_OBJ, IMG_INTERFACE_OBJ); + public static final ImageDescriptor PLUGIN_OBJ = + create(PATH_OBJ, IMG_PLUGIN_OBJ); + public static final ImageDescriptor SPY_OBJ = + create(PATH_OBJ, IMG_SPY_OBJ); + public static final ImageDescriptor MENU_OBJ = + create(PATH_OBJ, IMG_MENU_OBJ); + public static final ImageDescriptor ID_OBJ = + create(PATH_OBJ, IMG_ID_OBJ); + public static final ImageDescriptor MENUSPY_OBJ = + create(PATH_OBJ, IMG_MENUSPY_OBJ); + public static final ImageDescriptor CONTEXTID_OBJ = + create(PATH_OBJ, IMG_CONTEXTID_OBJ); + public static final ImageDescriptor SAVE_IMAGE_AS_OBJ = + create(PATH_OBJ, IMG_SAVE_IMAGE_AS_OBJ); + + public static final ImageDescriptor DESC_REFRESH_DISABLED = + create(PATH_DCL, "refresh.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_REFRESH = + create(PATH_LCL, "refresh.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_COLLAPSE_ALL = + create(PATH_LCL, "collapseall.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_ERROR_ST_OBJ = + create(PATH_OBJ, "error_st_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_ERROR_STACK_OBJ = + create(PATH_OBJ, "error_stack.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_EXT_POINT_OBJ = + create(PATH_OBJ, "ext_point_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_EXT_POINTS_OBJ = + create(PATH_OBJ, "ext_points_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_EXTENSION_OBJ = + create(PATH_OBJ, "extension_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_EXTENSIONS_OBJ = + create(PATH_OBJ, "extensions_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_GENERIC_XML_OBJ = + create(PATH_OBJ, "generic_xml_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_ATTR_XML_OBJ = + create(PATH_OBJ, "attr_xml_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_INFO_ST_OBJ = + create(PATH_OBJ, "info_st_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_JAVA_LIB_OBJ = + create(PATH_OBJ, "java_lib_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_NATIVE_LIB_OBJ = + create(PATH_OBJ, "native_lib_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_OK_ST_OBJ = + create(PATH_OBJ, "ok_st_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_PLUGIN_OBJ = + create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_REQ_PLUGIN_OBJ = + create(PATH_OBJ, "req_plugin_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_REQ_PLUGINS_OBJ = + create(PATH_OBJ, "req_plugins_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_RUNTIME_OBJ = + create(PATH_OBJ, "runtime_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_WARNING_ST_OBJ = + create(PATH_OBJ, "warning_st_obj.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_LOCATION = + create(PATH_OBJ, "location_obj.gif"); //$NON-NLS-1$ + + /* + * Overlays + */ + public static final ImageDescriptor DESC_RUN_CO = + create(PATH_OVR, "run_co.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_EXPORT_CO = + create(PATH_OVR, "export_co.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_ERROR_CO = + create(PATH_OVR, "error_co.gif"); //$NON-NLS-1$ + + private static final void initialize() { + PLUGIN_REGISTRY = PDERuntimeSpyPlugin.getDefault().getImageRegistry(); + manage(IMG_CLASS_OBJ, CLASS_OBJ); + manage(IMG_INTERFACE_OBJ, INTERFACE_OBJ); + manage(IMG_PLUGIN_OBJ, PLUGIN_OBJ); + manage(IMG_SPY_OBJ, SPY_OBJ); + manage(IMG_MENU_OBJ, MENU_OBJ); + manage(IMG_ID_OBJ, ID_OBJ); + manage(IMG_MENUSPY_OBJ, MENUSPY_OBJ); + manage(IMG_CONTEXTID_OBJ, CONTEXTID_OBJ); + manage(IMG_SAVE_IMAGE_AS_OBJ, SAVE_IMAGE_AS_OBJ); + } + + private static ImageDescriptor create(String prefix, String name) { + return ImageDescriptor.createFromURL(makeIconURL(prefix, name)); + } + + public static Image get(String key) { + if (PLUGIN_REGISTRY==null) initialize(); + return PLUGIN_REGISTRY.get(key); + } + private static URL makeIconURL(String prefix, String name) { + String path = "$nl$/" + prefix + name; //$NON-NLS-1$ + return FileLocator.find(PDERuntimeSpyPlugin.getDefault().getBundle(), new Path(path), null); + } + public static Image manage(String key, ImageDescriptor desc) { + Image image = desc.createImage(); + PLUGIN_REGISTRY.put(key, image); + return image; + } + +} Index: src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyMessages.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyMessages.java diff -N src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyMessages.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyMessages.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2005, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.runtime.spy; + +import org.eclipse.osgi.util.NLS; + +public class PDERuntimeSpyMessages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.pde.internal.runtime.spy.pderuntimespyresources";//$NON-NLS-1$ + + public static String SpyDialog_title; + public static String SpyDialog_activeShell_title; + public static String SpyDialog_activeShell_desc; + public static String SpyDialog_activePart_title; + public static String SpyDialog_activePart_desc; + public static String SpyDialog_activeWizard_title; + public static String SpyDialog_activeWizard_desc; + public static String SpyDialog_activeMenuIds; + public static String SpyDialog_contributingPluginId_title; + public static String SpyDialog_contributingPluginId_desc; + public static String SpyDialog_activeSelection_title; + public static String SpyDialog_activeSelection_desc; + public static String SpyDialog_activeSelectionInterfaces_desc; + public static String SpyDialog_activeDialogPageSection_title; + public static String SpyDialog_activeDialogPageSection_title2; + public static String SpyDialog_activeDialogPageSection_desc; + public static String SpyDialog_activeHelpSection_title; + + public static String SpyFormToolkit_saveImageAs_title; + + public static String SpyIDEUtil_createProjectTaskName; + + static { + // load message values from bundle file + NLS.initializeMessages(BUNDLE_NAME, PDERuntimeSpyMessages.class); + } + +} Index: src/org/eclipse/pde/internal/runtime/spy/pderuntimespyresources.properties =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/spy/pderuntimespyresources.properties diff -N src/org/eclipse/pde/internal/runtime/spy/pderuntimespyresources.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/runtime/spy/pderuntimespyresources.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,35 @@ +############################################################################### +# Copyright (c) 2000, 2007 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +# +# PDE Runtime Spy resources +# + +SpyDialog_title = Plug-in Spy +SpyDialog_activeShell_title = Active Shell +SpyDialog_activeShell_desc = The active shell class: +SpyDialog_activeWizard_title = Active Wizard ({0}) +SpyDialog_activeWizard_desc = The active wizard class: +SpyDialog_activePart_title = Active Part ({0}) +SpyDialog_activePart_desc = The active {0} class: +SpyDialog_activeMenuIds = The active menu contribution identifiers: +SpyDialog_contributingPluginId_title = The contributing plug-in: +SpyDialog_contributingPluginId_desc = The active {0} identifier: +SpyDialog_activeSelection_title = Active Selection +SpyDialog_activeSelection_desc = The selection class: +SpyDialog_activeSelectionInterfaces_desc = The interfaces valid for the selection: +SpyDialog_activeDialogPageSection_title = Active Page ({0}) +SpyDialog_activeDialogPageSection_title2 = Active Page +SpyDialog_activeDialogPageSection_desc = The active page class: +SpyDialog_activeHelpSection_title = Active Help Context Identifiers + +SpyFormToolkit_saveImageAs_title = Save Image As... + +SpyIDEUtil_createProjectTaskName=Creating {0} project Index: src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyPlugin.java =================================================================== RCS file: src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyPlugin.java diff -N src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyPlugin.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/runtime/spy/PDERuntimeSpyPlugin.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,155 @@ +/******************************************************************************* + * Copyright (c) 2000, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.runtime.spy; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.osgi.service.resolver.PlatformAdmin; +import org.eclipse.osgi.service.resolver.State; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.service.packageadmin.PackageAdmin; +import org.osgi.util.tracker.ServiceTracker; + +public class PDERuntimeSpyPlugin extends AbstractUIPlugin { + + public static final String ID = "org.eclipse.pde.runtime.spy"; //$NON-NLS-1$ + + private static PDERuntimeSpyPlugin inst; + private BundleContext fContext; + private ServiceTracker packageAdminTracker; + private ServiceTracker platformAdminTracker; + + private static boolean isBundleAvailable(String bundleID) { + Bundle bundle = Platform.getBundle(bundleID); + return bundle != null + && (bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.RESOLVED)) != 0; + } + + public static final boolean HAS_IDE_BUNDLES; + static { + boolean result = false; + try { + result = isBundleAvailable("org.eclipse.core.resources") //$NON-NLS-1$ + && isBundleAvailable("org.eclipse.pde.core") //$NON-NLS-1$ + && isBundleAvailable("org.eclipse.jdt.core") //$NON-NLS-1$ + && isBundleAvailable("org.eclipse.help") //$NON-NLS-1$ + && isBundleAvailable("org.eclipse.jdt.ui"); //$NON-NLS-1$ + } catch (Throwable exception) {} + HAS_IDE_BUNDLES = result; + } + + public static IWorkbenchPage getActivePage() { + return getDefault().internalGetActivePage(); + } + + public static Shell getActiveWorkbenchShell() { + return getActiveWorkbenchWindow().getShell(); + } + + public static IWorkbenchWindow getActiveWorkbenchWindow() { + return getDefault().getWorkbench().getActiveWorkbenchWindow(); + } + + public PackageAdmin getPackageAdmin() { + if (packageAdminTracker == null) { + return null; + } + return (PackageAdmin) packageAdminTracker.getService(); + } + + public PlatformAdmin getPlatformAdmin() { + if (platformAdminTracker == null) { + return null; + } + return (PlatformAdmin) platformAdminTracker.getService(); + } + + public static PDERuntimeSpyPlugin getDefault() { + return inst; + } + + public static String getPluginId() { + return getDefault().getBundle().getSymbolicName(); + } + + public PDERuntimeSpyPlugin() { + inst = this; + } + + private IWorkbenchPage internalGetActivePage() { + return getWorkbench().getActiveWorkbenchWindow().getActivePage(); + } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + this.fContext = context; + + packageAdminTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null); + packageAdminTracker.open(); + + platformAdminTracker = new ServiceTracker(context, PlatformAdmin.class.getName(), null); + platformAdminTracker.open(); + } + + public BundleContext getBundleContext() { + return this.fContext; + } + + public State getState() { + return getPlatformAdmin().getState(false); + } + + public static void log(Throwable e) { + if (e instanceof InvocationTargetException) + e = ((InvocationTargetException) e).getTargetException(); + IStatus status = null; + if (e instanceof CoreException) { + status = ((CoreException) e).getStatus(); + } else if (e.getMessage() != null) { + status = new Status( + IStatus.ERROR, + ID, + IStatus.OK, + e.getMessage(), + e); + } + if(status != null) + getDefault().getLog().log(status); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + if (packageAdminTracker != null) { + packageAdminTracker.close(); + packageAdminTracker = null; + } + if (platformAdminTracker != null) { + platformAdminTracker.close(); + platformAdminTracker = null; + } + inst = null; + } + +}