List of usage examples for com.vaadin.ui TextArea setValue
@Override public void setValue(String value)
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);/*from w ww.ja va 2 s . c o m*/ 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.ikasan.dashboard.ui.administration.panel.UserDirectoriesPanel.java
License:BSD License
protected void populateDirectoryTable(final AuthenticationMethod authenticationMethod) { Button test = new Button("Test"); test.setStyleName(BaseTheme.BUTTON_LINK); test.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { authenticationProviderFactory.testAuthenticationConnection(authenticationMethod); } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw);/*ww w. j ava2 s . c o m*/ Notification.show("Error occurred while testing connection!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error occurred while testing connection!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } Notification.show("Connection Successful!"); } }); final Button enableDisableButton = new Button(); if (authenticationMethod.isEnabled()) { enableDisableButton.setCaption("Disable"); } else { enableDisableButton.setCaption("Enable"); } enableDisableButton.setStyleName(BaseTheme.BUTTON_LINK); enableDisableButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { if (authenticationMethod.isEnabled()) { authenticationMethod.setEnabled(false); } else { authenticationMethod.setEnabled(true); } securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); populateAll(); } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error trying to enable/disable the authentication method!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } if (authenticationMethod.isEnabled()) { enableDisableButton.setCaption("Disable"); Notification.show("Enabled!"); } else { enableDisableButton.setCaption("Enable"); Notification.show("Disabled!"); } } }); Button delete = new Button("Delete"); delete.setStyleName(BaseTheme.BUTTON_LINK); delete.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { securityService.deleteAuthenticationMethod(authenticationMethod); List<AuthenticationMethod> authenticationMethods = securityService.getAuthenticationMethods(); directoryTable.removeAllItems(); long order = 1; for (final AuthenticationMethod authenticationMethod : authenticationMethods) { authenticationMethod.setOrder(order++); securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); } populateAll(); } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error trying to delete the authentication method!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } Notification.show("Deleted!"); } }); Button edit = new Button("Edit"); edit.setStyleName(BaseTheme.BUTTON_LINK); edit.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { UserDirectoryManagementPanel authMethodPanel = new UserDirectoryManagementPanel( authenticationMethod, securityService, authenticationProviderFactory, ldapService); Window window = new Window("Configure User Directory"); window.setModal(true); window.setHeight("90%"); window.setWidth("90%"); window.setContent(authMethodPanel); UI.getCurrent().addWindow(window); } }); Button synchronise = new Button("Synchronise"); synchronise.setStyleName(BaseTheme.BUTTON_LINK); synchronise.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { ldapService.synchronize(authenticationMethod); authenticationMethod.setLastSynchronised(new Date()); securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); populateAll(); } catch (UnexpectedRollbackException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); logger.error("Most specific cause: " + e.getMostSpecificCause()); e.getMostSpecificCause().printStackTrace(); logger.error("Most specific cause: " + e.getRootCause()); e.getRootCause().printStackTrace(); Notification.show("Error occurred while synchronizing!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error occurred while synchronizing!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error occurred while synchronizing!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } Notification.show("Synchronized!"); } }); GridLayout operationsLayout = new GridLayout(9, 2); operationsLayout.setWidth("250px"); operationsLayout.addComponent(enableDisableButton, 0, 0); operationsLayout.addComponent(new Label(" "), 1, 0); operationsLayout.addComponent(edit, 2, 0); operationsLayout.addComponent(new Label(" "), 3, 0); operationsLayout.addComponent(delete, 4, 0); operationsLayout.addComponent(new Label(" "), 5, 0); operationsLayout.addComponent(test, 6, 0); operationsLayout.addComponent(new Label(" "), 7, 0); operationsLayout.addComponent(synchronise, 8, 0); TextArea synchronisedTextArea = new TextArea(); synchronisedTextArea.setRows(3); synchronisedTextArea.setWordwrap(true); if (authenticationMethod.getLastSynchronised() != null) { synchronisedTextArea.setValue( "This directory was last synchronised at " + authenticationMethod.getLastSynchronised()); } else { synchronisedTextArea.setValue("This directory has not been synchronised"); } synchronisedTextArea.setSizeFull(); synchronisedTextArea.setReadOnly(true); operationsLayout.addComponent(synchronisedTextArea, 0, 1, 8, 1); HorizontalLayout orderLayout = new HorizontalLayout(); orderLayout.setWidth("50%"); if (authenticationMethod.getOrder() != 1) { Button upArrow = new Button(VaadinIcons.ARROW_UP); upArrow.addStyleName(ValoTheme.BUTTON_ICON_ONLY); upArrow.addStyleName(ValoTheme.BUTTON_BORDERLESS); upArrow.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { if (authenticationMethod.getOrder() != 1) { AuthenticationMethod upAuthMethod = securityService .getAuthenticationMethodByOrder(authenticationMethod.getOrder() - 1); upAuthMethod.setOrder(authenticationMethod.getOrder()); authenticationMethod.setOrder(authenticationMethod.getOrder() - 1); securityService.saveOrUpdateAuthenticationMethod(upAuthMethod); securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); populateAll(); } } }); orderLayout.addComponent(upArrow); } long numberOfAuthMethods = securityService.getNumberOfAuthenticationMethods(); if (authenticationMethod.getOrder() != numberOfAuthMethods) { Button downArrow = new Button(VaadinIcons.ARROW_DOWN); downArrow.addStyleName(ValoTheme.BUTTON_ICON_ONLY); downArrow.addStyleName(ValoTheme.BUTTON_BORDERLESS); downArrow.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { long numberOfAuthMethods = securityService.getNumberOfAuthenticationMethods(); if (authenticationMethod.getOrder() != numberOfAuthMethods) { AuthenticationMethod downAuthMethod = securityService .getAuthenticationMethodByOrder(authenticationMethod.getOrder() + 1); downAuthMethod.setOrder(authenticationMethod.getOrder()); authenticationMethod.setOrder(authenticationMethod.getOrder() + 1); securityService.saveOrUpdateAuthenticationMethod(downAuthMethod); securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); populateAll(); } } }); orderLayout.addComponent(downArrow); } this.directoryTable.addItem(new Object[] { authenticationMethod.getName(), "Microsoft Active Directory", orderLayout, operationsLayout }, authenticationMethod); }
From source file:org.ikasan.dashboard.ui.topology.component.BusinessStreamTab.java
License:BSD License
public Layout createBusinessStreamLayout() { this.businessStreamTable = new Table(); this.businessStreamTable.addContainerProperty("Server Name", String.class, null); this.businessStreamTable.addContainerProperty("Module Name", String.class, null); this.businessStreamTable.addContainerProperty("Flow Name", String.class, null); this.businessStreamTable.addContainerProperty("", Button.class, null); this.businessStreamTable.setWidth("100%"); this.businessStreamTable.setHeight(600, Unit.PIXELS); this.businessStreamTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.businessStreamTable.setDragMode(TableDragMode.ROW); this.businessStreamTable.setDropHandler(new DropHandler() { @Override/*from w w w . j av a 2 s . co m*/ public void drop(final DragAndDropEvent dropEvent) { final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication .hasGrantedAuthority(SecurityConstants.MODIFY_BUSINESS_STREAM_AUTHORITY))) { Notification.show("You do not have the privilege to modify a business stream."); return; } final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Flow) { final Flow flow = (Flow) t.getItemId(); final BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue(); BusinessStreamFlowKey key = new BusinessStreamFlowKey(); key.setBusinessStreamId(businessStream.getId()); key.setFlowId(flow.getId()); final BusinessStreamFlow businessStreamFlow = new BusinessStreamFlow(key); businessStreamFlow.setFlow(flow); businessStreamFlow.setOrder(businessStreamTable.getItemIds().size()); if (!businessStream.getFlows().contains(businessStreamFlow)) { businessStream.getFlows().add(businessStreamFlow); topologyService.saveBusinessStream(businessStream); Button deleteButton = new Button(); Resource deleteIcon = VaadinIcons.TRASH; deleteButton.setIcon(deleteIcon); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Delete the flow from the business stream."); deleteButton.setData(businessStreamFlow); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { businessStream.getFlows().remove(businessStreamFlow); topologyService.deleteBusinessStreamFlow(businessStreamFlow); topologyService.saveBusinessStream(businessStream); businessStreamTable.removeItem(businessStreamFlow.getFlow()); } }); businessStreamTable .addItem( new Object[] { flow.getModule().getServer().getName(), flow.getModule().getName(), flow.getName(), deleteButton }, businessStreamFlow); } } else if (t.getItemId() instanceof Module) { final Module sourceContainer = (Module) t.getItemId(); for (Flow flow : sourceContainer.getFlows()) { final BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue(); BusinessStreamFlowKey key = new BusinessStreamFlowKey(); key.setBusinessStreamId(businessStream.getId()); key.setFlowId(flow.getId()); final BusinessStreamFlow businessStreamFlow = new BusinessStreamFlow(key); businessStreamFlow.setFlow(flow); businessStreamFlow.setOrder(businessStreamTable.getItemIds().size()); if (!businessStream.getFlows().contains(businessStreamFlow)) { businessStream.getFlows().add(businessStreamFlow); topologyService.saveBusinessStream(businessStream); Button deleteButton = new Button(); Resource deleteIcon = VaadinIcons.TRASH; deleteButton.setIcon(deleteIcon); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Delete the flow from the business stream."); deleteButton.setData(businessStreamFlow); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { businessStream.getFlows().remove(businessStreamFlow); topologyService.deleteBusinessStreamFlow(businessStreamFlow); topologyService.saveBusinessStream(businessStream); businessStreamTable.removeItem(businessStreamFlow.getFlow()); } }); businessStreamTable.addItem( new Object[] { flow.getModule().getServer().getName(), flow.getModule().getName(), flow.getName(), deleteButton }, businessStreamFlow); } } } else { Notification.show("Only modules or flows can be dragged to this table."); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); GridLayout layout = new GridLayout(1, 6); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); Label tableDropHintLabel = new Label(); tableDropHintLabel.setCaptionAsHtml(true); tableDropHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drag modules or flows from the topology tree to the table below to build a business stream."); tableDropHintLabel.addStyleName(ValoTheme.LABEL_TINY); tableDropHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(tableDropHintLabel); GridLayout controlsLayout = new GridLayout(3, 3); controlsLayout.setColumnExpandRatio(0, .05f); controlsLayout.setColumnExpandRatio(1, .65f); controlsLayout.setColumnExpandRatio(2, .3f); controlsLayout.setWidth("100%"); controlsLayout.setSpacing(true); Label newBusinessStreamLabel = new Label("New Business Stream:"); newBusinessStreamLabel.setSizeUndefined(); controlsLayout.addComponent(newBusinessStreamLabel, 0, 0); controlsLayout.setComponentAlignment(newBusinessStreamLabel, Alignment.MIDDLE_RIGHT); Button newButton = new Button(); newButton.setIcon(VaadinIcons.PLUS); newButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); newButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); newButton.setDescription("Create a new business stream."); newButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final NewBusinessStreamWindow newBusinessStreamWindow = new NewBusinessStreamWindow(); UI.getCurrent().addWindow(newBusinessStreamWindow); newBusinessStreamWindow.addCloseListener(new Window.CloseListener() { // inline close-listener public void windowClose(CloseEvent e) { topologyService.saveBusinessStream(newBusinessStreamWindow.getBusinessStream()); businessStreamCombo.addItem(newBusinessStreamWindow.getBusinessStream()); businessStreamCombo.setItemCaption(newBusinessStreamWindow.getBusinessStream(), newBusinessStreamWindow.getBusinessStream().getName()); businessStreamCombo.select(newBusinessStreamWindow.getBusinessStream()); businessStreamTable.removeAllItems(); } }); } }); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication.hasGrantedAuthority(SecurityConstants.CREATE_BUSINESS_STREAM_AUTHORITY))) { newButton.setVisible(false); } controlsLayout.addComponent(newButton, 1, 0); Label businessStreamLabel = new Label("Business Stream:"); businessStreamLabel.setSizeUndefined(); final TextArea descriptionTextArea = new TextArea(); descriptionTextArea.setReadOnly(true); this.businessStreamCombo.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { if (event.getProperty() != null && event.getProperty().getValue() != null) { final BusinessStream businessStream = (BusinessStream) event.getProperty().getValue(); descriptionTextArea.setReadOnly(false); descriptionTextArea.setValue(businessStream.getDescription()); descriptionTextArea.setReadOnly(true); businessStreamTable.removeAllItems(); for (final BusinessStreamFlow businessStreamFlow : businessStream.getFlows()) { logger.info("Adding flow: " + businessStreamFlow); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Delete the flow from the business stream."); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { businessStream.getFlows().remove(businessStreamFlow); topologyService.deleteBusinessStreamFlow(businessStreamFlow); topologyService.saveBusinessStream(businessStream); businessStreamTable.removeItem(businessStreamFlow.getFlow()); } }); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService .getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication.hasGrantedAuthority( SecurityConstants.MODIFY_BUSINESS_STREAM_AUTHORITY))) { deleteButton.setVisible(false); } businessStreamTable.addItem( new Object[] { businessStreamFlow.getFlow().getModule().getServer().getName(), businessStreamFlow.getFlow().getName(), businessStreamFlow.getFlow().getName(), deleteButton }, businessStreamFlow); } } } }); businessStreamCombo.setWidth("100%"); controlsLayout.addComponent(businessStreamLabel, 0, 1); controlsLayout.setComponentAlignment(businessStreamLabel, Alignment.MIDDLE_RIGHT); controlsLayout.addComponent(businessStreamCombo, 1, 1); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Delete the selected business stream."); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Collection<BusinessStreamFlow> businessStreamFlows = (Collection<BusinessStreamFlow>) businessStreamTable .getItemIds(); for (BusinessStreamFlow businessStreamFlow : businessStreamFlows) { topologyService.deleteBusinessStreamFlow(businessStreamFlow); } BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue(); topologyService.deleteBusinessStream(businessStream); businessStreamTable.removeAllItems(); List<BusinessStream> businessStreams = topologyService.getAllBusinessStreams(); businessStreamCombo.removeItem(businessStream); descriptionTextArea.setValue(""); } }); if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication.hasGrantedAuthority(SecurityConstants.DELETE_BUSINESS_STREAM_AUTHORITY))) { deleteButton.setVisible(false); } controlsLayout.addComponent(deleteButton, 2, 1); Label descriptionLabel = new Label("Description:"); descriptionLabel.setSizeUndefined(); descriptionTextArea.setRows(4); descriptionTextArea.setWidth("100%"); controlsLayout.addComponent(descriptionLabel, 0, 2); controlsLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT); controlsLayout.addComponent(descriptionTextArea, 1, 2); layout.addComponent(controlsLayout); layout.addComponent(this.businessStreamTable); return layout; }
From source file:org.ikasan.dashboard.ui.topology.window.CategorisedErrorOccurrenceViewWindow.java
License:BSD License
protected Panel createErrorOccurrenceDetailsPanel() { Panel errorOccurrenceDetailsPanel = new Panel(); GridLayout layout = new GridLayout(4, 7); layout.setWidth("100%"); layout.setSpacing(true);/*from ww w . j a v a2 s .co m*/ layout.setColumnExpandRatio(0, .10f); layout.setColumnExpandRatio(1, .30f); layout.setColumnExpandRatio(2, .05f); layout.setColumnExpandRatio(3, .30f); Label errorOccurrenceDetailsLabel = new Label(" Categorised Error Occurence Details", ContentMode.HTML); Label errorCategoryLabel = new Label(); if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.BLOCKER)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.BAN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.BAN.getHtml() + " Blocker", ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.CRITICAL)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.EXCLAMATION.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.EXCLAMATION.getHtml() + " Critical", ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.MAJOR)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.ARROW_UP.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.ARROW_UP.getHtml() + " Major", ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.TRIVIAL)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.ARROW_DOWN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.ARROW_DOWN.getHtml() + " Trivial", ContentMode.HTML); } errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(errorOccurrenceDetailsLabel, 0, 0, 3, 0); Label label = new Label("Module Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf1 = new TextField(); tf1.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getModuleName()); tf1.setReadOnly(true); tf1.setWidth("80%"); layout.addComponent(tf1, 1, 1); label = new Label("Flow Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf2 = new TextField(); tf2.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowName()); tf2.setReadOnly(true); tf2.setWidth("80%"); layout.addComponent(tf2, 1, 2); label = new Label("Component Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf3 = new TextField(); tf3.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowElementName()); tf3.setReadOnly(true); tf3.setWidth("80%"); layout.addComponent(tf3, 1, 3); label = new Label("Date/Time:"); label.setSizeUndefined(); layout.addComponent(label, 0, 4); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf4 = new TextField(); tf4.setValue(new Date(this.categorisedErrorOccurrence.getErrorOccurrence().getTimestamp()).toString()); tf4.setReadOnly(true); tf4.setWidth("80%"); layout.addComponent(tf4, 1, 4); GridLayout wrapperLayout = new GridLayout(1, 4); wrapperLayout.setMargin(true); wrapperLayout.setWidth("100%"); Label errorMessageLabel = new Label("Error Message:"); errorMessageLabel.setSizeUndefined(); layout.addComponent(errorMessageLabel, 0, 5); layout.setComponentAlignment(errorMessageLabel, Alignment.TOP_RIGHT); final TextArea errorMessageTextArea = new TextArea(); errorMessageTextArea.setWidth("650px"); errorMessageTextArea.setRows(6); errorMessageTextArea .setValue(this.categorisedErrorOccurrence.getErrorCategorisation().getErrorDescription()); layout.addComponent(errorMessageTextArea, 1, 5, 3, 5); AceEditor editor = new AceEditor(); editor.setCaption("Error Details"); editor.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getErrorDetail()); editor.setReadOnly(true); editor.setMode(AceMode.xml); editor.setTheme(AceTheme.eclipse); editor.setHeight(470, Unit.PIXELS); editor.setWidth("100%"); label = new Label("Error Category:"); label.setSizeUndefined(); layout.addComponent(label, 2, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); layout.addComponent(errorCategoryLabel, 3, 1); layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_LEFT); label = new Label("System Action:"); label.setSizeUndefined(); layout.addComponent(label, 2, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField systemAction = new TextField(); systemAction.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getAction()); systemAction.setReadOnly(true); systemAction.setWidth("80%"); layout.addComponent(systemAction, 3, 2); label = new Label("User Action:"); label.setSizeUndefined(); layout.addComponent(label, 2, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField userAction = new TextField(); userAction.setValue(""); userAction.setReadOnly(true); userAction.setWidth("80%"); layout.addComponent(userAction, 3, 3); label = new Label("User Action By:"); label.setSizeUndefined(); layout.addComponent(label, 2, 4); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); Label userActionBy = new Label(); userActionBy.setValue(""); userActionBy.setReadOnly(true); userActionBy.setWidth("80%"); layout.addComponent(userActionBy, 3, 4); AceEditor eventEditor = new AceEditor(); eventEditor.setCaption("Event Payload"); if (this.categorisedErrorOccurrence.getErrorOccurrence().getEvent() != null) { eventEditor .setValue(new String((byte[]) this.categorisedErrorOccurrence.getErrorOccurrence().getEvent())); } eventEditor.setReadOnly(true); eventEditor.setMode(AceMode.java); eventEditor.setTheme(AceTheme.eclipse); eventEditor.setHeight(470, Unit.PIXELS); eventEditor.setWidth("100%"); HorizontalLayout formLayout = new HorizontalLayout(); formLayout.setWidth("100%"); formLayout.setHeight(300, Unit.PIXELS); formLayout.addComponent(layout); wrapperLayout.addComponent(formLayout, 0, 0); // VerticalSplitPanel vSplitPanel = new VerticalSplitPanel(); // vSplitPanel.setWidth("100%"); // vSplitPanel.setHeight(800, Unit.PIXELS); // vSplitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE); TabSheet tabsheet = new TabSheet(); tabsheet.setSizeFull(); HorizontalLayout h1 = new HorizontalLayout(); h1.setSizeFull(); h1.setMargin(true); h1.addComponent(eventEditor); // vSplitPanel.setFirstComponent(h1); HorizontalLayout h2 = new HorizontalLayout(); h2.setSizeFull(); h2.setMargin(true); h2.addComponent(editor); // vSplitPanel.setSecondComponent(h2); tabsheet.addTab(h2, "Error Details"); tabsheet.addTab(h1, "Event Payload"); wrapperLayout.addComponent(tabsheet, 0, 1); // wrapperLayout.addComponent(vSplitPanel, 0, 1); errorOccurrenceDetailsPanel.setContent(wrapperLayout); return errorOccurrenceDetailsPanel; }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
protected Panel createTextAreaPanel(ConfigurationParameter parameter, Validator validator) { Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true);// w w w. j ava2 s .c o m paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label label = new Label(parameter.getName()); label.setIcon(VaadinIcons.COG); label.addStyleName(ValoTheme.LABEL_LARGE); label.addStyleName(ValoTheme.LABEL_BOLD); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 0, 1, 0); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); logger.info(parameter.getName() + " " + parameter.getValue()); Label valueLabel = new Label("Value:"); valueLabel.setSizeUndefined(); TextArea textField = new TextArea(); textField.addValidator(validator); textField.setNullSettingAllowed(true); textField.setNullRepresentation(""); textField.setValidationVisible(false); textField.setRows(4); textField.setWidth("80%"); textField.setId(parameter.getName()); if (parameter instanceof ConfigurationParameterIntegerImpl) { StringToIntegerConverter plainIntegerConverter = new StringToIntegerConverter() { protected java.text.NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; }; }; // either set for the field or in your field factory for multiple fields textField.setConverter(plainIntegerConverter); } else if (parameter instanceof ConfigurationParameterLongImpl) { StringToLongConverter plainLongConverter = new StringToLongConverter() { protected java.text.NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; }; }; // either set for the field or in your field factory for multiple fields textField.setConverter(plainLongConverter); } textFields.put(parameter.getName(), textField); BeanItem<ConfigurationParameter> parameterItem = new BeanItem<ConfigurationParameter>(parameter); if (parameter.getValue() != null) { textField.setPropertyDataSource(parameterItem.getItemProperty("value")); } paramLayout.addComponent(valueLabel, 0, 1); paramLayout.addComponent(textField, 1, 1); paramLayout.setComponentAlignment(valueLabel, Alignment.TOP_RIGHT); Label paramDescriptionLabel = new Label("Description:"); paramDescriptionLabel.setSizeUndefined(); TextArea descriptionTextField = new TextArea(); descriptionTextField.setRows(4); descriptionTextField.setWidth("80%"); descriptionTextField.setId(parameter.getName()); paramLayout.addComponent(paramDescriptionLabel, 0, 2); paramLayout.addComponent(descriptionTextField, 1, 2); paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT); descriptionTextFields.put(parameter.getName(), descriptionTextField); if (parameter.getDescription() != null) { descriptionTextField.setValue(parameter.getDescription()); } paramPanel.setContent(paramLayout); return paramPanel; }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
protected Panel createMapPanel(final ConfigurationParameterMapImpl parameter) { Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true);/*from www.j av a 2 s .c o m*/ paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label label = new Label(parameter.getName()); label.setIcon(VaadinIcons.COG); label.addStyleName(ValoTheme.LABEL_LARGE); label.addStyleName(ValoTheme.LABEL_BOLD); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 0, 1, 0); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final Map<String, String> valueMap = parameter.getValue(); final GridLayout mapLayout = new GridLayout(5, (valueMap.size() != 0 ? valueMap.size() : 1) + 1); mapLayout.setMargin(true); mapLayout.setSpacing(true); int i = 0; for (final String key : valueMap.keySet()) { final Label keyLabel = new Label("Key"); final Label valueLabel = new Label("Value"); final TextField keyField = new TextField(); keyField.setValue(key); final TextField valueField = new TextField(); valueField.setValue(valueMap.get(key)); mapLayout.addComponent(keyLabel, 0, i); mapLayout.addComponent(keyField, 1, i); mapLayout.addComponent(valueLabel, 2, i); mapLayout.addComponent(valueField, 3, i); final String mapKey = parameter.getName() + i; TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; this.mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { valueMap.remove(key); mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, i); i++; } final Button addButton = new Button("add"); addButton.setStyleName(ValoTheme.BUTTON_LINK); addButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Label keyLabel = new Label("Key"); final Label valueLabel = new Label("Value"); final TextField keyField = new TextField(); final TextField valueField = new TextField(); mapLayout.insertRow(mapLayout.getRows()); mapLayout.removeComponent(addButton); mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() - 2); mapLayout.addComponent(keyField, 1, mapLayout.getRows() - 2); mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() - 2); mapLayout.addComponent(valueField, 3, mapLayout.getRows() - 2); final String mapKey = parameter.getName() + mapTextFields.size(); TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, mapLayout.getRows() - 2); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); } }); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); Panel mapPanel = new Panel(); mapPanel.setStyleName("dashboard"); mapPanel.setContent(mapLayout); paramLayout.addComponent(mapPanel, 0, 1, 1, 1); paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER); paramPanel.setContent(paramLayout); Label paramDescriptionLabel = new Label("Description:"); paramDescriptionLabel.setSizeUndefined(); TextArea descriptionTextField = new TextArea(); descriptionTextField.setRows(4); descriptionTextField.setWidth("80%"); descriptionTextField.setId(parameter.getName()); paramLayout.addComponent(paramDescriptionLabel, 0, 2); paramLayout.addComponent(descriptionTextField, 1, 2); paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT); descriptionTextFields.put(parameter.getName(), descriptionTextField); if (parameter.getDescription() != null) { descriptionTextField.setValue(parameter.getDescription()); } return paramPanel; }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
protected Panel createListPanel(final ConfigurationParameterListImpl parameter) { Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true);/*from w w w.j a v a2 s. com*/ paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label label = new Label(parameter.getName()); label.setIcon(VaadinIcons.COG); label.addStyleName(ValoTheme.LABEL_LARGE); label.addStyleName(ValoTheme.LABEL_BOLD); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 0, 1, 0); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final List<String> valueList = parameter.getValue(); final GridLayout listLayout = new GridLayout(3, (valueList.size() != 0 ? valueList.size() : 1) + 1); listLayout.setWidth("450px"); listLayout.setMargin(true); listLayout.setSpacing(true); listLayout.setColumnExpandRatio(0, 0.25f); listLayout.setColumnExpandRatio(1, 0.5f); listLayout.setColumnExpandRatio(2, 0.25f); int i = 0; for (final String value : valueList) { final Label valueLabel = new Label("Value"); final TextField valueField = new TextField(); valueField.setValue(value); valueField.setWidth("90%"); listLayout.addComponent(valueLabel, 0, i); listLayout.addComponent(valueField, 1, i); final String mapKey = parameter.getName() + i; this.valueTextFields.put(mapKey, valueField); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { valueList.remove(value); listLayout.removeComponent(valueLabel); listLayout.removeComponent(valueField); listLayout.removeComponent(removeButton); valueTextFields.remove(mapKey); } }); listLayout.addComponent(removeButton, 2, i); i++; } final Button addButton = new Button("add"); addButton.setStyleName(ValoTheme.BUTTON_LINK); addButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Label valueLabel = new Label("Value"); final TextField valueField = new TextField(); valueField.setWidth("90%"); listLayout.insertRow(listLayout.getRows()); listLayout.removeComponent(addButton); listLayout.addComponent(valueLabel, 0, listLayout.getRows() - 2); listLayout.addComponent(valueField, 1, listLayout.getRows() - 2); final String mapKey = parameter.getName() + valueTextFields.size(); valueTextFields.put(mapKey, valueField); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { listLayout.removeComponent(valueLabel); listLayout.removeComponent(valueField); listLayout.removeComponent(removeButton); valueTextFields.remove(mapKey); } }); listLayout.addComponent(removeButton, 2, listLayout.getRows() - 2); listLayout.addComponent(addButton, 0, listLayout.getRows() - 1); } }); listLayout.addComponent(addButton, 0, listLayout.getRows() - 1); Panel mapPanel = new Panel(); mapPanel.setStyleName("dashboard"); mapPanel.setContent(listLayout); paramLayout.addComponent(mapPanel, 0, 1, 1, 1); paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER); paramPanel.setContent(paramLayout); Label paramDescriptionLabel = new Label("Description:"); paramDescriptionLabel.setSizeUndefined(); TextArea descriptionTextField = new TextArea(); descriptionTextField.setRows(4); descriptionTextField.setWidth("80%"); descriptionTextField.setId(parameter.getName()); paramLayout.addComponent(paramDescriptionLabel, 0, 2); paramLayout.addComponent(descriptionTextField, 1, 2); paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT); descriptionTextFields.put(parameter.getName(), descriptionTextField); if (parameter.getDescription() != null) { descriptionTextField.setValue(parameter.getDescription()); } return paramPanel; }
From source file:org.ikasan.dashboard.ui.topology.window.ErrorOccurrenceViewWindow.java
License:BSD License
protected Panel createErrorOccurrenceDetailsPanel() { Panel errorOccurrenceDetailsPanel = new Panel(); GridLayout layout = new GridLayout(2, 6); layout.setSizeFull();//from w w w . j a v a 2 s . c o m layout.setSpacing(true); layout.setColumnExpandRatio(0, 0.25f); layout.setColumnExpandRatio(1, 0.75f); Label errorOccurrenceDetailsLabel = new Label("Error Occurence Details"); errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(errorOccurrenceDetailsLabel); Label label = new Label("Module Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf1 = new TextField(); tf1.setValue(this.errorOccurrence.getModuleName()); tf1.setReadOnly(true); tf1.setWidth("80%"); layout.addComponent(tf1, 1, 1); label = new Label("Flow Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf2 = new TextField(); tf2.setValue(this.errorOccurrence.getFlowName()); tf2.setReadOnly(true); tf2.setWidth("80%"); layout.addComponent(tf2, 1, 2); label = new Label("Component Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf3 = new TextField(); tf3.setValue(this.errorOccurrence.getFlowElementName()); tf3.setReadOnly(true); tf3.setWidth("80%"); layout.addComponent(tf3, 1, 3); label = new Label("Date/Time:"); label.setSizeUndefined(); layout.addComponent(label, 0, 4); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf4 = new TextField(); tf4.setValue(new Date(this.errorOccurrence.getTimestamp()).toString()); tf4.setReadOnly(true); tf4.setWidth("80%"); layout.addComponent(tf4, 1, 4); label = new Label("Error Message:"); label.setSizeUndefined(); layout.addComponent(label, 0, 5); layout.setComponentAlignment(label, Alignment.TOP_RIGHT); TextArea tf5 = new TextArea(); tf5.setValue(this.errorOccurrence.getErrorMessage()); tf5.setReadOnly(true); tf5.setWidth("80%"); tf5.setRows(3); layout.addComponent(tf5, 1, 5); GridLayout wrapperLayout = new GridLayout(1, 4); wrapperLayout.setMargin(true); wrapperLayout.setWidth("100%"); TabSheet tabsheet = new TabSheet(); tabsheet.setSizeFull(); AceEditor editor = new AceEditor(); // editor.setCaption("Error Details"); editor.setValue(this.errorOccurrence.getErrorDetail()); editor.setReadOnly(true); editor.setMode(AceMode.xml); editor.setTheme(AceTheme.eclipse); editor.setHeight(470, Unit.PIXELS); editor.setWidth("100%"); AceEditor eventEditor = new AceEditor(); // eventEditor.setCaption("Event Payload"); if (this.errorOccurrence.getEvent() != null) { eventEditor.setValue(new String((byte[]) this.errorOccurrence.getEvent())); } eventEditor.setReadOnly(true); eventEditor.setMode(AceMode.java); eventEditor.setTheme(AceTheme.eclipse); eventEditor.setHeight(470, Unit.PIXELS); eventEditor.setWidth("100%"); HorizontalLayout formLayout = new HorizontalLayout(); formLayout.setWidth("100%"); formLayout.setHeight(230, Unit.PIXELS); formLayout.addComponent(layout); wrapperLayout.addComponent(formLayout, 0, 0); // VerticalSplitPanel vSplitPanel = new VerticalSplitPanel(); // vSplitPanel.setWidth("100%"); // vSplitPanel.setHeight(800, Unit.PIXELS); // vSplitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE); HorizontalLayout h1 = new HorizontalLayout(); h1.setSizeFull(); h1.setMargin(true); h1.addComponent(eventEditor); // vSplitPanel.setFirstComponent(h1); HorizontalLayout h2 = new HorizontalLayout(); h2.setSizeFull(); h2.setMargin(true); h2.addComponent(editor); // vSplitPanel.setSecondComponent(h2); tabsheet.addTab(h2, "Error Details"); tabsheet.addTab(h1, "Event Payload"); wrapperLayout.addComponent(tabsheet, 0, 1); errorOccurrenceDetailsPanel.setContent(wrapperLayout); return errorOccurrenceDetailsPanel; }
From source file:org.openeos.usertask.ui.internal.vaadin.TasksWindow.java
License:Apache License
private Component createTaskSummary(UserTask task) { // TextField name = new TextField("Name"); // name.setValue(task.getName()); // name.setReadOnly(true); // name.setWidth("100%"); TextField priority = new TextField("Priority"); priority.setValue(Integer.toString(task.getPriority())); priority.setReadOnly(true);/*from w w w. j av a 2s .co m*/ TextField status = new TextField("Status"); status.setValue(task.getStatus().getDescription()); status.setReadOnly(true); TextArea description = new TextArea("Description"); description.setSizeFull(); description.setValue(task.getDescription()); description.setReadOnly(true); description.setRows(3); ComponentContainer buttons = createSummaryButtons(task); VerticalLayout secondColumnFields = new VerticalLayout(); secondColumnFields.setMargin(false); secondColumnFields.setSizeFull(); secondColumnFields.addComponent(priority); secondColumnFields.addComponent(status); HorizontalLayout fieldsLayout = new HorizontalLayout(); fieldsLayout.setSizeFull(); fieldsLayout.setMargin(false); fieldsLayout.setSpacing(false); fieldsLayout.addComponent(description); fieldsLayout.addComponent(secondColumnFields); fieldsLayout.setExpandRatio(description, 4.0f); fieldsLayout.setExpandRatio(secondColumnFields, 1.0f); HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setMargin(true); mainLayout.setSpacing(false); mainLayout.setSizeFull(); mainLayout.addComponent(fieldsLayout); mainLayout.addComponent(buttons); mainLayout.setComponentAlignment(buttons, Alignment.TOP_LEFT); mainLayout.setExpandRatio(fieldsLayout, 1.0f); Panel panel = new Panel("Summary"); panel.setStyleName("background-transparent"); panel.setContent(mainLayout); return panel; }
From source file:org.opennms.features.pluginmgr.vaadin.pluginmanager.ErrorMessageWindow.java
License:Apache License
public ErrorMessageWindow(SystemMessages systemMessages) { super("Full Log Message"); // Set window caption center();//from w w w . ja v a2 s. c o m setHeight("75%"); setWidth("75%"); // Some basic content for the window VerticalLayout content = new VerticalLayout(); content.setSizeFull(); TextArea ta = new TextArea(); ta.setWordwrap(true); ta.setImmediate(true); ta.setWidth("100%"); ta.setHeight("100%"); content.addComponent(ta); content.setExpandRatio(ta, 1.0f); if (systemMessages != null) { ta.setValue(systemMessages.getLongMessage()); } else { ta.setValue("Error: systemMessages should not be null"); LOG.error("Error: systemMessages should not be null"); } ta.setReadOnly(false); content.setMargin(true); setContent(content); // Disable the close button setClosable(false); // Trivial logic for closing the sub-window Button ok = new Button("OK"); ok.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { close(); // Close the sub-window } }); content.addComponent(ok); }