VerticalLayoutContainer rightContainer = new VerticalLayoutContainer();
layoutContainer
.add(leftContainer, new HorizontalLayoutData(300, 1));
layoutContainer.add(rightContainer);
baseName = new TextField();
baseName.setWidth(150);
baseDesc = new TextArea();
baseDesc.setWidth(150);
baseDesc.setHeight(36);
ListStore<String> scheduleTypeStore = new ListStore<String>(
new ModelKeyProvider<String>() {
@Override
public String getKey(final String item) {
return item;
}
});
scheduleTypeStore.add(JobModel.INDEPEN_JOB);
scheduleTypeStore.add(JobModel.DEPEND_JOB);
baseScheduleType = new ComboBox<String>(scheduleTypeStore,
new LabelProvider<String>() {
@Override
public String getLabel(final String item) {
return item;
}
});
baseScheduleType.setWidth(150);
baseScheduleType.setTriggerAction(TriggerAction.ALL);
baseScheduleType.setAllowBlank(false);
baseScheduleType.setEditable(false);
baseScheduleType
.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(
final ValueChangeEvent<String> event) {
if (event.getValue().equals(JobModel.INDEPEN_JOB)) {
cronWapper.show();
baseCron.setAllowBlank(false);
depCycleWapper.hide();
depJobsWapper.hide();
baseDepJobs.setAllowBlank(true);
} else if (event.getValue().equals(
JobModel.DEPEND_JOB)) {
cronWapper.hide();
baseCron.setAllowBlank(true);
depCycleWapper.show();
depJobsWapper.show();
baseDepJobs.setAllowBlank(false);
}
}
});
baseCron = new TextField();
baseCron.setWidth(150);
baseDepJobs = new TextField();
baseDepJobs.setWidth(150);
baseDepJobs.setReadOnly(true);
baseDepJobs.addHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
final CheckableJobTree tree = new CheckableJobTree();
tree.setSelectHandler(new SelectHandler() {
@Override
public void onSelect(final SelectEvent event) {
List<GroupJobTreeModel> list = tree.getTree()
.getCheckedSelection();// .getSelectionModel().getSelectedItems();
String result = "";
for (GroupJobTreeModel m : list) {
if (m.isJob()) {
result += m.getId() + ",";
}
}
if (result.endsWith(",")) {
result = result.substring(0,
result.length() - 1);
}
baseDepJobs.setValue(result.toString(), true);
baseDepJobs.validate();
}
});
tree.show();
tree.refresh(new Callback(){
@Override
public void callback() {
tree.init(baseDepJobs.getValue());
}
});
}
}, ClickEvent.getType());
ListStore<Map<String, String>> cycleStore = new ListStore<Map<String, String>>(
new ModelKeyProvider<Map<String, String>>() {
@Override
public String getKey(final Map<String, String> item) {
return item.get("key");
}
});
Map<String, String> sameday = new HashMap<String, String>();
sameday.put("key", "同一天");
sameday.put("value", "sameday");
Map<String, String> nolimit = new HashMap<String, String>();
nolimit.put("key", "无限制");
nolimit.put("value", " ");
cycleStore.add(nolimit);
cycleStore.add(sameday);
baseDepCycle = new ComboBox<Map<String, String>>(cycleStore,
new LabelProvider<Map<String, String>>() {
@Override
public String getLabel(final Map<String, String> item) {
return item.get("key");
}
}, new AbstractSafeHtmlRenderer<Map<String, String>>() {
@Override
public SafeHtml render(final Map<String, String> object) {
ComboBoxTemplates t = GWT
.create(ComboBoxTemplates.class);
return t.display(object.get("key"));
}
});
baseDepCycle.setWidth(150);
baseDepCycle.setTriggerAction(TriggerAction.ALL);
baseDepCycle.setEditable(false);
baseMain = new TextField();
baseMain.setWidth(150);
depCycleWapper = new FieldLabel(baseDepCycle, "依赖周期");
depJobsWapper = new FieldLabel(baseDepJobs, "依赖任务");
cronWapper = new FieldLabel(baseCron, "定时表达式");