List of usage examples for com.vaadin.ui TextArea setValue
@Override public void setValue(String value)
From source file:net.sourceforge.javydreamercsw.validation.manager.web.about.AboutProvider.java
License:Apache License
@Override public Component getContent() { VerticalLayout vl = new VerticalLayout(); vl.addComponent(new Image("", LOGO)); TextField version = new TextField(TRANSLATOR.translate("general.version")); version.setValue(((ValidationManagerUI) UI.getCurrent()).getVersion()); version.setReadOnly(true);/*from w w w . j a v a 2 s. co m*/ vl.addComponent(version); TextField build = new TextField(TRANSLATOR.translate("general.build")); build.setValue(((ValidationManagerUI) UI.getCurrent()).getBuild()); build.setReadOnly(true); vl.addComponent(build); TextArea desc = new TextArea(); desc.setValue("Validation Manager is a tool to handle all the " + "cumbersome paperwork of regulated environment validations. " + "Including Validation Plans, protocols, " + "executions and exceptions. Keeping everything in one " + "place and best of all paperless. "); desc.setReadOnly(true); desc.setWidth(100, Unit.PERCENTAGE); Link link = new Link("Get more information here", new ExternalResource("https://github.com/javydreamercsw/validation-manager")); vl.addComponent(desc); vl.addComponent(link); vl.setId(getComponentCaption()); return vl; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java
License:Apache License
private Component getEmailSettingTab() { VerticalLayout s2 = new VerticalLayout(); HorizontalSplitPanel split2 = new HorizontalSplitPanel(); s2.addComponent(split2);/*from w w w .ja v a2s. c om*/ Tree sTree2 = new Tree(TRANSLATOR.translate("general.email.settings")); sTree2.addValueChangeListener((Property.ValueChangeEvent event) -> { if (sTree2.getValue() instanceof VmSetting) { VmSetting vmSetting = (VmSetting) sTree2.getValue(); split2.setSecondComponent(displaySetting(vmSetting, !vmSetting.getSetting().equals("mail.enable"))); } }); split2.setFirstComponent(sTree2); VMSettingServer.getSettings().forEach(s -> { if (s.getSetting().startsWith("mail")) { sTree2.addItem(s); sTree2.setChildrenAllowed(s, false); sTree2.setItemCaption(s, TRANSLATOR.translate(s.getSetting())); } }); Button testEmail = new Button(TRANSLATOR.translate("general.email.settings.test"), listener -> { //Show a window to test email settings VMWindow w = new VMWindow(TRANSLATOR.translate("general.email.settings.test")); VerticalLayout vl = new VerticalLayout(); TextField to = new TextField(TRANSLATOR.translate("general.email.to")); TextField from = new TextField(TRANSLATOR.translate("general.email.from")); TextField subject = new TextField(TRANSLATOR.translate("general.email.subject")); TextArea mess = new TextArea(TRANSLATOR.translate("general.email.message")); mess.setSizeFull(); TextArea output = new TextArea(TRANSLATOR.translate("general.output")); output.setReadOnly(true); output.setSizeFull(); Button send = new Button(TRANSLATOR.translate("general.email.send"), l -> { try { Lookup.getDefault().lookup(IEmailManager.class).sendEmail(to.getValue(), null, from.getValue(), subject.getValue(), mess.getValue()); output.setValue(TRANSLATOR.translate("general.email.settings.test.success")); //Successful, update the enable setting. VMSettingServer enable = new VMSettingServer("mail.enable"); enable.setBoolVal(true); enable.write2DB(); } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); output.setReadOnly(false); output.setValue(sw.toString()); output.setReadOnly(true); } }); vl.addComponent(to); vl.addComponent(from); vl.addComponent(subject); vl.addComponent(mess); vl.addComponent(send); vl.addComponent(output); w.setContent(vl); w.setHeight(75, Sizeable.Unit.PERCENTAGE); w.setWidth(75, Sizeable.Unit.PERCENTAGE); ValidationManagerUI.getInstance().addWindow(w); }); s2.addComponent(testEmail); return s2; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.file.TextDisplay.java
License:Apache License
@Override public Window getViewer(File f) { BufferedReader br = null;/*from w w w.j av a2s. com*/ Window w = new VMWindow(f.getName()); w.setHeight(80, Sizeable.Unit.PERCENTAGE); w.setWidth(80, Sizeable.Unit.PERCENTAGE); //Just a plain panel will do TextArea text = new TextArea(); text.setSizeFull(); w.setContent(text); try { br = new BufferedReader(new FileReader(f)); String line; StringBuilder sb = new StringBuilder(); try { while ((line = br.readLine()) != null) { sb.append(line).append("\n"); } text.setValue(sb.toString()); text.setReadOnly(true); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } catch (FileNotFoundException ex) { Exceptions.printStackTrace(ex); } finally { try { if (br != null) { br.close(); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } } return w; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.notification.NotificationScreenProvider.java
License:Apache License
@Override public Component getContent() { VerticalLayout vs = new VerticalLayout(); //On top put a list of notifications BeanItemContainer<Notification> container = new BeanItemContainer<>(Notification.class); ValidationManagerUI.getInstance().getUser().getNotificationList().forEach(n -> { container.addBean(n);/*from w w w. j av a 2 s .c om*/ }); // Unable to use VerticalSplitPanel as I hoped. // See: https://github.com/vaadin/framework/issues/9460 // VerticalSplitPanel vs = new VerticalSplitPanel(); // vs.setSplitPosition(25, Sizeable.Unit.PERCENTAGE); TextArea text = new TextArea(TRANSLATOR.translate("general.text")); text.setWordwrap(true); text.setReadOnly(true); text.setSizeFull(); Grid grid = new Grid(TRANSLATOR.translate("general.notifications"), container); grid.setColumns("notificationType", "author", "creationDate", "archieved"); if (container.size() > 0) { grid.setHeightMode(HeightMode.ROW); grid.setHeightByRows(container.size() > 5 ? 5 : container.size()); } GridCellFilter filter = new GridCellFilter(grid); filter.setBooleanFilter("archieved", new GridCellFilter.BooleanRepresentation(VaadinIcons.CHECK, TRANSLATOR.translate("general.yes")), new GridCellFilter.BooleanRepresentation(VaadinIcons.CLOSE, TRANSLATOR.translate("general.no"))); filter.setDateFilter("creationDate", new SimpleDateFormat(VMSettingServer.getSetting("date.format").getStringVal()), true); grid.sort("creationDate"); Column nt = grid.getColumn("notificationType"); nt.setHeaderCaption(TRANSLATOR.translate("notification.type")); nt.setConverter(new Converter<String, NotificationType>() { @Override public NotificationType convertToModel(String value, Class<? extends NotificationType> targetType, Locale locale) throws Converter.ConversionException { for (NotificationType n : new NotificationTypeJpaController( DataBaseManager.getEntityManagerFactory()).findNotificationTypeEntities()) { if (Lookup.getDefault().lookup(InternationalizationProvider.class).translate(n.getTypeName()) .equals(value)) { return n; } } return null; } @Override public String convertToPresentation(NotificationType value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException { return Lookup.getDefault().lookup(InternationalizationProvider.class) .translate(value.getTypeName()); } @Override public Class<NotificationType> getModelType() { return NotificationType.class; } @Override public Class<String> getPresentationType() { return String.class; } }); Column author = grid.getColumn("author"); author.setConverter(new UserToStringConverter()); author.setHeaderCaption(TRANSLATOR.translate("notification.author")); Column creation = grid.getColumn("creationDate"); creation.setHeaderCaption(TRANSLATOR.translate("creation.time")); Column archive = grid.getColumn("archieved"); archive.setHeaderCaption(TRANSLATOR.translate("general.archived")); archive.setConverter(new Converter<String, Boolean>() { @Override public Boolean convertToModel(String value, Class<? extends Boolean> targetType, Locale locale) throws Converter.ConversionException { return value.equals(TRANSLATOR.translate("general.yes")); } @Override public String convertToPresentation(Boolean value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException { return value ? TRANSLATOR.translate("general.yes") : TRANSLATOR.translate("general.no"); } @Override public Class<Boolean> getModelType() { return Boolean.class; } @Override public Class<String> getPresentationType() { return String.class; } }); grid.setSelectionMode(SelectionMode.SINGLE); grid.setSizeFull(); ContextMenu menu = new ContextMenu(grid, true); menu.addItem(TRANSLATOR.translate("notification.mark.unread"), (MenuItem selectedItem) -> { Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null) { NotificationServer ns = new NotificationServer((Notification) selected); ns.setAcknowledgeDate(null); try { ns.write2DB(); ((VMUI) UI.getCurrent()).updateScreen(); ((VMUI) UI.getCurrent()).showTab(getComponentCaption()); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } } }); menu.addItem(TRANSLATOR.translate("notification.archive"), (MenuItem selectedItem) -> { Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null) { NotificationServer ns = new NotificationServer((Notification) selected); ns.setArchieved(true); try { ns.write2DB(); ((VMUI) UI.getCurrent()).updateScreen(); ((VMUI) UI.getCurrent()).showTab(getComponentCaption()); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } } }); grid.addSelectionListener(selectionEvent -> { // Get selection from the selection model Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null) { text.setReadOnly(false); Notification n = (Notification) selected; text.setValue(n.getContent()); text.setReadOnly(true); if (n.getAcknowledgeDate() != null) { try { //Mark as read NotificationServer ns = new NotificationServer((Notification) n); ns.setAcknowledgeDate(new Date()); ns.write2DB(); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } } } }); vs.addComponent(grid); vs.addComponent(text); vs.setSizeFull(); vs.setId(getComponentCaption()); return vs; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java
License:Apache License
private void showVersioningPrompt(Versionable ao, Runnable r) { VerticalLayout layout = new VerticalLayout(); TextArea message = new TextArea(); message.setValue(TRANSLATOR.translate("missing.reason.message")); message.setReadOnly(true);// w ww .j a va 2 s .co m message.setSizeFull(); TextArea desc = new TextArea(TRANSLATOR.translate("general.reason")); desc.setSizeFull(); layout.addComponent(message); layout.addComponent(desc); //Prompt user with reason for change MessageBox prompt = MessageBox.createQuestion(); prompt.withCaption(TRANSLATOR.translate("missing.reason.title")).withMessage(layout).withYesButton(() -> { ao.setReason(desc.getValue()); if (r != null) { r.run(); } }, ButtonOption.focus(), ButtonOption.icon(VaadinIcons.CHECK), ButtonOption.disable()) .withNoButton(ButtonOption.icon(VaadinIcons.CLOSE)); prompt.getWindow().setIcon(ValidationManagerUI.SMALL_APP_ICON); desc.addTextChangeListener((TextChangeEvent event1) -> { //Enable if there is a description change. prompt.getButton(ButtonType.YES).setEnabled(!event1.getText().trim().isEmpty()); }); prompt.getWindow().setWidth(50, Unit.PERCENTAGE); prompt.getWindow().setHeight(50, Unit.PERCENTAGE); prompt.open(); }
From source file:nz.co.senanque.workflowui.FieldGroupWizard.java
License:Apache License
@SuppressWarnings("serial") public void load(final WorkflowForm form) { ProcessDefinition processDefinition = form.getProcessDefinition(); String task = processDefinition.getTask(form.getProcessInstance().getTaskId()).toString(); ProcessDefinition ownerProcessDefinition = processDefinition; while (processDefinition != null) { ownerProcessDefinition = processDefinition; processDefinition = processDefinition.getOwnerProcess(); }//from ww w . j a v a 2s .c o m setCaption(m_messageSourceAccessor.getMessage("form.wizard.caption", new Object[] { new Long(form.getProcessInstance().getId()), ownerProcessDefinition.getName(), form.getProcessInstance().getReference(), ownerProcessDefinition.getDescription() })); formPanel.removeAllComponents(); formPanel.addComponent((VerticalLayout) form); ProcessInstance processInstance = form.getProcessInstance(); if (!form.isReadOnly()) { PermissionManager pm = m_maduraSessionManager.getPermissionManager(); processInstance = getWorkflowClient().lockProcessInstance(form.getProcessInstance(), pm.hasPermission(FixedPermissions.TECHSUPPORT), pm.getCurrentUser()); if (processInstance == null) { com.vaadin.ui.Notification.show(m_messageSourceAccessor.getMessage("failed.to.get.lock"), m_messageSourceAccessor.getMessage("message.noop"), com.vaadin.ui.Notification.Type.HUMANIZED_MESSAGE); return; } } form.setProcessInstance(processInstance); // This is binding the process instance associated with the form to the workflow validation session. // log.debug("Binding {} to Validation engine {}",processInstance.getClass().getSimpleName(),getMaduraSessionManager().getValidationEngine().getIdentifier()); getMaduraSessionManager().getValidationSession().bind(form.getProcessInstance()); ((VerticalLayout) form).addListener(new Listener() { @Override public void componentEvent(Event event) { close(); fireEvent(event); } }); formPanel.markAsDirty(); BeanItem<ProcessInstance> beanItem = new BeanItem<ProcessInstance>(form.getProcessInstance()); m_maduraFieldGroup = m_maduraSessionManager.createMaduraFieldGroup(); Button attachments = m_maduraFieldGroup.createButton("attachments", new ClickListener() { @Override public void buttonClick(ClickEvent event) { m_attachmentsPopup.load(form.getProcessInstance().getId()); } }); Map<String, Field<?>> fields = m_maduraFieldGroup.buildAndBind(new String[] { "queueName", "bundleName", "status", "reference", "lastUpdated", "lockedBy", "comment" }, beanItem); TextArea comment = (TextArea) fields.get("comment"); comment.setRows(2); comment.setWordwrap(true); comment.setWidth("700px"); TextArea taskField = new TextArea(); taskField.setRows(2); taskField.setWordwrap(true); taskField.setWidth("700px"); taskField.setValue(task); taskField.setReadOnly(true); processPanel.removeAllComponents(); processPanel.setMargin(true); processPanel.setSpacing(true); HorizontalLayout processPanelHorizontal = new HorizontalLayout(); processPanelHorizontal.setSpacing(true); processPanel.addComponent(processPanelHorizontal); VerticalLayout processPanelColumn1 = new VerticalLayout(); VerticalLayout processPanelColumn2 = new VerticalLayout(); VerticalLayout processPanelColumn3 = new VerticalLayout(); processPanelHorizontal.addComponent(processPanelColumn1); processPanelHorizontal.addComponent(processPanelColumn2); processPanelHorizontal.addComponent(processPanelColumn3); processPanelColumn1.addComponent(fields.get("queueName")); processPanelColumn1.addComponent(fields.get("bundleName")); processPanelColumn2.addComponent(fields.get("reference")); processPanelColumn2.addComponent(fields.get("lastUpdated")); processPanelColumn3.addComponent(fields.get("lockedBy")); processPanelColumn3.addComponent(fields.get("status")); processPanel.addComponent(comment); processPanel.addComponent(taskField); m_maduraSessionManager.updateOtherFields(null); m_maduraFieldGroup.setReadOnly(form.isReadOnly()); processPanel.addComponent(attachments); processPanel.markAsDirty(); auditPanel.removeAllComponents(); m_audits.setup(form.getProcessInstance()); auditPanel.addComponent(m_audits); if (getParent() == null) { UI.getCurrent().addWindow(this); this.center(); } }
From source file:org.activiti.explorer.ui.form.TextAreaFormPropertyRenderer.java
License:Apache License
@Override public Field getPropertyField(FormProperty formProperty) { TextArea textArea = new TextArea(getPropertyLabel(formProperty)); textArea.setRequired(formProperty.isRequired()); textArea.setEnabled(formProperty.isWritable()); textArea.setRows(10);/*w w w .j a v a2s .com*/ textArea.setColumns(40); textArea.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty))); if (formProperty.getValue() != null) { textArea.setValue(formProperty.getValue()); } return textArea; }
From source file:org.activiti.explorer.ui.task.DescriptionComponent.java
License:Apache License
protected void initLayoutClickListener() { addListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) { // textarea final TextArea descriptionTextArea = new TextArea(); descriptionTextArea.setWidth(100, UNITS_PERCENTAGE); descriptionTextArea.setValue(task.getDescription()); editLayout.addComponent(descriptionTextArea); // ok button Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); editLayout.addComponent(okButton); editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); // replace replaceComponent(descriptionLabel, editLayout); // When OK is clicked -> update task data + ui okButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { // Update data task.setDescription(descriptionTextArea.getValue().toString()); taskService.saveTask(task); // Update UI descriptionLabel.setValue(task.getDescription()); replaceComponent(editLayout, descriptionLabel); }//w ww.j a v a 2 s . c o m }); } } }); }
From source file:org.activiti.explorer.ui.task.TaskDetailPanel.java
License:Apache License
protected void initDescription(HorizontalLayout layout) { final CssLayout descriptionLayout = new CssLayout(); descriptionLayout.setWidth(100, UNITS_PERCENTAGE); layout.addComponent(descriptionLayout); layout.setExpandRatio(descriptionLayout, 1.0f); layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT); String descriptionText = null; if (task.getDescription() != null && !"".equals(task.getDescription())) { descriptionText = task.getDescription(); } else {/*from www .j a va 2s . c o m*/ descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION); } final Label descriptionLabel = new Label(descriptionText); descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE); descriptionLayout.addComponent(descriptionLabel); descriptionLayout.addListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) { // layout for textarea + ok button final VerticalLayout editLayout = new VerticalLayout(); editLayout.setSpacing(true); // textarea final TextArea descriptionTextArea = new TextArea(); descriptionTextArea.setNullRepresentation(""); descriptionTextArea.setWidth(100, UNITS_PERCENTAGE); descriptionTextArea.setValue(task.getDescription()); editLayout.addComponent(descriptionTextArea); // ok button Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK)); editLayout.addComponent(okButton); editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); // replace descriptionLayout.replaceComponent(descriptionLabel, editLayout); // When OK is clicked -> update task data + ui okButton.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { // Update data task.setDescription(descriptionTextArea.getValue().toString()); taskService.saveTask(task); // Update UI descriptionLabel.setValue(task.getDescription()); descriptionLayout.replaceComponent(editLayout, descriptionLabel); } }); } } }); }
From source file:org.apache.openaz.xacml.admin.components.PDPManagement.java
License:Apache License
protected void initializeTree(final boolean isAdmin) { ////from ww w .j a v a 2s . c om // Set the data source // this.table.setContainerDataSource(this.container); // // Setup the GUI properties // this.table.setVisibleColumns("Name", "Description", "Status", "Default", "PDPs", "Policies", "PIP Configurations"); this.table.setColumnHeaders("Name", "Description", "Status", "Default", "PDP's", "Policies", "PIP Configurations"); // // The description should be a text area // this.table.addGeneratedColumn("Description", new ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextArea area = new TextArea(); area.setValue(((PDPGroup) itemId).getDescription()); area.setReadOnly(true); return area; } }); // // Generate a GUI element for the PDP's // this.table.addGeneratedColumn("PDPs", new ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final Table table = new Table(); final PDPContainer container = new PDPContainer((PDPGroup) itemId); // // Setup the container data // table.setContainerDataSource(container); // // Save the group for easy access // table.setData(itemId); // // GUI properties // table.setPageLength(table.getContainerDataSource().size() + 2); table.setVisibleColumns("Name", "Status", "Description"); table.setColumnCollapsingAllowed(true); table.setColumnCollapsed("Description", true); table.setWidth("100%"); // // If an admin, then it is editable // if (isAdmin) { // // Set it as selectable // table.setSelectable(true); // // Add actions // table.addActionHandler(new Handler() { private static final long serialVersionUID = 1L; @Override public Action[] getActions(Object target, Object sender) { if (target == null) { return new Action[] { CREATE_PDP }; } if (target instanceof PDP) { if (self.container.size() > 1) { return new Action[] { EDIT_PDP, GET_PDP_STATUS, MOVE_PDP, DELETE_PDP }; } else { return new Action[] { EDIT_PDP, GET_PDP_STATUS, DELETE_PDP }; } } return null; } @Override public void handleAction(Action action, Object sender, Object target) { if (action == CREATE_PDP) { self.editPDP(null, (PDPGroup) table.getData()); return; } if (action == EDIT_PDP) { assert target instanceof PDP; self.editPDP((PDP) target, (PDPGroup) table.getData()); return; } if (action == MOVE_PDP) { assert target instanceof PDP; self.movePDP((PDP) target, (PDPGroup) table.getData()); return; } if (action == DELETE_PDP) { assert target instanceof PDP; self.deletePDP((PDP) target, (PDPGroup) table.getData()); return; } if (action == GET_PDP_STATUS) { assert target instanceof PDP; self.getPDPStatus((PDP) target, (PDPGroup) table.getData()); } } }); // // Respond to events // table.addItemClickListener(new ItemClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { self.editPDP((PDP) event.getItemId(), (PDPGroup) table.getData()); } } }); } return table; } }); // // Generate a GUI element for the policies // this.table.addGeneratedColumn("Policies", new ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { Table table = new Table(); table.setContainerDataSource(new PDPPolicyContainer((PDPGroup) itemId)); table.setPageLength(table.getContainerDataSource().size() + 2); table.setVisibleColumns("Root", "Name", "Version", "Description"); table.setColumnCollapsingAllowed(true); table.setColumnCollapsed("Description", true); table.setWidth("100%"); return table; } }); // // Generate a GUI element for the PIP configurations // this.table.addGeneratedColumn("PIP Configurations", new ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { Table table = new Table(); if (itemId instanceof PDPGroup) { table.setContainerDataSource(new PDPPIPContainer((PDPGroup) itemId)); table.setPageLength(table.getContainerDataSource().size() + 2); } if (itemId instanceof PDP) { table.setContainerDataSource(new PDPPIPContainer((PDP) itemId)); table.setVisible(false); table.setPageLength(0); } table.setVisibleColumns("Name", "Description"); table.setColumnCollapsingAllowed(true); table.setColumnCollapsed("Description", true); table.setWidth("100%"); return table; } }); // // Check the user's authorization level // if (((XacmlAdminUI) UI.getCurrent()).isAuthorized(XacmlAdminAuthorization.AdminAction.ACTION_ADMIN, XacmlAdminAuthorization.AdminResource.RESOURCE_PDP_ADMIN)) { this.table.setSelectable(true); } else { if (logger.isDebugEnabled()) { logger.debug("No admin access to pdp management"); } return; } // // Setup Action Handlers // this.table.addActionHandler(new Handler() { private static final long serialVersionUID = 1L; @Override public Action[] getActions(Object target, Object sender) { if (target == null) { // // Nothing is selected, they right-clicked empty space. // Only one action. // return new Action[] { CREATE_GROUP }; } if (target instanceof PDPGroup) { List<Action> actions = new ArrayList<Action>(); PDPGroupStatus.Status status = ((PDPGroup) target).getStatus().getStatus(); if (status == PDPGroupStatus.Status.LOAD_ERRORS) { actions.add(REPAIR_GROUP); } if (((PDPGroup) target).isDefaultGroup() == false) { actions.add(MAKE_DEFAULT); } actions.add(EDIT_GROUP); if (status == PDPGroupStatus.Status.OUT_OF_SYNCH) { actions.add(SYNCHRONIZE); } if (((PDPGroup) target).isDefaultGroup() == false) { actions.add(DELETE_GROUP); } actions.add(CREATE_PDP); // Throws a class cast exception // return (Action[]) actions.toArray(); Action[] actions2 = new Action[actions.size()]; int index = 0; for (Action a : actions) { actions2[index++] = a; } return actions2; } return null; } @Override public void handleAction(Action action, Object sender, Object target) { if (action == CREATE_GROUP) { self.editPDPGroup(null); return; } if (action == EDIT_GROUP) { assert target instanceof PDPGroup; self.editPDPGroup((PDPGroup) target); return; } if (action == DELETE_GROUP) { self.deleteGroup((PDPGroup) target); return; } if (action == REPAIR_GROUP) { if (target instanceof PDPGroup) { ((PDPGroup) target).repair(); } else { String message = "Action '" + REPAIR_GROUP.getCaption() + "' called on non-group target '" + target + "'"; logger.error(message); AdminNotification.error(message); } return; } if (action == MAKE_DEFAULT) { if (target instanceof PDPGroup) { try { self.container.makeDefault((PDPGroup) target); } catch (Exception e) { AdminNotification.error("Make Default failed. Reason:\n" + e.getMessage()); } } else { String message = "Action '" + MAKE_DEFAULT.getCaption() + "' called on non-group target '" + target + "'"; logger.error(message); AdminNotification.error(message); } return; } if (action == SYNCHRONIZE) { if (target instanceof PDPGroup) { logger.error("SYNCHRONIZE NOT YET IMPLMENTED"); AdminNotification.error("Synchronize not yet implemented"); } else { String message = "Action '" + SYNCHRONIZE.getCaption() + "' called on non-group target '" + target + "'"; logger.error(message); AdminNotification.error(message); } return; } if (action == CREATE_PDP) { if (target instanceof PDPGroup) { self.editPDP(null, ((PDPGroup) target)); } else { String message = "Action '" + CREATE_PDP.getCaption() + "' called on non-group target '" + target + "'"; logger.error(message); AdminNotification.error(message); } return; } } }); // // Listen for item change notifications // this.table.addItemClickListener(new ItemClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { assert event.getItemId() instanceof PDPGroup; self.editPDPGroup((PDPGroup) event.getItemId()); } } }); // // Respond to selection events // this.table.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { Object id = self.table.getValue(); if (id == null) { self.buttonRemove.setEnabled(false); } else { // // Make sure its not the default group // if (((PDPGroup) id).isDefaultGroup()) { self.buttonRemove.setEnabled(false); } else { self.buttonRemove.setEnabled(true); } } } }); // // Maximize the table // this.table.setSizeFull(); }