List of usage examples for com.vaadin.ui FormLayout addComponent
@Override public void addComponent(Component c)
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
@SuppressWarnings("unchecked") protected void addCommonComponentSettings(FormLayout formLayout, Object obj) { List<Object> list = (List<Object>) obj; List<Component> components = new ArrayList<Component>(list.size()); // Check if all selected components support the enabled property // TODO: Support more than the enable component. // Look for all common parameters. boolean supportEnable = true; boolean enabled = true; for (Object o : list) { if (o instanceof FlowStep) { Component component = ((FlowStep) o).getComponent(); if (!hasSetting(component, AbstractComponentRuntime.ENABLED)) { supportEnable = false;/*from ww w.jav a 2s.com*/ break; } if (enabled && !component.getBoolean(AbstractComponentRuntime.ENABLED, true)) { enabled = false; } components.add(component); } else { supportEnable = false; break; } } // Create the enabled field if all selected components support the // enabled setting. if (components.size() != 0 && supportEnable) { final CheckBox checkBox = new CheckBox("Enabled"); checkBox.setImmediate(true); checkBox.setRequired(true); checkBox.setValue(enabled); checkBox.addValueChangeListener((event) -> { for (final Component component : components) { saveSetting(AbstractComponentRuntime.ENABLED, checkBox.getValue().toString(), component); } if (listener != null) { listener.componentChanged(components); } }); checkBox.setReadOnly(readOnly); formLayout.addComponent(checkBox); } }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
protected void addResourceProperties(FormLayout formLayout, Resource resource) { TextField textField = new TextField("Resource Type"); textField.setValue(resource.getType()); textField.setReadOnly(true);/*from w ww . j a v a 2 s . c om*/ formLayout.addComponent(textField); }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
protected void addComponentProperties(FormLayout formLayout, Component component) { XMLComponent componentDefintion = context.getComponentDefinitionFactory() .getDefinition(component.getType()); addComponentName(formLayout, component); TextField textField = new TextField("Component Type"); textField.setValue(componentDefintion.getName()); textField.setReadOnly(true);/*from ww w.j a v a 2 s . c o m*/ formLayout.addComponent(textField); addResourceCombo(componentDefintion, formLayout, component); addInputModelCombo(componentDefintion, formLayout, component); addOutputModelCombo(componentDefintion, formLayout, component); }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
protected void addOutputModelCombo(XMLComponent componentDefintion, FormLayout formLayout, final Component component) { FlowStep step = getSingleFlowStep(); if (step != null) { String projectVersionId = step.getComponent().getProjectVersionId(); if ((componentDefintion.getOutputMessageType() == MessageType.ENTITY || componentDefintion.getOutputMessageType() == MessageType.ANY) && !componentDefintion.isInputOutputModelsMatch()) { final AbstractSelect combo = new ComboBox("Output Model"); combo.setImmediate(true);/*from ww w .j a v a2 s . c o m*/ combo.setNullSelectionAllowed(true); List<ModelName> models = context.getConfigurationService().findModelsInProject(projectVersionId); if (models != null) { for (ModelName model : models) { combo.addItem(model); if (isNotBlank(component.getOutputModelId()) && component.getOutputModelId().equals(model.getId())) { combo.setValue(model); } } } combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { ModelName model = (ModelName) combo.getValue(); if (model != null) { component.setOutputModel(context.getConfigurationService().findModel(model.getId())); } else { component.setOutputModel(null); } context.getConfigurationService().save((AbstractObject) component); setSource(value); } }); combo.setReadOnly(readOnly); formLayout.addComponent(combo); } } }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
protected void addComponentName(FormLayout formLayout, final Component component) { ImmediateUpdateTextField textField = new ImmediateUpdateTextField("Component Name") { private static final long serialVersionUID = 1L; protected void save(String text) { component.setName(text);//from w ww . ja v a 2 s . co m context.getConfigurationService().save(component); if (listener != null) { List<Component> components = new ArrayList<Component>(1); components.add(component); listener.componentChanged(components); } }; }; textField.setValue(component.getName()); textField.setRequired(true); textField.setDescription("Name for the component on the flow"); formLayout.addComponent(textField); }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
protected void addComponentShared(FormLayout formLayout, final Component component) { final CheckBox checkBox = new CheckBox("Shared"); checkBox.setImmediate(true);// w w w . j a v a 2s . com if (component.isShared()) { checkBox.setValue(true); } else { checkBox.setValue(false); } checkBox.setRequired(true); checkBox.setDescription("Whether this component can be reused"); checkBox.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { // TODO: Don't allow unshare if component is already on more // than 1 flow? // TODO: Refresh palette for the existing flow to have this item // display in shared definitions component.setShared((boolean) event.getProperty().getValue()); context.getConfigurationService().save(component); } }); checkBox.setReadOnly(readOnly); formLayout.addComponent(checkBox); }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
protected void addInputModelCombo(XMLComponent componentDefintion, FormLayout formLayout, final Component component) { FlowStep step = getSingleFlowStep(); if (step != null) { String projectVersionId = step.getComponent().getProjectVersionId(); if (componentDefintion.getInputMessageType() == MessageType.ENTITY || componentDefintion.getInputMessageType() == MessageType.ANY) { final AbstractSelect combo = new ComboBox("Input Model"); combo.setImmediate(true);/*from w w w .j a va 2 s. c o m*/ combo.setNullSelectionAllowed(true); List<ModelName> models = context.getConfigurationService().findModelsInProject(projectVersionId); if (models != null) { for (ModelName model : models) { combo.addItem(model); if (isNotBlank(component.getInputModelId()) && component.getInputModelId().equals(model.getId())) { combo.setValue(model); } } } combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { ModelName model = (ModelName) combo.getValue(); if (model != null) { component.setInputModel(context.getConfigurationService().findModel(model.getId())); } else { component.setInputModel(null); } if (componentDefintion.isInputOutputModelsMatch()) { component.setOutputModel(component.getInputModel()); } context.getConfigurationService().save((AbstractObject) component); setSource(value); } }); combo.setReadOnly(readOnly); formLayout.addComponent(combo); } } }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
protected void addResourceCombo(XMLComponent componentDefintion, FormLayout formLayout, final Component component) { if (componentDefintion == null) { log.info("null kaboom " + component.getName() + " " + component.getType()); }/*from ww w. j a v a2 s. c o m*/ FlowStep step = getSingleFlowStep(); if (componentDefintion.getResourceCategory() != null && componentDefintion.getResourceCategory() != ResourceCategory.NONE && step != null) { final AbstractSelect resourcesCombo = new ComboBox("Resource"); resourcesCombo.setImmediate(true); List<String> types = context.getResourceFactory() .getResourceTypes(componentDefintion.getResourceCategory()); String projectVersionId = step.getComponent().getProjectVersionId(); if (types != null) { List<Resource> resources = context.getConfigurationService().findResourcesByTypes(projectVersionId, types.toArray(new String[types.size()])); if (resources != null) { for (Resource resource : resources) { resourcesCombo.addItem(resource); } resourcesCombo.setValue(component.getResource()); } } resourcesCombo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { component.setResource((Resource) resourcesCombo.getValue()); context.getConfigurationService().save(component); } }); formLayout.addComponent(resourcesCombo); } }
From source file:org.jumpmind.metl.ui.views.design.PropertySheet.java
License:Open Source License
protected void addSettingField(final XMLSetting definition, final AbstractObjectWithSettings obj, FormLayout formLayout) { boolean required = definition.isRequired(); if (definition.isVisible()) { Component component = null; if (obj instanceof Component) { component = (Component) obj; }//from w ww . j a v a2 s .c om String description = definition.getDescription(); Type type = definition.getType(); FlowStep step = null; switch (type) { case BOOLEAN: final CheckBox checkBox = new CheckBox(definition.getName()); checkBox.setImmediate(true); boolean defaultValue = false; if (isNotBlank(definition.getDefaultValue())) { defaultValue = Boolean.parseBoolean(definition.getDefaultValue()); } checkBox.setValue(obj.getBoolean(definition.getId(), defaultValue)); checkBox.setRequired(required); checkBox.setDescription(description); checkBox.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { saveSetting(definition.getId(), checkBox.getValue().toString(), obj); if (listener != null) { List<Component> components = new ArrayList<Component>(1); components.add((Component) obj); listener.componentChanged(components); } } }); checkBox.setReadOnly(readOnly); formLayout.addComponent(checkBox); break; case CHOICE: final AbstractSelect choice = new ComboBox(definition.getName()); choice.setImmediate(true); List<String> choices = definition.getChoices() != null ? definition.getChoices().getChoice() : new ArrayList<String>(0); for (String c : choices) { choice.addItem(c); } choice.setValue(obj.get(definition.getId(), definition.getDefaultValue())); choice.setDescription(description); choice.setNullSelectionAllowed(false); choice.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { saveSetting(definition.getId(), (String) choice.getValue(), obj); } }); choice.setReadOnly(readOnly); formLayout.addComponent(choice); break; case PASSWORD: ImmediateUpdatePasswordField passwordField = new ImmediateUpdatePasswordField( definition.getName()) { private static final long serialVersionUID = 1L; protected void save(String text) { saveSetting(definition.getId(), text, obj); }; }; passwordField.setValue(obj.get(definition.getId(), definition.getDefaultValue())); passwordField.setRequired(required); passwordField.setDescription(description); passwordField.setReadOnly(readOnly); formLayout.addComponent(passwordField); break; case INTEGER: ImmediateUpdateTextField integerField = new ImmediateUpdateTextField(definition.getName()) { private static final long serialVersionUID = 1L; protected void save(String text) { saveSetting(definition.getId(), text, obj); }; }; integerField.setConverter(Integer.class); integerField.setValue(obj.get(definition.getId(), definition.getDefaultValue())); integerField.setRequired(required); integerField.setDescription(description); integerField.setReadOnly(readOnly); formLayout.addComponent(integerField); break; case TEXT: ImmediateUpdateTextField textField = new ImmediateUpdateTextField(definition.getName()) { private static final long serialVersionUID = 1L; protected void save(String text) { saveSetting(definition.getId(), text, obj); }; }; textField.setValue(obj.get(definition.getId(), definition.getDefaultValue())); textField.setRequired(required); textField.setDescription(description); textField.setReadOnly(readOnly); formLayout.addComponent(textField); break; case SOURCE_STEP: step = getSingleFlowStep(); if (step != null) { Flow flow = context.getConfigurationService().findFlow(step.getFlowId()); final AbstractSelect sourceStepsCombo = new ComboBox(definition.getName()); sourceStepsCombo.setImmediate(true); List<FlowStepLink> sourceSteps = flow.findFlowStepLinksWithTarget(step.getId()); for (FlowStepLink flowStepLink : sourceSteps) { FlowStep sourceStep = flow.findFlowStepWithId(flowStepLink.getSourceStepId()); sourceStepsCombo.addItem(sourceStep.getId()); sourceStepsCombo.setItemCaption(sourceStep.getId(), sourceStep.getName()); } sourceStepsCombo.setValue(obj.get(definition.getId())); sourceStepsCombo.setDescription(description); sourceStepsCombo.setNullSelectionAllowed(false); sourceStepsCombo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { saveSetting(definition.getId(), (String) sourceStepsCombo.getValue(), obj); } }); sourceStepsCombo.setReadOnly(readOnly); formLayout.addComponent(sourceStepsCombo); } break; case FLOW: step = getSingleFlowStep(); if (step != null) { String projectVersionId = step.getComponent().getProjectVersionId(); List<FlowName> flows = context.getConfigurationService().findFlowsInProject(projectVersionId, false); final AbstractSelect combo = new ComboBox(definition.getName()); combo.setImmediate(true); for (FlowName name : flows) { if (!step.getFlowId().equals(name.getId())) { combo.addItem(name.getId()); combo.setItemCaption(name.getId(), name.getName()); } } combo.setValue(obj.get(definition.getId())); combo.setDescription(description); combo.setNullSelectionAllowed(false); combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { saveSetting(definition.getId(), (String) combo.getValue(), obj); } }); combo.setReadOnly(readOnly); formLayout.addComponent(combo); } break; case STREAMABLE_RESOURCE: formLayout.addComponent(createResourceCombo(definition, obj, ResourceCategory.STREAMABLE)); break; case DATASOURCE_RESOURCE: formLayout.addComponent(createResourceCombo(definition, obj, ResourceCategory.DATASOURCE)); break; case ENTITY_COLUMN: if (component != null) { List<ModelEntity> entities = new ArrayList<ModelEntity>(); Model model = component.getInputModel(); if (model != null) { model.sortAttributes(); entities.addAll(model.getModelEntities()); } model = component.getOutputModel(); if (model != null) { model.sortAttributes(); entities.addAll(model.getModelEntities()); } AbstractObjectNameBasedSorter.sort(entities); final AbstractSelect entityColumnCombo = new ComboBox(definition.getName()); entityColumnCombo.setImmediate(true); for (ModelEntity modelEntity : entities) { for (ModelAttribute attribute : modelEntity.getModelAttributes()) { entityColumnCombo.addItem(attribute.getId()); entityColumnCombo.setItemCaption(attribute.getId(), modelEntity.getName() + "." + attribute.getName()); } } String currentValue = obj.get(definition.getId()); if (currentValue != null) { entityColumnCombo.setValue(obj.get(definition.getId())); } entityColumnCombo.setDescription(description); entityColumnCombo.setNullSelectionAllowed(definition.isRequired()); entityColumnCombo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { saveSetting(definition.getId(), (String) entityColumnCombo.getValue(), obj); } }); entityColumnCombo.setReadOnly(readOnly); formLayout.addComponent(entityColumnCombo); } break; case SCRIPT: final AceEditor editor = CommonUiUtils.createAceEditor(); editor.setTextChangeEventMode(TextChangeEventMode.LAZY); editor.setTextChangeTimeout(200); editor.setMode(AceMode.java); editor.setHeight(10, Unit.EM); editor.setCaption(definition.getName()); editor.setShowGutter(false); editor.setShowPrintMargin(false); editor.setValue(obj.get(definition.getId(), definition.getDefaultValue())); editor.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { Setting data = obj.findSetting(definition.getId()); data.setValue(event.getText()); context.getConfigurationService().save(data); } }); editor.setReadOnly(readOnly); formLayout.addComponent(editor); break; case MULTILINE_TEXT: case XML: ImmediateUpdateTextArea area = new ImmediateUpdateTextArea(definition.getName()) { private static final long serialVersionUID = 1L; protected void save(String text) { saveSetting(definition.getId(), text, obj); }; }; area.setValue(obj.get(definition.getId(), definition.getDefaultValue())); area.setRows(5); area.setRequired(required); area.setDescription(description); area.setReadOnly(readOnly); formLayout.addComponent(area); break; default: break; } } }
From source file:org.jumpmind.vaadin.ui.sqlexplorer.DbExportDialog.java
License:Open Source License
protected void createOptionLayout() { optionLayout = new VerticalLayout(); optionLayout.addStyleName("v-scrollable"); optionLayout.setMargin(true);//from w ww . ja va 2s . c om optionLayout.setSpacing(true); optionLayout.setSizeFull(); optionLayout.addComponent(new Label("Please choose from the following options")); FormLayout formLayout = new FormLayout(); formLayout.setSizeFull(); optionLayout.addComponent(formLayout); optionLayout.setExpandRatio(formLayout, 1); formatSelect = new ComboBox("Format"); formatSelect.setImmediate(true); for (DbExportFormat format : DbExportFormat.values()) { formatSelect.addItem(format); } formatSelect.setNullSelectionAllowed(false); formatSelect.setValue(DbExportFormat.SQL); formatSelect.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { DbExportFormat format = (DbExportFormat) formatSelect.getValue(); switch (format) { case SQL: compatibilitySelect.setEnabled(true); compatibilitySelect.setNullSelectionAllowed(false); setDefaultCompatibility(); data.setEnabled(true); foreignKeys.setEnabled(true); indices.setEnabled(true); quotedIdentifiers.setEnabled(true); break; case XML: compatibilitySelect.setEnabled(false); compatibilitySelect.setNullSelectionAllowed(true); compatibilitySelect.setValue(null); data.setEnabled(true); foreignKeys.setEnabled(true); indices.setEnabled(true); quotedIdentifiers.setEnabled(true); break; case CSV: compatibilitySelect.setEnabled(false); compatibilitySelect.setNullSelectionAllowed(true); compatibilitySelect.setValue(null); data.setEnabled(false); foreignKeys.setEnabled(false); indices.setEnabled(false); quotedIdentifiers.setEnabled(false); break; case SYM_XML: compatibilitySelect.setEnabled(false); compatibilitySelect.setNullSelectionAllowed(true); compatibilitySelect.setValue(null); data.setEnabled(false); foreignKeys.setEnabled(false); indices.setEnabled(false); quotedIdentifiers.setEnabled(false); break; } } }); formatSelect.select(DbExportFormat.SQL); formLayout.addComponent(formatSelect); compatibilitySelect = new ComboBox("Compatibility"); for (Compatible compatability : Compatible.values()) { compatibilitySelect.addItem(compatability); } compatibilitySelect.setNullSelectionAllowed(false); setDefaultCompatibility(); formLayout.addComponent(compatibilitySelect); createInfo = new CheckBox("Create Tables"); formLayout.addComponent(createInfo); dropTables = new CheckBox("Drop Tables"); formLayout.addComponent(dropTables); data = new CheckBox("Insert Data"); data.setValue(true); formLayout.addComponent(data); foreignKeys = new CheckBox("Create Foreign Keys"); formLayout.addComponent(foreignKeys); indices = new CheckBox("Create Indices"); formLayout.addComponent(indices); quotedIdentifiers = new CheckBox("Qualify with Quoted Identifiers"); formLayout.addComponent(quotedIdentifiers); whereClauseField = new TextArea("Where Clause"); whereClauseField.setWidth(100, Unit.PERCENTAGE); whereClauseField.setRows(2); formLayout.addComponent(whereClauseField); exportFormatOptionGroup = new OptionGroup("Export Format"); exportFormatOptionGroup.setImmediate(true); exportFormatOptionGroup.addItem(EXPORT_AS_A_FILE); if (queryPanel != null) { exportFormatOptionGroup.addItem(EXPORT_TO_THE_SQL_EDITOR); } exportFormatOptionGroup.setValue(EXPORT_AS_A_FILE); exportFormatOptionGroup.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { setExportButtonsEnabled(); } }); formLayout.addComponent(exportFormatOptionGroup); }