Filemenu popup within GMF [message #1007178] |
Mon, 04 February 2013 19:00 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Phil H![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=philipp%40kku49.de) Messages: 267 Registered: November 2012 |
Senior Member |
|
|
Hello,
I've created a GMF Editor which works fine so far.
What I want to do now is implementing a popup which opens when an user clicks on a node. This popup should realise some kind of a file manager, like the attached immage. The user should be able to choose a file somewhere from the drive and then the file path should be stored as an String attribute in the gmf model.
Hope you understand what I mean. Is there any chance to realise something like that? Maybe eclipse provide some support.
[Updated on: Tue, 05 February 2013 10:45] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Filemenu popup within GMF [message #1036758 is a reply to message #1007586] |
Mon, 08 April 2013 19:22 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Simon Zutterman![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=simonzutterman%40gmail.com) Messages: 28 Registered: October 2012 |
Junior Member |
|
|
Hey Phil,
I'd also really like to implement something like this in my editor, but even with the previous posts, I don't have a clue how.
As I would like it, I would have a node with a normal feature name label, but in the metamodel with a second attribute (filepath), if you double click on the node in the editor, you get the file manager popup, select a file on your drive and the filepath would be stored in the attribute, displayed in the properties view.
It would be a massive help and I would be eternally grateful if you could give me a more detailed explanation on how to do this! Or if you were willing, post me your project files so i can sort it out myself?
regards,
Simon
|
|
|
Re: Filemenu popup within GMF [message #1052645 is a reply to message #1007178] |
Tue, 30 April 2013 10:47 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Phil H![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=philipp%40kku49.de) Messages: 267 Registered: November 2012 |
Senior Member |
|
|
Hi Simon,
sry I just noticed your post now.
In your diagram edit.part package you should have a generated class for your node (called NameOfYourNodeEditPart). In your method createDefaultEditPolicies() you have to install your own created EditPolicy. In my case I just added:
installEditPolicy(EditPolicyRoles.OPEN_ROLE,new FilePathOpenEditPolicy());
The mentioned policy class looks like this:
public class FilePathOpenEditPolicy extends OpenEditPolicy {
protected Command getOpenCommand(final Request request) {
return new Command() {
public void execute() {
EditPart targetEditPart = getTargetEditPart(request);
if (targetEditPart instanceof IGraphicalEditPart) {
IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) targetEditPart;
TransactionalEditingDomain editingDomain = graphicalEditPart.getEditingDomain();
if (graphicalEditPart.getModel() instanceof View) {
View view = (View) graphicalEditPart.getModel();
if (view.getElement() instanceof Feature) {
Feature feature = (Feature) view.getElement();
Shell shell = Display.getCurrent().getActiveShell();
FileDialog fileDialog = new FileDialog(shell);
fileDialog.setText("Select an EFVM File");
fileDialog.setFilterExtensions(new String[] { "*.efvm" });
fileDialog.setFilterNames(new String[] { "*.efvm" });
try {
String path = fileDialog.open();
if (!path.isEmpty()) {
SetRequest setRequestX = new SetRequest(editingDomain, feature,PldPackage.eINSTANCE.getFeature_FilePath(),path);
SetValueCommand setX = new SetValueCommand(setRequestX);
setX.execute(null, null);
}
} catch (Exception e) {
MessageDialog.openWarning(shell, "Warning",
"No efvm file has been selected!");
// e.printStackTrace();
}
}
}
}
}
};
}
}
Hope this helps.
Cheers,
Phil
|
|
|
Powered by
FUDForum. Page generated in 0.02729 seconds