use of org.pentaho.mantle.client.commands.AbstractCommand in project pentaho-platform by pentaho.
the class SolutionBrowserPanel method executeActionSequence.
public void executeActionSequence(final FileCommand.COMMAND mode) {
if (filesListPanel.getSelectedFileItems() == null || filesListPanel.getSelectedFileItems().size() != 1) {
return;
}
// open in content panel
AbstractCommand authCmd = new AbstractCommand() {
protected void performOperation() {
performOperation(false);
}
protected void performOperation(boolean feedback) {
final FileItem selectedFileItem = filesListPanel.getSelectedFileItems().get(0);
String url = null;
url = // $NON-NLS-1$ //$NON-NLS-2$
"api/repo/files/" + SolutionBrowserPanel.pathToId(filesListPanel.getSelectedFileItems().get(0).getRepositoryFile().getPath()) + "/generatedContent";
url = getPath() + url;
if (mode == FileCommand.COMMAND.BACKGROUND) {
MessageDialogBox dialogBox = new // $NON-NLS-1$
MessageDialogBox(// $NON-NLS-1$
Messages.getString("info"), // $NON-NLS-1$
Messages.getString("backgroundExecutionWarning"), true, false, true);
dialogBox.center();
// $NON-NLS-1$
url += "&background=true";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
try {
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("couldNotBackgroundExecute"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
true);
dialogBox.center();
}
public void onResponseReceived(Request request, Response response) {
}
});
} catch (RequestException e) {
// ignored
}
} else if (mode == FileCommand.COMMAND.NEWWINDOW) {
// popup blockers might attack this
// $NON-NLS-1$ //$NON-NLS-2$
Window.open(url, "_blank", "menubar=yes,location=no,resizable=yes,scrollbars=yes,status=no");
} else if (mode == FileCommand.COMMAND.SUBSCRIBE) {
// $NON-NLS-1$
final String myurl = url + "&subscribepage=yes";
contentTabPanel.showNewURLTab(selectedFileItem.getLocalizedName(), selectedFileItem.getLocalizedName(), myurl, true);
} else {
contentTabPanel.showNewURLTab(selectedFileItem.getLocalizedName(), selectedFileItem.getLocalizedName(), url, true);
}
}
};
authCmd.execute();
}
use of org.pentaho.mantle.client.commands.AbstractCommand in project pentaho-platform by pentaho.
the class MantleXul method fetchPluginOverlays.
private void fetchPluginOverlays() {
AbstractCommand cmd = new AbstractCommand() {
protected void performOperation(boolean feedback) {
performOperation();
}
protected void performOperation() {
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "api/plugin-manager/overlays";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
builder.setHeader("accept", "application/json");
try {
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
Window.alert(exception.getMessage());
}
public void onResponseReceived(Request request, Response response) {
JsArray<JsXulOverlay> jsoverlays = JsXulOverlay.parseJson(JsonUtils.escapeJsonForEval(response.getText()));
ArrayList<XulOverlay> overlays = new ArrayList<XulOverlay>();
for (int i = 0; i < jsoverlays.length(); i++) {
JsXulOverlay o = jsoverlays.get(i);
MantleXulOverlay overlay;
overlay = new MantleXulOverlay(o.getId(), o.getOverlayUri(), o.getSource(), o.getResourceBundleUri(), Integer.parseInt(o.getPriority()));
overlays.add(overlay);
}
MantleXul.this.addOverlays(overlays);
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "plugin/data-access/api/permissions/hasDataAccess";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
builder.setHeader("accept", "application/json");
try {
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
Window.alert(exception.getMessage());
}
public void onResponseReceived(Request request, Response response) {
if (response.getText().equals("true")) {
controller.loadOverlay("dataaccess");
}
}
});
} catch (RequestException e) {
// showError(e);
}
}
});
} catch (RequestException e) {
// showError(e);
}
}
};
cmd.execute();
}
Aggregations