Set<JsJob> selectedJobs = getSelectedJobs();
if ( selectedJobs != null && selectedJobs.size() > 0 ) {
MessageDialogBox messageDialog =
new MessageDialogBox( Messages.getString( "executeNow" ), Messages.getString( "executeNowStarted" ),
false, true, true );
messageDialog.setCallback( new IDialogCallback() {
public void okPressed() {
// wait a little to refresh to give schedule time to update the last run
Timer t = new Timer() {
public void run() {
refresh();
}
};
t.schedule( 2000 );
}
public void cancelPressed() {
}
} );
messageDialog.center();
controlJobs( selectedJobs, "triggerNow", RequestBuilder.POST, false );
}
}
} );
triggerNowButton.setEnabled( false );
bar.add( triggerNowButton );
// Add control schedule button
controlScheduleButton.setCommand( new Command() {
public void execute() {
Set<JsJob> selectedJobs = getSelectedJobs();
if ( selectedJobs != null && selectedJobs.size() > 0 ) {
JsJob[] jobs = selectedJobs.toArray( new JsJob[selectedJobs.size()] );
if ( "NORMAL".equals( jobs[0].getState() ) ) {
controlJobs( selectedJobs, "pauseJob", RequestBuilder.POST, false );
} else {
controlJobs( selectedJobs, "resumeJob", RequestBuilder.POST, false );
}
}
}
} );
controlScheduleButton.setEnabled( false );
bar.add( controlScheduleButton );
bar.addSpacer( 20 );
// Add edit button
editButton.setCommand( new Command() {
public void execute() {
Set<JsJob> selectedJobs = getSelectedJobs();
if ( selectedJobs != null && selectedJobs.size() > 0 ) {
JsJob[] jobs = selectedJobs.toArray( new JsJob[selectedJobs.size()] );
final JsJob editJob = jobs[0];
final String url =
GWT.getHostPageBaseURL() + "api/repo/files/"
+ SolutionBrowserPanel.pathToId( editJob.getFullResourceName() ) + "/canAccess?cb="
+ System.currentTimeMillis() + "&permissions=" + READ_PERMISSION;
RequestBuilder executableTypesRequestBuilder = new RequestBuilder( RequestBuilder.GET, url );
try {
executableTypesRequestBuilder.setHeader( "If-Modified-Since", "01 Jan 1970 00:00:00 GMT" );
executableTypesRequestBuilder.sendRequest( null, new RequestCallback() {
public void onError( Request request, Throwable exception ) {
promptForScheduleResourceError( editJob );
}
public void onResponseReceived( Request request, Response response ) {
if ( "true".equalsIgnoreCase( response.getText() ) ) {
editJob( editJob );
} else {
promptForScheduleResourceError( editJob );
}
}
} );
} catch ( RequestException e ) {
// showError(e);
}
}
}
} );
editButton.setEnabled( false );
editButton.setToolTip( Messages.getString( "editTooltip" ) );
bar.add( editButton );
// Add remove button
scheduleRemoveButton.setCommand( new Command() {
public void execute() {
Set<JsJob> selectedJobs = getSelectedJobs();
if ( selectedJobs != null && selectedJobs.size() > 0 ) {
final PromptDialogBox prompt =
new PromptDialogBox( Messages.getString( "warning" ), Messages.getString( "yes" ), Messages
.getString( "no" ), false, true );
prompt.setContent( new Label( Messages.getString( "deleteConfirmSchedles", "" + selectedJobs.size() ) ) );
prompt.setCallback( new IDialogCallback() {
public void okPressed() {
controlJobs( getSelectedJobs(), "removeJob", RequestBuilder.DELETE, true );
prompt.hide();
}