List of usage examples for com.vaadin.ui Label setReadOnly
protected void setReadOnly(boolean readOnly)
From source file:nz.co.senanque.vaadinsupport.application.MaduraSessionManager.java
License:Apache License
/** * Check all the other fields to ensure they are still valid * this includes any buttons that were registered because they * get disabled if there are errors on the relevant form or * if the requiredness is incomplete./*from www .j a v a 2 s . c o m*/ * * @param field */ public void updateOtherFields(AbstractField field) { PermissionManager permissionmanager = getPermissionManager(); Collection<AbstractField> fields = getFields(); Collection<Label> labels = getLabels(); for (Label fieldx : labels) { com.vaadin.data.Property p = fieldx.getPropertyDataSource(); if (p != null && p instanceof LabelProperty) { fieldx.requestRepaint(); } } for (AbstractField fieldx : fields) { if (fieldx.equals(field)) continue; if ((fieldx instanceof Button) && !(fieldx instanceof CheckBox)) { com.vaadin.data.Property p = fieldx.getPropertyDataSource(); if (p != null && p instanceof ButtonProperty) { ((ButtonProperty) p).getPainter().paint((Button) fieldx); fieldx.requestRepaint(); } continue; } if (fieldx instanceof MenuItemWrapper) { MenuItemPainter menuItemPainter = ((MenuItemWrapper) fieldx).getMenuItemPainter(); MenuItem menuItem = (MenuItem) fieldx.getData(); if (menuItemPainter != null) { menuItemPainter.paint(menuItem); fieldx.requestRepaint(); } continue; } MaduraPropertyWrapper property = null; try { property = (MaduraPropertyWrapper) fieldx.getPropertyDataSource(); } catch (Exception e) { // ignore property = null; } if (property != null) { if (logger.isDebugEnabled()) { logger.debug("evaluating field: {}", property.getName()); if (fieldx.isEnabled() != property.isEnabled()) { logger.debug("Enabled: {} {}", fieldx.isEnabled(), property.isEnabled()); } if (fieldx.isReadOnly() != property.isReadOnly()) { logger.debug("ReadOnly: {} {}", fieldx.isReadOnly(), property.isReadOnly()); } if (fieldx.isRequired() != property.isRequired()) { logger.debug("Required: {} {}", fieldx.isRequired(), property.isRequired()); } if (fieldx.isVisible() != property.isVisible()) { logger.debug("Visible: {} {}", fieldx.isVisible(), property.isVisible()); } } fieldx.setEnabled(property.isEnabled()); fieldx.setReadOnly(property.isReadOnly()); fieldx.setRequired(property.isRequired()); fieldx.setVisible(property.isVisible()); // Permissions trump rules if (!permissionmanager.hasPermission(property.getReadPermission())) { fieldx.setVisible(false); } if (!permissionmanager.hasPermission(property.getWritePermission())) { fieldx.setEnabled(false); } if (fieldx instanceof AbstractSelect) { AbstractSelect select = (AbstractSelect) fieldx; List<ChoiceBase> availableList = new ArrayList<ChoiceBase>(); for (ChoiceBase v : property.getAvailableValues()) { availableList.add(v); } logger.debug("{} availableList {}", property.getName(), availableList); Collection<?> itemIds = select.getItemIds(); List<Object> killList = new ArrayList<Object>(); for (Object itemId : itemIds) { if (availableList.contains(itemId)) continue; killList.add(itemId); } for (Object kill : killList) { select.removeItem(kill); } for (ChoiceBase cb : availableList) { select.addItem(cb); } logger.debug("Select {} value \"{}\", updated to {}", new Object[] { property.getName(), select.getValue(), select.getItemIds() }); } } fieldx.requestRepaint(); } }
From source file:org.ikasan.dashboard.ui.topology.window.CategorisedErrorOccurrenceViewWindow.java
License:BSD License
protected Panel createErrorOccurrenceDetailsPanel() { Panel errorOccurrenceDetailsPanel = new Panel(); GridLayout layout = new GridLayout(4, 7); layout.setWidth("100%"); layout.setSpacing(true);/*from w w w . j a va2 s. c o m*/ layout.setColumnExpandRatio(0, .10f); layout.setColumnExpandRatio(1, .30f); layout.setColumnExpandRatio(2, .05f); layout.setColumnExpandRatio(3, .30f); Label errorOccurrenceDetailsLabel = new Label(" Categorised Error Occurence Details", ContentMode.HTML); Label errorCategoryLabel = new Label(); if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.BLOCKER)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.BAN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.BAN.getHtml() + " Blocker", ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.CRITICAL)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.EXCLAMATION.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.EXCLAMATION.getHtml() + " Critical", ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.MAJOR)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.ARROW_UP.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.ARROW_UP.getHtml() + " Major", ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.TRIVIAL)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.ARROW_DOWN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.ARROW_DOWN.getHtml() + " Trivial", ContentMode.HTML); } errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(errorOccurrenceDetailsLabel, 0, 0, 3, 0); Label label = new Label("Module Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf1 = new TextField(); tf1.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getModuleName()); tf1.setReadOnly(true); tf1.setWidth("80%"); layout.addComponent(tf1, 1, 1); label = new Label("Flow Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf2 = new TextField(); tf2.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowName()); tf2.setReadOnly(true); tf2.setWidth("80%"); layout.addComponent(tf2, 1, 2); label = new Label("Component Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf3 = new TextField(); tf3.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowElementName()); tf3.setReadOnly(true); tf3.setWidth("80%"); layout.addComponent(tf3, 1, 3); label = new Label("Date/Time:"); label.setSizeUndefined(); layout.addComponent(label, 0, 4); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf4 = new TextField(); tf4.setValue(new Date(this.categorisedErrorOccurrence.getErrorOccurrence().getTimestamp()).toString()); tf4.setReadOnly(true); tf4.setWidth("80%"); layout.addComponent(tf4, 1, 4); GridLayout wrapperLayout = new GridLayout(1, 4); wrapperLayout.setMargin(true); wrapperLayout.setWidth("100%"); Label errorMessageLabel = new Label("Error Message:"); errorMessageLabel.setSizeUndefined(); layout.addComponent(errorMessageLabel, 0, 5); layout.setComponentAlignment(errorMessageLabel, Alignment.TOP_RIGHT); final TextArea errorMessageTextArea = new TextArea(); errorMessageTextArea.setWidth("650px"); errorMessageTextArea.setRows(6); errorMessageTextArea .setValue(this.categorisedErrorOccurrence.getErrorCategorisation().getErrorDescription()); layout.addComponent(errorMessageTextArea, 1, 5, 3, 5); AceEditor editor = new AceEditor(); editor.setCaption("Error Details"); editor.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getErrorDetail()); editor.setReadOnly(true); editor.setMode(AceMode.xml); editor.setTheme(AceTheme.eclipse); editor.setHeight(470, Unit.PIXELS); editor.setWidth("100%"); label = new Label("Error Category:"); label.setSizeUndefined(); layout.addComponent(label, 2, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); layout.addComponent(errorCategoryLabel, 3, 1); layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_LEFT); label = new Label("System Action:"); label.setSizeUndefined(); layout.addComponent(label, 2, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField systemAction = new TextField(); systemAction.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getAction()); systemAction.setReadOnly(true); systemAction.setWidth("80%"); layout.addComponent(systemAction, 3, 2); label = new Label("User Action:"); label.setSizeUndefined(); layout.addComponent(label, 2, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField userAction = new TextField(); userAction.setValue(""); userAction.setReadOnly(true); userAction.setWidth("80%"); layout.addComponent(userAction, 3, 3); label = new Label("User Action By:"); label.setSizeUndefined(); layout.addComponent(label, 2, 4); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); Label userActionBy = new Label(); userActionBy.setValue(""); userActionBy.setReadOnly(true); userActionBy.setWidth("80%"); layout.addComponent(userActionBy, 3, 4); AceEditor eventEditor = new AceEditor(); eventEditor.setCaption("Event Payload"); if (this.categorisedErrorOccurrence.getErrorOccurrence().getEvent() != null) { eventEditor .setValue(new String((byte[]) this.categorisedErrorOccurrence.getErrorOccurrence().getEvent())); } eventEditor.setReadOnly(true); eventEditor.setMode(AceMode.java); eventEditor.setTheme(AceTheme.eclipse); eventEditor.setHeight(470, Unit.PIXELS); eventEditor.setWidth("100%"); HorizontalLayout formLayout = new HorizontalLayout(); formLayout.setWidth("100%"); formLayout.setHeight(300, Unit.PIXELS); formLayout.addComponent(layout); wrapperLayout.addComponent(formLayout, 0, 0); // VerticalSplitPanel vSplitPanel = new VerticalSplitPanel(); // vSplitPanel.setWidth("100%"); // vSplitPanel.setHeight(800, Unit.PIXELS); // vSplitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE); TabSheet tabsheet = new TabSheet(); tabsheet.setSizeFull(); HorizontalLayout h1 = new HorizontalLayout(); h1.setSizeFull(); h1.setMargin(true); h1.addComponent(eventEditor); // vSplitPanel.setFirstComponent(h1); HorizontalLayout h2 = new HorizontalLayout(); h2.setSizeFull(); h2.setMargin(true); h2.addComponent(editor); // vSplitPanel.setSecondComponent(h2); tabsheet.addTab(h2, "Error Details"); tabsheet.addTab(h1, "Event Payload"); wrapperLayout.addComponent(tabsheet, 0, 1); // wrapperLayout.addComponent(vSplitPanel, 0, 1); errorOccurrenceDetailsPanel.setContent(wrapperLayout); return errorOccurrenceDetailsPanel; }