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, boolean initialState) 

Source Link

Document

Creates a new checkbox with a caption and a set initial state.

Usage

From source file:org.eclipse.skalli.view.component.PhaseSelect.java

License:Open Source License

private Layout createLayout(boolean showDeletedCheckbox) {
    final FloatLayout layout = new FloatLayout();
    cb = new ComboBox(null, phases);
    cb.setImmediate(true);/*from  w  ww.j  av a2 s  .  co  m*/
    layout.addComponent(cb);
    if (showDeletedCheckbox) {
        deleted = new CheckBox("Deleted", project.isDeleted());
        deleted.setImmediate(true);
        layout.addComponent(deleted, "margin-left:20px;margin-top:3px");
    }
    return layout;
}

From source file:org.eclipse.skalli.view.ext.impl.internal.infobox.FeedInfoBox.java

License:Open Source License

private void addSourceFilter(final Layout parentLayout, FloatLayout layout, final String source,
        final HashMap<String, SourceDetails> sourceFilter, final Project project, final String userId) {
    final SourceDetails value = sourceFilter.get(source);
    CheckBox cb = new CheckBox(value.caption, value.selected);
    cb.setImmediate(true);/*from   ww  w.  ja v  a  2  s  . c o  m*/
    cb.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = 7364120771141334914L;

        @Override
        public void buttonClick(ClickEvent event) {
            boolean checked = event.getButton().booleanValue();
            value.selected = checked;
            renderContentPanel(parentLayout, project, userId, sourceFilter);
        }
    });
    layout.addComponent(cb, "margin-right:10px;"); //$NON-NLS-1$
}

From source file:org.escidoc.browser.elabsmodul.views.helpers.LabsLayoutHelper.java

License:Open Source License

public static HorizontalLayout createHorizontalLayoutWithELabsLabelAndCheckBoxData(final String labelTxt,
        final String checkBoxDescription, Property dataProperty, boolean required) {
    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeUndefined();
    horizontalLayout.setDescription(USER_DESCR_ON_HOR_LAYOUT_TO_EDIT);
    horizontalLayout.setEnabled(true);/*  www  .j  a  va  2s  .  c om*/
    horizontalLayout.setSpacing(true);
    horizontalLayout.setHeight(HOR_PANEL_HEIGHT);
    horizontalLayout.setStyleName(STYLE_ELABS_HOR_PANEL);
    Label label = new Label();
    label.setWidth(LABEL_WIDTH);
    label.setValue(DIV_ALIGN_RIGHT + (required ? ELabsViewContants.REQUIRED_SIGN : "") + labelTxt + DIV_END);
    label.setContentMode(Label.CONTENT_XHTML);
    label.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    final CheckBox checkBox = new CheckBox(checkBoxDescription, dataProperty);
    checkBox.setEnabled(true);
    checkBox.setVisible(true);
    checkBox.setWidth(TEXT_WIDTH);
    checkBox.setStyleName(STYLE_ELABS_TEXT_AS_LABEL);
    checkBox.setDescription(USER_DESCR_ON_LABEL_TO_EDIT);
    horizontalLayout.addComponent(label, 0);
    horizontalLayout.addComponent(checkBox, 1);
    horizontalLayout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    horizontalLayout.setComponentAlignment(checkBox, Alignment.MIDDLE_RIGHT);
    return horizontalLayout;
}

From source file:org.escidoc.browser.ui.tools.CreateResourcesView.java

License:Open Source License

private Form buildCreateOrgUnitForm() {
    final Form form = new Form();
    form.setImmediate(true);// w w  w  .j av a 2 s . c o m

    // Name
    final TextField txtNameContext = new TextField();
    txtNameContext.setCaption("Name");
    txtNameContext.setImmediate(false);
    txtNameContext.setWidth("-1px");
    txtNameContext.setHeight("-1px");
    txtNameContext.setInvalidAllowed(false);
    txtNameContext.setRequired(true);
    form.addField("txtNameContext", txtNameContext);

    // Description
    final TextField txtDescContext = new TextField("Description");
    txtDescContext.setImmediate(false);
    txtDescContext.setWidth("-1px");
    txtDescContext.setHeight("-1px");
    form.addField("txtDescContext", txtDescContext);

    final CheckBox checkStatusOpened = new CheckBox("Create OrgUnit in Status opened?", true);
    checkStatusOpened.setImmediate(true);
    form.addField("checkStatusOpened", checkStatusOpened);

    // btnAddContext
    final Button btnAddContext = new Button("Submit", new Button.ClickListener() {
        private static final long serialVersionUID = -1373866726572059290L;

        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                form.commit();
                controller.createResourceAddOrgUnit(txtNameContext.getValue().toString(),
                        txtDescContext.getValue().toString(), (Boolean) checkStatusOpened.getValue(), router,
                        router.getServiceLocation());
                router.getMainWindow().showNotification("Organizational Unit "
                        + txtNameContext.getValue().toString() + " created successfully ",
                        Window.Notification.TYPE_TRAY_NOTIFICATION);
                form.getField("txtNameContext").setValue("");
                form.getField("txtDescContext").setValue("");
            } catch (final EmptyValueException e) {
                router.getMainWindow().showNotification("Please fill in all the required elements in the form",
                        Window.Notification.TYPE_TRAY_NOTIFICATION);
            } catch (final Exception e) {
                router.getMainWindow().showNotification(
                        ViewConstants.ERROR_CREATING_RESOURCE + e.getLocalizedMessage(),
                        Window.Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });

    btnAddContext.setWidth("-1px");
    btnAddContext.setHeight("-1px");
    form.getLayout().addComponent(btnAddContext);

    form.getField("txtNameContext").setRequired(true);
    form.getField("txtNameContext").setRequiredError("Name is missing");

    form.getField("txtDescContext").setRequired(true);
    form.getField("txtDescContext").setRequiredError("Description is missing");
    return form;
}

From source file:org.escidoc.browser.ui.tools.CreateResourcesView.java

License:Open Source License

private void formAddContext(final VerticalLayout vlAccCreateContext) throws EscidocClientException {
    final Form frm = new Form();
    frm.setImmediate(true);//  ww w  . j a  v  a  2  s  .c om
    // Name
    final TextField txtNameContext = new TextField();
    txtNameContext.setCaption("Name");
    txtNameContext.setImmediate(false);
    txtNameContext.setWidth("-1px");
    txtNameContext.setHeight("-1px");
    txtNameContext.setInvalidAllowed(false);
    txtNameContext.setRequired(true);
    frm.addField("txtNameContext", txtNameContext);

    // Description
    final TextField txtDescContext = new TextField("Description");
    txtDescContext.setImmediate(false);
    txtDescContext.setWidth("-1px");
    txtDescContext.setHeight("-1px");
    frm.addField("txtDescContext", txtDescContext);

    // Description
    final TextField txtType = new TextField("Type");
    txtType.setImmediate(false);
    txtType.setWidth("-1px");
    txtType.setHeight("-1px");
    frm.addField("txtType", txtType);

    // OrgUnit
    final NativeSelect slOrgUnit = new NativeSelect("Organizational Unit");
    slOrgUnit.setImmediate(true);
    slOrgUnit.setWidth("-1px");
    slOrgUnit.setHeight("-1px");
    slOrgUnit.setRequired(true);
    slOrgUnit.setNullSelectionAllowed(false);
    frm.addField("slOrgUnit", slOrgUnit);

    final OrgUnitService orgUnitService = new OrgUnitService(router.getServiceLocation().getEscidocUri(),
            router.getApp().getCurrentUser().getToken());
    final Collection<OrganizationalUnit> orgUnits = orgUnitService.findAll();
    for (final OrganizationalUnit organizationalUnit : orgUnits) {
        slOrgUnit.addItem(organizationalUnit.getObjid());
        slOrgUnit.setItemCaption(organizationalUnit.getObjid(), organizationalUnit.getXLinkTitle());
    }

    frm.getLayout().addComponent(slOrgUnit);
    final CheckBox checkStatusOpened = new CheckBox("Create Context in Status opened?", true);
    checkStatusOpened.setImmediate(true);
    frm.addField("checkStatusOpened", checkStatusOpened);

    // btnAddContext
    final Button btnAddContext = new Button("Submit", new Button.ClickListener() {
        private static final long serialVersionUID = -4696167135894721166L;

        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                frm.commit();
                controller.createResourceAddContext(txtNameContext.getValue().toString(),
                        txtDescContext.getValue().toString(), txtType.getValue().toString(),
                        slOrgUnit.getValue().toString(), (Boolean) checkStatusOpened.getValue(), repositories,
                        router.getServiceLocation());
                router.getMainWindow().showNotification(
                        "Context " + txtNameContext.getValue().toString() + " created successfully ",
                        Window.Notification.TYPE_TRAY_NOTIFICATION);
                frm.getField("txtNameContext").setValue("");
                frm.getField("txtDescContext").setValue("");
                frm.getField("txtType").setValue("");
                frm.getField("slOrgUnit").setValue(null);
                // Ideally here should be a sync method to sync the tree

            } catch (final EmptyValueException e) {
                router.getMainWindow().showNotification("Please fill in all the required elements in the form",
                        Window.Notification.TYPE_TRAY_NOTIFICATION);
            } catch (final EscidocClientException e) {
                router.getMainWindow().showNotification(
                        ViewConstants.ERROR_CREATING_RESOURCE + e.getLocalizedMessage(),
                        Window.Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });

    btnAddContext.setWidth("-1px");
    btnAddContext.setHeight("-1px");
    frm.getLayout().addComponent(btnAddContext);

    frm.getField("txtNameContext").setRequired(true);
    frm.getField("txtNameContext").setRequiredError("Name is missing");

    frm.getField("txtDescContext").setRequired(true);
    frm.getField("txtDescContext").setRequiredError("Description is missing");

    frm.getField("txtType").setRequired(true);
    frm.getField("txtType").setRequiredError("Context Type is missing");
    //
    frm.getField("slOrgUnit").setRequired(true);
    frm.getField("slOrgUnit").setRequiredError("Organizazional Unit is required");

    vlAccCreateContext.addComponent(frm);
}

From source file:org.esn.esobase.view.tab.DirectTableEditTab.java

public DirectTableEditTab(DBService service_, SearchService searchService_) {
    this.service = service_;
    this.searchService = searchService_;
    this.setSizeFull();
    this.setMargin(false);
    linkedItemClickListener = new LinkedItemClickListener();
    searchTabs = new TabSheet();
    searchTabs.setSizeFull();/*from  w ww. j  a  v  a 2 s  .  c o m*/
    searchTabs.setHeight(250f, Unit.PIXELS);
    VerticalLayout searchInCatalogsLayout = new VerticalLayout();
    searchInCatalogsLayout.setSizeFull();
    searchInCatalogsLayout.setMargin(false);
    HorizontalLayout hl = new HorizontalLayout();
    hl.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT);
    searchField = new TextField();
    searchField.setWidth(500, Unit.PIXELS);
    searchField
            .addShortcutListener(new ShortcutListener("Search shortcut", ShortcutAction.KeyCode.ENTER, null) {
                @Override
                public void handleAction(Object sender, Object target) {
                    search();
                }
            });
    hl.addComponent(searchField);
    searchButton = new Button("?");
    searchButton.setIcon(FontAwesome.SEARCH);
    searchButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            search();

        }
    });
    hl.addComponent(searchButton);
    hl.addComponent(new Label(""));

    tableNamesList.add("GSpreadSheetsNpcName");
    tableNamesList.add("GSpreadSheetsNpcPhrase");
    tableNamesList.add("GSpreadSheetsPlayerPhrase");
    tableNamesList.add("GSpreadSheetsAbilityDescription");
    tableNamesList.add("GSpreadSheetsAchievement");
    tableNamesList.add("GSpreadSheetsAchievementDescription");
    tableNamesList.add("GSpreadSheetsActivator");
    tableNamesList.add("GSpreadSheetsCollectible");
    tableNamesList.add("GSpreadSheetsCollectibleDescription");
    tableNamesList.add("GSpreadSheetsItemDescription");
    tableNamesList.add("GSpreadSheetsItemName");
    tableNamesList.add("GSpreadSheetsJournalEntry");
    tableNamesList.add("GSpreadSheetsLoadscreen");
    tableNamesList.add("GSpreadSheetsLocationName");
    tableNamesList.add("GSpreadSheetsNote");
    tableNamesList.add("GSpreadSheetsQuestDescription");
    tableNamesList.add("GSpreadSheetsQuestDirection");
    tableNamesList.add("GSpreadSheetsQuestName");
    tableNamesList.add("GSpreadSheetsQuestStartTip");
    tableNamesList.add("GSpreadSheetsQuestEndTip");
    tableNames = new ComboBoxMultiselect(null);
    tableNames.setSelectAllButtonCaption(" ?");
    tableNames.setShowSelectAllButton(new ComboBoxMultiselect.ShowButton() {
        @Override
        public boolean isShow(String filter, int page) {
            return true;
        }
    });
    tableNames.setClearButtonCaption("? ");
    tableNames.setPageLength(0);
    tableNames.addItems(tableNamesList);
    tableNames.selectAll();
    tableNames.setItemCaption("GSpreadSheetsAbilityDescription", "?? ???");
    tableNames.setItemCaption("GSpreadSheetsAchievement", "??");
    tableNames.setItemCaption("GSpreadSheetsAchievementDescription", "?? ?");
    tableNames.setItemCaption("GSpreadSheetsActivator", "?");
    tableNames.setItemCaption("GSpreadSheetsCollectible", " ");
    tableNames.setItemCaption("GSpreadSheetsCollectibleDescription",
            "??  ");
    tableNames.setItemCaption("GSpreadSheetsItemDescription", "?? ");
    tableNames.setItemCaption("GSpreadSheetsItemName", "?? ");
    tableNames.setItemCaption("GSpreadSheetsJournalEntry", "? ");
    tableNames.setItemCaption("GSpreadSheetsLoadscreen", " ?");
    tableNames.setItemCaption("GSpreadSheetsLocationName", "");
    tableNames.setItemCaption("GSpreadSheetsNote", "?");
    tableNames.setItemCaption("GSpreadSheetsNpcName", "NPC");
    tableNames.setItemCaption("GSpreadSheetsNpcPhrase", " NPC");
    tableNames.setItemCaption("GSpreadSheetsPlayerPhrase", " ");
    tableNames.setItemCaption("GSpreadSheetsQuestDescription", "?? ?");
    tableNames.setItemCaption("GSpreadSheetsQuestDirection", " ?");
    tableNames.setItemCaption("GSpreadSheetsQuestEndTip", " ");
    tableNames.setItemCaption("GSpreadSheetsQuestName", "?? ?");
    tableNames.setItemCaption("GSpreadSheetsQuestStartTip", "? ");
    hl.addComponent(tableNames);
    regularExpression = new CheckBox("regexp", false);
    hl.addComponent(regularExpression);
    withTranslatedNeighbours = new CheckBox(
            "? ?  ???", false);
    hl.addComponent(withTranslatedNeighbours);
    neighboursCount = new Slider(null, 1, 200);
    neighboursCount.setValue(20d);
    hl.addComponent(neighboursCount);
    searchInCatalogsLayout.addComponent(hl);
    translatedTextSpecification = new TranslatedTextSpecification();
    resultTable = new Table(" ?");
    resultTable.addStyleName(ValoTheme.TABLE_SMALL);
    resultTable.addStyleName(ValoTheme.TABLE_COMPACT);
    resultTable.setSizeFull();
    resultTable.setPageLength(0);
    hc.addContainerProperty("textEn", String.class, null);
    hc.addContainerProperty("textRu", String.class, null);
    hc.addContainerProperty("catalogType", String.class, null);
    hc.addContainerProperty("translator", String.class, null);
    hc.addContainerProperty("weight", Integer.class, null);
    resultTable.setContainerDataSource(hc);
    resultTable.setVisibleColumns(new Object[] { "textEn", "textRu", "catalogType", "translator" });
    resultTable.setColumnHeaders(
            new String[] { "?", "?? ?", "", "" });
    resultTable.addItemClickListener(new SearchTableRowClickListener());

    searchInCatalogsLayout.addComponent(resultTable);
    searchInCatalogsLayout.setExpandRatio(resultTable, 5f);

    searchTabs.addTab(searchInCatalogsLayout, "?");
    VerticalLayout translationsLayout = new VerticalLayout();
    translationsLayout.setMargin(false);
    translationsLayout.setSpacing(false);
    translationsLayout.setSizeFull();
    HorizontalLayout traslationsFilterslayout = new HorizontalLayout();
    statusFilter = new ComboBox("?", Arrays.asList(TRANSLATE_STATUS.values()));
    statusFilter.setNullSelectionAllowed(false);
    statusFilter.setValue(TRANSLATE_STATUS.NEW);
    traslationsFilterslayout.addComponent(statusFilter);
    translatorBox = new ComboBox("");
    translatorBox.setPageLength(15);
    sysAccountContainer = service.loadBeanItems(sysAccountContainer);
    translatorBox.setContainerDataSource(sysAccountContainer);
    translatorBox.setFilteringMode(FilteringMode.CONTAINS);
    traslationsFilterslayout.addComponent(translatorBox);
    translateTypeBox = new ComboBox("");
    translateTypeBox.setNullSelectionAllowed(true);
    translateTypeBox.setPageLength(15);
    translateTypeBox.addItem("spreadSheetsActivator");
    translateTypeBox.setItemCaption("spreadSheetsActivator", "?");
    translateTypeBox.addItem("spreadSheetsAchievement");
    translateTypeBox.setItemCaption("spreadSheetsAchievement", "??");
    translateTypeBox.addItem("spreadSheetsAchievementDescription");
    translateTypeBox.setItemCaption("spreadSheetsAchievementDescription",
            "?? ?");
    translateTypeBox.addItem("spreadSheetsNote");
    translateTypeBox.setItemCaption("spreadSheetsNote", "?");
    translateTypeBox.addItem("spreadSheetsItemDescription");
    translateTypeBox.setItemCaption("spreadSheetsItemDescription", "?? ");
    translateTypeBox.addItem("spreadSheetsItemName");
    translateTypeBox.setItemCaption("spreadSheetsItemName", "?? ");
    translateTypeBox.addItem("spreadSheetsJournalEntry");
    translateTypeBox.setItemCaption("spreadSheetsJournalEntry", "?  ");
    translateTypeBox.addItem("spreadSheetsLocationName");
    translateTypeBox.setItemCaption("spreadSheetsLocationName", "?? ");
    translateTypeBox.addItem("spreadSheetsNpcName");
    translateTypeBox.setItemCaption("spreadSheetsNpcName", " NPC");
    translateTypeBox.addItem("spreadSheetsNpcPhrase");
    translateTypeBox.setItemCaption("spreadSheetsNpcPhrase", " NPC");
    translateTypeBox.addItem("spreadSheetsPlayerPhrase");
    translateTypeBox.setItemCaption("spreadSheetsPlayerPhrase", " ");
    translateTypeBox.addItem("spreadSheetsQuestDescription");
    translateTypeBox.setItemCaption("spreadSheetsQuestDescription", "?? ?");
    translateTypeBox.addItem("spreadSheetsQuestDirection");
    translateTypeBox.setItemCaption("spreadSheetsQuestDirection", " ?");
    translateTypeBox.addItem("spreadSheetsQuestName");
    translateTypeBox.setItemCaption("spreadSheetsQuestName", "?? ?");
    translateTypeBox.addItem("spreadSheetsQuestStartTip");
    translateTypeBox.setItemCaption("spreadSheetsQuestStartTip", "? ");
    translateTypeBox.addItem("spreadSheetsQuestEndTip");
    translateTypeBox.setItemCaption("spreadSheetsQuestEndTip", " ");
    translateTypeBox.addItem("sheetsCollectible");
    translateTypeBox.setItemCaption("sheetsCollectible",
            "??  ");
    translateTypeBox.addItem("sheetsCollectibleDescription");
    translateTypeBox.setItemCaption("sheetsCollectibleDescription",
            "??  ");
    translateTypeBox.addItem("sheetsLoadscreen");
    translateTypeBox.setItemCaption("sheetsLoadscreen", " ?");
    translateTypeBox.setFilteringMode(FilteringMode.CONTAINS);
    traslationsFilterslayout.addComponent(translateTypeBox);
    filterTranslationButton = new Button("?");
    filterTranslationButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            filterTranslations();
        }
    });
    traslationsFilterslayout.addComponent(filterTranslationButton);
    traslationsFilterslayout.setComponentAlignment(filterTranslationButton, Alignment.BOTTOM_LEFT);
    translationsLayout.addComponent(traslationsFilterslayout);
    newTranslationsTable = new MGrid();
    newTranslationsTable.setSizeFull();
    newTranslationsContainer = new GeneratedPropertyListContainer<>(TranslatedText.class);
    newTranslationsTable.setContainerDataSource(newTranslationsContainer);
    filterTranslations();
    newTranslationsContainer.sort(new Object[] { "id" }, new boolean[] { true });
    newTranslationsTable.setContainerDataSource(newTranslationsContainer);
    newTranslationsTable.setColumns("author", "createTime", "text");
    newTranslationsTable.getColumn("author").setHeaderCaption("?").setMaximumWidth(200);
    newTranslationsTable.getColumn("createTime").setHeaderCaption("").setWidth(140);
    newTranslationsTable.getColumn("text").setHeaderCaption("").setMaximumWidth(800)
            .setMinimumWidth(600);
    newTranslationsTable.addItemClickListener(new TranslationsTableRowClickListener());
    translationsLayout.addComponent(newTranslationsTable);
    translationsLayout.setExpandRatio(newTranslationsTable, 5f);
    searchTabs.addTab(translationsLayout, "");
    this.addComponent(searchTabs);
    filterLayout = new HorizontalLayout();
    Label itemTypeLabel = new Label("");
    itemType = new ComboBox();
    itemType.addItems(service.getTypes());
    itemType.setNullSelectionAllowed(true);
    itemType.setFilteringMode(FilteringMode.CONTAINS);
    filterLayout.addComponent(itemTypeLabel);
    filterLayout.addComponent(itemType);
    Label itemSubTypeLabel = new Label("");
    itemSubType = new ComboBox();
    itemSubType.addItems(service.getSubTypes());
    itemSubType.setNullSelectionAllowed(true);
    itemSubType.setFilteringMode(FilteringMode.CONTAINS);
    filterLayout.addComponent(itemSubTypeLabel);
    filterLayout.addComponent(itemSubType);
    notTranslated = new CheckBox("? ");
    notTranslated.setValue(Boolean.FALSE);
    filterLayout.addComponent(notTranslated);
    filterLayout.setComponentAlignment(notTranslated, Alignment.MIDDLE_LEFT);
    this.addComponent(filterLayout);
    tableTabs = new TabSheet();
    tableTabs.setSizeFull();
    gSpreadSheetsNpcNameContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsNpcName.class);
    npcNameTable = new GspreadSheetTable(gSpreadSheetsNpcNameContainer, PAGESIZE,
            service.getgSpreadSheetsNpcNameRepository(), specification);
    npcNameTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    npcNameTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(npcNameTable));
    tableTabs.addTab(npcNameTable, "NPC");
    npcNameTable.build();
    npcNameTable.setVisibleColumns(
            new Object[] { "rowNum", "sex", "textEn", "textRu", "infoColumn", "translateColumn" });
    npcNameTable.setColumnWidth("sex", 87);
    npcNameTable.setColumnHeader("sex", "");

    locationNameContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsLocationName.class);
    locationNameTable = new GspreadSheetTable(locationNameContainer, PAGESIZE,
            service.getgSpreadSheetsLocationNameRepository(), specification);
    locationNameTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    locationNameTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(locationNameTable));
    tableTabs.addTab(locationNameTable, "");
    locationNameTable.build();
    locationNameTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    activatorContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsActivator.class);
    activatorTable = new GspreadSheetTable(activatorContainer, PAGESIZE,
            service.getgSpreadSheetsActivatorRepository(), specification);
    activatorTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    activatorTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(activatorTable));
    tableTabs.addTab(activatorTable, "?");
    activatorTable.build();
    activatorTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    playerPhraseContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsPlayerPhrase.class);
    playerPhraseTable = new GspreadSheetTable(playerPhraseContainer, PAGESIZE,
            service.getgSpreadSheetsPlayerPhraseRepository(), specification);
    playerPhraseTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    playerPhraseTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(playerPhraseTable));
    tableTabs.addTab(playerPhraseTable, " ");
    playerPhraseTable.build();
    playerPhraseTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(".wrapped-text {\n" + "    white-space: normal;\n" + "    overflow: hidden;\n" + "}");
    npcPhraseContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsNpcPhrase.class);
    npcPhraseTable = new GspreadSheetTable(npcPhraseContainer, PAGESIZE,
            service.getgSpreadSheetsNpcPhraseRepository(), specification);
    npcPhraseTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    npcPhraseTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(npcPhraseTable));
    tableTabs.addTab(npcPhraseTable, " NPC");
    npcPhraseTable.build();
    npcPhraseTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    questNameContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsQuestName.class);
    questNameTable = new GspreadSheetTable(questNameContainer, PAGESIZE,
            service.getgSpreadSheetsQuestNameRepository(), specification);
    questNameTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    questNameTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(questNameTable));
    tableTabs.addTab(questNameTable, "?? ?");
    questNameTable.build();
    questNameTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    questDescriptionContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsQuestDescription.class);
    questDescriptionTable = new GspreadSheetTable(questDescriptionContainer, PAGESIZE,
            service.getgSpreadSheetsQuestDescriptionRepository(), specification);
    questDescriptionTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    questDescriptionTable.addGeneratedColumn("translateColumn",
            new TranslateColumnGenerator(questDescriptionTable));
    tableTabs.addTab(questDescriptionTable, "?? ?");
    questDescriptionTable.build();
    questDescriptionTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    questDirectionContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsQuestDirection.class);
    questDirectionTable = new GspreadSheetTable(questDirectionContainer, PAGESIZE,
            service.getgSpreadSheetsQuestDirectionRepository(), specification);
    questDirectionTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    questDirectionTable.addGeneratedColumn("translateColumn",
            new TranslateColumnGenerator(questDirectionTable));
    tableTabs.addTab(questDirectionTable, " ?");
    questDirectionTable.build();
    questDirectionTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    questStartTipContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsQuestStartTip.class);
    questStartTipTable = new GspreadSheetTable(questStartTipContainer, PAGESIZE,
            service.getgSpreadSheetsQuestStartTipRepository(), specification);
    questStartTipTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    questStartTipTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(questStartTipTable));
    tableTabs.addTab(questStartTipTable, "? ");
    questStartTipTable.build();
    questStartTipTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    questEndTipContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsQuestEndTip.class);
    questEndTipTable = new GspreadSheetTable(questEndTipContainer, PAGESIZE,
            service.getgSpreadSheetsQuestEndTipRepository(), specification);
    questEndTipTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    questEndTipTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(questEndTipTable));
    tableTabs.addTab(questEndTipTable, " ");
    questEndTipTable.build();
    questEndTipTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    itemNameLayout = new VerticalLayout();
    itemNameLayout.setMargin(false);
    itemNameLayout.setSpacing(false);
    itemNameLayout.setSizeFull();
    Label itemNameLabel = new Label(
            "???!  ?  ?:   ? ?, ? ? ? ? .");
    itemNameLabel.setStyleName(ValoTheme.LABEL_COLORED);
    itemNameContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsItemName.class);
    itemNameTable = new GspreadSheetTable(itemNameContainer, PAGESIZE,
            service.getgSpreadSheetsItemNameRepository(), itemNameSpecification);
    itemNameTable.addGeneratedColumn("itemTypeColumn", new ItemInfoColumnGenerator());
    itemNameTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    itemNameTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(itemNameTable));
    itemNameLayout.addComponent(itemNameLabel);
    itemNameLayout.addComponent(itemNameTable);
    itemNameLayout.setExpandRatio(itemNameTable, 1f);
    tableTabs.addTab(itemNameLayout, "?? ");
    itemNameTable.build();
    itemNameTable.setVisibleColumns(
            new Object[] { "rowNum", "textEn", "textRu", "itemTypeColumn", "infoColumn", "translateColumn" });
    itemNameTable.setColumnHeader("itemTypeColumn", "");
    itemNameTable.setColumnExpandRatio("itemTypeColumn", 0.5f);

    itemDescriptionContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsItemDescription.class);
    itemDescriptionTable = new GspreadSheetTable(itemDescriptionContainer, PAGESIZE,
            service.getgSpreadSheetsItemDescriptionRepository(), specification);
    itemDescriptionTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    itemDescriptionTable.addGeneratedColumn("translateColumn",
            new TranslateColumnGenerator(itemDescriptionTable));
    tableTabs.addTab(itemDescriptionTable, "?? ");
    itemDescriptionTable.build();
    itemDescriptionTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    journalEntryContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsJournalEntry.class);
    journalEntryTable = new GspreadSheetTable(journalEntryContainer, PAGESIZE,
            service.getgSpreadSheetsJournalEntryRepository(), specification);
    journalEntryTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    journalEntryTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(journalEntryTable));
    tableTabs.addTab(journalEntryTable, "? ");
    journalEntryTable.build();
    journalEntryTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    achievementContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsAchievement.class);
    achievementTable = new GspreadSheetTable(achievementContainer, PAGESIZE,
            service.getgSpreadSheetsAchievementRepository(), specification);
    achievementTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    achievementTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(achievementTable));
    tableTabs.addTab(achievementTable, "??");
    achievementTable.build();
    achievementTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    achievementDescriptionContainer = new GeneratedPropertyListContainer<>(
            GSpreadSheetsAchievementDescription.class);
    achievementDescriptionTable = new GspreadSheetTable(achievementDescriptionContainer, PAGESIZE,
            service.getgSpreadSheetsAchievementDescriptionRepository(), specification);
    achievementDescriptionTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    achievementDescriptionTable.addGeneratedColumn("translateColumn",
            new TranslateColumnGenerator(achievementDescriptionTable));
    tableTabs.addTab(achievementDescriptionTable, "?? ?");
    achievementDescriptionTable.build();
    achievementDescriptionTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    abilityDescriptionContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsAbilityDescription.class);
    abilityDescriptionTable = new GspreadSheetTable(abilityDescriptionContainer, PAGESIZE,
            service.getgSpreadSheetsAbilityDescriptionRepository(), specification);
    abilityDescriptionTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    abilityDescriptionTable.addGeneratedColumn("translateColumn",
            new TranslateColumnGenerator(abilityDescriptionTable));
    tableTabs.addTab(abilityDescriptionTable, "?? ???");
    abilityDescriptionTable.build();
    abilityDescriptionTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    noteContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsNote.class);
    noteTable = new GspreadSheetTable(noteContainer, PAGESIZE, service.getgSpreadSheetsNoteRepository(),
            specification);
    noteTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    noteTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(noteTable));
    tableTabs.addTab(noteTable, "?");
    noteTable.build();
    noteTable.setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    collectibleContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsCollectible.class);
    collectibleTable = new GspreadSheetTable(collectibleContainer, PAGESIZE,
            service.getgSpreadSheetsCollectibleRepository(), specification);
    collectibleTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    collectibleTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(collectibleTable));
    tableTabs.addTab(collectibleTable, " ");
    collectibleTable.build();
    collectibleTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    collectibleDescriptionContainer = new GeneratedPropertyListContainer<>(
            GSpreadSheetsCollectibleDescription.class);
    collectibleDescriptionTable = new GspreadSheetTable(collectibleDescriptionContainer, PAGESIZE,
            service.getgSpreadSheetsCollectibleDescriptionRepository(), specification);
    collectibleDescriptionTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    collectibleDescriptionTable.addGeneratedColumn("translateColumn",
            new TranslateColumnGenerator(collectibleDescriptionTable));
    tableTabs.addTab(collectibleDescriptionTable,
            "??  ");
    collectibleDescriptionTable.build();
    collectibleDescriptionTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });

    loadscreenContainer = new GeneratedPropertyListContainer<>(GSpreadSheetsLoadscreen.class);
    loadscreenTable = new GspreadSheetTable(loadscreenContainer, PAGESIZE,
            service.getgSpreadSheetsLoadscreenRepository(), specification);
    loadscreenTable.addGeneratedColumn("infoColumn", new InfoColumnGenerator());
    loadscreenTable.addGeneratedColumn("translateColumn", new TranslateColumnGenerator(loadscreenTable));
    tableTabs.addTab(loadscreenTable, " ?");
    loadscreenTable.build();
    loadscreenTable
            .setVisibleColumns(new Object[] { "rowNum", "textEn", "textRu", "infoColumn", "translateColumn" });
    LoadTables();
    itemType.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            LoadTables();
        }
    });
    itemSubType.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            LoadTables();
        }
    });
    notTranslated.addValueChangeListener(new HasValue.ValueChangeListener<Boolean>() {
        @Override
        public void valueChange(HasValue.ValueChangeEvent<Boolean> event) {
            LoadTables();
        }
    });

    this.addComponent(tableTabs);
    this.setExpandRatio(tableTabs, 20f);
}

From source file:org.jpos.qi.QIEntityView.java

License:Open Source License

protected CheckBox buildAndBindBooleanField(String id) {
    CheckBox box = new CheckBox(StringUtils.capitalize(getCaptionFromId("field." + id)), false);
    Binder.BindingBuilder builder = formatField(id, box);
    builder.bind(id);/*w  ww .  jav a  2 s. c  o m*/
    return box;
}

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

License:Open Source License

public MailServerPanel(final ApplicationContext context, TabbedPanel tabbedPanel) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;

    final GlobalSetting hostNameSetting = getGlobalSetting(MailSession.SETTING_HOST_NAME, "localhost");
    final GlobalSetting transportSetting = getGlobalSetting(MailSession.SETTING_TRANSPORT, "smtp");
    final GlobalSetting portSetting = getGlobalSetting(MailSession.SETTING_PORT_NUMBER, "25");
    final GlobalSetting fromSetting = getGlobalSetting(MailSession.SETTING_FROM, "metl@localhost");
    final GlobalSetting usernameSetting = getGlobalSetting(MailSession.SETTING_USERNAME, "");
    final GlobalSetting passwordSetting = getGlobalSetting(MailSession.SETTING_PASSWORD, "");
    final GlobalSetting useTlsSetting = getGlobalSetting(MailSession.SETTING_USE_TLS, "false");
    final GlobalSetting useAuthSetting = getGlobalSetting(MailSession.SETTING_USE_AUTH, "false");

    FormLayout form = new FormLayout();
    form.setSpacing(true);/* w w w . j a  va 2s.  c om*/

    ImmediateUpdateTextField hostField = new ImmediateUpdateTextField("Host name") {
        protected void save(String value) {
            saveSetting(hostNameSetting, value);
        }
    };
    hostField.setValue(hostNameSetting.getValue());
    hostField.setWidth(25f, Unit.EM);
    form.addComponent(hostField);
    hostField.focus();

    NativeSelect transportField = new NativeSelect("Transport");
    transportField.addItem("smtp");
    transportField.addItem("smtps");
    transportField.select(transportSetting.getValue() == null ? "smtp" : transportSetting.getValue());
    transportField.setNullSelectionAllowed(false);
    transportField.setImmediate(true);
    transportField.setWidth(10f, Unit.EM);
    transportField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            saveSetting(transportSetting, (String) event.getProperty().getValue());
        }
    });
    form.addComponent(transportField);

    ImmediateUpdateTextField portField = new ImmediateUpdateTextField("Port") {
        protected void save(String value) {
            saveSetting(portSetting, value);
        }
    };
    portField.setValue(portSetting.getValue());
    portField.setWidth(25f, Unit.EM);
    form.addComponent(portField);

    ImmediateUpdateTextField fromField = new ImmediateUpdateTextField("From Address") {
        protected void save(String value) {
            saveSetting(fromSetting, value);
        }
    };
    fromField.setValue(fromSetting.getValue());
    fromField.setWidth(25f, Unit.EM);
    form.addComponent(fromField);

    CheckBox tlsField = new CheckBox("Use TLS", Boolean.valueOf(useTlsSetting.getValue()));
    tlsField.setImmediate(true);
    tlsField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            saveSetting(useTlsSetting, ((Boolean) event.getProperty().getValue()).toString());
        }
    });
    form.addComponent(tlsField);

    final ImmediateUpdateTextField userField = new ImmediateUpdateTextField("Username") {
        protected void save(String value) {
            saveSetting(usernameSetting, value);
        }
    };
    userField.setValue(usernameSetting.getValue());
    userField.setWidth(25f, Unit.EM);

    final ImmediateUpdatePasswordField passwordField = new ImmediateUpdatePasswordField("Password") {
        protected void save(String value) {
            saveSetting(passwordSetting, value);
        }
    };
    passwordField.setValue(passwordSetting.getValue());
    passwordField.setWidth(25f, Unit.EM);

    CheckBox authField = new CheckBox("Use Authentication", Boolean.valueOf(useAuthSetting.getValue()));
    authField.setImmediate(true);
    authField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            Boolean isEnabled = (Boolean) event.getProperty().getValue();
            saveSetting(useAuthSetting, isEnabled.toString());
            userField.setEnabled(isEnabled);
            passwordField.setEnabled(isEnabled);
        }
    });
    form.addComponent(authField);
    userField.setEnabled(authField.getValue());
    form.addComponent(userField);
    passwordField.setEnabled(authField.getValue());
    form.addComponent(passwordField);

    Button testButton = new Button("Test Connection");
    testButton.addClickListener(new TestClickListener());
    form.addComponent(testButton);

    addComponent(form);
    setMargin(true);
}

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

License:Open Source License

public NotificationEditPanel(final ApplicationContext context, final Notification notification) {
    this.context = context;
    this.notification = notification;

    sampleSubjectByEvent = new HashMap<String, String>();
    sampleSubjectByEvent.put(Notification.EventType.FLOW_START.toString(), "Flow $(_flowName) started");
    sampleSubjectByEvent.put(Notification.EventType.FLOW_END.toString(), "Flow $(_flowName) ended");
    sampleSubjectByEvent.put(Notification.EventType.FLOW_ERROR.toString(), "Flow $(_flowName) - ERROR");

    sampleMessageByEvent = new HashMap<String, String>();
    sampleMessageByEvent.put(Notification.EventType.FLOW_START.toString(),
            "Started flow $(_flowName) on agent $(_agentName) at $(_time) on $(_date)");
    sampleMessageByEvent.put(Notification.EventType.FLOW_END.toString(),
            "Ended flow $(_flowName) on agent $(_agent) at $(_time) on $(_date)");
    sampleMessageByEvent.put(Notification.EventType.FLOW_ERROR.toString(),
            "Error in flow $(_flowName) on agent $(_agentName) at $(_time) on $(_date)\n\n$(_errorText)");

    FormLayout form = new FormLayout();
    form.setSizeFull();/*from  w w  w.  ja v  a  2s  .c o  m*/
    form.setSpacing(true);

    levelField = new NativeSelect("Level");
    for (Notification.Level level : Notification.Level.values()) {
        levelField.addItem(level.toString());
    }
    levelField.setNullSelectionAllowed(false);
    levelField.setImmediate(true);
    levelField.setWidth(15f, Unit.EM);
    levelField.addValueChangeListener(new LevelFieldListener());
    form.addComponent(levelField);

    linkField = new ComboBox("Linked To");
    linkField.setNullSelectionAllowed(false);
    linkField.setImmediate(true);
    linkField.setWidth(15f, Unit.EM);
    linkField.addValueChangeListener(new LinkFieldListener());
    form.addComponent(linkField);

    eventField = new NativeSelect("Event");
    eventField.setNullSelectionAllowed(false);
    eventField.setImmediate(true);
    eventField.setWidth(15f, Unit.EM);
    eventField.addValueChangeListener(new EventFieldListener());
    form.addComponent(eventField);

    nameField = new ImmediateUpdateTextField("Name") {
        protected void save(String value) {
            notification.setName(value);
            saveNotification();
        }
    };
    nameField.setValue(StringUtils.trimToEmpty(notification.getName()));
    nameField.setWidth(20f, Unit.EM);
    nameField.setDescription("Display name for the notification");
    form.addComponent(nameField);

    ImmediateUpdateTextArea recipientsField = new ImmediateUpdateTextArea("Recipients") {
        protected void save(String value) {
            notification.setRecipients(value);
            saveNotification();
        }
    };
    recipientsField.setValue(StringUtils.trimToEmpty(notification.getRecipients()));
    recipientsField.setColumns(20);
    recipientsField.setRows(10);
    recipientsField.setInputPrompt("address1@example.com\r\naddress2@example.com");
    recipientsField.setDescription("Email addresses of recipients, separated by commas.");
    form.addComponent(recipientsField);

    subjectField = new ImmediateUpdateTextField("Subject") {
        protected void save(String value) {
            notification.setSubject(value);
            saveNotification();
        }
    };
    subjectField.setValue(StringUtils.trimToEmpty(notification.getSubject()));
    subjectField.setWidth(40f, Unit.EM);
    subjectField.setDescription("The subject of the email can contain...");
    form.addComponent(subjectField);

    messageField = new ImmediateUpdateTextArea("Message") {
        protected void save(String value) {
            notification.setMessage(value);
            saveNotification();
        }
    };
    messageField.setValue(StringUtils.trimToEmpty(notification.getMessage()));
    messageField.setColumns(40);
    messageField.setRows(10);
    messageField.setDescription("The body of the email can contain...");
    form.addComponent(messageField);

    CheckBox enableField = new CheckBox("Enabled", notification.isEnabled());
    enableField.setImmediate(true);
    enableField.addValueChangeListener(new ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            notification.setEnabled((Boolean) event.getProperty().getValue());
            saveNotification();
        }
    });
    form.addComponent(enableField);

    if (notification.getLevel() == null) {
        isInit = true;
        levelField.setValue(Notification.Level.GLOBAL.toString());
        notification.setLevel(Notification.Level.GLOBAL.toString());
        notification.setNotifyType(Notification.NotifyType.MAIL.toString());
        updateLinks();
        updateEventTypes();
        updateName();
    } else {
        levelField.setValue(notification.getLevel());
        updateLinks();
        updateEventTypes();
        linkField.setValue(notification.getLinkId());
        eventField.setValue(notification.getEventType());
        isInit = true;
    }

    addComponent(form);
    setMargin(true);
    autoSave = true;
}

From source file:org.jumpmind.metl.ui.views.deploy.EditAgentPanel.java

License:Open Source License

public EditAgentPanel(ApplicationContext context, TabbedPanel tabbedPanel, Agent agent) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;
    this.agent = agent;
    this.backgroundRefresherService = context.getBackgroundRefresherService();

    HorizontalLayout editAgentLayout = new HorizontalLayout();
    editAgentLayout.setSpacing(true);// w w w  .  j a v  a 2  s . co  m
    editAgentLayout.setMargin(new MarginInfo(true, false, false, true));
    editAgentLayout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(editAgentLayout);

    final ComboBox startModeCombo = new ComboBox("Start Mode");
    startModeCombo.setImmediate(true);
    startModeCombo.setNullSelectionAllowed(false);
    AgentStartMode[] modes = AgentStartMode.values();
    for (AgentStartMode agentStartMode : modes) {
        startModeCombo.addItem(agentStartMode.name());
    }
    startModeCombo.setValue(agent.getStartMode());
    startModeCombo.addValueChangeListener(event -> {
        agent.setStartMode((String) startModeCombo.getValue());
        context.getConfigurationService().save((AbstractObject) EditAgentPanel.this.agent);
    });

    editAgentLayout.addComponent(startModeCombo);
    editAgentLayout.setComponentAlignment(startModeCombo, Alignment.BOTTOM_LEFT);

    Button parameterButton = new Button("Parameters");
    parameterButton.addClickListener(new ParameterClickListener());
    editAgentLayout.addComponent(parameterButton);
    editAgentLayout.setComponentAlignment(parameterButton, Alignment.BOTTOM_LEFT);

    HorizontalLayout buttonGroup = new HorizontalLayout();

    final TextField hostNameField = new TextField("Hostname");
    hostNameField.setImmediate(true);
    hostNameField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    hostNameField.setTextChangeTimeout(100);
    hostNameField.setWidth(20, Unit.EM);
    hostNameField.setNullRepresentation("");
    hostNameField.setValue(agent.getHost());
    hostNameField.addValueChangeListener(event -> {
        agent.setHost((String) hostNameField.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });

    buttonGroup.addComponent(hostNameField);
    buttonGroup.setComponentAlignment(hostNameField, Alignment.BOTTOM_LEFT);

    Button getHostNameButton = new Button("Get Host");
    getHostNameButton.addClickListener(event -> hostNameField.setValue(AppUtils.getHostName()));
    buttonGroup.addComponent(getHostNameButton);
    buttonGroup.setComponentAlignment(getHostNameButton, Alignment.BOTTOM_LEFT);

    editAgentLayout.addComponent(buttonGroup);
    editAgentLayout.setComponentAlignment(buttonGroup, Alignment.BOTTOM_LEFT);

    Button exportButton = new Button("Export Agent Config", event -> exportConfiguration());
    editAgentLayout.addComponent(exportButton);
    editAgentLayout.setComponentAlignment(exportButton, Alignment.BOTTOM_LEFT);

    CheckBox autoRefresh = new CheckBox("Auto Refresh", Boolean.valueOf(agent.isAutoRefresh()));
    autoRefresh.setImmediate(true);
    autoRefresh.addValueChangeListener(event -> {
        agent.setAutoRefresh(autoRefresh.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });
    editAgentLayout.addComponent(autoRefresh);
    editAgentLayout.setComponentAlignment(autoRefresh, Alignment.BOTTOM_LEFT);

    CheckBox allowTestFlowsField = new CheckBox("Allow Test Flows", Boolean.valueOf(agent.isAllowTestFlows()));
    allowTestFlowsField.setImmediate(true);
    allowTestFlowsField.addValueChangeListener(event -> {
        agent.setAllowTestFlows(allowTestFlowsField.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });
    editAgentLayout.addComponent(allowTestFlowsField);
    editAgentLayout.setComponentAlignment(allowTestFlowsField, Alignment.BOTTOM_LEFT);

    ButtonBar buttonBar = new ButtonBar();
    addComponent(buttonBar);

    addDeploymentButton = buttonBar.addButton("Add Deployment", Icons.DEPLOYMENT);
    addDeploymentButton.addClickListener(new AddDeploymentClickListener());

    editButton = buttonBar.addButton("Edit", FontAwesome.EDIT);
    editButton.addClickListener(event -> editClicked());

    enableButton = buttonBar.addButton("Enable", FontAwesome.CHAIN);
    enableButton.addClickListener(event -> enableClicked());

    disableButton = buttonBar.addButton("Disable", FontAwesome.CHAIN_BROKEN);
    disableButton.addClickListener(event -> disableClicked());

    removeButton = buttonBar.addButton("Remove", FontAwesome.TRASH_O);
    removeButton.addClickListener(event -> removeClicked());

    runButton = buttonBar.addButton("Run", Icons.RUN);
    runButton.addClickListener(event -> runClicked());

    container = new BeanItemContainer<AgentDeploymentSummary>(AgentDeploymentSummary.class);
    container.setItemSorter(new TableItemSorter());

    table = new Table();
    table.setSizeFull();
    table.setCacheRate(100);
    table.setPageLength(100);
    table.setImmediate(true);
    table.setSelectable(true);
    table.setMultiSelect(true);

    table.setContainerDataSource(container);
    table.setVisibleColumns("name", "projectName", "type", "status", "logLevel", "startType",
            "startExpression");
    table.setColumnHeaders("Deployment", "Project", "Type", "Status", "Log Level", "Start Type",
            "Start Expression");
    table.addGeneratedColumn("status", new StatusRenderer());
    table.addItemClickListener(new TableItemClickListener());
    table.addValueChangeListener(new TableValueChangeListener());
    table.setSortContainerPropertyId("type");
    table.setSortAscending(true);

    addComponent(table);
    setExpandRatio(table, 1.0f);
    refresh();
    setButtonsEnabled();
    backgroundRefresherService.register(this);
}