List of usage examples for com.vaadin.ui Component setVisible
public void setVisible(boolean visible);
From source file:com.mymita.vaadlets.VaadletsBuilder.java
License:Apache License
private static void setComponentAttributes(final com.vaadin.ui.Component vaadinComponent, final com.mymita.vaadlets.core.Component c) { vaadinComponent.setCaption(c.getCaption()); vaadinComponent.setEnabled(c.isEnabled()); vaadinComponent.setReadOnly(c.isReadonly()); vaadinComponent.setVisible(c.isVisible()); if (c.getHeight() != null) { vaadinComponent.setHeight(c.getHeight()); }/*from w w w. j a v a2 s .c om*/ if (c.getWidth() != null) { vaadinComponent.setWidth(c.getWidth()); } if (c.isSizeUndefined() != null && c.isSizeUndefined().booleanValue()) { vaadinComponent.setSizeUndefined(); } if (c.isSizeFull() != null && c.isSizeFull().booleanValue()) { vaadinComponent.setSizeFull(); } }
From source file:com.ocs.dynamo.ui.composite.form.ModelBasedEditForm.java
License:Apache License
public void setEntity(T entity) { this.entity = entity; setViewMode(getFormOptions().isOpenInViewMode() && entity.getId() != null); // recreate the group BeanItem<T> beanItem = new BeanItem<T>(entity); groups.get(isViewMode()).setItemDataSource(beanItem); // "rebuild" so that the correct layout is displayed build();/*from www.ja v a 2 s. c o m*/ // reconstruct all labels (since they cannot be bound automatically) for (Entry<AttributeModel, Component> e : labels.get(isViewMode()).entrySet()) { Component newLabel = constructLabel(entity, e.getKey()); // label is displayed in view mode or when its an existing entity newLabel.setVisible(entity.getId() != null || isViewMode()); // replace all existing labels with new labels HasComponents hc = e.getValue().getParent(); if (hc instanceof Layout) { ((Layout) hc).replaceComponent(e.getValue(), newLabel); labels.get(isViewMode()).put(e.getKey(), newLabel); } } // refresh the upload components for (Entry<AttributeModel, Component> e : uploads.get(isViewMode()).entrySet()) { Component uc = constructUploadField(e.getKey()); HasComponents hc = e.getValue().getParent(); if (hc instanceof Layout) { ((Layout) hc).replaceComponent(e.getValue(), uc); uploads.get(isViewMode()).put(e.getKey(), uc); } } // refresh any fields that need it for (Field<?> f : groups.get(isViewMode()).getFields()) { if (f instanceof Refreshable) { ((Refreshable) f).refresh(); } } if (!isViewMode() && firstField != null) { firstField.focus(); } // update the title label Label newTitleLabel = constructTitleLabel(); titleBars.get(isViewMode()).replaceComponent(titleLabels.get(isViewMode()), newTitleLabel); titleLabels.put(isViewMode(), newTitleLabel); }
From source file:com.ocs.dynamo.ui.composite.form.ModelBasedEditForm.java
License:Apache License
/** * Replaces a label (in response to a change) * /*from w ww . ja v a 2 s . co m*/ * @param propertyName */ public void replaceLabel(String propertyName) { AttributeModel am = getEntityModel().getAttributeModel(propertyName); if (am != null) { Component replacement = constructLabel(getEntity(), am); Component oldLabel = labels.get(isViewMode()).get(am); // label is displayed in view mode or when its an existing entity replacement.setVisible(true); // replace all existing labels with new labels HasComponents hc = labels.get(isViewMode()).get(am).getParent(); if (hc instanceof Layout) { ((Layout) hc).replaceComponent(oldLabel, replacement); labels.get(isViewMode()).put(am, replacement); } } }
From source file:com.pms.component.ganttchart.DemoUI.java
License:Apache License
private void openStepEditor(AbstractStep step) { final Window win = new Window("Step Editor"); win.setResizable(false);/*w w w.j a va 2 s . c om*/ win.center(); final Collection<Component> hidden = new ArrayList<Component>(); BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step); final FieldGroup group = new FieldGroup(item); group.setBuffered(true); TextField captionField = new TextField("Caption"); captionField.setNullRepresentation(""); group.bind(captionField, "caption"); TextField descriptionField = new TextField("Description"); descriptionField.setNullRepresentation(""); group.bind(descriptionField, "description"); descriptionField.setVisible(false); hidden.add(descriptionField); NativeSelect captionMode = new NativeSelect("Caption Mode"); captionMode.addItem(Step.CaptionMode.TEXT); captionMode.addItem(Step.CaptionMode.HTML); group.bind(captionMode, "captionMode"); captionMode.setVisible(false); hidden.add(captionMode); final NativeSelect parentStepSelect = new NativeSelect("Parent Step"); parentStepSelect.setEnabled(false); if (!gantt.getSteps().contains(step)) { // new step parentStepSelect.setEnabled(true); for (Step parentStepCanditate : gantt.getSteps()) { parentStepSelect.addItem(parentStepCanditate); parentStepSelect.setItemCaption(parentStepCanditate, parentStepCanditate.getCaption()); if (step instanceof SubStep) { if (parentStepCanditate.getSubSteps().contains(step)) { parentStepSelect.setValue(parentStepCanditate); parentStepSelect.setEnabled(false); break; } } } } parentStepSelect.setVisible(false); hidden.add(parentStepSelect); TextField bgField = new TextField("Background color"); bgField.setNullRepresentation(""); group.bind(bgField, "backgroundColor"); bgField.setVisible(false); hidden.add(bgField); DateField startDate = new DateField("Start date"); startDate.setLocale(gantt.getLocale()); startDate.setTimeZone(gantt.getTimeZone()); startDate.setResolution(Resolution.SECOND); startDate.setConverter(new DateToLongConverter()); group.bind(startDate, "startDate"); DateField endDate = new DateField("End date"); endDate.setLocale(gantt.getLocale()); endDate.setTimeZone(gantt.getTimeZone()); endDate.setResolution(Resolution.SECOND); endDate.setConverter(new DateToLongConverter()); group.bind(endDate, "endDate"); CheckBox showMore = new CheckBox("Show all settings"); showMore.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { for (Component c : hidden) { c.setVisible((Boolean) event.getProperty().getValue()); } win.center(); } }); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); win.setContent(content); content.addComponent(captionField); content.addComponent(captionMode); content.addComponent(descriptionField); content.addComponent(parentStepSelect); content.addComponent(bgField); content.addComponent(startDate); content.addComponent(endDate); content.addComponent(showMore); HorizontalLayout buttons = new HorizontalLayout(); content.addComponent(buttons); Button ok = new Button("Ok", new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { group.commit(); AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); gantt.markStepDirty(step); if (parentStepSelect.isEnabled() && parentStepSelect.getValue() != null) { SubStep subStep = addSubStep(parentStepSelect, step); step = subStep; } if (step instanceof Step && !gantt.getSteps().contains(step)) { gantt.addStep((Step) step); } if (ganttListener != null && step instanceof Step) { ganttListener.stepModified((Step) step); } win.close(); } catch (CommitException e) { Notification.show("Commit failed", e.getMessage(), Type.ERROR_MESSAGE); e.printStackTrace(); } } private SubStep addSubStep(final NativeSelect parentStepSelect, AbstractStep dataSource) { SubStep subStep = new SubStep(); subStep.setCaption(dataSource.getCaption()); subStep.setCaptionMode(dataSource.getCaptionMode()); subStep.setStartDate(dataSource.getStartDate()); subStep.setEndDate(dataSource.getEndDate()); subStep.setBackgroundColor(dataSource.getBackgroundColor()); subStep.setDescription(dataSource.getDescription()); subStep.setStyleName(dataSource.getStyleName()); ((Step) parentStepSelect.getValue()).addSubStep(subStep); return subStep; } }); Button cancel = new Button("Cancel", new ClickListener() { @Override public void buttonClick(ClickEvent event) { group.discard(); win.close(); } }); Button delete = new Button("Delete", new ClickListener() { @Override public void buttonClick(ClickEvent event) { AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); if (step instanceof SubStep) { SubStep substep = (SubStep) step; substep.getOwner().removeSubStep(substep); } else { gantt.removeStep((Step) step); if (ganttListener != null) { ganttListener.stepDeleted((Step) step); } } win.close(); } }); buttons.addComponent(ok); buttons.addComponent(cancel); buttons.addComponent(delete); win.setClosable(true); DashboardUI.getCurrent().getUI().addWindow(win); }
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the charts layout./*from w w w . j a v a 2 s . c o m*/ */ private void createChartsLayout() { chartsLayout = new VerticalLayout(); chartsLayout.addStyleName("chartsLayout"); chartsLayout.setHeight("100%"); chartsLayout.setSpacing(true); addComponent(chartsLayout); final HorizontalLayout chartsHeaderLayout = new HorizontalLayout(); chartsHeaderLayout.setStyleName("panelHeaderLayout"); chartsHeaderLayout.setWidth("100%"); chartsHeaderLayout.setSpacing(true); chartsHeaderLayout.setMargin(new MarginInfo(false, true, false, true)); chartsLayout.addComponent(chartsHeaderLayout); chartControls = new ChartControls(); chartControls.addIntervalSelectionListener(chartIntervalListener); chartControls.addThemeSelectionListener(chartThemeListener); chartsHeaderLayout.addComponent(chartControls); chartsHeaderLayout.setComponentAlignment(chartControls, Alignment.MIDDLE_LEFT); final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); chartsHeaderLayout.addComponent(buttonsLayout); chartsHeaderLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT); SettingsDialog settingsDialog = new SettingsDialog("Edit Monitors...", "Monitors"); final Button editMonitorsButton = settingsDialog.getButton(); editMonitorsButton.setVisible(false); buttonsLayout.addComponent(editMonitorsButton); final Button addChartButton = new Button("Add Chart..."); addChartButton.setVisible(false); buttonsLayout.addComponent(addChartButton); addChartButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new ChartsDialog(chartsArrayLayout, null); } }); final Button editButton = new Button("Edit"); editButton.setDescription("Enter Editing mode"); final Button saveButton = new Button("Done"); saveButton.setDescription("Exit Editing mode"); buttonsLayout.addComponent(editButton); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(editButton, saveButton); chartsArrayLayout.setDragMode(LayoutDragMode.CLONE); chartsArrayLayout.setEditable(true); chartsHeaderLayout.setStyleName("panelHeaderLayout-editable"); editMonitorsButton.setVisible(true); addChartButton.setVisible(true); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(false); } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(saveButton, editButton); chartsArrayLayout.setDragMode(LayoutDragMode.NONE); chartsArrayLayout.setEditable(false); chartsHeaderLayout.setStyleName("panelHeaderLayout"); editMonitorsButton.setVisible(false); addChartButton.setVisible(false); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(true); refresh(); } }); final Button expandButton = new NativeButton(); expandButton.setStyleName("expandButton"); expandButton.setDescription("Expand/Reduce viewing area"); buttonsLayout.addComponent(expandButton); buttonsLayout.setComponentAlignment(expandButton, Alignment.MIDDLE_CENTER); expandButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { isExpanded = !isExpanded; AnimatorProxy proxy = getSession().getAttribute(AnimatorProxy.class); proxy.addListener(new AnimationListener() { public void onAnimation(AnimationEvent event) { Component component = event.getComponent(); component.setVisible(isExpanded ? false : true); } }); // OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); // if (!isExpanded) { // overviewPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(overviewPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); // // TopPanel topPanel = getSession().getAttribute(TopPanel.class); // if (!isExpanded) { // topPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(topPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); VerticalLayout topMid = getSession().getAttribute(VerticalLayout.class); if (!isExpanded) { topMid.setVisible(isExpanded ? false : true); } proxy.animate(topMid, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN) .setDuration(500).setDelay(100); expandButton.setStyleName(isExpanded ? "contractButton" : "expandButton"); } }); chartsPanel = new Panel(); chartsPanel.setSizeFull(); chartsPanel.addStyleName(Runo.PANEL_LIGHT); chartsLayout.addComponent(chartsPanel); chartsLayout.setExpandRatio(chartsPanel, 1.0f); }
From source file:com.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java
private Component buildBadgeWrapper(final Component menuItemButton, final Component badgeLabel) { CssLayout dashboardWrapper = new CssLayout(menuItemButton); dashboardWrapper.addStyleName("badgewrapper"); dashboardWrapper.addStyleName(ValoTheme.MENU_ITEM); badgeLabel.addStyleName(ValoTheme.MENU_BADGE); badgeLabel.setWidthUndefined();/* w w w . j av a2 s . c o m*/ badgeLabel.setVisible(false); dashboardWrapper.addComponent(badgeLabel); return dashboardWrapper; }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultCompoundSearchView.java
License:Apache License
@Override public void addComponent(Component component) { if (component != searchBar) { component.setVisible(false); enableCollapsing();// ww w.j a v a 2 s.c o m } super.addComponent(component); }
From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultCompoundSearchView.java
License:Apache License
private void updateDetailVisibility() { for (Component child : this) { if (child != searchBar) { child.setVisible(!collapsed); }/*from w w w. j a v a 2 s .c om*/ } }
From source file:edu.nps.moves.mmowgli.MmowgliOuterFrame.java
License:Open Source License
private Component makeFouoButtonTL() { Component comp = Footer.buildFouoNoticeTL(); comp.setVisible(Game.getTL().isShowFouo()); return comp; }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java
License:Open Source License
private void setCheck(HorizontalLayout row, boolean show) { Component c = row.getComponent(1); // second Component check = row.getComponent(0); if (!show) { // want to hide if (c instanceof Label) return; // I'm already hiding check.setVisible(false); Label sp;/*from w w w . j av a 2 s .c o m*/ row.addComponent(sp = new Label(), 1); sp.setWidth("12px"); } else { // want to show if (!(c instanceof Label)) return; //I'm already showing check.setVisible(true); row.removeComponent(c); } }