Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 77493 Details for
Bug 96962
Quickfix to solve restriction access problem
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch
patch96962.txt (text/plain), 13.93 KB, created by
Adam Archer
on 2007-08-31 13:56:58 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Adam Archer
Created:
2007-08-31 13:56:58 EDT
Size:
13.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v >retrieving revision 1.319 >diff -u -r1.319 PDEUIMessages.java >--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 28 Aug 2007 22:05:14 -0000 1.319 >+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 31 Aug 2007 17:58:23 -0000 >@@ -1606,6 +1606,8 @@ > public static String FeatureImportWizard_operation_multiProblem; > public static String FeatureImportWizard_operation_creating2; > >+ public static String ForbiddenAccessProposal_quickfixMessage; >+ > public static String UpdateBuildpathWizard_wtitle; > public static String UpdateBuildpathWizard_title; > public static String UpdateBuildpathWizard_desc; >Index: src/org/eclipse/pde/internal/ui/PDEPluginImages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java,v >retrieving revision 1.100 >diff -u -r1.100 PDEPluginImages.java >--- src/org/eclipse/pde/internal/ui/PDEPluginImages.java 15 Aug 2007 20:12:51 -0000 1.100 >+++ src/org/eclipse/pde/internal/ui/PDEPluginImages.java 31 Aug 2007 17:58:23 -0000 >@@ -54,7 +54,8 @@ > public static final String OBJ_DESC_GENERATE_CLASS = NAME_PREFIX + "OBJ_DESC_GENERATE_CLASS"; //$NON-NLS-1$ > public static final String OBJ_DESC_GENERATE_INTERFACE = NAME_PREFIX + "OBJ_DESC_GENERATE_INTERFACE"; //$NON-NLS-1$ > public static final String OBJ_DESC_PACKAGE = NAME_PREFIX + "OBJ_DESC_PACKAGE"; //$NON-NLS-1$ >- >+ public static final String OBJ_DESC_BUNDLE = NAME_PREFIX + "OBJ_DESC_BUNDLE"; //$NON-NLS-1$ >+ > /** > * OBJ16 > */ >@@ -301,6 +302,7 @@ > manage(OBJ_DESC_GENERATE_CLASS, DESC_GENERATE_CLASS); > manage(OBJ_DESC_GENERATE_INTERFACE, DESC_GENERATE_INTERFACE); > manage(OBJ_DESC_PACKAGE, DESC_PACKAGE_OBJ); >+ manage(OBJ_DESC_BUNDLE, DESC_BUNDLE_OBJ); > } > > private static URL makeImageURL(String prefix, String name) { >Index: src/org/eclipse/pde/internal/ui/pderesources.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v >retrieving revision 1.917 >diff -u -r1.917 pderesources.properties >--- src/org/eclipse/pde/internal/ui/pderesources.properties 29 Aug 2007 15:29:34 -0000 1.917 >+++ src/org/eclipse/pde/internal/ui/pderesources.properties 31 Aug 2007 17:58:23 -0000 >@@ -1120,6 +1120,7 @@ > FeatureImportWizard_operation_creating = Creating projects from features... > FeatureImportWizard_operation_multiProblem = Problems detected while importing features > FeatureImportWizard_operation_creating2 = Creating ''{0}''... >+ForbiddenAccessProposal_quickfixMessage=Export the ''{0}'' package from the ''{1}'' plug-in > > UpdateBuildpathWizard_wtitle = Java Classpath > UpdateBuildpathWizard_title = Update Java class path >Index: src/org/eclipse/pde/internal/ui/preferences/OSGiFrameworkPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/preferences/OSGiFrameworkPreferencePage.java,v >retrieving revision 1.5 >diff -u -r1.5 OSGiFrameworkPreferencePage.java >--- src/org/eclipse/pde/internal/ui/preferences/OSGiFrameworkPreferencePage.java 29 Aug 2007 19:03:53 -0000 1.5 >+++ src/org/eclipse/pde/internal/ui/preferences/OSGiFrameworkPreferencePage.java 31 Aug 2007 17:58:23 -0000 >@@ -49,14 +49,8 @@ > IWorkbenchPreferencePage { > > class FrameworkLabelProvider extends LabelProvider { >- private Image image; >- >- public FrameworkLabelProvider() { >- image = PDEPluginImages.DESC_BUNDLE_OBJ.createImage(); >- } >- > public Image getImage(Object element) { >- return image; >+ return PDEPluginImages.get(PDEPluginImages.OBJ_DESC_BUNDLE); > } > > public String getText(Object element) { >@@ -67,11 +61,6 @@ > } > return super.getText(element); > } >- >- public void dispose() { >- image.dispose(); >- super.dispose(); >- } > } > > private TableViewer fTableViewer; >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/plugin.xml,v >retrieving revision 1.423 >diff -u -r1.423 plugin.xml >--- plugin.xml 20 Aug 2007 18:28:23 -0000 1.423 >+++ plugin.xml 31 Aug 2007 17:58:23 -0000 >@@ -1753,4 +1753,11 @@ > parentId="org.eclipse.ui.textEditorScope"> > </context> > </extension> >+ <extension >+ point="org.eclipse.jdt.ui.quickFixProcessors"> >+ <quickFixProcessor >+ class="org.eclipse.pde.internal.ui.correction.java.QuickFixProcessor" >+ id="org.eclipse.jdt.ui.text.correction.QuickFixProcessor"> >+ </quickFixProcessor> >+ </extension> > </plugin> >Index: src/org/eclipse/pde/internal/ui/correction/java/ForbiddenAccessProposal.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/correction/java/ForbiddenAccessProposal.java >diff -N src/org/eclipse/pde/internal/ui/correction/java/ForbiddenAccessProposal.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/correction/java/ForbiddenAccessProposal.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/******************************************************************************* >+ * 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.ui.correction.java; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.jdt.core.IPackageFragment; >+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.contentassist.IContextInformation; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.pde.core.IBaseModel; >+import org.eclipse.pde.internal.core.ibundle.IBundle; >+import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase; >+import org.eclipse.pde.internal.core.text.bundle.ExportPackageHeader; >+import org.eclipse.pde.internal.core.text.bundle.ExportPackageObject; >+import org.eclipse.pde.internal.ui.PDEPluginImages; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.util.ModelModification; >+import org.eclipse.pde.internal.ui.util.PDEModelUtility; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.osgi.framework.Constants; >+ >+public class ForbiddenAccessProposal implements IJavaCompletionProposal { >+ >+ private IProject fProject; >+ private IPackageFragment fFragment; >+ >+ public ForbiddenAccessProposal(IPackageFragment fragment, IProject project) { >+ fProject = project; >+ fFragment = fragment; >+ } >+ >+ public void apply(IDocument document) { >+ ModelModification mod = new ModelModification(fProject){ >+ protected void modifyModel(IBaseModel model, >+ IProgressMonitor monitor) throws CoreException { >+ if (model instanceof IBundlePluginModelBase) { >+ IBundle bundle = ((IBundlePluginModelBase)model).getBundleModel().getBundle(); >+ >+ ExportPackageHeader header = (ExportPackageHeader)bundle.getManifestHeader(Constants.EXPORT_PACKAGE); >+ if (header == null) { >+ bundle.setHeader(Constants.EXPORT_PACKAGE, ""); //$NON-NLS-1$ >+ header = (ExportPackageHeader)bundle.getManifestHeader(Constants.EXPORT_PACKAGE); >+ } >+ header.addPackage(new ExportPackageObject(header, fFragment, Constants.VERSION_ATTRIBUTE)); >+ } >+ } >+ }; >+ PDEModelUtility.modifyModel(mod, new NullProgressMonitor()); >+ } >+ >+ public String getDisplayString() { >+ return NLS.bind(PDEUIMessages.ForbiddenAccessProposal_quickfixMessage, new String[] {fFragment.getElementName(), fProject.getName()}); >+ } >+ >+ public Image getImage() { >+ return PDEPluginImages.get(PDEPluginImages.OBJ_DESC_BUNDLE); >+ } >+ >+ public int getRelevance() { >+ return 100; >+ } >+ >+ public String getAdditionalProposalInfo() { >+ return null; >+ } >+ public IContextInformation getContextInformation() { >+ return null; >+ } >+ public Point getSelection(IDocument document) { >+ return null; >+ } >+} >Index: src/org/eclipse/pde/internal/ui/correction/java/QuickFixProcessor.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/correction/java/QuickFixProcessor.java >diff -N src/org/eclipse/pde/internal/ui/correction/java/QuickFixProcessor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/correction/java/QuickFixProcessor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/******************************************************************************* >+ * 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.ui.correction.java; >+ >+import java.util.ArrayList; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IPackageFragment; >+import org.eclipse.jdt.core.compiler.IProblem; >+import org.eclipse.jdt.core.dom.ASTNode; >+import org.eclipse.jdt.core.dom.IBinding; >+import org.eclipse.jdt.core.dom.Name; >+import org.eclipse.jdt.core.dom.Type; >+import org.eclipse.jdt.ui.text.java.IInvocationContext; >+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; >+import org.eclipse.jdt.ui.text.java.IProblemLocation; >+import org.eclipse.jdt.ui.text.java.IQuickFixProcessor; >+import org.eclipse.osgi.service.resolver.ExportPackageDescription; >+import org.eclipse.pde.core.plugin.IPluginModelBase; >+import org.eclipse.pde.internal.core.PDECore; >+import org.eclipse.pde.internal.core.WorkspaceModelManager; >+ >+public class QuickFixProcessor implements IQuickFixProcessor { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.ui.text.java.IQuickFixProcessor#getCorrections(org.eclipse.jdt.ui.text.java.IInvocationContext, org.eclipse.jdt.ui.text.java.IProblemLocation[]) >+ */ >+ public IJavaCompletionProposal[] getCorrections(IInvocationContext context, >+ IProblemLocation[] locations) throws CoreException { >+ ArrayList results = new ArrayList(); >+ for (int i = 0; i < locations.length; i++) { >+ int id = locations[i].getProblemId(); >+ switch (id) { >+ case IProblem.ForbiddenReference: >+ handleAccessRestrictionProblem(context, locations[i], results); >+ default: >+ } >+ } >+ return (IJavaCompletionProposal[])results.toArray(new IJavaCompletionProposal[results.size()]); >+ } >+ >+ private void handleAccessRestrictionProblem(IInvocationContext context, >+ IProblemLocation location, ArrayList results) { >+ IBinding referencedElement= null; >+ ASTNode node= location.getCoveredNode(context.getASTRoot()); >+ if (node instanceof Type) { >+ referencedElement= ((Type) node).resolveBinding(); >+ } else if (node instanceof Name) { >+ referencedElement= ((Name) node).resolveBinding(); >+ } >+ if (referencedElement != null) { >+ // get the project that contains the reference element >+ // ensure it exists in the workspace and is a plug-in project >+ IJavaProject referencedJavaProject = referencedElement.getJavaElement().getJavaProject(); >+ if (referencedJavaProject != null && WorkspaceModelManager.isPluginProject(referencedJavaProject.getProject())) { >+ // get the packages exported by the referenced plug-in project >+ IPluginModelBase referencedModel = PDECore.getDefault().getModelManager().findModel(referencedJavaProject.getProject()); >+ ExportPackageDescription[] exportPackages = referencedModel.getBundleDescription().getExportPackages(); >+ // check if the required package is exported already >+ boolean packageExported = false; >+ IPackageFragment referencedPackage = (IPackageFragment)referencedElement.getJavaElement().getAncestor(IJavaElement.PACKAGE_FRAGMENT); >+ if (referencedPackage != null) { >+ for (int i = 0; i < exportPackages.length; i++) { >+ if (exportPackages[i].getName().equals(referencedPackage.getElementName())){ >+ packageExported = true; >+ break; >+ } >+ } >+ // if the package is not exported, add the quickfix >+ if (!packageExported) { >+ results.add(new ForbiddenAccessProposal(referencedPackage, referencedJavaProject.getProject())); >+ } >+ } >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.ui.text.java.IQuickFixProcessor#hasCorrections(org.eclipse.jdt.core.ICompilationUnit, int) >+ */ >+ public boolean hasCorrections(ICompilationUnit unit, int problemId) { >+ switch (problemId) { >+ case IProblem.ForbiddenReference: >+ IJavaElement parent = unit.getParent(); >+ if (parent != null) { >+ IJavaProject project = parent.getJavaProject(); >+ if (project != null) >+ return WorkspaceModelManager.isPluginProject(project.getProject()); >+ } >+ default: >+ } >+ return false; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 96962
:
77409
|
77492
| 77493 |
77605