List of usage examples for com.vaadin.ui Button setEnabled
@Override public void setEnabled(boolean enabled)
From source file:net.sourceforge.javydreamercsw.validation.manager.web.workflow.WorkflowViewer.java
License:Apache License
private Component getControls() { VerticalLayout controls = new VerticalLayout(); Button addStep = new Button(TRANSLATOR.translate("general.add.step")); VerticalLayout vl = new VerticalLayout(); TextField name = new TextField(TRANSLATOR.translate("general.name")); vl.addComponent(name);/*from ww w .j av a2 s .c o m*/ addStep.addClickListener(listener -> { MessageBox prompt = MessageBox.createQuestion().withCaption(TRANSLATOR.translate("general.add.step")) .withMessage(vl).withYesButton(() -> { if (name.getValue() != null && !name.getValue().isEmpty()) { Graph.Node node = new Graph.Node(TRANSLATOR.translate(name.getValue())); nodes.put(--count, node); node.setParam(KEY, "" + count); node.setParam(ITEM_NAME, TRANSLATOR.translate(name.getValue())); added.add(node); refreshWorkflow(); } }, ButtonOption.focus(), ButtonOption.icon(VaadinIcons.CHECK)) .withNoButton(ButtonOption.icon(VaadinIcons.CLOSE)); prompt.getWindow().setIcon(ValidationManagerUI.SMALL_APP_ICON); prompt.open(); }); addStep.setWidth(100, Unit.PERCENTAGE); addStep.setEnabled(workflows.getValue() != null); controls.addComponent(addStep); Button addTransition = new Button(TRANSLATOR.translate("general.add.transition")); VerticalLayout vl2 = new VerticalLayout(); TextField transitionName = new TextField(TRANSLATOR.translate("general.name")); ListSelect nodeList = new ListSelect(TRANSLATOR.translate("general.step")); BeanItemContainer<Graph.Node> container = new BeanItemContainer<>(Graph.Node.class, nodes.values()); nodeList.setContainerDataSource(container); nodeList.getItemIds().forEach(id -> { Graph.Node temp = ((Graph.Node) id); nodeList.setItemCaption(id, temp.getId()); }); nodeList.setNullSelectionAllowed(false); vl2.addComponent(transitionName); vl2.addComponent(nodeList); addTransition.addClickListener(listener -> { MessageBox prompt = MessageBox.createQuestion() .withCaption(TRANSLATOR.translate("general.add.transition")).withMessage(vl2) .withYesButton(() -> { if (transitionName.getValue() != null && !transitionName.getValue().isEmpty() && selected instanceof Subgraph.Node) { Subgraph.Edge edge = new Subgraph.Edge(); edge.setDest((Subgraph.Node) nodeList.getValue()); edges.put(transitionName.getValue(), new AbstractMap.SimpleEntry<>((Subgraph.Node) selected, edge)); edge.setParam(KEY, "" + --count); added.add(edge); refreshWorkflow(); } }, ButtonOption.focus(), ButtonOption.icon(VaadinIcons.CHECK)) .withNoButton(ButtonOption.icon(VaadinIcons.CLOSE)); prompt.getWindow().setIcon(ValidationManagerUI.SMALL_APP_ICON); prompt.open(); }); addTransition.setWidth(100, Unit.PERCENTAGE); addTransition.setEnabled(selected instanceof Subgraph.Node); controls.addComponent(addTransition); Button delete = new Button(TRANSLATOR.translate("general.delete")); delete.setEnabled(selected != null); delete.setWidth(100, Unit.PERCENTAGE); delete.addClickListener(listener -> { MessageBox prompt = MessageBox.createQuestion().withCaption(TRANSLATOR.translate("general.delete")) .withMessage(TRANSLATOR.translate("general.delete.confirmation")).withYesButton(() -> { if (selected instanceof Subgraph.Edge) { Subgraph.Edge edge = (Subgraph.Edge) selected; edges.remove(edge.getParam("label")); addToDelete(edge); } else { Graph.Node node = (Graph.Node) selected; addToDelete(node); } refreshWorkflow(); }, ButtonOption.focus(), ButtonOption.icon(VaadinIcons.CHECK)) .withNoButton(ButtonOption.icon(VaadinIcons.CLOSE)); prompt.getWindow().setIcon(ValidationManagerUI.SMALL_APP_ICON); prompt.open(); }); controls.addComponent(delete); Button rename = new Button(TRANSLATOR.translate("general.rename")); rename.setWidth(100, Unit.PERCENTAGE); rename.setEnabled(selected != null); rename.addClickListener(listener -> { Window w = new VMWindow(TRANSLATOR.translate("general.rename")); w.setWidth(25, Unit.PERCENTAGE); w.setHeight(25, Unit.PERCENTAGE); UI.getCurrent().addWindow(w); }); controls.addComponent(rename); Button save = new Button(TRANSLATOR.translate("general.save")); save.setWidth(100, Unit.PERCENTAGE); save.setEnabled(!added.isEmpty() || !deleted.isEmpty()); save.addClickListener(listener -> { List<Graph.Node> nodesToAdd = new ArrayList<>(); List<Subgraph.Edge> edgesToAdd = new ArrayList<>(); WorkflowServer ws = new WorkflowServer(((Workflow) workflows.getValue()).getId()); added.forEach(a -> { if (a instanceof Graph.Node) { nodesToAdd.add((Graph.Node) a); } else if (a instanceof Subgraph.Edge) { edgesToAdd.add((Subgraph.Edge) a); } }); deleted.forEach(a -> { LOG.log(Level.INFO, "Deleted: {0}", a); }); nodesToAdd.forEach(node -> { try { ws.addStep(node.getParam(ITEM_NAME)); } catch (VMException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage(), ex); } }); displayWorkflow(ws.getEntity()); }); controls.addComponent(save); Button cancel = new Button(TRANSLATOR.translate("general.cancel")); cancel.setWidth(100, Unit.PERCENTAGE); cancel.setEnabled(selected != null); cancel.addClickListener(listener -> { Workflow w = (Workflow) workflows.getValue(); if (w != null) { displayWorkflow(w); } deleted.clear(); added.clear(); }); controls.addComponent(cancel); return controls; }
From source file:nz.co.senanque.vaadinsupport.AbstractButtonPainter.java
License:Apache License
public void paint(Button button) { if (!getPermissionManager().hasPermission(getPermissionName())) { button.setEnabled(false); }//from w w w.j a v a2 s . c o m }
From source file:nz.co.senanque.vaadinsupport.FieldButtonPainter.java
License:Apache License
public void paint(Button button) { Boolean b = (Boolean) m_property.getValue(); if (b != null && b) { button.setEnabled(true); } else {/* ww w . ja v a2 s . c o m*/ button.setEnabled(false); } super.paint(button); }
From source file:nz.co.senanque.vaadinsupport.SubmitButtonPainter.java
License:Apache License
public void paint(Button button) { if (m_form != null && m_form.isReadOnly()) { button.setEnabled(false); } else {/* ww w .j ava2 s . c o m*/ button.setEnabled(isEnabled()); } super.paint(button); }
From source file:org.activiti.explorer.ui.management.processdefinition.ActiveProcessDefinitionDetailPanel.java
License:Apache License
protected void initActions(final AbstractPage parentPage) { ActiveProcessDefinitionPage processDefinitionPage = (ActiveProcessDefinitionPage) parentPage; Button suspendButton = new Button(i18nManager.getMessage(Messages.PROCESS_SUSPEND)); suspendButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { ChangeProcessSuspensionStatePopupWindow popupWindow = new ChangeProcessSuspensionStatePopupWindow( processDefinition.getId(), parentPage, true); ExplorerApp.get().getViewManager().showPopupWindow(popupWindow); }/*from ww w . j a v a 2 s .c o m*/ }); // Check if button must be disabled boolean suspendJobPending = false; List<Job> jobs = ProcessEngines.getDefaultProcessEngine().getManagementService().createJobQuery() .processDefinitionId(processDefinition.getId()).list(); for (Job job : jobs) { // TODO: this is a hack. Needs to be cleaner in engine! if (((JobEntity) job).getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)) { suspendJobPending = true; break; } } suspendButton.setEnabled(!suspendJobPending); // Clear toolbar and add 'start' button processDefinitionPage.getToolBar().removeAllButtons(); processDefinitionPage.getToolBar().addButton(suspendButton); }
From source file:org.activiti.explorer.ui.management.processdefinition.SuspendedProcessDefinitionDetailPanel.java
License:Apache License
protected void initActions(final AbstractPage parentPage) { SuspendedProcessDefinitionPage processDefinitionPage = (SuspendedProcessDefinitionPage) parentPage; Button activateButton = new Button(i18nManager.getMessage(Messages.PROCESS_ACTIVATE)); activateButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { ChangeProcessSuspensionStatePopupWindow popupWindow = new ChangeProcessSuspensionStatePopupWindow( processDefinition.getId(), parentPage, false); ExplorerApp.get().getViewManager().showPopupWindow(popupWindow); }/* w w w .j ava2s. c om*/ }); // Check if already activation job pending boolean activateJobPending = false; List<Job> jobs = ProcessEngines.getDefaultProcessEngine().getManagementService().createJobQuery() .processDefinitionId(processDefinition.getId()).list(); for (Job job : jobs) { // TODO: this is a hack. Needs to be cleaner in engine! if (((JobEntity) job).getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) { activateJobPending = true; break; } } activateButton.setEnabled(!activateJobPending); // Clear toolbar and add 'start' button processDefinitionPage.getToolBar().removeAllButtons(); processDefinitionPage.getToolBar().addButton(activateButton); }
From source file:org.activiti.explorer.ui.process.simple.editor.SimpleTableEditor.java
License:Apache License
protected void initButtons(GridLayout layout) { final Button saveButton = new Button( ExplorerApp.get().getI18nManager().getMessage(Messages.PROCESS_EDITOR_SAVE)); saveButton.setEnabled(nameField.getValue() != null && !"".equals((String) nameField.getValue())); toolBar.addButton(saveButton);/*from w w w . jav a 2 s. co m*/ saveButton.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { save(); } }); // Dependending on namefield value, save button is enabled nameField.addListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { if (nameField.getValue() != null && !"".equals((String) nameField.getValue())) { saveButton.setEnabled(true); } else { saveButton.setEnabled(false); } } }); }
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);/*from w w w. jav a 2s . co m*/ 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.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 ww w . ja v a 2s.c o 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.webui.vaadin.component.BaseObjectPanel.java
License:Apache License
@Override public String getStyle(Object itemId, Object propertyId) { Item item = getItem(itemId);//from w ww.ja v a 2 s .c o m if (propertyId == null) { updateItemIcon(itemId); // no propertyId, styling row if (m_associations.isAssociated(itemId)) { return "associated"; } if (m_associations.isRelated(itemId)) { return "related"; } // Try to highlight the parent of any dynamic link... Collection<?> children = getChildren(itemId); if (children != null && !children.isEmpty()) { Set<?> activeSelection = m_associations.getActiveSelection(); if (Collections.disjoint(children, activeSelection)) { // Not in the active selection, check whether we've got an associated or related child... for (Object child : children) { if (m_associations.isAssociated(child)) { return "associated-parent"; } if (m_associations.isRelated(child)) { return "related-parent"; } } } else { // one of the children is selected... return "associated-parent"; } } } else if (OBJECT_DESCRIPTION.equals(propertyId)) { return "description"; } else if (ACTION_UNLINK.equals(propertyId)) { Button unlinkButton = (Button) item.getItemProperty(propertyId).getValue(); if (unlinkButton != null) { boolean enabled = m_associations.isAssociated(itemId); unlinkButton.setEnabled(enabled); } } return null; }