graphical editor fly layout palette [message #238845] |
Thu, 04 October 2007 04:17  |
Eclipse User |
|
|
|
Originally posted by: shady_86.sify.com
i m trying to make an rcp app with gef in that i have added the extension for an editor,
i have created the class for that as 'Sharad extends GraphicalEditorFlylayoutPalette'
now i want to open this editor by an action in the menu as new.
i know how to do this if the editor is a simple editor for text editing but the procedure the same for this also??,
i mean here also do we have to make the EditorInput class??
your comments wil be really helpfull for me.
thanks,
--
Sharad
|
|
|
|
Re: graphical editor fly layout palette [message #238901 is a reply to message #238867] |
Fri, 05 October 2007 07:25   |
Eclipse User |
|
|
|
Originally posted by: shady_86.sify.com
but we will have to make the IEditorInput class to make the openEditor method to work, will there be nay changes also??
actually i dont know exactly why this class is needed or what is the purpose,
i saw a tutorial once about opening an editor where they didnt told about this class properly so i just remember that we need this class to open an editor,
so please can you help me with that??
thanks,
--
Sharad
> Hi Sharad,
> The procedure for opening a graphical editor is
> very similar. You
> will need to provide some implementation in the
> setInput method to
> handle the input - which is probably a
> FileEditorInput - you don't have
> to create this class unless you need something
> special in the project
> manager view. Then, configureGraphicalEditor and
> initializeGraphicalEditor (in that order) get called.
> this is where you
> et up your root edit part, set the contents on the
> viewer, etc. The
> examples cover this part pretty well.
>
> hope that helps.
> adam
>
> sharad singh wrote:
> > i m trying to make an rcp app with gef in that i
> have added the extension for an editor,
> > i have created the class for that as 'Sharad
> extends GraphicalEditorFlylayoutPalette'
> >
> > now i want to open this editor by an action in the
> menu as new.
> >
> > i know how to do this if the editor is a simple
> editor for text editing but the procedure the same
> for this also??,
> >
> > i mean here also do we have to make the EditorInput
> class??
> >
> > your comments wil be really helpfull for me.
> >
> > thanks,
> > --
> > Sharad
> >
|
|
|
Re: graphical editor fly layout palette [message #238968 is a reply to message #238901] |
Tue, 09 October 2007 04:55  |
Eclipse User |
|
|
|
Originally posted by: luis_dediego.yahoo.com
Hi Sharad,
I got the same problem when trying to open an editor input. I had a File
selector customized to my file extension but I did not found any way to
create the EditorInput.
Finally I intercepted the filename and then created a IFileStore with
this pieces of code. I hope this will help you to open the file.
Best regards.
-- This is to open the file dialog and get the filename
public static String openDialog(IWorkbenchWindow window) {
// TODO Save locally the previous scenery just in case of errors.
// TODO Check is an scenery is already open. If so ask for closing.
// - Get the user to choose an scenery file.
// String sceneryPath = null;
final FileDialog fileChooser = new FileDialog(window.getShell(),
SWT.OPEN);
// TODO Configure the text of the dialog to be presented to the user.
fileChooser.setText("Texto to be configured.");
fileChooser.setFilterPath(null);
fileChooser.setFilterExtensions(OPEN_FILTER_EXTENSIONS);
fileChooser.setFilterNames(OPEN_FILTER_NAMES);
final String sceneryName = fileChooser.open();
return sceneryName;
}
-- This is to check the filename and to create the FileInput that is
required by the call to the IDE workbench with this call:
IDE.openEditorOnFileStore(page, newScenery.getFileStoreModel());
public static boolean checkFileStore(String sceneryName) throws
PartInitException {
if (null == sceneryName) return false;
newScenery = new Scenery();
newScenery.setSceneryName(sceneryName);
// - Check that the file selected exists and is valid.
final IFileStore fileStore = EFS.getLocalFileSystem().getStore(new
Path(sceneryName));
if (!fileStore.fetchInfo().isDirectory() &&
fileStore.fetchInfo().exists()) {
// - Read the scenery properties and locate the scenery object data.
final File sceneryFile = new File(sceneryName);
if (null == sceneryFile)
throw new PartInitException("The scenery file selected cannot
be open or is empty.");
final Properties props = new Properties();
try {
props.load(new BufferedInputStream(new
FileInputStream(sceneryFile)));
newScenery.setProperties(props);
final String modelFileName = props.getProperty("modelLocation");
if (null == modelFileName)
throw new PartInitException("The scenery model data file
selected cannot be open or is empty.");
newScenery.setModelFileName(modelFileName);
// - Test if the model exists and then open through the interface.
final IFileStore fileStoreModel =
EFS.getLocalFileSystem().getStore(new Path(modelFileName));
if (!fileStoreModel.fetchInfo().isDirectory() &&
fileStoreModel.fetchInfo().exists()) {
newScenery.setFileStore(fileStoreModel);
newScenery.setLoadStatus(Scenery.PREPARED);
return true;
}
} catch (final FileNotFoundException e) {
// EXCEPTION PartInitException("The scenery file open has
failed.");
// throw new PartInitException("The scenery file open has
failed." + e.getMessage());
e.printStackTrace();
throw new PartInitException("The scenery model data file cannot
be found.");
} catch (final IOException e) {
// EXCEPTION PartInitException("The scenery file open has
failed.");
// throw new PartInitException("The scenery file open has
failed." + e.getMessage());
e.printStackTrace();
throw new PartInitException("The scenery model data file cannot
be read or open.");
}
}
return false;
}
|
|
|
Powered by
FUDForum. Page generated in 0.03149 seconds