try {
rb.sendRequest( null, new RequestCallback() {
@Override
public void onError( Request request, Throwable exception ) {
MessageDialogBox dialogBox = new MessageDialogBox( Messages.getString( "error" ), exception.getMessage(), //$NON-NLS-1$ //$NON-NLS-2$
false, false, true );
dialogBox.center();
}
@Override
public void onResponseReceived( Request request, Response response ) {
if ( response.getStatusCode() == 200 ) {
JsArray<JsCreateNewConfig> jsarray = parseJson( JsonUtils.escapeJsonForEval( response.getText() ) );
final ArrayList<JsCreateNewConfig> sorted = new ArrayList<JsCreateNewConfig>();
for ( int i = 0; i < jsarray.length(); i++ ) {
sorted.add( jsarray.get( i ) );
}
Collections.sort( sorted, new JsCreateNewConfigComparator() );
popup.setStyleName( "newToolbarDropdown" );
VerticalPanel buttonPanel = new VerticalPanel();
popup.add( buttonPanel );
for ( int i = 0; i < sorted.size(); i++ ) {
final int finali = i;
Button button = new Button( Messages.getString( sorted.get( i ).getLabel() ) );
button.setStyleName( "pentaho-button" );
button.getElement().addClassName( "newToolbarDropdownButton" );
button.addClickHandler( new ClickHandler() {
public void onClick( ClickEvent event ) {
if (sorted.get( finali ).getActionUrl().startsWith("javascript:")) {
doEvalJS(sorted.get( finali ).getActionUrl().substring("javascript:".length()));
} else {
SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(
Messages.getString( sorted.get( finali ).getTabName() ),
Messages.getString( sorted.get( finali ).getTabName() ), sorted.get( finali ).getActionUrl(),
false );
}
popup.hide();
}
} );
String name = sorted.get( i ).getName();
if ("data-access".equals(name)) {
buttonPanel.add(new HTML("<hr style='color: #a7a7a7' />"));
}
buttonPanel.add( button );
}
popup.setPopupPosition( anchorWidget.getAbsoluteLeft(), anchorWidget.getAbsoluteTop()
+ anchorWidget.getOffsetHeight() );
popup.show();
} else {
MessageDialogBox dialogBox =
new MessageDialogBox( Messages.getString( "error" ), Messages.getString( "error" ), //$NON-NLS-1$ //$NON-NLS-2$
false, false, true );
dialogBox.center();
}
}
} );
} catch ( RequestException e ) {
MessageDialogBox dialogBox = new MessageDialogBox( Messages.getString( "error" ), e.getMessage(), //$NON-NLS-1$ //$NON-NLS-2$
false, false, true );
dialogBox.center();
}
}