Skip to content

Commit

Permalink
Merge pull request #456 from UnifiedViews/feature/384_scheduler_gui_c…
Browse files Browse the repository at this point in the history
…hange_access_via_URL

Scheduler GUI is accessible via url
  • Loading branch information
pgo-eea-sk committed Sep 3, 2015
2 parents a135b59 + 5c0434e commit 6d48b6a
Show file tree
Hide file tree
Showing 4 changed files with 1,588 additions and 1,395 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.vaadin.data.Validator;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.event.FieldEvents;
import com.vaadin.server.Page;
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
Expand All @@ -52,17 +53,19 @@
import cz.cuni.mff.xrg.odcs.commons.app.scheduling.Schedule;
import cz.cuni.mff.xrg.odcs.commons.app.scheduling.ScheduleNotificationRecord;
import cz.cuni.mff.xrg.odcs.commons.app.scheduling.ScheduleType;
import cz.cuni.mff.xrg.odcs.frontend.AppEntry;
import cz.cuni.mff.xrg.odcs.frontend.auxiliaries.SimpleTreeFilter;
import cz.cuni.mff.xrg.odcs.frontend.container.ReadOnlyContainer;
import cz.cuni.mff.xrg.odcs.frontend.container.accessor.PipelineNameAccessor;
import cz.cuni.mff.xrg.odcs.frontend.doa.container.InMemorySource;
import cz.cuni.mff.xrg.odcs.frontend.doa.container.db.DbInMemorySource;
import cz.cuni.mff.xrg.odcs.frontend.i18n.Messages;
import cz.cuni.mff.xrg.odcs.frontend.navigation.ParametersHandler;

/**
* Dialog for the scheduling rule creation. Designed for setting the description
* of when the pipeline should be executed.
*
*
* @author Maria Kukhar
*/
public class SchedulePipeline extends Window {
Expand Down Expand Up @@ -182,6 +185,12 @@ public SchedulePipeline() {
this.setResizable(false);
this.setModal(true);
this.setCaption(Messages.getString("SchedulePipeline.schedule"));
this.addCloseListener(new Window.CloseListener() {
@Override
public void windowClose(CloseEvent e) {
resetURL();
}
});
}

/**
Expand All @@ -196,7 +205,7 @@ public void init() {

/**
* Is initialized.
*
*
* @return If is initialized
*/
public boolean isInitialized() {
Expand All @@ -205,7 +214,7 @@ public boolean isInitialized() {

/**
* Sets the corresponding value of Pipeline to the dialog.
*
*
* @param selectedPipeline
*/
public void setSelectePipeline(Pipeline selectedPipeline) {
Expand Down Expand Up @@ -237,7 +246,7 @@ public void setSelectePipeline(Pipeline selectedPipeline) {

/**
* Selects given schedule and displays it.
*
*
* @param selectedSchedule
*/
public void setSelectedSchedule(Schedule selectedSchedule) {
Expand Down Expand Up @@ -314,7 +323,7 @@ public void setSelectedSchedule(Schedule selectedSchedule) {

} //AFTER_PIPELINE type
else {
//setting after_pipeline list
//setting after_pipeline list
Set<Pipeline> after = selectedSchedule.getAfterPipelines();
List<Long> afterNames = new ArrayList<>();
for (Pipeline afteritem : after) {
Expand Down Expand Up @@ -348,7 +357,7 @@ public void setSelectedSchedule(Schedule selectedSchedule) {
/**
* Builds main layout contains pipeline, the type of pipeline scheduling,
* layouts with components for setting each of the type.
*
*
* @return mainLayout GridLayout with all dialog components
*/
@AutoGenerated
Expand Down Expand Up @@ -707,6 +716,7 @@ public void buttonClick(ClickEvent event) {

}
}
resetURL();
close();

}
Expand All @@ -722,6 +732,7 @@ public void buttonClick(ClickEvent event) {

@Override
public void buttonClick(Button.ClickEvent event) {
resetURL();
close();

}
Expand Down Expand Up @@ -789,7 +800,7 @@ public void valueChange(ValueChangeEvent event) {
/**
* Building layout for the AFTER_PIPELINE scheduling type. Calls from {@link #buildMainLayout} in case of {@link #scheduleType} is setting as
* {@link ScheduleType#AFTER_PIPELINE}
*
*
* @return afterLayout GridLayout with components that designed for setting
* schedule the pipeline to run after selected pipelines finish.
*/
Expand Down Expand Up @@ -835,7 +846,7 @@ public void textChange(final FieldEvents.TextChangeEvent event) {
filter = new SimpleTreeFilter(event.getText(), true, false);
f.addContainerFilter(filter);

// update filters
// update filters
source.showAll();

source.filter(isInitialized, new InMemorySource.Filter<Pipeline>() {
Expand Down Expand Up @@ -871,7 +882,7 @@ public boolean filter(Pipeline object) {
selectPipe.setItemCaptionPropertyId("name");
selectPipe.setLeftColumnCaption(Messages.getString("SchedulePipeline.pipelines.available"));
selectPipe.setRightColumnCaption(Messages.getString("SchedulePipeline.pipelines.selected"));
//selectPipe is mandatory component
//selectPipe is mandatory component
selectPipe.addValidator(new Validator() {
private static final long serialVersionUID = 1L;

Expand All @@ -897,7 +908,7 @@ public void validate(Object value) throws InvalidValueException {
/**
* Building layout for the PERIODICALLY scheduling type. Calls from {@link #buildMainLayout} in case of {@link #scheduleType} is setting as
* {@link ScheduleType#PERIODICALLY}
*
*
* @return autoLayout GridLayout with components that designed for setting
* schedule the pipeline to run automatically in fixed interval.
*/
Expand Down Expand Up @@ -955,7 +966,7 @@ public void valueChange(ValueChangeEvent event) {

dateIntervalLayout.addComponent(new Label(Messages.getString("SchedulePipeline.interval")));

//OptionGroup with an interval
//OptionGroup with an interval
inervalLayout = new VerticalLayout();
intervalOption = new OptionGroup();
intervalOption.setImmediate(true);
Expand Down Expand Up @@ -1141,7 +1152,7 @@ public void validate(Object val) throws InvalidValueException {
/**
* Creating error message in case of wrong email format or duplicate emails
* in Notification tab
*
*
* @return String with error message
*/
private String emailValidation() {
Expand Down Expand Up @@ -1275,4 +1286,29 @@ private String getScheduleAuthorDisplayName(Schedule schedule) {
return ownerDisplayName;
}
}

public void setPipeline(Long pipelineId) {
if (pipelineId != null) {
comboPipeline.setValue(pipelineId);
comboPipeline.setEnabled(false);
}
}

public void enableComboPipeline() {
if (!comboPipeline.isEnabled()) {
comboPipeline.setEnabled(true);
}
}

private void resetURL() {
String uriFragment = Page.getCurrent().getUriFragment();
if (uriFragment.contains("New/")) {
uriFragment = uriFragment.replace("New/", "");
}
ParametersHandler handler = new ParametersHandler(uriFragment);
handler.removeParameter("schedule");
handler.removeParameter("pipeline");
((AppEntry) UI.getCurrent()).setUriFragment(handler.getUriFragment(), false);
}

}
Loading

0 comments on commit 6d48b6a

Please sign in to comment.