List of usage examples for com.vaadin.ui Button addListener
@Override
public Registration addListener(Component.Listener listener)
From source file:org.activiti.kickstart.ui.panel.ActionsPanel.java
License:Apache License
public ActionsPanel(ViewManager viewManager) { setStyleName(Reindeer.PANEL_LIGHT);//from ww w . ja v a 2 s. c o m VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); Button createAdhocWorkflowButton = new Button(CREATE_WORKFLOW); createAdhocWorkflowButton.setWidth("132px"); createAdhocWorkflowButton.addListener(new CreateKickstartWorkflowClickListener(viewManager)); Button enhanceWorkflowButton = new Button(ENHANCE_WORKFLOW); enhanceWorkflowButton.setWidth("132px"); enhanceWorkflowButton.addListener(new EnhanceWorkflowClickListener(viewManager)); layout.addComponent(createAdhocWorkflowButton); layout.addComponent(enhanceWorkflowButton); addComponent(layout); }
From source file:org.activiti.kickstart.ui.panel.KickstartWorkflowPanel.java
License:Apache License
protected void initButtons(GridLayout layout) { final Button saveButton = new Button("Save"); saveButton.setEnabled(nameField.getValue() != null && !"".equals((String) nameField.getValue())); saveButton.setIcon(saveImage);/* ww w. j a v a 2 s . com*/ saveButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 3546324122090420533L; public void buttonClick(ClickEvent event) { try { adhocWorkflowService.deployKickstartWorkflow(createAdhocWorkflow()); Panel successPanel = new Panel(); successPanel.setStyleName(Reindeer.PANEL_LIGHT); Label successLabel = new Label("Process successfully deployed"); successPanel.addComponent(successLabel); viewManager.switchWorkArea(ViewManager.PROCESS_SUCESSFULLY_DEPLOYED, successPanel); } catch (Exception e) { e.printStackTrace(); viewManager.showPopupWindow(new ErrorPopupWindow(e)); } } }); // Dependending on namefield value, save button is enabled nameField.addListener(new ValueChangeListener() { private static final long serialVersionUID = -4357300368046546003L; public void valueChange(ValueChangeEvent event) { if (nameField.getValue() != null && !"".equals((String) nameField.getValue())) { saveButton.setEnabled(true); } else { saveButton.setEnabled(false); } } }); Button generateImageButton = new Button("View image"); generateImageButton.setIcon(generateImageImage); generateImageButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 5671158538486627690L; public void buttonClick(ClickEvent event) { viewManager.showPopupWindow(new ProcessImagePopupWindow(viewManager, createAdhocWorkflow())); } }); HorizontalLayout footer = new HorizontalLayout(); footer.setSpacing(true); footer.addComponent(saveButton); footer.addComponent(generateImageButton); layout.addComponent(new Label()); layout.addComponent(footer); }
From source file:org.activiti.kickstart.ui.panel.SelectAdhocWorkflowPanel.java
License:Apache License
protected void initWorkflowTableContents() { List<KickstartWorkflowInfo> processDefinitions = adhocWorkflowService.findKickstartWorkflowInformation(); for (final KickstartWorkflowInfo infoDto : processDefinitions) { Item workflowItem = workflowTable.getItem(workflowTable.addItem()); Button nameButton = new Button(infoDto.getName()); nameButton.setStyleName("link"); nameButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 5671158538486627690L; public void buttonClick(ClickEvent event) { viewManager.showPopupWindow(new ProcessImagePopupWindow(viewManager, infoDto.getId())); }/*from w ww. ja va2s . co m*/ }); workflowItem.getItemProperty("name").setValue(nameButton); workflowItem.getItemProperty("key").setValue(infoDto.getKey()); workflowItem.getItemProperty("version").setValue(infoDto.getVersion()); workflowItem.getItemProperty("createTime").setValue(infoDto.getCreateTime()); workflowItem.getItemProperty("nrOfRunningInstance").setValue(infoDto.getNrOfRuntimeInstances()); workflowItem.getItemProperty("nrOfHistoricInstances").setValue(infoDto.getNrOfHistoricInstances()); HorizontalLayout actions = new HorizontalLayout(); actions.setSpacing(true); Button editButton = new Button("edit"); editButton.setStyleName("link"); // editButton.setIcon(editImage); editButton.setData(infoDto.getId()); editButton .addListener(new EditExistingKickstartWorkflowClickListener(viewManager, adhocWorkflowService)); actions.addComponent(editButton); StreamResource.StreamSource streamSource = new StreamSource() { private static final long serialVersionUID = -8875067466181823014L; public InputStream getStream() { return ServiceLocator.getAdhocWorkflowService().getProcessBpmnXml(infoDto.getId()); } }; Link bpmnXmlLink = new Link("get xml", new StreamResource(streamSource, infoDto.getKey() + ".bpmn20.xml", viewManager.getApplication())); // bpmnXmlLink.setIcon(xmlImage); actions.addComponent(bpmnXmlLink); workflowItem.getItemProperty("actions").setValue(actions); } workflowTable.setPageLength(workflowTable.size()); }
From source file:org.activiti.kickstart.ui.panel.SelectWorkflowPanel.java
License:Apache License
protected void initWorkflowTableContents() { List<KickstartWorkflowInfo> processDefinitions = kickstartService.findWorkflowInformation(true); for (final KickstartWorkflowInfo infoDto : processDefinitions) { Item workflowItem = workflowTable.getItem(workflowTable.addItem()); Button nameButton = new Button(infoDto.getName()); nameButton.setStyleName("link"); nameButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 5671158538486627690L; public void buttonClick(ClickEvent event) { KickstartApplication.get().getViewManager() .showPopupWindow(new ProcessImagePopupWindow(infoDto.getId())); }// www . ja va 2 s .c o m }); workflowItem.getItemProperty("name").setValue(nameButton); workflowItem.getItemProperty("key").setValue(infoDto.getKey()); workflowItem.getItemProperty("version").setValue(infoDto.getVersion()); workflowItem.getItemProperty("createTime").setValue(infoDto.getCreateTime()); workflowItem.getItemProperty("nrOfRunningInstance").setValue(infoDto.getNrOfRuntimeInstances()); workflowItem.getItemProperty("nrOfHistoricInstances").setValue(infoDto.getNrOfHistoricInstances()); HorizontalLayout actions = new HorizontalLayout(); actions.setSpacing(true); Button editButton = new Button("edit"); editButton.setStyleName("link"); // editButton.setIcon(editImage); editButton.setData(infoDto.getId()); editButton.addListener(new EditExistingKickstartWorkflowClickListener(kickstartService)); actions.addComponent(editButton); StreamResource.StreamSource streamSource = new StreamSource() { private static final long serialVersionUID = -8875067466181823014L; public InputStream getStream() { return KickstartApplication.get().getKickstartService().getBpmnXml(infoDto.getId()); } }; Link bpmnXmlLink = new Link("get xml", new StreamResource(streamSource, infoDto.getKey() + ".bpmn20.xml", KickstartApplication.get())); // bpmnXmlLink.setIcon(xmlImage); actions.addComponent(bpmnXmlLink); workflowItem.getItemProperty("actions").setValue(actions); } workflowTable.setPageLength(workflowTable.size()); }
From source file:org.activiti.kickstart.ui.popup.FormPopupWindow.java
License:Apache License
protected void initUi() { GridLayout layout = new GridLayout(2, 4); layout.setSpacing(true);// ww w . j a v a2 s . co m addComponent(layout); // Title layout.addComponent(new Label(FORM_TITLE)); titleField = new TextField(); layout.addComponent(titleField); // Description layout.addComponent(new Label(DESCRIPTION)); descriptionField = new TextField(); descriptionField.setRows(2); descriptionField.setColumns(25); layout.addComponent(descriptionField); // Property table propertyTable = new PropertyTable(); layout.addComponent(new Label(DATA)); layout.addComponent(propertyTable); fillFormFields(); // Buttons HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); // Save button Button saveButton = new Button("Save"); buttons.addComponent(saveButton); saveButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -2906886872414089331L; public void buttonClick(ClickEvent event) { FormDto form = createForm(); formModel.addForm(taskItemId, form); close(); } }); // Delete button Button deleteButton = new Button("Delete"); buttons.addComponent(deleteButton); deleteButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 5267967369680365653L; public void buttonClick(ClickEvent event) { formModel.removeForm(taskItemId); close(); } }); layout.addComponent(new Label("")); layout.addComponent(buttons); }
From source file:org.activiti.kickstart.ui.table.PropertyTable.java
License:Apache License
protected void addPropertyRow(Object itemId, String propertyName, String propertyType, Boolean required) { Object newItemId = null;/*w ww . j a v a2 s . c o m*/ if (itemId == null) { // add at the end of list newItemId = addItem(); } else { newItemId = addItemAfter(itemId); } Item newItem = getItem(newItemId); // name newItem.getItemProperty("property").setValue(propertyName == null ? "My Property" : propertyName); // type ComboBox typeComboBox = new ComboBox("types", Arrays.asList("text", "number", "date")); if (propertyType == null) { typeComboBox.setValue(typeComboBox.getItemIds().iterator().next()); typeComboBox.setNullSelectionAllowed(false); } else { typeComboBox.setValue(propertyType); } newItem.getItemProperty("type").setValue(typeComboBox); // required CheckBox requiredCheckBox = new CheckBox(); requiredCheckBox.setValue(required == null ? false : required); newItem.getItemProperty("required").setValue(requiredCheckBox); // actions HorizontalLayout actionButtons = new HorizontalLayout(); Button deleteRowButton = new Button("-"); deleteRowButton.setData(newItemId); deleteRowButton.addListener(new DeletePropertyClickListener(this)); actionButtons.addComponent(deleteRowButton); Button addRowButton = new Button("+"); addRowButton.setData(newItemId); addRowButton.addListener(new AddPropertyClickListener(this)); actionButtons.addComponent(addRowButton); newItem.getItemProperty("actions").setValue(actionButtons); }
From source file:org.activiti.kickstart.ui.table.TaskTable.java
License:Apache License
protected HorizontalLayout generateActionButtons(Object taskItemId) { HorizontalLayout actionButtons = new HorizontalLayout(); FormDto form = taskFormModel.getForm(taskItemId); Button formButton = new Button(form == null ? "Create form" : "Edit form"); formButton.addListener(new ShowFormClickListener(viewManager, taskFormModel, taskItemId)); formButton.setData(taskItemId);/* w w w .j a v a2 s .co m*/ actionButtons.addComponent(formButton); Button deleteTaskButton = new Button("-"); deleteTaskButton.setData(taskItemId); deleteTaskButton.addListener(new DeleteTaskClickListener(this)); actionButtons.addComponent(deleteTaskButton); Button addTaskButton = new Button("+"); addTaskButton.setData(taskItemId); addTaskButton.addListener(new AddTaskClickListener(this)); actionButtons.addComponent(addTaskButton); return actionButtons; }
From source file:org.apache.ace.tageditor.TagTableEntry.java
License:Apache License
public Object addTo(final Table table) { Button deleteButton = new Button() { @Override/*ww w. ja va2 s . c o m*/ public boolean isEnabled() { return super.isEnabled() && m_id != null; } }; deleteButton.setCaption("x"); deleteButton.setStyleName("small"); deleteButton.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { removeFrom(table); } }); m_id = table.addItem(new Object[] { m_keyField, m_valueField, deleteButton }, null); return m_id; }
From source file:org.apache.ace.target.management.ui.TargetManagementExtension.java
License:Apache License
public Component create(Map<String, Object> context) { GridLayout result = new GridLayout(1, 4); result.setCaption(CAPTION);/*from www. j ava 2 s . co m*/ result.setMargin(true); result.setSpacing(true); result.setSizeFull(); final StatefulTargetObject target = getRepositoryObjectFromContext(context); final CheckBox registerCB = new CheckBox("Registered?"); registerCB.setImmediate(true); registerCB.setEnabled(!target.isRegistered()); registerCB.setValue(Boolean.valueOf(target.isRegistered())); result.addComponent(registerCB); final CheckBox autoApproveCB = new CheckBox("Auto approve?"); autoApproveCB.setImmediate(true); autoApproveCB.setEnabled(target.isRegistered()); autoApproveCB.setValue(Boolean.valueOf(target.getAutoApprove())); result.addComponent(autoApproveCB); final Button approveButton = new Button("Approve changes"); approveButton.setImmediate(true); approveButton.setEnabled(getApproveButtonEnabledState(target)); result.addComponent(approveButton); // Add a spacer that fill the remainder of the available space... result.addComponent(new Label(" ")); result.setRowExpandRatio(3, 1.0f); // Add all listeners... registerCB.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { if (event.getButton().booleanValue()) { target.register(); registerCB.setEnabled(!target.isRegistered()); autoApproveCB.setEnabled(target.isRegistered()); } } }); autoApproveCB.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { target.setAutoApprove(event.getButton().booleanValue()); approveButton.setEnabled(getApproveButtonEnabledState(target)); } }); approveButton.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { target.approve(); approveButton.setEnabled(getApproveButtonEnabledState(target)); } }); return result; }
From source file:org.apache.ace.useradmin.ui.vaadin.UserAdminWindow.java
License:Apache License
/** * Creates a new {@link UserAdminWindow} instance. */// w w w .j a v a2 s . co m public UserAdminWindow() { setCaption("Manage users"); setWidth("30%"); m_userTable = new Table(); m_userTable.setSizeFull(); m_userTable.setImmediate(true); m_userTable.setSelectable(true); m_userTable.setSortDisabled(false); m_userTable.addContainerProperty("User", UserDTO.class, null); m_userTable.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { selectUser((UserDTO) m_userTable.getValue()); } }); VerticalLayout usersList = new VerticalLayout(); usersList.setSizeFull(); usersList.addComponent(m_userTable); Button addUserButton = new Button("+"); addUserButton.setStyleName(Reindeer.BUTTON_SMALL); addUserButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { prepareForNewUser(); } }); m_removeUserButton = new Button(); m_removeUserButton.setStyleName(Reindeer.BUTTON_SMALL); m_removeUserButton.setCaption("-"); m_removeUserButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { removeSelectedUser((UserDTO) m_userTable.getValue()); } }); HorizontalLayout addRemoveUserButtons = new HorizontalLayout(); addRemoveUserButtons.setMargin(true, false, false, false); addRemoveUserButtons.setSpacing(true); addRemoveUserButtons.addComponent(addUserButton); addRemoveUserButtons.addComponent(m_removeUserButton); usersList.addComponent(addRemoveUserButtons); usersList.setExpandRatio(m_userTable, 1.0f); usersList.setExpandRatio(addRemoveUserButtons, 0.0f); ValueChangeListener changeListener = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { m_applyButton.setEnabled(isCurrentFormValid()); m_cancelButton.setEnabled(true); } }; m_usernameTextField = new TextField(); m_usernameTextField.setCaption("Username"); m_usernameTextField.setImmediate(true); m_usernameTextField.setRequired(true); m_usernameTextField.addListener(changeListener); m_passwordTextField = new PasswordField(); m_passwordTextField.setCaption("Password"); m_passwordTextField.setImmediate(true); m_passwordTextField.setRequired(true); m_passwordTextField.addListener(changeListener); m_groupSelect = new Select(); m_groupSelect.setCaption("Role"); m_groupSelect.setImmediate(true); m_groupSelect.setNullSelectionAllowed(false); m_groupSelect.setRequired(true); m_groupSelect.addListener(changeListener); FormLayout formLayout = new FormLayout(); formLayout.addComponent(m_usernameTextField); formLayout.addComponent(m_passwordTextField); formLayout.addComponent(m_groupSelect); m_applyButton = new Button(); m_applyButton.setCaption("Apply changes"); m_applyButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { storeUserInfo(); } }); m_cancelButton = new Button(); m_cancelButton.setEnabled(false); m_cancelButton.setCaption("Cancel"); m_cancelButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { selectUser((UserDTO) m_userTable.getValue()); } }); HorizontalLayout addUserButtons = new HorizontalLayout(); addUserButtons.setMargin(true, false, false, false); addUserButtons.setSpacing(true); addUserButtons.addComponent(m_applyButton); addUserButtons.addComponent(m_cancelButton); formLayout.addComponent(addUserButtons); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeFull(); horizontalLayout.setSpacing(true); horizontalLayout.addComponent(usersList); horizontalLayout.addComponent(formLayout); horizontalLayout.setExpandRatio(usersList, 0.35f); horizontalLayout.setExpandRatio(formLayout, 0.65f); addComponent(horizontalLayout); updateState(null, false /* editAllowed */); }