List of usage examples for com.google.gwt.user.client.ui CheckBox setValue
@Override public void setValue(Boolean value)
From source file:org.rstudio.studio.client.workbench.views.environment.view.CallFramePanel.java
License:Open Source License
public CallFramePanel(EnvironmentObjectsObserver observer, CallFramePanelHost panelHost) { final ThemeStyles globalStyles = ThemeResources.INSTANCE.themeStyles(); panelHost_ = panelHost;//from w w w . j av a2 s.co m // import the minimize button from the global theme resources HTML minimize = new HTML(); minimize.setStylePrimaryName(globalStyles.minimize()); minimize.addStyleName(ThemeStyles.INSTANCE.handCursor()); minimize.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { if (isMinimized_) { callFramePanelHeader.removeStyleName(globalStyles.minimizedWindow()); panelHost_.restoreCallFramePanel(); isMinimized_ = false; } else { callFramePanelHeader.addStyleName(globalStyles.minimizedWindow()); panelHost_.minimizeCallFramePanel(); isMinimized_ = true; } } }); initWidget(GWT.<Binder>create(Binder.class).createAndBindUi(this)); Label tracebackTitle = new Label("Traceback"); tracebackTitle.addStyleName(style.tracebackHeader()); callFramePanelHeader.addStyleName(globalStyles.windowframe()); callFramePanelHeader.add(tracebackTitle); CheckBox showInternals = new CheckBox("Show internals"); showInternals.setValue(panelHost_.getShowInternalFunctions()); showInternals.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { panelHost_.setShowInternalFunctions(event.getValue()); // Ignore the function on the top of the stack; we always // want to show it since it's the execution point for (int i = 1; i < callFrameItems_.size(); i++) { CallFrameItem item = callFrameItems_.get(i); if (!item.isNavigable() && !item.isHidden()) { item.setVisible(event.getValue()); } } } }); showInternals.setStylePrimaryName(style.toggleHide()); callFramePanelHeader.add(showInternals); callFramePanelHeader.setWidgetRightWidth(showInternals, 28, Style.Unit.PX, 30, Style.Unit.PCT); callFramePanelHeader.add(minimize); callFramePanelHeader.setWidgetRightWidth(minimize, 14, Style.Unit.PX, 14, Style.Unit.PX); observer_ = observer; callFrameItems_ = new ArrayList<CallFrameItem>(); }
From source file:org.thechiselgroup.biomixer.client.BioMixerViewWindowContentProducer.java
License:Apache License
private VerticalPanel createArcTypeContainerControl(String label, final ArcItemContainer arcItemContainer) { final TextBox arcColorText = new TextBox(); arcColorText.setText(arcItemContainer.getArcColor()); final ListBox arcStyleDropDown = new ListBox(); arcStyleDropDown.setVisibleItemCount(1); arcStyleDropDown.addItem(ArcSettings.ARC_STYLE_SOLID); arcStyleDropDown.addItem(ArcSettings.ARC_STYLE_DASHED); arcStyleDropDown.addItem(ArcSettings.ARC_STYLE_DOTTED); String arcStyle = arcItemContainer.getArcStyle(); if (ArcSettings.ARC_STYLE_DOTTED.equals(arcStyle)) { arcStyleDropDown.setSelectedIndex(2); } else if (ArcSettings.ARC_STYLE_DASHED.equals(arcStyle)) { arcStyleDropDown.setSelectedIndex(1); } else {// w w w . j a va 2 s .c o m arcStyleDropDown.setSelectedIndex(0); } final ListBox arcHeadDropDown = new ListBox(); arcHeadDropDown.setVisibleItemCount(1); arcHeadDropDown.addItem(ArcSettings.ARC_HEAD_NONE); arcHeadDropDown.addItem(ArcSettings.ARC_HEAD_TRIANGLE_EMPTY); arcHeadDropDown.addItem(ArcSettings.ARC_HEAD_TRIANGLE_FULL); String arcHead = arcItemContainer.getArcHead(); if (ArcSettings.ARC_HEAD_TRIANGLE_FULL.equals(arcHead)) { arcHeadDropDown.setSelectedIndex(2); } else if (ArcSettings.ARC_HEAD_TRIANGLE_EMPTY.equals(arcHead)) { arcHeadDropDown.setSelectedIndex(1); } else if (ArcSettings.ARC_HEAD_NONE.equals(arcHead)) { arcHeadDropDown.setSelectedIndex(0); } final String defaultEntry = "Default"; final ListBox arcThicknessDropDown = new ListBox(); arcThicknessDropDown.setVisibleItemCount(1); arcThicknessDropDown.addItem(defaultEntry); arcThicknessDropDown.addItem("1"); arcThicknessDropDown.addItem("2"); arcThicknessDropDown.addItem("3"); arcThicknessDropDown.addItem("4"); arcThicknessDropDown.addItem("5"); arcThicknessDropDown.setSelectedIndex(0); final Button updateButton = new Button("Update Arcs"); updateButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { arcItemContainer.setArcColor(arcColorText.getText()); arcItemContainer.setArcStyle(arcStyleDropDown.getItemText(arcStyleDropDown.getSelectedIndex())); String selectedThicknessText = arcThicknessDropDown .getItemText(arcThicknessDropDown.getSelectedIndex()); if (selectedThicknessText.equals(defaultEntry)) { arcItemContainer.setArcThicknessLevel(0); } else { arcItemContainer.setArcThicknessLevel(Integer.parseInt(selectedThicknessText)); } arcItemContainer.setArcHead(arcHeadDropDown.getItemText(arcHeadDropDown.getSelectedIndex())); } }); final CheckBox visibleCheckBox = new CheckBox("Arcs Visible"); visibleCheckBox.setValue(true); visibleCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { boolean value = visibleCheckBox.getValue(); updateButton.setEnabled(value); arcStyleDropDown.setEnabled(value); arcHeadDropDown.setEnabled(value); arcThicknessDropDown.setEnabled(value); arcColorText.setEnabled(value); arcItemContainer.setVisible(value); } }); VerticalPanel containerPanel = new VerticalPanel(); containerPanel.add(new Label(label)); containerPanel.add(visibleCheckBox); containerPanel.add(new Label("Arc Color")); containerPanel.add(arcColorText); containerPanel.add(new Label("Arc Style")); containerPanel.add(arcStyleDropDown); containerPanel.add(new Label("Arc Head")); containerPanel.add(arcHeadDropDown); containerPanel.add(new Label("Arc Thickness")); containerPanel.add(arcThicknessDropDown); containerPanel.add(updateButton); // Handler runs and removes itself internally. @SuppressWarnings("unused") Handler handler = new Handler() { private HandlerRegistration register = arcColorText.addAttachHandler(this); @Override public void onAttachOrDetach(AttachEvent event) { $(arcColorText).as(Enhance).colorBox(ColorPickerType.SIMPLE); // Only want this run once, so let's do a trick to remove it. register.removeHandler(); } }; return containerPanel; }
From source file:org.thechiselgroup.biomixer.client.BioMixerViewWindowContentProducer.java
License:Apache License
private SidePanelSection createOntologyGraphNodesSidePanelSection(final ResourceModel resourceModel, final VisualizationModel visualizationModel) { final VerticalPanel panel = new VerticalPanel(); final Map<String, CheckBox> ontologyToFilterBox = CollectionFactory.createStringMap(); final CheckBox colorByOntologyCheckBox = new CheckBox("Color Nodes by Ontology"); colorByOntologyCheckBox.setValue(true); colorByOntologyCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override//from w w w. ja v a 2 s.co m public void onValueChange(ValueChangeEvent<Boolean> event) { boolean value = colorByOntologyCheckBox.getValue(); VisualItemValueResolver resolver; if (value) { resolver = NODE_COLOR_BY_ONTOLOGY_RESOLVER_FACTORY.create(); } else { resolver = NODE_BACKGROUND_COLOR_RESOLVER_FACTORY.create(); } visualizationModel.setResolver(Graph.NODE_BACKGROUND_COLOR, resolver); } }); resourceModel.getResources().addEventHandler(new ResourceSetChangedEventHandler() { @Override public void onResourceSetChanged(ResourceSetChangedEvent event) { LightweightCollection<Resource> addedResources = event.getAddedResources(); for (Resource resource : addedResources) { if (Ontology.isOntology(resource)) { String ontologyAcronym = (String) resource.getValue(Ontology.ONTOLOGY_ACRONYM); if (!ontologyToFilterBox.containsKey(ontologyAcronym)) { CheckBox checkBox = new CheckBox("<span style='color: " + BioMixerConceptByOntologyColorResolver.getColor(ontologyAcronym) + "'>▉</span>" + " " + "Show " + resource.getValue(Ontology.ONTOLOGY_ACRONYM), true); checkBox.setValue(true); ontologyToFilterBox.put(ontologyAcronym, checkBox); panel.add(checkBox); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { updatePredicate(resourceModel, false, ontologyToFilterBox); } }); } } } } }); panel.add(colorByOntologyCheckBox); updatePredicate(resourceModel, false, ontologyToFilterBox); return new SidePanelSection("Nodes", panel); }
From source file:org.thechiselgroup.biomixer.client.BioMixerViewWindowContentProducer.java
License:Apache License
private SidePanelSection createConceptGraphNodesSidePanelSection(final ResourceModel resourceModel, final VisualizationModel visualizationModel) { final VerticalPanel panel = new VerticalPanel(); final Map<String, CheckBox> ontologyToFilterBox = CollectionFactory.createStringMap(); // code below removes the "Show Mapping Nodes" checkbox under the // "Nodes" view part in the vertical panel // final CheckBox mappingNodesCheckbox = new // CheckBox("Show Mapping Nodes"); // mappingNodesCheckbox.setValue(false); // mappingNodesCheckbox // .addValueChangeHandler(new ValueChangeHandler<Boolean>() { // @Override//from w w w . j a v a 2 s . c o m // public void onValueChange(ValueChangeEvent<Boolean> event) { // updatePredicate(resourceModel, // mappingNodesCheckbox.getValue(), // ontologyToFilterBox); // } // }); final CheckBox colorByOntologyCheckBox = new CheckBox("Color Concept Nodes by Ontology"); colorByOntologyCheckBox.setValue(true); colorByOntologyCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { boolean value = colorByOntologyCheckBox.getValue(); VisualItemValueResolver resolver; if (value) { resolver = NODE_COLOR_BY_ONTOLOGY_RESOLVER_FACTORY.create(); } else { resolver = NODE_BACKGROUND_COLOR_RESOLVER_FACTORY.create(); } visualizationModel.setResolver(Graph.NODE_BACKGROUND_COLOR, resolver); } }); resourceModel.getResources().addEventHandler(new ResourceSetChangedEventHandler() { @Override public void onResourceSetChanged(ResourceSetChangedEvent event) { LightweightCollection<Resource> addedResources = event.getAddedResources(); for (Resource resource : addedResources) { if (Concept.isConcept(resource)) { String ontologyAcronym = (String) resource.getValue(Concept.ONTOLOGY_ACRONYM); if (!ontologyToFilterBox.containsKey(ontologyAcronym)) { CheckBox checkBox = new CheckBox("<span style='color: " + BioMixerConceptByOntologyColorResolver.getColor(ontologyAcronym) + "'>▉</span>" + " " + "Show " + resource.getValue(Concept.ONTOLOGY_ACRONYM), true); checkBox.setValue(true); ontologyToFilterBox.put(ontologyAcronym, checkBox); panel.add(checkBox); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { updatePredicate(resourceModel, false, ontologyToFilterBox); // the code below updates the // "Show Mapping Nodes" checkbox // under "Nodes" view part in the // vertical panel // updatePredicate(resourceModel, // mappingNodesCheckbox // .getValue(), // ontologyToFilterBox); } }); } } } } }); // next line commented out so the "Show Mapping Nodes" checkbox is not // added to the "Nodes" view part in the vertical panel // panel.add(mappingNodesCheckbox); panel.add(colorByOntologyCheckBox); updatePredicate(resourceModel, false, ontologyToFilterBox); return new SidePanelSection("Nodes", panel); }
From source file:org.thechiselgroup.biomixer.client.visualization_component.text.TextVisualization.java
License:Apache License
@Override public SidePanelSection[] getSidePanelSections() { FlowPanel settingsPanel = new FlowPanel(); final CheckBox oneItemPerRowBox = new CheckBox("One item per row"); oneItemPerRowBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override/*from w w w . java 2 s .c o m*/ public void onValueChange(ValueChangeEvent<Boolean> event) { setTagCloud(!oneItemPerRowBox.getValue()); } }); settingsPanel.add(oneItemPerRowBox); oneItemPerRowBox.setValue(!tagCloud); return new SidePanelSection[] { new SidePanelSection("Settings", settingsPanel), }; }
From source file:org.thechiselgroup.choosel.visualization_component.chart.client.barchart.BarChart.java
License:Apache License
@Override public SidePanelSection[] getSidePanelSections() { FlowPanel settingsPanel = new FlowPanel(); {//from www .ja v a 2 s. c om settingsPanel.add(new Label("Chart orientation")); final ListBox layoutBox = new ListBox(false); layoutBox.setVisibleItemCount(1); for (LayoutType layout : LayoutType.values()) { layoutBox.addItem(layout.getName(), layout.toString()); } layoutBox.setSelectedIndex(1); layoutBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { setLayout(LayoutType.valueOf(layoutBox.getValue(layoutBox.getSelectedIndex()))); } }); settingsPanel.add(layoutBox); } { settingsPanel.add(new Label("Bar spacing")); CheckBox checkBox = new CheckBox(); checkBox.setText("separate"); checkBox.setValue(barSpacing); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { setBarSpacing(event.getValue()); } }); settingsPanel.add(checkBox); } { settingsPanel.add(new Label("Value labels")); CheckBox checkBox = new CheckBox(); checkBox.setText("visible"); checkBox.setValue(valueLabelVisibility); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { setValueLabelVisibility(event.getValue()); } }); settingsPanel.add(checkBox); } { settingsPanel.add(new Label("Partial bar width")); CheckBox checkBox = new CheckBox(); checkBox.setText("thinner"); checkBox.setValue(partialBarThinner); checkBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { setThinPartialBars(event.getValue()); } }); settingsPanel.add(checkBox); } return new SidePanelSection[] { new SidePanelSection("Settings", settingsPanel), }; }
From source file:org.unitime.timetable.gwt.client.admin.ScriptPage.java
License:Apache License
private void scriptChanged() { ScriptInterface script = getScript(); if (script == null) { iForm.getRowFormatter().setVisible(iDescriptionRow, false); while (iForm.getRowCount() > iDescriptionRow + 2) iForm.removeRow(1 + iDescriptionRow); iHeader.setEnabled("edit", false); iHeader.setEnabled("execute", false); iParams.clear();//from w ww .j ava 2 s. c o m } else { iDescription.setHTML(script.getDescription()); iForm.getRowFormatter().setVisible(iDescriptionRow, true); iHeader.setEnabled("edit", script.canEdit()); iHeader.setEnabled("execute", script.canExecute()); iParams.clear(); while (iForm.getRowCount() > iDescriptionRow + 2) iForm.removeRow(1 + iDescriptionRow); if (script.hasParameters()) { for (final ScriptParameterInterface param : script.getParameters()) { Widget widget = null; if (param.hasOptions()) { final ListBox list = new ListBox(); list.setMultipleSelect(param.isMultiSelect()); if (!param.isMultiSelect()) list.addItem(MESSAGES.itemSelect()); for (ScriptInterface.ListItem item : param.getOptions()) { list.addItem(item.getText(), item.getValue()); if (param.getDefaultValue() != null && param.getDefaultValue().equalsIgnoreCase(item.getValue())) list.setSelectedIndex(list.getItemCount() - 1); } list.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { if (param.isMultiSelect()) { String value = ""; for (int i = 0; i < list.getItemCount(); i++) if (list.isItemSelected(i)) value += (value.isEmpty() ? "" : ",") + list.getValue(i); iParams.put(param.getName(), value); } else { if (list.getSelectedIndex() <= 0) iParams.remove(param.getName()); else iParams.put(param.getName(), list.getValue(list.getSelectedIndex())); } } }); widget = list; } else if ("boolean".equalsIgnoreCase(param.getType())) { CheckBox ch = new CheckBox(); ch.setValue("true".equalsIgnoreCase(param.getDefaultValue())); ch.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue() == null) iParams.remove(param.getName()); else iParams.put(param.getName(), event.getValue() ? "true" : "false"); } }); widget = ch; } else if ("file".equalsIgnoreCase(param.getType())) { UniTimeFileUpload upload = new UniTimeFileUpload(); upload.reset(); widget = upload; } else if ("textarea".equalsIgnoreCase(param.getType())) { TextArea textarea = new TextArea(); textarea.setStyleName("unitime-TextArea"); textarea.setVisibleLines(5); textarea.setCharacterWidth(80); if (param.getDefaultValue() != null) textarea.setText(param.getDefaultValue()); textarea.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { if (event.getValue() == null) iParams.remove(param.getName()); else iParams.put(param.getName(), event.getValue()); } }); widget = textarea; } else { TextBox text = new TextBox(); text.setStyleName("unitime-TextBox"); text.setWidth("400px"); if (param.getDefaultValue() != null) text.setText(param.getDefaultValue()); text.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { if (event.getValue() == null) iParams.remove(param.getName()); else iParams.put(param.getName(), event.getValue()); } }); widget = text; } int row = iForm.insertRow(iForm.getRowCount() - 1); iForm.setWidget(row, 0, new Label((param.getLabel() == null || param.getLabel().isEmpty() ? param.getName() : param.getLabel()) + ":", false)); iForm.setWidget(row, 1, widget); } } } }
From source file:org.unitime.timetable.gwt.client.admin.TaskEditor.java
License:Apache License
private void scriptChanged(boolean clear) { ScriptInterface script = getScript(); if (script == null) { iForm.getRowFormatter().setVisible(iDescriptionRow, false); while (iForm.getRowCount() > iDescriptionRow + 2) iForm.removeRow(1 + iDescriptionRow); iBottom.setEnabled("save", false); iTask.clearParameters();/*from w w w. j a v a2 s .co m*/ } else { iDescription.setHTML(script.getDescription()); iForm.getRowFormatter().setVisible(iDescriptionRow, script.getDescription() != null && !script.getDescription().isEmpty()); iBottom.setEnabled("save", script.canExecute()); if (clear) iTask.clearParameters(); while (iForm.getRowCount() > iDescriptionRow + 2) iForm.removeRow(1 + iDescriptionRow); if (script.hasParameters()) { for (final ScriptParameterInterface param : script.getParameters()) { if (param.getValue() != null) iTask.setParameter(param.getName(), param.getValue()); String defaultValue = iTask.getParameter(param.getName()); if (defaultValue == null) defaultValue = param.getValue(); if (defaultValue == null) defaultValue = param.getDefaultValue(); Widget widget = null; if (param.hasOptions()) { final ListBox list = new ListBox(); list.setMultipleSelect(param.isMultiSelect()); if (!param.isMultiSelect()) list.addItem(MESSAGES.itemSelect()); for (ScriptInterface.ListItem item : param.getOptions()) { list.addItem(item.getText(), item.getValue()); if (defaultValue != null) { if (param.isMultiSelect()) { for (String id : defaultValue.split(",")) if (!id.isEmpty() && (id.equalsIgnoreCase(item.getValue()) || id.equalsIgnoreCase(item.getText()) || item.getText().startsWith(id + " - "))) { list.setItemSelected(list.getItemCount() - 1, true); break; } } else if (defaultValue.equalsIgnoreCase(item.getValue()) || defaultValue.equalsIgnoreCase(item.getText()) || item.getText().startsWith(defaultValue + " - ")) list.setSelectedIndex(list.getItemCount() - 1); } } list.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { if (param.isMultiSelect()) { String value = ""; for (int i = 0; i < list.getItemCount(); i++) if (list.isItemSelected(i)) value += (value.isEmpty() ? "" : ",") + list.getValue(i); iTask.setParameter(param.getName(), value); } else { iTask.setParameter(param.getName(), list.getValue(list.getSelectedIndex())); } } }); widget = list; } else if ("boolean".equalsIgnoreCase(param.getType())) { CheckBox ch = new CheckBox(); ch.setValue("true".equalsIgnoreCase(defaultValue)); ch.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { iTask.setParameter(param.getName(), event.getValue() ? "true" : "false"); } }); widget = ch; } else if ("file".equalsIgnoreCase(param.getType())) { UniTimeFileUpload upload = new UniTimeFileUpload(); upload.reset(); widget = upload; } else if ("textarea".equalsIgnoreCase(param.getType())) { TextArea textarea = new TextArea(); textarea.setStyleName("unitime-TextArea"); textarea.setVisibleLines(5); textarea.setCharacterWidth(80); if (defaultValue != null) textarea.setText(defaultValue); textarea.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { iTask.setParameter(param.getName(), event.getValue()); } }); widget = textarea; } else if ("integer".equalsIgnoreCase(param.getType()) || "int".equalsIgnoreCase(param.getType()) || "long".equalsIgnoreCase(param.getType()) || "short".equalsIgnoreCase(param.getType()) || "byte".equalsIgnoreCase(param.getType())) { NumberBox text = new NumberBox(); text.setDecimal(false); text.setNegative(true); if (defaultValue != null) text.setText(defaultValue); text.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { iTask.setParameter(param.getName(), event.getValue()); } }); widget = text; } else if ("number".equalsIgnoreCase(param.getType()) || "float".equalsIgnoreCase(param.getType()) || "double".equalsIgnoreCase(param.getType())) { NumberBox text = new NumberBox(); text.setDecimal(true); text.setNegative(true); if (defaultValue != null) text.setText(defaultValue); text.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { iTask.setParameter(param.getName(), event.getValue()); } }); widget = text; } else if ("date".equalsIgnoreCase(param.getType())) { SingleDateSelector text = new SingleDateSelector(); if (defaultValue != null) text.setText(defaultValue); final DateTimeFormat format = DateTimeFormat.getFormat(CONSTANTS.eventDateFormat()); text.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> event) { iTask.setParameter(param.getName(), format.format(event.getValue())); } }); widget = text; } else if ("slot".equalsIgnoreCase(param.getType()) || "time".equalsIgnoreCase(param.getType())) { TimeSelector text = new TimeSelector(); if (defaultValue != null) text.setText(defaultValue); text.addValueChangeHandler(new ValueChangeHandler<Integer>() { @Override public void onValueChange(ValueChangeEvent<Integer> event) { iTask.setParameter(param.getName(), event.getValue().toString()); } }); widget = text; } else if ("datetime".equalsIgnoreCase(param.getType()) || "timestamp".equalsIgnoreCase(param.getType())) { DateTimeBox text = new DateTimeBox(); if (defaultValue != null) text.setText(defaultValue); text.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { iTask.setParameter(param.getName(), event.getValue()); } }); widget = text; } else { TextBox text = new TextBox(); text.setStyleName("unitime-TextBox"); text.setWidth("400px"); if (defaultValue != null) text.setText(defaultValue); text.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { iTask.setParameter(param.getName(), event.getValue()); } }); widget = text; } int row = iForm.insertRow(iForm.getRowCount() - 1); iForm.setWidget(row, 0, new Label((param.getLabel() == null || param.getLabel().isEmpty() ? param.getName() : param.getLabel()) + ":", false)); iForm.setWidget(row, 1, widget); } } } if (isShowing()) center(); }
From source file:org.unitime.timetable.gwt.client.curricula.CurriculaTable.java
License:Apache License
private void fillRow(CurriculumInterface c) { int row = iTable.getRowCount(); List<Widget> line = new ArrayList<Widget>(); if (c.isEditable()) { CheckBox ch = new CheckBox(); final Long cid = c.getId(); ch.setValue(iSelectedCurricula.contains(cid)); ch.addClickHandler(new ClickHandler() { @Override/* ww w .j a va2 s . c o m*/ public void onClick(ClickEvent event) { event.stopPropagation(); } }); ch.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) iSelectedCurricula.add(cid); else iSelectedCurricula.remove(cid); } }); line.add(ch); } else { line.add(new Label("")); } DisplayMode m = CurriculumCookie.getInstance().getCurriculaDisplayMode(); line.add(new Label(m.isCurriculumAbbv() ? c.getAbbv() : c.getName(), false)); line.add(new Label(m.isAreaAbbv() ? c.getAcademicArea().getAbbv() : c.getAcademicArea().getName(), false)); line.add(new HTML(m.isMajorAbbv() ? c.getMajorCodes(", ") : c.getMajorNames("<br>"), m.isMajorAbbv())); line.add(new Label(m.formatDepartment(c.getDepartment()), false)); line.add(new Label(c.getLastLike() == null ? "" : c.getLastLikeString(), false)); line.add(new Label(c.getProjection() == null ? "" : c.getProjectionString(), false)); line.add(new Label(c.getExpected() == null ? "" : c.getExpectedString(), false)); line.add(new Label(c.getEnrollment() == null ? "" : c.getEnrollmentString(), false)); line.add(new Label(c.getRequested() == null ? "" : c.getRequestedString(), false)); iTable.setRow(row, c, line); iTable.getCellFormatter().addStyleName(row, 0, "unitime-NoPrint"); iTable.getFlexCellFormatter().setHorizontalAlignment(row, 5, HasHorizontalAlignment.ALIGN_RIGHT); iTable.getFlexCellFormatter().setHorizontalAlignment(row, 6, HasHorizontalAlignment.ALIGN_RIGHT); iTable.getFlexCellFormatter().setHorizontalAlignment(row, 7, HasHorizontalAlignment.ALIGN_RIGHT); iTable.getFlexCellFormatter().setHorizontalAlignment(row, 8, HasHorizontalAlignment.ALIGN_RIGHT); iTable.getFlexCellFormatter().setHorizontalAlignment(row, 9, HasHorizontalAlignment.ALIGN_RIGHT); }
From source file:org.unitime.timetable.gwt.client.events.EventAdd.java
License:Apache License
public EventAdd(AcademicSessionSelectionBox session, EventPropertiesProvider properties) { iSession = session;/*ww w. ja va2 s . c o m*/ iProperties = properties; iForm = new SimpleForm(); iLookup = new Lookup(); iLookup.addValueChangeHandler(new ValueChangeHandler<PersonInterface>() { @Override public void onValueChange(ValueChangeEvent<PersonInterface> event) { if (event.getValue() != null) { iMainExternalId = event.getValue().getId(); iMainFName.setText( event.getValue().getFirstName() == null ? "" : event.getValue().getFirstName()); iMainMName.setText( event.getValue().getMiddleName() == null ? "" : event.getValue().getMiddleName()); iMainLName.getWidget() .setText(event.getValue().getLastName() == null ? "" : event.getValue().getLastName()); iMainTitle.setText( event.getValue().getAcademicTitle() == null ? "" : event.getValue().getAcademicTitle()); iMainPhone.setText(event.getValue().getPhone() == null ? "" : event.getValue().getPhone()); iMainEmail.getWidget() .setText(event.getValue().getEmail() == null ? "" : event.getValue().getEmail()); iOriginalContact = new ContactInterface(event.getValue()); iMainContactChanged.setValue(false, true); checkMainContactChanged(); } } }); iAdditionalLookup = new Lookup(); iAdditionalLookup.addValueChangeHandler(new ValueChangeHandler<PersonInterface>() { @Override public void onValueChange(ValueChangeEvent<PersonInterface> event) { if (event.getValue() != null) { final ContactInterface contact = new ContactInterface(event.getValue()); List<Widget> row = new ArrayList<Widget>(); row.add(new Label(contact.getName(MESSAGES), false)); row.add(new Label(contact.hasEmail() ? contact.getEmail() : "", false)); row.add(new Label(contact.hasPhone() ? contact.getPhone() : "", false)); Image remove = new Image(RESOURCES.delete()); remove.addStyleName("remove"); remove.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { for (int row = 1; row < iContacts.getRowCount(); row++) if (contact.equals(iContacts.getData(row))) { iContacts.removeRow(row); break; } iForm.getRowFormatter().setVisible(iContactRow, iContacts.getRowCount() > 1); } }); row.add(remove); int nrInstructors = 0; for (int r = 1; r < iContacts.getRowCount(); r++) if (iContacts.getData(r) == null) nrInstructors++; int rowNum; if (nrInstructors == 0) { rowNum = iContacts.addRow(contact, row); } else { rowNum = iContacts.insertRow(iContacts.getRowCount() - nrInstructors); iContacts.setRow(rowNum, contact, row); } for (int col = 0; col < iContacts.getCellCount(rowNum); col++) iContacts.getCellFormatter().addStyleName(rowNum, col, "additional-contact"); } iForm.getRowFormatter().setVisible(iContactRow, iContacts.getRowCount() > 1); } }); iLookup.setOptions("mustHaveExternalId" + (iSession.getAcademicSessionId() == null ? "" : ",session=" + iSession.getAcademicSessionId())); iAdditionalLookup.setOptions("mustHaveExternalId" + (iSession.getAcademicSessionId() == null ? "" : ",session=" + iSession.getAcademicSessionId())); iSession.addAcademicSessionChangeHandler(new AcademicSessionProvider.AcademicSessionChangeHandler() { @Override public void onAcademicSessionChange(AcademicSessionProvider.AcademicSessionChangeEvent event) { iLookup.setOptions("mustHaveExternalId,session=" + event.getNewAcademicSessionId()); iAdditionalLookup.setOptions("mustHaveExternalId,session=" + event.getNewAcademicSessionId()); } }); iHeader = new UniTimeHeaderPanel(MESSAGES.sectEvent()); ClickHandler clickCreateOrUpdate = new ClickHandler() { @Override public void onClick(ClickEvent event) { iSavedEvent = null; validate(new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { UniTimeNotifications.error(MESSAGES.failedValidation(caught.getMessage()), caught); } @Override public void onSuccess(Boolean result) { if (result) { final EventInterface event = getEvent(); LoadingWidget.getInstance() .show(event.getId() == null ? MESSAGES.waitCreate(event.getName()) : MESSAGES.waitUpdate(event.getName())); RPC.execute( SaveEventRpcRequest.saveEvent(getEvent(), iSession.getAcademicSessionId(), getMessage(), isSendEmailConformation()), new AsyncCallback<SaveOrApproveEventRpcResponse>() { @Override public void onFailure(Throwable caught) { LoadingWidget.getInstance().hide(); String message = (event.getId() == null ? MESSAGES.failedCreate(event.getName(), caught.getMessage()) : MESSAGES.failedUpdate(event.getName(), caught.getMessage())); iHeader.setErrorMessage(message); UniTimeNotifications.error(message, caught); } @Override public void onSuccess(SaveOrApproveEventRpcResponse result) { LoadingWidget.getInstance().hide(); iSavedEvent = result.getEvent(); if (result.hasMessages()) for (MessageInterface m : result.getMessages()) { if (m.isError()) UniTimeNotifications.warn(m.getMessage()); else if (m.isWarning()) UniTimeNotifications.error(m.getMessage()); else UniTimeNotifications.info(m.getMessage()); } hide(); } }); } } }); } }; iHeader.addButton("create", MESSAGES.buttonCreateEvent(), 100, clickCreateOrUpdate); iHeader.addButton("update", MESSAGES.buttonUpdateEvent(), 100, clickCreateOrUpdate); iHeader.addButton("delete", MESSAGES.buttonDeleteEvent(), 100, new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { if (!Window.confirm(MESSAGES.confirmDeleteEvent())) return; final EventInterface event = getEvent(); if (event.hasMeetings()) event.getMeetings().clear(); LoadingWidget.getInstance().show(MESSAGES.waitDelete(event.getName())); RPC.execute(SaveEventRpcRequest.saveEvent(event, iSession.getAcademicSessionId(), getMessage(), isSendEmailConformation()), new AsyncCallback<SaveOrApproveEventRpcResponse>() { @Override public void onFailure(Throwable caught) { LoadingWidget.getInstance().hide(); iHeader.setErrorMessage( MESSAGES.failedDelete(event.getName(), caught.getMessage())); UniTimeNotifications .error(MESSAGES.failedDelete(event.getName(), caught.getMessage()), caught); } @Override public void onSuccess(SaveOrApproveEventRpcResponse result) { LoadingWidget.getInstance().hide(); iSavedEvent = result.getEvent(); if (result.hasMessages()) for (MessageInterface m : result.getMessages()) { if (m.isError()) UniTimeNotifications.warn(m.getMessage()); else if (m.isWarning()) UniTimeNotifications.error(m.getMessage()); else UniTimeNotifications.info(m.getMessage()); } hide(); } }); } }); iHeader.addButton("cancel", MESSAGES.buttonCancelEvent(), 100, new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { if (!Window.confirm(MESSAGES.confirmCancelEvent())) return; final EventInterface event = getEvent(); if (event.hasMeetings()) { for (Iterator<MeetingInterface> i = event.getMeetings().iterator(); i.hasNext();) { MeetingInterface m = i.next(); if (m.getId() == null) i.remove(); else if (m.isCanCancel()) m.setApprovalStatus(ApprovalStatus.Cancelled); else if (m.isCanDelete() && (m.getApprovalStatus() == ApprovalStatus.Pending || m.getApprovalStatus() == ApprovalStatus.Approved)) i.remove(); } } LoadingWidget.getInstance().show(MESSAGES.waitCancel(event.getName())); RPC.execute(SaveEventRpcRequest.saveEvent(event, iSession.getAcademicSessionId(), getMessage(), isSendEmailConformation()), new AsyncCallback<SaveOrApproveEventRpcResponse>() { @Override public void onFailure(Throwable caught) { LoadingWidget.getInstance().hide(); iHeader.setErrorMessage( MESSAGES.failedCancel(event.getName(), caught.getMessage())); UniTimeNotifications .error(MESSAGES.failedCancel(event.getName(), caught.getMessage()), caught); } @Override public void onSuccess(SaveOrApproveEventRpcResponse result) { LoadingWidget.getInstance().hide(); iSavedEvent = result.getEvent(); if (result.hasMessages()) for (MessageInterface m : result.getMessages()) { if (m.isError()) UniTimeNotifications.warn(m.getMessage()); else if (m.isWarning()) UniTimeNotifications.error(m.getMessage()); else UniTimeNotifications.info(m.getMessage()); } hide(); } }); } }); iHeader.addButton("back", MESSAGES.buttonBack(), 75, new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); iForm.addHeaderRow(iHeader); iSessionRow = iForm.addRow(MESSAGES.propAcademicSession(), new Label()); iName = new UniTimeWidget<TextBox>(new TextBox()); iName.getWidget().setStyleName("unitime-TextBox"); iName.getWidget().setMaxLength(100); iName.getWidget().setWidth("480px"); iName.getWidget().addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { iName.clearHint(); iHeader.clearMessage(); } }); iForm.addRow(MESSAGES.propEventName(), iName); iSponsors = new ListBox(); iForm.addRow(MESSAGES.propSponsor(), iSponsors); iEventType = new UniTimeWidget<ListBox>(new ListBox()); iEventType.getWidget().addItem(EventInterface.EventType.Special.getName(CONSTANTS), EventInterface.EventType.Special.name()); iForm.addRow(MESSAGES.propEventType(), iEventType); iLimit = new NumberBox(); iLimit.setStyleName("unitime-TextBox"); iLimit.setMaxLength(10); iLimit.setWidth("50px"); iForm.addRow(MESSAGES.propAttendance(), iLimit); iCourses = new CourseRelatedObjectsTable(iSession); iCourses.addValueChangeHandler(new ValueChangeHandler<List<RelatedObjectInterface>>() { @Override public void onValueChange(ValueChangeEvent<List<RelatedObjectInterface>> event) { checkEnrollments(event.getValue(), iMeetings.getMeetings()); } }); iReqAttendance = new CheckBox(MESSAGES.checkRequiredAttendance()); iMainContact = new SimpleForm(); iMainContact.getElement().getStyle().clearWidth(); iMainContact.removeStyleName("unitime-NotPrintableBottomLine"); iLookupButton = new Button(MESSAGES.buttonLookupMainContact()); iLookupButton.setWidth("75px"); Character lookupAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.buttonLookupMainContact()); if (lookupAccessKey != null) iLookupButton.setAccessKey(lookupAccessKey); iLookupButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!iLookupButton.isVisible()) return; iLookup.setQuery( (iMainFName.getText() + (iMainMName.getText().isEmpty() ? "" : " " + iMainMName.getText()) + " " + iMainLName.getWidget().getText()).trim()); iLookup.center(); } }); iLookupButton.setVisible(false); iAdditionalLookupButton = new Button(MESSAGES.buttonLookupAdditionalContact()); iAdditionalLookupButton.setWidth("125px"); Character additionalLookupAccessKey = UniTimeHeaderPanel .guessAccessKey(MESSAGES.buttonLookupAdditionalContact()); if (additionalLookupAccessKey != null) iAdditionalLookupButton.setAccessKey(additionalLookupAccessKey); iAdditionalLookupButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (iAdditionalLookupButton.isVisible()) iAdditionalLookup.center(); } }); iAdditionalLookupButton.setVisible(false); iMainContactResetButton = new Button(MESSAGES.buttonResetMainContact()); iMainContactResetButton.setWidth("75px"); Character resetAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.buttonResetMainContact()); if (resetAccessKey != null) iMainContactResetButton.setAccessKey(resetAccessKey); iMainContactResetButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (iLookupButton.isVisible()) { iOriginalContact = null; } if (iOriginalContact == null) { iMainExternalId = null; iMainFName.setText(""); iMainMName.setText(""); iMainLName.getWidget().setText(""); iMainTitle.setText(""); iMainPhone.setText(""); iMainEmail.getWidget().setText(""); } else { iMainExternalId = iOriginalContact.getExternalId(); iMainFName.setText(iOriginalContact.hasFirstName() ? iOriginalContact.getFirstName() : ""); iMainMName.setText(iOriginalContact.hasMiddleName() ? iOriginalContact.getMiddleName() : ""); iMainLName.getWidget() .setText(iOriginalContact.hasLastName() ? iOriginalContact.getLastName() : ""); iMainTitle.setText( iOriginalContact.hasAcademicTitle() ? iOriginalContact.getAcademicTitle() : ""); iMainPhone.setText(iOriginalContact.hasPhone() ? iOriginalContact.getPhone() : ""); iMainEmail.getWidget().setText(iOriginalContact.hasEmail() ? iOriginalContact.getEmail() : ""); } iMainContactChanged.setValue(false, true); checkMainContactChanged(); } }); iMainContactResetButton.setVisible(false); iMainFName = new TextBox(); iMainFName.setStyleName("unitime-TextBox"); iMainFName.setMaxLength(100); iMainFName.setWidth("285px"); iMainContact.addRow(MESSAGES.propFirstName(), iMainFName); iMainContact.setWidget(0, 2, iLookupButton); iMainContact.setWidget(0, 3, iMainContactResetButton); iMainMName = new TextBox(); iMainMName.setStyleName("unitime-TextBox"); iMainMName.setMaxLength(100); iMainMName.setWidth("285px"); iMainContact.addRow(MESSAGES.propMiddleName(), iMainMName); iMainLName = new UniTimeWidget<TextBox>(new TextBox()); iMainLName.getWidget().setStyleName("unitime-TextBox"); iMainLName.getWidget().setMaxLength(100); iMainLName.getWidget().setWidth("285px"); iMainLName.getWidget().addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { iMainLName.clearHint(); iHeader.clearMessage(); } }); iMainContact.addRow(MESSAGES.propLastName(), iMainLName); iMainTitle = new TextBox(); iMainTitle.setStyleName("unitime-TextBox"); iMainTitle.setMaxLength(50); iMainTitle.setWidth("285px"); iAcademicTitleRow = iMainContact.addRow(MESSAGES.propAcademicTitle(), iMainTitle); iMainEmail = new UniTimeWidget<TextBox>(new TextBox()); iMainEmail.getWidget().setStyleName("unitime-TextBox"); iMainEmail.getWidget().setMaxLength(200); iMainEmail.getWidget().setWidth("285px"); iMainEmail.getWidget().addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { iMainEmail.clearHint(); iHeader.clearMessage(); } }); iMainContact.addRow(MESSAGES.propEmail(), iMainEmail); iMainPhone = new TextBox(); iMainPhone.setStyleName("unitime-TextBox"); iMainPhone.setMaxLength(35); iMainPhone.setWidth("285px"); iMainContact.addRow(MESSAGES.propPhone(), iMainPhone); iMainContact.setWidget(iMainContact.getRowCount() - 1, 2, iAdditionalLookupButton); iMainContact.getFlexCellFormatter().setColSpan(iMainContact.getRowCount() - 1, 2, 2); ValueChangeHandler<String> checkMainContactHandler = new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { checkMainContactChanged(); } }; iMainFName.addValueChangeHandler(checkMainContactHandler); iMainMName.addValueChangeHandler(checkMainContactHandler); iMainLName.getWidget().addValueChangeHandler(checkMainContactHandler); iMainTitle.addValueChangeHandler(checkMainContactHandler); iMainPhone.addValueChangeHandler(checkMainContactHandler); iMainEmail.getWidget().addValueChangeHandler(checkMainContactHandler); iForm.addRow(MESSAGES.propMainContact(), iMainContact); iMainContactChanged = new CheckBox(MESSAGES.checkYourContactChange()); iMainContactChangedRow = iForm.addRow("", iMainContactChanged); iForm.getRowFormatter().setVisible(iMainContactChangedRow, false); iForm.getCellFormatter().setStyleName(iMainContactChangedRow, 1, "unitime-CheckNotConfirmed"); iMainContactChanged.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { checkMainContactChanged(); iHeader.clearMessage(); } }); iContacts = new UniTimeTable<ContactInterface>(); iContacts.setStyleName("unitime-EventContacts"); List<Widget> contactHeader = new ArrayList<Widget>(); contactHeader.add(new UniTimeTableHeader(MESSAGES.colNamePerson())); contactHeader.add(new UniTimeTableHeader(MESSAGES.colEmail())); contactHeader.add(new UniTimeTableHeader(MESSAGES.colPhone())); contactHeader.add(new UniTimeTableHeader(" ")); iContacts.addRow(null, contactHeader); iContactRow = iForm.addRow(MESSAGES.propAdditionalContacts(), iContacts); iForm.getRowFormatter().setVisible(iContactRow, false); iEmails = new TextArea(); iEmails.setStyleName("unitime-TextArea"); iEmails.setVisibleLines(3); iEmails.setCharacterWidth(80); UniTimeWidget<TextArea> emailsWithHint = new UniTimeWidget<TextArea>(iEmails); emailsWithHint.setHint(MESSAGES.hintAdditionalEmails()); iForm.addRow(MESSAGES.propAdditionalEmails(), emailsWithHint); iStandardNotes = new ListBox(); iStandardNotes.setVisibleItemCount(10); iStandardNotes.setWidth("600px"); iStandardNotes.addDoubleClickHandler(new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { String text = iNotes.getText(); if (!text.isEmpty() && !text.endsWith("\n")) text += "\n"; text += iStandardNotes.getValue(iStandardNotes.getSelectedIndex()); iNotes.setText(text); iStandardNotesBox.hide(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { iNotes.setFocus(true); } }); } }); iStandardNotes.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) { String text = iNotes.getText(); if (!text.isEmpty() && !text.endsWith("\n")) text += "\n"; text += iStandardNotes.getValue(iStandardNotes.getSelectedIndex()); iNotes.setText(text); event.preventDefault(); event.stopPropagation(); iStandardNotesBox.hide(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { iNotes.setFocus(true); } }); } } }); UniTimeWidget<ListBox> standardNotesWithHint = new UniTimeWidget<ListBox>(iStandardNotes); standardNotesWithHint.setHint(MESSAGES.hintStandardNoteDoubleClickToSelect()); SimpleForm standardNotesForm = new SimpleForm(); standardNotesForm.addRow(standardNotesWithHint); final UniTimeHeaderPanel standardNotesFooter = new UniTimeHeaderPanel(); standardNotesForm.addRow(standardNotesFooter); iStandardNotesBox = new UniTimeDialogBox(true, false); iStandardNotesBox.setText(MESSAGES.dialogStandardNotes()); iStandardNotesBox.setWidget(standardNotesForm); standardNotesFooter.addButton("select", MESSAGES.buttonSelect(), new ClickHandler() { @Override public void onClick(ClickEvent event) { if (iStandardNotes.getSelectedIndex() >= 0) { String text = iNotes.getText(); if (!text.isEmpty() && !text.endsWith("\n")) text += "\n"; text += iStandardNotes.getValue(iStandardNotes.getSelectedIndex()); iNotes.setText(text); } iStandardNotesBox.hide(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { iNotes.setFocus(true); } }); } }); standardNotesFooter.addButton("cancel", MESSAGES.buttonCancel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { iStandardNotesBox.hide(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { iNotes.setFocus(true); } }); } }); standardNotesFooter.setEnabled("select", false); iStandardNotes.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { standardNotesFooter.setEnabled("select", iStandardNotes.getSelectedIndex() >= 0); } }); iNotes = new TextArea(); iNotes.setStyleName("unitime-TextArea"); iNotes.setVisibleLines(5); iNotes.setCharacterWidth(80); VerticalPanel notesPanel = new VerticalPanel(); notesPanel.add(iNotes); notesPanel.setSpacing(0); iStandardNotesButton = new Button(MESSAGES.buttonStandardNotes(), new ClickHandler() { @Override public void onClick(ClickEvent event) { if (iStandardNotes.getItemCount() > 0) { iStandardNotesBox.center(); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { iStandardNotes.setFocus(true); } }); } } }); Character standardNotesButtonAccessKey = UniTimeHeaderPanel.guessAccessKey(MESSAGES.buttonStandardNotes()); if (standardNotesButtonAccessKey != null) iStandardNotesButton.setAccessKey(standardNotesButtonAccessKey); iStandardNotesButton.setVisible(false); iStandardNotesButton.getElement().getStyle().setMarginTop(2, Unit.PX); notesPanel.add(iStandardNotesButton); notesPanel.setCellHorizontalAlignment(iStandardNotesButton, HasHorizontalAlignment.ALIGN_RIGHT); int row = iForm.addRow(MESSAGES.propAdditionalInformation(), notesPanel); Roles.getTextboxRole().setAriaLabelledbyProperty(iNotes.getElement(), Id.of(iForm.getWidget(row, 0).getElement())); iFileUpload = new UniTimeFileUpload(); iForm.addRow(MESSAGES.propAttachment(), iFileUpload); iExpirationDate = new SingleDateSelector(); iExpirationDate.setFirstDate(iExpirationDate.today()); iForm.addRow(MESSAGES.propExpirationDate(), iExpirationDate); iCoursesForm = new SimpleForm(); iCoursesForm.addHeaderRow(MESSAGES.sectRelatedCourses()); iCoursesForm.removeStyleName("unitime-NotPrintableBottomLine"); iCoursesForm.addRow(iCourses); iCoursesForm.addRow(iReqAttendance); iForm.addRow(iCoursesForm); iEventType.getWidget().addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { EventType type = getEventType(); iName.setReadOnly( type == EventType.Class || type == EventType.MidtermExam || type == EventType.FinalExam); iEvent.setType(type); iCoursesForm.setVisible(type == EventType.Course); iForm.getRowFormatter().setVisible(iForm.getRow(MESSAGES.propAttendance()), type == EventType.Special); iForm.getRowFormatter().setVisible(iForm.getRow(MESSAGES.propSponsor()), type != EventType.Unavailabile && type != EventType.Class && type != EventType.MidtermExam && type != EventType.FinalExam && iSponsors.getItemCount() > 0); iForm.getRowFormatter().setVisible(iForm.getRow(MESSAGES.propExpirationDate()), getProperties() != null && (getProperties().isCanSetExpirationDate() || iExpirationDate.getValue() != null) && type != EventType.Unavailabile && type != EventType.Class && type != EventType.MidtermExam && type != EventType.FinalExam); if (iMeetings.getRowCount() > 1) { LoadingWidget.getInstance().show(MESSAGES.waitCheckingRoomAvailability()); RPC.execute( EventRoomAvailabilityRpcRequest.checkAvailability(iMeetings.getMeetings(), getEventId(), getEventType(), iSession.getAcademicSessionId()), new AsyncCallback<EventRoomAvailabilityRpcResponse>() { @Override public void onFailure(Throwable caught) { LoadingWidget.getInstance().hide(); UniTimeNotifications.error(MESSAGES.failedRoomAvailability(caught.getMessage()), caught); } @Override public void onSuccess(EventRoomAvailabilityRpcResponse result) { LoadingWidget.getInstance().hide(); iMeetings.setMeetings(iEvent, result.getMeetings()); checkEnrollments(iCourses.getValue(), iMeetings.getMeetings()); showCreateButtonIfApplicable(); } }); } } }); iEventAddMeetings = new AddMeetingsDialog(session, iProperties, new AsyncCallback<List<MeetingInterface>>() { @Override public void onFailure(Throwable caught) { UniTimeNotifications.error(MESSAGES.failedAddMeetings(caught.getMessage()), caught); } @Override public void onSuccess(List<MeetingInterface> result) { LoadingWidget.getInstance().show(MESSAGES.waitCheckingRoomAvailability()); RPC.execute( EventRoomAvailabilityRpcRequest.checkAvailability(result, getEventId(), getEventType(), iSession.getAcademicSessionId()), new AsyncCallback<EventRoomAvailabilityRpcResponse>() { @Override public void onFailure(Throwable caught) { LoadingWidget.getInstance().hide(); UniTimeNotifications.error( MESSAGES.failedRoomAvailability(caught.getMessage()), caught); } @Override public void onSuccess(EventRoomAvailabilityRpcResponse result) { LoadingWidget.getInstance().hide(); addMeetings(result.getMeetings()); iEventAddMeetings.reset( iProperties == null ? null : iProperties.getRoomFilter(), iProperties == null ? null : iProperties.getSelectedDates(), iProperties == null ? null : iProperties.getSelectedTime()); } }); } }); iEventModifyMeetings = new AddMeetingsDialog(session, iProperties, new AsyncCallback<List<MeetingInterface>>() { @Override public void onFailure(Throwable caught) { UniTimeNotifications.error(MESSAGES.failedChangeMeetings(caught.getMessage()), caught); } @Override public void onSuccess(List<MeetingInterface> result) { final List<MeetingInterface> meetings = iMeetings.getMeetings(); if (!iEventType.isReadOnly()) iEvent.setType(getEventType()); RPC.execute( EventRoomAvailabilityRpcRequest.checkAvailability(result, getEventId(), getEventType(), iSession.getAcademicSessionId()), new AsyncCallback<EventRoomAvailabilityRpcResponse>() { @Override public void onFailure(Throwable caught) { LoadingWidget.getInstance().hide(); UniTimeNotifications.error( MESSAGES.failedRoomAvailability(caught.getMessage()), caught); } @Override public void onSuccess(EventRoomAvailabilityRpcResponse result) { LoadingWidget.getInstance().hide(); List<MeetingInterface> added = new ArrayList<EventInterface.MeetingInterface>( result.getMeetings()); current: for (Iterator<MeetingInterface> i = meetings.iterator(); i .hasNext();) { MeetingInterface meeting = i.next(); if (meeting.getApprovalStatus() != ApprovalStatus.Pending && meeting.getApprovalStatus() != ApprovalStatus.Approved) continue; if (!iSelection.contains(meeting)) continue; for (Iterator<MeetingInterface> j = added.iterator(); j.hasNext();) { MeetingInterface m = j.next(); if (m.getDayOfYear() == meeting.getDayOfYear() && EventInterface.equals(meeting.getLocation(), m.getLocation()) && meeting.getStartSlot() == m.getStartSlot() && meeting.getEndSlot() == m.getEndSlot()) { j.remove(); continue current; } } if (meeting.getId() == null) { i.remove(); } else if (meeting.getApprovalStatus() == ApprovalStatus.Cancelled || meeting.getApprovalStatus() == ApprovalStatus.Deleted) { // already cancelled or deleted } else if (meeting.isCanDelete()) { meeting.setApprovalStatus(ApprovalStatus.Deleted); meeting.setCanApprove(false); meeting.setCanCancel(false); meeting.setCanInquire(false); meeting.setCanEdit(false); meeting.setCanDelete(false); } else if (meeting.isCanCancel()) { meeting.setApprovalStatus(ApprovalStatus.Cancelled); meeting.setCanApprove(false); meeting.setCanCancel(false); meeting.setCanInquire(false); meeting.setCanEdit(false); meeting.setCanDelete(false); } } added: for (MeetingInterface meeting : added) { if (meeting.getApprovalStatus() != ApprovalStatus.Pending && meeting.getApprovalStatus() != ApprovalStatus.Approved) continue; for (MeetingInterface existing : meetings) { if (existing.getApprovalStatus() != ApprovalStatus.Pending && existing.getApprovalStatus() != ApprovalStatus.Approved) continue; if (existing.inConflict(meeting)) { UniTimeNotifications.warn(MESSAGES.warnNewMeetingOverlaps( meeting.toString(), existing.toString())); continue added; } } meetings.add(meeting); } Collections.sort(meetings); boolean hasSelection = false; for (int row = 1; row < iMeetings.getRowCount(); row++) { Widget w = iMeetings.getWidget(row, 0); if (w != null && w instanceof CheckBox) { CheckBox ch = (CheckBox) w; if (ch.getValue()) { hasSelection = true; break; } } } iMeetings.setMeetings(iEvent, meetings); showCreateButtonIfApplicable(); ValueChangeEvent.fire(iMeetings, iMeetings.getValue()); if (hasSelection) rows: for (int row = 1; row < iMeetings.getRowCount(); row++) { Widget w = iMeetings.getWidget(row, 0); if (w != null && w instanceof CheckBox) { CheckBox ch = (CheckBox) w; MeetingInterface meeting = iMeetings.getData(row).getMeeting(); for (MeetingInterface m : result.getMeetings()) { if (m.getDayOfYear() == meeting.getDayOfYear() && EventInterface.equals(meeting.getLocation(), m.getLocation()) && meeting.getStartSlot() == m.getStartSlot() && meeting.getEndSlot() == m.getEndSlot()) { ch.setValue(true); continue rows; } } } } } }); } }); iEventModifyMeetings.setText(MESSAGES.dialogModifyMeetings()); iMeetingsHeader = new UniTimeHeaderPanel(MESSAGES.sectMeetings()); iMeetingsHeader.addButton("add", MESSAGES.buttonAddMeetings(), 100, new ClickHandler() { @Override public void onClick(ClickEvent event) { iEventAddMeetings.showDialog(getEventId(), getConflicts()); } }); iMeetingsHeader.addButton("operations", MESSAGES.buttonMoreOperations(), 75, new ClickHandler() { @Override public void onClick(ClickEvent event) { final PopupPanel popup = new PopupPanel(true); iMeetings.getHeader(0).setMenu(popup); popup.showRelativeTo((UIObject) event.getSource()); ((MenuBar) popup.getWidget()).focus(); } }); iForm.addHeaderRow(iMeetingsHeader); iMeetings = new EventMeetingTable(EventMeetingTable.Mode.MeetingsOfAnEvent, true, iProperties); iMeetings.setEditable(true); iMeetings.setOperation(EventMeetingTable.OperationType.AddMeetings, this); iMeetings.setOperation(EventMeetingTable.OperationType.Delete, this); iMeetings.setOperation(EventMeetingTable.OperationType.Cancel, this); iMeetings.setOperation(EventMeetingTable.OperationType.Modify, this); iMeetings.addValueChangeHandler(new ValueChangeHandler<List<EventMeetingRow>>() { @Override public void onValueChange(ValueChangeEvent<List<EventMeetingRow>> event) { checkEnrollments(iCourses.getValue(), iMeetings.getMeetings()); showCreateButtonIfApplicable(); } }); iForm.addRow(iMeetings); iShowDeleted = new CheckBox("<i>" + MESSAGES.showDeletedMeetings() + "</i>", true); iForm.addRow(iShowDeleted); iForm.getCellFormatter().setHorizontalAlignment(iForm.getRowCount() - 1, 0, HasHorizontalAlignment.ALIGN_RIGHT); iShowDeleted.setValue(EventCookie.getInstance().isShowDeletedMeetings()); iShowDeleted.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { iMeetings.setMeetings(iEvent, iMeetings.getMeetings()); EventCookie.getInstance().setShowDeletedMeetings(event.getValue()); if (event.getValue()) iMeetings.removeStyleName("unitime-EventMeetingsHideDeleted"); else iMeetings.addStyleName("unitime-EventMeetingsHideDeleted"); } }); if (!iShowDeleted.getValue()) iMeetings.addStyleName("unitime-EventMeetingsHideDeleted"); iEnrollments = new EnrollmentTable(false, true); iEnrollments.getTable().setStyleName("unitime-Enrollments"); iEnrollmentHeader = new UniTimeHeaderPanel(MESSAGES.sectEnrollments()); iEnrollmentRow = iForm.addHeaderRow(iEnrollmentHeader); iForm.addRow(iEnrollments.getTable()); iForm.getRowFormatter().setVisible(iEnrollmentRow, false); iForm.getRowFormatter().setVisible(iEnrollmentRow + 1, false); iFooter = iHeader.clonePanel(""); iEmailConfirmationHeader = new CheckBox(MESSAGES.checkSendEmailConfirmation(), true); iEmailConfirmationHeader.addStyleName("toggle"); iHeader.getPanel().insert(iEmailConfirmationHeader, 4); iHeader.getPanel().setCellVerticalAlignment(iEmailConfirmationHeader, HasVerticalAlignment.ALIGN_MIDDLE); iEmailConfirmationFooter = new CheckBox(MESSAGES.checkSendEmailConfirmation(), true); iEmailConfirmationFooter.addStyleName("toggle"); iFooter.getPanel().insert(iEmailConfirmationFooter, 4); iFooter.getPanel().setCellVerticalAlignment(iEmailConfirmationFooter, HasVerticalAlignment.ALIGN_MIDDLE); iEmailConfirmationHeader.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { iEmailConfirmationFooter.setValue(event.getValue(), false); } }); iEmailConfirmationFooter.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { iEmailConfirmationHeader.setValue(event.getValue(), false); } }); iForm.addNotPrintableBottomRow(iFooter); iMeetings.addMouseClickListener(new UniTimeTable.MouseClickListener<EventMeetingRow>() { @Override public void onMouseClick(UniTimeTable.TableEvent<EventMeetingRow> event) { EventMeetingRow row = event.getData(); if (row == null) return; if (row.getParent() != null) row = row.getParent(); MeetingInterface meeting = row.getMeeting(); if (meeting == null) return; if (iMeetings.isSelectable(row) && (meeting.getId() == null || meeting.isCanCancel() || meeting.isCanDelete())) { List<EventMeetingRow> selection = new ArrayList<EventMeetingRow>(); selection.add(row); execute(iMeetings, OperationType.Modify, selection); } else if (!row.getMeeting().isPast() && (row.getMeeting().getApprovalStatus() == ApprovalStatus.Cancelled || row.getMeeting().getApprovalStatus() == ApprovalStatus.Deleted)) { List<EventMeetingRow> selection = new ArrayList<EventMeetingRow>(); selection.add(row); execute(iMeetings, OperationType.Modify, selection); } } }); initWidget(iForm); }