|
|
Re: Where to construct model? [message #228110 is a reply to message #228102] |
Fri, 15 December 2006 22:29 |
Jeff Higgins Messages: 51 Registered: July 2009 |
Member |
|
|
Thank you Anthony.
Looking at GEF Logic Editor I see:
protected void setInput(IEditorInput input) {
superSetInput(input);
IFile file = ((IFileEditorInput)input).getFile();
try {
InputStream is = file.getContents(false);
ObjectInputStream ois = new ObjectInputStream(is);
setLogicDiagram((LogicDiagram)ois.readObject());
ois.close();
}
// other stuff
}
OK I'll do it here. But:
Given that I don't have access to org.eclipse.core.resources.IFile,
But I do have org.eclipse.core.runtime.IPath;
How do I cast IEditorInput to MyPathEditorInput so that I can have
access to it's public IPath getPath() method?
Thanks,
your help is greatly appreciated.
Jeff Higgins
"Anthony Hunter" <anthonyh@ca.ibm.com> wrote in message
news:elv2d0$vos$1@utils.eclipse.org...
> Hi Jeff,
>
> The editor is normally where the root of your model is cached.
>
> Given you are calling openEditor, which calls
> EditorPart.setInput(IEditorInput) , you are already passing the file
> resource to your editor.
>
> Look at the GEF Logic Editor example for an example.
>
> Cheers...
> Anthony
>
> "Jeff Higgins" <oohiggins@yahoo.com> wrote in message
> news:eluo9l$jel$1@utils.eclipse.org...
>> Hi,
>> newbie question.
>> I have an RCP application that wishes to open
>> one editor. In my application's ActionBarAdvisor
>> I create an Open menu item and attach to my
>> OpenFileAction. OpenFileAction run() method looks
>> like this:
>>
>> public void run() {
>> FileDialog fileDialog = new
>> FileDialog(window.getShell(), SWT.OPEN);
>> String fileName = fileDialog.open();
>> try {
>> window.getActivePage()
>> .openEditor(new MyPathEditorInput
>> (new Path(fileName)),"myEditorID");
>> } catch ()
>>
>> Now, I have all of my EditParts and my model ready to go
>> except I don't know where to construct and keep my model?
>>
>> Should I place a private instance of my model in my editor
>> and construct it in my editor's getContent() method?
>> Something like this?
>>
>> private MyModel model;
>>
>> protected Object getContent() {
>> MyPathEditorInput input =
>> getSite()
>> .getWorkbenchWindow()
>> .getActivePage()
>> .getInput()
>> .getAdapter(MyPathEditorInput);
>> File file = new File(input.getPath());
>> model = makeModel(file);
>> return model;
>> }
>>
>> Thanks for any assistance.
>> Jeff Higgins
>>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02056 seconds