Copy link to clipboard
Copied
I have Flash Builder 4 Standard installed in Eclipse 3.6.
I am writing an Eclipse plugin where I need to access the Flex project properties so I do something like this:
import com.adobe.flexbuilder.codemodel.common.CMFactory;
import com.adobe.flexbuilder.codemodel.project.*;
IProject flexProject = CMFactory.getManager().getProjectFor(myEclipseProject);
Copy link to clipboard
Copied
In your plugin, have you added a dependency to the com.adobe.flexbuilder.codemodel plugin?
If not, can you add the dependency and try?
Copy link to clipboard
Copied
Yes, I have added the dependency to com.adobe.flexbuilder.codemodel. The problem is with the "Access restriction" error, where can this come from?
Thanks.
Copy link to clipboard
Copied
Hi Laurent,
We are unable to reproduce this issue locally. Can you please provide more detailed reproducible steps? May be there is some step that we are missing here.
-radhakrishna
Copy link to clipboard
Copied
Here are steps to reproduce my problem:
1) From Eclipse File > New menu select "Plug-in Project"
2) Enter a project name, leave other options as-is
3) In the "Content" page of the wizard leave all fields as-is (Yes for Generate activator and this plug-in will make contribution to the UI. No for Rich Client application)
4) In the "Templates" page, select "Plug-in with a Popup menu"
5) This generates the project with a NewAction.java class.
Then modify NewAction.java as shown in the code sample below.
1) The "selectionChanged" method sets the _selectedProject variable.
2) The "run" method tries to get the flexProject information from the selected project
=> The import of CMFactory gives me an Access Restriction error "The type CMFactory is not accessible due to restriction on required library D:\Program Files\Adobe\Adobe Flash Builder 4 Plug-in\eclipse\plugins\com.adobe.flexbuilder.codemodel_4.0.0.272416\codemodel.jar
What restriction is this about?
How can one import the flexbuilder libraries in order to get information on the flex projects in this case?
Thanks!
--Laurent
import com.adobe.flexbuilder.codemodel.common.CMFactory;
import com.adobe.flexbuilder.codemodel.project.*;
public class NewAction implements IObjectActionDelegate {
private Shell shell;
private IProject _selectedProject;
...
public void run(IAction action) {
// get the flexProject information
IProject flexProject = CMFactory.getManager().getProjectFor(_selectedProject);
...
}
public void selectionChanged(IAction action, ISelection selection) {
_selectedProject = null;
boolean enabled = false;
if (selection instanceof IStructuredSelection) {
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (obj instanceof IProject) {
IProject proj = (IProject)obj;
if (proj.isOpen()) {
enabled = true;
_selectedProject = proj;
}
}
}
action.setEnabled(enabled);
}
Copy link to clipboard
Copied
How did you add the dependency to codemodel.jar? Adding it into "java build path" won't be the way to do it for a plugin dependecy. You could create another plugin - "plugin from existing jar" and add codemodel.jar there and then in your plugin.xml you could add the first plugin as a required plugin in the dependency tab.
May be this helps : http://stackoverflow.com/questions/1227425/how-can-i-add-the-external-jar-to-the-eclipse-rcp-application
Copy link to clipboard
Copied
> How did you add the dependency to codemodel.jar?
I edited the plug-in dependencies (plugin.xml file). It is found correctly so it's not the issue.
The problem is the Access Restriction error. Why do you think this is happening?
Copy link to clipboard
Copied
Has anyone seen this kind of Access Restriction error on a Flex library?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks for sending this sample code. I finally figured out that the error had nothing to do with "unauthorized access to com.adobe.flexbuilder.codemodel"... it was due to the fact that this bundle was both in the "Require-bundle" and "Import-Package" section of my plugin's MANIFEST.MF file.