nowTextBox.getElement().getStyle().setMarginLeft( 5, Unit.PX );
nowTextBox.getElement().getStyle().setMarginRight( 5, Unit.PX );
final TextBox scheduleTextBox = new TextBox();
scheduleTextBox.setVisibleLength( 4 );
JsJob tmpJsJob = parseJsonJob( JsonUtils.escapeJsonForEval( response.getText() ) );
boolean fakeJob = false;
if ( tmpJsJob == null ) {
tmpJsJob = createJsJob();
fakeJob = true;
}
final JsJob jsJob = tmpJsJob;
if ( jsJob != null ) {
scheduleTextBox.setValue( "" + ( Long.parseLong( jsJob.getJobParamValue( "age" ) ) / 86400L ) );
} else {
scheduleTextBox.setText( "180" );
}
scheduleTextBox.addChangeHandler( new ChangeHandler() {
public void onChange( ChangeEvent event ) {
if ( jsJob != null ) {
JsArray<JsJobParam> params = jsJob.getJobParams();
for ( int i = 0; i < params.length(); i++ ) {
if ( params.get( i ).getName().equals( "age" ) ) {
params.get( i ).setValue( "" + ( Long.parseLong( scheduleTextBox.getText() ) * 86400L ) );
break;
}
}
}
}
} );
Label settingsLabel = new Label( Messages.getString( "settings" ) );
settingsLabel.setStyleName( "pentaho-fieldgroup-major" );
add( settingsLabel, DockPanel.NORTH );
VerticalPanel nowPanelWrapper = new VerticalPanel();
Label deleteNowLabel = new Label( Messages.getString( "deleteGeneratedFilesNow" ) );
deleteNowLabel.getElement().getStyle().setPaddingTop( 15, Unit.PX );
deleteNowLabel.setStyleName( "pentaho-fieldgroup-minor" );
nowPanelWrapper.add( deleteNowLabel );
HorizontalPanel nowLabelPanel = new HorizontalPanel();
nowLabelPanel.getElement().getStyle().setPaddingTop( 10, Unit.PX );
nowLabelPanel.getElement().getStyle().setPaddingBottom( 10, Unit.PX );
Label deleteGeneratedFilesOlderThan = new Label( Messages.getString( "deleteGeneratedFilesOlderThan" ) );
deleteGeneratedFilesOlderThan.getElement().getStyle().setPaddingTop( 7, Unit.PX );
nowLabelPanel.add( deleteGeneratedFilesOlderThan );
nowLabelPanel.add( nowTextBox );
nowTextBox.setText( "180" );
Label days = new Label( Messages.getString( "daysDot" ) );
days.getElement().getStyle().setPaddingTop( 7, Unit.PX );
nowLabelPanel.add( days );
Button deleteNowButton = new Button( Messages.getString( "deleteNow" ) );
deleteNowButton.setStylePrimaryName( "pentaho-button" );
deleteNowButton.addStyleName( "first" );
deleteNowButton.addClickHandler( new ClickHandler() {
public void onClick( ClickEvent event ) {
deleteContentNow( Long.parseLong( nowTextBox.getValue() ) * 86400L );
}
} );
nowPanelWrapper.add( nowLabelPanel );
nowPanelWrapper.add( deleteNowButton );
add( nowPanelWrapper, DockPanel.NORTH );
// scheduled
VerticalPanel scheduledPanel = new VerticalPanel();
Label deleteScheduleLabel = new Label( Messages.getString( "scheduleDeletionOfGeneratedFiles" ) );
deleteScheduleLabel.setStyleName( "pentaho-fieldgroup-minor" );
deleteScheduleLabel.getElement().getStyle().setPaddingTop( 15, Unit.PX );
scheduledPanel.add( deleteScheduleLabel );
Label descLabel;
if ( !fakeJob ) {
String desc = jsJob.getJobTrigger().getDescription();
descLabel = new Label( desc );
scheduledPanel.add( descLabel );
} else {
descLabel = new Label( Messages.getString( "generatedFilesAreNotScheduledToBeDeleted" ) );
scheduledPanel.add( descLabel );