List of usage examples for com.google.gwt.user.client.ui CheckBox setEnabled
@Override public void setEnabled(boolean enabled)
From source file:org.roda.wui.common.client.tools.FacetUtils.java
private static <T extends IsIndexed> void updateFacetPanels(final AsyncTableCell<T, ?> list, final Map<String, FlowPanel> facetPanels, final List<FacetFieldResult> facetResults, final boolean hideDisabled) { for (FacetFieldResult facetResult : facetResults) { final String facetField = facetResult.getField(); FlowPanel facetPanel = facetPanels.get(facetResult.getField()); if (facetPanel != null) { facetPanel.clear();//from w w w . j a v a 2 s . c o m if (facetResult.getTotalCount() == 0) { facetPanel.getParent().addStyleName("facet-empty"); } else { facetPanel.getParent().removeStyleName("facet-empty"); } for (FacetValue facetValue : facetResult.getValues()) { final String value = facetValue.getValue(); final String label = facetValue.getLabel(); long count = facetValue.getCount(); boolean selected = facetResult.getSelectedValues().contains(value); StringBuilder checkboxLabel = new StringBuilder(); checkboxLabel.append(label); if (count > 0 || facetResult.getSelectedValues().isEmpty() || selected) { checkboxLabel.append(" (").append(count).append(")"); } CheckBox facetValuePanel = new CheckBox(checkboxLabel.toString()); facetValuePanel.setTitle(checkboxLabel.toString()); facetValuePanel.addStyleName("sidebar-facet-label"); facetValuePanel.addStyleName("fade-out"); boolean enabled = count > 0 || !facetResult.getSelectedValues().isEmpty(); facetValuePanel.setEnabled(enabled); if (hideDisabled) { facetValuePanel.setVisible(enabled); } facetPanel.add(facetValuePanel); facetValuePanel.setValue(selected); facetValuePanel.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { Facets facets = list.getFacets(); FacetParameter selectedFacetParameter = facets.getParameters().get(facetField); if (selectedFacetParameter != null) { if (event.getValue()) { selectedFacetParameter.getValues().add(value); } else { selectedFacetParameter.getValues().remove(value); } } else { LOGGER.warn("Haven't found the facet parameter: " + facetField); } list.setFacets(facets); } }); } } else { LOGGER.warn("Got a facet but haven't got a panel for it"); } } }
From source file:org.rstudio.studio.client.workbench.prefs.views.EditingPreferencesPane.java
License:Open Source License
private void disable(CheckBox checkBox) { checkBox.setValue(false); checkBox.setEnabled(false); checkBox.setVisible(false); }
From source file:org.rstudio.studio.client.workbench.prefs.views.EditingPreferencesPane.java
License:Open Source License
private void enable(CheckBox checkBox) { checkBox.setValue(true); checkBox.setEnabled(true); checkBox.setVisible(true); }
From source file:org.unitime.timetable.gwt.client.rooms.RoomEdit.java
License:Apache License
public void setRoom(RoomDetailInterface room) { iRoom = room;/*w ww. j a va 2 s. com*/ if (iRoom == null) { iRoom = new RoomDetailInterface(); iRoom.setSessionId(iProperties.getAcademicSessionId()); iRoom.setSessionName(iProperties.getAcademicSessionName()); iHeader.setEnabled("create", true); iHeader.setEnabled("update", false); iHeader.setEnabled("delete", false); } else { iHeader.setEnabled("create", false); iHeader.setEnabled("update", true); iHeader.setEnabled("delete", iRoom.isCanDelete()); } iLastControllingDept = iRoom.getControlDepartment(); iLastEventDept = iRoom.getEventDepartment(); iForm.clear(); iHeader.clearMessage(); iForm.addHeaderRow(iHeader); int firstRow = iForm.getRowCount(); if (iMode.hasSessionSelection()) { iForm.addRow(MESSAGES.propAcademicSession(), new Label( iRoom.hasSessionName() ? iRoom.getSessionName() : iProperties.getAcademicSessionName()), 1); } if (iRoom.getRoomType() == null || iRoom.isCanChangeType()) { iType.clearHint(); iType.getWidget().clear(); if (iRoom.getRoomType() == null) { iType.getWidget().addItem(MESSAGES.itemSelect(), "-1"); for (RoomTypeInterface type : iProperties.getRoomTypes()) { if (type.isRoom() && iProperties.isCanAddRoom()) iType.getWidget().addItem(type.getLabel(), type.getId().toString()); else if (!type.isRoom() && iProperties.isCanAddNonUniversity()) iType.getWidget().addItem(type.getLabel(), type.getId().toString()); } iType.getWidget().setSelectedIndex(0); } else { for (RoomTypeInterface type : iProperties.getRoomTypes()) { if (type.isRoom() && iRoom.getBuilding() != null) iType.getWidget().addItem(type.getLabel(), type.getId().toString()); else if (!type.isRoom() && iRoom.getBuilding() == null) iType.getWidget().addItem(type.getLabel(), type.getId().toString()); } for (int i = 0; i < iType.getWidget().getItemCount(); i++) { if (iType.getWidget().getValue(i).equals(iRoom.getRoomType().getId().toString())) { iType.getWidget().setSelectedIndex(i); break; } } } iForm.addRow(MESSAGES.propRoomType(), iType, 1); } else { iForm.addRow(MESSAGES.propRoomType(), new Label(iRoom.getRoomType().getLabel(), false), 1); } if (iRoom.getUniqueId() != null && iRoom.getBuilding() == null) { iBuildingRow = -1; } else if (iRoom.getUniqueId() == null || iRoom.isCanChangeRoomProperties()) { iBuilding.clearHint(); if (iRoom.getBuilding() == null) { iBuilding.getWidget().setSelectedIndex(0); } else { iBuilding.getWidget().setSelectedIndex(1 + iProperties.getBuildings().indexOf(iRoom.getBuilding())); } iBuildingRow = iForm.addRow(MESSAGES.propBuilding(), iBuilding, 1); } else { iBuildingRow = iForm.addRow(MESSAGES.propBuilding(), new Label(iRoom.getBuilding().getAbbreviation() + " - " + iRoom.getBuilding().getName()), 1); } if (iRoom.getUniqueId() == null || iRoom.isCanChangeRoomProperties()) { iName.clearHint(); iName.getWidget().setText(iRoom.getName() == null ? "" : iRoom.getName()); iForm.addRow(iNameLabel, iName, 1); } else { iForm.addRow(iNameLabel, new Label(iRoom.getName()), 1); } if (iRoom.getRoomType() == null || iRoom.isCanChangeType()) { typeChanged(); } else { if (iBuildingRow >= 0) iForm.getRowFormatter().setVisible(iBuildingRow, iRoom.getRoomType() != null && iRoom.getRoomType().isRoom()); iNameLabel .setText(iRoom.getRoomType() != null && iRoom.getRoomType().isRoom() ? MESSAGES.propRoomNumber() : MESSAGES.propRoomName()); } if (iRoom.getUniqueId() == null || iRoom.isCanChangeRoomProperties()) { iDisplayName.setText(iRoom.getDisplayName() == null ? "" : iRoom.getDisplayName()); iForm.addRow(MESSAGES.propDisplayName(), iDisplayName, 1); } else if (iRoom.hasDisplayName()) { iForm.addRow(MESSAGES.propDisplayName(), new Label(iRoom.getDisplayName()), 1); } if ((iRoom.getUniqueId() == null && iProperties.isCanChangeExternalId()) || iRoom.isCanChangeExternalId()) { iExternalId.setText(iRoom.getExternalId() == null ? "" : iRoom.getExternalId()); iForm.addRow(MESSAGES.propExternalId(), iExternalId, 1); } else if (iRoom.hasExternalId()) { iForm.addRow(MESSAGES.propExternalId(), new Label(iRoom.getExternalId()), 1); } if (iRoom.getUniqueId() == null || iRoom.isCanChangeCapacity()) { iCapacity.clearHint(); iCapacity.getWidget().setValue(iRoom.getCapacity()); iForm.addRow(MESSAGES.propCapacity(), iCapacity, 1); } else if (iRoom.getCapacity() != null) { iForm.addRow(MESSAGES.propCapacity(), new Label(iRoom.getCapacity().toString()), 1); } if ((iRoom.getUniqueId() == null && iProperties.isCanChangeControll()) || iRoom.isCanChangeControll()) { iControllingDepartment.clearHint(); iControllingDepartment.getWidget().clear(); iControllingDepartment.getWidget().addItem(MESSAGES.itemNoControlDepartment(), "-1"); for (DepartmentInterface department : iProperties.getDepartments()) iControllingDepartment.getWidget().addItem( department.getExtAbbreviationOrCode() + " - " + department.getExtLabelWhenExist(), department.getId().toString()); if (iRoom.getControlDepartment() == null) { iControllingDepartment.getWidget().setSelectedIndex(0); } else { int index = iProperties.getDepartments().indexOf(iRoom.getControlDepartment()); if (index >= 0) { iControllingDepartment.getWidget().setSelectedIndex(1 + index); } else { iControllingDepartment.getWidget().addItem( iRoom.getControlDepartment().getExtAbbreviationOrCode() + " - " + iRoom.getControlDepartment().getExtLabelWhenExist(), iRoom.getControlDepartment().getId().toString()); iControllingDepartment.getWidget() .setSelectedIndex(iControllingDepartment.getWidget().getItemCount() - 1); } } if (iRoom.getUniqueId() == null && iControllingDepartment.getWidget().getItemCount() == 2) iControllingDepartment.getWidget().setSelectedIndex(1); iForm.addRow(MESSAGES.propControllingDepartment(), iControllingDepartment, 1); /* } else if (iRoom.getUniqueId() == null) { iControllingDepartment.getWidget().clear(); for (DepartmentInterface department: iProperties.getDepartments()) iControllingDepartment.getWidget().addItem(department.getExtAbbreviationOrCode() + " - " + department.getExtLabelWhenExist(), department.getId().toString()); //TODO: guess selected department from filter iForm.addRow(MESSAGES.propDepartment(), iControllingDepartment, 1);*/ } else if (iRoom.getControlDepartment() != null && iProperties.isCanSeeCourses()) { iForm.addRow(MESSAGES.propControllingDepartment(), new Label(RoomDetail.toString(iRoom.getControlDepartment())), 1); } if (iRoom.getUniqueId() == null || iRoom.isCanChangeRoomProperties()) { iX.setValue(iRoom.getX()); iY.setValue(iRoom.getY()); iForm.addRow(MESSAGES.propCoordinates(), iCoordinates, 1); iArea.setValue(iRoom.getArea()); iAreaFormat.setText(iProperties != null && iProperties.isRoomAreaInMetricUnits() ? CONSTANTS.roomAreaMetricUnitsLong() : CONSTANTS.roomAreaUnitsLong()); iForm.addRow(MESSAGES.propRoomArea(), iAreaPanel, 1); if (iProperties.isCanSeeCourses()) { iDistanceCheck.setValue(!iRoom.isIgnoreTooFar()); distanceCheckChanged(); iForm.addRow(MESSAGES.propDistanceCheck(), iDistanceCheck, 1); } iRoomCheck.setValue(!iRoom.isIgnoreRoomCheck()); roomCheckChanged(); iForm.addRow(MESSAGES.propRoomCheck(), iRoomCheck, 1); if (iGoogleMapControl != null) iGoogleMapControl.setVisible(true); } else { if (iRoom.hasCoordinates()) if (iProperties != null && iProperties.hasEllipsoid()) iForm.addRow(MESSAGES.propCoordinates(), new HTML(MESSAGES .coordinatesWithEllipsoid(iRoom.getX(), iRoom.getY(), iProperties.getEllipsoid())), 1); else iForm.addRow(MESSAGES.propCoordinates(), new HTML(MESSAGES.coordinates(iRoom.getX(), iRoom.getY())), 1); if (iRoom.getArea() != null) iForm.addRow(MESSAGES.propRoomArea(), new HTML(MESSAGES.roomArea(iRoom.getArea()) + " " + (iProperties != null && iProperties.isRoomAreaInMetricUnits() ? CONSTANTS.roomAreaMetricUnitsShort() : CONSTANTS.roomAreaUnitsShort())), 1); if (iProperties.isCanSeeCourses()) { iForm.addRow(MESSAGES.propDistanceCheck(), new Check(!room.isIgnoreTooFar(), MESSAGES.infoDistanceCheckOn(), MESSAGES.infoDistanceCheckOff()), 1); iForm.addRow(MESSAGES.propRoomCheck(), new Check(!room.isIgnoreRoomCheck(), MESSAGES.infoRoomCheckOn(), MESSAGES.infoRoomCheckOff()), 1); } else if (iProperties.isCanSeeEvents()) { iForm.addRow(MESSAGES.propRoomCheck(), new Check(!room.isIgnoreRoomCheck(), MESSAGES.infoRoomCheckOn(), MESSAGES.infoRoomCheckOff()), 1); } if (iGoogleMapControl != null) iGoogleMapControl.setVisible(false); } if ((iRoom.getUniqueId() == null && iProperties.isCanChangeExamStatus()) || iRoom.isCanChangeExamStatus()) { for (Map.Entry<Long, CheckBox> e : iExaminationRooms.entrySet()) e.getValue().setValue(false); if (iRoom.hasExamTypes()) { for (ExamTypeInterface type : iRoom.getExamTypes()) iExaminationRooms.get(type.getId()).setValue(true); } iForm.addRow(MESSAGES.propExamRooms(), iExaminationRoomsPanel, 1); iExamCapacity.getWidget().setValue(iRoom.getExamCapacity()); iForm.addRow(MESSAGES.propExamCapacity(), iExamCapacity, 1); } else if (iProperties.isCanSeeExams() && (iRoom.getExamCapacity() != null || iRoom.hasExamTypes())) { iForm.addRow(MESSAGES.propExamCapacity(), new RoomDetail.ExamSeatingCapacityLabel(iRoom), 1); } if ((iRoom.getUniqueId() == null && iProperties.isCanChangeEventProperties()) || iRoom.isCanChangeEventProperties()) { iEventDepartment.clear(); if ((iRoom.getUniqueId() == null && iProperties.isCanChangeControll()) || (iRoom.getUniqueId() != null && (iRoom.getEventDepartment() == null || iRoom.isCanChangeControll()))) { iEventDepartment.addItem(MESSAGES.itemNoEventDepartment(), "-1"); } for (DepartmentInterface department : iProperties.getDepartments()) if (department.isEvent()) iEventDepartment.addItem(department.getDeptCode() + " - " + department.getLabel(), department.getId().toString()); if (iRoom.getEventDepartment() == null) { iEventDepartment.setSelectedIndex(0); } else { iEventDepartment.setSelectedIndex(0); for (int i = 1; i < iEventDepartment.getItemCount(); i++) { if (iEventDepartment.getValue(i).equals(iRoom.getEventDepartment().getId().toString())) { iEventDepartment.setSelectedIndex(i); break; } } if (iRoom.getEventDepartment() != null && "-1".equals(iEventDepartment.getValue(iEventDepartment.getSelectedIndex()))) { iEventDepartment.addItem( iRoom.getEventDepartment().getDeptCode() + " - " + iRoom.getEventDepartment().getLabel(), iRoom.getEventDepartment().getId().toString()); iEventDepartment.setSelectedIndex(iEventDepartment.getItemCount() + -1); } } iForm.addRow(MESSAGES.propEventDepartment(), iEventDepartment, 1); iEventStatus.getWidget() .setSelectedIndex(iRoom.getEventStatus() == null ? 0 : iRoom.getEventStatus() + 1); iEventStatus.clearHint(); iForm.addRow(MESSAGES.propEventStatus(), iEventStatus, 1); iNote.getWidget().setText(iRoom.getEventNote() == null ? "" : iRoom.getEventNote()); iForm.addRow(MESSAGES.propEventNote(), iNote, 1); iBreakTime.setValue(iRoom.getBreakTime()); iForm.addRow(MESSAGES.propBreakTime(), iBreakTimePanel, 1); } else if (iProperties.isCanSeeEvents()) { if (iRoom.getEventDepartment() != null) iForm.addRow(MESSAGES.propEventDepartment(), new Label(RoomDetail.toString(iRoom.getEventDepartment(), true)), 1); if (iRoom.getEventStatus() != null || iRoom.getDefaultEventStatus() != null) { Label status = new Label( CONSTANTS.eventStatusName()[iRoom.getEventStatus() == null ? iRoom.getDefaultEventStatus() : iRoom.getEventStatus()]); if (iRoom.getEventStatus() == null) status.addStyleName("default"); iForm.addRow(MESSAGES.propEventStatus(), status, 1); } if (iRoom.hasEventNote() || iRoom.hasDefaultEventNote()) { HTML note = new HTML(iRoom.hasEventNote() ? iRoom.getEventNote() : iRoom.getDefaultEventNote()); if (!iRoom.hasEventNote()) note.addStyleName("default"); iForm.addRow(MESSAGES.propEventNote(), note, 1); } if (iRoom.getBreakTime() != null || iRoom.getDefaultBreakTime() != null) { Label bt = new Label( (iRoom.getBreakTime() == null ? iRoom.getDefaultBreakTime() : iRoom.getBreakTime()) .toString()); if (iRoom.getBreakTime() == null) bt.addStyleName("default"); iForm.addRow(MESSAGES.propBreakTime(), bt, 1); } } if (iProperties.isGoogleMap()) { iForm.setWidget(firstRow, 2, iGoogleMap); iForm.getFlexCellFormatter().setRowSpan(firstRow, 2, iForm.getRowCount() - firstRow - 1); } if (((iRoom.getUniqueId() == null && iProperties.isCanChangeGroups()) || iRoom.isCanChangeGroups()) && !iProperties.getGroups().isEmpty()) { iForm.addHeaderRow(MESSAGES.headerRoomGroups()); for (Map.Entry<Long, CheckBox> e : iGroups.entrySet()) e.getValue().setValue(iRoom.hasGroup(e.getKey())); if (iGlobalGroupsPanel != null) { iForm.addRow(MESSAGES.propGlobalGroups(), iGlobalGroupsPanel); } else { List<GroupInterface> globalGroups = iRoom.getGlobalGroups(); if (!globalGroups.isEmpty()) iForm.addRow(MESSAGES.propGlobalGroups(), new RoomDetail.GroupsCell(globalGroups), 1); } for (DepartmentInterface dept : iProperties.getDepartments()) { P d = iGroupPanel.get(dept.getId()); if (d != null) iForm.addRow(dept.getExtLabelWhenExist() + ":", d); } } else if (iRoom.hasGroups()) { iForm.addHeaderRow(MESSAGES.headerRoomGroups()); List<GroupInterface> globalGroups = iRoom.getGlobalGroups(); if (!globalGroups.isEmpty()) iForm.addRow(MESSAGES.propGlobalGroups(), new RoomDetail.GroupsCell(globalGroups)); List<GroupInterface> departmentalGroups = iRoom.getDepartmentalGroups(null); if (!departmentalGroups.isEmpty()) iForm.addRow(MESSAGES.propDepartmenalGroups(), new RoomDetail.GroupsCell(departmentalGroups)); } if (((iRoom.getUniqueId() == null && iProperties.isCanChangeFeatures()) || iRoom.isCanChangeFeatures()) && !iProperties.getFeatures().isEmpty()) { iForm.addHeaderRow(MESSAGES.headerRoomFeatures()); for (Map.Entry<Long, CheckBox> e : iFeatures.entrySet()) e.getValue().setValue(iRoom.hasFeature(e.getKey())); P features = new P("features"); Map<Long, P> fp = new HashMap<Long, P>(); for (FeatureInterface feature : iProperties.getFeatures()) { CheckBox ch = iFeatures.get(feature.getId()); if (feature.getType() != null) { P d = fp.get(feature.getType().getId()); if (d == null) { d = new P("features"); d.setWidth("100%"); fp.put(feature.getType().getId(), d); } d.add(ch); } else { features.add(ch); } } for (FeatureInterface feature : iRoom.getFeatures()) { if (!iFeatures.containsKey(feature.getId()) && feature.getDepartment() == null) { P f = new P("feature"); f.setText(feature.getTitle()); if (feature.getType() != null) { P d = fp.get(feature.getType().getId()); if (d == null) { d = new P("features"); d.setWidth("100%"); fp.put(feature.getType().getId(), d); } d.add(f); } else { features.add(f); } } } if (features.getWidgetCount() > 0) iForm.addRow(MESSAGES.propFeatures(), features); for (FeatureTypeInterface type : iProperties.getFeatureTypes()) { P d = fp.get(type.getId()); if (d != null) iForm.addRow(type.getLabel() + ":", d); } } else if (iRoom.hasFeatures()) { iForm.addHeaderRow(MESSAGES.headerRoomFeatures()); List<FeatureInterface> features = iRoom.getFeatures((Long) null); if (!features.isEmpty()) iForm.addRow(MESSAGES.propFeatures(), new RoomDetail.FeaturesCell(features)); for (FeatureTypeInterface type : iProperties.getFeatureTypes()) { List<FeatureInterface> featuresOfType = iRoom.getFeatures(type); if (!featuresOfType.isEmpty()) iForm.addRow(type.getLabel() + ":", new RoomDetail.FeaturesCell(featuresOfType)); } } if (iRoom.hasRoomSharingModel()) { iRoomSharingHeader.clearMessage(); iRoomSharing.setEditable(iProperties.isCanEditDepartments() || (iRoom.getUniqueId() == null && iProperties.isCanChangeAvailability()) || iRoom.isCanChangeAvailability()); iRoomSharing.setModel(iRoom.getRoomSharingModel()); iRoomSharing.setVisible(true); if (iRoom.getUniqueId() == null) { iLastSelectedDepartmentId = Long.valueOf(iControllingDepartment.getWidget() .getValue(iControllingDepartment.getWidget().getSelectedIndex())); if (iLastSelectedDepartmentId > 0) iRoomSharing.addOption(iLastSelectedDepartmentId); } iForm.addHeaderRow(iRoomSharingHeader); iForm.addRow(iRoomSharing); } else if (iProperties.isCanEditDepartments() || (iRoom.getUniqueId() == null && iProperties.isCanChangeAvailability()) || iRoom.isCanChangeAvailability()) { iForm.addHeaderRow(iRoomSharingHeader); iForm.addRow(iRoomSharing); iRoomSharingHeader.showLoading(); iRoomSharing.setVisible(false); RPC.execute( RoomInterface.RoomSharingRequest.load(iRoom.getSessionId(), iRoom.getUniqueId(), false, true), new AsyncCallback<RoomSharingModel>() { @Override public void onFailure(Throwable caught) { iRoomSharingHeader .setErrorMessage(MESSAGES.failedToLoadRoomAvailability(caught.getMessage())); } @Override public void onSuccess(RoomSharingModel result) { iRoomSharingHeader.clearMessage(); iRoomSharing.setEditable(iProperties.isCanEditDepartments() || (iRoom.getUniqueId() == null && iProperties.isCanChangeAvailability()) || iRoom.isCanChangeAvailability()); iRoomSharing.setModel(result); iRoomSharing.setVisible(true); if (iRoom.getUniqueId() == null) { iLastSelectedDepartmentId = Long.valueOf(iControllingDepartment.getWidget() .getValue(iControllingDepartment.getWidget().getSelectedIndex())); if (iLastSelectedDepartmentId > 0) iRoomSharing.addOption(iLastSelectedDepartmentId); } } }); } if (iProperties.isCanEditRoomExams() || (iProperties.isCanSeeExams() && iRoom.isCanSeePeriodPreferences() && iRoom.hasExamTypes())) { iPeriodPreferencesHeaderRow = iForm.addHeaderRow(iPeriodPreferencesHeader); iForm.getRowFormatter().setVisible(iPeriodPreferencesHeaderRow, false); for (ExamTypeInterface type : iProperties.getExamTypes()) { PeriodPreferencesWidget pref = iPeriodPreferences.get(type.getId()); int row = iForm.addRow(MESSAGES.propExaminationPreferences(type.getLabel()), pref); iPeriodPreferencesRow.put(type.getId(), row); iForm.getRowFormatter().setVisible(iPeriodPreferencesRow.get(type.getId()), false); } iPeriodPreferencesHeader.clearMessage(); for (final ExamTypeInterface type : iProperties.getExamTypes()) { final PeriodPreferencesWidget pref = iPeriodPreferences.get(type.getId()); if (iRoom.hasPeriodPreferenceModel(type.getId())) { pref.setEditable(iProperties.isCanEditRoomExams()); pref.setModel(iRoom.getPeriodPreferenceModel(type.getId())); boolean visible = iExaminationRooms.get(type.getId()).getValue() && !pref.getModel().getPeriods().isEmpty(); iForm.getRowFormatter().setVisible(iPeriodPreferencesRow.get(type.getId()), visible); if (visible) iForm.getRowFormatter().setVisible(iPeriodPreferencesHeaderRow, true); } else if ((iRoom.getUniqueId() == null && iProperties.isCanChangeExamStatus()) || iRoom.isCanChangeExamStatus()) { iPeriodPreferencesHeader.showLoading(); iForm.getRowFormatter().setVisible(iPeriodPreferencesRow.get(type.getId()), false); RPC.execute(RoomInterface.PeriodPreferenceRequest.load(iRoom.getSessionId(), iRoom.getUniqueId(), type.getId()), new AsyncCallback<PeriodPreferenceModel>() { @Override public void onFailure(Throwable caught) { iPeriodPreferencesHeader.setErrorMessage( MESSAGES.failedToLoadPeriodPreferences(caught.getMessage())); } @Override public void onSuccess(PeriodPreferenceModel result) { iPeriodPreferencesHeader.clearMessage(); pref.setEditable(iProperties.isCanEditRoomExams()); pref.setModel(result); boolean visible = iExaminationRooms.get(type.getId()).getValue() && !pref.getModel().getPeriods().isEmpty(); iForm.getRowFormatter().setVisible(iPeriodPreferencesRow.get(type.getId()), visible); if (visible) iForm.getRowFormatter().setVisible(iPeriodPreferencesHeaderRow, true); } }); } else { iForm.getRowFormatter().setVisible(iPeriodPreferencesRow.get(type.getId()), false); } } } else { iPeriodPreferencesHeaderRow = -1; iPeriodPreferencesRow.clear(); } if (((iRoom.getUniqueId() == null && iProperties.isCanChangeEventAvailability()) || iRoom.isCanChangeEventAvailability()) || (iProperties.isCanSeeEvents() && iRoom.isCanSeeEventAvailability())) { iForm.addHeaderRow(iEventAvailabilityHeader); iForm.addRow(iEventAvailability); iEventAvailabilityHeader .setVisible(!"-1".equals(iEventDepartment.getValue(iEventDepartment.getSelectedIndex()))); if (iRoom.hasEventAvailabilityModel()) { iEventAvailabilityHeader.clearMessage(); iEventAvailability .setEditable((iRoom.getUniqueId() == null && iProperties.isCanChangeEventAvailability()) || iRoom.isCanChangeEventAvailability()); iEventAvailability.setModel(iRoom.getEventAvailabilityModel()); iEventAvailability .setVisible(!"-1".equals(iEventDepartment.getValue(iEventDepartment.getSelectedIndex()))); } else { iEventAvailabilityHeader.showLoading(); iEventAvailability.setVisible(false); RPC.execute(RoomInterface.RoomSharingRequest.load(iRoom.getSessionId(), iRoom.getUniqueId(), true), new AsyncCallback<RoomSharingModel>() { @Override public void onFailure(Throwable caught) { iEventAvailabilityHeader.setErrorMessage( MESSAGES.failedToLoadRoomAvailability(caught.getMessage())); } @Override public void onSuccess(RoomSharingModel result) { iEventAvailabilityHeader.clearMessage(); iEventAvailability.setEditable( (iRoom.getUniqueId() == null && iProperties.isCanChangeEventAvailability()) || iRoom.isCanChangeEventAvailability()); iEventAvailability.setModel(result); iEventAvailability.setVisible(!"-1" .equals(iEventDepartment.getValue(iEventDepartment.getSelectedIndex()))); } }); } } if (iRoom.hasPictures() || (iRoom.getUniqueId() == null && iProperties.isCanChangePicture()) || iRoom.isCanChangePicture()) { iForm.addHeaderRow(iPicturesHeader); if ((iRoom.getUniqueId() == null && iProperties.isCanChangePicture()) || iRoom.isCanChangePicture()) iForm.addRow(MESSAGES.propNewPicture(), iFileUpload); iForm.addRow(iPictures); iPictures.clearTable(1); if (iRoom.hasPictures()) { for (final RoomPictureInterface picture : iRoom.getPictures()) iPictures.addRow(picture, line(picture)); } } iForm.addBottomRow(iFooter); if (iRoom.getUniqueId() == null && iProperties.hasFutureSessions()) { int row = iForm.addHeaderRow(iApplyToHeader); iForm.getRowFormatter().addStyleName(row, "space-above"); iApplyTo.clearTable(1); long id = 0; for (AcademicSessionInterface session : iProperties.getFutureSessions()) { List<Widget> line = new ArrayList<Widget>(); CheckBox select = new CheckBox(); line.add(select); select.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { futureChanged(); } }); line.add(new Label()); line.add(new Label()); line.add(new Label()); line.add(new Label()); line.add(new Label(session.getLabel())); Integer flags = RoomCookie.getInstance().getFutureFlags(session.getId()); select.setValue(flags != null); for (FutureOperation op : FutureOperation.values()) { CheckBox ch = new CheckBox(); ch.setValue(canFutureOperation(iRoom, op) && ((flags == null && op.getDefaultSelectionNewRoom()) || (flags != null && op.in(flags)))); if (op == FutureOperation.ROOM_PROPERTIES) { ch.setValue(true); ch.setEnabled(false); } line.add(ch); } FutureRoomInterface fr = new FutureRoomInterface(); fr.setSession(session); fr.setId(--id); iApplyTo.addRow(fr, line); } for (FutureOperation op : FutureOperation.values()) { iApplyTo.setColumnVisible(6 + op.ordinal(), canFutureOperation(iRoom, op)); } iApplyTo.setColumnVisible(1, false); iApplyTo.setColumnVisible(2, false); iApplyTo.setColumnVisible(3, false); iApplyTo.setColumnVisible(4, false); iForm.addRow(iApplyTo); futureChanged(); } else if (iRoom.hasFutureRooms()) { int row = iForm.addHeaderRow(iApplyToHeader); iForm.getRowFormatter().addStyleName(row, "space-above"); iApplyTo.clearTable(1); boolean hasExtId = false, hasType = false, hasCapacity = false; for (FutureRoomInterface fr : iRoom.getFutureRooms()) { List<Widget> line = new ArrayList<Widget>(); CheckBox select = new CheckBox(); line.add(select); select.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { futureChanged(); } }); line.add(new FutureRoomNameCell(fr)); if (fr.hasExternalId()) hasExtId = true; line.add(new Label(fr.hasExternalId() ? fr.getExternalId() : "")); if (fr.hasType()) hasType = true; line.add(new Label(fr.hasType() ? fr.getType() : "")); if (fr.hasCapacity()) hasCapacity = true; line.add(new Label(fr.hasCapacity() ? fr.getCapacity().toString() : "")); line.add(new Label(fr.getSession().getLabel())); Integer flags = RoomCookie.getInstance().getFutureFlags(fr.getSession().getId()); select.setValue(flags != null); for (FutureOperation op : FutureOperation.values()) { CheckBox ch = new CheckBox(); ch.setValue(canFutureOperation(iRoom, op) && ((flags == null && op.getDefaultSelection()) || (flags != null && op.in(flags)))); line.add(ch); } iApplyTo.addRow(fr, line); } for (FutureOperation op : FutureOperation.values()) { iApplyTo.setColumnVisible(6 + op.ordinal(), canFutureOperation(iRoom, op)); } iApplyTo.setColumnVisible(1, true); iApplyTo.setColumnVisible(2, hasExtId); iApplyTo.setColumnVisible(3, hasType); iApplyTo.setColumnVisible(4, hasCapacity); iForm.addRow(iApplyTo); futureChanged(); } }
From source file:org.unitime.timetable.gwt.client.rooms.RoomFeatureEdit.java
License:Apache License
public void setProperties(RoomPropertiesInterface properties) { iProperties = properties;//from www . j a v a 2s. c om iRooms.setProperties(properties); iForm.getRowFormatter().setVisible(iTypeRow, !iProperties.getFeatureTypes().isEmpty()); iType.clear(); if (!iProperties.getFeatureTypes().isEmpty()) { iType.addItem(MESSAGES.itemNoFeatureType(), "-1"); for (FeatureTypeInterface type : iProperties.getFeatureTypes()) iType.addItem(type.getLabel(), type.getId().toString()); } iFutureSessions.clear(); iForm.getRowFormatter().setVisible(iFutureSessionsRow, iProperties.hasFutureSessions()); if (iProperties.hasFutureSessions()) { CheckBox current = new CheckBox(iProperties.getAcademicSessionName()); current.setValue(true); current.setEnabled(false); current.addStyleName("future-session"); iFutureSessions.add(current); for (AcademicSessionInterface session : iProperties.getFutureSessions()) { if (session.isCanAddGlobalRoomGroup() || session.isCanAddDepartmentalRoomGroup()) { CheckBox ch = new CheckBox(session.getLabel()); iFutureSessionsToggles.put(session.getId(), ch); ch.addStyleName("future-session"); iFutureSessions.add(ch); } } } }
From source file:org.unitime.timetable.gwt.client.rooms.RoomGroupEdit.java
License:Apache License
public void setProperties(RoomPropertiesInterface properties) { iProperties = properties;// w w w . ja v a 2s .co m iRooms.setProperties(properties); iFutureSessions.clear(); iForm.getRowFormatter().setVisible(iFutureSessionsRow, iProperties.hasFutureSessions()); if (iProperties.hasFutureSessions()) { CheckBox current = new CheckBox(iProperties.getAcademicSessionName()); current.setValue(true); current.setEnabled(false); current.addStyleName("future-session"); iFutureSessions.add(current); for (AcademicSessionInterface session : iProperties.getFutureSessions()) { if (session.isCanAddGlobalRoomGroup() || session.isCanAddDepartmentalRoomGroup()) { CheckBox ch = new CheckBox(session.getLabel()); iFutureSessionsToggles.put(session.getId(), ch); ch.addStyleName("future-session"); iFutureSessions.add(ch); } } } }
From source file:org.unitime.timetable.gwt.client.widgets.CourseFinderMultipleCourses.java
License:Apache License
protected void updateCourseDetails() { if (iLastDetails != null) { for (RequestedCourse rc : iCheckedCourses) { if (rc.equals(iLastDetails)) { rc.clearSelection();/*from ww w . j a v a2s .com*/ for (Map.Entry<Preference, CheckBox> e : iInstructionalMethods.entrySet()) if (e.getValue().isEnabled() && e.getValue().getValue()) rc.setSelectedIntructionalMethod(e.getKey(), true); if (iDetails != null) for (CourseFinderCourseDetails d : iDetails) d.onGetValue(rc); } } } int row = iCourses.getSelectedRow(); CourseAssignment record = iCourses.getData(row); iLastDetails = record; if (record == null) { if (iDetails != null) for (CourseFinderCourseDetails detail : iDetails) { detail.setValue(null); } if (isVisible() && isAttached()) AriaStatus.getInstance().setHTML(ARIA.courseFinderNoCourse()); iInstructionalMethodsPanel.clear(); iInstructionalMethods.clear(); } else { for (CourseFinderCourseDetails detail : iDetails) detail.setValue(record); if (record.hasTitle()) { if (record.hasNote()) { AriaStatus.getInstance() .setHTML(ARIA.courseFinderSelectedWithTitleAndNote(iCourses.getSelectedRow(), iCourses.getRowCount() - 1, record.getSubject(), record.getCourseNbr(), record.getTitle(), record.getNote())); } else { AriaStatus.getInstance() .setHTML(ARIA.courseFinderSelectedWithTitle(iCourses.getSelectedRow(), iCourses.getRowCount() - 1, record.getSubject(), record.getCourseNbr(), record.getTitle())); } } else { if (record.hasNote()) { AriaStatus.getInstance() .setHTML(ARIA.courseFinderSelectedWithNote(iCourses.getSelectedRow(), iCourses.getRowCount() - 1, record.getSubject(), record.getCourseNbr(), record.getNote())); } else { AriaStatus.getInstance().setHTML(ARIA.courseFinderSelected(iCourses.getSelectedRow(), iCourses.getRowCount() - 1, record.getSubject(), record.getCourseNbr())); } } iInstructionalMethodsPanel.clear(); iInstructionalMethods.clear(); if (record.hasInstructionalMethodSelection()) { P imp = new P("preference-label"); imp.setText(MESSAGES.labelInstructionalMethodPreference()); iInstructionalMethodsPanel.add(imp); for (final IdValue m : record.getInstructionalMethods()) { CheckBox ch = new CheckBox(m.getValue()); ch.setValue(isSelectedMethod(m.getId())); ch.setEnabled(isEnabled()); final Preference p = new Preference(m.getId(), m.getValue(), isSelectedMethodRequired(m.getId())); ch.addValueChangeHandler(new ValueChangeHandler<Boolean>() { @Override public void onValueChange(ValueChangeEvent<Boolean> event) { if (event.getValue()) iSelectedMethods.add(p); else iSelectedMethods.remove(p); } }); ch.addStyleName("instructional-method"); iInstructionalMethods.put(p, ch); iInstructionalMethodsPanel.add(ch); } } else if (record.hasInstructionalMethods()) { P imp = new P("preference-label"); imp.setText(MESSAGES.labelInstructionalMethodPreference()); iInstructionalMethodsPanel.add(imp); for (IdValue m : record.getInstructionalMethods()) { CheckBox ch = new CheckBox(m.getValue()); ch.addStyleName("instructional-method"); ch.setValue(true); ch.setEnabled(false); iInstructionalMethods .put(new Preference(m.getId(), m.getValue(), isSelectedMethodRequired(m.getId())), ch); iInstructionalMethodsPanel.add(ch); } } if (iRequired != null) { iInstructionalMethodsPanel.add(iRequired); } } }
From source file:tv.dyndns.kishibe.qmaclone.client.ui.WidgetMultiItemSelector.java
License:Open Source License
public void setEnabled(boolean enabled) { listBox.setEnabled(enabled);/*from w ww . ja v a 2 s. c o m*/ checkBoxMultiSelect.setEnabled(enabled); for (CheckBox checkBox : checkBoxs) { checkBox.setEnabled(enabled); } }