List of usage examples for com.vaadin.ui HorizontalLayout setHeight
@Override public void setHeight(String height)
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.LinkCreationFormLayout.java
License:Mozilla Public License
public void initLayout() { setCaption(action.getCaption());/*from www .j a v a2 s. co m*/ // main window layout setWidth(FULL_SIZE); setMargin(true); setSpacing(true); final Form inputForm = new Form(); inputForm.setReadOnly(true); inputForm.setWidth(INPUT_FORM_WIDTH); addComponent(inputForm); inputForm.setImmediate(true); inputForm.setWriteThrough(false); // set up form data binding final LinkData linkData = new LinkData(fromInstance); linkData.setToInstance(S23MKernel.coreGraphs.vertex); //default target instance final BeanItem<LinkData> item = new BeanItem<LinkData>(linkData); inputForm.setItemDataSource(item); inputForm.setVisibleItemProperties(LinkData.getDisplayedInstances()); final HorizontalLayout buttonBarLayout = new HorizontalLayout(); buttonBarLayout.setSpacing(true); buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT); inputForm.getFooter().addComponent(buttonBarLayout); for (final String key : LinkData.getDisplayedInstances()) { inputForm.getField(key).setWidth(FIELD_WIDTH); } // drop handler final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm); targetWrapper.setWidth(FULL_SIZE); targetWrapper.setHeight(FULL_SIZE); targetWrapper.setDropHandler(new DropHandler() { public void drop(final DragAndDropEvent event) { final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable(); final TreeNode node = (TreeNode) t.getData("itemId"); inputForm.getItemDataSource().getItemProperty(LinkData.TO_INSTANCE).setValue(node.getSet()); inputForm.getField(LinkData.TARGET).requestRepaint(); } public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); addComponent(targetWrapper); //parent.getMainApplication().getContainmentTreePanel().setEditMode(true); //add all visible instances from the fromInstance //parent.getMainApplication().getContainmentTreePanel().getScopeMap() // .putAll(addAllVisibleInstanceUUIDs(fromInstance)); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); //((org.s23m.cell.editor.semanticdomain.Editor)getApplication()).updateContainmentTree(); final Button okBtn = new Button("OK", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { // create a new link instance final Set metaInstance = (action.equals(TreeActionHandler.ACTION_CREATE_VISIBILITY)) ? S23MKernel.coreGraphs.visibility : S23MKernel.coreGraphs.superSetReference; if (action.equals(TreeActionHandler.ACTION_CREATE_VISIBILITY) || action.equals(TreeActionHandler.ACTION_CREATE_SSR)) { final Set src = (Set) inputForm.getItemDataSource().getItemProperty(LinkData.FROM_INSTANCE) .getValue(); final Set trgt = (Set) inputForm.getItemDataSource().getItemProperty(LinkData.TO_INSTANCE) .getValue(); if (src != null && trgt != null) { final Set v = Instantiation.arrow(metaInstance, src, trgt); String msg = ""; if (!v.identity().isEqualTo( S23MSemanticDomains.semanticErr_TargetIsNotWithinVisibility.identity())) { inputForm.commit(); msg = "Successfully created a new link"; parent.getMainApplication().getMainWindow().showNotification(msg); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); parent.closeTab(LinkCreationFormLayout.this); } else { msg = "Failed creating a visibility link: " + v.identity().name(); parent.getMainApplication().getMainWindow().showNotification("Error", v.identity().name(), Notification.TYPE_ERROR_MESSAGE); } //parent.getMainApplication().getConsole().setValue( // parent.getMainApplication().getConsole().getValue() + msg // + "\n"); } } //parent.getMainApplication().getContainmentTreePanel().setEditMode(false); //parent.getMainApplication().getContainmentTreePanel().getScopeMap().clear(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); } }); final Button closeBtn = new Button("Cancel", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { inputForm.discard(); parent.getMainApplication().getContainmentTreePanel().setEditMode(false); parent.getMainApplication().getContainmentTreePanel().getScopeMap().clear(); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); //changeSupport.removePropertyChangeListener(EditorController.getInstance()); parent.closeTab(LinkCreationFormLayout.this); } }); buttonBarLayout.addComponent(okBtn); buttonBarLayout.addComponent(closeBtn); buttonBarLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.SemanticInstanceCreationFormLayout.java
License:Mozilla Public License
private void initLayout() { setCaption(action.getCaption());//from w w w . ja v a 2 s . c om setWidth(FULL_SIZE); setMargin(true); setSpacing(true); final Form inputForm = new Form(); inputForm.setReadOnly(true); inputForm.setWidth(INPUT_FORM_WIDTH); addComponent(inputForm); inputForm.setImmediate(true); inputForm.setWriteThrough(false); inputForm.setFormFieldFactory(new FormFieldFactory() { public Field createField(final Item item, final Object propertyId, final Component uiContext) { final String textLabel = DefaultFieldFactory.createCaptionByPropertyId(propertyId); final TextField f = new TextField(textLabel); if (propertyId.toString().equals(SemanticInstanceData.REFERENCED_SEMANTIC_IDENTITY_NAME)) { f.setRequiredError(textLabel + " is a mandatory field."); f.setRequired(true); } if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_DOMAIN)) { if (propertyId.toString().equals(SemanticInstanceData.NAME)) { f.setRequiredError(textLabel + " is a mandatory field."); f.setRequired(true); } } return f; } }); //set up form data binding final SemanticInstanceData formData = new SemanticInstanceData("", "", containerInstnace); final BeanItem<SemanticInstanceData> item = new BeanItem<SemanticInstanceData>(formData); inputForm.setItemDataSource(item); if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_ROLE)) { inputForm.setVisibleItemProperties(SemanticInstanceData.getDisplayedInstancesForSemanticRole()); } else { inputForm.setVisibleItemProperties(SemanticInstanceData.getDisplayedInstances()); } // drop handler final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm); targetWrapper.setWidth(INPUT_FORM_WIDTH); targetWrapper.setHeight(INPUT_FORM_WIDTH); targetWrapper.setDropHandler(new DropHandler() { public void drop(final DragAndDropEvent event) { final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable(); final TreeNode node = (TreeNode) t.getData("itemId"); inputForm.getItemDataSource().getItemProperty(SemanticInstanceData.REFERENCED_SEMANTIC_IDENTITY) .setValue(node.getSet()); inputForm.getField(SemanticInstanceData.REFERENCED_SEMANTIC_IDENTITY_NAME).requestRepaint(); } public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); addComponent(targetWrapper); final HorizontalLayout buttonBarLayout = new HorizontalLayout(); buttonBarLayout.setSpacing(true); buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT); inputForm.getFooter().addComponent(buttonBarLayout); final Button okBtn = new Button("OK", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_IDENTITY)) { inputForm.commit(); if (isAnonymousData(formData)) { Instantiation.addAnonymousDisjunctSemanticIdentitySet(formData.getSemanticDomain()); } else { Instantiation.addDisjunctSemanticIdentitySet(formData.getName(), formData.getPluralName(), formData.getSemanticDomain()); } closeOperation("New semantic identity is created"); } else if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_DOMAIN)) { inputForm.commit(); if (!isAnonymousData(formData)) { Instantiation.addSemanticDomain(formData.getName(), formData.getPluralName(), formData.getSemanticDomain()); closeOperation("New semantic domain is created"); } } else if (action.equals(TreeActionHandler.ACTION_ADD_SEMANTIC_ROLE)) { inputForm.commit(); if (formData.getReferencedSemanticIdentity() != null) { F_Transaction.commitChangedSets(); log.info("Changeset size " + org.s23m.cell.api.Query.changedSets().size()); if (isAnonymousData(formData)) { final Set r = Instantiation.addAnonymousSemanticRole(formData.getSemanticDomain(), formData.getReferencedSemanticIdentity()); log.info("AnonymousSemanticRole " + r.identity().uniqueRepresentationReference() + " created."); } else { final Set r = Instantiation.addSemanticRole(formData.getName(), formData.getPluralName(), formData.getSemanticDomain(), formData.getReferencedSemanticIdentity()); log.info("Semantic role " + r.identity().name() + " created."); } log.info("Changeset size after creation " + org.s23m.cell.api.Query.changedSets().size()); closeOperation("New semantic role is created"); } else { parentTab.getMainApplication().getMainWindow().showNotification( "Missing referenced semantic identity", Window.Notification.TYPE_ERROR_MESSAGE); } } } catch (final EmptyValueException th) { } } private void closeOperation(final String message) { parentTab.getMainApplication().getMainWindow().showNotification(message); ((Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); //changeSupport.removePropertyChangeListener(EditorController.getInstance()); parentTab.closeTab(SemanticInstanceCreationFormLayout.this); } }); final Button cancelBtn = new Button("Cancel", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { inputForm.discard(); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); changeSupport.removePropertyChangeListener(EditorController.getInstance()); parentTab.closeTab(SemanticInstanceCreationFormLayout.this); } }); buttonBarLayout.addComponent(okBtn); buttonBarLayout.addComponent(cancelBtn); buttonBarLayout.setComponentAlignment(cancelBtn, Alignment.TOP_RIGHT); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.VertexCreationFormLayout.java
License:Mozilla Public License
private void createInputForm() { setCaption(action.getCaption());/* w ww.j av a 2s . co m*/ setWidth(WINDOW_WIDTH); setMargin(true); setSpacing(true); final Form inputForm = new Form(); inputForm.setWidth(INPUT_FORM_WIDTH); addComponent(inputForm); inputForm.setImmediate(true); inputForm.setWriteThrough(false); final InstantiationData instData = new InstantiationData(metaInstance, containerInstance.identity().name(), false, "", ""); final BeanItem<InstantiationData> instItem = new BeanItem<InstantiationData>(instData); inputForm.setItemDataSource(instItem); inputForm.setVisibleItemProperties(InstantiationData.getDisplayOrder()); // drop handler final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm); targetWrapper.setWidth(WINDOW_WIDTH); targetWrapper.setHeight("100%"); targetWrapper.setDropHandler(new DropHandler() { public void drop(final DragAndDropEvent event) { final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable(); final TreeNode node = (TreeNode) t.getData("itemId"); if (SetType.isSemanticDomainNode(node.getSet())) { instData.setIdentity(node.getSet()); inputForm.getField(InstantiationData.NAME).requestRepaint(); inputForm.getField(InstantiationData.PLURAL_NAME).requestRepaint(); inputForm.setComponentError(null); } else { inputForm.getItemDataSource().getItemProperty(InstantiationData.METAINSTANCE) .setValue(node.getSet()); inputForm.getField(InstantiationData.METAINSTANCE_NAME).requestRepaint(); } } public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); addComponent(targetWrapper); final HorizontalLayout okbar = new HorizontalLayout(); okbar.setSpacing(true); okbar.setHeight(BUTTON_BAR_HEIGHT); inputForm.getFooter().addComponent(okbar); for (final String key : InstantiationData.getDisplayOrder()) { inputForm.getField(key).setWidth(FIELD_WIDTH); } final Button okBtn = new Button(OK_BUTTON_TEXT, new Button.ClickListener() { public void buttonClick(final ClickEvent event) { //create a new instance inputForm.commit(); if (!checkForEmptyInstances(instData)) { Set s = null; String msgCaption = ""; if (action.equals(TreeActionHandler.ACTION_ADD)) { msgCaption = INSTANCE_ADDITION_MSG; if (instData.isAbstract()) { ; s = containerInstance.addAbstract(instData.getMetaInstance(), instData.getIdentity()); } else { s = containerInstance.addConcrete(instData.getMetaInstance(), instData.getIdentity()); } } else if (action.equals(TreeActionHandler.ACTION_INSTANTIATE)) { msgCaption = INSTANCE_INSTANTIATION_MSG; if (instData.isAbstract()) { s = Instantiation.instantiateAbstract(metaInstance, instData.getIdentity()); } else { s = Instantiation.instantiateConcrete(metaInstance, instData.getIdentity()); } } if (s != null && s.identity().name().equals(instData.getName())) { parent.getMainApplication().getMainWindow().showNotification(msgCaption); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); //changeSupport.removePropertyChangeListener(EditorController.getInstance()); parent.closeTab(VertexCreationFormLayout.this); } else { parent.getMainApplication().getMainWindow().showNotification("Error", s.identity().name(), Notification.TYPE_ERROR_MESSAGE); } } } private boolean checkForEmptyInstances(final InstantiationData instData) { boolean gotEmptyValue = false; if (instData.getMetaInstance() == null) { inputForm.setComponentError(new UserError( DefaultFieldFactory.createCaptionByPropertyId(InstantiationData.METAINSTANCE) + " is missing.")); gotEmptyValue = true; } if (instData.getIdentity() == null) { inputForm.setComponentError( new UserError(DefaultFieldFactory.createCaptionByPropertyId(InstantiationData.IDENTITY) + " is missing.")); gotEmptyValue = true; } return gotEmptyValue; } }); final Button closeBtn = new Button(CANCEL_BUTTON_TEXT, new Button.ClickListener() { public void buttonClick(final ClickEvent event) { inputForm.discard(); ((org.s23m.cell.editor.semanticdomain.Editor) getApplication()).updateContainmentTree(); //changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null); changeSupport.removePropertyChangeListener(EditorController.getInstance()); parent.closeTab(VertexCreationFormLayout.this); } }); okbar.addComponent(okBtn); okbar.addComponent(closeBtn); okbar.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.MultitabPanel.java
License:Mozilla Public License
private void createMultitabPanel() { addStyleName(Runo.PANEL_LIGHT);/* w w w . ja v a2 s . c o m*/ getLayout().setMargin(true); // Search results tab content searchResultPanel = new Panel(); final VerticalLayout searchLayer = new VerticalLayout(); searchLayer.setHeight(SEARCH_RESULTS_PANEL_HEIGHT); searchResultPanel.addStyleName(Runo.PANEL_LIGHT); searchLayer.addComponent(searchResultPanel); // Details form tab content final VerticalLayout detailsFormLayout = new VerticalLayout(); detailsFormLayout.setMargin(true); detailsForm = new Form() { @SuppressWarnings("unchecked") @Override public void setReadOnly(final boolean readOnly) { super.setReadOnly(readOnly); final BeanItem<DetailsData> dataSrc = (BeanItem<DetailsData>) detailsForm.getItemDataSource(); final Set detailsInstance = dataSrc.getBean().getInstance(); if (!InstanceGetter.hasModifiableName(detailsInstance)) { for (final String id : DetailsData.getNameFieldIds()) { final Field f = detailsForm.getField(id); f.setReadOnly(true); } } } }; detailsForm.setCaption("Instance Details"); detailsForm.setImmediate(true); detailsForm.setWriteThrough(false); final DetailsData detailsData = new DetailsData(Root.root); final BeanItem<DetailsData> detailsItem = new BeanItem<DetailsData>(detailsData); final FormFieldFactory formFieldFactory = new PanelFormFieldFactory(); detailsForm.setFormFieldFactory(formFieldFactory); //addImageUploadControls(detailsData); detailsForm.setItemDataSource(detailsItem); detailsForm.setVisibleItemProperties(DetailsData.getDisplayOrder()); detailsForm.setFooter(new VerticalLayout()); final HorizontalLayout formButtonBar = new HorizontalLayout(); formButtonBar.setSpacing(true); formButtonBar.setHeight(BUTTON_BAR_HEIGHT); final Layout footer = detailsForm.getFooter(); footer.addComponent(formButtonBar); editBtn = new Button(EDIT_BUTTON_LABEL, this, FORM_EVENT_HANDLER); saveBtn = new Button(SAVE_BUTTON_LABEL, this, FORM_EVENT_HANDLER); saveBtn.setVisible(false); cancelBtn = new Button(CANCEL_BUTTON_LABEL, this, FORM_EVENT_HANDLER); cancelBtn.setVisible(false); formButtonBar.addComponent(editBtn); formButtonBar.setComponentAlignment(editBtn, Alignment.TOP_RIGHT); formButtonBar.addComponent(saveBtn); formButtonBar.addComponent(cancelBtn); detailsFormLayout.addComponent(detailsForm); tabSheet = new TabSheet(); tabSheet.setWidth(TAB_SHEET_WIDTH_RATIO); tabSheet.setHeight("90%"); tabSheet.addTab(searchLayer, SEARCH_TAB_LABEL, EditorIcon.SEARCH.getIconImage()); tabSheet.addTab(detailsFormLayout, DETAILS_TAB_LABEL, EditorIcon.DETAILS.getIconImage()); tabSheet.addTab(new AdminFormLayout(this), ADMIN_TAB_LABEL, EditorIcon.ADMIN.getIconImage()); //tabSheet.addTab(new GraphVisualizationLayout(this), VISUALIZATION_TAB, EditorIcon.ADMIN.getIconImage()); addComponent(tabSheet); }
From source file:org.vaadin.dialogs.DefaultConfirmDialogFactory.java
License:Mozilla Public License
public ConfirmDialog create(final String caption, final String message, final String okCaption, final String cancelCaption) { // Create a confirm dialog final ConfirmDialog confirm = new ConfirmDialog(); confirm.setCaption(caption != null ? caption : DEFAULT_CAPTION); // Close listener implementation confirm.addListener(new Window.CloseListener() { private static final long serialVersionUID = 1971800928047045825L; public void windowClose(CloseEvent ce) { // Only process if still enabled if (confirm.isEnabled()) { confirm.setEnabled(false); // avoid double processing confirm.setConfirmed(false); if (confirm.getListener() != null) { confirm.getListener().onClose(confirm); }//from w w w. ja va 2s . c o m } } }); // Create content VerticalLayout c = (VerticalLayout) confirm.getContent(); c.setSizeFull(); c.setSpacing(true); // Panel for scrolling lengthty messages. Panel scroll = new Panel(new VerticalLayout()); scroll.setScrollable(true); c.addComponent(scroll); scroll.setWidth("100%"); scroll.setHeight("100%"); scroll.setStyleName(Reindeer.PANEL_LIGHT); c.setExpandRatio(scroll, 1f); // Always HTML, but escape Label text = new Label("", Label.CONTENT_RAW); scroll.addComponent(text); confirm.setMessageLabel(text); confirm.setMessage(message); HorizontalLayout buttons = new HorizontalLayout(); c.addComponent(buttons); buttons.setSpacing(true); buttons.setHeight(format(BUTTON_HEIGHT) + "em"); buttons.setWidth("100%"); Label spacerLeft = new Label(""); buttons.addComponent(spacerLeft); spacerLeft.setWidth("100%"); buttons.setExpandRatio(spacerLeft, 1f); final Button cancel = new Button(cancelCaption != null ? cancelCaption : DEFAULT_CANCEL_CAPTION); cancel.setData(false); cancel.setClickShortcut(KeyCode.ESCAPE, null); buttons.addComponent(cancel); confirm.setCancelButton(cancel); final Button ok = new Button(okCaption != null ? okCaption : DEFAULT_OK_CAPTION); ok.setData(true); ok.setClickShortcut(KeyCode.ENTER, null); ok.focus(); buttons.addComponent(ok); confirm.setOkButton(ok); Label spacerRight = new Label(""); buttons.addComponent(spacerRight); spacerRight.setWidth("100%"); buttons.setExpandRatio(spacerRight, 1f); // Create a listener for buttons Button.ClickListener cb = new Button.ClickListener() { private static final long serialVersionUID = 3525060915814334881L; public void buttonClick(ClickEvent event) { // Copy the button date to window for passing through either // "OK" or "CANCEL". Only process id still enabled. if (confirm.isEnabled()) { confirm.setEnabled(false); // Avoid double processing confirm.setConfirmed(event.getButton() == ok); // We need to cast this way, because of the backward // compatibility issue in 6.4 series. Component parent = confirm.getParent(); if (parent instanceof Window) { try { Method m = Window.class.getDeclaredMethod("removeWindow", Window.class); m.invoke(parent, confirm); } catch (Exception e) { throw new RuntimeException( "Failed to remove confirmation dialog from the parent window.", e); } } // This has to be invoked as the window.close // event is not fired when removed. if (confirm.getListener() != null) { confirm.getListener().onClose(confirm); } } } }; cancel.addListener(cb); ok.addListener(cb); // Approximate the size of the dialog double[] dim = getDialogDimensions(message, ConfirmDialog.CONTENT_TEXT_WITH_NEWLINES); confirm.setWidth(format(dim[0]) + "em"); confirm.setHeight(format(dim[1]) + "em"); confirm.setResizable(false); return confirm; }
From source file:org.vaadin.training.fundamentals.happening.ui.NavigationComponent.java
License:Apache License
@SuppressWarnings("serial") private void buildLayout() { HorizontalLayout header = new HorizontalLayout(); header.setWidth("100%"); header.setHeight("50px"); Label appName = new Label("Happening Application Header"); header.addComponent(appName);/* w ww . j av a 2s . com*/ NativeButton listButton = new NativeButton("List"); listButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { setCurrentView(ListHappeningsView.class, null); } }); NativeButton addButton = new NativeButton("Add"); addButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { setCurrentView(AddNewView.class, null); } }); NativeButton logoutButton = new NativeButton("Logout"); logoutButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { getApplication().close(); } }); header.addComponent(listButton); header.addComponent(addButton); header.addComponent(logoutButton); addComponent(header); }
From source file:probe.com.view.body.quantcompare.PieChart.java
public PieChart(String title, double full, double found, final String notfound) { this.setWidth(200 + "px"); this.setHeight(200 + "px"); defaultKeyColorMap.put("Found", new Color(110, 177, 206)); defaultKeyColorMap.put("Not found", new Color(219, 169, 1)); otherSymbols.setGroupingSeparator('.'); this.setStyleName("click"); labels = new String[] { "Found", "Not found" }; double foundPercent = ((found / full) * 100.0); df = new DecimalFormat("#.##", otherSymbols); valuesMap.put("Found", ((int) found) + " (" + df.format(foundPercent) + "%)"); values = new Double[] { foundPercent, 100.0 - foundPercent }; valuesMap.put("Not found", ((int) (full - found)) + " (" + df.format(100.0 - foundPercent) + "%)"); String defaultImgURL = initPieChart(200, 200, title); chartImg.setSource(new ExternalResource(defaultImgURL)); this.addComponent(chartImg); this.addLayoutClickListener(PieChart.this); popupLayout = new PopupView(null, popupBody); popupLayout.setHideOnMouseOut(false); popupBody.setWidth("300px"); popupBody.setStyleName(Reindeer.LAYOUT_WHITE); popupBody.setHeightUndefined();/*from w w w . j av a2s .c om*/ this.addComponent(popupLayout); this.notfound = notfound.replace(" ", "").replace(",", "/n"); HorizontalLayout topLayout = new HorizontalLayout(); topLayout.setWidth("100%"); topLayout.setHeight("20px"); Label header = new Label("<b>Not Found (New Proteins)</b>"); header.setStyleName(Reindeer.LABEL_SMALL); topLayout.addComponent(header); header.setContentMode(ContentMode.HTML); VerticalLayout closeBtn = new VerticalLayout(); closeBtn.setWidth("10px"); closeBtn.setHeight("10px"); closeBtn.setStyleName("closebtn"); topLayout.addComponent(closeBtn); topLayout.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT); closeBtn.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { popupLayout.setPopupVisible(false); } }); popupBody.addComponent(topLayout); popupBody.addComponent(textArea); textArea.setWidth("100%"); textArea.setHeight("150px"); textArea.setValue(this.notfound); textArea.setReadOnly(true); popupBody.setSpacing(true); HorizontalLayout bottomLayout = new HorizontalLayout(); bottomLayout.setWidth("100%"); bottomLayout.setHeight("40px"); bottomLayout.setMargin(new MarginInfo(false, true, true, true)); popupBody.addComponent(bottomLayout); Button exportTableBtn = new Button(""); exportTableBtn.setHeight("24px"); exportTableBtn.setWidth("24px"); exportTableBtn.setPrimaryStyleName("exportxslbtn"); exportTableBtn.setDescription("Export table data"); exportTableBtn.addClickListener(new Button.ClickListener() { private Table table; @Override public void buttonClick(Button.ClickEvent event) { if (table == null) { table = new Table(); table.addContainerProperty("Index", Integer.class, null, "", null, Table.Align.RIGHT); table.addContainerProperty("Accession", String.class, Table.Align.CENTER); table.setVisible(false); addComponent(table); int i = 1; for (String str : notfound.replace(" ", "").replace(",", "\n").split("\n")) { table.addItem(new Object[] { i, str }, i++); } } ExcelExport csvExport = new ExcelExport(table, "Not found protein accessions (New proteins)"); // csvExport.setReportTitle("CSF-PR / Not found protein accessions (New proteins) "); csvExport.setExportFileName("CSF-PR - Not found protein accessions" + ".xls"); csvExport.setMimeType(CsvExport.EXCEL_MIME_TYPE); csvExport.setDisplayTotals(false); csvExport.setExcelFormatOfProperty("Index", "#0;[Red] #0"); csvExport.export(); } }); bottomLayout.addComponent(exportTableBtn); bottomLayout.setComponentAlignment(exportTableBtn, Alignment.MIDDLE_RIGHT); }
From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.interactivepiechartfilters.StudiesPieChartFiltersContainerLayout.java
/** * * @param Quant_Central_Manager/*from w ww .j a v a 2 s.co m*/ * @param handler */ public StudiesPieChartFiltersContainerLayout(QuantCentralManager Quant_Central_Manager, final CSFPRHandler handler) { int layoutHeight = Page.getCurrent().getBrowserWindowHeight() - 200; int layoutWidth = Page.getCurrent().getBrowserWindowWidth() - 200; this.setWidth(layoutWidth + "px"); this.setHeight(layoutHeight + "px"); int filterWidth = layoutWidth / 3; this.setSpacing(true); boolean[] activeFilters = Quant_Central_Manager.getActiveFilters(); Map<Integer, QuantDatasetObject> quantDatasetArr = Quant_Central_Manager.getFilteredDatasetsList(); internalSelectionManager = new PieChartsSelectionManager(Quant_Central_Manager); if (quantDatasetArr == null) { return; } this.setRows(4); this.setColumns(4); int colCounter = 0; int rowCounter = 0; this.chartSet.clear(); for (int x = 0; x < activeFilters.length; x++) { String filterId = ""; if (activeFilters[x]) { Map<String, List<Integer>> dsIndexesMap = new HashMap<String, List<Integer>>(); // List<Object> valueSet = new ArrayList<Object>(); switch (x) { case 0: // filterId = "identifiedProteinsNumber"; // for (QuantDatasetObject pb : quantDatasetArr) { // if (pb == null) { // continue; // } // int value = pb.getIdentifiedProteinsNumber(); // valueSet.add(value); // } break; case 1: // filterId = "quantifiedProteinsNumber"; // for (QuantDatasetObject pb : quantDatasetArr) { // if (pb == null) { // continue; // } // int value = pb.getQuantifiedProteinsNumber(); // valueSet.add(value); // // } break; case 2: // filterId = "analyticalMethod"; // for (QuantDatasetObject pb : quantDatasetArr.values()) { // if (pb == null) { // continue; // } // String value = pb.getAnalyticalMethod(); // valueSet.add(value); // // } break; case 3: // filterId = "rawDataUrl"; // for (QuantDatasetObject pb : quantDatasetArr.values()) { // // if (pb == null) { // continue; // } // if (!dsIndexesMap.containsKey(pb.getRawDataUrl())) { // List<Integer> list = new ArrayList<Integer>(); // dsIndexesMap.put(pb.getRawDataUrl(), list); // // } // List<Integer> list = dsIndexesMap.get(pb.getRawDataUrl()); // list.add(pb.getUniqId()); // dsIndexesMap.put(pb.getRawDataUrl(), list); // valueSet.add(pb.getRawDataUrl()); // // } break; case 4: filterId = "year"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } if (!dsIndexesMap.containsKey(pb.getYear() + "")) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(pb.getYear() + "", list); } List<Integer> list = dsIndexesMap.get(pb.getYear() + ""); list.add(pb.getDsKey()); dsIndexesMap.put(pb.getYear() + "", list); int value = pb.getYear(); // valueSet.add(value); } break; case 5: filterId = "typeOfStudy"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } if (!dsIndexesMap.containsKey(pb.getTypeOfStudy())) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(pb.getTypeOfStudy(), list); } if (pb.getTypeOfStudy().trim().equalsIgnoreCase("")) { pb.setTypeOfStudy("Not Available"); } List<Integer> list = dsIndexesMap.get(pb.getTypeOfStudy()); list.add(pb.getDsKey()); dsIndexesMap.put(pb.getTypeOfStudy(), list); String value = pb.getTypeOfStudy(); // valueSet.add(value); } break; case 6: filterId = "sampleType"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } if (pb.getSampleType().trim().equalsIgnoreCase("")) { pb.setSampleType("Not Available"); } if (!dsIndexesMap.containsKey(pb.getSampleType())) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(pb.getSampleType(), list); } List<Integer> list = dsIndexesMap.get(pb.getSampleType()); list.add(pb.getDsKey()); dsIndexesMap.put(pb.getSampleType(), list); String value = pb.getSampleType(); // valueSet.add(value); } break; case 7: filterId = "sampleMatching"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } if (pb.getSampleMatching().trim().equalsIgnoreCase("")) { pb.setSampleMatching("Not Available"); } if (!dsIndexesMap.containsKey(pb.getSampleMatching())) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(pb.getSampleMatching(), list); } List<Integer> list = dsIndexesMap.get(pb.getSampleMatching()); list.add(pb.getDsKey()); dsIndexesMap.put(pb.getSampleMatching(), list); String value = pb.getSampleMatching(); // valueSet.add(value); } break; case 8: filterId = "technology"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getTechnology(); if (value == null || value.equalsIgnoreCase("")) { value = "Not Available"; } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(value); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 9: filterId = "analyticalApproach"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getAnalyticalApproach(); if (value == null || value.trim().equalsIgnoreCase("")) { pb.setAnalyticalApproach("Not Available"); value = "Not Available"; } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(pb.getAnalyticalApproach()); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 10: filterId = "enzyme"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getEnzyme(); if (value == null || value.trim().equalsIgnoreCase("")) { value = "Not Available"; pb.setEnzyme(value); } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(value); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 11: filterId = "shotgunTargeted"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getShotgunTargeted(); if (value == null || value.trim().equalsIgnoreCase("")) { value = "Not Available"; pb.setShotgunTargeted(value); } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(value); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 12: // filterId = "quantificationBasis"; // for (QuantDatasetObject pb : quantDatasetArr.values()) { // if (pb == null) { // continue; // } // String value = pb.getQuantificationBasis(); // if (value == null || value.trim().equalsIgnoreCase("")) { // value = "Not Available"; // pb.setQuantificationBasis(value); // } // if (!dsIndexesMap.containsKey(value)) { // List<Integer> list = new ArrayList<Integer>(); // dsIndexesMap.put(value, list); // // } // List<Integer> list = dsIndexesMap.get(value); // list.add(pb.getDsKey()); // dsIndexesMap.put(value, list); // valueSet.add(value); // } break; case 13: filterId = "quantBasisComment"; for (QuantDatasetObject pb : quantDatasetArr.values()) { if (pb == null) { continue; } String value = pb.getQuantBasisComment(); if (value == null || value.trim().equalsIgnoreCase("")) { value = "Not Available"; pb.setQuantBasisComment(value); } if (!dsIndexesMap.containsKey(value)) { List<Integer> list = new ArrayList<Integer>(); dsIndexesMap.put(value, list); } List<Integer> list = dsIndexesMap.get(value); list.add(pb.getDsKey()); dsIndexesMap.put(value, list); // valueSet.add(value); } break; case 14: // for (QuantDatasetObject pb : QuantDatasetListObject) { // int value = pb.getQuantifiedProteinsNumber(); // valueSet.add(value); // } break; case 15: // for (QuantDatasetObject pb : QuantDatasetListObject) { // int value = pb.getPatientsGroup1Number(); // valueSet.add(value); // } break; case 16: // for (QuantDatasetObject pb : QuantDatasetListObject) { // int value = pb.getPatientsGroup2Number(); // valueSet.add(value); // } break; case 17: // for (QuantDatasetObject pb : QuantDatasetListObject) { // String value = pb.getNormalizationStrategy(); // valueSet.add(value); // } break; } // if (!valueSet.isEmpty()) { //do we need valueSet;; JfreeDivaPieChartFilter iFilter = new JfreeDivaPieChartFilter(filterId, x, internalSelectionManager, dsIndexesMap, filterWidth); chartSet.add(iFilter.getChart()); // fullFilterList.put(filterId, valueSet); this.addComponent(iFilter, colCounter++, rowCounter); this.setComponentAlignment(iFilter, Alignment.MIDDLE_CENTER); if (colCounter == 3) { colCounter = 0; rowCounter++; } } // } } Quant_Central_Manager.setStudiesOverviewPieChart(chartSet); HorizontalLayout btnLayout = new HorizontalLayout(); btnLayout.setHeight("23px"); btnLayout.setWidthUndefined(); btnLayout.setSpacing(true); btnLayout.setStyleName(Reindeer.LAYOUT_WHITE); if (colCounter == 3) { this.addComponent(btnLayout, 2, ++rowCounter); } else { this.addComponent(btnLayout, 2, rowCounter); } this.setComponentAlignment(btnLayout, Alignment.MIDDLE_CENTER); Button applyFilters = new Button("Apply"); applyFilters.setDescription("Apply the selected filters"); applyFilters.setPrimaryStyleName("resetbtn"); applyFilters.setWidth("50px"); applyFilters.setHeight("24px"); btnLayout.addComponent(applyFilters); applyFilters.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { pieChartFiltersBtn.closePupupWindow(); } }); // Button unselectAllBtn = new Button("Unselect All"); // unselectAllBtn.setStyleName(Reindeer.BUTTON_SMALL); // btnLayout.addComponent(unselectAllBtn); // unselectAllBtn.addClickListener(new Button.ClickListener() { // // @Override // public void buttonClick(Button.ClickEvent event) { // // internalSelectionManager.unselectAll(); // // } // }); // Button unselectAllBtn = new Button("Clear"); unselectAllBtn.setPrimaryStyleName("resetbtn"); unselectAllBtn.setWidth("50px"); unselectAllBtn.setHeight("24px"); btnLayout.addComponent(unselectAllBtn); btnLayout.setComponentAlignment(unselectAllBtn, Alignment.TOP_LEFT); unselectAllBtn.setDescription("Clear All Selections"); unselectAllBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { internalSelectionManager.unselectAll(); } }); Button resetFiltersBtn = new Button("Reset"); resetFiltersBtn.setPrimaryStyleName("resetbtn"); resetFiltersBtn.setWidth("50px"); resetFiltersBtn.setHeight("24px"); btnLayout.addComponent(resetFiltersBtn); resetFiltersBtn.setDescription("Reset all applied filters"); resetFiltersBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { internalSelectionManager.resetToInitState(); internalSelectionManager.resetCentralSelectionManager(); } }); Button exportChartsBtn = new Button(""); exportChartsBtn.setWidth("24px"); exportChartsBtn.setHeight("24px"); exportChartsBtn.setPrimaryStyleName("exportpdfbtn"); btnLayout.addComponent(exportChartsBtn); exportChartsBtn.setDescription("Export all charts filters as pdf file"); // exportChartsBtn.addClickListener(new Button.ClickListener() { // @Override // public void buttonClick(Button.ClickEvent event) { // String url = handler.exportImgAsPdf(chartSet, "piechart_filters.pdf"); // FileResource res = new FileResource(new File(url)); // Page.getCurrent().open(res, "_blank", true); // } // }); StreamResource myResource = createResource(handler); FileDownloader fileDownloader = new FileDownloader(myResource); fileDownloader.extend(exportChartsBtn); pieChartFiltersBtn = new PopupInteractiveDSFiltersLayout(this); }
From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.PopupRecombineDiseaseGroups.java
private void initPopupLayout() { int h = 0;//(default_DiseaseCat_DiseaseGroupMap.size() * 33) + 300; for (Map<String, String> m : default_DiseaseCat_DiseaseGroupMap.values()) { if (h < m.size()) { h = m.size();/*from ww w .java2s . c om*/ } } h = (h * 26) + 200; int w = 700; if (Page.getCurrent().getBrowserWindowHeight() - 280 < h) { h = Page.getCurrent().getBrowserWindowHeight() - 280; } if (Page.getCurrent().getBrowserWindowWidth() < w) { w = Page.getCurrent().getBrowserWindowWidth(); } popupWindow.setWidth(w + "px"); popupWindow.setHeight(h + "px"); popupBodyLayout.setWidth((w - 50) + "px"); Set<String> diseaseSet = Quant_Central_Manager.getDiseaseCategorySet(); diseaseTypeSelectionList.setDescription("Select disease category"); for (String disease : diseaseSet) { diseaseTypeSelectionList.addItem(disease); diseaseTypeSelectionList.setItemCaption(disease, (disease)); } HorizontalLayout diseaseCategorySelectLayout = new HorizontalLayout(); diseaseCategorySelectLayout.setWidthUndefined(); diseaseCategorySelectLayout.setHeight("50px"); diseaseCategorySelectLayout.setSpacing(true); diseaseCategorySelectLayout.setMargin(true); popupBodyLayout.addComponent(diseaseCategorySelectLayout); popupBodyLayout.setComponentAlignment(diseaseCategorySelectLayout, Alignment.TOP_LEFT); Label title = new Label("Disease Category"); title.setStyleName(Reindeer.LABEL_SMALL); diseaseCategorySelectLayout.addComponent(title); diseaseCategorySelectLayout.setComponentAlignment(title, Alignment.BOTTOM_CENTER); diseaseTypeSelectionList.setWidth("200px"); diseaseTypeSelectionList.setNullSelectionAllowed(false); diseaseTypeSelectionList.setValue("All"); diseaseTypeSelectionList.setImmediate(true); diseaseCategorySelectLayout.addComponent(diseaseTypeSelectionList); diseaseCategorySelectLayout.setComponentAlignment(diseaseTypeSelectionList, Alignment.TOP_LEFT); diseaseTypeSelectionList.setStyleName("diseaseselectionlist"); diseaseTypeSelectionList.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { boolean showAll = false; String value = event.getProperty().getValue().toString(); if (value.equalsIgnoreCase("All")) { showAll = true; } for (String dName : diseaseGroupsGridLayoutMap.keySet()) { if (dName.equalsIgnoreCase(value) || showAll) { diseaseGroupsGridLayoutMap.get(dName).setVisible(true); } else { diseaseGroupsGridLayoutMap.get(dName).setVisible(false); } } } }); VerticalLayout diseaseGroupsNamesContainer = new VerticalLayout(); diseaseGroupsNamesContainer.setWidth("100%"); diseaseGroupsNamesContainer.setHeightUndefined(); popupBodyLayout.addComponent(diseaseGroupsNamesContainer); diseaseGroupsNamesContainer.setStyleName(Reindeer.LAYOUT_WHITE); GridLayout diseaseNamesHeader = new GridLayout(2, 1); diseaseNamesHeader.setWidth("100%"); diseaseNamesHeader.setHeightUndefined(); diseaseNamesHeader.setSpacing(true); diseaseNamesHeader.setMargin(new MarginInfo(true, false, true, false)); diseaseGroupsNamesContainer.addComponent(diseaseNamesHeader); Label col1Label = new Label("Group Name"); diseaseNamesHeader.addComponent(col1Label, 0, 0); col1Label.setStyleName(Reindeer.LABEL_SMALL); Label col2Label = new Label("Suggested Name"); diseaseNamesHeader.addComponent(col2Label, 1, 0); col2Label.setStyleName(Reindeer.LABEL_SMALL); Panel diseaseGroupsNamesFrame = new Panel(); diseaseGroupsNamesFrame.setWidth("100%"); diseaseGroupsNamesFrame.setHeight((h - 200) + "px"); diseaseGroupsNamesContainer.addComponent(diseaseGroupsNamesFrame); diseaseGroupsNamesFrame.setStyleName(Reindeer.PANEL_LIGHT); VerticalLayout diseaseNamesUpdateContainerLayout = new VerticalLayout(); for (String diseaseCategory : diseaseSet) { if (diseaseCategory.equalsIgnoreCase("All")) { continue; } HorizontalLayout diseaseNamesUpdateContainer = initDiseaseNamesUpdateContainer(diseaseCategory); diseaseNamesUpdateContainerLayout.addComponent(diseaseNamesUpdateContainer); diseaseGroupsGridLayoutMap.put(diseaseCategory, diseaseNamesUpdateContainer); } diseaseGroupsNamesFrame.setContent(diseaseNamesUpdateContainerLayout); HorizontalLayout btnLayout = new HorizontalLayout(); btnLayout.setMargin(true); btnLayout.setSpacing(true); Button resetFiltersBtn = new Button("Reset"); resetFiltersBtn.setPrimaryStyleName("resetbtn"); btnLayout.addComponent(resetFiltersBtn); resetFiltersBtn.setWidth("50px"); resetFiltersBtn.setHeight("24px"); resetFiltersBtn.setDescription("Reset group names to default"); resetFiltersBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { resetToDefault(); } }); Button resetToOriginalBtn = new Button("Publications Names"); resetToOriginalBtn.setPrimaryStyleName("resetbtn"); btnLayout.addComponent(resetToOriginalBtn); resetToOriginalBtn.setWidth("150px"); resetToOriginalBtn.setHeight("24px"); resetToOriginalBtn.setDescription("Reset group names to original publication names"); resetToOriginalBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { resetToPublicationsNames(); } }); Button applyFilters = new Button("Update"); applyFilters.setDescription("Update disease groups with the selected names"); applyFilters.setPrimaryStyleName("resetbtn"); applyFilters.setWidth("50px"); applyFilters.setHeight("24px"); btnLayout.addComponent(applyFilters); applyFilters.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { updateGroups(); } }); popupBodyLayout.addComponent(btnLayout); popupBodyLayout.setComponentAlignment(btnLayout, Alignment.MIDDLE_RIGHT); resetToDefault(); }
From source file:probe.com.view.body.quantdatasetsoverview.quantproteinscomparisons.TrendLegend.java
private HorizontalLayout generateItemLabel(String label, String style) { HorizontalLayout labelLayout = new HorizontalLayout(); labelLayout.setSpacing(true);//from w w w . ja va 2 s .c o m labelLayout.setHeight("20px"); VerticalLayout icon = new VerticalLayout(); icon.setWidth("10px"); icon.setHeight("10px"); icon.setStyleName(style); labelLayout.addComponent(icon); labelLayout.setComponentAlignment(icon, Alignment.MIDDLE_LEFT); Label l = new Label("<font size='2' face='Verdana'>" + label + "</font>"); l.setContentMode(ContentMode.HTML); labelLayout.addComponent(l); return labelLayout; }