I've got an Eclipse RCP application and a strange behaviour while using a wizard page. Following situation:
I've got a wizard page which is part of a multi-page-wizard. At this page I override the createContent(...) method to create my widgets, etc. After creating my widgets 2 private methods addListeners() and init() are called which initializes my widgets out of the model and add some listeners (e.g. a ModifyListener). The obscure behaviour is the following: When I first call init() and after that call addListeners() everything works fine. But if I do it the vice versa I got a NullPointerException in the WizardDialog.updateButtons() method which is part of RCP framework: There is a variable called currentPage as the following code excerpt shows. This variable causes the NPE mentioned above. If I do it the right way, the variable is correctly set.
...
if (backButton != null) {
backButton.setEnabled(currentPage.getPreviousPage() != null);
}
...
I don't get this behaviour. Can someony explain it to me? Within the 2 private methods mentioned above no framework-calls are done. Maybe it's some timing issue?
Best regards,
AnarchoEnte
Related
I am using geoserver. I extended ContentDataStore plugin to add csv data types as layers. I am using geoserver rest api, HTTPUtils.put method actually. When I do this the datastore gets created without boundingbox defined, unlike when it is created manually on geoserver web application. Therefore I get an exception when I try to use wms-getCapabilities method, because there is no boundingbox defined.
The getCapabilities query is below:
localhost:8090/geoserver/wms?Service=WMS&Version=1.1.1&Request=GetCapabilities
The inner exception is below:
Caused by: java.lang.NullPointerException
at org.geoserver.wms.capabilities.GetCapabilitiesTransformer$CapabilitiesTranslator.handleLatLonBBox(GetCapabilitiesTransformer.java:1349)
at org.geoserver.wms.capabilities.GetCapabilitiesTransformer$CapabilitiesTranslator.handleLayer(GetCapabilitiesTransformer.java:901)
at org.geoserver.wms.capabilities.GetCapabilitiesTransformer$CapabilitiesTranslator.handleLayerTree(GetCapabilitiesTransformer.java:826)
... 90 more
Is there a way to define boundingbox for a datastore/layer in xxxDataStore or xxxDataStoreFactory classes. So far I couldn't find any way to define while creating the datastore.
Thanks in advance
I found the answer to it. I changed 2 classes. The first one is xxxFeatureSource which extends ContentFeatureSource (it's in ContentDataStore plugin) and the second one is DataStoreFileResource.
In xxxFeatureSource I overrided ReferencedEnvelope getBoundsInternal() method and implemented code which calculates my boundingBox.
In DataStoreFileResource I added this line;
ftInfo.setLatLonBoundingBox( bounds );
into the void handlePut() method, right after ftInfo.setNativeBoundingBox( bounds ).
Now I can use getCapabilities method after adding my DataStore via GeoServer rest api.
Hope it helps others too.
I am creating an RCP application using Eclipse 4.4.1 with the Compatibility Layer (migration from 3.x to 4.x). I have defined menus in the application model. Menus are displaying properly when the application is launched for the first time, but restarting the application is hiding the menu bar completely and only showing the toolbar.
Why might no menus be displaying when the RCP Application is restored?
This sounds like this bug here that I just recently myself encountered:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388808
Personally, the workaround in the bug report did not exactly work for me (it may for you however). What did work for me was based off of the final post here by Karl Puperze, (slightly modified):
https://www.eclipse.org/forums/index.php/t/446433/
public class ForceMainMenuProcessor
{
#Execute
public void execute(#Optional MApplication application, #Optional EModelService modelService)
{
MTrimmedWindow window = (MTrimmedWindow)
modelService.find("<id of your main trimmed window>", application);
if (window == null || window.getMainMenu() != null)
{ return; }
final MMenu mainMenu = modelService.createModelElement(MMenu.class);
mainMenu.setElementId("org.eclipse.ui.main.menu");
window.setMainMenu(mainMenu);
}
}
From that, the last steps were to make sure I defined (with no content) a menu in the main e4xmi file that had the org.eclipse.ui.main.menu id, then defined a fragment that contained the menu contents.
To the plugin.xml, added to the org.eclipse.e4.workbench.model extension point a fragment that pointed to the .e4xmi model fragment that was just created and set the 'apply' to always.
Finally, to the same extension point, added a processor and pointed it to the class above. beforefragment was true and apply was always.
The e4xmi files were still used to define the menu, but in code, because of the defined processor above, the menu is forced to appear regardless of whatever persistent state was saved in the workspace. I ended up with this solution after already splitting the menu into a separate model fragment, so I am not sure if that part of the solution is definitely required, but most certainly defining the processor is.
I am looking to add a ContextMenu to a TreeViewer following the example set out here: http://www.vogella.com/articles/EclipseCommands/article.html#contextmenu however I get a NPE at the line
getSite().registerContextMenu(menuManager, viewer);
getSite() returns null rather than the IWorkbenchPartSite. Can anyone explain why the IWorkbenchPartSite is null or how I could initialise it?
Any help is appreciated.
There is no method getSite() in preference pages. So I assume you are in an editor or a view.
The site is injected by the platform using the init method. When you call getSite() you have to make sure that you do it after the platform has called the init method.
A good place for context menu registration is the createPartControl method.
To summarize the answer shown here Code assist in (jsp /jstl) view for Spring MVC model objects in Eclipse
is not working for me at all, is there a setting that I need to change ?
I have just downloaded the sample spring-mvc-showcase on github, and it doesn't work out of the box on that project (with either 11.1.3 or EAP 12 version both full enterprise editions), see below (I have no idea where it gets formBean from) :
Here is an example from my own project,the screen shot below (bottom frame) shows my controller adding a string attribute to model and returning correct view name. I would then expect shopString to be offered up as autocomplete option when editing that view, however it is not :
sg is a javascript variable - so great it should be there, but where is "shopString" ?.
Is there a setting I need to change or something else I am missing to get this functionality (using 11.1.3 enterprise edition with all the spring plugins).
It is also failing on spring specific variables :
IS their an open source (one of the spring tutorial projects?) where this definitely works ... or is there a setting I need change in my Intellij install (I have tested with a brand new download of the version 12 EAP) ?
One more screenshot below shows all my spring coifg files set up correctly via autodetection, but the code inspections fails ... this is the spring-mvc-showcase project :
There's a standard way to do this, which is not IntelliJ-specific.
<jsp:useBean id="someModel" scope="request" type="foo.bar.SomeModelClass"/>
The type attribute here does not need to be a concrete class, it can be an interface type as well. Typically you'd put these declarations at the start of your JSP/JSPX files, to provide something like a "declaration of model inputs".
Using JSPs in such a declarative way was recommended in the original book on Spring, in fact (Expert One-on-One J2EE Design and Development.). IntelliJ has been providing full code completion for such pages since at least 7 years.
Note that there are additional relevant convenience features in IntelliJ: if an EL variable reference is marked as undefined, you can press Alt-Enter to select a QuickFix, which will insert a declaration like above. It will even try to figure out the actual type, based on the properties you're accessing.
As I understand Spring, there is no declaration for definitions of variables that you may put into your model. The call model.addAttribute() may add an object to the model, either identified by a parameter or automatically generated by the class name of the object.
So imagine the following case where you have more than one method:
#RequestMapping("foo") public String foo(Model model) {
model.addAttribute("model", new Foo());
return new Random().nextBoolean() ? "page" : "someOtherPage";
}
#RequestMapping("bar") public String bar(Model model) {
model.addAttribute("model", new Bar());
model.addAttribute("model", new Foo());
model.addAttribute("model", new Bar());
return new Random().nextBoolean() ? "page" : "someOtherPage";
}
and the JSP would be something like
<c:out ${model.value} />
Since there is no proper mapping of which controllers may under some circumstances forward to which views, nor what exactly lies within the model, your IDE has no real chance to provide you with proper information.
But to support the IDE in suggesting you some useful information, you can use type hints. Therefore, you have to copy the whole reference of an object, e. g. foo and add a JSP comment like:
<%--#elvariable id="foo" type="com.mycompany.SomeObject"--%>
The warning will vanish and the full IDE support is on your side, allowing you to traverse the fields of foo.
One of the nicest things is that the unused getter warnings will vanish, too. You can directly call the show usages action directly from the JSP or the POJO.
This also works with JSF and particularly within JSF components. Pretty neat feature to have this kind of code completion, showing warnings and errors.
Hope that helps you with your switch to Intellij Idea.
Edit: I also reported this finding to a friend wo wrapped the whole thing into a nice blog entry. Maybe you're interested in reading it: open link
This got fixed in the latest release of intellij 122.694
I faced with similar issue when start writing my own interceptor. Problem was that I start using refference in my view resolver configuration
don't use contruction like this
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" ref="prefix"/>
<property name="suffix" ref="suffix"/>
</bean>-
I have created a stateless component in Wicket 1.5, by extending the component and giving the #StatelessComponent annotation,
I was trying to check the component being stateful/stateless with the StatelessChecker.
But i am not able to check, here is the code which i was trying .
#StatelessComponent
public class StatelessText extends TextField
//Client Class
StatelessText test = new StatelessText("test");
StatelessChecker sc = new StatelessChecker();
sc.onBeforeRender(test);
I dont see anything on console or any exceptions/errors.
Maybe i am not using the correct way, Can anybody please guide me here.
Appreciate the Help.
you have to register the StatelessChecker during the init of the WicketApplication.
/**
* #see org.apache.wicket.Application#init()
*/
#Override
public void init() {
super.init();
// might want to check if you're in dev mode or not...
getComponentPreOnBeforeRenderListeners().add(new StatelessChecker());
}
You dont need to explicitly call the Statelesschecker in your class. As Throsten said you need to add that in your WebApplications init and annotate your - class to be checked - as Statelesscomponent. If your Application is confidured to be in development mode in you web.xml you will get a runtime error when calling this page if it is Statefull.
Im not sure I understood what you are trying to do there. why are you holding an instance of your class in itself? are you trying to build a singleton? And what purpose does StatelessText has anyway? the Textfield in an usual form will be Stateless as long theres no explicitly added Ajax behaviour to it.