performance - Eclipse Plugin Development---PopupMenuCreation -
i developing wizard using eclipse plugin development.
requirement:
i have create context menu needs populated user right clicks on source folder in java project. once user performs first step handler needs selected src folder in wizard. wizard contains treeviewer need selected src folder packaged.
my analysis:
i have handler class gets selected packages
samplehandler.java
public object execute(executionevent event) throws executionexception { shell = handlerutil.getactiveshell(event); // initializing workbench window object iworkbenchwindow window = (iworkbenchwindow) handlerutil.getactiveworkbenchwindow(event); iselection sel = handlerutil.getactivemenuselection(event); final istructuredselection selection = (istructuredselection) sel; object firstelement = selection.getfirstelement(); if (firstelement instanceof ipackagefragment) { // selected fragment ipackagefragment packagefragment = (ipackagefragment) firstelement; modelpackage = packagefragment.getelementname(); boolean =!projectresourcehelper.isentitybasepackage(modelpackage); if(a == true){ messagedialog.openinformation(shell, "warning", "please click entity base package"); shell shell = handlerutil.getactiveshell(event); greenwizard wizard = new greenwizard(); wizarddialog dialog = new wizarddialog( part.getsite().getshell(), wizard); dialog.create(); dialog.open(); return null; } try{ window.run(true, true, new irunnablewithprogress(){ @override public void run(iprogressmonitor monitor) throws invocationtargetexception, interruptedexception { monitor.begintask("layer codes being generated...", 1); // invocation of generate layers method monitor.worked(1); // done operation completion. monitor.done(); } }); } catch(invocationtargetexception ite){ messagedialog.openerror(shell, "greenfield code generation exception", ite.getmessage()); } catch (interruptedexception ie) { messagedialog.openerror(shell, "greenfield code generation exception", ie.getmessage()); } }
i have main wizard class called within method.
greenwizard wizard = new greenwizard();
and main wizard in return calls wizard page need selection performed on right click user.
my wizardpageclass
public generategreenfieldlayer(iworkbench workbench, istructuredselection selection) { super("greenfield"); setimagedescriptor(resourcemanager .getimagedescriptor("\\icons\\greenfield-new-wiz.png")); settitle("greenfield generate layer"); setdescription("select specfic class grenerate layers"); } /** * create contents of wizard. * * @param parent */ @override public void createcontrol(composite parent) { composite container = new composite(parent, swt.null); setcontrol(container); container.setlayout(new gridlayout(2, false)); final checkboxtreeviewer treeviewer = new checkboxtreeviewer(container, swt.border); tree = treeviewer.gettree(); tree.settooltiptext("choose package"); griddata gd_tree = new griddata(swt.fill, swt.fill, true, true, 1, 1); gd_tree.widthhint = 280; gd_tree.heighthint = 140; tree.setlayoutdata(gd_tree); treeviewer.setcontentprovider(new greenfieldtreecontentprovider()); treeviewer.setlabelprovider(new workbenchlabelprovider()); treeviewer.addselectionchangedlistener(new iselectionchangedlistener () { public void selectionchanged(selectionchangedevent event) { } }); }
can please guide me how selection object method , pass treeviewer initial input in wizard page.
please correct me if missing steps new this.
thanks in advance
you should separate code following pieces , dataflows:
- handler: selection , create wizard , wizard dialog (as already)
- handler->wizard: use wizard's constructor or custom
init(foo)
method (which call handler) set selected object (or whatever want pass initial data) handler - wizard->wizardpage: when creating wizard, instantiate wizardpage(s) , pass selection wizard pages. (if need more complex model shared between wizard , pages consider creating instantiating simple value-holder class wizard model; i.e., simple java class data , getters/setters. object can shared across pages if pass every page's constructor)
- wizardpage: create ui wizard page, let user modify model
- wizardpage->wizard: if not use shared wizard model via value-holder class, have
getxxx()
method let wizard access user's input page - wizard: implement
wizard.performfinish()
work @ end of wizard usinggetcontainer().run()
instead of havingwindow.run()
call in handler.
Comments
Post a Comment