|
Re: I don't find the solution [message #384286 is a reply to message #384285] |
Tue, 14 April 2009 14:18 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------080406060502040708050201
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Please use the GMF newsgroup for questions about GMF. I've added it to
the "to" list of the reply, so no need to repost. Here's how EMF's
generated wizard opens the editor upon completion.
public boolean performFinish() {
try {
// Remember the file.
//
final IFile modelFile = getModelFile();
// Do the work within an operation.
//
WorkspaceModifyOperation operation =
new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor
progressMonitor) {
try {
// Create a resource set
//
ResourceSet resourceSet = new
ResourceSetImpl();
// Get the URI of the model file.
//
URI fileURI =
URI.createPlatformResourceURI(modelFile.getFullPath().toStri ng(), true);
// Create a resource for this file.
//
Resource resource =
resourceSet.createResource(fileURI);
// Add the initial model object to the
contents.
//
EObject rootObject = createInitialModel();
if (rootObject != null) {
resource.getContents().add(rootObject);
}
// Save the contents of the resource to
the file system.
//
Map<Object, Object> options = new
HashMap<Object, Object>();
options.put(XMLResource.OPTION_ENCODING,
initialObjectCreationPage.getEncoding());
resource.save(options);
}
catch (Exception exception) {
CustOrderEditorPlugin.INSTANCE.log(exception);
}
finally {
progressMonitor.done();
}
}
};
getContainer().run(false, false, operation);
// Select the new file resource in the current view.
//
IWorkbenchWindow workbenchWindow =
workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
final IWorkbenchPart activePart = page.getActivePart();
if (activePart instanceof ISetSelectionTarget) {
final ISelection targetSelection = new
StructuredSelection(modelFile);
getShell().getDisplay().asyncExec
(new Runnable() {
public void run() {
((ISetSelectionTarget)activePart).selectReveal(targetSelecti on);
}
});
}
// Open an editor on the new file.
//
try {
page.openEditor
(new FileEditorInput(modelFile),
workbench.getEditorRegistry().getDefaultEditor(modelFile.get FullPath().toString()).getId());
}
catch (PartInitException exception) {
MessageDialog.openError(workbenchWindow.getShell(),
CustOrderEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label "),
exception.getMessage());
return false;
}
return true;
}
catch (Exception exception) {
CustOrderEditorPlugin.INSTANCE.log(exception);
return false;
}
}
bassem-ca wrote:
> In the method actionPerformed of a button ,how can I invoke my
> plugin (4 files jar) which is a graphical editor developped with GMF ?
>
> Thanks
>
--------------080406060502040708050201
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Please use the GMF newsgroup for questions about GMF.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Re: I don't find the solution [message #615329 is a reply to message #384285] |
Tue, 14 April 2009 14:18 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------080406060502040708050201
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Please use the GMF newsgroup for questions about GMF. I've added it to
the "to" list of the reply, so no need to repost. Here's how EMF's
generated wizard opens the editor upon completion.
public boolean performFinish() {
try {
// Remember the file.
//
final IFile modelFile = getModelFile();
// Do the work within an operation.
//
WorkspaceModifyOperation operation =
new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor
progressMonitor) {
try {
// Create a resource set
//
ResourceSet resourceSet = new
ResourceSetImpl();
// Get the URI of the model file.
//
URI fileURI =
URI.createPlatformResourceURI(modelFile.getFullPath().toStri ng(), true);
// Create a resource for this file.
//
Resource resource =
resourceSet.createResource(fileURI);
// Add the initial model object to the
contents.
//
EObject rootObject = createInitialModel();
if (rootObject != null) {
resource.getContents().add(rootObject);
}
// Save the contents of the resource to
the file system.
//
Map<Object, Object> options = new
HashMap<Object, Object>();
options.put(XMLResource.OPTION_ENCODING,
initialObjectCreationPage.getEncoding());
resource.save(options);
}
catch (Exception exception) {
CustOrderEditorPlugin.INSTANCE.log(exception);
}
finally {
progressMonitor.done();
}
}
};
getContainer().run(false, false, operation);
// Select the new file resource in the current view.
//
IWorkbenchWindow workbenchWindow =
workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = workbenchWindow.getActivePage();
final IWorkbenchPart activePart = page.getActivePart();
if (activePart instanceof ISetSelectionTarget) {
final ISelection targetSelection = new
StructuredSelection(modelFile);
getShell().getDisplay().asyncExec
(new Runnable() {
public void run() {
((ISetSelectionTarget)activePart).selectReveal(targetSelecti on);
}
});
}
// Open an editor on the new file.
//
try {
page.openEditor
(new FileEditorInput(modelFile),
workbench.getEditorRegistry().getDefaultEditor(modelFile.get FullPath().toString()).getId());
}
catch (PartInitException exception) {
MessageDialog.openError(workbenchWindow.getShell(),
CustOrderEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label "),
exception.getMessage());
return false;
}
return true;
}
catch (Exception exception) {
CustOrderEditorPlugin.INSTANCE.log(exception);
return false;
}
}
bassem-ca wrote:
> In the method actionPerformed of a button ,how can I invoke my
> plugin (4 files jar) which is a graphical editor developped with GMF ?
>
> Thanks
>
--------------080406060502040708050201
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Please use the GMF newsgroup for questions about GMF.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03649 seconds