Fixed Beaninfo so containers can be used in the search path. I.E. you can select packages from a container that is in your classpath and have those packages on your classpath. NOTE: This is not the same as have containers ADDED to the beaninfo classpath. That is not yet supported.
diff --git a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoEntry.java b/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoEntry.java index 444c20b..f5958e4 100644 --- a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoEntry.java +++ b/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoEntry.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: BeaninfoEntry.java,v $ - * $Revision: 1.1 $ $Date: 2003/10/27 17:17:59 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:00 $ */ import java.util.ArrayList; @@ -32,6 +32,12 @@ /** * Beaninfo entry. Location of the beaninfos. Much like a standard classpath entry. + * The BeanInfos are either in a jar or another project. They can be supplied as + * a local file in the project, or as an external jar, or as external jar through a + * variable, or an external jar through a plugin. + * <p> + * An external jar through containers is not valid because container are attached to + * projects. they aren't standalone. * * @version 1.0 * @author @@ -43,7 +49,10 @@ public static final int BIE_PLUGIN = 100; // Beaninfo jar can be found in a plugin. static int kindFromString(String kindStr) { - + if (kindStr == null) + return -1; + if (kindStr.equalsIgnoreCase("con")) + return IClasspathEntry.CPE_CONTAINER; if (kindStr.equalsIgnoreCase("var")) //$NON-NLS-1$ return IClasspathEntry.CPE_VARIABLE; if (kindStr.equalsIgnoreCase("src")) //$NON-NLS-1$ @@ -66,6 +75,8 @@ return "lib"; //$NON-NLS-1$ case IClasspathEntry.CPE_VARIABLE : return "var"; //$NON-NLS-1$ + case IClasspathEntry.CPE_CONTAINER: + return "con"; case BIE_PLUGIN: return "plugin"; //$NON-NLS-1$ default : @@ -100,6 +111,7 @@ case IClasspathEntry.CPE_VARIABLE : return JavaCore.newVariableEntry(path, null, null, isExported); + } return null; @@ -113,7 +125,7 @@ // ensure path is absolute IPath path = new Path(pathStr); int kind = kindFromString(elementKind); - if (kind != IClasspathEntry.CPE_VARIABLE && kind != BIE_PLUGIN && !path.isAbsolute()) { + if (kind != IClasspathEntry.CPE_VARIABLE && kind != IClasspathEntry.CPE_CONTAINER && kind != BIE_PLUGIN && !path.isAbsolute()) { path = project != null ? project.getFullPath().append(path) : path.makeAbsolute(); // Some folder/jar within this project } @@ -213,7 +225,7 @@ if (entry != null) { element.setAttribute(BeaninfosDoc.sKind, kindToString(entry.getEntryKind())); path = entry.getPath(); - if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) { + if (entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE && entry.getEntryKind() != IClasspathEntry.CPE_CONTAINER) { // translate to project relative from absolute (unless a device path) if (path.isAbsolute()) { if (path.segment(0).equals(project.getFullPath().segment(0))) {
diff --git a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoNature.java b/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoNature.java index e23183d..7aac844 100644 --- a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoNature.java +++ b/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoNature.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: BeaninfoNature.java,v $ - * $Revision: 1.8 $ $Date: 2004/03/06 18:38:37 $ + * $Revision: 1.9 $ $Date: 2004/03/08 00:48:00 $ */ import java.io.*; @@ -348,64 +348,7 @@ Utilities.setBeanInfoSearchPath(registry, null); } - /* - * Get the search path in the old format. - */ - private BeaninfoSearchPathEntry[] getOldFormatSearchPath(Element root) { - NodeList children = root.getChildNodes(); - int childrenLength = children.getLength(); - ArrayList childrenList = new ArrayList(childrenLength); - for (int i = 0; i < childrenLength; i++) { - Node child = children.item(i); - BeaninfoSearchPathEntry bentry = BeaninfoSearchPathEntry.readEntry(child); - if (bentry != null) - childrenList.add(bentry); - } - return (BeaninfoSearchPathEntry[]) childrenList.toArray(new BeaninfoSearchPathEntry[childrenList.size()]); - } - - /* - * Convert the old format to new format. - */ - private BeaninfosDoc convertOldFormatSearchPath(Element root) { - BeaninfoSearchPathEntry[] entries = getOldFormatSearchPath(root); - - try { - IJavaProject jp = JavaCore.create(getProject()); - IClasspathEntry[] cpEntries = jp.getRawClasspath(); - HashMap resolvedEntries = new HashMap(cpEntries.length); - for (int i = 0; i < cpEntries.length; i++) { - IClasspathEntry resolved = JavaCore.getResolvedClasspathEntry(cpEntries[i]); - if (resolved != null) - resolvedEntries.put(resolved.getPath(), new Integer(i)); - } - - List newentries = new ArrayList(entries.length); - for (int i = 0; i < entries.length; i++) { - IPath pkgPath = new Path(entries[i].getPackageName().replace('.', '/')); - try { - IPackageFragment frag = (IPackageFragment) jp.findElement(pkgPath); // Find the first match - if (frag != null) { - IPackageFragmentRoot froot = (IPackageFragmentRoot) frag.getParent(); - Integer index = (Integer) resolvedEntries.get(froot.getPath()); - if (index != null) { - IClasspathEntry cpe = cpEntries[index.intValue()]; - newentries.add(new SearchpathEntry(cpe.getEntryKind(), cpe.getPath(), frag.getElementName())); - } - } - } catch (ClassCastException e) { - // It didn't find a IPackageFragment, it should of, so skip this entry. - } - } - return new BeaninfosDoc((IBeaninfosDocEntry[]) newentries.toArray(new IBeaninfosDocEntry[newentries.size()])); - } catch (JavaModelException e) { - } - return null; - } - private static final String ENCODING = "UTF-8"; //$NON-NLS-1$ - private static final String sSearchPathElementName = "searchPath"; //$NON-NLS-1$ - // Old format root element name (WSAD 4.0.0) static final String sBeaninfos = "beaninfos"; // Root element name //$NON-NLS-1$ /** * Get the persistent search path. The object returned is a copy of the @@ -422,12 +365,7 @@ DocumentBuilderFactoryImpl bldrFactory = new DocumentBuilderFactoryImpl(); Document doc = bldrFactory.newDocumentBuilder().parse(new InputSource(new InputStreamReader(property, ENCODING))); Element root = doc.getDocumentElement(); - if (root != null && root.getNodeName().equalsIgnoreCase(sSearchPathElementName)) { - // Old format. Need to convert to new format. - bdoc = convertOldFormatSearchPath(root); - setSearchPath(bdoc); // Now put out the converted format. - } else if (root != null && root.getNodeName().equalsIgnoreCase(sBeaninfos)) { - // New format + if (root != null && root.getNodeName().equalsIgnoreCase(sBeaninfos)) { bdoc = BeaninfosDoc.readEntry(new DOMReader(), root, getProject()); } } finally {
diff --git a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoSearchPathEntry.java b/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoSearchPathEntry.java deleted file mode 100644 index 550cc0b..0000000 --- a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/BeaninfoSearchPathEntry.java +++ /dev/null
@@ -1,83 +0,0 @@ -package org.eclipse.jem.internal.beaninfo.adapters; -/******************************************************************************* - * Copyright (c) 2001, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -/* - * $RCSfile: BeaninfoSearchPathEntry.java,v $ - * $Revision: 1.1 $ $Date: 2003/10/27 17:17:59 $ - */ - - -import org.w3c.dom.*; -/** - * Entry of search path for beaninfo. - * *package* because it is for old format and should not be used outside of this package. - */ - -class BeaninfoSearchPathEntry { - protected String fPackageName; // Name of package that this entry references - - /** - * packageName. - */ - public BeaninfoSearchPathEntry(String packageName) { - fPackageName = packageName; - } - - public String getPackageName() { - return fPackageName; - } - - /** - * package protected so that only BeaninfoNature can call it. This is the - * old format which is no longer being used. It is here to allow conversion - * from Beta to GA. - */ - private static final String sSearchPathEntryElementName = "pathEntry"; //$NON-NLS-1$ - private static final String sPackageElementName = "package"; //$NON-NLS-1$ - static BeaninfoSearchPathEntry readOldEntry(Node node) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element beElement= (Element) node; - if (beElement.getNodeName().equalsIgnoreCase(sSearchPathEntryElementName)) { - String pkgName = beElement.getAttribute(sPackageElementName); - return new BeaninfoSearchPathEntry(pkgName); - } - } - return null; - } - - public static BeaninfoSearchPathEntry readEntry(Node node) { - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element beElement= (Element) node; - if (beElement.getNodeName().equalsIgnoreCase(sSearchPathEntryElementName)) { - String pkgName = beElement.getAttribute(sPackageElementName); - return new BeaninfoSearchPathEntry(pkgName); - } - } - return null; - } - - public Element writeEntry(Document doc) { - Element entry = doc.createElement(sSearchPathEntryElementName); // Create entry - entry.setAttribute(sPackageElementName, getPackageName()); // Set the package name - return entry; - } - - public boolean equals(Object other) { - if (this == other) - return true; - - if (!(other instanceof BeaninfoSearchPathEntry)) - return false; - - BeaninfoSearchPathEntry otherEntry = (BeaninfoSearchPathEntry) other; - return (fPackageName.equals(otherEntry.fPackageName)); - } -} \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/DOMReader.java b/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/DOMReader.java index 9dfc1ed..9368770 100644 --- a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/DOMReader.java +++ b/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/DOMReader.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: DOMReader.java,v $ - * $Revision: 1.1 $ $Date: 2003/10/27 17:17:59 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:00 $ */ import org.w3c.dom.Element; @@ -65,7 +65,7 @@ * @see IReader#getAttribute(Object, String) */ public String getAttribute(Object element, String attributeName) { - return (element instanceof Element) ? ((Element) element).getAttribute(attributeName) : null; + return (element instanceof Element) && ((Element) element).hasAttribute(attributeName) ? ((Element) element).getAttribute(attributeName) : null; } } \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/SearchpathEntry.java b/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/SearchpathEntry.java index a511739..579fc53 100644 --- a/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/SearchpathEntry.java +++ b/plugins/org.eclipse.jem.beaninfo/beaninfo/org/eclipse/jem/internal/beaninfo/adapters/SearchpathEntry.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: SearchpathEntry.java,v $ - * $Revision: 1.1 $ $Date: 2003/10/27 17:17:59 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:00 $ */ import org.eclipse.core.resources.IProject; @@ -24,6 +24,9 @@ * Searchpath entry. Beaninfo searchpath entry (i.e. package name). Can include * kind/path/exported if not a child of the BeaninfoEntry. * + * Note: if not a child of a BeanInfoEntry, then the path refers to a package + * in the classpath, so container is supported here. + * * @version 1.0 * @author */ @@ -42,11 +45,14 @@ String elementKind = reader.getAttribute(element, BeaninfosDoc.sKind); String pathStr = reader.getAttribute(element, BeaninfosDoc.sPath); - // ensure path is absolute - IPath path = new Path(pathStr); - int kind = BeaninfoEntry.kindFromString(elementKind); - if (kind != IClasspathEntry.CPE_VARIABLE && !path.isAbsolute()) { - path = project != null ? project.getFullPath().append(path) : path.makeAbsolute(); // Some folder/jar within this project + int kind = BeaninfoEntry.kindFromString(elementKind); + IPath path = null; + if (pathStr != null) { + // ensure path is absolute + path = new Path(pathStr); + if (kind != IClasspathEntry.CPE_VARIABLE && kind != IClasspathEntry.CPE_CONTAINER && !path.isAbsolute()) { + path = project != null ? project.getFullPath().append(path) : path.makeAbsolute(); // Some folder/jar within this project + } } // create the appropriate entry @@ -54,11 +60,13 @@ switch (kind) { case IClasspathEntry.CPE_LIBRARY : - valid = path.isAbsolute(); + valid = path != null && path.isAbsolute(); break; case IClasspathEntry.CPE_SOURCE : - if (path.isAbsolute()) { + if (path == null) + valid = false; + else if (path.isAbsolute()) { // must be an entry in this project or specify another project String projSegment = path.segment(0); if (project == null || projSegment == null || !projSegment.equals(project.getName())) { @@ -69,6 +77,7 @@ break; case IClasspathEntry.CPE_VARIABLE : + case IClasspathEntry.CPE_CONTAINER: break; default : @@ -117,7 +126,7 @@ // A non-beaninfo child element.setAttribute(BeaninfosDoc.sKind, BeaninfoEntry.kindToString(kind)); IPath tPath = path; - if (kind != IClasspathEntry.CPE_VARIABLE) { + if (kind != IClasspathEntry.CPE_VARIABLE && kind != IClasspathEntry.CPE_CONTAINER) { // translate to project relative from absolute (unless a device path) if (tPath.isAbsolute()) { if (tPath.segment(0).equals(project.getFullPath().segment(0))) {
diff --git a/plugins/org.eclipse.jem.ui/.project b/plugins/org.eclipse.jem.ui/.project index 894fce4..51c31b7 100644 --- a/plugins/org.eclipse.jem.ui/.project +++ b/plugins/org.eclipse.jem.ui/.project
@@ -14,6 +14,7 @@ <project>org.eclipse.jdt.ui</project> <project>org.eclipse.jem.beaninfo</project> <project>org.eclipse.jem.proxy</project> + <project>org.eclipse.jem.workbench</project> <project>org.eclipse.ui</project> <project>org.eclipse.ui.ide</project> </projects>
diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BIListElementSorter.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BIListElementSorter.java index d4cfc0a..fbdbd74 100644 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BIListElementSorter.java +++ b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BIListElementSorter.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: BIListElementSorter.java,v $ - * $Revision: 1.1 $ $Date: 2004/03/04 16:14:29 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:07 $ */ import org.eclipse.jdt.core.IClasspathEntry; @@ -37,15 +37,17 @@ switch (((BeaninfoEntry) element.getEntry()).getKind()) { case IClasspathEntry.CPE_LIBRARY: - return 3; + return 4; case IClasspathEntry.CPE_PROJECT: return 1; case IClasspathEntry.CPE_SOURCE: return 0; case IClasspathEntry.CPE_VARIABLE: - return 2; + return 3; case BeaninfoEntry.BIE_PLUGIN: - return 4; + return 5; + case IClasspathEntry.CPE_CONTAINER: + return 2; } } return super.category(obj);
diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoEntrySearchpathDialog.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoEntrySearchpathDialog.java index bdb7f2e..54244f9 100644 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoEntrySearchpathDialog.java +++ b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoEntrySearchpathDialog.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: BeaninfoEntrySearchpathDialog.java,v $ - * $Revision: 1.1 $ $Date: 2004/03/04 16:14:29 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:07 $ */ import java.text.MessageFormat; @@ -113,7 +113,7 @@ /* 5 */ BeanInfoUIMessages.getString("SearchPathDialog.Remove") }; //$NON-NLS-1$ - listField = new ListDialogField(adapter, buttonLabels, new SearchPathListLabelProvider()); + listField = new ListDialogField(adapter, buttonLabels, new SearchPathListLabelProvider(jProject)); listField.setLabelText(BeanInfoUIMessages.getString("SearchPathDialog.Desc.Label")); //$NON-NLS-1$ listField.setUpButtonIndex(0); listField.setDownButtonIndex(1);
diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoPathsBlock.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoPathsBlock.java index 7e38a2e..dfb865a 100644 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoPathsBlock.java +++ b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfoPathsBlock.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: BeaninfoPathsBlock.java,v $ - * $Revision: 1.1 $ $Date: 2004/03/04 16:14:29 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:07 $ */ import java.io.File; @@ -63,7 +63,8 @@ private BeaninfosWorkbookPage fBeaninfosPage; private BuildSearchBasePage fCurrPage; - + private SearchPathListLabelProvider labelProvider; + public BeaninfoPathsBlock(IWorkspaceRoot root, IStatusChangeListener context) { fWorkspaceRoot = root; fContext = context; @@ -81,7 +82,8 @@ /* 4 */ BeanInfoUIMessages.getString("BeanInfoPathsBlock.UnexportAll") //$NON-NLS-1$ }; - fSearchOrder = new CheckedListDialogField(null, buttonLabels, new SearchPathListLabelProvider()); + labelProvider = new SearchPathListLabelProvider(); // We keep around to update with latest project. + fSearchOrder = new CheckedListDialogField(null, buttonLabels, labelProvider); fSearchOrder.setDialogFieldListener(adapter); fSearchOrder.setLabelText( BeanInfoUIMessages.getString(BeanInfoUIMessages.BPB_SEARCHPATH_LABEL)); @@ -209,6 +211,7 @@ */ public void init(IJavaProject jproject) { fCurrJProject = jproject; + labelProvider.setJavaProject(jproject); try { // If we have a config file, we will assume we have a nature. It will add it automatically @@ -297,6 +300,7 @@ fEnableBeaninfoDialogField.setSelection(false); } +// listenForClasspathChange(); doStatusLineUpdate(); } @@ -556,5 +560,5 @@ } fCurrPage = newPage; } - } + } } \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosPropertyPage.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosPropertyPage.java index 3a29132..d1a2740 100644 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosPropertyPage.java +++ b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosPropertyPage.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: BeaninfosPropertyPage.java,v $ - * $Revision: 1.1 $ $Date: 2004/03/04 16:14:29 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:07 $ */ import java.lang.reflect.InvocationTargetException; @@ -37,6 +37,8 @@ public class BeaninfosPropertyPage extends PropertyPage implements IStatusChangeListener { private BeaninfoPathsBlock fBuildPathsBlock; + private IResourceChangeListener listener; + private IProject project; /* * @see PreferencePage#createControl(Composite) @@ -48,23 +50,43 @@ // ensure the page has no special buttons noDefaultAndApplyButton(); - IProject project= getProject(); + project= getProject(); if (project == null || !isJavaProject(project)) { return createWithoutJava(parent); } else if (!project.isOpen()) { return createForClosedProject(parent); } else { - return createWithJava(parent, project); + return createWithJava(parent); } } /** * Content for valid projects. */ - private Control createWithJava(Composite parent, IProject project) { + private Control createWithJava(Composite parent) { IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); fBuildPathsBlock= new BeaninfoPathsBlock(root, this); - fBuildPathsBlock.init(JavaCore.create(project)); + final IJavaProject jproject = JavaCore.create(project); + fBuildPathsBlock.init(jproject); + final IPath classpathfile = project.getFile(".classpath").getFullPath(); + listener = new IResourceChangeListener() { + + /* (non-Javadoc) + * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) + */ + public void resourceChanged(IResourceChangeEvent event) { + if (fBuildPathsBlock != null) { + if (event.getDelta().findMember(classpathfile) != null) + getControl().getDisplay().asyncExec(new Runnable() { // Can be called outside of display loop + public void run() { + fBuildPathsBlock.init(jproject); + } + }); + } + } + }; + project.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.POST_CHANGE); + return fBuildPathsBlock.createControl(parent); } @@ -144,4 +166,14 @@ StatusUtil.applyToStatusLine(this, status); } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.IDialogPage#dispose() + */ + public void dispose() { + if (listener != null) + project.getWorkspace().removeResourceChangeListener(listener); + listener = null; + super.dispose(); + } } \ No newline at end of file
diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosWorkbookPage.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosWorkbookPage.java index db55adb..100251d 100644 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosWorkbookPage.java +++ b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/BeaninfosWorkbookPage.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: BeaninfosWorkbookPage.java,v $ - * $Revision: 1.1 $ $Date: 2004/03/04 16:14:29 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:07 $ */ import java.util.*; @@ -57,6 +57,7 @@ private IClasspathEntry[] resolvedList; private IClasspathEntry[] rawList; + private SearchPathListLabelProvider labelProvider; private static final String DIALOGSTORE_LASTEXTJAR = JEMUIPlugin.PI_BEANINFO_UI + ".lastextjar"; //$NON-NLS-1$ private static final String DIALOGSTORE_LASTVARIABLE = JEMUIPlugin.PI_BEANINFO_UI + ".lastvar"; //$NON-NLS-1$ @@ -82,7 +83,8 @@ BeaninfosAdapter adapter= new BeaninfosAdapter(); - fBeaninfosList= new ListDialogField(adapter, buttonLabels, new SearchPathListLabelProvider()); + labelProvider = new SearchPathListLabelProvider(); // kept around so can be updated with java project later + fBeaninfosList= new ListDialogField(adapter, buttonLabels, labelProvider); fBeaninfosList.setDialogFieldListener(adapter); fBeaninfosList.setLabelText(BeanInfoUIMessages.getString("BeanInfosWorkbookPage.List.Text")); //$NON-NLS-1$ fBeaninfosList.setRemoveButtonIndex(8); @@ -96,6 +98,7 @@ public void init(IJavaProject jproject) { fCurrJProject= jproject; + labelProvider.setJavaProject(jproject); try { rawList = fCurrJProject.getRawClasspath(); resolvedList = new IClasspathEntry[rawList.length];
diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackagesWorkbookPage.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackagesWorkbookPage.java index b0d6ca8..f920400 100644 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackagesWorkbookPage.java +++ b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/PackagesWorkbookPage.java
@@ -11,14 +11,13 @@ *******************************************************************************/ /* * $RCSfile: PackagesWorkbookPage.java,v $ - * $Revision: 1.1 $ $Date: 2004/03/04 16:14:29 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:07 $ */ import java.util.*; import java.util.List; import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.core.*; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; @@ -90,8 +89,10 @@ private ListDialogField fSearchPackagesList; - private IClasspathEntry[] resolvedList; + private IPackageFragmentRoot[][] rootsPerRawEntry; private IClasspathEntry[] rawList; + + SearchPathListLabelProvider labelProvider; public PackagesWorkbookPage(IWorkspaceRoot root, BeaninfoPathsBlock biPathsBlock, List interestedFieldsForEnableControl) { this.biPathsBlock = biPathsBlock; @@ -112,7 +113,8 @@ /* 3 */ BeanInfoUIMessages.getString("PackagesWorkbook.Remove") }; //$NON-NLS-1$ - fSearchPackagesList = new ListDialogField(adapter, buttonLabels, new SearchPathListLabelProvider()); + labelProvider = new SearchPathListLabelProvider(); + fSearchPackagesList = new ListDialogField(adapter, buttonLabels, labelProvider); fSearchPackagesList.setDialogFieldListener(adapter); fSearchPackagesList.setLabelText(BeanInfoUIMessages.getString("PackagesWorkbook.LabelText")); //$NON-NLS-1$ fSearchPackagesList.setRemoveButtonIndex(3); @@ -124,11 +126,16 @@ public void init(IJavaProject jproject) { fCurrJProject = jproject; + labelProvider.setJavaProject(jproject); try { rawList = fCurrJProject.getRawClasspath(); - resolvedList = fCurrJProject.getResolvedClasspath(true); + rootsPerRawEntry = new IPackageFragmentRoot[rawList.length][]; + for (int i = 0; i < rawList.length; i++) { + rootsPerRawEntry[i] = fCurrJProject.findPackageFragmentRoots(rawList[i]); + } } catch (JavaModelException e) { - rawList = resolvedList = new IClasspathEntry[0]; + rawList = new IClasspathEntry[0]; + rootsPerRawEntry = new IPackageFragmentRoot[0][]; } updatePackagesList(); } @@ -345,12 +352,12 @@ */ private List chooseDefined() { - // Current pre-defined ones are only pre-reqed projects. Registered vars will be added later. + // Current pre-defined ones are only pre-reqed projects. // The list of inputs will not contain any already in the path. // We will create them here and if not selected they will thrown away. // The assumption is that there are not very many and our SearchPathListLabelProvider does // a good job of showing them. Otherwise we would need to come up with one that can show - // IJavaProjects and Registered vars when we get them. + // IJavaProjects when we get them. List inputs = new ArrayList(); List currentList = fSearchPackagesList.getElements(); for (int i = 0; i < rawList.length; i++) { @@ -369,9 +376,9 @@ } } - ILabelProvider labelProvider = new SearchPathListLabelProvider(); + ILabelProvider labelProvider1 = new SearchPathListLabelProvider(fCurrJProject); ElementListSelectionDialog dialog = - new ElementListSelectionDialog(getShell(), labelProvider); + new ElementListSelectionDialog(getShell(), labelProvider1); dialog.setTitle(BeanInfoUIMessages.getString("PackagesWorkbook.SelectionDialog.DefinedPaths.Title")); //$NON-NLS-1$ dialog.setMessage(BeanInfoUIMessages.getString("PackagesWorkbook.SelectionDialog.DefinedPaths.Message")); //$NON-NLS-1$ @@ -391,12 +398,14 @@ boolean isExported = false; IPackageFragment frag = (IPackageFragment) element; // Need to find corresponding raw class path entry. - IPath path = ((IPackageFragmentRoot) frag.getParent()).getPath(); // Get frag root path. - for (int i = 0; i < resolvedList.length; i++) { - if (resolvedList[i] != null && path.equals(resolvedList[i].getPath())) { - isExported = rawList[i].isExported() || rawList[i].getEntryKind() == IClasspathEntry.CPE_SOURCE; - se = new SearchpathEntry(rawList[i].getEntryKind(), rawList[i].getPath(), frag.getElementName()); - break; + IPackageFragmentRoot root = (IPackageFragmentRoot) frag.getParent(); // Get frag root. + for (int i = 0; i < rootsPerRawEntry.length; i++) { + for (int j = 0; j < rootsPerRawEntry[i].length; j++) { + if (rootsPerRawEntry[i][j].equals(root)) { + isExported = rawList[i].isExported() || rawList[i].getEntryKind() == IClasspathEntry.CPE_SOURCE; + se = new SearchpathEntry(rawList[i].getEntryKind(), rawList[i].getPath(), frag.getElementName()); + break; + } } }
diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SPListElementSorter.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SPListElementSorter.java index ccf1bdc..bb7bc4d 100644 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SPListElementSorter.java +++ b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SPListElementSorter.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: SPListElementSorter.java,v $ - * $Revision: 1.1 $ $Date: 2004/03/04 16:14:29 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:07 $ */ import org.eclipse.jdt.core.IClasspathEntry; @@ -38,12 +38,14 @@ switch (((SearchpathEntry) element.getEntry()).getKind()) { case IClasspathEntry.CPE_LIBRARY: - return 3; + return 4; case IClasspathEntry.CPE_PROJECT: return 1; case IClasspathEntry.CPE_SOURCE: return 0; case IClasspathEntry.CPE_VARIABLE: + return 3; + case IClasspathEntry.CPE_CONTAINER: return 2; } }
diff --git a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchPathListLabelProvider.java b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchPathListLabelProvider.java index e903ea2..ad37cc1 100644 --- a/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchPathListLabelProvider.java +++ b/plugins/org.eclipse.jem.ui/beaninfoui/org/eclipse/jem/internal/beaninfo/ui/SearchPathListLabelProvider.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: SearchPathListLabelProvider.java,v $ - * $Revision: 1.1 $ $Date: 2004/03/04 16:14:29 $ + * $Revision: 1.2 $ $Date: 2004/03/08 00:48:07 $ */ import java.net.MalformedURLException; @@ -22,15 +22,19 @@ import org.eclipse.core.resources.*; import org.eclipse.core.runtime.IPath; +import org.eclipse.jdt.core.*; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.wizards.buildpaths.ArchiveFileFilter; +import org.eclipse.jdt.ui.JavaElementImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.*; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.internal.misc.OverlayComposite; @@ -41,11 +45,12 @@ public class SearchPathListLabelProvider extends LabelProvider { IWorkspaceRoot fRoot; + IJavaProject javaProject; // Shared images private Image fJarIcon, fExtJarIcon; - private Image fFolderImage, fProjectImage, fVariableImage; - private Image fMissingLibaryImage, fMissingVariableImage; + private Image fFolderImage, fProjectImage, fVariableImage, fLibraryImage; + private Image fMissingJarImage, fMissingVariableImage; private Image fMissingFolderImage, fMissingProjectImage; private Image fPackageImage; @@ -54,6 +59,7 @@ private Image fBeanImage; private Image fMissingPackageImage; private Image fBlankImage; + private Image fMissingLibraryImage; private HashMap fBeanedImages = new HashMap(); // Key of image to a composite with a bean attached private HashMap fPackagedImages = new HashMap(); private HashMap fMissingPackagedImages = new HashMap(); @@ -61,6 +67,12 @@ // Key of image to a composite with a package attached public SearchPathListLabelProvider() { + this(null); + } + + public SearchPathListLabelProvider(IJavaProject javaProject) { + this.javaProject = javaProject; + fRoot = ResourcesPlugin.getWorkspace().getRoot(); ImageRegistry reg = JavaPlugin.getDefault().getImageRegistry(); @@ -69,17 +81,23 @@ fFolderImage = reg.get(JavaPluginImages.IMG_OBJS_PACKFRAG_ROOT); fVariableImage = reg.get(JavaPluginImages.IMG_OBJS_ENV_VAR); + + fLibraryImage = reg.get(JavaPluginImages.IMG_OBJS_LIBRARY); IWorkbench workbench = JavaPlugin.getDefault().getWorkbench(); fProjectImage = workbench.getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT); - fMissingLibaryImage = reg.get(JavaPluginImages.IMG_OBJS_MISSING_JAR); + fMissingJarImage = reg.get(JavaPluginImages.IMG_OBJS_MISSING_JAR); fMissingVariableImage = reg.get(JavaPluginImages.IMG_OBJS_MISSING_ENV_VAR); fMissingFolderImage = reg.get(JavaPluginImages.IMG_OBJS_MISSING_PACKFRAG_ROOT); fMissingProjectImage = workbench.getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED); fPackageImage = reg.get(JavaPluginImages.IMG_OBJS_PACKAGE); + Rectangle r = fLibraryImage.getBounds(); + Point s = new Point(r.width, r.height); + JavaElementImageDescriptor jed = new JavaElementImageDescriptor(reg.getDescriptor(JavaPluginImages.IMG_OBJS_LIBRARY), JavaElementImageDescriptor.WARNING, s); + fMissingLibraryImage = jed.createImage(); try { ImageDescriptor pin = ImageDescriptor.createFromURL( @@ -117,6 +135,10 @@ } + public void setJavaProject(IJavaProject javaProject) { + this.javaProject = javaProject; + } + public String getText(Object element) { if (element instanceof BPListElement) { BPListElement bpentry = (BPListElement) element; @@ -161,6 +183,18 @@ pathString = name; break; + case IClasspathEntry.CPE_CONTAINER: + try { + IClasspathContainer c = JavaCore.getClasspathContainer(path, javaProject); + if (c != null) { + pathString = c.getDescription(); + break; + } + } catch (JavaModelException e) { + } + pathString = path.toString(); + break; + case IClasspathEntry.CPE_PROJECT : pathString = path.toString(); break; @@ -220,7 +254,7 @@ else pathImage = fExtJarIcon; } else - pathImage = fMissingLibaryImage; + pathImage = fMissingJarImage; break; case IClasspathEntry.CPE_PROJECT : @@ -237,6 +271,13 @@ pathImage = fMissingVariableImage; break; + case IClasspathEntry.CPE_CONTAINER: + if (!bpentry.isMissing()) + pathImage = fLibraryImage; + else + pathImage = fMissingLibraryImage; + break; + case BeaninfoEntry.BIE_PLUGIN: pathImage = fPluginImage; break; @@ -325,6 +366,7 @@ fBeanImage.dispose(); fMissingPackageImage.dispose(); fBlankImage.dispose(); + fMissingLibraryImage.dispose(); for (Iterator itr = fBeanedImages.values().iterator(); itr.hasNext();) { ((Image) itr.next()).dispose(); }
diff --git a/plugins/org.eclipse.jem.ui/plugin.xml b/plugins/org.eclipse.jem.ui/plugin.xml index d07d0fd..e6f57e9 100644 --- a/plugins/org.eclipse.jem.ui/plugin.xml +++ b/plugins/org.eclipse.jem.ui/plugin.xml
@@ -24,6 +24,7 @@ <import plugin="org.eclipse.jdt.launching"/> <import plugin="org.eclipse.jdt.debug.ui"/> <import plugin="com.ibm.wtp.common.util"/> + <import plugin="org.eclipse.jem.workbench"/> </requires> @@ -69,8 +70,8 @@ label="%Action.proxyLaunch" pulldown="true" icon="icons/full/ctool16/run_exc.gif" - class="org.eclipse.jem.internal.ui.proxy.ProxyLaunchToolbarDelegate" tooltip="%Action.proxyLaunchTip" + class="org.eclipse.jem.internal.ui.proxy.ProxyLaunchToolbarDelegate" toolbarPath="org.eclipse.debug.ui.launchActionSet/proxyLaunch" id="org.eclipse.jem.ui.proxy.ProxyLaunchToolbarDelegateAction"> </action> @@ -94,8 +95,8 @@ <action label="%Action.proxyLaunch" icon="icons/full/ctool16/run_exc.gif" - class="org.eclipse.jem.internal.ui.proxy.ProxyLaunchMenuDelegate" tooltip="%Action.proxyLaunchTip" + class="org.eclipse.jem.internal.ui.proxy.ProxyLaunchMenuDelegate" menubarPath="org.eclipse.ui.run/" id="org.eclipse.jem.ui.proxy.ProxyLaunchMenuDelegateAction"> </action> @@ -104,8 +105,8 @@ <extension point="org.eclipse.ui.popupMenus"> <objectContribution - objectClass="org.eclipse.core.resources.IProject" adaptable="true" + objectClass="org.eclipse.core.resources.IProject" id="org.eclipse.jem.ui.select.default.objectcontibution"> <action label="%Action.selectDefault" @@ -148,10 +149,10 @@ point="org.eclipse.ui.editors"> <editor name="%Editors.OverrideEditor" - icon="icons/full/obj16/file_obj.gif" extensions="override" - contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor" + icon="icons/full/obj16/file_obj.gif" class="org.eclipse.ui.editors.text.TextEditor" + contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor" id="org.eclipse.jem.beaninfo.OverrideEditor"> </editor> </extension>