List of usage examples for com.vaadin.ui Label setEnabled
@Override public void setEnabled(boolean enabled)
From source file:de.symeda.sormas.ui.samples.SampleEditForm.java
License:Open Source License
@Override protected void addFields() { addField(SampleDto.LAB_SAMPLE_ID, TextField.class); DateTimeField sampleDateField = addField(SampleDto.SAMPLE_DATE_TIME, DateTimeField.class); sampleDateField.setInvalidCommitted(false); addField(SampleDto.SAMPLE_MATERIAL, ComboBox.class); addField(SampleDto.SAMPLE_MATERIAL_TEXT, TextField.class); ComboBox sampleSource = addField(SampleDto.SAMPLE_SOURCE, ComboBox.class); DateField shipmentDate = addDateField(SampleDto.SHIPMENT_DATE, DateField.class, 7); addField(SampleDto.SHIPMENT_DETAILS, TextField.class); DateField receivedDate = addField(SampleDto.RECEIVED_DATE, DateField.class); ComboBox lab = addField(SampleDto.LAB, ComboBox.class); lab.addItems(FacadeProvider.getFacilityFacade().getAllLaboratories(true)); TextField labDetails = addField(SampleDto.LAB_DETAILS, TextField.class); labDetails.setVisible(false);/* www . j a v a2s .c om*/ addField(SampleDto.SPECIMEN_CONDITION, ComboBox.class); addField(SampleDto.NO_TEST_POSSIBLE_REASON, TextField.class); addField(SampleDto.COMMENT, TextArea.class).setRows(2); CheckBox shipped = addField(SampleDto.SHIPPED, CheckBox.class); CheckBox received = addField(SampleDto.RECEIVED, CheckBox.class); ComboBox pathogenTestResultField = addField(SampleDto.PATHOGEN_TEST_RESULT, ComboBox.class); initializeRequestedTests(); // Validators sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, shipmentDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(), shipmentDate.getCaption()))); sampleDateField.addValidator(new DateComparisonValidator(sampleDateField, receivedDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, sampleDateField.getCaption(), receivedDate.getCaption()))); shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, sampleDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, shipmentDate.getCaption(), sampleDateField.getCaption()))); shipmentDate.addValidator(new DateComparisonValidator(shipmentDate, receivedDate, true, false, I18nProperties.getValidationError(Validations.beforeDate, shipmentDate.getCaption(), receivedDate.getCaption()))); receivedDate.addValidator(new DateComparisonValidator(receivedDate, sampleDateField, false, false, I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(), sampleDateField.getCaption()))); receivedDate.addValidator(new DateComparisonValidator(receivedDate, shipmentDate, false, false, I18nProperties.getValidationError(Validations.afterDate, receivedDate.getCaption(), shipmentDate.getCaption()))); FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL_TEXT, SampleDto.SAMPLE_MATERIAL, Arrays.asList(SampleMaterial.OTHER), true); FieldHelper.setVisibleWhen(getFieldGroup(), SampleDto.NO_TEST_POSSIBLE_REASON, SampleDto.SPECIMEN_CONDITION, Arrays.asList(SpecimenCondition.NOT_ADEQUATE), true); FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SAMPLE_MATERIAL, Arrays.asList(SampleDto.SAMPLE_MATERIAL_TEXT), Arrays.asList(SampleMaterial.OTHER)); FieldHelper.setRequiredWhen(getFieldGroup(), SampleDto.SPECIMEN_CONDITION, Arrays.asList(SampleDto.NO_TEST_POSSIBLE_REASON), Arrays.asList(SpecimenCondition.NOT_ADEQUATE)); addValueChangeListener(e -> { CaseDataDto caze = FacadeProvider.getCaseFacade() .getCaseDataByUuid(getValue().getAssociatedCase().getUuid()); FieldHelper.setRequiredWhen(getFieldGroup(), received, Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.SPECIMEN_CONDITION), Arrays.asList(true)); FieldHelper.setEnabledWhen(getFieldGroup(), received, Arrays.asList(true), Arrays.asList(SampleDto.RECEIVED_DATE, SampleDto.LAB_SAMPLE_ID, SampleDto.SPECIMEN_CONDITION, SampleDto.NO_TEST_POSSIBLE_REASON), true); if (caze.getDisease() != Disease.NEW_INFLUENCA) { sampleSource.setVisible(false); } if (UserProvider.getCurrent().hasUserRight(UserRight.SAMPLE_EDIT_NOT_OWNED) || UserProvider.getCurrent().getUuid().equals(getValue().getReportingUser().getUuid())) { FieldHelper.setEnabledWhen(getFieldGroup(), shipped, Arrays.asList(true), Arrays.asList(SampleDto.SHIPMENT_DATE, SampleDto.SHIPMENT_DETAILS), true); FieldHelper.setRequiredWhen(getFieldGroup(), shipped, Arrays.asList(SampleDto.SHIPMENT_DATE), Arrays.asList(true)); setRequired(true, SampleDto.SAMPLE_DATE_TIME, SampleDto.SAMPLE_MATERIAL, SampleDto.LAB); } else { getField(SampleDto.SAMPLE_DATE_TIME).setEnabled(false); getField(SampleDto.SAMPLE_MATERIAL).setEnabled(false); getField(SampleDto.SAMPLE_MATERIAL_TEXT).setEnabled(false); getField(SampleDto.LAB).setEnabled(false); getField(SampleDto.SHIPPED).setEnabled(false); getField(SampleDto.SHIPMENT_DATE).setEnabled(false); getField(SampleDto.SHIPMENT_DETAILS).setEnabled(false); getField(SampleDto.SAMPLE_SOURCE).setEnabled(false); } shipped.addValueChangeListener(event -> { if ((boolean) event.getProperty().getValue() == true) { if (shipmentDate.getValue() == null) { shipmentDate.setValue(new Date()); } } }); received.addValueChangeListener(event -> { if ((boolean) event.getProperty().getValue() == true) { if (receivedDate.getValue() == null) { receivedDate.setValue(new Date()); } } }); // Initialize referral and report information VerticalLayout reportInfoLayout = new VerticalLayout(); String reportInfoText = I18nProperties.getString(Strings.reportedOn) + " " + DateHelper.formatLocalDateTime(getValue().getReportDateTime()) + " " + I18nProperties.getString(Strings.by) + " " + getValue().getReportingUser().toString(); Label reportInfoLabel = new Label(reportInfoText); reportInfoLabel.setEnabled(false); reportInfoLayout.addComponent(reportInfoLabel); SampleReferenceDto referredFromRef = FacadeProvider.getSampleFacade() .getReferredFrom(getValue().getUuid()); if (referredFromRef != null) { SampleDto referredFrom = FacadeProvider.getSampleFacade() .getSampleByUuid(referredFromRef.getUuid()); Button referredButton = new Button(I18nProperties.getCaption(Captions.sampleReferredFrom) + " " + referredFrom.getLab().toString()); referredButton.addStyleName(ValoTheme.BUTTON_LINK); referredButton.addStyleName(CssStyles.VSPACE_NONE); referredButton.addClickListener( s -> ControllerProvider.getSampleController().navigateToData(referredFrom.getUuid())); reportInfoLayout.addComponent(referredButton); } getContent().addComponent(reportInfoLayout, REPORT_INFORMATION_LOC); if (FacadeProvider.getPathogenTestFacade().hasPathogenTest(getValue().toReference())) { pathogenTestResultField.setRequired(true); } else { pathogenTestResultField.setEnabled(false); } }); lab.addValueChangeListener(event -> { if (event.getProperty().getValue() != null && ((FacilityReferenceDto) event.getProperty().getValue()) .getUuid().equals(FacilityDto.OTHER_LABORATORY_UUID)) { labDetails.setVisible(true); labDetails.setRequired(true); } else { labDetails.setVisible(false); labDetails.setRequired(false); labDetails.clear(); } }); }
From source file:edu.kit.dama.ui.admin.GenericSpecificPropertiesLayout.java
License:Apache License
/** * Fill the layout depending on the provided configurable and properties. * * @param pConfigurable The configurable used to obtain all supported * property keys and their descriptions. * @param pProperties A set of key-value pairs for the provided * configurable.//from w w w . j a v a 2 s . co m * * @throws UIComponentUpdateException If pConfigurable is null. */ public void updateComponents(IConfigurable pConfigurable, Properties pProperties) throws UIComponentUpdateException { if (pConfigurable == null) { reset(); throw new UIComponentUpdateException("Invalid IConfigurable argument 'null'."); } //obtain all properties String[] keys = pConfigurable.getInternalPropertyKeys(); if (keys == null || keys.length == 0) { reset(); LOGGER.warn("Provided configurable has no specific properties."); return; } removeAllComponents(); for (String key : keys) { TextField propertyField = UIUtils7.factoryTextField(key, ""); if (pProperties != null) { //obtain and set the value String defaultValue = (String) pProperties.get(key); propertyField.setValue(defaultValue); propertyField.setId(key); } String description = pConfigurable.getInternalPropertyDescription(key); Label propertyDescription; if (description != null && description.length() > 1) { propertyDescription = new Label( "Description: " + pConfigurable.getInternalPropertyDescription(key)); } else { propertyDescription = new Label("No description available"); } propertyDescription.setEnabled(false); propertyField.addStyleName(CSSTokenContainer.BOLD_CAPTION); addComponent(propertyField); addComponent(propertyDescription); propertiesFields.add(propertyField); } }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageBase.java
License:Open Source License
@Override public void initGui() { setWidth("988px"); // same width as included panel setHeight(BIGGESTWINDOW_HEIGHT_S); // try to handle making the popup miss the video Instrumentation.addInstrumentation(this); Game game = Game.getTL();/*from w ww. jav a 2 s.c o m*/ MovePhase phase = game.getCurrentMove().getCurrentMovePhase(); HorizontalLayout outerLayout = new HorizontalLayout(); outerLayout.setSpacing(true); addComponent(outerLayout); outerLayout.setWidth("988px"); setExpandRatio(outerLayout, 1); Label spacer; outerLayout.addComponent(baseVLayout = new VerticalLayout()); baseVLayout.setWidth("988px"); outerLayout.setComponentAlignment(baseVLayout, Alignment.TOP_CENTER); baseVLayout.setSpacing(true); // This is just to give us a hidden widget to update to keep push channel alive through Akamai outerLayout.addComponent(pushPingLab = new HtmlLabel("")); pushPingLab.setWidth("5px"); String headingStr = phase.getOrientationCallToActionText(); String summaryStr = phase.getOrientationHeadline(); String textStr = phase.getOrientationSummary(); Media vid = phase.getOrientationVideo(); vidPan = new VideoWithRightTextPanel(vid, headingStr, summaryStr, textStr, null); vidPan.setLargeText(true); baseVLayout.addComponent(vidPan); vidPan.initGui(); HorizontalLayout bottomHLayout = new HorizontalLayout(); bottomHLayout.addComponent(spacer = new Label()); // special spacer bottomHLayout.setExpandRatio(spacer, 1.0f); Label[] spacers = new Label[5]; Label lab; int numButts = 0; // Email signup button //----------------------- if (phase.isSignupButtonShow()) { VerticalLayout signupVL = new VerticalLayout(); signupVL.setHeight("50px"); signupVL.setMargin(false); if (mockupOnly) signupVL.addComponent(signupButt = new NativeButton(null)); // no handler else signupVL.addComponent(signupButt = new NativeButton(null, this)); signupButt.addStyleName("signupbutton"); signupButt.setEnabled(phase.isSignupButtonEnabled()); Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(signupButt, phase.getSignupButtonIcon()); signupVL.setComponentAlignment(signupButt, Alignment.MIDDLE_CENTER); signupVL.addComponent(lab = new Label()); lab.setHeight("1px"); signupVL.setExpandRatio(lab, 1.0f); signupVL.addComponent(lab = new HtmlLabel(phase.getSignupButtonSubText())); lab.addStyleName("m-text-align-center"); signupButt.setDescription(phase.getSignupButtonToolTip()); lab.setDescription(phase.getSignupButtonToolTip()); lab.setEnabled(phase.isSignupButtonEnabled()); signupVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); bottomHLayout.addComponent(signupVL); numButts++; } // New player reg button //---------------------- if (phase.isNewButtonShow()) { if (numButts > 0) bottomHLayout.addComponent(spacers[numButts] = new Label()); VerticalLayout newButtVL = new VerticalLayout(); newButtVL.setHeight("50px"); newButtVL.setMargin(false); if (mockupOnly) newButtVL.addComponent(imNewButt = new NativeButton(null)); // no handler else newButtVL.addComponent(imNewButt = new NativeButton(null, this)); imNewButt.setEnabled(phase.isNewButtonEnabled()); imNewButt.addStyleName("newuserbutton"); Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(imNewButt, phase.getNewButtonIcon()); newButtVL.setComponentAlignment(imNewButt, Alignment.MIDDLE_CENTER); newButtVL.addComponent(lab = new Label()); lab.setHeight("1px"); newButtVL.setExpandRatio(lab, 1.0f); /* boolean gameRO = game.isReadonly(); boolean gameClamped = game.isRegisteredLogonsOnly(); imNewButt.setEnabled(!gameRO & !gameClamped); // Label lab; if (gameRO) { newButtVL.addComponent(lab = new Label("No new player accounts, for now")); // "Player registration is currently closed")); // //"Sorry, no more new players")); String s; lab.setDescription(s = "New player accounts will open when game play starts"); imNewButt.setDescription(s); } else if (gameClamped) newButtVL.addComponent(lab = new Label("The game is full, please retry later")); // "Sorry, no more new players")); else newButtVL.addComponent(lab = new Label("You can get started in 2 minutes...")); */ newButtVL.addComponent(lab = new HtmlLabel(phase.getNewButtonSubText())); newButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); lab.addStyleName("m-text-align-center"); lab.setEnabled(phase.isNewButtonEnabled()); imNewButt.setDescription(phase.getNewButtonToolTip()); lab.setDescription(phase.getNewButtonToolTip()); newButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); bottomHLayout.addComponent(newButtVL); numButts++; } // Existing player button //----------------------- if (phase.isLoginButtonShow()) { if (numButts > 0) bottomHLayout.addComponent(spacers[numButts] = new Label()); VerticalLayout rightButtVL = new VerticalLayout(); rightButtVL.setHeight("50px"); rightButtVL.setMargin(false); if (mockupOnly) rightButtVL.addComponent(imRegisteredButt = new NativeButton(null)); // no handler else rightButtVL.addComponent(imRegisteredButt = new NativeButton(null, this)); imRegisteredButt.addStyleName("loginbutton"); imRegisteredButt.setEnabled(phase.isLoginButtonEnabled()); Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(imRegisteredButt, phase.getLoginButtonIcon()); rightButtVL.setComponentAlignment(imRegisteredButt, Alignment.MIDDLE_CENTER); rightButtVL.addComponent(lab = new Label()); lab.setHeight("1px"); rightButtVL.setExpandRatio(lab, 1.0f); rightButtVL.addComponent(lab = new HtmlLabel(phase.getLoginButtonSubText())); lab.addStyleName("m-text-align-center"); lab.setEnabled(phase.isLoginButtonEnabled()); rightButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); imRegisteredButt.setDescription(phase.getLoginButtonToolTip()); lab.setDescription(phase.getLoginButtonToolTip()); bottomHLayout.addComponent(rightButtVL); numButts++; checkQuickCACLoginTL(); } // Guest signup button //----------------------- if (phase.isGuestButtonShow()) { if (numButts > 0) bottomHLayout.addComponent(spacers[numButts] = new Label()); VerticalLayout guestButtVL = new VerticalLayout(); guestButtVL.setHeight("50px"); guestButtVL.setMargin(false); if (mockupOnly) guestButtVL.addComponent(guestButt = new NativeButton(null)); else guestButtVL.addComponent(guestButt = new NativeButton(null, this)); guestButt.addStyleName("guestbutton"); guestButt.setEnabled(phase.isGuestButtonEnabled()); Mmowgli2UI.getGlobals().mediaLocator().decorateImageButton(guestButt, phase.getGuestButtonIcon()); guestButtVL.setComponentAlignment(guestButt, Alignment.MIDDLE_CENTER); guestButtVL.addComponent(lab = new Label()); lab.setHeight("1px"); guestButtVL.setExpandRatio(lab, 1.0f); guestButtVL.addComponent(lab = new HtmlLabel(phase.getGuestButtonSubText())); lab.addStyleName("m-text-align-center"); guestButtVL.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); guestButt.setDescription(phase.getGuestButtonToolTip()); lab.setDescription(phase.getGuestButtonToolTip()); lab.setEnabled(phase.isGuestButtonEnabled()); bottomHLayout.addComponent(guestButtVL); numButts++; } for (int i = 0; i < numButts; i++) if (spacers[i] != null) spacers[i].setWidth(BUTTON_SPACING[numButts]); bottomHLayout.addComponent(spacer = new Label()); // special spacer bottomHLayout.setExpandRatio(spacer, 1.0f); baseVLayout.addComponent(bottomHLayout); baseVLayout.setComponentAlignment(bottomHLayout, Alignment.TOP_CENTER); lab = new HtmlLabel( "<center>Each MMOWGLI game is independent.<br> You need a new account for every game. </center>"); lab.setSizeUndefined(); lab.addStyleName("m-margintop-20"); lab.addStyleName("m-greyborder"); lab.addStyleName("m-background-white"); lab.addStyleName("m-opacity-75"); baseVLayout.addComponent(lab); baseVLayout.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); String troubleUrl = GameLinks.getTL().getTroubleLink(); Link lnk = new Link("Trouble signing in?", new ExternalResource(troubleUrl)); baseVLayout.addComponent(lnk); lnk.setTargetName(PORTALTARGETWINDOWNAME); lnk.setTargetBorder(BorderStyle.DEFAULT); lnk.addStyleName("m-margin-top-20"); baseVLayout.setComponentAlignment(lnk, Alignment.MIDDLE_CENTER); //checkUserLimits(); done from app entry point }
From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java
License:Open Source License
private void addRow(int lig) { List<Object> cells = new ArrayList<Object>(); Label dateLabel = new Label(param.leftPartLine.get(lig)); dateLabel.addStyleName("date-saisie"); dateLabel.setWidth(param.largeurCol + "px"); cells.add(dateLabel);//from w ww .ja va2 s . c o m int qte = param.montant[lig]; boolean isExcluded = isExcluded(lig); if (param.readOnly) { // String txt; if (isExcluded) { txt = "XXXXXX"; } else if (qte == 0) { txt = ""; } else { txt = "" + new CurrencyTextFieldConverter().convertToString(qte); } Label tf = new Label(txt); tf.addStyleName("cell-voir"); tf.setWidth((param.largeurCol - 10) + "px"); cells.add(tf); } else { if (isExcluded) { TextField tf = new TextField(); tf.setValue("XXXXXX"); tf.setEnabled(false); tf.addStyleName("cell-voir"); tf.setWidth((param.largeurCol - 10) + "px"); cells.add(tf); } else { // // Si derniere ligne : on autorise les nombres ngatifs (sauf si on en mode de saisie de la dernire ligne) boolean allowNegativeNumber = (lig == param.nbLig - 1) && (param.computeLastLine == true); final TextField tf = BaseUiTools.createCurrencyField("", allowNegativeNumber); tf.setData(new GridIJData(lig, 0)); tf.setConvertedValue(new Integer(qte)); tf.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { try { updateModele(); } catch (ErreurSaisieException e) { NotificationHelper.displayNotificationMontant(); } } }); tf.addStyleName("cell-saisie"); tf.setWidth((param.largeurCol - 10) + "px"); shortCutManager.registerTextField(tf); cells.add(tf); // Si derniere ligne : on desactive la saisie , sauf si pas de recalcul if ((lig == param.nbLig - 1) && (param.computeLastLine == true)) { tf.setEnabled(false); lastLineTextField = tf; } } } table.addItem(cells.toArray(), new Integer(lig)); }
From source file:fr.amapj.view.engine.grid.integergrid.PopupIntegerGrid.java
License:Open Source License
private void addRow(int lig) { List<Object> cells = new ArrayList<Object>(); Label dateLabel = new Label(param.leftPartLine.get(lig), ContentMode.HTML); dateLabel.addStyleName(param.leftPartLineStyle); cells.add(dateLabel);/*from ww w. j ava 2 s . com*/ for (int j = 0; j < param.nbCol; j++) { int qte = param.qte[lig][j]; boolean isExcluded = isExcluded(lig, j); // En lecture simple if (param.readOnly) { // String txt; if (isExcluded) { txt = "XXXXXX"; } else if (qte == 0) { txt = ""; } else { txt = "" + qte; } Label tf = new Label(txt); tf.addStyleName("cell-voir"); tf.setWidth((param.largeurCol - 10) + "px"); cells.add(tf); } // En mode normal else { // Si la cellule est exclue if (isExcluded) { TextField tf = new TextField(); tf.setValue("XXXXXX"); tf.setEnabled(false); tf.addStyleName("cell-voir"); tf.setWidth((param.largeurCol - 10) + "px"); cells.add(tf); } else { // final TextField tf = BaseUiTools.createQteField(""); tf.setData(new GridIJData(lig, j)); if (qte == 0) { tf.setConvertedValue(null); } else { tf.setConvertedValue(new Integer(qte)); } tf.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { try { GridIJData ij = (GridIJData) tf.getData(); int qte = readValueInCell(tf); param.updateQte(ij.i(), ij.j(), qte); displayMontantTotal(); } catch (ErreurSaisieException e) { NotificationHelper.displayNotificationQte(); } } }); tf.addStyleName("cell-saisie"); tf.setWidth((param.largeurCol - 10) + "px"); shortCutManager.registerTextField(tf); cells.add(tf); } } } table.addItem(cells.toArray(), new Integer(lig)); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.wizard.project.GAMPStep.java
License:Apache License
@Override public Component getContent() { VerticalLayout vl = new VerticalLayout(); Label text = new Label(); text.setSizeFull();//ww w. j a va 2s. com text.setEnabled(false); text.setValue(TRANSLATOR.translate("template.gamp5.disclaimer")); getCategory().removeAllItems(); switch (wizard.getType()) { case "general.software": //Load SW options getCategory().addItem("template.gamp5.sw.cat1"); getCategory().addItem("template.gamp5.sw.cat3"); getCategory().addItem("template.gamp5.sw.cat4"); getCategory().addItem("template.gamp5.sw.cat5"); break; default: //Load HW options getCategory().addItem("template.gamp5.hw.cat1"); getCategory().addItem("template.gamp5.hw.cat2"); } wizard.translateSelect(getCategory()); vl.addComponent(getCategory()); vl.addComponent(text); vl.setSizeFull(); return vl; }
From source file:nz.co.senanque.vaadinsupport.application.MaduraSessionManager.java
License:Apache License
/** * Check all the other fields to ensure they are still valid * this includes any buttons that were registered because they * get disabled if there are errors on the relevant form or * if the requiredness is incomplete.//from w w w . j av a 2 s . c om * * @param field */ public void updateOtherFields(AbstractField field) { PermissionManager permissionmanager = getPermissionManager(); Collection<AbstractField> fields = getFields(); Collection<Label> labels = getLabels(); for (Label fieldx : labels) { com.vaadin.data.Property p = fieldx.getPropertyDataSource(); if (p != null && p instanceof LabelProperty) { fieldx.requestRepaint(); } } for (AbstractField fieldx : fields) { if (fieldx.equals(field)) continue; if ((fieldx instanceof Button) && !(fieldx instanceof CheckBox)) { com.vaadin.data.Property p = fieldx.getPropertyDataSource(); if (p != null && p instanceof ButtonProperty) { ((ButtonProperty) p).getPainter().paint((Button) fieldx); fieldx.requestRepaint(); } continue; } if (fieldx instanceof MenuItemWrapper) { MenuItemPainter menuItemPainter = ((MenuItemWrapper) fieldx).getMenuItemPainter(); MenuItem menuItem = (MenuItem) fieldx.getData(); if (menuItemPainter != null) { menuItemPainter.paint(menuItem); fieldx.requestRepaint(); } continue; } MaduraPropertyWrapper property = null; try { property = (MaduraPropertyWrapper) fieldx.getPropertyDataSource(); } catch (Exception e) { // ignore property = null; } if (property != null) { if (logger.isDebugEnabled()) { logger.debug("evaluating field: {}", property.getName()); if (fieldx.isEnabled() != property.isEnabled()) { logger.debug("Enabled: {} {}", fieldx.isEnabled(), property.isEnabled()); } if (fieldx.isReadOnly() != property.isReadOnly()) { logger.debug("ReadOnly: {} {}", fieldx.isReadOnly(), property.isReadOnly()); } if (fieldx.isRequired() != property.isRequired()) { logger.debug("Required: {} {}", fieldx.isRequired(), property.isRequired()); } if (fieldx.isVisible() != property.isVisible()) { logger.debug("Visible: {} {}", fieldx.isVisible(), property.isVisible()); } } fieldx.setEnabled(property.isEnabled()); fieldx.setReadOnly(property.isReadOnly()); fieldx.setRequired(property.isRequired()); fieldx.setVisible(property.isVisible()); // Permissions trump rules if (!permissionmanager.hasPermission(property.getReadPermission())) { fieldx.setVisible(false); } if (!permissionmanager.hasPermission(property.getWritePermission())) { fieldx.setEnabled(false); } if (fieldx instanceof AbstractSelect) { AbstractSelect select = (AbstractSelect) fieldx; List<ChoiceBase> availableList = new ArrayList<ChoiceBase>(); for (ChoiceBase v : property.getAvailableValues()) { availableList.add(v); } logger.debug("{} availableList {}", property.getName(), availableList); Collection<?> itemIds = select.getItemIds(); List<Object> killList = new ArrayList<Object>(); for (Object itemId : itemIds) { if (availableList.contains(itemId)) continue; killList.add(itemId); } for (Object kill : killList) { select.removeItem(kill); } for (ChoiceBase cb : availableList) { select.addItem(cb); } logger.debug("Select {} value \"{}\", updated to {}", new Object[] { property.getName(), select.getValue(), select.getItemIds() }); } } fieldx.requestRepaint(); } }
From source file:org.diretto.web.richwebclient.view.windows.UploadSettingsWindow.java
/** * Constructs an {@link UploadSettingsWindow}. * //from w w w . j av a2 s.c o m * @param mainWindow The corresponding {@code MainWindow} * @param uploadSection The corresponding {@code UploadSection} * @param fileInfo The {@code FileInfo} object * @param mediaType The {@code MediaType} of the file * @param uploadSettings The corresponding {@code UploadSettings} * @param otherFiles The names of the other upload files */ public UploadSettingsWindow(final MainWindow mainWindow, final UploadSection uploadSection, FileInfo fileInfo, MediaType mediaType, UploadSettings uploadSettings, List<String> otherFiles) { super("Upload Settings"); this.mainWindow = mainWindow; setModal(true); setStyleName(Reindeer.WINDOW_BLACK); setWidth("940px"); setHeight((((int) mainWindow.getHeight()) - 160) + "px"); setResizable(false); setClosable(false); setDraggable(false); setPositionX((int) (mainWindow.getWidth() / 2.0f) - 470); setPositionY(126); wrapperLayout = new HorizontalLayout(); wrapperLayout.setSizeFull(); wrapperLayout.setMargin(true, true, true, true); addComponent(wrapperLayout); mainLayout = new VerticalLayout(); mainLayout.setSizeFull(); mainLayout.setSpacing(true); HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setWidth("100%"); mainLayout.addComponent(titleLayout); HorizontalLayout leftTitleLayout = new HorizontalLayout(); titleLayout.addComponent(leftTitleLayout); titleLayout.setComponentAlignment(leftTitleLayout, Alignment.MIDDLE_LEFT); Label fileNameLabel = StyleUtils.getLabelH2(fileInfo.getName()); leftTitleLayout.addComponent(fileNameLabel); leftTitleLayout.setComponentAlignment(fileNameLabel, Alignment.MIDDLE_LEFT); Label bullLabel = StyleUtils.getLabelHTML( " • "); leftTitleLayout.addComponent(bullLabel); leftTitleLayout.setComponentAlignment(bullLabel, Alignment.MIDDLE_LEFT); Label titleLabel = StyleUtils.getLabelHTML("<b>Title</b> "); leftTitleLayout.addComponent(titleLabel); leftTitleLayout.setComponentAlignment(titleLabel, Alignment.MIDDLE_LEFT); final TextField titleField = new TextField(); titleField.setMaxLength(50); titleField.setWidth("100%"); titleField.setImmediate(true); if (uploadSettings != null && uploadSettings.getTitle() != null) { titleField.setValue(uploadSettings.getTitle()); } titleField.focus(); titleField.setCursorPosition(((String) titleField.getValue()).length()); titleLayout.addComponent(titleField); titleLayout.setComponentAlignment(titleField, Alignment.MIDDLE_RIGHT); titleLayout.setExpandRatio(leftTitleLayout, 0); titleLayout.setExpandRatio(titleField, 1); mainLayout.addComponent(StyleUtils.getHorizontalLine()); GridLayout topGridLayout = new GridLayout(2, 3); topGridLayout.setColumnExpandRatio(0, 1.0f); topGridLayout.setColumnExpandRatio(1, 0.0f); topGridLayout.setWidth("100%"); topGridLayout.setSpacing(true); mainLayout.addComponent(topGridLayout); Label descriptionLabel = StyleUtils.getLabelBold("Description"); topGridLayout.addComponent(descriptionLabel, 0, 0); final TextArea descriptionArea = new TextArea(); descriptionArea.setSizeFull(); descriptionArea.setImmediate(true); if (uploadSettings != null && uploadSettings.getDescription() != null) { descriptionArea.setValue(uploadSettings.getDescription()); } topGridLayout.addComponent(descriptionArea, 0, 1); VerticalLayout tagsWrapperLayout = new VerticalLayout(); tagsWrapperLayout.setHeight("30px"); tagsWrapperLayout.setSpacing(false); topGridLayout.addComponent(tagsWrapperLayout, 0, 2); HorizontalLayout tagsLayout = new HorizontalLayout(); tagsLayout.setWidth("100%"); tagsLayout.setSpacing(true); Label tagsLabel = StyleUtils.getLabelBoldHTML("Tags "); tagsLabel.setSizeUndefined(); tagsLayout.addComponent(tagsLabel); tagsLayout.setComponentAlignment(tagsLabel, Alignment.MIDDLE_LEFT); addTagField = new TextField(); addTagField.setImmediate(true); addTagField.setInputPrompt("Enter new Tag"); addTagField.addShortcutListener(new ShortcutListener(null, KeyCode.ENTER, new int[0]) { private static final long serialVersionUID = -4767515198819351723L; @Override public void handleAction(Object sender, Object target) { if (target == addTagField) { addTag(); } } }); tagsLayout.addComponent(addTagField); tagsLayout.setComponentAlignment(addTagField, Alignment.MIDDLE_LEFT); tabSheet = new TabSheet(); tabSheet.setStyleName(Reindeer.TABSHEET_SMALL); tabSheet.addStyleName("view"); tabSheet.addListener(new ComponentDetachListener() { private static final long serialVersionUID = -657657505471281795L; @Override public void componentDetachedFromContainer(ComponentDetachEvent event) { tags.remove(tabSheet.getTab(event.getDetachedComponent()).getCaption()); } }); Button addTagButton = new Button("Add", new Button.ClickListener() { private static final long serialVersionUID = 5914473126402594623L; @Override public void buttonClick(ClickEvent event) { addTag(); } }); addTagButton.setStyleName(Reindeer.BUTTON_DEFAULT); tagsLayout.addComponent(addTagButton); tagsLayout.setComponentAlignment(addTagButton, Alignment.MIDDLE_LEFT); Label spaceLabel = StyleUtils.getLabelHTML(""); spaceLabel.setSizeUndefined(); tagsLayout.addComponent(spaceLabel); tagsLayout.setComponentAlignment(spaceLabel, Alignment.MIDDLE_LEFT); tagsLayout.addComponent(tabSheet); tagsLayout.setComponentAlignment(tabSheet, Alignment.MIDDLE_LEFT); tagsLayout.setExpandRatio(tabSheet, 1.0f); tagsWrapperLayout.addComponent(tagsLayout); tagsWrapperLayout.setComponentAlignment(tagsLayout, Alignment.TOP_LEFT); if (uploadSettings != null && uploadSettings.getTags() != null && uploadSettings.getTags().size() > 0) { for (String tag : uploadSettings.getTags()) { addTagField.setValue(tag); addTag(); } } Label presettingLabel = StyleUtils.getLabelBold("Presetting"); topGridLayout.addComponent(presettingLabel, 1, 0); final TwinColSelect twinColSelect; if (otherFiles != null && otherFiles.size() > 0) { twinColSelect = new TwinColSelect(null, otherFiles); } else { twinColSelect = new TwinColSelect(); } twinColSelect.setWidth("400px"); twinColSelect.setRows(10); topGridLayout.addComponent(twinColSelect, 1, 1); topGridLayout.setComponentAlignment(twinColSelect, Alignment.TOP_RIGHT); Label otherFilesLabel = StyleUtils .getLabelSmallHTML("Select the files which should get the settings of this file as presetting."); otherFilesLabel.setSizeUndefined(); topGridLayout.addComponent(otherFilesLabel, 1, 2); topGridLayout.setComponentAlignment(otherFilesLabel, Alignment.MIDDLE_CENTER); mainLayout.addComponent(StyleUtils.getHorizontalLine()); final UploadGoogleMap googleMap; if (uploadSettings != null && uploadSettings.getTopographicPoint() != null) { googleMap = new UploadGoogleMap(mediaType, 12, uploadSettings.getTopographicPoint().getLatitude(), uploadSettings.getTopographicPoint().getLongitude(), MapType.HYBRID); } else { googleMap = new UploadGoogleMap(mediaType, 12, 48.42255269321401d, 9.956477880477905d, MapType.HYBRID); } googleMap.setWidth("100%"); googleMap.setHeight("300px"); mainLayout.addComponent(googleMap); mainLayout.addComponent(StyleUtils.getHorizontalLine()); GridLayout bottomGridLayout = new GridLayout(3, 3); bottomGridLayout.setSizeFull(); bottomGridLayout.setSpacing(true); mainLayout.addComponent(bottomGridLayout); Label licenseLabel = StyleUtils.getLabelBold("License"); bottomGridLayout.addComponent(licenseLabel, 0, 0); final TextArea licenseArea = new TextArea(); licenseArea.setWidth("320px"); licenseArea.setHeight("175px"); licenseArea.setImmediate(true); if (uploadSettings != null && uploadSettings.getLicense() != null) { licenseArea.setValue(uploadSettings.getLicense()); } bottomGridLayout.addComponent(licenseArea, 0, 1); final Label startTimeLabel = StyleUtils.getLabelBold("Earliest possible Start Date"); startTimeLabel.setSizeUndefined(); bottomGridLayout.setComponentAlignment(startTimeLabel, Alignment.TOP_CENTER); bottomGridLayout.addComponent(startTimeLabel, 1, 0); final InlineDateField startTimeField = new InlineDateField(); startTimeField.setImmediate(true); startTimeField.setResolution(InlineDateField.RESOLUTION_SEC); boolean currentTimeAdjusted = false; if (uploadSettings != null && uploadSettings.getTimeRange() != null && uploadSettings.getTimeRange().getStartDateTime() != null) { startTimeField.setValue(uploadSettings.getTimeRange().getStartDateTime().toDate()); } else { currentTimeAdjusted = true; startTimeField.setValue(new Date()); } bottomGridLayout.setComponentAlignment(startTimeField, Alignment.TOP_CENTER); bottomGridLayout.addComponent(startTimeField, 1, 1); final CheckBox exactTimeCheckBox = new CheckBox("This is the exact point in time."); exactTimeCheckBox.setImmediate(true); bottomGridLayout.setComponentAlignment(exactTimeCheckBox, Alignment.TOP_CENTER); bottomGridLayout.addComponent(exactTimeCheckBox, 1, 2); final Label endTimeLabel = StyleUtils.getLabelBold("Latest possible Start Date"); endTimeLabel.setSizeUndefined(); bottomGridLayout.setComponentAlignment(endTimeLabel, Alignment.TOP_CENTER); bottomGridLayout.addComponent(endTimeLabel, 2, 0); final InlineDateField endTimeField = new InlineDateField(); endTimeField.setImmediate(true); endTimeField.setResolution(InlineDateField.RESOLUTION_SEC); if (uploadSettings != null && uploadSettings.getTimeRange() != null && uploadSettings.getTimeRange().getEndDateTime() != null) { endTimeField.setValue(uploadSettings.getTimeRange().getEndDateTime().toDate()); } else { endTimeField.setValue(startTimeField.getValue()); } bottomGridLayout.setComponentAlignment(endTimeField, Alignment.TOP_CENTER); bottomGridLayout.addComponent(endTimeField, 2, 1); if (!currentTimeAdjusted && ((Date) startTimeField.getValue()).equals((Date) endTimeField.getValue())) { exactTimeCheckBox.setValue(true); endTimeLabel.setEnabled(false); endTimeField.setEnabled(false); } exactTimeCheckBox.addListener(new ValueChangeListener() { private static final long serialVersionUID = 7193545421803538364L; @Override public void valueChange(ValueChangeEvent event) { if ((Boolean) event.getProperty().getValue()) { endTimeLabel.setEnabled(false); endTimeField.setEnabled(false); } else { endTimeLabel.setEnabled(true); endTimeField.setEnabled(true); } } }); mainLayout.addComponent(StyleUtils.getHorizontalLine()); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true, false, false, false); buttonLayout.setSpacing(false); HorizontalLayout uploadButtonLayout = new HorizontalLayout(); uploadButtonLayout.setMargin(false, true, false, false); uploadButton = new Button("Upload File", new Button.ClickListener() { private static final long serialVersionUID = 8013811216568950479L; @Override @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { String titleValue = titleField.getValue().toString().trim(); Date startTimeValue = (Date) startTimeField.getValue(); Date endTimeValue = (Date) endTimeField.getValue(); boolean exactTimeValue = (Boolean) exactTimeCheckBox.getValue(); if (titleValue.equals("")) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils.getLabelHTML("A title entry is required.")); mainWindow.addWindow(confirmWindow); } else if (titleValue.length() < 5 || titleValue.length() > 50) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils .getLabelHTML("The number of characters of the title has to be between 5 and 50.")); mainWindow.addWindow(confirmWindow); } else if (!exactTimeValue && startTimeValue.after(endTimeValue)) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries", StyleUtils.getLabelHTML("The second date has to be after the first date.")); mainWindow.addWindow(confirmWindow); } else if (startTimeValue.after(new Date()) || (!exactTimeValue && endTimeValue.after(new Date()))) { ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries", StyleUtils.getLabelHTML("The dates are not allowed to be in the future.")); mainWindow.addWindow(confirmWindow); } else { disableButtons(); String descriptionValue = descriptionArea.getValue().toString().trim(); String licenseValue = licenseArea.getValue().toString().trim(); TopographicPoint topographicPointValue = googleMap.getMarkerPosition(); Collection<String> presettingValues = (Collection<String>) twinColSelect.getValue(); if (exactTimeValue) { endTimeValue = startTimeValue; } TimeRange timeRange = new TimeRange(new DateTime(startTimeValue), new DateTime(endTimeValue)); UploadSettings uploadSettings = new UploadSettings(titleValue, descriptionValue, licenseValue, new Vector<String>(tags), topographicPointValue, timeRange); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.upload(uploadSettings, new Vector<String>(presettingValues)); } } }); uploadButton.setStyleName(Reindeer.BUTTON_DEFAULT); uploadButtonLayout.addComponent(uploadButton); buttonLayout.addComponent(uploadButtonLayout); HorizontalLayout cancelButtonLayout = new HorizontalLayout(); cancelButtonLayout.setMargin(false, true, false, false); cancelButton = new Button("Cancel", new Button.ClickListener() { private static final long serialVersionUID = -2565870159504952913L; @Override public void buttonClick(ClickEvent event) { disableButtons(); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.cancelUpload(); } }); cancelButton.setStyleName(Reindeer.BUTTON_DEFAULT); cancelButtonLayout.addComponent(cancelButton); buttonLayout.addComponent(cancelButtonLayout); cancelAllButton = new Button("Cancel All", new Button.ClickListener() { private static final long serialVersionUID = -8578124709201789182L; @Override public void buttonClick(ClickEvent event) { disableButtons(); mainWindow.removeWindow(event.getButton().getWindow()); requestRepaint(); uploadSection.cancelAllUploads(); } }); cancelAllButton.setStyleName(Reindeer.BUTTON_DEFAULT); buttonLayout.addComponent(cancelAllButton); mainLayout.addComponent(buttonLayout); mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER); wrapperLayout.addComponent(mainLayout); }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.QueryPanel.java
License:Open Source License
protected boolean execute(final boolean runAsScript, String sqlText, final int tabPosition, final boolean forceNewTab) { boolean scheduled = false; if (runnersInProgress == null) { runnersInProgress = new HashSet<SqlRunner>(); }/* w ww .ja v a2 s.c o m*/ if (sqlText == null) { if (!runAsScript) { sqlText = selectSqlToRun(); } else { sqlText = sqlArea.getValue(); } sqlText = sqlText != null ? sqlText.trim() : null; } if (StringUtils.isNotBlank(sqlText)) { final HorizontalLayout executingLayout = new HorizontalLayout(); executingLayout.setMargin(true); executingLayout.setSizeFull(); final Label label = new Label("Executing:\n\n" + StringUtils.abbreviate(sqlText, 250), ContentMode.PREFORMATTED); label.setEnabled(false); executingLayout.addComponent(label); executingLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final String sql = sqlText; final Tab executingTab; if (!forceNewTab && generalResultsTab != null) { replaceGeneralResultsWith(executingLayout, FontAwesome.SPINNER); executingTab = null; } else { executingTab = resultsTabs.addTab(executingLayout, StringUtils.abbreviate(sql, 20), FontAwesome.SPINNER, tabPosition); } if (executingTab != null) { executingTab.setClosable(true); resultsTabs.setSelectedTab(executingTab); } final SqlRunner runner = new SqlRunner(sql, runAsScript, user, db, settingsProvider.get(), this, generalResultsTab != null); runnersInProgress.add(runner); runner.setConnection(connection); runner.setListener(new SqlRunner.ISqlRunnerListener() { private static final long serialVersionUID = 1L; @Override public void writeSql(String sql) { QueryPanel.this.appendSql(sql); } @Override public void reExecute(String sql) { QueryPanel.this.reExecute(sql); } public void finished(final FontAwesome icon, final List<Component> results, final long executionTimeInMs, final boolean transactionStarted, final boolean transactionEnded) { VaadinSession.getCurrent().access(new Runnable() { @Override public void run() { try { if (transactionEnded) { transactionEnded(); } else if (transactionStarted) { rollbackButtonValue = true; commitButtonValue = true; setButtonsEnabled(); sqlArea.setStyleName("transaction-in-progress"); connection = runner.getConnection(); } addToSqlHistory(StringUtils.abbreviate(sql, 1024 * 8), runner.getStartTime(), executionTimeInMs, user); for (Component resultComponent : results) { resultComponent.setSizeFull(); if (forceNewTab || generalResultsTab == null || results.size() > 1) { if (resultComponent instanceof TabularResultLayout) { resultComponent = ((TabularResultLayout) resultComponent) .refreshWithoutSaveButton(); } addResultsTab(resultComponent, StringUtils.abbreviate(sql, 20), icon, tabPosition); } else { replaceGeneralResultsWith(resultComponent, icon); resultsTabs.setSelectedTab(generalResultsTab.getComponent()); } String statusVal; if (canceled) { statusVal = "Sql canceled after " + executionTimeInMs + " ms for " + db.getName() + ". Finished at " + SimpleDateFormat.getTimeInstance().format(new Date()); } else { statusVal = "Sql executed in " + executionTimeInMs + " ms for " + db.getName() + ". Finished at " + SimpleDateFormat.getTimeInstance().format(new Date()); } status.setValue(statusVal); resultStatuses.put(resultComponent, statusVal); canceled = false; } } finally { setButtonsEnabled(); if (executingTab != null) { resultsTabs.removeTab(executingTab); } else if (results.size() > 1) { resetGeneralResultsTab(); } runnersInProgress.remove(runner); runner.setListener(null); } } }); } }); final Button cancel = new Button("Cancel"); cancel.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { log.info("Canceling sql: " + sql); label.setValue("Canceling" + label.getValue().substring(9)); executingLayout.removeComponent(cancel); canceled = true; new Thread(new Runnable() { @Override public void run() { runner.cancel(); } }).start(); } }); executingLayout.addComponent(cancel); scheduled = true; runner.start(); } setButtonsEnabled(); return scheduled; }
From source file:org.processbase.ui.bpm.development.ModulesJarPanel.java
License:Open Source License
@Override public void refreshTable() { try {/*from www .java 2 s .c o m*/ table.removeAllItems(); GsonBuilder gb = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ"); Gson gson = gb.create(); Type collectionType = new TypeToken<LinkedList<String>>() { }.getType(); LinkedList<String> jarList = new LinkedList<String>(); String metaDataString = ProcessbaseApplication.getCurrent().getBpmModule() .getMetaData("PROCESSBASE_UI_JAR_LIST"); if (metaDataString != null) { LinkedList<String> savedJarList = gson.fromJson(metaDataString, collectionType); if (!savedJarList.isEmpty()) { jarList.addAll(savedJarList); } } for (String name : jarList) { Item woItem = table.addItem(name); Label teb = new Label(name); Attributes mainAttributes = getManifestAttributes(name); String bungleVersion = ""; String bungleName = "MANIFEST ATTRIBUTES NOT FOUND"; if (mainAttributes != null) { bungleVersion = mainAttributes.getValue("Bundle-Version"); bungleName = mainAttributes.getValue("Bundle-Name"); } else { teb.setEnabled(false); } woItem.getItemProperty("fileName").setValue(teb); woItem.getItemProperty("bungleName").setValue(bungleName); woItem.getItemProperty("bungleVersion").setValue(bungleVersion); TableLinkButton tlb = new TableLinkButton( ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDelete"), "icons/cancel.png", name, this, Constants.ACTION_DELETE); woItem.getItemProperty("actions").setValue(tlb); } table.setSortContainerPropertyId("fileName"); table.setSortAscending(false); table.sort(); } catch (Exception ex) { ex.printStackTrace(); showError(ex.getMessage()); } }