List of usage examples for com.vaadin.ui Panel addStyleName
@Override public void addStyleName(String style)
From source file:org.esn.esobase.view.tab.QuestTranslateTab.java
public QuestTranslateTab(DBService service_) { this.setSizeFull(); this.setSpacing(false); this.setMargin(false); this.service = service_; QuestChangeListener questChangeListener = new QuestChangeListener(); FilterChangeListener filterChangeListener = new FilterChangeListener(); questListlayout = new HorizontalLayout(); questListlayout.setWidth(100f, Unit.PERCENTAGE); questListlayout.setSpacing(false);// w ww. ja v a 2 s. c om questListlayout.setMargin(false); locationTable = new ComboBox("?"); locationTable.setPageLength(30); locationTable.setScrollToSelectedItem(true); locationTable.setWidth(100f, Unit.PERCENTAGE); locationTable.addValueChangeListener(filterChangeListener); locationTable.setDataProvider(new ListDataProvider<>(locations)); questTable = new ComboBox("?"); questTable.setWidth(100f, Unit.PERCENTAGE); questTable.setPageLength(15); questTable.setScrollToSelectedItem(true); questTable.setWidth(100f, Unit.PERCENTAGE); questTable.addValueChangeListener(questChangeListener); questTable.setDataProvider(new ListDataProvider<>(questList)); questListlayout.addComponent(questTable); FormLayout locationAndQuestLayout = new FormLayout(locationTable, questTable); locationAndQuestLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); locationAndQuestLayout.setSizeFull(); questListlayout.addComponent(locationAndQuestLayout); translateStatus = new ComboBoxMultiselect("? ", Arrays.asList(TRANSLATE_STATUS.values())); translateStatus.setClearButtonCaption("?"); translateStatus.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { LoadFilters(); LoadContent(); } }); noTranslations = new CheckBox("? ?"); noTranslations.setValue(Boolean.FALSE); noTranslations.addValueChangeListener(filterChangeListener); emptyTranslations = new CheckBox("? "); emptyTranslations.setValue(Boolean.FALSE); emptyTranslations.addValueChangeListener(filterChangeListener); HorizontalLayout checkBoxlayout = new HorizontalLayout(noTranslations, emptyTranslations); checkBoxlayout.setSpacing(false); checkBoxlayout.setMargin(false); translatorBox = new ComboBox(""); translatorBox.setPageLength(15); translatorBox.setScrollToSelectedItem(true); translatorBox.setDataProvider(new ListDataProvider<SysAccount>(service.getSysAccounts())); translatorBox.addValueChangeListener(filterChangeListener); refreshButton = new Button(""); refreshButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { LoadFilters(); LoadContent(); } }); countLabel = new Label(); searchField = new TextField("?? ?"); searchField.setSizeFull(); searchField.addValueChangeListener(filterChangeListener); FormLayout filtersLayout = new FormLayout(translateStatus, translatorBox, checkBoxlayout, searchField); filtersLayout.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); filtersLayout.setSizeFull(); questListlayout.addComponent(filtersLayout); questListlayout.addComponent(refreshButton); questListlayout.addComponent(countLabel); questListlayout.setExpandRatio(locationAndQuestLayout, 0.4f); questListlayout.setExpandRatio(filtersLayout, 0.4f); questListlayout.setExpandRatio(refreshButton, 0.1f); questListlayout.setExpandRatio(countLabel, 0.1f); questListlayout.setHeight(105f, Unit.PIXELS); this.addComponent(questListlayout); infoLayout = new VerticalLayout(); infoLayout.setSizeFull(); infoLayout.setSpacing(false); infoLayout.setMargin(false); tabSheet = new TabSheet(); tabSheet.setSizeFull(); nameLayout = new VerticalLayout(); nameLayout.setSizeFull(); nameHLayout = new HorizontalLayout(); nameHLayout.setSizeFull(); nameHLayout.setSpacing(false); nameHLayout.setMargin(false); nameLayout = new VerticalLayout(); nameLayout.setSizeFull(); nameLayout.setSpacing(false); nameLayout.setMargin(false); questNameEnArea = new TextArea("?"); questNameEnArea.setSizeFull(); questNameEnArea.setRows(1); questNameEnArea.setReadOnly(true); questNameRuArea = new TextArea("? Ru"); questNameRuArea.setSizeFull(); questNameRuArea.setRows(1); questNameRuArea.setReadOnly(true); questNameRawEnArea = new TextArea("? "); questNameRawEnArea.setSizeFull(); questNameRawEnArea.setRows(1); questNameRawEnArea.setReadOnly(true); questNameRawRuArea = new TextArea("? Ru"); questNameRawRuArea.setSizeFull(); questNameRawRuArea.setRows(1); questNameRawRuArea.setReadOnly(true); nameLayout.addComponents(questNameEnArea, questNameRuArea, questNameRawEnArea, questNameRawRuArea); nameHLayout.addComponent(nameLayout); nameTranslateLayout = new VerticalLayout(); nameTranslateLayout.setSizeFull(); nameTranslateLayout.setSpacing(false); nameTranslateLayout.setMargin(false); nameHLayout.addComponent(nameTranslateLayout); infoLayout.addComponent(nameHLayout); descriptionLayout = new VerticalLayout(); descriptionLayout.setSizeFull(); descriptionHLayout = new HorizontalLayout(); descriptionHLayout.setSizeFull(); descriptionHLayout.setSpacing(false); descriptionHLayout.setMargin(false); descriptionLayout = new VerticalLayout(); descriptionLayout.setSizeFull(); descriptionLayout.setSpacing(false); descriptionLayout.setMargin(false); questDescriptionEnArea = new TextArea("?"); questDescriptionEnArea.setSizeFull(); questDescriptionEnArea.setRows(4); questDescriptionEnArea.setReadOnly(true); questDescriptionRuArea = new TextArea("? Ru"); questDescriptionRuArea.setSizeFull(); questDescriptionRuArea.setRows(4); questDescriptionRuArea.setReadOnly(true); questDescriptionRawEnArea = new TextArea("? "); questDescriptionRawEnArea.setSizeFull(); questDescriptionRawEnArea.setRows(4); questDescriptionRawEnArea.setReadOnly(true); questDescriptionRawRuArea = new TextArea("? Ru"); questDescriptionRawRuArea.setSizeFull(); questDescriptionRawRuArea.setRows(4); questDescriptionRawRuArea.setReadOnly(true); descriptionLayout.addComponents(questDescriptionEnArea, questDescriptionRuArea, questDescriptionRawEnArea, questDescriptionRawRuArea); descriptionHLayout.addComponent(descriptionLayout); descriptionTranslateLayout = new VerticalLayout(); descriptionTranslateLayout.setSizeFull(); descriptionTranslateLayout.setSpacing(false); descriptionTranslateLayout.setMargin(false); descriptionHLayout.addComponent(descriptionTranslateLayout); infoLayout.addComponent(descriptionHLayout); tabSheet.addTab(infoLayout, "?"); stepsLayout = new VerticalLayout(); stepsLayout.setSizeFull(); stepsLayout.setSpacing(false); stepsLayout.setMargin(false); stepsData = new TreeData(); stepsGrid = new TreeGrid(new TreeDataProvider(stepsData)); stepsGrid.setSelectionMode(Grid.SelectionMode.NONE); stepsGrid.setRowHeight(250); stepsGrid.setHeaderVisible(false); stepsGrid.setSizeFull(); stepsGrid.setItemCollapseAllowedProvider(new ItemCollapseAllowedProvider() { @Override public boolean test(Object item) { return false; } }); stepsGrid.addColumn(new ValueProvider() { @Override public Object apply(Object source) { if (source instanceof QuestStep) { return "?"; } if (source instanceof QuestDirection) { return " - " + ((QuestDirection) source).getDirectionType().name(); } return null; } }).setId("rowType").setCaption("").setWidth(132).setStyleGenerator(rowStyleGenerator); stepsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestStep) { QuestStep step = (QuestStep) source; if (step.getTextEn() != null && !step.getTextEn().isEmpty()) { TextArea textEnArea = new TextArea("? "); textEnArea.setValue(step.getTextEn()); textEnArea.setReadOnly(true); textEnArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnArea); } if (step.getTextRu() != null && !step.getTextRu().isEmpty()) { TextArea textRuArea = new TextArea(" "); textRuArea.setValue(step.getTextRu()); textRuArea.setReadOnly(true); textRuArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuArea); } } else if (source instanceof QuestDirection) { QuestDirection d = (QuestDirection) source; if (d.getTextEn() != null && !d.getTextEn().isEmpty()) { TextArea textEnArea = new TextArea("? "); textEnArea.setValue(d.getTextEn()); textEnArea.setRows(2); textEnArea.setReadOnly(true); textEnArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnArea); } if (d.getTextRu() != null && !d.getTextRu().isEmpty()) { TextArea textRuArea = new TextArea(" "); textRuArea.setValue(d.getTextRu()); textRuArea.setRows(2); textRuArea.setReadOnly(true); textRuArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuArea); } } return result; } }).setId("ingameText").setStyleGenerator(rowStyleGenerator); stepsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestStep) { QuestStep step = (QuestStep) source; if (step.getSheetsJournalEntry() != null) { TextArea textEnRawArea = new TextArea("? "); textEnRawArea.setValue(step.getSheetsJournalEntry().getTextEn()); textEnRawArea.setReadOnly(true); textEnRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnRawArea); if (step.getSheetsJournalEntry().getTextRu() != null && !step.getSheetsJournalEntry() .getTextRu().equals(step.getSheetsJournalEntry().getTextEn())) { TextArea textRuRawArea = new TextArea(" " + step.getSheetsJournalEntry().getTranslator()); textRuRawArea.setValue(step.getSheetsJournalEntry().getTextRu()); textRuRawArea.setReadOnly(true); textRuRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuRawArea);//, " " } } } else if (source instanceof QuestDirection) { QuestDirection d = (QuestDirection) source; if (d.getSheetsQuestDirection() != null) { TextArea textEnRawArea = new TextArea("? "); textEnRawArea.setValue(d.getSheetsQuestDirection().getTextEn()); textEnRawArea.setRows(2); textEnRawArea.setReadOnly(true); textEnRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnRawArea); if (d.getSheetsQuestDirection().getTextRu() != null && !d.getSheetsQuestDirection() .getTextRu().equals(d.getSheetsQuestDirection().getTextEn())) { TextArea textRuRawArea = new TextArea(" " + d.getSheetsQuestDirection().getTranslator()); textRuRawArea.setValue(d.getSheetsQuestDirection().getTextRu()); textRuRawArea.setRows(2); textRuRawArea.setReadOnly(true); textRuRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuRawArea); } } } return result; } }).setId("rawText").setStyleGenerator(rowStyleGenerator); stepsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { Panel panel = new Panel(); panel.addStyleName(ValoTheme.PANEL_BORDERLESS); panel.setWidth(100f, Unit.PERCENTAGE); panel.setHeight(245f, Unit.PIXELS); final VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestStep) { Set<TranslatedText> list = new HashSet<>(); List<SysAccount> accounts = new ArrayList<>(); QuestStep step = (QuestStep) source; list.addAll(step.getSheetsJournalEntry().getTranslatedTexts()); if (list != null) { for (TranslatedText t : list) { result.addComponent(new TranslationCell(t)); accounts.add(t.getAuthor()); } } if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && step.getSheetsJournalEntry() != null && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) { final TranslatedText translatedText = new TranslatedText(); translatedText.setAuthor(SpringSecurityHelper.getSysAccount()); translatedText.setSpreadSheetsJournalEntry(step.getSheetsJournalEntry()); Button addTranslation = new Button(" ", FontAwesome.PLUS_SQUARE); addTranslation.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (translatedText.getSpreadSheetsJournalEntry() != null) { translatedText.getSpreadSheetsJournalEntry().getTranslatedTexts() .add(translatedText); } result.addComponent(new TranslationCell(translatedText)); event.getButton().setVisible(false); } }); result.addComponent(addTranslation); } } else if (source instanceof QuestDirection) { Set<TranslatedText> list = new HashSet<>(); List<SysAccount> accounts = new ArrayList<>(); QuestDirection d = (QuestDirection) source; list.addAll(d.getSheetsQuestDirection().getTranslatedTexts()); if (list != null) { for (TranslatedText t : list) { result.addComponent(new TranslationCell(t)); accounts.add(t.getAuthor()); } } if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && d.getSheetsQuestDirection() != null && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) { final TranslatedText translatedText = new TranslatedText(); translatedText.setAuthor(SpringSecurityHelper.getSysAccount()); translatedText.setSpreadSheetsQuestDirection(d.getSheetsQuestDirection()); Button addTranslation = new Button(" "); addTranslation.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (translatedText.getSpreadSheetsQuestDirection() != null) { translatedText.getSpreadSheetsQuestDirection().getTranslatedTexts() .add(translatedText); } result.addComponent(new TranslationCell(translatedText)); event.getButton().setVisible(false); } }); result.addComponent(addTranslation); } } panel.setContent(result); return panel; } }).setId("translation").setStyleGenerator(rowStyleGenerator); stepsGrid.setColumns("rowType", "ingameText", "rawText", "translation"); stepsLayout.addComponent(stepsGrid); tabSheet.addTab(stepsLayout, ""); itemsGrid = new Grid(new ListDataProvider(itemList)); itemsGrid.setSelectionMode(Grid.SelectionMode.NONE); itemsGrid.setRowHeight(250); itemsGrid.setHeaderVisible(false); itemsGrid.setSizeFull(); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestItem) { QuestItem item = (QuestItem) source; if (item.getName() != null) { TextArea textEnRawArea = new TextArea("? "); textEnRawArea.setValue(item.getName().getTextEn()); textEnRawArea.setReadOnly(true); textEnRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnRawArea); if (item.getName().getTextRu() != null && !item.getName().getTextRu().equals(item.getName().getTextEn())) { TextArea textRuRawArea = new TextArea( " ? " + item.getName().getTranslator()); textRuRawArea.setValue(item.getName().getTextRu()); textRuRawArea.setReadOnly(true); textRuRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuRawArea);//, " " } } } return result; } }).setId("rawName"); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestItem) { QuestItem item = (QuestItem) source; if (item.getDescription() != null) { TextArea textEnRawArea = new TextArea("? "); textEnRawArea.setValue(item.getDescription().getTextEn()); textEnRawArea.setReadOnly(true); textEnRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textEnRawArea); if (item.getDescription().getTextRu() != null && !item.getDescription().getTextRu().equals(item.getDescription().getTextEn())) { TextArea textRuRawArea = new TextArea( " ?? " + item.getDescription().getTranslator()); textRuRawArea.setValue(item.getDescription().getTextRu()); textRuRawArea.setReadOnly(true); textRuRawArea.setWidth(100f, Unit.PERCENTAGE); result.addComponent(textRuRawArea);//, " " } } } return result; } }).setId("rawDescription"); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { Panel panel = new Panel(); panel.addStyleName(ValoTheme.PANEL_BORDERLESS); panel.setWidth(100f, Unit.PERCENTAGE); panel.setHeight(245f, Unit.PIXELS); final VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestItem) { Set<TranslatedText> list = new HashSet<>(); List<SysAccount> accounts = new ArrayList<>(); QuestItem item = (QuestItem) source; if (item.getName() != null) { String text = item.getName().getTextEn(); list.addAll(item.getName().getTranslatedTexts()); if (list != null) { for (TranslatedText t : list) { result.addComponent(new TranslationCell(t)); accounts.add(t.getAuthor()); } } if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && text != null && !text.isEmpty() && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) { final TranslatedText translatedText = new TranslatedText(); translatedText.setAuthor(SpringSecurityHelper.getSysAccount()); translatedText.setSpreadSheetsItemName(item.getName()); Button addTranslation = new Button(" ", FontAwesome.PLUS_SQUARE); addTranslation.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (translatedText.getSpreadSheetsItemName() != null) { translatedText.getSpreadSheetsItemName().getTranslatedTexts() .add(translatedText); } result.addComponent(new TranslationCell(translatedText)); event.getButton().setVisible(false); } }); result.addComponent(addTranslation); } } } panel.setContent(result); return panel; } }).setId("nameTranslation"); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { Panel panel = new Panel(); panel.addStyleName(ValoTheme.PANEL_BORDERLESS); panel.setWidth(100f, Unit.PERCENTAGE); panel.setHeight(245f, Unit.PIXELS); final VerticalLayout result = new VerticalLayout(); result.setSpacing(false); result.setMargin(false); if (source instanceof QuestItem) { Set<TranslatedText> list = new HashSet<>(); List<SysAccount> accounts = new ArrayList<>(); QuestItem item = (QuestItem) source; if (item.getDescription() != null) { String text = item.getDescription().getTextEn(); list.addAll(item.getDescription().getTranslatedTexts()); if (list != null) { for (TranslatedText t : list) { result.addComponent(new TranslationCell(t)); accounts.add(t.getAuthor()); } } if (!accounts.contains(SpringSecurityHelper.getSysAccount()) && text != null && !text.isEmpty() && SpringSecurityHelper.hasRole("ROLE_TRANSLATE")) { final TranslatedText translatedText = new TranslatedText(); translatedText.setAuthor(SpringSecurityHelper.getSysAccount()); translatedText.setSpreadSheetsItemDescription(item.getDescription()); Button addTranslation = new Button(" ", FontAwesome.PLUS_SQUARE); addTranslation.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (translatedText.getSpreadSheetsItemDescription() != null) { translatedText.getSpreadSheetsItemDescription().getTranslatedTexts() .add(translatedText); } result.addComponent(new TranslationCell(translatedText)); event.getButton().setVisible(false); } }); result.addComponent(addTranslation); } } } panel.setContent(result); return panel; } }).setId("descriptionTranslation"); itemsGrid.addComponentColumn(new ValueProvider() { @Override public Object apply(Object source) { VerticalLayout result = new VerticalLayout(); result.setMargin(new MarginInfo(true, false, false, false)); result.setSpacing(false); if (source instanceof QuestItem) { GSpreadSheetsItemName name = ((QuestItem) source).getName(); if (name.getIcon() != null) { Image image = new Image(null, new ExternalResource( "https://elderscrolls.net" + name.getIcon().replaceAll(".dds", ".png"))); result.addComponent(image); return result; } } return result; } }).setId("icon").setWidth(95); itemsGrid.setColumns("icon", "rawName", "nameTranslation", "rawDescription", "descriptionTranslation"); tabSheet.addTab(itemsGrid, ""); this.addComponent(tabSheet); this.setExpandRatio(tabSheet, 1f); GridScrollExtension stepsScrollExtension = new GridScrollExtension(stepsGrid); GridScrollExtension itemsScrollExtension = new GridScrollExtension(itemsGrid); new NoAutcompleteComboBoxExtension(locationTable); new NoAutcompleteComboBoxExtension(questTable); new NoAutcompleteComboBoxExtension(translatorBox); LoadFilters(); }
From source file:org.fossa.rolp.ui.dashboard.KlassenlehrerDashboard.java
License:Open Source License
public KlassenlehrerDashboard(RolpApplication app) { super(app);//from ww w .ja v a 2s . c o m this.app = app; setCaption(" - KlassenlehrerDashboard - "); setWidth("100%"); setHeight("100%"); buildButtonBatteries(); CustomLayout layout = new CustomLayout("./lehrerDashboards/klassenLehrerDashboardMain"); setContent(layout); CustomLayout headline = new CustomLayout("./lehrerDashboards/headline"); headline.addStyleName("headline"); Embedded logo = new Embedded(null, new ThemeResource(MAINPAGE_PANEL_ANMELDEN_LOGO_PATH)); logo.setType(Embedded.TYPE_IMAGE); logo.setWidth("100px"); logo.setHeight("96px"); headline.addComponent(logo, "logo"); headline.addComponent(headdataEditingPanel, "headdataEditingPanel"); Panel hints = new Panel(); hints.addStyleName("hints"); hinweistext = new Label(); hinweistext.setContentMode(Label.CONTENT_XHTML); hinweistext.setReadOnly(true); hinweistext.setHeight("250px"); hints.setHeight("250px"); hints.setScrollable(true); hints.addComponent(hinweistext); refreshHinweistext(); CustomLayout schuelerListe = new CustomLayout("./lehrerDashboards/liste"); schuelerListe.addStyleName("liste"); schuelerList = getSchuelerList(); schuelerList.setHeight("250px"); schuelerList.setStyleName("list"); schuelerListe.addComponent(schuelerList, "list"); schuelerListe.setHeight("260px"); layout.addComponent(schuelerListe, "liste"); layout.addComponent(headline, "headline"); layout.addComponent(horizontalButtonBattery, "horizontalButtonBattery"); layout.addComponent(verticalButtonBattery, "verticalButtonBattery"); layout.addComponent(hints, "hints"); windowCloseButton.setWidth("100%"); layout.addComponent(windowCloseButton, "windowCloseButton"); // app.getAnimator().animate(horizontalButtonBattery, AnimType.ROLL_DOWN_OPEN_POP).setDuration(500).setDelay(500); }
From source file:org.ikasan.dashboard.ui.administration.panel.PolicyManagementPanel.java
License:BSD License
@SuppressWarnings({ "serial" }) protected void init() { this.setWidth("100%"); this.setHeight("100%"); this.createAssociatedRolesPanel(); this.createPolicyDropPanel(); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);//w w w .ja v a 2 s . co m layout.setSpacing(true); layout.setWidth("100%"); Panel policyAdministrationPanel = new Panel(); policyAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); policyAdministrationPanel.setHeight("100%"); policyAdministrationPanel.setWidth("100%"); GridLayout gridLayout = new GridLayout(2, 6); gridLayout.setSizeFull(); Label roleManagementLabel = new Label("Policy 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 Policy Name field to find a policy."); 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); GridLayout formLayout = new GridLayout(2, 4); formLayout.setWidth("100%"); formLayout.setSpacing(true); formLayout.setColumnExpandRatio(0, 1); formLayout.setColumnExpandRatio(1, 5); Label policyNameLabel = new Label("Policy Name:"); policyNameLabel.setSizeUndefined(); final DragAndDropWrapper policyNameFieldWrap = initPolicyNameField(); formLayout.addComponent(policyNameLabel, 0, 0); formLayout.setComponentAlignment(policyNameLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(policyNameFieldWrap, 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(this.descriptionField, 1, 1); this.linkTypeLabel.setSizeUndefined(); formLayout.addComponent(this.linkTypeLabel, 0, 2); formLayout.setComponentAlignment(this.linkTypeLabel, Alignment.MIDDLE_RIGHT); this.linkType.setWidth("70%"); formLayout.addComponent(this.linkType, 1, 2); this.linkTypeLabel.setVisible(false); this.linkType.setVisible(false); this.linkedEntityLabel.setSizeUndefined(); this.linkedEntity = new TextArea(); this.linkedEntity.setWidth("70%"); this.linkedEntity.setHeight("60px"); formLayout.addComponent(this.linkedEntityLabel, 0, 3); formLayout.setComponentAlignment(this.linkedEntityLabel, Alignment.MIDDLE_RIGHT); formLayout.addComponent(linkedEntity, 1, 3); this.linkedEntityLabel.setVisible(false); this.linkedEntity.setVisible(false); gridLayout.addComponent(formLayout, 0, 3, 1, 3); Label roleTableHintLabel = new Label(); roleTableHintLabel.setCaptionAsHtml(true); roleTableHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " The Roles table below displays the roles that are assigned the current policy."); roleTableHintLabel.addStyleName(ValoTheme.LABEL_TINY); roleTableHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); gridLayout.addComponent(roleTableHintLabel, 0, 4, 1, 4); gridLayout.addComponent(this.roleTable, 0, 5, 1, 5); policyAdministrationPanel.setContent(gridLayout); layout.addComponent(policyAdministrationPanel); HorizontalLayout roleMemberPanelLayout = new HorizontalLayout(); roleMemberPanelLayout.setMargin(true); roleMemberPanelLayout.addComponent(this.policyDropPanel); 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.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 a va 2s.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();/* ww w .jav a2 s. co m*/ 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); 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.UserDirectoriesPanel.java
License:BSD License
protected void init() { Label userDirectories = new Label("User Directories"); userDirectories.setStyleName(ValoTheme.LABEL_HUGE); Label parapraphOne = new Label(); parapraphOne.setCaptionAsHtml(true); parapraphOne.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " The table below shows the user directories currently configured for Ikasan."); parapraphOne.addStyleName(ValoTheme.LABEL_TINY); parapraphOne.addStyleName(ValoTheme.LABEL_LIGHT); Label parapraphTwo = new Label(); parapraphTwo.setCaptionAsHtml(true); parapraphTwo.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " The order of the directory is the order in which it will be searched for users and groups." + " It is recommended that each user exists in a single directory."); parapraphTwo.addStyleName(ValoTheme.LABEL_TINY); parapraphTwo.addStyleName(ValoTheme.LABEL_LIGHT); this.mainLayout.setWidth("100%"); this.mainLayout.setSpacing(true); this.mainLayout.addComponent(userDirectories); this.mainLayout.addComponent(parapraphOne); this.mainLayout.addComponent(parapraphTwo); Button newDirectoryButton = new Button("Add Directory"); newDirectoryButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final UserDirectoryManagementPanel authMethodPanel = new UserDirectoryManagementPanel( new AuthenticationMethod(), securityService, authenticationProviderFactory, ldapService); Window window = new Window("Configure User Directory"); window.setModal(true);// w ww. j a va2 s.c o m window.setHeight("90%"); window.setWidth("90%"); window.setContent(authMethodPanel); UI.getCurrent().addWindow(window); window.addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { populateAll(); } }); } }); this.mainLayout.addComponent(newDirectoryButton); this.setWidth("100%"); this.setHeight("100%"); this.directoryTable = new Table(); this.directoryTable.setWidth("100%"); this.directoryTable.setHeight("600px"); this.directoryTable.setCellStyleGenerator(new IkasanCellStyleGenerator()); this.directoryTable.addContainerProperty("Directory Name", String.class, null); this.directoryTable.addContainerProperty("Type", String.class, null); this.directoryTable.addContainerProperty("Order", Layout.class, null); this.directoryTable.addContainerProperty("Operations", Layout.class, null); this.directoryTable.setColumnExpandRatio("Directory Name", 25); this.directoryTable.setColumnExpandRatio("Type", 25); this.directoryTable.setColumnAlignment("Order", Align.CENTER); this.directoryTable.setColumnExpandRatio("Order", 10); this.directoryTable.setColumnAlignment("Operations", Align.CENTER); this.directoryTable.setColumnWidth("Operations", 300); this.mainLayout.addComponent(this.directoryTable); this.mainLayout.setMargin(true); Panel wrapperPanel = new Panel(); wrapperPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); wrapperPanel.setSizeFull(); wrapperPanel.setContent(this.mainLayout); HorizontalLayout wrapperLayout = new HorizontalLayout(); wrapperLayout.setSizeFull(); wrapperLayout.setMargin(true); wrapperLayout.addComponent(wrapperPanel); this.setContent(wrapperLayout); }
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();//from www . j av a2 s . c o m Panel securityAdministrationPanel = new Panel(); securityAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); securityAdministrationPanel.setHeight("100%"); securityAdministrationPanel.setWidth("100%"); GridLayout gridLayout = new GridLayout(2, 6); gridLayout.setMargin(true); 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); }
From source file:org.ikasan.dashboard.ui.framework.panel.ProfilePanel.java
License:BSD License
@SuppressWarnings("deprecation") protected void init() { this.setWidth("100%"); this.setHeight("100%"); VerticalLayout layout = new VerticalLayout(); layout.setSizeFull();/*from w w w. ja v a 2 s. com*/ Panel securityAdministrationPanel = new Panel(); securityAdministrationPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); securityAdministrationPanel.setHeight("100%"); securityAdministrationPanel.setWidth("100%"); GridLayout gridLayout = new GridLayout(2, 6); gridLayout.setMargin(true); gridLayout.setSpacing(true); gridLayout.setSizeFull(); Label mappingConfigurationLabel = new Label("User Profile"); mappingConfigurationLabel.setStyleName(ValoTheme.LABEL_HUGE); gridLayout.addComponent(mappingConfigurationLabel, 0, 0, 1, 0); Label usernameLabel = new Label("Username:"); usernameField.setWidth("65%"); firstName = new TextField(); firstName.setWidth("65%"); firstName.setNullRepresentation(""); surname = new TextField(); surname.setWidth("65%"); surname.setNullRepresentation(""); department.setWidth("65%"); department.setNullRepresentation(""); email.setWidth("65%"); email.setNullRepresentation(""); roleTable.addContainerProperty("Role", String.class, null); roleTable.addStyleName("ikasan"); roleTable.addStyleName(ValoTheme.TABLE_SMALL); roleTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); roleTable.setHeight("520px"); roleTable.setWidth("250px"); 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(usernameField, 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 Ikasan roles that the user has."); 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."); rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_TINY); rolesAndGroupsHintLabel2.addStyleName(ValoTheme.LABEL_LIGHT); rolesAndGroupsHintLabel2.setWidth(300, Unit.PIXELS); gridLayout.addComponent(rolesAndGroupsHintLabel2, 0, 4, 1, 4); dashboadActivityTable.addContainerProperty("Action", String.class, null); dashboadActivityTable.addContainerProperty("Date/Time", String.class, null); dashboadActivityTable.addStyleName("ikasan"); dashboadActivityTable.addStyleName(ValoTheme.TABLE_SMALL); dashboadActivityTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); dashboadActivityTable.setHeight("350px"); dashboadActivityTable.setWidth("300px"); this.permissionChangeTable.addContainerProperty("Action", String.class, null); this.permissionChangeTable.addContainerProperty("Date/Time", String.class, null); this.permissionChangeTable.addStyleName("ikasan"); this.permissionChangeTable.addStyleName(ValoTheme.TABLE_SMALL); this.permissionChangeTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.permissionChangeTable.setHeight("350px"); this.permissionChangeTable.setWidth("300px"); gridLayout.addComponent(roleTable, 0, 5); this.associatedPrincipalsTable.addContainerProperty("Groups", String.class, null); this.associatedPrincipalsTable.addItemClickListener(this.associatedPrincipalItemClickListener); this.associatedPrincipalsTable.addStyleName("ikasan"); this.associatedPrincipalsTable.addStyleName(ValoTheme.TABLE_SMALL); this.associatedPrincipalsTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); associatedPrincipalsTable.setHeight("520px"); associatedPrincipalsTable.setWidth("400px"); gridLayout.addComponent(this.associatedPrincipalsTable, 1, 5); 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 dashboardActivityLabel = new Label("Dashboard Activity"); dashboardActivityLabel.setStyleName(ValoTheme.LABEL_HUGE); roleMemberLayout.addComponent(dashboardActivityLabel); roleMemberLayout.addComponent(this.dashboadActivityTable); Label permissionChangeLabel = new Label("User Security Changes"); permissionChangeLabel.setStyleName(ValoTheme.LABEL_HUGE); roleMemberLayout.addComponent(permissionChangeLabel); roleMemberLayout.addComponent(this.permissionChangeTable); 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.mappingconfiguration.panel.MappingConfigurationPanel.java
License:BSD License
/** * Helper method to initialise this object. *//*from w ww . j a v a2s. c o m*/ @SuppressWarnings("serial") protected void init() { layout = new GridLayout(5, 6); layout.setSpacing(true); layout.setMargin(true); layout.setWidth("100%"); this.addStyleName(ValoTheme.PANEL_BORDERLESS); paramQueriesLayout = new VerticalLayout(); toolBarLayout = new HorizontalLayout(); toolBarLayout.setWidth("100%"); Button linkButton = new Button(); linkButton.setIcon(VaadinIcons.REPLY_ALL); linkButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); linkButton.setDescription("Return to search results"); linkButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); linkButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Navigator navigator = new Navigator(UI.getCurrent(), menuLayout.getContentContainer()); for (IkasanUIView view : topLevelNavigator.getIkasanViews()) { navigator.addView(view.getPath(), view.getView()); } saveRequiredMonitor.manageSaveRequired("mappingView"); navigator = new Navigator(UI.getCurrent(), mappingNavigator.getContainer()); for (IkasanUIView view : mappingNavigator.getIkasanViews()) { navigator.addView(view.getPath(), view.getView()); } } }); toolBarLayout.addComponent(linkButton); toolBarLayout.setExpandRatio(linkButton, 0.865f); this.editButton.setIcon(VaadinIcons.EDIT); this.editButton.setDescription("Edit the mapping configuration"); this.editButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.editButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.editButton.setVisible(false); this.editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { setEditable(true); mappingConfigurationFunctionalGroup.editButtonPressed(); } }); toolBarLayout.addComponent(this.editButton); toolBarLayout.setExpandRatio(this.editButton, 0.045f); this.saveButton.setIcon(VaadinIcons.HARDDRIVE); this.saveButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.saveButton.setDescription("Save the mapping configuration"); this.saveButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.saveButton.setVisible(false); this.saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { logger.info("Save button clicked!!"); save(); setEditable(false); Notification.show("Changes Saved!", "", Notification.Type.HUMANIZED_MESSAGE); mappingConfigurationFunctionalGroup.saveOrCancelButtonPressed(); } catch (InvalidValueException e) { // We can ignore this one as we have already dealt with the // validation messages using the validation framework. } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Cauget exception trying to save a Mapping Configuration!", sw.toString(), Notification.Type.ERROR_MESSAGE); } } }); toolBarLayout.addComponent(this.saveButton); toolBarLayout.setExpandRatio(this.saveButton, 0.045f); this.cancelButton.setIcon(VaadinIcons.CLOSE_CIRCLE); this.cancelButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.cancelButton.setDescription("Cancel the current edit"); this.cancelButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); this.cancelButton.setVisible(false); this.cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { setEditable(false); mappingConfigurationFunctionalGroup.saveOrCancelButtonPressed(); Navigator navigator = new Navigator(UI.getCurrent(), menuLayout.getContentContainer()); for (IkasanUIView view : topLevelNavigator.getIkasanViews()) { navigator.addView(view.getPath(), view.getView()); } saveRequiredMonitor.manageSaveRequired("mappingView"); navigator = new Navigator(UI.getCurrent(), mappingNavigator.getContainer()); for (IkasanUIView view : mappingNavigator.getIkasanViews()) { navigator.addView(view.getPath(), view.getView()); } } }); toolBarLayout.addComponent(this.cancelButton); toolBarLayout.setExpandRatio(this.cancelButton, 0.045f); FileDownloader fd = new FileDownloader(this.getMappingConfigurationExportStream()); fd.extend(exportMappingConfigurationButton); this.exportMappingConfigurationButton.setIcon(VaadinIcons.DOWNLOAD_ALT); this.exportMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.exportMappingConfigurationButton.setDescription("Export the current mapping configuration"); this.exportMappingConfigurationButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); toolBarLayout.addComponent(this.exportMappingConfigurationButton); toolBarLayout.setExpandRatio(this.exportMappingConfigurationButton, 0.045f); final GridLayout contentLayout = new GridLayout(1, 2); contentLayout.setWidth("100%"); contentLayout.addComponent(toolBarLayout); contentLayout.addComponent(createMappingConfigurationForm()); VerticalSplitPanel vpanel = new VerticalSplitPanel(contentLayout, createTableLayout(false)); vpanel.setStyleName(ValoTheme.SPLITPANEL_LARGE); paramQueriesLayout.setSpacing(true); Label configValueLabels = new Label("Source Configuration Value Queries:"); layout.addComponent(configValueLabels, 2, 2, 3, 2); Panel queryParamsPanel = new Panel(); queryParamsPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); queryParamsPanel.setHeight(100, Unit.PIXELS); queryParamsPanel.setWidth(100, Unit.PERCENTAGE); queryParamsPanel.setContent(paramQueriesLayout); this.layout.addComponent(queryParamsPanel, 2, 3, 3, 5); vpanel.setSplitPosition(325, Unit.PIXELS); this.setContent(vpanel); this.setSizeFull(); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.NewMappingConfigurationPanel.java
License:BSD License
/** * Helper method to initialise this object. *///w ww .ja va 2s . c o m @SuppressWarnings("serial") protected void init() { layout = new GridLayout(5, 6); layout.setSpacing(true); layout.setMargin(true); layout.setWidth("100%"); this.addStyleName(ValoTheme.PANEL_BORDERLESS); this.parameterQueryTextFields = new ArrayList<TextField>(); this.typeComboBox.setReadOnly(false); this.clientComboBox.setReadOnly(false); this.sourceContextComboBox.setReadOnly(false); this.targetContextComboBox.setReadOnly(false); super.clientComboBox.unselect(super.clientComboBox.getValue()); super.sourceContextComboBox.unselect(super.sourceContextComboBox.getValue()); super.targetContextComboBox.unselect(super.targetContextComboBox.getValue()); super.typeComboBox.unselect(super.typeComboBox.getValue()); super.mappingConfigurationFunctionalGroup.editButtonPressed(); super.mappingConfiguration = new MappingConfiguration(); this.mappingConfigurationConfigurationValuesTable.populateTable(mappingConfiguration); HorizontalLayout toolBarLayout = new HorizontalLayout(); toolBarLayout.setWidth("100%"); Label spacerLabel = new Label(""); toolBarLayout.addComponent(spacerLabel); toolBarLayout.setExpandRatio(spacerLabel, 0.865f); this.editButton.setIcon(VaadinIcons.EDIT); this.editButton.setDescription("Edit the mapping configuration"); this.editButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.editButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); toolBarLayout.addComponent(editButton); toolBarLayout.setExpandRatio(editButton, 0.045f); this.saveButton.setIcon(VaadinIcons.HARDDRIVE); this.saveButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.saveButton.setDescription("Save the mapping configuration"); this.saveButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); toolBarLayout.addComponent(saveButton); toolBarLayout.setExpandRatio(saveButton, 0.045f); this.cancelButton.setIcon(VaadinIcons.CLOSE_CIRCLE); this.cancelButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); this.cancelButton.setDescription("Cancel the current edit"); this.cancelButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); toolBarLayout.addComponent(this.cancelButton); toolBarLayout.setExpandRatio(this.cancelButton, 0.045f); final VerticalLayout contentLayout = new VerticalLayout(); contentLayout.addComponent(toolBarLayout); contentLayout.addComponent(createMappingConfigurationForm()); VerticalSplitPanel vpanel = new VerticalSplitPanel(contentLayout, createTableLayout(false)); vpanel.setStyleName(ValoTheme.SPLITPANEL_LARGE); Button addParametersButton = new Button(); addParametersButton.setIcon(VaadinIcons.FORM); addParametersButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); addParametersButton.setDescription( "Add new key location queries. The number of fields created corresponds to the number of query parameters."); addParametersButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); addParametersButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { addParamQueryFields(); } }); paramQueriesLayout.removeAllComponents(); // paramQueriesLayout.addComponent(addParametersButton); paramQueriesLayout.setSpacing(true); Label configValueLabels = new Label("Source Configuration Value Queries:"); layout.addComponent(configValueLabels, 2, 2); layout.addComponent(addParametersButton, 3, 2); Panel queryParamsPanel = new Panel(); queryParamsPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); queryParamsPanel.setHeight(140, Unit.PIXELS); queryParamsPanel.setWidth(100, Unit.PERCENTAGE); queryParamsPanel.setContent(paramQueriesLayout); this.layout.addComponent(queryParamsPanel, 2, 3, 3, 5); vpanel.setSplitPosition(325, Unit.PIXELS); this.setContent(vpanel); this.setSizeFull(); }