In addition to the attribute view provided by ECLIPSE, GEF applicationsProgramYou can also modify the model information in the pop-up dialog box.
To double-click a node to open the dialog box, addCodeAs follows:
Public Void Receivmrequest (request req ){
If (Req. GetType (). Equals (requestconstants. req_open )){
Messagedialog. openinformation (getviewer (). getcontrol (). getshell (), " GEF practice " , " A Dialog " );
}
}
As an example, the above Code only opens a dialog box for displaying information. You can replace it with the self-implemented dialog box to display/modify node information.
Add the following code to createnodecommand. You can specify the node name in the dialog box when creating a node:
Public Void Execute (){
Inputdialog DLG = New Inputdialog (shell, " GEF practice " , " New node's name: " , " Node " , Null );
If (Window. OK = DLG. open ()){
This . Node. setname (DLG. getvalue ());
}
This . Digoal. addnode ( This . Node );
}
The shell is used to open the dialog box, so you need to add a shell member variable in createnodecommand and pass a shell instance to it when creating createnodecommand in diagramlayouteditpolicy.
The create node dialog box is displayed.
Click here to download the project. This project is modified from gefpractice in the GEF application instance. The extension of the target file is changed to. gefpracticedlg.