EXT-GWT Portal: How to get all Portlets? - java

Hi all this is my first Question here!
Im just making my first steps with (Ext-) GWT. I´m testing the Ext-GWT libraries and really: These are absolute great!
Now my question:
Is it possible to make a kind of "clear-Portal" or "hide all portles" for a defined Portal?
Or have i always manually clear the portal like in my example code above?
My sample code looks like this:
//define the Portal, 2 columns, each 50% auf width, with borders and Backgroundcolor
portal = new Portal(2);
portal.setBorders(true);
portal.setStyleAttribute("backgroundColor", "white");
portal.setColumnWidth(0, .50);
portal.setColumnWidth(1, .50);
//define a Portlet for showing all Users
portletUser = new Portlet();
portletUser.setHeading("Benutzer");
configPanel(portletUser);
portletUser.setLayout(new FitLayout());
CompUserList compUserList = new CompUserList();
portletUser.add(compUserList);
portletUser.setHeight(250);
//define a Portlet for showing all Vehicles
portletVehicles = new Portlet();
portletVehicles.setHeading("Fahrzeuge");
configPanel(portletVehicles);
portletVehicles.setLayout(new FitLayout());
CompVehicleList compVehicleList = new CompVehicleList();
portletVehicles.add(compVehicleList);
portletVehicles.setHeight(250);
//define a portlet for showing all countries
portletCountries = new Portlet();
portletCountries.setHeading("Länder");
configPanel(portletCountries);
portletCountries.setLayout(new FitLayout());
CompCountryList compCountryList = new CompCountryList();
portletCountries.add(compCountryList);
portletCountries.setHeight(250);
//add both Portlets to Portal
portal.add(portletUser, 0);
portal.add(portletVehicles, 1);
So first of all this works fine and looks great :-)
Now i have a a button in a accordeon menu. The Listener on this button should hide all portlets in the portal (at this time its the portletUser and portletVehicles) and then add another portlet (for example the portletCountries):
portletUser.hide();
portletVehicles.hide();
portal.add(portletCountries, 0)
Question from above again ;-)
Is it possible to make a kind of "clear-Portal" or "hide all portles" for a defined Portal?
Or have i always manually clear the portal like in my example code above?
What is the best practice for this functionallity?
Thanks all for your tips!
Lars.

I haven't used Ext-GWT -- but looking at the Javadoc for Portal there are two things I would try:
for (LayoutContainer c : portal.getItems()) {
c.hide();
}
or, more generally, wrap a Portal in your own class which records the Portlets which are in the Portal -- then you can get a List rather than List.

Related

How to write JellyTools functional tests?

I managed to set up JellyTools in my Java project in Netbeans Platform. Now I would like to write some functional tests with it but I can't find any tutorials about JellyTools apart from this:
http://wiki.netbeans.org/JellyTools
Can anyone give me some tips about it or post some other tutorials?
I would like to write a text in a textfield for example and then press the button "Next" in a wizard but I couldn't manage to do it with the tutorial above.
I resolved my own question about writing a text in a wizard and then press "Next". This way I can create a project automaticaly in my application:
Action action = new Action("File|New Project", null);
action.perform();
WizardOperator wo = new WizardOperator("New Project");
wo.next();
JTextFieldOperator txtName = new JTextFieldOperator(
(JTextField) new JLabelOperator(wo, "Project Name:").getLabelFor());
txtName.clearText();
txtName.typeText("MyProject");
wo.finish();
Adrian,
Jelly tools is intended to create UI tests for Netbeans IDE itself, so it is not expected to use it for test Your UI. You can try Jemmy module which is also base layer for Jelly.
You can see some Jemmy tutorials there: https://jemmy.java.net/tutorial.html
Hope this helps.

How to use PDFBox to create a link that goes to *previous view*?

By using PDFBox, it is easy to create a link that goes a particular page or page view by using PDPageDestination. For example, the following code will make a link that goes to page 9:
PDAnnotationLink link = new PDAnnotationLink();
PDPageDestination destination = new PDPageFitWidthDestination();
PDActionGoTo action = new PDActionGoTo();
destination.setPage(document.getPage(9));
action.setDestination(destination);
link.setAction(action);
Problem:
Instead of going to a particular page, I would like to go to the previous view.
For example, suppose in a PDF file, each of P.1 and P.2 has a link that goes to P. 9. Now I would like to put on P. 9 a link that goes back to where the user started.
If the user started out at P.1 and clicked the link to P.9, he arrives at P.9. When he clicks the link on P. 9, he will go back to P.1, where he came from. But If he started out at P.2, then the link at P.9 will go back to P.2 instead.
Question: How do I achieve this with PDFBox?
FYI, with Adobe Acrobat, this can be achieved by adding an "execute a menu item" action to a link, and then choosing "Previous View" as the menu item, as shown in this screenshot:
Link to Acrobat screenshot
With the guidance of Tilman, I managed to solve my own problem.
I cannot find a PDAction subclass that gives me the capability to add a "named action", so I created my own subclass, "PDActionNamed":
class PDActionNamed extends PDAction {
public static final String SUB_TYPE = "Named";
public PDActionNamed() {
super();
setSubType( SUB_TYPE );
}
public void setN( String s ) {
action.setName( "N", s );
}
}
To use the subclass,
PDAnnotationLink link = new PDAnnotationLink();
PDActionNamed action = new PDActionNamed ();
action.setN("GoBack"); // this is one of Acrobat's default named action
link.setAction(action);
It seems to work even on non-Javascript-supported PDF readers (e.g. SumatraPDF).
What you're talking about is a viewer dependant action; I don't think there is a way to do this generically but there should be ways to do this in Adobe Acrobat / Adobe Reader.
One such way is to insert a link that triggers an Action. The action could be a Javascript action and the Javascript could be relatively simple as the Acrobat Javascript API contains an "app" method called "goBack".
So, insert a link as you're doing right now. Insert not a GoTo action but a Javascript action. And set the Javascript to: "app.goBack()".
This should work in Acrobat (they have a similar example with a button form field in the Acrobat Javascript API reference. The question is whether it will work in other viewers as well and thus whether it will fulfil your business case.

GWT Bootstrap Responsive Design of existing webapp with screens

I have a working web application developed with GWT. Now that it has to resize on a tablet or smaller screens I thought of using GWT Bootstrap. But the existing application has only one project.html and project.css file under war folder. Currently no UI binders are used. There are four screens displaying different charts created by d3js.
My Question is it still possible to use gwt bootstrap for resizing? Or what about only Bootstrap and use the css file without any UI binders?
Which approach is better ? As im confused and have spent couple of hours searching and reading.
If you plan to interact in your GWT app with bootstrap components (i.e. NavBar, Caoursel, etc) then I would go with gwt-bootstrap because you don't have to use JSNI and you get some type safety.
If you don't need to interact those components or you use mostly pure HTML in your GWT app you can also use plain bootstrap and add the corresponding classes.
Edit code example:
UiBinder:
<b:NavPills>
<b:AnchorListItem active="true">Item 1</b:AnchorListItem>
<b:AnchorListItem>Item 2</b:AnchorListItem>
<b:AnchorListItem>Item 3</b:AnchorListItem>
<b:AnchorListItem enabled="false">Item 4</b:AnchorListItem>
<b:AnchorListItem pull="RIGHT">Pulled right</b:AnchorListItem>
</b:NavPills>
Code:
NavPills pills = new NavPills();
AnchorListItem item1 = new AnchorListItem("Item 1");
item1.setActive(true);
pills.add(item1);
pills.add(new AnchorListItem("Item 2");
pills.add(new AnchorListItem("Item 3");
...

Implementing MixedParamUrlCodingStrategy prevents my site from using CSS

I developed an application in Wicket with a CSS-styled left menu. Everything worked fine. Then, to get the URLs to be RESTful, I changed WicketApplication.java to use MixedParamUrlCodingStrategy. From then on, the style stopped working. I don't know where the problem is. I didn't change anything else. Here's my code:
mount("/site",PackageName.forPackage(WelcomePage.class.getPackage()));
//
mount("/download",PackageName.forPackage(AppDownloadApi.class.getPackage()));
// mountBookmarkablePage("push/reg", PushRegApi.class);
mountBookmarkablePage("push/send", PushMessageApi.class);
mountBookmarkablePage("device", DeviceprofileExportAsXML.class);
// mountBookmarkablePage("app/download", AppDownloadApi.class);
// mountBookmarkablePage("ds/export", ExportDataSource.class);
// mountBookmarkablePage("control/export", ExportAsXML.class);
MixedParamUrlCodingStrategy ds = new MixedParamUrlCodingStrategy(
"ds", ExportDataSource.class, new String[]{"name"});
mount(ds);
MixedParamUrlCodingStrategy control = new MixedParamUrlCodingStrategy(
"control", ExportAsXML.class, new String[]{"controlName"});
mount(control);
MixedParamUrlCodingStrategy app = new MixedParamUrlCodingStrategy(
"app", AppDownloadApi.class, new String[]{"appId"});
mount(app);
MixedParamUrlCodingStrategy pushReg = new MixedParamUrlCodingStrategy(
enter code here "push/reg", PushRegApi.class, new String[]{"appName",
"groupName","userName","password","deviceToken"});
mount(pushReg);
If I uncomment the comments, and remove MixedParamUrlCodingStrategy, then everything works fine. How can I have both RESTful URLs and my desired style?
This could be an issue with how you are linking your CSS into the pages. We had a simmilar issue when first starting as we had hardcoded the path to CSS into the page, but then when we changed the mappings of some pages the relative paths to the CSS files were nolonger valid.
I would suggest to use FireBug and check the Net tab to see if the CSS is loading, and if so what the contents of the request returns.
You may need to use something like the CSSPackageResource.getHeaderContributer to link the css to the page correctly.

Resources for data binding with WindowBuilder with SWT/JFace

I just started creating a SWT/JFace application using the (now free) WindowBuilder from Google (previously instantiations).
I find the Data binding part difficult although it -should- make it easier for me.
For instance, I cannot bind the enabling-property of a button to a (myself defined) boolean function.
Are there any resources (demos, text, tutorials, examples) about using the WindowBuilder GUI and/or the data binding principle?
The information found on the google page or the instantiations page did not help me enough.
For what it's worth:
bindingContext.bindValue(
new ComputedValue() {
public Object calculate() {
// calculate the enablement using the value of other, previously
// created observables.
}
},
WidgetProperties.enabled().observe(theButton)
);
The Eclipse newsgroups are a great place to ask these questions. Try the eclipse.platform.jface newsgroup.

Categories

Resources