Problem in opening an editor in a multipage editor from a table [message #508524] |
Tue, 19 January 2010 05:16  |
Eclipse User |
|
|
|
I have a table which contains the EMF items and i try to open an editor in a multipage editor from the table.
this was working properly when i was in RCP plugin but the problem is coming after switching completely to EMF.
Below is the description of the problem
On clicking an element in Table Viewer , we have mapped an action delegate to it,
This action delegate calls the
IWorkbenchPage.openEditor(viewerInput, AgEditor.ID, activate);
wherein viewerInput is the IEditorInput and is set accordingly
AGEditor is the editor class which extends MultiPageEditorPart and implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker
In the create pages method overwritten for the editor the Viewerpane is accessed by
ViewerPane viewerPane = new ViewerPane(getSite().getPage(), AgEditor.this)
However the viewerpane is got as null
Below is the code which i am using
public void createPages() {
// Creates the model from the editor input
//
createModel(); //This method is below
// Only creates the other pages if there is something that can be edited
//
if (!getEditingDomain().getResourceSet().getResources().isEmpty ())
{
// Create a page for the baseText view (like SpeechMarker).
//
{
if(getSite()!=null)
ViewerPane viewerPane = new ViewerPane(getSite().getPage(), AgEditor.this)
{
@Override
public Viewer createViewer(Composite parent)
{
return new BaseTextViewer(parent); // BaseTextViewer is one of the editor in MultiPageEditorPart
}
@Override
public void requestActivation() {
super.requestActivation();
((BaseTextViewer) getViewer()).setFocus();
setCurrentViewerPane(this);
}
/*
* (non-Javadoc)
* @see org.eclipse.emf.common.ui.ViewerPane#setFocus()
*/
@Override
public void setFocus()
{
requestActivation();
((BaseTextViewer) getViewer()).setFocus();
}
};
//Viewer Pane got here is null ... The AgEditor values is present
public void createModel() {
URI resourceURI = EditUIUtil.getURI(getEditorInput());
Exception exception = null;
Resource resource = null;
try {
// Load the resource through the editing domain.
//
resource = editingDomain.getResourceSet().getResource(resourceURI, true);
}
catch (Exception e) {
exception = e;
resource = editingDomain.getResourceSet().getResource(resourceURI, false);
}
Diagnostic diagnostic = analyzeResourceProblems(resource, exception);
if (diagnostic.getSeverity() != Diagnostic.OK) {
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
}
editingDomain.getResourceSet().eAdapters().add(problemIndica tionAdapter);
}
If anyone can figure out the problem plaese provide a solution to this. I am using latest EMF v3.5. Any help provided will be deeply appreciated.
Thanks in advance
Rahul
|
|
|
Re: Problem in opening an editor in a multipage editor from a table [message #508606 is a reply to message #508524] |
Tue, 19 January 2010 10:38  |
Eclipse User |
|
|
|
Rahul,
Comments below.
Rahul wrote:
> I have a table which contains the EMF items and i try to open an
> editor in a multipage editor from the table.
> this was working properly when i was in RCP plugin but the problem is
> coming after switching completely to EMF.
>
> Below is the description of the problem
>
> On clicking an element in Table Viewer , we have mapped an action
> delegate to it,
> This action delegate calls the
> IWorkbenchPage.openEditor(viewerInput, AgEditor.ID, activate);
>
> wherein viewerInput is the IEditorInput and is set accordingly
> AGEditor is the editor class which extends MultiPageEditorPart and
> implements IEditingDomainProvider, ISelectionProvider, IMenuListener,
> IViewerProvider, IGotoMarker
> In the create pages method overwritten for the editor the
> Viewerpane is accessed by
> ViewerPane viewerPane = new ViewerPane(getSite().getPage(),
> AgEditor.this)
> However the viewerpane is got as null
>
> Below is the code which i am using
> public void createPages() {
> // Creates the model from the editor input
> //
> createModel(); //This method is below
>
> // Only creates the other pages if there is something that
> can be edited
> //
> if
> (!getEditingDomain().getResourceSet().getResources().isEmpty ())
> {
> // Create a page for the baseText view (like
> SpeechMarker).
> //
> {
> if(getSite()!=null)
> ViewerPane viewerPane = new
> ViewerPane(getSite().getPage(), AgEditor.this)
> {
> @Override
> public Viewer createViewer(Composite parent)
> {
> return new BaseTextViewer(parent);
> // BaseTextViewer is one of the editor in MultiPageEditorPart
> }
> @Override
> public void requestActivation() {
> super.requestActivation();
> ((BaseTextViewer)
> getViewer()).setFocus();
> setCurrentViewerPane(this);
> }
> /*
> * (non-Javadoc)
> * @see
> org.eclipse.emf.common.ui.ViewerPane#setFocus()
> */
> @Override
> public void setFocus()
> {
> requestActivation();
> ((BaseTextViewer)
> getViewer()).setFocus();
> }
> };
>
> //Viewer Pane got here is null ... The AgEditor values is present
>
>
>
>
>
> public void createModel() {
> URI resourceURI = EditUIUtil.getURI(getEditorInput());
> Exception exception = null;
> Resource resource = null;
> try {
> // Load the resource through the editing domain.
> //
> resource =
> editingDomain.getResourceSet().getResource(resourceURI, true);
> }
> catch (Exception e) {
> exception = e;
> resource =
> editingDomain.getResourceSet().getResource(resourceURI, false);
> }
>
> Diagnostic diagnostic = analyzeResourceProblems(resource,
> exception);
> if (diagnostic.getSeverity() != Diagnostic.OK) {
> resourceToDiagnosticMap.put(resource,
> analyzeResourceProblems(resource, exception));
> }
>
> editingDomain.getResourceSet().eAdapters().add(problemIndica
> tionAdapter);
> }
>
>
> If anyone can figure out the problem plaese provide a solution to
> this. I am using latest EMF v3.5. Any help provided will be deeply
> appreciated.
Best to use a debugger. I really can't see a problem just looking at
large code snippets.
>
> Thanks in advance
> Rahul
>
|
|
|
Powered by
FUDForum. Page generated in 0.02846 seconds