List of usage examples for com.vaadin.ui Button setEnabled
@Override public void setEnabled(boolean enabled)
From source file:fr.univlorraine.mondossierweb.views.AdminView.java
License:Apache License
private void ajoutGestionSwap() { layoutSwapUser.setMargin(true);/*from w w w.j a v a 2s .c om*/ layoutSwapUser.setSpacing(true); /* Boutons */ HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setWidth(100, Unit.PERCENTAGE); buttonsLayout.setSpacing(true); layoutSwapUser.addComponent(buttonsLayout); btnEditSwap = new Button(applicationContext.getMessage(NAME + ".btnEdit", null, getLocale()), FontAwesome.PENCIL); btnEditSwap.setEnabled(false); btnEditSwap.addClickListener(e -> { if (confSwapTable.getValue() instanceof UtilisateurSwap) { //configController.editConfApp((PreferencesApplication) confAppTable.getValue()); SwapUtilisateurWindow suw = new SwapUtilisateurWindow((UtilisateurSwap) confSwapTable.getValue(), false); suw.addCloseListener(f -> init()); tabSelectedPosition = 1; MainUI.getCurrent().addWindow(suw); } }); buttonsLayout.addComponent(btnEditSwap); buttonsLayout.setComponentAlignment(btnEditSwap, Alignment.MIDDLE_LEFT); btnAddSwap = new Button(applicationContext.getMessage(NAME + ".btnAdd", null, getLocale()), FontAwesome.PLUS); btnAddSwap.setEnabled(true); btnAddSwap.addClickListener(e -> { SwapUtilisateurWindow suw = new SwapUtilisateurWindow(new UtilisateurSwap(), true); suw.addCloseListener(f -> init()); tabSelectedPosition = 1; MainUI.getCurrent().addWindow(suw); }); buttonsLayout.addComponent(btnAddSwap); buttonsLayout.setComponentAlignment(btnAddSwap, Alignment.MIDDLE_CENTER); // Deconnexion Button decoBtn = new Button("Se Dconnecter", FontAwesome.SIGN_OUT); decoBtn.setEnabled(true); decoBtn.addClickListener(e -> { getUI().getPage().setLocation("j_spring_security_logout"); }); buttonsLayout.addComponent(decoBtn); buttonsLayout.setComponentAlignment(decoBtn, Alignment.MIDDLE_RIGHT); /* Table des conf */ confSwapTable = new Table(null, new BeanItemContainer<>(UtilisateurSwap.class, configController.getSwapUtilisateurs())); confSwapTable.setSizeFull(); confSwapTable.setVisibleColumns((Object[]) SWAP_FIELDS_ORDER); for (String fieldName : SWAP_FIELDS_ORDER) { confSwapTable.setColumnHeader(fieldName, applicationContext.getMessage(NAME + ".confSwapTable." + fieldName, null, getLocale())); } confSwapTable.setSortContainerPropertyId("loginSource"); confSwapTable.setColumnCollapsingAllowed(true); confSwapTable.setColumnReorderingAllowed(true); confSwapTable.setSelectable(true); confSwapTable.setImmediate(true); confSwapTable.addItemSetChangeListener(e -> confSwapTable.sanitizeSelection()); confSwapTable.addValueChangeListener(e -> { // Le bouton d'dition est actif seulement si un parametre est slectionn. boolean confIsSelected = confSwapTable.getValue() instanceof UtilisateurSwap; btnEditSwap.setEnabled(confIsSelected); }); confSwapTable.addItemClickListener(e -> { if (e.isDoubleClick()) { confSwapTable.select(e.getItemId()); btnEditSwap.click(); } }); layoutSwapUser.addComponent(confSwapTable); layoutSwapUser.setExpandRatio(confSwapTable, 1); }
From source file:info.magnolia.dam.app.assets.field.PermissionedUploadAndEditActionRenderer.java
License:Open Source License
@Override public View start(ActionDefinition definition, ActionListener listener) { View view = super.start(definition, listener); final Button button = (Button) view.asVaadinComponent(); // don't disable on click or action may be wrongly unavailable button.setDisableOnClick(false);//from w w w . ja v a 2 s .c om chooseDialogEventBus.addHandler(SelectionChangedEvent.class, new SelectionChangedEvent.Handler() { @Override public void onSelectionChanged(SelectionChangedEvent event) { // inner availability logic here mirrors the one in UpladAssetActionRenderer (in use for DirectUploadAction) Set<Object> itemIds = event.getItemIds(); if (itemIds == null || itemIds.isEmpty()) { return; } try { JcrNodeItemId nodeItemId = (JcrNodeItemId) itemIds.iterator().next(); javax.jcr.Node node = MgnlContext.getJCRSession(nodeItemId.getWorkspace()) .getNodeByIdentifier(nodeItemId.getUuid()); boolean uploadAllowed = itemIds.size() == 1; if (uploadAllowed) { uploadAllowed &= NodeUtil.isNodeType(node, NodeTypes.Folder.NAME) || NodeUtil.getAncestors(node).isEmpty(); } if (uploadAllowed) uploadAllowed &= node.getSession().hasPermission(node.getPath(), "add_node"); button.setEnabled(uploadAllowed); } catch (RepositoryException e) { button.setEnabled(false); } } }); return view; }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * abre una vista. La colocar en el lado derecho * * @param ui/*from w w w. jav a 2s. co m*/ * @param view */ public static void addView(MyUI ui, AbstractView view) { if (view == null) { System.out.println("abriendo vista null"); ui.getViewDisplay().removeAllComponents(); } else { System.out.println("abriendo vista " + view.getClass().getName() + "::" + view.getViewId()); ViewLayout v = new ViewLayout(view); if (view instanceof AbstractDialog) { AbstractDialog d = (AbstractDialog) view; // Create a sub-window and set the content Window subWindow = new Window(((AbstractDialog) view).getTitle()); HorizontalLayout footer = new HorizontalLayout(); footer.setWidth("100%"); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); Label footerText = new Label(""); footerText.setSizeUndefined(); Button ok; if (d instanceof AbstractAddRecordDialog) { ok = new Button("Add record", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { //if (d.isCloseOnOk()) subWindow.close(); ((AbstractAddRecordDialog) view).addAndClean(v.getView().getForm().getData()); } }); } else { ok = new Button(d.getOkText(), e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (d.isCloseOnOk()) subWindow.close(); ((AbstractDialog) view).onOk(v.getView().getForm().getData()); } }); } ok.addStyleName(ValoTheme.BUTTON_PRIMARY); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER); footer.addComponents(footerText); for (AbstractAction a : d.getActions()) { Button b = new Button(a.getName(), e -> { a.run(); }); //b.addStyleName(ValoTheme.BUTTON_); //b.setClickShortcut(ShortcutAction.KeyCode.ENTER); if ("previous".equalsIgnoreCase(a.getName())) { b.setIcon(VaadinIcons.ANGLE_LEFT); } else if ("next".equalsIgnoreCase(a.getName())) { b.setIcon(VaadinIcons.ANGLE_RIGHT); } footer.addComponent(b); } if (d instanceof AbstractListEditorDialog) { AbstractListEditorDialog lv = (AbstractListEditorDialog) d; Property<Integer> pos = new SimpleObjectProperty<>(); pos.setValue(lv.getInitialPos()); Button prev = new Button("Previous", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (pos.getValue() > 0) { lv.setData(pos.getValue(), view.getForm().getData()); pos.setValue(pos.getValue() - 1); view.getForm().setData(lv.getData(pos.getValue())); } } }); prev.setIcon(VaadinIcons.ANGLE_LEFT); footer.addComponent(prev); Button next = new Button("Next", e -> { List<String> errors = v.getView().getForm().validate(); if (errors.size() > 0) { io.mateu.ui.core.client.app.MateuUI.notifyErrors(errors); } else { if (pos.getValue() < lv.getListSize() - 1) { lv.setData(pos.getValue(), view.getForm().getData()); pos.setValue(pos.getValue() + 1); view.getForm().setData(lv.getData(pos.getValue())); } } }); next.setIcon(VaadinIcons.ANGLE_RIGHT); footer.addComponent(next); pos.addListener(new ChangeListener<Integer>() { @Override public void changed(ObservableValue<? extends Integer> observable, Integer oldValue, Integer newValue) { if (newValue <= 0) { prev.setEnabled(false); } else { prev.setEnabled(true); } if (newValue < lv.getListSize() - 1) { next.setEnabled(true); } else { next.setEnabled(false); } } }); } footer.addComponents(ok); //, cancel); footer.setExpandRatio(footerText, 1); v.addComponent(footer); subWindow.setContent(v); // Center it in the browser window subWindow.center(); subWindow.setModal(true); // Open it in the UI ui.addWindow(subWindow); } else { System.out.println("aadiendo vista al contenedor de vistas"); ui.getViewDisplay().removeAllComponents(); ui.getViewDisplay().addComponent(v); ui.refreshMenu(v.getArea(), v.getMenu()); } } }
From source file:io.subutai.plugin.accumulo.ui.manager.AddNodeWindow.java
public AddNodeWindow(final Accumulo accumulo, final ExecutorService executorService, final Tracker tracker, final AccumuloClusterConfig accumuloClusterConfig, Set<EnvironmentContainerHost> nodes, final NodeType nodeType) { super("Add New Node"); setModal(true);// w w w.j ava2 s . com setWidth(650, Unit.PIXELS); setHeight(450, Unit.PIXELS); GridLayout content = new GridLayout(1, 3); content.setSizeFull(); content.setMargin(true); content.setSpacing(true); HorizontalLayout topContent = new HorizontalLayout(); topContent.setSpacing(true); content.addComponent(topContent); topContent.addComponent(new Label("Nodes:")); final ComboBox hadoopNodes = new ComboBox(); hadoopNodes.setId("HadoopNodesCb"); hadoopNodes.setImmediate(true); hadoopNodes.setTextInputAllowed(false); hadoopNodes.setNullSelectionAllowed(false); hadoopNodes.setRequired(true); hadoopNodes.setWidth(200, Unit.PIXELS); for (EnvironmentContainerHost node : nodes) { hadoopNodes.addItem(node); hadoopNodes.setItemCaption(node, node.getHostname()); } if (nodes.size() == 0) { return; } hadoopNodes.setValue(nodes.iterator().next()); topContent.addComponent(hadoopNodes); final Button addNodeBtn = new Button("Add"); addNodeBtn.setId("AddSelectedNode"); topContent.addComponent(addNodeBtn); final Button ok = new Button("Ok"); addNodeBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addNodeBtn.setEnabled(false); ok.setEnabled(false); showProgress(); EnvironmentContainerHost containerHost = (EnvironmentContainerHost) hadoopNodes.getValue(); final UUID trackID = accumulo.addNode(accumuloClusterConfig.getClusterName(), containerHost.getHostname(), nodeType); executorService.execute(new Runnable() { public void run() { while (track) { TrackerOperationView po = tracker.getTrackerOperation(AccumuloClusterConfig.PRODUCT_KEY, trackID); if (po != null) { setOutput(po.getDescription() + "\nState: " + po.getState() + "\nLogs:\n" + po.getLog()); if (po.getState() != OperationState.RUNNING) { hideProgress(); ok.setEnabled(true); break; } } else { setOutput("Product operation not found. Check logs"); break; } try { Thread.sleep(1000); } catch (InterruptedException ex) { break; } } } }); } }); outputTxtArea = new TextArea("Operation output"); outputTxtArea.setId("outputTxtArea"); outputTxtArea.setRows(13); outputTxtArea.setColumns(43); outputTxtArea.setImmediate(true); outputTxtArea.setWordwrap(true); content.addComponent(outputTxtArea); indicator = new Label(); indicator.setId("indicator"); indicator.setIcon(new ThemeResource("img/spinner.gif")); indicator.setContentMode(ContentMode.HTML); indicator.setHeight(11, Unit.PIXELS); indicator.setWidth(50, Unit.PIXELS); indicator.setVisible(false); ok.setId("btnOk"); ok.setStyleName("default"); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { //close window track = false; close(); } }); HorizontalLayout bottomContent = new HorizontalLayout(); bottomContent.addComponent(indicator); bottomContent.setComponentAlignment(indicator, Alignment.MIDDLE_RIGHT); bottomContent.addComponent(ok); content.addComponent(bottomContent); content.setComponentAlignment(bottomContent, Alignment.MIDDLE_RIGHT); setContent(content); }
From source file:io.subutai.plugin.accumulo.ui.manager.Manager.java
private void enableButtons(Button... buttons) { for (Button b : buttons) { b.setEnabled(true); } }
From source file:io.subutai.plugin.accumulo.ui.manager.Manager.java
private void disableButtons(Button... buttons) { for (Button b : buttons) { b.setEnabled(false); } }
From source file:it.vige.greenarea.bpm.custom.ui.form.GreenareaPagedTable.java
License:Apache License
@Override public HorizontalLayout createControls() { I18nManager I18nManager = get().getI18nManager(); final PagedTableContainer container = (PagedTableContainer) getContainerDataSource(); Label itemsPerPageLabel = new Label(I18nManager.getMessage(PAGINAZIONE_PER_PAGINA)); final ComboBox itemsPerPageSelect = new ComboBox(); itemsPerPageSelect.addItem("3"); itemsPerPageSelect.addItem("10"); itemsPerPageSelect.addItem("25"); itemsPerPageSelect.addItem("50"); itemsPerPageSelect.setImmediate(true); itemsPerPageSelect.setNullSelectionAllowed(false); itemsPerPageSelect.setWidth("50px"); itemsPerPageSelect.addListener(new ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { setPageLength(Integer.valueOf(String.valueOf(event.getProperty().getValue()))); }//from www . ja v a2s . c om }); itemsPerPageSelect.select(maxRecords + ""); Label pageLabel = new Label(I18nManager.getMessage(PAGINAZIONE_PAG) + " ", Label.CONTENT_XHTML); final TextField currentPageTextField = new TextField(); currentPageTextField.setValue(String.valueOf(getCurrentPage())); currentPageTextField.addValidator(new IntegerValidator(null)); Label separatorLabel = new Label(" / ", Label.CONTENT_XHTML); final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), Label.CONTENT_XHTML); currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL); currentPageTextField.setImmediate(true); currentPageTextField.addListener(new ValueChangeListener() { private static final long serialVersionUID = -2255853716069800092L; public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) { if (currentPageTextField.isValid() && currentPageTextField.getValue() != null) { int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue())); setCurrentPage(page); } } }); pageLabel.setWidth(null); currentPageTextField.setWidth("20px"); separatorLabel.setWidth(null); totalPagesLabel.setWidth(null); HorizontalLayout controlBar = new HorizontalLayout(); HorizontalLayout pageSize = new HorizontalLayout(); HorizontalLayout pageManagement = new HorizontalLayout(); final Button first = new Button("<<", new ClickListener() { private static final long serialVersionUID = -355520120491283992L; public void buttonClick(ClickEvent event) { setCurrentPage(0); if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) { Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()]; GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm .getComponent(1); FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0); FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent .getRenderer(formProperty); greenareaFormPropertiesComponent.getForm() .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId()) .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " " + selectable.getValue()); } } }); final Button previous = new Button("<", new ClickListener() { private static final long serialVersionUID = -355520120491283992L; public void buttonClick(ClickEvent event) { previousPage(); if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) { Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()]; GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm .getComponent(1); FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0); FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent .getRenderer(formProperty); greenareaFormPropertiesComponent.getForm() .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId()) .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " " + selectable.getValue()); } } }); final Button next = new Button(">", new ClickListener() { private static final long serialVersionUID = -1927138212640638452L; public void buttonClick(ClickEvent event) { nextPage(); if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) { Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()]; GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm .getComponent(1); FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0); FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent .getRenderer(formProperty); greenareaFormPropertiesComponent.getForm() .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId()) .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " " + selectable.getValue()); } } }); final Button last = new Button(">>", new ClickListener() { private static final long serialVersionUID = -355520120491283992L; public void buttonClick(ClickEvent event) { setCurrentPage(getTotalAmountOfPages()); if (values != null && !values.isEmpty() && values.iterator().next() instanceof Selectable) { Selectable selectable = (Selectable) values.toArray()[container.getStartIndex()]; GreenareaFormPropertiesComponent greenareaFormPropertiesComponent = (GreenareaFormPropertiesComponent) greenareaFormPropertiesForm .getComponent(1); FormProperty formProperty = greenareaFormPropertiesComponent.getFormProperties().get(0); FormPropertyRenderer formPropertyRenderer = greenareaFormPropertiesComponent .getRenderer(formProperty); greenareaFormPropertiesComponent.getForm() .getField(greenareaFormPropertiesComponent.getFormProperties().get(0).getId()) .setValue(formPropertyRenderer.getPropertyLabel(formProperty) + " " + selectable.getValue()); } } }); first.setStyleName(Reindeer.BUTTON_LINK); previous.setStyleName(Reindeer.BUTTON_LINK); next.setStyleName(Reindeer.BUTTON_LINK); last.setStyleName(Reindeer.BUTTON_LINK); itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption"); itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox"); pageLabel.addStyleName("pagedtable-pagecaption"); currentPageTextField.addStyleName("pagedtable-pagefield"); separatorLabel.addStyleName("pagedtable-separator"); totalPagesLabel.addStyleName("pagedtable-total"); first.addStyleName("pagedtable-first"); previous.addStyleName("pagedtable-previous"); next.addStyleName("pagedtable-next"); last.addStyleName("pagedtable-last"); itemsPerPageLabel.addStyleName("pagedtable-label"); itemsPerPageSelect.addStyleName("pagedtable-combobox"); pageLabel.addStyleName("pagedtable-label"); currentPageTextField.addStyleName("pagedtable-label"); separatorLabel.addStyleName("pagedtable-label"); totalPagesLabel.addStyleName("pagedtable-label"); first.addStyleName("pagedtable-button"); previous.addStyleName("pagedtable-button"); next.addStyleName("pagedtable-button"); last.addStyleName("pagedtable-button"); pageSize.addComponent(itemsPerPageLabel); pageSize.addComponent(itemsPerPageSelect); pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT); pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT); pageSize.setSpacing(true); pageManagement.addComponent(first); pageManagement.addComponent(previous); pageManagement.addComponent(pageLabel); pageManagement.addComponent(currentPageTextField); pageManagement.addComponent(separatorLabel); pageManagement.addComponent(totalPagesLabel); pageManagement.addComponent(next); pageManagement.addComponent(last); pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT); pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT); pageManagement.setWidth(null); pageManagement.setSpacing(true); controlBar.addComponent(pageSize); controlBar.addComponent(pageManagement); controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER); controlBar.setWidth("100%"); controlBar.setExpandRatio(pageSize, 1); addListener(new PageChangeListener() { public void pageChanged(PagedTableChangeEvent event) { first.setEnabled(container.getStartIndex() > 0); previous.setEnabled(container.getStartIndex() > 0); next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength()); currentPageTextField.setValue(String.valueOf(getCurrentPage())); totalPagesLabel.setValue(getTotalAmountOfPages()); itemsPerPageSelect.setValue(String.valueOf(getPageLength())); } }); controlBar.setStyleName("pagination"); return controlBar; }
From source file:jp.primecloud.auto.ui.MyCloudManage.java
License:Open Source License
MyCloudManage(Application ap) { apl = ap;/*w w w . j a va 2s . com*/ // setIcon(Icons.EDITMINI.resource()); setCaption(ViewProperties.getCaption("window.myCloudManage")); setModal(true); setWidth("550px"); VerticalLayout layout = (VerticalLayout) getContent(); layout.setMargin(true); // ? HorizontalLayout tbar = new HorizontalLayout(); tbar.setWidth("100%"); tbar.setSpacing(true); // ? Label tcaption = new Label(ViewProperties.getCaption("table.cloud")); tcaption.setWidth("300px"); tbar.addComponent(tcaption); tbar.setComponentAlignment(tcaption, Alignment.MIDDLE_LEFT); // Edit Button editButton = new Button(ViewProperties.getCaption("button.editCloud")); editButton.setDescription(ViewProperties.getCaption("description.editCloud")); editButton.setIcon(Icons.EDITMINI.resource()); editButton.setWidth("85px"); editButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.editButtonClick(event); } }); tbar.addComponent(editButton); tbar.setComponentAlignment(editButton, Alignment.BOTTOM_RIGHT); // Delete Button deleteButton = new Button(ViewProperties.getCaption("button.delete")); deleteButton.setDescription(ViewProperties.getCaption("description.delete")); deleteButton.setWidth("85px"); deleteButton.setIcon(Icons.DELETEMINI.resource()); deleteButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.deleteButtonClick(event); } }); tbar.addComponent(deleteButton); tbar.setComponentAlignment(deleteButton, Alignment.BOTTOM_RIGHT); tbar.setExpandRatio(tcaption, 10); layout.addComponent(tbar); // ? Label spacer1 = new Label(""); spacer1.setHeight("5px"); layout.addComponent(spacer1); // cloudTable = new CloudTable(); layout.addComponent(cloudTable); // ? Label spacer2 = new Label(""); spacer2.setHeight("7px"); layout.addComponent(spacer2); // ?? HorizontalLayout bbar = new HorizontalLayout(); bbar.setWidth("100%"); HorizontalLayout rlay = new HorizontalLayout(); rlay.setSpacing(true); // New Button addButton = new Button(ViewProperties.getCaption("button.newCloud")); addButton.setDescription(ViewProperties.getCaption("description.newCloud")); addButton.setIcon(Icons.ADD.resource()); addButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.addButtonClick(event); } }); bbar.addComponent(addButton); bbar.setComponentAlignment(addButton, Alignment.MIDDLE_LEFT); // Switch Button switchButton = new Button(ViewProperties.getCaption("button.switch")); switchButton.setDescription(ViewProperties.getCaption("description.mycloud.switch")); switchButton.setWidth("85px"); switchButton.setIcon(Icons.SELECTMINI.resource()); switchButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.switchButtonClick(event); } }); // [Enter]?switchButton switchButton.setClickShortcut(KeyCode.ENTER); switchButton.focus(); rlay.addComponent(switchButton); // Cancel Button cancelButton = new Button(ViewProperties.getCaption("button.cancel")); cancelButton.setDescription(ViewProperties.getCaption("description.cancel")); cancelButton.setWidth("85px"); cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { MyCloudManage.this.close(); } }); rlay.addComponent(cancelButton); bbar.addComponent(rlay); bbar.setComponentAlignment(rlay, Alignment.MIDDLE_RIGHT); layout.addComponent(bbar); // ??? initData(); //???/? if (ViewContext.getPowerUser()) { addButton.setEnabled(true); deleteButton.setEnabled(true); editButton.setEnabled(true); //?????????????? if (ViewContext.getPowerUser() && !ViewContext.getPowerDefaultMaster().equals(ViewContext.getLoginUser())) { addButton.setEnabled(false); } } else if (ViewContext.getUserNo().equals(ViewContext.getLoginUser())) { addButton.setEnabled(true); deleteButton.setEnabled(true); editButton.setEnabled(true); } else { addButton.setEnabled(false); deleteButton.setEnabled(false); editButton.setEnabled(false); } // showClouds(); }
From source file:jp.primecloud.auto.ui.ServerTable.java
License:Open Source License
public void setButtonStatus(Instance instance) { for (Entry<Long, List<Button>> entry : map.entrySet()) { Long key = entry.getKey(); if (key.equals(instance.getInstanceNo())) { for (Button button : entry.getValue()) { if ("".equals(instance.getStatus()) || InstanceStatus.STOPPED.toString().equals(instance.getStatus())) { if (("STOP".equals(button.getCaption()))) { button.setEnabled(false); } else if (("START".equals(button.getCaption()))) { button.setIcon(Icons.PLAY.resource()); button.setDescription(ViewProperties.getCaption("description.startServer")); button.setEnabled(true); } else { button.setEnabled(true); }//from w w w . ja v a 2s.c o m } else if (InstanceStatus.RUNNING.toString().equals(instance.getStatus())) { if (("STOP".equals(button.getCaption()))) { button.setEnabled(true); } else if (("START".equals(button.getCaption()))) { button.setIcon(Icons.RELOAD.resource()); button.setDescription(ViewProperties.getCaption("description.reloadServer")); button.setEnabled(true); } else { button.setEnabled(false); } } else if (InstanceStatus.WARNING.toString().equals(instance.getStatus())) { if (("STOP".equals(button.getCaption()))) { button.setEnabled(true); } else { button.setEnabled(false); } } else { button.setEnabled(false); } } } else { for (Button button : entry.getValue()) { button.setEnabled(false); } } } }
From source file:jp.primecloud.auto.ui.ServiceTable.java
License:Open Source License
public void setButtonStatus(ComponentDto dto) { //????????/*from w w w . j av a 2 s. co m*/ // START,EDIT,STOP // ? START,EDIT,DELETE // ??? // WARNINGEDIT,STOP jp.primecloud.auto.entity.crud.Component component = dto.getComponent(); for (Entry<Long, List<Button>> entry : map.entrySet()) { Long key = entry.getKey(); if (key.equals(component.getComponentNo())) { for (Button button : entry.getValue()) { if ("".equals(dto.getStatus()) || "STOPPED".equals(dto.getStatus())) { if (("STOP".equals(button.getCaption()))) { button.setEnabled(false); } else if (("START".equals(button.getCaption()))) { button.setIcon(Icons.PLAY.resource()); button.setDescription(ViewProperties.getCaption("description.startService")); button.setEnabled(true); } else { button.setEnabled(true); } } else if ("RUNNING".equals(dto.getStatus())) { if (("STOP".equals(button.getCaption()))) { button.setEnabled(true); } else if (("START".equals(button.getCaption()))) { button.setIcon(Icons.RELOAD.resource()); button.setDescription(ViewProperties.getCaption("description.reloadService")); button.setEnabled(true); } else if (("EDIT".equals(button.getCaption()))) { button.setEnabled(true); } else { button.setEnabled(false); } } else if ("WARNING".equals(dto.getStatus())) { if (("STOP".equals(button.getCaption()))) { button.setEnabled(true); } else if ("START".equals(button.getCaption())) { button.setIcon(Icons.RELOAD.resource()); button.setDescription(ViewProperties.getCaption("description.reloadService")); button.setEnabled(true); } else if ("EDIT".equals(button.getCaption())) { // ???????????? boolean processing = false; for (ComponentInstanceDto componentInstance : dto.getComponentInstances()) { ComponentInstanceStatus status = ComponentInstanceStatus .fromStatus(componentInstance.getComponentInstance().getStatus()); if (status != ComponentInstanceStatus.RUNNING && status != ComponentInstanceStatus.WARNING && status != ComponentInstanceStatus.STOPPED) { processing = true; break; } } button.setEnabled(!processing); } else { button.setEnabled(false); } } else { button.setEnabled(false); } } } else { for (Button button : entry.getValue()) { button.setEnabled(false); } } } }