List of usage examples for com.vaadin.ui Panel addStyleName
@Override public void addStyleName(String style)
From source file:org.s23m.cell.editor.semanticdomain.ui.components.ContainmentTreePanel.java
License:Mozilla Public License
private Panel createOperationsPanel() { final Panel operationsPanel = new Panel(); final HorizontalLayout operationsPanelLayout = new HorizontalLayout(); operationsPanelLayout.setWidth(TAB_SHEET_HEIGHT_RATIO); operationsPanelLayout.setSpacing(true); operationsPanel.addStyleName(Runo.PANEL_LIGHT); operationsPanel.getLayout().setMargin(true); operationsPanel.setLayout(operationsPanelLayout); commitButton = new Button(); commitButton.setDescription("Commit"); commitButton.setIcon(EditorIcon.PERSIST.getIconImage()); commitButton.addListener(Button.ClickEvent.class, this, CHANGESET_COMMIT_CMD); rollbackButton = new Button(); rollbackButton.setDescription("Rollback"); // TODO use a more appropriate icon rollbackButton.setIcon(EditorIcon.DELETE.getIconImage()); rollbackButton.addListener(Button.ClickEvent.class, this, CHANGESET_ROLLBACK_CMD); commitButton.setImmediate(true);//w w w . ja v a 2 s . co m rollbackButton.setImmediate(true); commitButton.setEnabled(false); rollbackButton.setEnabled(false); final Button retrievalBtn = new Button(); retrievalBtn.setDescription("Retrieve"); retrievalBtn.setIcon(EditorIcon.RETRIEVE.getIconImage()); retrievalBtn.setWidth(null); retrievalBtn.addListener(Button.ClickEvent.class, this, INSTANCE_RETRIEVAL_CMD); operationsPanel.addComponent(retrievalBtn); operationsPanel.addComponent(commitButton); operationsPanel.addComponent(rollbackButton); return operationsPanel; }
From source file:org.vaadin.addons.criteriacontainersample.AbstractBeanTupleApplication.java
License:Apache License
/** * @param mainWindow the window in which the panel should appear * @param filterPanel the panel with an input field and a button. *//*from ww w .ja va 2 s . co m*/ private void createTopPanel(Window mainWindow, Panel filterPanel) { filterPanel.addStyleName(Runo.PANEL_LIGHT); HorizontalLayout filterLayout = new HorizontalLayout(); filterLayout.setMargin(false); filterLayout.setSpacing(true); filterPanel.setContent(filterLayout); mainWindow.addComponent(filterPanel); Panel buttonPanel = new Panel(); buttonPanel.addStyleName(Runo.PANEL_LIGHT); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(false); buttonLayout.setSpacing(true); buttonPanel.setContent(buttonLayout); mainWindow.addComponent(buttonPanel); Panel buttonPanel2 = new Panel(); buttonPanel2.addStyleName(Runo.PANEL_LIGHT); HorizontalLayout buttonLayout2 = new HorizontalLayout(); buttonLayout2.setMargin(false); buttonLayout2.setSpacing(true); buttonPanel2.setContent(buttonLayout2); mainWindow.addComponent(buttonPanel2); nameFilterField = new TextField("Name"); filterPanel.addComponent(nameFilterField); refreshButton = new Button("Refresh"); refreshButton.addListener(this); buttonPanel.addComponent(refreshButton); editButton = new Button("Edit"); editButton.addListener(this); buttonPanel.addComponent(editButton); saveButton = new Button("Save"); saveButton.addListener(this); saveButton.setEnabled(false); buttonPanel2.addComponent(saveButton); cancelButton = new Button("Cancel"); cancelButton.addListener(this); cancelButton.setEnabled(false); buttonPanel2.addComponent(cancelButton); }
From source file:org.vaadin.addons.criteriacontainersample.AbstractEntityApplication.java
License:Apache License
/** * Create the top panel where the user can add filtering restrictions. * @param mainWindow//from w w w . j av a 2 s.com * @return */ private Panel createFilterPanel(VerticalLayout mainLayout) { Panel filterPanel = new Panel(); filterPanel.addStyleName(Runo.PANEL_LIGHT); HorizontalLayout filterLayout = new HorizontalLayout(); filterLayout.setMargin(false); filterLayout.setSpacing(true); filterPanel.setContent(filterLayout); mainLayout.addComponent(filterPanel); Panel buttonPanel = new Panel(); buttonPanel.addStyleName(Runo.PANEL_LIGHT); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(false); buttonLayout.setSpacing(true); buttonPanel.setContent(buttonLayout); mainLayout.addComponent(buttonPanel); Panel buttonPanel2 = new Panel(); buttonPanel2.addStyleName(Runo.PANEL_LIGHT); HorizontalLayout buttonLayout2 = new HorizontalLayout(); buttonLayout2.setMargin(false); buttonLayout2.setSpacing(true); buttonPanel2.setContent(buttonLayout2); mainLayout.addComponent(buttonPanel2); nameFilterField = new TextField("Name"); filterPanel.addComponent(nameFilterField); refreshButton = new Button("Refresh"); refreshButton.addListener(this); buttonPanel.addComponent(refreshButton); editButton = new Button("Edit"); editButton.addListener(this); buttonPanel.addComponent(editButton); saveButton = new Button("Save"); saveButton.addListener(this); saveButton.setEnabled(false); buttonPanel2.addComponent(saveButton); cancelButton = new Button("Cancel"); cancelButton.addListener(this); cancelButton.setEnabled(false); buttonPanel2.addComponent(cancelButton); addItemButton = new Button("Add Row"); addItemButton.addListener(this); addItemButton.setEnabled(false); buttonPanel2.addComponent(addItemButton); removeItemButton = new Button("Remove Row"); removeItemButton.addListener(this); removeItemButton.setEnabled(false); buttonPanel2.addComponent(removeItemButton); return buttonPanel2; }
From source file:org.vaadin.addons.lazyquerycontainer.example.mock.VaadinApplication.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setMargin(true);/*from www.java 2s . c o m*/ mainLayout.setSpacing(true); setContent(mainLayout); Panel buttonPanel = new Panel(); buttonPanel.addStyleName(Runo.PANEL_LIGHT); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(false); buttonLayout.setSpacing(true); buttonPanel.setContent(buttonLayout); mainLayout.addComponent(buttonPanel); Panel buttonPanel2 = new Panel(); buttonPanel2.addStyleName(Runo.PANEL_LIGHT); HorizontalLayout buttonLayout2 = new HorizontalLayout(); buttonLayout2.setMargin(false); buttonLayout2.setSpacing(true); buttonPanel2.setContent(buttonLayout2); mainLayout.addComponent(buttonPanel2); refreshButton = new Button("Refresh"); refreshButton.setIcon(new ClassResource(QueryItemStatusColumnGenerator.class, "images/table_refresh.png")); refreshButton.addClickListener(this); buttonLayout.addComponent(refreshButton); editButton = new Button("Edit"); editButton.setIcon(new ClassResource(QueryItemStatusColumnGenerator.class, "images/table_edit.png")); editButton.addClickListener(this); buttonLayout.addComponent(editButton); addPropertyButton = new Button("Add Column"); addPropertyButton.setIcon(new ClassResource(QueryItemStatusColumnGenerator.class, "images/tab_add.png")); addPropertyButton.addClickListener(this); buttonLayout.addComponent(addPropertyButton); removeAllItemsButton = new Button("Remove All Rows"); removeAllItemsButton.setIcon(new ClassResource(QueryItemStatusColumnGenerator.class, "images/delete.png")); removeAllItemsButton.addClickListener(this); buttonLayout.addComponent(removeAllItemsButton); saveButton = new Button("Save"); saveButton.setIcon(new ClassResource(QueryItemStatusColumnGenerator.class, "images/table_save.png")); saveButton.addClickListener(this); saveButton.setEnabled(false); buttonLayout2.addComponent(saveButton); cancelButton = new Button("Cancel"); cancelButton.setIcon(new ClassResource(QueryItemStatusColumnGenerator.class, "images/cancel.png")); cancelButton.addClickListener(this); cancelButton.setEnabled(false); buttonLayout2.addComponent(cancelButton); addItemButton = new Button("Add Row"); addItemButton .setIcon(new ClassResource(QueryItemStatusColumnGenerator.class, "images/table_row_insert.png")); addItemButton.addClickListener(this); addItemButton.setEnabled(false); buttonLayout2.addComponent(addItemButton); removeItemButton = new Button("Remove Row"); removeItemButton .setIcon(new ClassResource(QueryItemStatusColumnGenerator.class, "images/table_row_delete.png")); removeItemButton.addClickListener(this); removeItemButton.setEnabled(false); buttonLayout2.addComponent(removeItemButton); table = new Table(); mainLayout.addComponent(table); table.setPageLength(20); mockQueryFactory = new MockQueryFactory(2000, 10, 20); container = new LazyQueryContainer(new LazyQueryDefinition(true, 50, "Index"), mockQueryFactory); container.addContainerProperty(LazyQueryView.PROPERTY_ID_ITEM_STATUS, QueryItemStatus.class, QueryItemStatus.None, true, false); container.addContainerProperty("Index", Integer.class, 0, true, true); container.addContainerProperty("ReverseIndex", Integer.class, 0, true, true); container.addContainerProperty("Editable", String.class, "", false, false); container.addContainerProperty(LazyQueryView.DEBUG_PROPERTY_ID_QUERY_INDEX, Integer.class, 0, true, false); container.addContainerProperty(LazyQueryView.DEBUG_PROPERTY_ID_BATCH_INDEX, Integer.class, 0, true, false); container.addContainerProperty(LazyQueryView.DEBUG_PROPERTY_ID_BATCH_QUERY_TIME, Long.class, 0, true, false); table.setContainerDataSource(container); visibleColumnIds.add(LazyQueryView.PROPERTY_ID_ITEM_STATUS); visibleColumnIds.add("Index"); visibleColumnIds.add("ReverseIndex"); visibleColumnIds.add("Editable"); visibleColumnIds.add(LazyQueryView.DEBUG_PROPERTY_ID_QUERY_INDEX); visibleColumnIds.add(LazyQueryView.DEBUG_PROPERTY_ID_BATCH_INDEX); visibleColumnIds.add(LazyQueryView.DEBUG_PROPERTY_ID_BATCH_QUERY_TIME); visibleColumnLabels.add(""); visibleColumnLabels.add("Index"); visibleColumnLabels.add("Reverse Index"); visibleColumnLabels.add("Editable"); visibleColumnLabels.add("Query"); visibleColumnLabels.add("Batch"); visibleColumnLabels.add("Time [ms]"); table.setColumnWidth("Editable", 135); table.setVisibleColumns(visibleColumnIds.toArray()); table.setColumnHeaders(visibleColumnLabels.toArray(new String[0])); table.setColumnWidth(LazyQueryView.PROPERTY_ID_ITEM_STATUS, 16); table.addGeneratedColumn(LazyQueryView.PROPERTY_ID_ITEM_STATUS, new QueryItemStatusColumnGenerator()); table.setEditable(false); table.setMultiSelect(true); table.setMultiSelectMode(MultiSelectMode.DEFAULT); table.setSelectable(true); //table.setWriteThrough(true); }
From source file:ro.zg.netcell.vaadin.action.application.OpenSelectedEntityHandler.java
License:Apache License
@Override public void handle(final ActionContext actionContext) throws Exception { final ComponentContainer container = actionContext.getTargetContainer(); container.removeAllComponents();//from w w w . j a v a2 s. c o m // container.setSizeFull(); // container.setMargin(false); final OpenGroupsApplication app = actionContext.getApp(); final Entity entity = actionContext.getEntity(); EntityState entityState = entity.getState(); boolean isOpened = entityState.isOpened(); String complexEntityType = entity.getComplexType(); ApplicationConfigManager appConfigManager = app.getAppConfigManager(); List<String> subtyesList = appConfigManager.getSubtypesForComplexType(complexEntityType); // Panel currentContainer = (Panel) container; ComponentContainer currentContainer = container; entity.setEntityContainer(container); CssLayout headerContainer = new CssLayout(); headerContainer.addStyleName("entity-header-container"); currentContainer.addComponent(headerContainer); // CssLayout titleContainer = new CssLayout(); // titleContainer.setWidth("80%"); // titleContainer.addStyleName(OpenGroupsStyles.MIDDLE_LEFT); // headerContainer.addComponent(titleContainer); // titleContainer.setSizeFull(); // /* show level */ // String levelMsg = getMessage("level"); // Label levelLabel = new Label(levelMsg+" "+entity.getDepth()); // titleContainer.addComponent(levelLabel); /* show entity type */ if (entity.getState().isEntityTypeVisible()) { String entityTypeCaption = getMessage(entity.getComplexType()); String size = OpenGroupsIconsSet.MEDIUM; if (entity.getContent() != null) { size = OpenGroupsIconsSet.LARGE; } // Label typeIcon = new Label(); // typeIcon.setDescription(entityTypeCaption); // typeIcon.setIcon(OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(), // size)); // typeIcon.setSizeUndefined(); // typeIcon.addStyleName("top-left right-margin-20"); // headerContainer.addComponent(typeIcon); Embedded eicon = new Embedded(null, OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(), size)); eicon.setDescription(entityTypeCaption); eicon.addStyleName("top-left right-margin-20"); headerContainer.addComponent(eicon); // Embedded eicon2 = new Embedded("", // OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(), // size)); // eicon2.setDescription(entityTypeCaption); // eicon2.addStyleName("top-left right-margin-20"); // headerContainer.addComponent(eicon2); } // Label test = new Label("test"); // test.setSizeUndefined(); // test.addStyleName("top-left"); // headerContainer.addComponent(test); /* add last action for this entity */ if (entity.getLastActionType() != null) { String actionType = entity.getLastActionType(); String msg = getMessage(actionType); // Label actionLabel = new Label(); // actionLabel.setDescription(msg); // actionLabel.setIcon(OpenGroupsResources.getIcon(actionType, // OpenGroupsIconsSet.MEDIUM)); // actionLabel.setSizeUndefined(); // actionLabel.addStyleName(OpenGroupsStyles.MIDDLE_LEFT); // titleContainer.addComponent(actionLabel); Embedded actionIcon = new Embedded(null, OpenGroupsResources.getIcon(actionType, OpenGroupsIconsSet.MEDIUM)); actionIcon.setDescription(msg); actionIcon.addStyleName("top-left right-margin-20"); headerContainer.addComponent(actionIcon); } EntityLink selectedCause = entity.getSelectedCause(); /* display title */ /* if the entity is open */ /* treat leafs like all posts 21.08.2012 */ if (isOpened /* * || (subtyesList == null && entity.getLastActionType() == * null) */) { Label title = new Label(entity.getTitle()); if (isOpened) { title.addStyleName(OpenGroupsStyles.TITLE_LINK); } else { title.addStyleName("list-issue-title"); } // title.addStyleName("top-left"); // title.setSizeFull(); title.setWidth("80%"); // title.setHeight("100%"); headerContainer.addComponent(title); } else { // Button titleLink = new Button(entity.getTitle()); // titleLink.setWidth("100%"); // titleLink.addStyleName(BaseTheme.BUTTON_LINK); // titleLink.addStyleName("issue-title"); // titleLink.setDescription(entity.getContentPreview()); Label titleLink = null; /* treat leafs like all posts 21.08.2012 */ // if (subtyesList != null) { titleLink = OpenGroupsUtil.getLinkForEntity(entity, app); titleLink.setDescription(entity.getContentPreview()); titleLink.addStyleName("list-issue-title"); // } // /* is a leaf entity in the recent activity list */ // else { // String parentTitle = selectedCause.getParentTitle(); // Entity parentEntity = new Entity(selectedCause.getParentId()); // parentEntity.setTitle(parentTitle); // // parentEntity.getState().setDesiredActionsPath( // complexEntityType + // Defaults.getDefaultActionForEntityType(complexEntityType)); // titleLink = OpenGroupsUtil.getLinkForEntity(parentEntity, app, // entity.getTitle()); // titleLink.setDescription(entity.getContentPreview()); // titleLink.addStyleName("list-issue-title"); // // } // titleLink.setWidth("75%"); titleLink.addStyleName("top-left"); headerContainer.addComponent(titleLink); // titleContainer.setExpandRatio(titleLink, 10f); // currentContainer.addStyleName("list-item"); } /* add parent link */ if (selectedCause != null && !isOpened && entity.getContent() == null) { // CssLayout parentInfoContainer = new CssLayout(); // parentInfoContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT); // headerContainer.addComponent(parentInfoContainer); // headerContainer.setColumnExpandRatio(1, 1f); // headerContainer.setComponentAlignment(parentInfoContainer, // Alignment.TOP_RIGHT); /* if parent entity is the current selected entity, say it */ Entity mainEntity = actionContext.getMainEntity(); if (selectedCause.getParentId() == mainEntity.getId()) { // String currentMsg = getMessage(mainEntity.getComplexType() + // ".current"); // Label currentEntityLabel = new Label(currentMsg); // currentEntityLabel.setSizeUndefined(); // currentEntityLabel.addStyleName("top-right"); // headerContainer.addComponent(currentEntityLabel); // titleContainer.setExpandRatio(currentEntityLabel, 2f); } else {/* add link to the parent entity */ String parentTitle = selectedCause.getParentTitle(); final Entity parentEntity = new Entity(selectedCause.getParentId()); parentEntity.setTitle(parentTitle); Label parentLink = OpenGroupsUtil.getLinkForEntityWithImage(parentEntity, app, OpenGroupsResources.getIconPath(OpenGroupsIconsSet.PARENT, OpenGroupsIconsSet.MEDIUM)); parentLink.setDescription(parentTitle); parentLink.setSizeUndefined(); parentLink.addStyleName(OpenGroupsStyles.TOP_RIGHT); // CssLayout imgContainer = new CssLayout(); // imgContainer.setWidth("24px"); // imgContainer.setHeight("24px"); // imgContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT); // imgContainer.addComponent(parentLink); // parentInfoContainer.addComponent(imgContainer); headerContainer.addComponent(parentLink); } } /* display header actions */ if (isOpened) { UserActionList headerActions = getAvailableActions(entity, ActionLocations.HEADER); boolean allowRefresh = appConfigManager.getComplexEntityBooleanParam(entity.getComplexType(), ComplexEntityParam.ALLOW_REFRESH); boolean hasHeaderActions = headerActions != null && headerActions.getActions() != null; if (allowRefresh || hasHeaderActions) { HorizontalLayout actionsContainer = new HorizontalLayout(); actionsContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT); actionsContainer.setSpacing(true); // /* add refresh button */ // if (allowRefresh) { // actionsContainer.addComponent(getRefreshButton(entity, app)); // } // if (hasHeaderActions) { // for (final UserAction ha : // headerActions.getActions().values()) { // Button actButton = getButtonForAction(ha, entity, app); // actionsContainer.addComponent(actButton); // } // } headerContainer.addComponent(actionsContainer); // headerContainer.setColumnExpandRatio(1, 1f); // headerContainer.setComponentAlignment(actionsContainer, // Alignment.TOP_RIGHT); entity.setHeaderActionLinksContainer(actionsContainer); refreshHeaderActionLinks(entity, app, actionContext); } } /* display tags */ List<Tag> tags = entity.getTags(); if (tags != null) { if (tags.size() > 0) { String tagsList = ""; for (int i = 0; i < tags.size(); i++) { Tag tag = tags.get(i); tagsList += tag.getTagName(); if ((tags.size() - i) > 1) { tagsList += ", "; } } String tagsLabelString = app.getMessage("tags.label") + tagsList; currentContainer.addComponent(new Label(tagsLabelString)); } } CssLayout statusPane = new CssLayout(); statusPane.addStyleName("entity-status-pane"); currentContainer.addComponent(statusPane); if (appConfigManager.getComplexEntityBooleanParam(complexEntityType, ComplexEntityParam.SHOW_POST_INFO)) { String insertDateString = entity.getInsertDate().toString(); Label insertDate = new Label(app.getMessage("posted") + DateUtil.removeNanos(insertDateString)); statusPane.addComponent(insertDate); // statusPane.setColumnExpandRatio(0, 1f); } CssLayout statsSummaryPane = new CssLayout(); statsSummaryPane.addStyleName("entity-stats-summary-pane"); // statsSummaryPane.setSizeFull(); // statsSummaryPane.setWidth("100%"); currentContainer.addComponent(statsSummaryPane); /* add votes */ if (appConfigManager.getComplexEntityBooleanParam(complexEntityType, ComplexEntityParam.ALLOW_VOTING)) { // HorizontalLayout votesPane = new HorizontalLayout(); // votesPane.setMargin(false); // votesPane.addStyleName("middle-left"); // votesPane.addStyleName("margin-right"); // statsSummaryPane.addComponent(votesPane); // statsSummaryPane.setExpandRatio(votesPane, 1f); // statsSummaryPane.setComponentAlignment(votesPane, // Alignment.MIDDLE_LEFT); Label votesLabel = new Label(app.getMessage("votes") + ": "); votesLabel.setContentMode(Label.CONTENT_XHTML); votesLabel.setSizeUndefined(); votesLabel.addStyleName("middle-left"); // votesPane.addComponent(votesLabel); Label proVotes = FormatingUtils.coloredLabel(entity.getProVotes(), "336633"); proVotes.addStyleName("middle-left"); proVotes.setSizeUndefined(); // votesPane.addComponent(proVotes); Label dash = new Label("-"); dash.addStyleName("middle-left"); dash.setSizeUndefined(); // votesPane.addComponent(new Label("-")); Label opposedVotes = FormatingUtils.coloredLabel(entity.getOpposedVotes(), "660000"); // votesPane.addComponent(opposedVotes); opposedVotes.addStyleName("middle-left"); opposedVotes.addStyleName("right-margin-10"); opposedVotes.setSizeUndefined(); statsSummaryPane.addComponent(votesLabel); statsSummaryPane.addComponent(proVotes); statsSummaryPane.addComponent(dash); statsSummaryPane.addComponent(opposedVotes); } List<TypeRelationConfig> subtypes = appConfigManager.getSubtypesForType(entity.getComplexTypeId()); // if (subtyesList != null) { if (subtypes != null) { Map<String, Long> firstLevelSubtypesCount = entity.getSubtypeEntitiesCount(); Map<String, Long> allSubtypesCount = entity.getRecursiveSubtypeEntitiesCount(); // for (String s : subtyesList) { // String subtype = s.toLowerCase(); for (TypeRelationConfig trc : subtypes) { String targetComplexType = trc.getTargetComplexType(); String subtype = targetComplexType.toLowerCase(); String displayName = app.getMessage("subtype." + subtype); Entity refEntity = new Entity(entity.getId()); refEntity.getState().setDesiredActionsPath( targetComplexType + Defaults.getDefaultActionForEntityType(targetComplexType)); Label subtypeLink = OpenGroupsUtil.getLinkForEntity(refEntity, app, displayName); String valueString = ": " + firstLevelSubtypesCount.get(subtype); // if (getAppConfigManager().getComplexEntityBooleanParam(s, // ComplexEntityParam.ALLOW_RECURSIVE_LIST)) { if (appConfigManager.getTypeRelationBooleanConfigParam(trc.getId(), TypeRelationConfigParam.ALLOW_RECURSIVE_LIST)) { Long recCount = allSubtypesCount.get(subtype); if (recCount != null) { valueString += " / " + recCount; } } Label sl = new Label(valueString); sl.setWidth(null); sl.addStyleName("middle-left"); sl.addStyleName("right-margin-10"); subtypeLink.setWidth(null); subtypeLink.addStyleName("middle-left"); statsSummaryPane.addComponent(subtypeLink); statsSummaryPane.addComponent(sl); // statsSummaryPane.setExpandRatio(sl, 1f); // statsSummaryPane.setComponentAlignment(sl, // Alignment.MIDDLE_LEFT); } } displaySummaryActions(entity, app, statsSummaryPane, actionContext); // statusPane.addComponent(statsSummaryPane, 1, 0); // statusPane.setColumnExpandRatio(1, 1.8f); // statusPane.setComponentAlignment(statsSummaryPane, // Alignment.MIDDLE_RIGHT); // summaryLayout.setComponentAlignment(statsSummaryPane, // Alignment.MIDDLE_RIGHT); /* add the content */ Object contentObj = entity.getContent(); if (contentObj != null) { // content.setSizeFull(); Panel contentContainer = new Panel(); // CssLayout contentContainer = new CssLayout(); contentContainer.addStyleName("text-content"); currentContainer.addComponent(contentContainer); Label content = new Label(contentObj.toString()); content.setContentMode(Label.CONTENT_XHTML); // content.addStyleName("text-label"); contentContainer.addComponent(content); /* if the content is visible, display footer actions */ displayFooterActions(entity, app, currentContainer, actionContext); } }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private RefreshableTab createSettings() { final Form systemForm; {// w w w.j a v a 2s .co m final ComboBox serviceLocation; { String[][] defs = { { "? ", "http://195.245.214.33:7777/esv" }, { "? ", "http://oraas.rt.ru:7777/gateway/services/SID0003318" } }; serviceLocation = new ComboBox("?? ?? "); serviceLocation.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_EXPLICIT); for (String[] def : defs) { addOption(serviceLocation, def[1], def[0], false); } serviceLocation.setImmediate(true); serviceLocation.setInputPrompt("http://"); serviceLocation.setNewItemsAllowed(true); serviceLocation.setNewItemHandler(new AbstractSelect.NewItemHandler() { @Override public void addNewItem(String newItemCaption) { addOption(serviceLocation, newItemCaption, newItemCaption, true); } }); String href = AdminServiceProvider.get() .getSystemProperty(CertificateVerifier.VERIFY_SERVICE_LOCATION); addOption(serviceLocation, href, href, true); } final CheckBox allowValidate; { allowValidate = new CheckBox(" ? "); allowValidate.setRequired(true); allowValidate.setImmediate(true); allowValidate.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { serviceLocation.setRequired(Boolean.TRUE.equals(event.getProperty().getValue())); } }); allowValidate.setValue(AdminServiceProvider .getBoolProperty(CertificateVerifier.ALLOW_VERIFY_CERTIFICATE_PROPERTY)); } systemForm = new Form(); systemForm.addField("location", serviceLocation); systemForm.addField("allowVerify", allowValidate); systemForm.setImmediate(true); systemForm.setWriteThrough(false); systemForm.setInvalidCommitted(false); Button commit = new Button("", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { systemForm.commit(); set(CertificateVerifier.VERIFY_SERVICE_LOCATION, serviceLocation.getValue()); set(CertificateVerifier.ALLOW_VERIFY_CERTIFICATE_PROPERTY, allowValidate.getValue()); event.getButton().getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } catch (Validator.InvalidValueException ignore) { } } }); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(commit); systemForm.getFooter().addComponent(buttons); } Panel b1 = new Panel(); b1.setSizeFull(); Label b1label = new Label(" ?"); b1label.addStyleName(Reindeer.LABEL_H2); b1.addComponent(b1label); b1.addComponent(systemForm); VerticalLayout certificates = new VerticalLayout(); certificates.setSizeFull(); certificates.setSpacing(true); HorizontalLayout topHl = new HorizontalLayout(); topHl.setSizeFull(); topHl.setSpacing(true); Panel certificatesPanel = new Panel("", certificates); certificatesPanel.setSizeFull(); certificatesPanel.addStyleName(Reindeer.PANEL_LIGHT); boolean linkCertificate = AdminServiceProvider.getBoolProperty(CertificateVerifier.LINK_CERTIFICATE); final CheckBox switchLink = new CheckBox("? "); switchLink.setValue(linkCertificate); switchLink.setImmediate(true); switchLink.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { set(CertificateVerifier.LINK_CERTIFICATE, switchLink.getValue()); event.getButton().getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } }); Panel b2 = new Panel(); b2.setSizeFull(); Label b2label = new Label("? ?"); b2label.addStyleName(Reindeer.LABEL_H2); b2.addComponent(b2label); b2.addComponent(switchLink); certificates.addComponent(b1); certificates.addComponent(b2); certificates.setExpandRatio(b1, 0.7f); certificates.setExpandRatio(b2, 0.3f); CheckBox productionMode = new CheckBox("? ", AdminServiceProvider.getBoolProperty(API.PRODUCTION_MODE)); productionMode.setImmediate(true); productionMode.setDescription( " ? ? ?? ?? testMsg"); productionMode.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { boolean value = Boolean.TRUE.equals(event.getProperty().getValue()); set(API.PRODUCTION_MODE, value); } }); Panel smevPanel = new Panel(" "); smevPanel.setSizeFull(); smevPanel.addComponent(productionMode); HorizontalLayout bottomHl = new HorizontalLayout(); bottomHl.setSizeFull(); bottomHl.setSpacing(true); LogSettings logSettings = new LogSettings(); Panel emailDatesPanel = createEmailDatesPanel(); Panel mailTaskConfigPanel = createMilTaskConfigPanel(); topHl.addComponent(certificatesPanel); topHl.addComponent(emailDatesPanel); topHl.addComponent(mailTaskConfigPanel); topHl.setExpandRatio(certificatesPanel, 0.4f); topHl.setExpandRatio(emailDatesPanel, 0.6f); topHl.setExpandRatio(mailTaskConfigPanel, 0.5f); Panel esiaPanel = buildEsiaPanel(); Panel printTemplatesPanel = buildPrintTemplatesPanel(); bottomHl.addComponent(smevPanel); bottomHl.addComponent(esiaPanel); bottomHl.addComponent(printTemplatesPanel); bottomHl.setExpandRatio(smevPanel, 0.2f); bottomHl.setExpandRatio(esiaPanel, 0.4f); bottomHl.setExpandRatio(printTemplatesPanel, 0.4f); final VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setSizeFull(); layout.addComponent(topHl); layout.addComponent(logSettings); layout.addComponent(bottomHl); layout.setExpandRatio(topHl, 0.40f); layout.setExpandRatio(logSettings, 0.40f); layout.setExpandRatio(bottomHl, 0.20f); layout.setMargin(true); layout.setSpacing(true); return new RefreshableTab(layout, logSettings); }
From source file:ru.codeinside.adm.ui.LogSettings.java
License:Mozilla Public License
LogSettings() { logErrors = new OptionGroup("? ? :", Arrays.asList(Status.FAILURE.name())); logErrors.setItemCaption(Status.FAILURE.name(), ""); logErrors.setImmediate(true);//w ww . j a v a 2 s.c o m logErrors.setMultiSelect(true); logStatus = new OptionGroup("? ? '':", statusKeys()); logStatus.setItemCaption(Status.REQUEST.name(), "?"); logStatus.setItemCaption(Status.RESULT.name(), ""); logStatus.setItemCaption(Status.PING.name(), "?"); logStatus.setMultiSelect(true); logStatus.setImmediate(true); ipSet = new TextArea("? IP ?:"); ipSet.setWordwrap(true); ipSet.setNullRepresentation(""); ipSet.setWidth(100f, UNITS_PERCENTAGE); ipSet.setRows(10); tf = new TextField(" , :"); tf.setRequired(true); tf.addValidator(new Validator() { public void validate(Object value) throws InvalidValueException { if (!isValid(value)) { throw new InvalidValueException( " ? "); } } public boolean isValid(Object value) { return value instanceof String && ((String) value).matches("[1-9][0-9]*"); } }); b1 = new Block("") { @Override void onLayout(Layout layout) { layout.addComponent(logErrors); layout.addComponent(logStatus); } @Override void onChange() { logErrors.setReadOnly(false); logStatus.setReadOnly(false); } @Override void onRefresh() { boolean _logErrors = AdminServiceProvider.getBoolProperty(API.LOG_ERRORS); if (_logErrors) { logErrors.setReadOnly(false); logErrors.setValue(Arrays.asList(Status.FAILURE.name())); } else { logErrors.setValue(Collections.emptySet()); } logErrors.setReadOnly(true); String _logStatus = AdminServiceProvider.get().getSystemProperty(API.LOG_STATUS); if (_logStatus != null) { Set<String> set = new HashSet<String>(); for (String key : statusKeys()) { if (_logStatus.contains(key)) { set.add(key); } } logStatus.setReadOnly(false); logStatus.setValue(set); } else { logStatus.setValue(Collections.emptySet()); } logStatus.setReadOnly(true); } @Override void onApply() { Collection logErrorsValue = (Collection) logErrors.getValue(); boolean errorsEnabled = logErrorsValue.contains(Status.FAILURE.name()); AdminServiceProvider.get().saveSystemProperty(API.LOG_ERRORS, Boolean.toString(errorsEnabled)); LogCustomizer.setShouldWriteServerLogErrors(errorsEnabled); Collection logStatusValue = (Collection) logStatus.getValue(); Set<Status> statuses = new TreeSet<Status>(); if (logStatusValue.contains(Status.REQUEST.name())) { statuses.add(Status.REQUEST); statuses.add(Status.ACCEPT); statuses.add(Status.CANCEL); } if (logStatusValue.contains(Status.RESULT.name())) { statuses.add(Status.RESULT); statuses.add(Status.REJECT); statuses.add(Status.STATE); statuses.add(Status.NOTIFY); } if (logStatusValue.contains(Status.PING.name())) { statuses.add(Status.PING); statuses.add(Status.PROCESS); statuses.add(Status.PACKET); } StringBuilder statusBuilder = new StringBuilder(); for (Status status : statuses) { if (statusBuilder.length() > 0) { statusBuilder.append(", "); } statusBuilder.append(status); } String status = statusBuilder.toString(); AdminServiceProvider.get().saveSystemProperty(API.LOG_STATUS, status); LogCustomizer.setServerLogStatus(status); boolean enabled = !status.isEmpty(); LogCustomizer.setShouldWriteServerLog(enabled); AdminServiceProvider.get().saveSystemProperty(API.ENABLE_CLIENT_LOG, Boolean.toString(enabled)); } }; b2 = new Block("? ") { @Override void onLayout(Layout layout) { layout.addComponent(ipSet); } @Override void onRefresh() { String ips = AdminServiceProvider.get().getSystemProperty(API.SKIP_LOG_IPS); ipSet.setReadOnly(false); ipSet.setValue(ips); ipSet.setReadOnly(true); } @Override void onChange() { ipSet.setReadOnly(false); } @Override void onApply() { String value = (String) ipSet.getValue(); TreeSet<String> items = new TreeSet<String>(); if (value != null) { for (String item : value.split("[,;\\s]+")) { items.add(item); } StringBuilder sb = new StringBuilder(); for (String item : items) { if (sb.length() > 0) { sb.append(", "); } sb.append(item); } value = sb.toString(); } AdminServiceProvider.get().saveSystemProperty(API.SKIP_LOG_IPS, value); LogCustomizer.setIgnoreSet(items); } }; b3 = new Block("? ") { @Override void onButtons(Layout layout) { layout.addComponent(new Button("? ", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { LogScheduler.cleanLog(); getWindow().showNotification("?? ", Window.Notification.TYPE_HUMANIZED_MESSAGE); } })); } @Override void onLayout(Layout layout) { layout.addComponent(tf); } @Override void onRefresh() { String logDepth = AdminServiceProvider.get().getSystemProperty(API.LOG_DEPTH); tf.setReadOnly(false); if (logDepth != null && logDepth.matches("[1-9][0-9]*")) { tf.setValue(logDepth); } else { tf.setValue(String.valueOf(API.DEFAULT_LOG_DEPTH)); } tf.setReadOnly(true); } @Override void onChange() { tf.setReadOnly(false); } @Override void onApply() { tf.validate(); AdminServiceProvider.get().saveSystemProperty(API.LOG_DEPTH, tf.getValue().toString()); } }; final CheckBox logSpSign = new CheckBox(" ? "); logSpSign.setValue(Boolean.valueOf(AdminServiceProvider.get().getSystemProperty(API.LOG_SP_SIGN))); logSpSign.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { AdminServiceProvider.get().saveSystemProperty(API.LOG_SP_SIGN, String.valueOf(valueChangeEvent.getProperty().getValue())); notifySuccess(); } }); logSpSign.setImmediate(true); final CheckBox logOvSign = new CheckBox(" ? "); logOvSign.setValue(Boolean.valueOf(AdminServiceProvider.get().getSystemProperty(API.LOG_OV_SIGN))); logOvSign.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { AdminServiceProvider.get().saveSystemProperty(API.LOG_OV_SIGN, String.valueOf(valueChangeEvent.getProperty().getValue())); notifySuccess(); } }); logOvSign.setImmediate(true); Label userSignsLabel = new Label("? ?"); userSignsLabel.addStyleName(Reindeer.LABEL_H2); VerticalLayout userSignsVl = new VerticalLayout(); userSignsVl.setMargin(true); userSignsVl.setSpacing(true); userSignsVl.addComponent(userSignsLabel); userSignsVl.addComponent(logSpSign); userSignsVl.addComponent(logOvSign); Panel userSingsWrapper = new Panel(); userSingsWrapper.setScrollable(true); userSingsWrapper.setContent(userSignsVl); userSingsWrapper.setSizeFull(); VerticalLayout vl = new VerticalLayout(); vl.addComponent(b1); vl.addComponent(userSingsWrapper); vl.setExpandRatio(b1, 0.7f); vl.setExpandRatio(userSingsWrapper, 0.3f); vl.setSizeFull(); HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); layout.addComponent(vl); layout.addComponent(b2); layout.addComponent(b3); layout.setSizeFull(); layout.setExpandRatio(vl, 0.333f); layout.setExpandRatio(b2, 0.333f); layout.setExpandRatio(b3, 0.333f); Panel wrapper = new Panel(" ", layout); wrapper.addStyleName(Reindeer.PANEL_LIGHT); wrapper.setSizeFull(); setCompositionRoot(wrapper); setSizeFull(); }