Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler GUI is accessible via url #456

Merged
merged 4 commits into from
Sep 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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