illegalArgumentException [message #1085104] |
Mon, 12 August 2013 13:04 |
junior developer Messages: 354 Registered: January 2013 |
Senior Member |
|
|
Hi all,
I use two editor.I create some elements another editor automatically. but I receive an error about create URİ.I created resource Uri such as platfor/resource/relative path but
I receive an error :Attempted to beginRule: L/deneme/user.mydsl2, does not match outer scope rule: L/deneme/denemeCT.mydAttempted to beginRule: L/deneme/user.mydsl2, does not match outer scope rule: L/deneme/denemeCT.myds.I do not solve this problem
public class Sitepermission6 {
@Inject
Provider<XtextResourceSet> rsp;
public File userFile;
public static SitePermission createDefaultSitePermission(String webName,
String webGuID, UserModel userModel) {
// Initialize the model
MyDsl2Package.eINSTANCE.eClass();
// Retrieve the default factory singleton
MyDsl2Factory factory = MyDsl2Factory.eINSTANCE;
// SitePermission
SitePermission sitePermission = factory.createSitePermission();
sitePermission.setName(webName);
sitePermission.setWebGUID(webGuID);
// Owners Group
Group ownerGroup = MyDsl2Factory.eINSTANCE.createGroup();
ownerGroup.setName("Owners");
sitePermission.getOwnedGroup().add(ownerGroup);
userModel.getSitePermissions().add(sitePermission);
return sitePermission;
}
public SitePermission loadForCreateSitePermission(String webName,
String webGuID) {
SitePermission sitePermission = null;
XtextResourceSet resourceSet = rsp.get();
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
Resource resource = resourceSet.getResource(URI.createURI(getUserFileLocationURI()), true);
System.out.println(resource);
UserModel eobject = (UserModel) resource.getContents().get(0);
sitePermission = createDefaultSitePermission(webName, webGuID, eobject);
try {
resource.save(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return sitePermission;
}
public String getUserFileLocationURI() {
IEditorPart editorPart = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editorPart != null) {
IFileEditorInput input = (IFileEditorInput) editorPart
.getEditorInput();
IFile file = input.getFile();
String path = "";
int segmentCount = file.getProjectRelativePath().segmentCount();
if(segmentCount != 1){
for (int i = 0; i < segmentCount -1; i++) {
path += file.getProjectRelativePath().segment(i) + "/";
}
}
return "platform:/resource/" + file.getProject().getName() + "/" + path + UserConstant1.USER_FILE_NAME;
}
return "";
}
}
PS:
ıf use this code crate uri C:\relative path ,I do not receive an error.and I created elements in the editor but every time I save other editor for use cerated elements in the referenced editor.
public SitePermission loadForCreateSitePermission(String webName,
String webGuID) {
SitePermission sitePermission = null;
XtextResourceSet resourceSet = rsp.get();
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
getUserFilePath(getProjectName(), UserConstant1.USER_FILE_NAME);
if (getUserFile() != null) {
Resource resource = resourceSet.getResource(URI.createURI(userFile.toURI().toString()), true);
Resource resource = resourceSet.getResource(URI.createURI(getUserFileLocationURI()), true);
System.out.println(resource);
UserModel eobject = (UserModel) resource.getContents().get(0);
sitePermission = createDefaultSitePermission(webName, webGuID, eobject);
try {
resource.save(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return sitePermission;
}
/*public static IProject getProjectName() {
IEditorPart editorPart = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
IProject activeProject = null;
if (editorPart != null) {
IFileEditorInput input = (IFileEditorInput) editorPart
.getEditorInput();
IFile file = input.getFile();
activeProject = file.getProject();
}
return activeProject;
}
public void getUserFilePath(IProject project, String name) {
File[] files = project.getLocation().toFile().listFiles();
showFiles(files, name);
}
public void showFiles(File[] files, String name) {
if (getUserFile() == null) {
for (File file : files) {
if (name.equals(file.getName())) {
setUserFile(file);
break;
} else {
if (file.isDirectory()) {
showFiles(file.listFiles(), name); // Calls same method again.
}
}
}
}
}
public File getUserFile() {
return userFile;
}
public void setUserFile(File userFile) {
this.userFile = userFile;
Best Regards
|
|
|
|
Powered by
FUDForum. Page generated in 0.03360 seconds