Example usage for com.vaadin.ui CheckBox CheckBox

List of usage examples for com.vaadin.ui CheckBox CheckBox

Introduction

In this page you can find the example usage for com.vaadin.ui CheckBox CheckBox.

Prototype

public CheckBox(String caption) 

Source Link

Document

Creates a new checkbox with a set caption.

Usage

From source file:org.jpos.qi.system.LogListenerView.java

License:Open Source License

public LogEvent log(LogEvent event) {
    String r = event.getRealm();//from   w  w w .j av a 2  s. c  o  m
    CheckBox cb = realms.get(r);
    if (cb != null) {
        if (!cb.getValue())
            return event; // ignore
    } else {
        getSession().getLockInstance().lock();
        try {
            cb = new CheckBox(r);
            cb.setValue(true);
            realms.put(r, cb);
            realmsLayout.setSizeUndefined();
        } finally {
            if (getSession() != null)
                getSession().getLockInstance().unlock();
        }
        realmsLayout.addComponent(cb);
    }
    sp.out(key, new FrozenLogEvent(event), BUFFER_TIMEOUT);
    return event;
}

From source file:org.jumpmind.metl.ui.mapping.EditMappingPanel.java

License:Open Source License

protected void buildUI() {
    if (!readOnly) {
        ButtonBar buttonBar = new ButtonBar();
        addComponent(buttonBar);//w w  w.  j  a v a 2  s .c o  m
        Button autoMapButton = buttonBar.addButton("Auto Map", FontAwesome.FLASH);
        removeButton = buttonBar.addButton("Remove", FontAwesome.TRASH_O);
        removeButton.setEnabled(false);
        autoMapButton.addClickListener(new AutoMapListener());
        removeButton.addClickListener(new RemoveListener());
    }

    HorizontalLayout titleHeader = new HorizontalLayout();
    titleHeader.setSpacing(true);
    titleHeader.setMargin(new MarginInfo(false, true, false, true));
    titleHeader.setWidth(100f, Unit.PERCENTAGE);
    titleHeader.addComponent(new Label(
            "<b>Input Model:</b> &nbsp;"
                    + (component.getInputModel() != null ? component.getInputModel().getName() : "?"),
            ContentMode.HTML));
    titleHeader.addComponent(new Label(
            "<b>Output Model:</b> &nbsp;"
                    + (component.getOutputModel() != null ? component.getOutputModel().getName() : "?"),
            ContentMode.HTML));
    addComponent(titleHeader);

    HorizontalLayout filterHeader = new HorizontalLayout();
    filterHeader.setSpacing(true);
    filterHeader.setMargin(new MarginInfo(true, true, true, true));
    filterHeader.setWidth(100f, Unit.PERCENTAGE);
    HorizontalLayout srcFilterHeader = new HorizontalLayout();
    srcFilterHeader.setSpacing(true);
    srcFilterHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    filterHeader.addComponent(srcFilterHeader);
    HorizontalLayout dstFilterHeader = new HorizontalLayout();
    dstFilterHeader.setSpacing(true);
    dstFilterHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    filterHeader.addComponent(dstFilterHeader);
    addComponent(filterHeader);

    srcTextFilter = new TextField();
    srcTextFilter.setInputPrompt("Filter");
    srcTextFilter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    srcTextFilter.setIcon(FontAwesome.SEARCH);
    srcTextFilter.setImmediate(true);
    srcTextFilter.setTextChangeEventMode(TextChangeEventMode.LAZY);
    srcTextFilter.setTextChangeTimeout(200);
    srcTextFilter.addTextChangeListener(new FilterInputTextListener());
    srcFilterHeader.addComponent(srcTextFilter);

    srcMapFilter = new CheckBox("Mapped Only");
    srcMapFilter.addValueChangeListener(new FilterSrcMapListener());
    srcFilterHeader.addComponent(srcMapFilter);

    dstTextFilter = new TextField();
    dstTextFilter.setInputPrompt("Filter");
    dstTextFilter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    dstTextFilter.setIcon(FontAwesome.SEARCH);
    dstTextFilter.setImmediate(true);
    dstTextFilter.setTextChangeEventMode(TextChangeEventMode.LAZY);
    dstTextFilter.setTextChangeTimeout(200);
    dstTextFilter.addTextChangeListener(new FilterOutputTextListener());
    dstFilterHeader.addComponent(dstTextFilter);

    dstMapFilter = new CheckBox("Mapped Only");
    dstMapFilter.addValueChangeListener(new FilterDstMapListener());
    dstFilterHeader.addComponent(dstMapFilter);

    Panel panel = new Panel();
    VerticalLayout vlay = new VerticalLayout();
    vlay.setSizeFull();
    diagram = new MappingDiagram(context, component, readOnly);
    diagram.setSizeFull();
    vlay.addComponent(diagram);
    panel.setContent(vlay);
    panel.setSizeFull();
    addComponent(panel);
    setExpandRatio(panel, 1.0f);
    diagram.addListener(new EventListener());
}

From source file:org.jumpmind.metl.ui.views.admin.GroupEditPanel.java

License:Open Source License

public GroupEditPanel(ApplicationContext context, Group group) {
    this.context = context;
    this.group = group;

    FormLayout layout = new FormLayout();

    TextField nameField = new TextField("Group Name", StringUtils.trimToEmpty(group.getName()));
    nameField.addValueChangeListener(new NameChangeListener());
    layout.addComponent(nameField);//ww w  .  j a va  2  s  .c o  m
    nameField.focus();

    CheckBox readOnly = new CheckBox("Read Only");
    readOnly.setImmediate(true);
    readOnly.setValue(group.isReadOnly());
    readOnly.addValueChangeListener(new ReadOnlyChangeListener());
    layout.addComponent(readOnly);

    TwinColSelect privSelect = new TwinColSelect();
    for (Privilege priv : Privilege.values()) {
        privSelect.addItem(priv.name());
    }
    lastPrivs = new HashSet<String>();
    for (GroupPrivilege groupPriv : group.getGroupPrivileges()) {
        lastPrivs.add(groupPriv.getName());
    }
    privSelect.setValue(lastPrivs);
    privSelect.setRows(20);
    privSelect.setNullSelectionAllowed(true);
    privSelect.setMultiSelect(true);
    privSelect.setImmediate(true);
    privSelect.setLeftColumnCaption("Available privileges");
    privSelect.setRightColumnCaption("Selected privileges");
    privSelect.addValueChangeListener(new PrivilegeChangeListener());
    layout.addComponent(privSelect);

    addComponent(layout);
    setMargin(true);
}

From source file:org.jumpmind.metl.ui.views.admin.LoggingPanel.java

License:Open Source License

public LoggingPanel(ApplicationContext context, TabbedPanel tabbedPanel) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;
    this.backgroundRefresherService = context.getBackgroundRefresherService();
    if (LogUtils.isFileEnabled()) {
        logFile = new File(LogUtils.getLogFilePath());
    }/* w w w. j a  va2  s  . c o m*/
    setSizeFull();
    setSpacing(true);
    setMargin(true);

    HorizontalLayout topPanelLayout = new HorizontalLayout();
    topPanelLayout.setWidth(100, Unit.PERCENTAGE);
    topPanelLayout.setSpacing(true);

    Button refreshButton = new Button("Refresh");
    refreshButton.addClickListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            refresh();
        }
    });
    topPanelLayout.addComponent(refreshButton);
    topPanelLayout.setComponentAlignment(refreshButton, Alignment.BOTTOM_LEFT);

    bufferSize = new TextField();
    bufferSize.setImmediate(true);
    bufferSize.setWidth(5, Unit.EM);
    bufferSize.setValue("1000");
    bufferSize.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            refresh();
        }
    });
    topPanelLayout.addComponent(bufferSize);

    filter = new TextField();
    filter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    filter.setInputPrompt("Filter");
    filter.setIcon(FontAwesome.SEARCH);
    filter.setNullRepresentation("");
    filter.setImmediate(true);
    filter.setTextChangeEventMode(TextChangeEventMode.LAZY);
    filter.setTextChangeTimeout(200);
    filter.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            refresh();
        }
    });
    topPanelLayout.addComponent(filter);
    topPanelLayout.setComponentAlignment(filter, Alignment.BOTTOM_LEFT);

    autoRefreshOn = new CheckBox("Auto Refresh");
    autoRefreshOn.setValue(true);
    autoRefreshOn.setImmediate(true);
    topPanelLayout.addComponent(autoRefreshOn);
    topPanelLayout.setComponentAlignment(autoRefreshOn, Alignment.BOTTOM_LEFT);

    Label spacer = new Label();
    topPanelLayout.addComponent(spacer);
    topPanelLayout.setExpandRatio(spacer, 1);

    if (logFile != null && logFile.exists()) {
        Button downloadButton = new Button("Download log file");
        downloadButton.addStyleName(ValoTheme.BUTTON_LINK);
        downloadButton.addStyleName(ValoTheme.BUTTON_SMALL);

        FileDownloader fileDownloader = new FileDownloader(getLogFileResource());
        fileDownloader.extend(downloadButton);
        topPanelLayout.addComponent(downloadButton);
        topPanelLayout.setComponentAlignment(downloadButton, Alignment.BOTTOM_RIGHT);
    }

    addComponent(topPanelLayout);

    logPanel = new Panel("Log Output");
    logPanel.setSizeFull();
    logView = new Label("", ContentMode.HTML);
    logView.setSizeUndefined();
    logPanel.setContent(logView);
    addComponent(logPanel);
    setExpandRatio(logPanel, 1);
    refresh();
    backgroundRefresherService.register(this);
}

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.ja v  a 2  s . c  o  m
                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 addComponentShared(FormLayout formLayout, final Component component) {

    final CheckBox checkBox = new CheckBox("Shared");
    checkBox.setImmediate(true);//from   w ww . j a va 2s. c o  m

    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 addSettingField(final XMLSetting definition, final AbstractObjectWithSettings obj,
        FormLayout formLayout) {/*from  w w  w .ja  v a 2s. c  o m*/
    boolean required = definition.isRequired();
    if (definition.isVisible()) {
        Component component = null;
        if (obj instanceof Component) {
            component = (Component) obj;
        }
        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.metl.ui.views.manage.ExecutionRunPanel.java

License:Open Source License

public ExecutionRunPanel(String executionId, ApplicationContext context, TabbedPanel parentTabSheet,
        IFlowRunnable flowRunnable) {/*w  w  w  .ja v  a 2  s. c o  m*/
    this.executionService = context.getExecutionService();
    this.executionId = executionId;
    this.context = context;
    this.parentTabSheet = parentTabSheet;
    this.flowRunnable = flowRunnable;

    Execution execution = executionService.findExecution(executionId);
    this.flow = context.getConfigurationService().findFlow(execution.getFlowId());

    HorizontalLayout topBar = new HorizontalLayout();
    topBar.setMargin(new MarginInfo(true, true, false, true));
    topBar.setWidth(100, Unit.PERCENTAGE);

    HorizontalLayout left = new HorizontalLayout();
    topBar.addComponent(left);

    HorizontalLayout right = new HorizontalLayout();
    right.setSpacing(true);
    topBar.addComponent(right);
    topBar.setComponentAlignment(right, Alignment.MIDDLE_RIGHT);

    Label limitLabel = new Label("Max Log Messages To Show :");
    right.addComponent(limitLabel);
    right.setComponentAlignment(limitLabel, Alignment.MIDDLE_RIGHT);
    limitField = new ImmediateUpdateTextField(null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void save(String text) {
            Setting setting = context.getUser().findSetting(UserSetting.SETTING_MAX_LOG_MESSAGE_TO_SHOW);
            setting.setValue(Integer.toString(getMaxToShow(text)));
            context.getConfigurationService().save(setting);
        }
    };
    limitField.setWidth("5em");
    limitField.setValue(context.getUser().get(UserSetting.SETTING_MAX_LOG_MESSAGE_TO_SHOW, "1000"));
    right.addComponent(limitField);
    right.setComponentAlignment(limitField, Alignment.MIDDLE_RIGHT);

    showDiagramCheckbox = new CheckBox("Show Diagram");
    showDiagramCheckbox.addValueChangeListener((event) -> {
        if (showDiagramCheckbox.getValue()) {
            showDiagram();
        } else {
            showDetails();
        }
    });
    right.addComponent(showDiagramCheckbox);
    right.setComponentAlignment(showDiagramCheckbox, Alignment.MIDDLE_RIGHT);

    addComponent(topBar);

    ButtonBar buttonBar = new ButtonBar();

    rerunButton = buttonBar.addButton("Rerun", Icons.RUN, event -> rerun());
    rerunButton.setVisible(false);
    removeButton = buttonBar.addButton("Remove", Icons.DELETE, event -> remove());
    removeButton.setVisible(false);
    cancelButton = buttonBar.addButton("Cancel", Icons.CANCEL, event -> cancel());

    addComponent(buttonBar);

    HorizontalLayout header1 = new HorizontalLayout();
    header1.addComponent(new Label("<b>Flow:</b>", ContentMode.HTML));
    header1.addComponent(flowLabel);
    header1.addComponent(new Label("<b>Start:</b>", ContentMode.HTML));
    header1.addComponent(startLabel);
    header1.setSpacing(true);
    header1.setMargin(new MarginInfo(false, true, false, true));
    header1.setWidth("100%");
    addComponent(header1);

    HorizontalLayout header2 = new HorizontalLayout();
    header2.addComponent(new Label("<b>Status:</b>", ContentMode.HTML));
    header2.addComponent(statusLabel);
    header2.addComponent(new Label("<b>End:</b>", ContentMode.HTML));
    header2.addComponent(endLabel);
    header2.setSpacing(true);
    header2.setMargin(new MarginInfo(false, true, true, true));
    header2.setWidth("100%");
    addComponent(header2);

    stepContainer.setBeanIdProperty("id");

    diagramLayout = new VerticalLayout();
    diagramLayout.setWidth(10000, Unit.PIXELS);
    diagramLayout.setHeight(10000, Unit.PIXELS);

    flowPanel = new Panel();
    flowPanel.setSizeFull();
    flowPanel.addStyleName(ValoTheme.PANEL_WELL);

    flowPanel.setContent(diagramLayout);

    stepTable.setContainerDataSource(stepContainer);
    stepTable.setSelectable(true);
    stepTable.setMultiSelect(true);
    stepTable.setImmediate(true);
    stepTable.setSizeFull();
    stepTable.setVisibleColumns(
            new Object[] { "componentName", "threadNumber", "status", "payloadReceived", "messagesReceived",
                    "messagesProduced", "payloadProduced", "startTime", "endTime", "handleDurationString" });
    stepTable.setColumnHeaders(new String[] { "Component Name", "Thread", "Status", "Payload Recvd",
            "Msgs Recvd", "Msgs Sent", "Payload Sent", "Start", "End", "Run Duration" });
    stepTable.setColumnWidth("status", 100);
    stepTable.setColumnWidth("messagesReceived", 100);
    stepTable.setColumnWidth("messagesProduced", 100);
    stepTable.setColumnWidth("payloadReceived", 100);
    stepTable.setColumnWidth("payloadProduced", 100);
    stepTable.setColumnWidth("threadNumber", 100);
    stepTable.setColumnWidth("startTime", 170);
    stepTable.setColumnWidth("endTime", 170);
    stepTable.setColumnExpandRatio("handleDurationString", 1);
    stepTable.addValueChangeListener(event -> {
        @SuppressWarnings("unchecked")
        Set<String> executionStepIds = (Set<String>) event.getProperty().getValue();
        logContainer.removeAllItems();
        List<ExecutionStepLog> logs = executionService.findExecutionStepLogs(executionStepIds, getMaxToShow());
        logContainer.addAll(logs);
    });

    stepTable.addValueChangeListener(event -> {
        @SuppressWarnings("unchecked")
        Set<String> executionStepIds = (Set<String>) event.getProperty().getValue();
        logContainer.removeAllItems();
        List<ExecutionStepLog> logs = executionService.findExecutionStepLogs(executionStepIds, getMaxToShow());
        logContainer.addAll(logs);
    });

    logTable = new Grid();
    logTable.addColumn("level", String.class).setHeaderCaption("Level").setWidth(110).setMaximumWidth(200);
    logTable.addColumn("createTime", Date.class).setHeaderCaption("Time").setWidth(120).setMaximumWidth(200)
            .setRenderer(new DateRenderer(UiConstants.TIME_FORMAT));
    logTable.addColumn("logText", String.class).setHeaderCaption("Message").setExpandRatio(1);
    logTable.setContainerDataSource(logContainer);
    logTable.setSizeFull();
    logTable.addItemClickListener(event -> logTableCellClicked(logTable, event));
    logTable.addSortListener(event -> {
        lastSortOrder = event.getSortOrder();
    });

    HeaderRow filteringHeader = logTable.appendHeaderRow();
    HeaderCell logTextFilterCell = filteringHeader.getCell("logText");
    TextField filterField = new TextField();
    filterField.setInputPrompt("Filter");
    filterField.addStyleName(ValoTheme.TEXTFIELD_TINY);
    filterField.setWidth("100%");

    // Update filter When the filter input is changed
    filterField.addTextChangeListener(change -> {
        // Can't modify filters so need to replace
        logContainer.removeContainerFilters("logText");

        // (Re)create the filter if necessary
        if (!change.getText().isEmpty())
            logContainer.addContainerFilter(new SimpleStringFilter("logText", change.getText(), true, false));
    });
    logTextFilterCell.setComponent(filterField);

    HeaderCell levelFilterCell = filteringHeader.getCell("level");
    ComboBox levelFilter = new ComboBox();
    levelFilter.setWidth(8, Unit.EM);
    levelFilter.setNullSelectionAllowed(true);
    LogLevel[] levels = LogLevel.values();
    for (LogLevel logLevel : levels) {
        levelFilter.addItem(logLevel.name());
    }
    levelFilter.addValueChangeListener(change -> {
        logContainer.removeContainerFilters("level");
        String text = (String) levelFilter.getValue();
        if (isNotBlank(text)) {
            logContainer.addContainerFilter(new SimpleStringFilter("level", text, true, false));
        }
    });
    levelFilterCell.setComponent(levelFilter);

    levelFilter.addStyleName(ValoTheme.COMBOBOX_TINY);

    splitPanel = new VerticalSplitPanel();
    splitPanel.setFirstComponent(flowPanel);
    splitPanel.setSecondComponent(logTable);
    splitPanel.setSplitPosition(50f);
    splitPanel.setSizeFull();
    addComponent(splitPanel);
    setExpandRatio(splitPanel, 1.0f);

    showDiagramCheckbox.setValue(context.getUser().getBoolean(UserSetting.SETTING_SHOW_RUN_DIAGRAM, true));
    if (!showDiagramCheckbox.getValue()) {
        showDetails();
    }

    context.getBackgroundRefresherService().register(this);
}

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 w  w  . ja  v a2s. c o m*/
    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);

}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.DbFillDialog.java

License:Open Source License

protected void createOptionLayout() {
    optionLayout = new VerticalLayout();
    optionLayout.addStyleName("v-scrollable");
    optionLayout.setMargin(true);//from   ww  w. jav a2s.c o m
    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);

    countField = new TextField("Count (# of rows to fill)");
    countField.setValue("1");
    countField.setTextChangeEventMode(TextChangeEventMode.EAGER);
    countField.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(TextChangeEvent event) {
            countField.setValue(event.getText());
            fillButton.setEnabled(enableFillButton());
        }
    });
    formLayout.addComponent(countField);

    intervalField = new TextField("Interval (ms)");
    intervalField.setValue("0");
    intervalField.setTextChangeEventMode(TextChangeEventMode.EAGER);
    intervalField.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(TextChangeEvent event) {
            intervalField.setValue(event.getText());
            fillButton.setEnabled(enableFillButton());
        }
    });
    formLayout.addComponent(intervalField);

    insertWeightField = new TextField("Insert Weight");
    insertWeightField.setValue("1");
    insertWeightField.setTextChangeEventMode(TextChangeEventMode.EAGER);
    insertWeightField.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(TextChangeEvent event) {
            insertWeightField.setValue(event.getText());
            fillButton.setEnabled(enableFillButton());
        }
    });
    formLayout.addComponent(insertWeightField);

    updateWeightField = new TextField("Update Weight");
    updateWeightField.setValue("0");
    updateWeightField.setTextChangeEventMode(TextChangeEventMode.EAGER);
    updateWeightField.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(TextChangeEvent event) {
            updateWeightField.setValue(event.getText());
            fillButton.setEnabled(enableFillButton());
        }
    });
    formLayout.addComponent(updateWeightField);

    deleteWeightField = new TextField("Delete Weight");
    deleteWeightField.setValue("0");
    deleteWeightField.setTextChangeEventMode(TextChangeEventMode.EAGER);
    deleteWeightField.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(TextChangeEvent event) {
            deleteWeightField.setValue(event.getText());
            fillButton.setEnabled(enableFillButton());
        }
    });
    formLayout.addComponent(deleteWeightField);

    continueBox = new CheckBox("Continue (ignore ANY errors and continue to modify)");
    continueBox.setValue(true);
    formLayout.addComponent(continueBox);

    cascadeBox = new CheckBox("Fill dependent tables also.");
    cascadeBox.setValue(false);
    formLayout.addComponent(cascadeBox);

    cascadeSelectBox = new CheckBox("Fill dependent tables by selecting existing data.");
    cascadeSelectBox.setValue(false);
    formLayout.addComponent(cascadeSelectBox);

    verboseBox = new CheckBox("Turn on verbose logging during fill.");
    verboseBox.setValue(false);
    formLayout.addComponent(verboseBox);

    truncateBox = new CheckBox("Truncate table(s) before filling.");
    truncateBox.setValue(false);
    formLayout.addComponent(truncateBox);

    oGroup = new OptionGroup();
    oGroup.addItem("Fill Table(s)");
    oGroup.addItem("Send to Sql Editor");
    oGroup.select("Fill Table(s)");
    oGroup.setNullSelectionAllowed(false);
    formLayout.addComponent(oGroup);

}