List of usage examples for com.vaadin.ui Button setDescription
public void setDescription(String description)
From source file:org.escidoc.browser.ui.view.WikiPageView.java
License:Open Source License
private Button showDelete(final ResourceModel child) { Button edit = new Button(); edit.setStyleName(BaseTheme.BUTTON_LINK); edit.setDescription(ViewConstants.PROPERTY_DELETE); edit.setIcon(new ThemeResource("images/wpzoom/trash.png")); edit.addListener(new Button.ClickListener() { @Override/*from w ww .j a va 2 s . c o m*/ public void buttonClick(ClickEvent event) { MessageBox mb = new MessageBox(router.getMainWindow().getWindow(), "Are you sure?", MessageBox.Icon.QUESTION, "Do you really want to continue?", new MessageBox.ButtonConfig(MessageBox.ButtonType.YES, "Yes"), new MessageBox.ButtonConfig(MessageBox.ButtonType.NO, "No")); mb.show(new MessageBox.EventListener() { private static final long serialVersionUID = 1L; @Override public void buttonClicked(ButtonType buttonType) { if (buttonType.equals(MessageBox.ButtonType.YES)) { controller.deleteItem(); } } }); } }); return edit; }
From source file:org.escidoc.browser.ui.view.WikiPageView.java
License:Open Source License
private Button showShare(final ResourceModel child) { Button edit = new Button(); edit.setStyleName(BaseTheme.BUTTON_LINK); edit.setDescription(ViewConstants.PROPERTY_SHARE); edit.setIcon(new ThemeResource("images/wpzoom/share.png")); edit.addListener(new Button.ClickListener() { @Override/* www .j ava2 s. c o m*/ public void buttonClick(ClickEvent event) { controller.getRouter().getMainWindow().showNotification("Not yet Implemented " + child.getId(), Notification.TYPE_HUMANIZED_MESSAGE); } }); return edit; }
From source file:org.escidoc.browser.ui.view.WikiPageView.java
License:Open Source License
private Button showShare(Version version) { Button edit = new Button(); edit.setStyleName(BaseTheme.BUTTON_LINK); edit.setDescription(ViewConstants.PROPERTY_SHARE); edit.setIcon(new ThemeResource("images/wpzoom/share.png")); edit.addListener(new Button.ClickListener() { @Override//from w w w. j av a 2 s . c o m public void buttonClick(ClickEvent event) { controller.getRouter().getMainWindow().showNotification("Not yet Implemented ", Notification.TYPE_HUMANIZED_MESSAGE); } }); return edit; }
From source file:org.escidoc.browser.ui.view.WikiPageView.java
License:Open Source License
private Button downloadShow(final ResourceModel child) { Button edit = new Button(); edit.setStyleName(BaseTheme.BUTTON_LINK); edit.setDescription(ViewConstants.PROPERTY_DOWNLOAD); edit.setIcon(new ThemeResource("images/wpzoom/eye.png")); edit.addListener(new Button.ClickListener() { @Override/*ww w. j ava 2 s . c o m*/ public void buttonClick(ClickEvent event) { try { router.getMainWindow().open( new ExternalResource(buildUri(controller.getMetadata(ViewConstants.WIKIPAGEMD))), "_blank"); } catch (EscidocClientException e) { controller.getRouter().getMainWindow().showNotification( "No content to download! Could it be that this Wiki is empty!?", Notification.TYPE_HUMANIZED_MESSAGE); } } }); return edit; }
From source file:org.escidoc.browser.ui.view.WikiPageView.java
License:Open Source License
private Button downloadShowVersion(final Version version) { Button edit = new Button(); edit.setStyleName(BaseTheme.BUTTON_LINK); edit.setDescription(ViewConstants.PROPERTY_DOWNLOAD); edit.setIcon(new ThemeResource("images/wpzoom/eye.png")); edit.addListener(new Button.ClickListener() { @Override/*from w ww . j a v a 2s.com*/ public void buttonClick(ClickEvent event) { try { controller.getMetadata(ViewConstants.WIKIPAGEMD); router.getMainWindow().open(new ExternalResource(buildUri(version.getXLinkHref()), "_blank")); } catch (EscidocClientException e) { controller.getRouter().getMainWindow().showNotification( "No content to download! Could it be that this Wiki is empty!?", Notification.TYPE_HUMANIZED_MESSAGE); } } }); return edit; }
From source file:org.ikasan.dashboard.ui.administration.panel.PolicyManagementPanel.java
License:BSD License
/** * /*from w ww. ja v a2s.co m*/ */ protected void createPolicyDropPanel() { this.policyDropPanel = new Panel(); Label rolePoliciesLabel = new Label("Role/Policy Associations"); rolePoliciesLabel.setStyleName(ValoTheme.LABEL_HUGE); this.policyDropPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); this.policyDropPanel.setHeight("100%"); this.policyDropPanel.setWidth("100%"); this.rolesCombo = new ComboBox("Roles"); this.rolesCombo.setWidth("90%"); this.rolesCombo.addValueChangeListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { final Role role = (Role) event.getProperty().getValue(); if (role != null) { List<Policy> policies = securityService.getAllPoliciesWithRole(role.getName()); PolicyManagementPanel.this.policyDropTable.removeAllItems(); for (final Policy policy : policies) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Remove Policy from this Role"); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { role.getPolicies().remove(policy); PolicyManagementPanel.this.saveRole(role); PolicyManagementPanel.this.policyDropTable.removeItem(policy.getName()); PolicyManagementPanel.this.roleTable.removeItem(role); } }); PolicyManagementPanel.this.policyDropTable .addItem(new Object[] { policy.getName(), deleteButton }, policy.getName()); } } } }); this.policyDropTable = new Table(); this.policyDropTable.addContainerProperty("Role Policies", String.class, null); this.policyDropTable.addContainerProperty("", Button.class, null); this.policyDropTable.setHeight("700px"); this.policyDropTable.setWidth("300px"); this.policyDropTable.setDragMode(TableDragMode.ROW); this.policyDropTable.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); if (rolesCombo.getValue() == null) { // Do nothing if there is no role selected logger.info("Ignoring drop: " + dropEvent); return; } final WrapperTransferable t = (WrapperTransferable) dropEvent.getTransferable(); final AutocompleteField sourceContainer = (AutocompleteField) t.getDraggedComponent(); logger.info("sourceContainer.getText(): " + sourceContainer.getText()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Remove Policy from this Role"); final Policy policy = PolicyManagementPanel.this.securityService .findPolicyByName(sourceContainer.getText()); final Role selectedRole = PolicyManagementPanel.this.securityService .findRoleByName(((Role) rolesCombo.getValue()).getName()); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { selectedRole.getPolicies().remove(policy); PolicyManagementPanel.this.saveRole(selectedRole); policyDropTable.removeItem(policy.getName()); roleTable.removeItem(selectedRole); } }); PolicyManagementPanel.this.policyDropTable.addItem( new Object[] { sourceContainer.getText(), deleteButton }, sourceContainer.getText()); selectedRole.getPolicies().add(policy); PolicyManagementPanel.this.saveRole(selectedRole); policy.getRoles().add(selectedRole); PolicyManagementPanel.this.roleTable.removeAllItems(); for (final Role role : policy.getRoles()) { Button roleDeleteButton = new Button(); roleDeleteButton.setIcon(VaadinIcons.TRASH); roleDeleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Remove Policy from this Role"); roleDeleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { selectedRole.getPolicies().remove(policy); PolicyManagementPanel.this.saveRole(selectedRole); PolicyManagementPanel.this.roleTable.removeItem(role); PolicyManagementPanel.this.policyDropTable.removeItem(policy.getName()); } }); PolicyManagementPanel.this.roleTable.addItem(new Object[] { role.getName(), roleDeleteButton }, role); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); GridLayout layout = new GridLayout(); layout.setSpacing(true); layout.setWidth("100%"); layout.setHeight("100%"); layout.addComponent(rolePoliciesLabel); layout.addComponent(this.rolesCombo); Label policyDropHintLabel = new Label(); policyDropHintLabel.setCaptionAsHtml(true); policyDropHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drop a policy into the table below to associate with a role."); policyDropHintLabel.addStyleName(ValoTheme.LABEL_TINY); policyDropHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(policyDropHintLabel); layout.addComponent(this.policyDropTable); this.policyDropPanel.setContent(layout); }
From source file:org.ikasan.dashboard.ui.administration.panel.PolicyManagementPanel.java
License:BSD License
/** * Helper method to initialise behaviour of the policy name field. * //from ww w . ja v a2 s .c o m * @return */ protected DragAndDropWrapper initPolicyNameField() { // The policy field name is an autocomplete field. this.policyNameField = new AutocompleteField<Policy>(); this.policyNameField.setWidth("70%"); // We also want it to be drag and drop friendly. final DragAndDropWrapper policyNameFieldWrap = new DragAndDropWrapper(policyNameField); policyNameFieldWrap.setDragStartMode(DragStartMode.COMPONENT); // In order to have the auto complete work we must add a query listener. // The query listener gets activated when a user begins to type into // the field and hits the database looking for suggestions. policyNameField.setQueryListener(new AutocompleteQueryListener<Policy>() { @Override public void handleUserQuery(AutocompleteField<Policy> field, String query) { // Iterate over the returned results and add them as suggestions for (Policy policy : securityService.getPolicyByNameLike(query)) { field.addSuggestion(policy, policy.getName()); } } }); // Once a suggestion is selected the listener below gets fired and we populate // associated fields as required. policyNameField.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<Policy>() { @Override public void onSuggestionPicked(final Policy pickedPolicy) { PolicyManagementPanel.this.policy = pickedPolicy; // Populate all the policy related fields. PolicyManagementPanel.this.policyItem = new BeanItem<Policy>(PolicyManagementPanel.this.policy); PolicyManagementPanel.this.policyNameField .setPropertyDataSource(policyItem.getItemProperty("name")); PolicyManagementPanel.this.descriptionField .setPropertyDataSource(policyItem.getItemProperty("description")); if (PolicyManagementPanel.this.policy.getPolicyLink() != null) { PolicyManagementPanel.this.linkedEntity.setVisible(true); PolicyManagementPanel.this.linkType.setVisible(true); PolicyManagementPanel.this.linkTypeLabel.setVisible(true); PolicyManagementPanel.this.linkedEntityLabel.setVisible(true); PolicyManagementPanel.this.linkType.setValue( PolicyManagementPanel.this.policy.getPolicyLink().getPolicyLinkType().getName()); PolicyManagementPanel.this.linkedEntity .setValue(PolicyManagementPanel.this.policy.getPolicyLink().getName()); } else { PolicyManagementPanel.this.linkType.setValue(null); PolicyManagementPanel.this.linkedEntity.setValue(new String()); PolicyManagementPanel.this.linkedEntity.setVisible(false); PolicyManagementPanel.this.linkedEntityLabel.setVisible(false); PolicyManagementPanel.this.linkType.setVisible(false); PolicyManagementPanel.this.linkTypeLabel.setVisible(false); } roleTable.removeAllItems(); // Add all the associated roles to the role table. for (final Role role : policy.getRoles()) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Remove Policy from this Role"); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { // Update the roles associated with policy // and update in the DB. policy.getRoles().remove(role); PolicyManagementPanel.this.savePolicy(policy); // Once we are happy that the DB call was fine // update the UI components to reflect the change. roleTable.removeItem(role); policyDropTable.removeItem(policy.getName()); } }); roleTable.addItem(new Object[] { role.getName(), deleteButton }, role); } PolicyManagementPanel.this.cancelButton.setVisible(false); PolicyManagementPanel.this.newButton.setVisible(true); PolicyManagementPanel.this.deleteButton.setVisible(true); } }); return policyNameFieldWrap; }
From source file:org.ikasan.dashboard.ui.administration.panel.RoleManagementPanel.java
License:BSD License
/** * //from w ww .j a va 2 s. c om */ protected void createPolicyDropPanel() { this.policyDropPanel = new Panel(); this.policyDropPanel.setStyleName(ValoTheme.PANEL_BORDERLESS); this.policyDropPanel.setHeight("100%"); this.policyDropPanel.setWidth("100%"); this.policyTable = new Table(); this.policyTable.addContainerProperty("Role Policies", String.class, null); this.policyTable.addContainerProperty("", Button.class, null); this.policyTable.setHeight("720px"); this.policyTable.setWidth("300px"); this.policyTable.setDragMode(TableDragMode.ROW); this.policyTable.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { if (role == null) { // Do nothing if there is no role selected logger.info("Ignoring drop: " + dropEvent); return; } // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final WrapperTransferable t = (WrapperTransferable) dropEvent.getTransferable(); final AutocompleteField sourceContainer = (AutocompleteField) t.getDraggedComponent(); logger.info("sourceContainer.getText(): " + sourceContainer.getText()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Remove Policy from this Role"); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Policy policy = RoleManagementPanel.this.securityService .findPolicyByName(sourceContainer.getText()); logger.info("Trying to remove policy: " + policy); Role selectedRole = RoleManagementPanel.this.securityService .findRoleByName(RoleManagementPanel.this.roleNameField.getText()); logger.info("From role: " + selectedRole); selectedRole.getPolicies().remove(policy); RoleManagementPanel.this.saveRole(selectedRole); RoleManagementPanel.this.policyTable.removeItem(policy.getName()); } }); Policy policy = RoleManagementPanel.this.securityService .findPolicyByName(sourceContainer.getText()); Role selectedRole = RoleManagementPanel.this.securityService .findRoleByName(RoleManagementPanel.this.roleNameField.getText()); selectedRole.getPolicies().add(policy); RoleManagementPanel.this.saveRole(selectedRole); RoleManagementPanel.this.policyTable.addItem( new Object[] { sourceContainer.getText(), deleteButton }, sourceContainer.getText()); } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); GridLayout layout = new GridLayout(); layout.setSpacing(true); layout.setWidth("100%"); Label associatedPoliciesLabel = new Label("Associated Policies"); associatedPoliciesLabel.setStyleName(ValoTheme.LABEL_HUGE); Label policy1HintLabel = new Label(); policy1HintLabel.setCaptionAsHtml(true); policy1HintLabel.setCaption( VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Type into the text box below to find a policy."); policy1HintLabel.addStyleName(ValoTheme.LABEL_TINY); policy1HintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(associatedPoliciesLabel); layout.addComponent(policy1HintLabel); layout.addComponent(policyNameFieldWrap); Label policy2HintLabel = new Label(); policy2HintLabel.setCaptionAsHtml(true); policy2HintLabel.setCaption( VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drag below to associate policy with current role."); policy2HintLabel.addStyleName(ValoTheme.LABEL_TINY); policy2HintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(policy2HintLabel); layout.addComponent(this.policyTable); this.policyDropPanel.setContent(layout); }
From source file:org.ikasan.dashboard.ui.administration.panel.RoleManagementPanel.java
License:BSD License
/** * Helper method to initialise behaviour of the role name field. * //from w w w . j a v a 2s . com * @return */ protected void initRoleNameField() { // The policy field name is an autocomplete field. this.roleNameField = new AutocompleteField<Role>(); this.roleNameField.setWidth("80%"); // In order to have the auto complete work we must add a query listener. // The query listener gets activated when a user begins to type into // the field and hits the database looking for suggestions. roleNameField.setQueryListener(new AutocompleteQueryListener<Role>() { @Override public void handleUserQuery(AutocompleteField<Role> field, String query) { // Iterate over the returned results and add them as suggestions for (Role role : securityService.getRoleByNameLike(query)) { field.addSuggestion(role, role.getName()); } } }); // Once a suggestion is selected the listener below gets fired and we populate // associated fields as required. roleNameField.setSuggestionPickedListener(new AutocompleteSuggestionPickedListener<Role>() { @Override public void onSuggestionPicked(final Role pickedRole) { RoleManagementPanel.this.role = pickedRole; // Populate all the policy related fields. RoleManagementPanel.this.roleItem = new BeanItem<Role>(RoleManagementPanel.this.role); RoleManagementPanel.this.roleNameField.setPropertyDataSource(roleItem.getItemProperty("name")); RoleManagementPanel.this.descriptionField .setPropertyDataSource(roleItem.getItemProperty("description")); RoleManagementPanel.this.policyTable.removeAllItems(); for (final Policy policy : role.getPolicies()) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Remove Policy from this Role"); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Policy selectedPolicy = RoleManagementPanel.this.securityService .findPolicyByName(policy.getName()); Role selectedRole = RoleManagementPanel.this.securityService .findRoleByName(role.getName()); selectedRole.getPolicies().remove(selectedPolicy); RoleManagementPanel.this.saveRole(selectedRole); RoleManagementPanel.this.policyTable.removeItem(policy.getName()); } }); RoleManagementPanel.this.policyTable.addItem(new Object[] { policy.getName(), deleteButton }, policy.getName()); } RoleManagementPanel.this.associatedPrincipalsTable.removeAllItems(); logger.info("Trying to get pinciplas for role: " + role); List<IkasanPrincipal> principals = RoleManagementPanel.this.securityService .getAllPrincipalsWithRole(role.getName()); logger.info("Adding the following number of principals : " + principals.size()); for (final IkasanPrincipal ikasanPrincipal : principals) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Unassign this role from the given User/Group"); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Role selectedRole = RoleManagementPanel.this.securityService .findRoleByName(RoleManagementPanel.this.roleNameField.getText()); logger.info("Removing principal role: " + selectedRole); ikasanPrincipal.getRoles().remove(selectedRole); RoleManagementPanel.this.securityService.savePrincipal(ikasanPrincipal); RoleManagementPanel.this.associatedPrincipalsTable.removeItem(ikasanPrincipal); } }); RoleManagementPanel.this.associatedPrincipalsTable .addItem(new Object[] { ikasanPrincipal.getName(), deleteButton }, ikasanPrincipal); } } }); }
From source file:org.ikasan.dashboard.ui.administration.panel.RoleManagementPanel.java
License:BSD License
@Override public void enter(ViewChangeEvent event) { this.policyNameField.clearChoices(); this.roleNameField.clearChoices(); if (this.role != null) { RoleManagementPanel.this.associatedPrincipalsTable.removeAllItems(); logger.info("Trying to get pincipals for role: " + role); List<IkasanPrincipal> principals = RoleManagementPanel.this.securityService .getAllPrincipalsWithRole(role.getName()); logger.info("Adding the following number of principals : " + principals.size()); for (final IkasanPrincipal ikasanPrincipal : principals) { Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Unassign this role from the given User/Group"); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Role selectedRole = RoleManagementPanel.this.securityService .findRoleByName(RoleManagementPanel.this.roleNameField.getText()); logger.info("Removing principal role: " + selectedRole); ikasanPrincipal.getRoles().remove(selectedRole); RoleManagementPanel.this.securityService.savePrincipal(ikasanPrincipal); RoleManagementPanel.this.associatedPrincipalsTable.removeItem(ikasanPrincipal); }//ww w.j a v a 2 s.co m }); RoleManagementPanel.this.associatedPrincipalsTable .addItem(new Object[] { ikasanPrincipal.getName(), deleteButton }, ikasanPrincipal); } } }