List of usage examples for com.vaadin.ui VerticalLayout setSizeFull
@Override public void setSizeFull()
From source file:org.escidoc.browser.ui.UserGroupView.java
License:Open Source License
private ComponentContainer buildVlContentPanel() throws EscidocClientException { VerticalLayout layout = createMainLayout(); layout.setSizeFull(); layout.addComponent(buildVlResourceProperties()); addNameField(layout);//from ww w . j a va2 s .c om addOrgUnitTable(layout); addSaveButton(layout); layout.addComponent(new GroupRolesView(resourceProxy.getId(), repositories, router)); return layout; }
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();/* ww w.ja va 2 s . c om*/ 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.fatal1t.finbe.ui.views.SimpleLoginView.java
@Autowired public SimpleLoginView(LoginService service, AuthenticationService authenticationService1) { setSizeFull();/*from w ww . j a v a2 s . c o m*/ this.loginService = service; this.authenticationService = authenticationService1; // Create login & registration button and add them to separate component loginButton = new Button("Login"); registerButton = new Button("Register"); buttons = new HorizontalLayout(loginButton, registerButton); // Create the user input field user = new TextField("User:"); user.setWidth("300px"); user.setRequired(true); user.setInputPrompt("Your username (eg. joe@email.com)"); user.setValue("test"); //user.addValidator(new EmailValidator( // "Username must be an email address")); //user.setInvalidAllowed(false); // Create the password input field password = new PasswordField("Password:"); password.setWidth("300px"); //password.addValidator(new PasswordValidator()); password.setRequired(true); password.setValue("123456"); password.setNullRepresentation(""); //add listeners and shortcuts this.loginButton.addClickListener(e -> this.loginButtonClick(e)); this.loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); this.registerButton.addClickListener(e -> { System.out.println("Pozadavek na registraci"); this.getUI().getNavigator().navigateTo(RegistrationView.NAME); }); // Add both to a panel VerticalLayout fields = new VerticalLayout(user, password, buttons); fields.setCaption("Please login to access the application. (test@test.com/passw0rd)"); fields.setSpacing(true); fields.setMargin(new MarginInfo(true, true, true, true)); fields.setSizeUndefined(); // The view root layout VerticalLayout viewLayout = new VerticalLayout(fields); viewLayout.setSizeFull(); viewLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER); setCompositionRoot(viewLayout); }
From source file:org.gpstouch.account.AccountGridView.java
public AccountGridView() { setSizeFull();//from w w w . ja v a 2 s. co m addStyleName("crud-view"); HorizontalLayout topLayout = createTopBar(); grid = new AccountGrid(); grid.addSelectionListener(new SelectionListener() { @Override public void select(SelectionEvent event) { viewLogic.rowSelected(grid.getSelectedRow()); } }); VerticalLayout barAndGridLayout = new VerticalLayout(); barAndGridLayout.addComponent(topLayout); barAndGridLayout.addComponent(grid); barAndGridLayout.setMargin(true); barAndGridLayout.setSpacing(true); barAndGridLayout.setSizeFull(); barAndGridLayout.setExpandRatio(grid, 1); barAndGridLayout.setStyleName("crud-main-layout"); addComponent(barAndGridLayout); viewLogic.init(); }
From source file:org.hip.vif.web.components.AbstractConfigurationPopup.java
License:Open Source License
/** @return {@link VerticalLayout} the configured layout of the popup window */ public static VerticalLayout createLayout() { final VerticalLayout out = new VerticalLayout(); out.setStyleName("vif-lookup"); //$NON-NLS-1$ out.setMargin(true);/* ww w . j a v a2s . com*/ out.setSpacing(true); out.setSizeFull(); return out; }
From source file:org.iespuigcastellar.attendancemanager.screenlayouts.EditTeachersLayout.java
License:Open Source License
private void initLayout() { VerticalLayout left = new VerticalLayout(); left.setSizeFull(); left.addComponent(teachersTable);/*from ww w . j av a 2s. c o m*/ teachersTable.setSizeFull(); left.setExpandRatio(teachersTable, 1); tablecontrols.setWidth("100%"); left.addComponent(tablecontrols); this.addComponent(left); VerticalLayout right = new VerticalLayout(); right.setSizeFull(); Panel formPanel = new Panel("Form:"); formPanel.setSizeFull(); formPanel.addComponent(teacherForm); formPanel.addComponent(addupdateButton); right.addComponent(formPanel); teacherForm.setSizeFull(); teacherForm.getLayout().setMargin(true); teacherForm.setImmediate(true); teacherForm.getLayout().addComponent(loginTextField); teacherForm.getLayout().addComponent(passwordTextField); teacherForm.getLayout().addComponent(commentTextField); teacherForm.getLayout().addComponent(adminCheckBox); //teacherForm.setEnabled(false); this.addComponent(right); }
From source file:org.iespuigcastellar.attendancemanager.screenlayouts.NewEditTeachersLayout.java
License:Open Source License
private void initLayout() { VerticalLayout left = new VerticalLayout(); left.setSizeFull(); left.addComponent(teachersTable);//w w w. ja v a2s. c o m teachersTable.setSizeFull(); left.setExpandRatio(teachersTable, 1); filterHorizontalLayout.setWidth("100%"); left.addComponent(filterHorizontalLayout); this.addComponent(left); VerticalLayout right = new VerticalLayout(); HorizontalLayout controlsHorizontalLayout = new HorizontalLayout(); newButton = new Button("New", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub System.out.println("Nuevo profesor !!!"); Object id = teachersTable.addItem(); teachersTable.setValue(id); teachersData.getContainerProperty(id, "id").setValue(0); teachersData.getContainerProperty(id, "login").setValue(""); teachersData.getContainerProperty(id, "password").setValue(""); teachersData.getContainerProperty(id, "comment").setValue(""); teachersData.getContainerProperty(id, "admin").setValue(new Boolean(false)); // <- REVISAR !!! deleteButton.setEnabled(false); saveButton.setVisible(true); updateButton.setVisible(false); } }); controlsHorizontalLayout.addComponent(newButton); deleteButton = new Button("Delete", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { System.out.println("Delete teacher " + teachersTable.getValue() + " on " + new java.util.Date()); app.storage.deleteTeacher((Integer) teachersTable.getValue()); teachersTable.removeItem(teachersTable.getValue()); teachersTable.select(null); newButton.setEnabled(true); deleteButton.setEnabled(false); } }); deleteButton.setEnabled(false); controlsHorizontalLayout.addComponent(deleteButton); controlsHorizontalLayout.setSpacing(true); controlsHorizontalLayout.setMargin(true); right.addComponent(new Panel("Controls", controlsHorizontalLayout)); saveButton = new Button("save", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { System.out.println("Save Button !!!"); deleteButton.setEnabled(false); teacherForm.commit(); Teacher t = new Teacher(Integer.valueOf((String) teacherForm.getField("id").getValue()), (String) teacherForm.getField("login").getValue(), (String) teacherForm.getField("password").getValue(), (String) teacherForm.getField("comment").getValue(), (Boolean) teacherForm.getField("admin").getValue()); int id = app.storage.addTeacher(t); //teachersTable.removeAllItems(); //loadData(); //teacherForm.getField("id").setValue(id); System.out.println(t); teachersTable.select(null); saveButton.setVisible(false); } }); saveButton.setVisible(false); updateButton = new Button("update", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { System.out.println("Update Button "); Teacher t = new Teacher(Integer.valueOf((String) teacherForm.getField("id").getValue()), (String) teacherForm.getField("login").getValue(), (String) teacherForm.getField("password").getValue(), (String) teacherForm.getField("comment").getValue(), (Boolean) teacherForm.getField("admin").getValue()); app.storage.updateTeacher(t); teacherForm.commit(); } }); updateButton.setVisible(false); teacherForm.getLayout().addComponent(saveButton); teacherForm.getLayout().addComponent(updateButton); teacherForm.setSizeFull(); teacherForm.getLayout().setMargin(true); teacherForm.setImmediate(true); //teacherForm.setEnabled(false); // teacher = new Teacher(0, "", "", "", false); // teacherItem = new BeanItem<Teacher>(teacher); teacherForm.setCaption("Teacher details"); teacherForm.setWriteThrough(false); teacherForm.setInvalidCommitted(false); teacherForm.setFormFieldFactory(new TeacherFieldFactory()); // teacherForm.setData(teacherItem); teacherForm.setVisibleItemProperties( Arrays.asList(new String[] { "id", "login", "password", "comment", "admin" })); right.addComponent(teacherForm); this.addComponent(right); }
From source file:org.ikasan.dashboard.ui.administration.panel.PrincipalManagementPanel.java
License:BSD License
@SuppressWarnings("deprecation") protected void init() { this.setWidth("100%"); this.setHeight("100%"); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true);/*from ww w. j ava 2 s . c o m*/ layout.setSizeFull(); Panel securityAdministrationPanel = new Panel(); securityAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); securityAdministrationPanel.setHeight("100%"); securityAdministrationPanel.setWidth("100%"); GridLayout gridLayout = new GridLayout(2, 5); gridLayout.setWidth("100%"); gridLayout.setHeight("100%"); gridLayout.setMargin(true); gridLayout.setSizeFull(); Label groupManagementLabel = new Label("Group Management"); groupManagementLabel.setStyleName(ValoTheme.LABEL_HUGE); gridLayout.addComponent(groupManagementLabel, 0, 0, 1, 0); Label groupSearchHintLabel = new Label(); groupSearchHintLabel.setCaptionAsHtml(true); groupSearchHintLabel.setCaption( VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Type into the Group Name field to find a group."); groupSearchHintLabel.addStyleName(ValoTheme.LABEL_TINY); groupSearchHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); gridLayout.addComponent(groupSearchHintLabel, 0, 1, 1, 1); Label principalNameLabel = new Label("Group Name:"); principalNameLabel.setSizeUndefined(); principalNameField = new AutocompleteField<IkasanPrincipal>(); principalNameField.setWidth("70%"); final DragAndDropWrapper principalNameFieldWrap = new DragAndDropWrapper(principalNameField); principalNameFieldWrap.setDragStartMode(DragStartMode.COMPONENT); principalTypeField.setWidth("70%"); descriptionField.setWidth("70%"); descriptionField.setHeight("60px"); roleTable.addContainerProperty("Role", String.class, null); roleTable.addContainerProperty("", Button.class, null); roleTable.setHeight("610px"); roleTable.setWidth("300px"); userTable.addContainerProperty("Associated Users", String.class, null); userTable.setHeight("610px"); userTable.setWidth("300px"); principalDropTable.addContainerProperty("Members", String.class, null); principalDropTable.addContainerProperty("", Button.class, null); principalDropTable.setHeight("700px"); principalDropTable.setWidth("300px"); principalNameField.setQueryListener(new AutocompleteQueryListener<IkasanPrincipal>() { @Override public void handleUserQuery(AutocompleteField<IkasanPrincipal> field, String query) { for (IkasanPrincipal principal : securityService.getPrincipalByNameLike(query)) { field.addSuggestion(principal, principal.getName()); } } }); principalNameField.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<IkasanPrincipal>() { @Override public void onSuggestionPicked(final IkasanPrincipal principal) { PrincipalManagementPanel.this.principal = principal; PrincipalManagementPanel.this.setValues(); } }); GridLayout formLayout = new GridLayout(2, 3); formLayout.setWidth("100%"); formLayout.setHeight("135px"); formLayout.setSpacing(true); formLayout.setColumnExpandRatio(0, .1f); formLayout.setColumnExpandRatio(1, .8f); formLayout.addComponent(principalNameLabel, 0, 0); formLayout.setComponentAlignment(principalNameLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(principalNameFieldWrap, 1, 0); Label principalTypeLabel = new Label("Group Type:"); principalTypeLabel.setSizeUndefined(); formLayout.addComponent(principalTypeLabel, 0, 1); formLayout.setComponentAlignment(principalTypeLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(principalTypeField, 1, 1); Label descriptionLabel = new Label("Description:"); descriptionLabel.setSizeUndefined(); formLayout.addComponent(descriptionLabel, 0, 2); formLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT); formLayout.addComponent(descriptionField, 1, 2); gridLayout.addComponent(formLayout, 0, 2, 1, 2); principalDropTable.setDragMode(TableDragMode.ROW); principalDropTable.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); if (rolesCombo.getValue() == null) { // Do nothing if there is no role selected logger.info("Ignoring drop: " + dropEvent); return; } final WrapperTransferable t = (WrapperTransferable) dropEvent.getTransferable(); final AutocompleteField sourceContainer = (AutocompleteField) t.getDraggedComponent(); logger.info("sourceContainer.getText(): " + sourceContainer.getText()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); final IkasanPrincipal principal = securityService.findPrincipalByName(sourceContainer.getText()); final Role roleToRemove = (Role) rolesCombo.getValue(); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { principalDropTable.removeItem(principal.getName()); principal.getRoles().remove(roleToRemove); securityService.savePrincipal(principal); if (principalNameField.getText().equals(principal.getName())) { roleTable.removeItem(roleToRemove); } } }); principalDropTable.addItem(new Object[] { sourceContainer.getText(), deleteButton }, sourceContainer.getText()); principal.getRoles().add((Role) rolesCombo.getValue()); securityService.savePrincipal(principal); roleTable.removeAllItems(); for (final Role role : principal.getRoles()) { Button roleDeleteButton = new Button(); roleDeleteButton.setIcon(VaadinIcons.TRASH); roleDeleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); roleDeleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); roleDeleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { roleTable.removeItem(role); principal.getRoles().remove(role); securityService.savePrincipal(principal); principalDropTable.removeItem(principal.getName()); } }); roleTable.addItem(new Object[] { role.getName(), roleDeleteButton }, role); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); Label roleTableHintLabel = new Label(); roleTableHintLabel.setCaptionAsHtml(true); roleTableHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " The Roles table below displays the roles that are assigned to the group. Roles can be deleted from this table."); roleTableHintLabel.addStyleName(ValoTheme.LABEL_TINY); roleTableHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); gridLayout.addComponent(roleTableHintLabel, 0, 3, 1, 3); gridLayout.addComponent(roleTable, 0, 4); gridLayout.addComponent(userTable, 1, 4); this.rolesCombo = new ComboBox("Roles"); this.rolesCombo.setWidth("90%"); this.rolesCombo.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { final Role role = (Role) event.getProperty().getValue(); if (role != null) { logger.info("Value changed got Role: " + role); List<IkasanPrincipal> principals = securityService.getAllPrincipalsWithRole(role.getName()); principalDropTable.removeAllItems(); for (final IkasanPrincipal principal : principals) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { principalDropTable.removeItem(principal.getName()); principal.getRoles().remove(role); securityService.savePrincipal(principal); if (principalNameField.getText().equals(principal.getName())) { roleTable.removeItem(role); } } }); principalDropTable.addItem(new Object[] { principal.getName(), deleteButton }, principal.getName()); } } } }); Panel roleMemberPanel = new Panel(); roleMemberPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); roleMemberPanel.setHeight("100%"); roleMemberPanel.setWidth("100%"); GridLayout roleMemberLayout = new GridLayout(); roleMemberLayout.setSpacing(true); roleMemberLayout.setWidth("100%"); roleMemberLayout.setHeight("100%"); Label roleGroupLabels = new Label("Role/Group Associations"); roleGroupLabels.setStyleName(ValoTheme.LABEL_HUGE); gridLayout.addComponent(roleGroupLabels); Label groupDragHintLabel = new Label(); groupDragHintLabel.setCaptionAsHtml(true); groupDragHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drop groups into the table below to assign them the role."); roleMemberLayout.addComponent(roleGroupLabels); roleMemberLayout.addComponent(groupDragHintLabel); roleMemberLayout.addComponent(this.rolesCombo); roleMemberLayout.addComponent(this.principalDropTable); roleMemberPanel.setContent(roleMemberLayout); securityAdministrationPanel.setContent(gridLayout); layout.addComponent(securityAdministrationPanel); VerticalLayout roleMemberPanelLayout = new VerticalLayout(); roleMemberPanelLayout.setWidth("100%"); roleMemberPanelLayout.setHeight("100%"); roleMemberPanelLayout.setMargin(true); roleMemberPanelLayout.addComponent(roleMemberPanel); roleMemberPanelLayout.setSizeFull(); HorizontalSplitPanel hsplit = new HorizontalSplitPanel(); hsplit.setFirstComponent(layout); hsplit.setSecondComponent(roleMemberPanelLayout); // Set the position of the splitter as percentage hsplit.setSplitPosition(65, Unit.PERCENTAGE); hsplit.setLocked(true); this.setContent(hsplit); }
From source file:org.ikasan.dashboard.ui.administration.panel.RoleManagementPanel.java
License:BSD License
@SuppressWarnings({ "serial" }) protected void init() { this.setWidth("100%"); this.setHeight("100%"); this.initPolicyNameField(); this.createPolicyDropPanel(); VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); Panel roleAdministrationPanel = new Panel(); roleAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); roleAdministrationPanel.setHeight("100%"); roleAdministrationPanel.setWidth("100%"); GridLayout gridLayout = new GridLayout(2, 6); gridLayout.setWidth("100%"); gridLayout.setHeight("100%"); gridLayout.setMargin(true);/*from w w w . j a va 2 s .c o m*/ gridLayout.setSizeFull(); Label roleManagementLabel = new Label("Role Management"); roleManagementLabel.setStyleName(ValoTheme.LABEL_HUGE); gridLayout.addComponent(roleManagementLabel, 0, 0, 1, 0); Label roleSearchHintLabel = new Label(); roleSearchHintLabel.setCaptionAsHtml(true); roleSearchHintLabel.setCaption( VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Type into the Role Name field to find a role."); roleSearchHintLabel.addStyleName(ValoTheme.LABEL_TINY); roleSearchHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); gridLayout.addComponent(roleSearchHintLabel, 0, 1, 1, 1); Layout controlLayout = this.initControlLayout(); gridLayout.addComponent(controlLayout, 0, 2, 1, 2); Label roleNameLabel = new Label("Role Name:"); roleNameLabel.setSizeUndefined(); initRoleNameField(); GridLayout formLayout = new GridLayout(2, 2); formLayout.setWidth("100%"); formLayout.setHeight("115px"); formLayout.setSpacing(true); formLayout.setColumnExpandRatio(0, 1); formLayout.setColumnExpandRatio(1, 5); this.roleNameField.setWidth("70%"); formLayout.addComponent(roleNameLabel, 0, 0); formLayout.setComponentAlignment(roleNameLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(this.roleNameField, 1, 0); Label descriptionLabel = new Label("Description:"); descriptionLabel.setSizeUndefined(); this.descriptionField = new TextArea(); this.descriptionField.setWidth("70%"); this.descriptionField.setHeight("60px"); formLayout.addComponent(descriptionLabel, 0, 1); formLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT); formLayout.addComponent(descriptionField, 1, 1); gridLayout.addComponent(formLayout, 0, 3, 1, 3); Label roleTableHintLabel = new Label(); roleTableHintLabel.setCaptionAsHtml(true); roleTableHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " The Associated Users/Groups table below displays the users/groups that are assigned the current role."); roleTableHintLabel.addStyleName(ValoTheme.LABEL_TINY); roleTableHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); gridLayout.addComponent(roleTableHintLabel, 0, 4, 1, 4); this.associatedPrincipalsTable = new Table(); this.associatedPrincipalsTable.addItemClickListener(this.associatedPrincipalItemClickListener); this.associatedPrincipalsTable.addContainerProperty("Associated Users/Groups", String.class, null); this.associatedPrincipalsTable.addContainerProperty("", Button.class, null); this.associatedPrincipalsTable.setHeight("600px"); this.associatedPrincipalsTable.setWidth("650px"); gridLayout.addComponent(this.associatedPrincipalsTable, 0, 5, 1, 5); roleAdministrationPanel.setContent(gridLayout); layout.addComponent(roleAdministrationPanel); HorizontalLayout policyDropPanelLayout = new HorizontalLayout(); policyDropPanelLayout.setMargin(true); policyDropPanelLayout.addComponent(this.policyDropPanel); policyDropPanelLayout.setSizeFull(); HorizontalSplitPanel hsplit = new HorizontalSplitPanel(); hsplit.setFirstComponent(layout); hsplit.setSecondComponent(policyDropPanelLayout); // Set the position of the splitter as percentage hsplit.setSplitPosition(65, Unit.PERCENTAGE); hsplit.setLocked(true); this.setContent(hsplit); }
From source file:org.ikasan.dashboard.ui.administration.panel.UserManagementPanel.java
License:BSD License
@SuppressWarnings("deprecation") protected void init() { this.setWidth("100%"); this.setHeight("100%"); VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); Panel securityAdministrationPanel = new Panel(); securityAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); securityAdministrationPanel.setHeight("100%"); securityAdministrationPanel.setWidth("100%"); GridLayout gridLayout = new GridLayout(2, 6); gridLayout.setMargin(true);//from w w w .j a v a 2 s . c o m gridLayout.setSpacing(true); gridLayout.setSizeFull(); Label mappingConfigurationLabel = new Label("User Management"); mappingConfigurationLabel.setStyleName(ValoTheme.LABEL_HUGE); gridLayout.addComponent(mappingConfigurationLabel, 0, 0, 1, 0); Label userSearchHintLabel = new Label(); userSearchHintLabel.setCaptionAsHtml(true); userSearchHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Type into the Username, Firstname or Surname fields to find a user."); userSearchHintLabel.addStyleName(ValoTheme.LABEL_TINY); userSearchHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); gridLayout.addComponent(userSearchHintLabel, 0, 1, 1, 1); Label usernameLabel = new Label("Username:"); usernameField.setWidth("40%"); final DragAndDropWrapper usernameFieldWrap = new DragAndDropWrapper(usernameField); usernameFieldWrap.setDragStartMode(DragStartMode.COMPONENT); firstName = new AutocompleteField<User>(); firstName.setWidth("40%"); surname = new AutocompleteField<User>(); surname.setWidth("40%"); final TextField department = new TextField(); department.setWidth("40%"); final TextField email = new TextField(); email.setWidth("40%"); final Table roleTable = new Table(); roleTable.addContainerProperty("Role", String.class, null); roleTable.addContainerProperty("", Button.class, null); roleTable.setHeight("520px"); roleTable.setWidth("250px"); usernameField.setQueryListener(new AutocompleteQueryListener<User>() { @Override public void handleUserQuery(AutocompleteField<User> field, String query) { for (User user : userService.getUserByUsernameLike(query)) { field.addSuggestion(user, user.getUsername()); } } }); usernameField.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<User>() { @Override public void onSuggestionPicked(User user) { UserManagementPanel.this.user = user; firstName.setText(user.getFirstName()); surname.setText(user.getSurname()); department.setValue(user.getDepartment()); email.setValue(user.getEmail()); final IkasanPrincipal principal = securityService.findPrincipalByName(user.getUsername()); roleTable.removeAllItems(); for (final Role role : principal.getRoles()) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { roleTable.removeItem(role); principal.getRoles().remove(role); securityService.savePrincipal(principal); userDropTable.removeItem(principal.getName()); } }); roleTable.addItem(new Object[] { role.getName(), deleteButton }, role); } associatedPrincipalsTable.removeAllItems(); for (IkasanPrincipal ikasanPrincipal : user.getPrincipals()) { if (!ikasanPrincipal.getType().equals("user")) { associatedPrincipalsTable.addItem(new Object[] { ikasanPrincipal.getName() }, ikasanPrincipal); } } } }); firstName.setQueryListener(new AutocompleteQueryListener<User>() { @Override public void handleUserQuery(AutocompleteField<User> field, String query) { for (User user : userService.getUserByFirstnameLike(query)) { field.addSuggestion(user, user.getFirstName() + " " + user.getSurname()); } } }); firstName.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<User>() { @Override public void onSuggestionPicked(User user) { UserManagementPanel.this.user = user; usernameField.setText(user.getUsername()); firstName.setText(user.getFirstName()); surname.setText(user.getSurname()); department.setValue(user.getDepartment()); email.setValue(user.getEmail()); final IkasanPrincipal principal = securityService.findPrincipalByName(user.getUsername()); roleTable.removeAllItems(); for (final Role role : principal.getRoles()) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { roleTable.removeItem(role); principal.getRoles().remove(role); securityService.savePrincipal(principal); userDropTable.removeItem(principal.getName()); } }); roleTable.addItem(new Object[] { role.getName(), deleteButton }, role); } associatedPrincipalsTable.removeAllItems(); for (IkasanPrincipal ikasanPrincipal : user.getPrincipals()) { if (!ikasanPrincipal.getType().equals("user")) { associatedPrincipalsTable.addItem(new Object[] { ikasanPrincipal.getName() }, ikasanPrincipal); } } } }); surname.setQueryListener(new AutocompleteQueryListener<User>() { @Override public void handleUserQuery(AutocompleteField<User> field, String query) { for (User user : userService.getUserBySurnameLike(query)) { field.addSuggestion(user, user.getFirstName() + " " + user.getSurname()); } } }); surname.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<User>() { @Override public void onSuggestionPicked(User user) { UserManagementPanel.this.user = user; usernameField.setText(user.getUsername()); firstName.setText(user.getFirstName()); surname.setText(user.getSurname()); department.setValue(user.getDepartment()); email.setValue(user.getEmail()); final IkasanPrincipal principal = securityService.findPrincipalByName(user.getUsername()); roleTable.removeAllItems(); for (final Role role : principal.getRoles()) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { roleTable.removeItem(role); principal.getRoles().remove(role); securityService.savePrincipal(principal); userDropTable.removeItem(principal.getName()); } }); roleTable.addItem(new Object[] { role.getName(), deleteButton }, role); associatedPrincipalsTable.removeAllItems(); for (IkasanPrincipal ikasanPrincipal : user.getPrincipals()) { if (!ikasanPrincipal.getType().equals("user")) { associatedPrincipalsTable.addItem(new Object[] { ikasanPrincipal.getName() }, ikasanPrincipal); } } } } }); GridLayout formLayout = new GridLayout(2, 5); formLayout.setSpacing(true); formLayout.setWidth("100%"); formLayout.setColumnExpandRatio(0, .1f); formLayout.setColumnExpandRatio(1, .8f); usernameLabel.setSizeUndefined(); formLayout.addComponent(usernameLabel, 0, 0); formLayout.setComponentAlignment(usernameLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(usernameFieldWrap, 1, 0); Label firstNameLabel = new Label("First name:"); firstNameLabel.setSizeUndefined(); formLayout.addComponent(firstNameLabel, 0, 1); formLayout.setComponentAlignment(firstNameLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(firstName, 1, 1); Label surnameLabel = new Label("Surname:"); surnameLabel.setSizeUndefined(); formLayout.addComponent(surnameLabel, 0, 2); formLayout.setComponentAlignment(surnameLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(surname, 1, 2); Label departmentLabel = new Label("Department:"); departmentLabel.setSizeUndefined(); formLayout.addComponent(departmentLabel, 0, 3); formLayout.setComponentAlignment(departmentLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(department, 1, 3); Label emailLabel = new Label("Email address:"); emailLabel.setSizeUndefined(); formLayout.addComponent(emailLabel, 0, 4); formLayout.setComponentAlignment(emailLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(email, 1, 4); gridLayout.addComponent(formLayout, 0, 2, 1, 2); Label rolesAndGroupsHintLabel1 = new Label(); rolesAndGroupsHintLabel1.setCaptionAsHtml(true); rolesAndGroupsHintLabel1.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " The Roles table below displays the roles that the user has. Roles can be deleted from this table."); rolesAndGroupsHintLabel1.addStyleName(ValoTheme.LABEL_TINY); rolesAndGroupsHintLabel1.addStyleName(ValoTheme.LABEL_LIGHT); rolesAndGroupsHintLabel1.setWidth(300, Unit.PIXELS); gridLayout.addComponent(rolesAndGroupsHintLabel1, 0, 3, 1, 3); Label rolesAndGroupsHintLabel2 = new Label(); rolesAndGroupsHintLabel2.setCaptionAsHtml(true); rolesAndGroupsHintLabel2.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " The Groups table below displays all the LDAP groups that the user is a member of. You cannot manage these " + "from this application."); rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_TINY); rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_LIGHT); rolesAndGroupsHintLabel2.setWidth(300, Unit.PIXELS); gridLayout.addComponent(rolesAndGroupsHintLabel2, 0, 4, 1, 4); final ClientSideCriterion acceptCriterion = new SourceIs(usernameField); userDropTable.addContainerProperty("Members", String.class, null); userDropTable.addContainerProperty("", Button.class, null); userDropTable.setHeight("715px"); userDropTable.setWidth("300px"); userDropTable.setDragMode(TableDragMode.ROW); userDropTable.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { if (rolesCombo.getValue() == null) { // Do nothing if there is no role selected logger.info("Ignoring drop: " + dropEvent); return; } // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final WrapperTransferable t = (WrapperTransferable) dropEvent.getTransferable(); final AutocompleteField sourceContainer = (AutocompleteField) t.getDraggedComponent(); logger.info("sourceContainer.getText(): " + sourceContainer.getText()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); final IkasanPrincipal principal = securityService.findPrincipalByName(sourceContainer.getText()); final Role roleToRemove = (Role) rolesCombo.getValue(); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { userDropTable.removeItem(principal.getName()); principal.getRoles().remove(roleToRemove); securityService.savePrincipal(principal); if (UserManagementPanel.this.usernameField.getText().equals(principal.getName())) { roleTable.removeItem(roleToRemove); } } }); userDropTable.addItem(new Object[] { sourceContainer.getText(), deleteButton }, sourceContainer.getText()); principal.getRoles().add((Role) rolesCombo.getValue()); securityService.savePrincipal(principal); roleTable.removeAllItems(); for (final Role role : principal.getRoles()) { Button roleDeleteButton = new Button(); roleDeleteButton.setIcon(VaadinIcons.TRASH); roleDeleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); roleDeleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); roleDeleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { roleTable.removeItem(role); principal.getRoles().remove(role); securityService.savePrincipal(principal); userDropTable.removeItem(principal.getName()); } }); roleTable.addItem(new Object[] { role.getName(), roleDeleteButton }, role); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); gridLayout.addComponent(roleTable, 0, 5); this.associatedPrincipalsTable.addContainerProperty("Groups", String.class, null); this.associatedPrincipalsTable.addItemClickListener(this.associatedPrincipalItemClickListener); associatedPrincipalsTable.setHeight("520px"); associatedPrincipalsTable.setWidth("400px"); gridLayout.addComponent(this.associatedPrincipalsTable, 1, 5); this.rolesCombo = new ComboBox("Roles"); this.rolesCombo.setWidth("90%"); this.rolesCombo.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { final Role role = (Role) event.getProperty().getValue(); if (role != null) { logger.info("Value changed got Role: " + role); List<IkasanPrincipal> principals = securityService.getAllPrincipalsWithRole(role.getName()); userDropTable.removeAllItems(); for (final IkasanPrincipal principal : principals) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { userDropTable.removeItem(principal.getName()); principal.getRoles().remove(role); securityService.savePrincipal(principal); if (UserManagementPanel.this.usernameField.getText().equals(principal.getName())) { roleTable.removeItem(role); } } }); userDropTable.addItem(new Object[] { principal.getName(), deleteButton }, principal.getName()); } } } }); Panel roleMemberPanel = new Panel(); roleMemberPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); roleMemberPanel.setHeight("100%"); roleMemberPanel.setWidth("100%"); GridLayout roleMemberLayout = new GridLayout(); roleMemberLayout.setSpacing(true); roleMemberLayout.setWidth("100%"); Label roleMemberAssociationsLabel = new Label("Role/Member Associations"); roleMemberAssociationsLabel.setStyleName(ValoTheme.LABEL_HUGE); Label userDragHintLabel = new Label(); userDragHintLabel.setCaptionAsHtml(true); userDragHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drop users into the table below to assign them the role."); roleMemberLayout.addComponent(roleMemberAssociationsLabel); roleMemberLayout.addComponent(userDragHintLabel); roleMemberLayout.addComponent(this.rolesCombo); roleMemberLayout.addComponent(this.userDropTable); roleMemberPanel.setContent(roleMemberLayout); securityAdministrationPanel.setContent(gridLayout); layout.addComponent(securityAdministrationPanel); VerticalLayout roleMemberPanelLayout = new VerticalLayout(); roleMemberPanelLayout.setWidth("100%"); roleMemberPanelLayout.setHeight("100%"); roleMemberPanelLayout.setMargin(true); roleMemberPanelLayout.addComponent(roleMemberPanel); roleMemberPanelLayout.setSizeFull(); HorizontalSplitPanel hsplit = new HorizontalSplitPanel(); hsplit.setFirstComponent(layout); hsplit.setSecondComponent(roleMemberPanelLayout); // Set the position of the splitter as percentage hsplit.setSplitPosition(65, Unit.PERCENTAGE); hsplit.setLocked(true); this.setContent(hsplit); }