List of usage examples for com.vaadin.ui AbstractField getValue
public V getValue();
From source file:de.escidoc.admintool.view.start.AbstractStartButtonListener.java
License:Open Source License
private void testConnection(final AbstractField escidocUriField) { if (validateConnection(escidocUriField)) { initApplication();//from www . ja v a 2 s . c o m } else { mainWindow.showNotification(new Window.Notification("Can not connect to: " + escidocUriField.getValue(), Notification.TYPE_ERROR_MESSAGE)); } }
From source file:de.escidoc.admintool.view.start.AbstractStartButtonListener.java
License:Open Source License
private boolean validateConnection(final AbstractField escidocUriField) { final String strUrl = (String) escidocUriField.getValue(); URLConnection connection;//w w w. j av a 2s. c o m try { connection = new URL(strUrl).openConnection(); connection.setConnectTimeout(FIVE_SECONDS); connection.connect(); final int responseCode = ((HttpURLConnection) connection).getResponseCode(); return responseCode == 200; } catch (final IllegalArgumentException e) { LOG.warn("Malformed URL: " + e); mainWindow.showNotification(new Notification(e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); return false; } catch (final MalformedURLException e) { LOG.warn("Malformed URL: " + e); mainWindow.showNotification(new Notification(e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); return false; } catch (final IOException e) { LOG.warn("IOException: " + e); mainWindow.showNotification(new Notification(e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); return false; } }
From source file:de.escidoc.admintool.view.start.StartButtonListener.java
License:Open Source License
private void validate(final AbstractField escidocUriField) { try {// w w w.jav a 2s. c om escidocUriField.validate(); if (tryToConnect(escidocUriField)) { login(); } else { mainWindow.showNotification(new Notification(CAN_NOT_CONNECT_TO + escidocUriField.getValue(), Notification.TYPE_WARNING_MESSAGE)); } } catch (final EmptyValueException e) { mainWindow.showNotification(new Notification(e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); } }
From source file:de.escidoc.admintool.view.start.StartButtonListener.java
License:Open Source License
private boolean tryToConnect(final AbstractField escidocUriField) { final String strUrl = (String) escidocUriField.getValue(); URLConnection connection;//from w w w . j a va 2 s .co m try { connection = new URL(strUrl).openConnection(); connection.setConnectTimeout(FIVE_SECONDS); connection.connect(); final int responseCode = ((HttpURLConnection) connection).getResponseCode(); return responseCode == 200; } catch (final IllegalArgumentException e) { LOG.warn("Malformed URL: " + e); mainWindow.showNotification(new Notification(e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); return false; } catch (final MalformedURLException e) { LOG.warn("Malformed URL: " + e); mainWindow.showNotification(new Notification(e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); return false; } catch (final IOException e) { LOG.warn("IOException: " + e); mainWindow.showNotification(new Notification(e.getMessage(), Notification.TYPE_ERROR_MESSAGE)); return false; } }
From source file:de.escidoc.admintool.view.validator.EmptyFieldValidator.java
License:Open Source License
/** * A simple validator to test, if the field is filled. * /*from w w w . j a va 2 s .co m*/ * @param field * The field to test. * @param message * The message that should be shown (as a tooltip) if the result is bad. * @return true if the field is filled, otherwise false. */ public static synchronized boolean isValid(final AbstractField field, final String message) { if (!(field.getValue() != null && ((String) field.getValue()).trim().length() > 0)) { field.setComponentError(null); field.setComponentError(new UserError(message)); return false; } field.setComponentError(null); return true; }
From source file:fi.semantum.strategia.widget.Indicator.java
License:Open Source License
public static String updateIndicatorValue(final Main main, HorizontalLayout hl, final Base base, final Indicator indicator, boolean canWrite) { final Database database = main.getDatabase(); Datatype dt = indicator.getDatatype(database); if (dt != null) { final AbstractField<?> field = dt.getEditor(main, base, indicator, false, null); field.setWidth("150px"); field.setReadOnly(!canWrite);/*w w w . j ava2 s . com*/ hl.addComponent(field); hl.setComponentAlignment(field, Alignment.MIDDLE_LEFT); Object value = field.getValue(); return value != null ? value.toString() : ""; } else { Object value = indicator.getValue(); final String formatted = value != null ? value.toString() : ""; final TextField tf = new TextField(); tf.setValue(formatted); tf.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 3547126051252580446L; @Override public void valueChange(ValueChangeEvent event) { try { double value = Double.parseDouble(tf.getValue()); indicator.updateWithComment(main, base, value, main.getUIState().forecastMeters, new AbstractCommentCallback() { public void canceled() { tf.setValue(formatted); } }); } catch (NumberFormatException e) { tf.setComponentError(new UserError("Arvon tulee olla numero")); } } }); tf.setWidth("150px"); tf.setReadOnly(!canWrite); hl.addComponent(tf); hl.setComponentAlignment(tf, Alignment.MIDDLE_LEFT); return tf.getValue(); } }
From source file:info.magnolia.ui.form.field.AbstractCustomMultiField.java
License:Open Source License
@Override public boolean isEmpty() { boolean isEmpty = false; List<AbstractField<T>> fields = getFields(this, false); for (AbstractField<T> field : fields) { isEmpty = field.getValue() == null; if (isEmpty) { return isEmpty; }//from w ww. j a v a2 s .com } return isEmpty; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.execution.ExecutionWizardStep.java
License:Apache License
@Override public boolean onAdvance() { //Can only proceed after the current step is executed and documented. String answer = ((String) result.getValue()); String answer2 = ((String) review.getValue()); boolean pass = true; if (answer == null) { Notification.show(TRANSLATOR.translate("unable.to.proceed"), result.getRequiredError(), Notification.Type.WARNING_MESSAGE); } else if (reviewer && answer2 == null) { Notification.show(TRANSLATOR.translate("unable.to.proceed"), review.getRequiredError(), Notification.Type.WARNING_MESSAGE); } else {/* w ww.j a va2s . co m*/ //Check all fields for answers for (AbstractField field : fields) { if (field.isRequired() && !(field instanceof CheckBox) && field.isEmpty()) { Notification.show(TRANSLATOR.translate("unable.to.proceed"), field.getRequiredError(), Notification.Type.WARNING_MESSAGE); pass = false; } } if (pass) { try { //Save the result ExecutionResult newResult = ExecutionResultServer.getResult(answer); ReviewResult newReview = ReviewResultServer.getReview(answer2); getExecutionStep().setExecutionStart(start.getValue()); if (getExecutionStep().getResultId() == null || !Objects.equals(getExecutionStep().getResultId().getId(), newResult.getId())) { getExecutionStep().setResultId(newResult); //Set end date to null to reflect update getExecutionStep().setExecutionEnd(null); } if (reviewer && (getExecutionStep().getReviewResultId() == null || !Objects .equals(getExecutionStep().getReviewResultId().getId(), newReview.getId()))) { getExecutionStep().setReviewResultId(newReview); getExecutionStep().setReviewer(ValidationManagerUI.getInstance().getUser()); } if (getExecutionStep().getExecutionEnd() == null) { getExecutionStep().setExecutionEnd(new Date()); } if (reviewer && getExecutionStep().getReviewDate() == null) { getExecutionStep().setReviewDate(new Date()); } if (getExecutionStep().getExecutionStepAnswerList() == null) { getExecutionStep().setExecutionStepAnswerList(new ArrayList<>()); } if (getExecutionStep().getExecutionStepHasVmUserList() == null) { getExecutionStep().setExecutionStepHasVmUserList(new ArrayList<>()); } getExecutionStep().getExecutionStepAnswerList().clear(); for (AbstractField field : fields) { //The field has the field name as data if (field.getData() == null) { pass = false; LOG.log(Level.SEVERE, "Field missing data! {0}", field); } else { String fieldName = (String) field.getData(); ExecutionStepAnswer stepAnswer = new ExecutionStepAnswer( getExecutionStep().getExecutionStepPK().getTestCaseExecutionId(), getExecutionStep().getExecutionStepPK().getStepId(), getExecutionStep().getExecutionStepPK().getStepTestCaseId()); stepAnswer.setExecutionStep(getExecutionStep().getEntity()); stepAnswer.setFieldName(fieldName); stepAnswer.setFieldAnswer(field.getValue().toString()); getExecutionStep().getExecutionStepAnswerList().add(stepAnswer); } } } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); } } } boolean validAnswer = result.getValue() != null && !((String) result.getValue()).trim().isEmpty(); boolean validReview = review.getValue() != null && !((String) review.getValue()).trim().isEmpty(); return reviewer ? validReview && validAnswer : validAnswer && pass; }
From source file:org.eclipse.hawkbit.ui.common.CommonDialogWindow.java
License:Open Source License
/** * saves the original values in a Map so we can use them for detecting * changes/*from w w w.j a v a2 s .c om*/ */ public final void setOrginaleValues() { for (final AbstractField<?> field : allComponents) { Object value = field.getValue(); if (field instanceof Table) { value = ((Table) field).getContainerDataSource().getItemIds(); } orginalValues.put(field, value); } saveButton.setEnabled(isSaveButtonEnabledAfterValueChange(null, null)); }
From source file:org.eclipse.hawkbit.ui.common.CommonDialogWindow.java
License:Open Source License
private static Object getCurrentValue(final Component currentChangedComponent, final Object newValue, final AbstractField<?> field) { Object currentValue = field.getValue(); if (field instanceof Table) { currentValue = ((Table) field).getContainerDataSource().getItemIds(); }/*from w ww . ja v a 2 s . c o m*/ if (field.equals(currentChangedComponent)) { currentValue = newValue; } return currentValue; }