java - Perspective not loading in RCP when tried more than one -
i creating rcp application. have view class newview.
public class newview extends viewpart { private databindingcontext m_bindingcontext; public static final string id = "com.app.editor.newview"; savenewfilebean bean = new savenewfilebean(); private styledtext text; public newview() { } @override public void createpartcontrol(composite parent) { text = new styledtext(parent, swt.border); m_bindingcontext = initdatabindings(); } public string returntext(){ string textdata = bean.gettext(); return textdata; } @override public void setfocus() { } protected databindingcontext initdatabindings() { databindingcontext bindingcontext = new databindingcontext(); // iobservablevalue observetexttextobservewidget = widgetproperties.text(swt.modify).observe(text); iobservablevalue textbeanobservevalue = pojoproperties.value("text").observe(bean); bindingcontext.bindvalue(observetexttextobservewidget, textbeanobservevalue, null, null); // return bindingcontext; } }
when running application first time, click on new menu , everything working fine. but, when trying load again clicking on new again, doesn't give error. but, doesn't load perspective also. there issue code?
thanks!
edit: new command. new calls handler newfilehandler in turn calls newview.java using below code.
public class newfilehandler extends abstracthandler { @override public object execute(executionevent event) throws executionexception { switchperspectiveaction action = new switchperspectiveaction(); action.run(newfileperspective.id); return null; } }
switchperspectiveasction class
public class switchperspectiveaction extends action { public void run(string newperspectiveid) { if (platformui.getworkbench() != null) { try { platformui.getworkbench().showperspective(newperspectiveid, platformui.getworkbench().getactiveworkbenchwindow()); } catch (workbenchexception e) { e.printstacktrace(); } } } }
edit:
i tried code.
iworkbenchpage page = platformui.getworkbench().getactiveworkbenchwindow().getactivepage(); try { page.showview(openfileperspective.id, "1" , iworkbenchpage.view_activate); } catch (partinitexception e) { // todo auto-generated catch block e.printstacktrace(); }
gives error.
org.eclipse.ui.partinitexception: not create view: com.app.editor.openfileperspective:1 @ org.eclipse.ui.internal.workbenchpage.busyshowview(workbenchpage.java:1275) @ org.eclipse.ui.internal.workbenchpage$14.run(workbenchpage.java:4208) @ org.eclipse.swt.custom.busyindicator.showwhile(busyindicator.java:70) @ org.eclipse.ui.internal.workbenchpage.showview(workbenchpage.java:4204) @ com.app.editor.handlers.openhandler.execute(openhandler.java:66) @ org.eclipse.ui.internal.handlers.handlerproxy.execute(handlerproxy.java:294) @ org.eclipse.ui.internal.handlers.e4handlerproxy.execute(e4handlerproxy.java:90) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.eclipse.e4.core.internal.di.methodrequestor.execute(methodrequestor.java:55) @ org.eclipse.e4.core.internal.di.injectorimpl.invokeusingclass(injectorimpl.java:247) @ org.eclipse.e4.core.internal.di.injectorimpl.invoke(injectorimpl.java:229) @ org.eclipse.e4.core.contexts.contextinjectionfactory.invoke(contextinjectionfactory.java:132) @ org.eclipse.e4.core.commands.internal.handlerservicehandler.execute(handlerservicehandler.java:149) @ org.eclipse.core.commands.command.executewithchecks(command.java:499) @ org.eclipse.core.commands.parameterizedcommand.executewithchecks(parameterizedcommand.java:508) @ org.eclipse.e4.core.commands.internal.handlerserviceimpl.executehandler(handlerserviceimpl.java:210) @ org.eclipse.e4.ui.workbench.renderers.swt.handledcontributionitem.executeitem(handledcontributionitem.java:825) @ org.eclipse.e4.ui.workbench.renderers.swt.handledcontributionitem.handlewidgetselection(handledcontributionitem.java:701) @ org.eclipse.e4.ui.workbench.renderers.swt.handledcontributionitem.access$6(handledcontributionitem.java:685) @ org.eclipse.e4.ui.workbench.renderers.swt.handledcontributionitem$4.handleevent(handledcontributionitem.java:613) @ org.eclipse.swt.widgets.eventtable.sendevent(eventtable.java:84) @ org.eclipse.swt.widgets.display.sendevent(display.java:4353) @ org.eclipse.swt.widgets.widget.sendevent(widget.java:1061) @ org.eclipse.swt.widgets.display.rundeferredevents(display.java:4172) @ org.eclipse.swt.widgets.display.readanddispatch(display.java:3761) @ org.eclipse.e4.ui.internal.workbench.swt.partrenderingengine$9.run(partrenderingengine.java:1151) @ org.eclipse.core.databinding.observable.realm.runwithdefault(realm.java:332) @ org.eclipse.e4.ui.internal.workbench.swt.partrenderingengine.run(partrenderingengine.java:1032) @ org.eclipse.e4.ui.internal.workbench.e4workbench.createandrunui(e4workbench.java:148) @ org.eclipse.ui.internal.workbench$5.run(workbench.java:636) @ org.eclipse.core.databinding.observable.realm.runwithdefault(realm.java:332) @ org.eclipse.ui.internal.workbench.createandrunworkbench(workbench.java:579) @ org.eclipse.ui.platformui.createandrunworkbench(platformui.java:150) @ com.app.editor.application.start(application.java:20) @ org.eclipse.equinox.internal.app.eclipseapphandle.run(eclipseapphandle.java:196) @ org.eclipse.core.runtime.internal.adaptor.eclipseapplauncher.runapplication(eclipseapplauncher.java:134) @ org.eclipse.core.runtime.internal.adaptor.eclipseapplauncher.start(eclipseapplauncher.java:104) @ org.eclipse.core.runtime.adaptor.eclipsestarter.run(eclipsestarter.java:380) @ org.eclipse.core.runtime.adaptor.eclipsestarter.run(eclipsestarter.java:235) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.eclipse.equinox.launcher.main.invokeframework(main.java:648) @ org.eclipse.equinox.launcher.main.basicrun(main.java:603) @ org.eclipse.equinox.launcher.main.run(main.java:1465) @ org.eclipse.equinox.launcher.main.main(main.java:1438)
showperspective
doesn't if perspective open. can't use open multiple copies of same view.
if want open view use:
iworkbenchpage page = platformui.getworkbench().getactiveworkbenchwindow().getactivepage(); iviewpart viewpart = page.showview("the view id");
note show 1 instance of view @ time.
to close view use:
page.hideview(viewpart);
you can show multiple copies of view using secondary id view:
page.showview("view id", "secondary id", iworkbenchpage.view_activate);
the secondary id not have defined anywhere. needs unique each view want show.
Comments
Post a Comment