Example usage for com.vaadin.ui Button setIcon

List of usage examples for com.vaadin.ui Button setIcon

Introduction

In this page you can find the example usage for com.vaadin.ui Button setIcon.

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

From source file:net.sourceforge.javydreamercsw.validation.manager.web.tester.ExecutionScreen.java

License:Apache License

public ExecutionScreen() {
    testCaseTree = new TreeTable("available.tests");
    testCaseTree.setAnimationsEnabled(true);
    testCaseTree.addContainerProperty("general.name", String.class, "");
    testCaseTree.addGeneratedColumn("general.status", (Table source, Object itemId, Object columnId) -> {
        if ("general.status".equals(columnId) && itemId instanceof String) {
            String id = (String) itemId;
            String message;//from w  ww  .  j a  va2  s . c  o  m
            HorizontalLayout icons = new HorizontalLayout();
            Button label = new Button();
            Button label2 = new Button();
            icons.addComponent(label2);
            icons.addComponent(label);
            label.addStyleName(ValoTheme.BUTTON_BORDERLESS + " labelButton");
            label2.addStyleName(ValoTheme.BUTTON_BORDERLESS + " labelButton");
            Map<String, Integer> summary = new HashMap<>();
            boolean locked = false;
            if (id.startsWith("tce")) {
                TestCaseExecutionServer tce = new TestCaseExecutionServer(Integer.parseInt(id.substring(3)));
                summary = getSummary(tce, -1);
                locked = isLocked(tce);
            } else if (id.startsWith("es")) {
                ExecutionStepServer es = new ExecutionStepServer(extractExecutionStepPK(id));
                summary = getSummary(es.getTestCaseExecution(),
                        Integer.parseInt(id.substring(id.lastIndexOf("-") + 1)));
                locked = es.getLocked();
            }
            if (locked) {
                label2.setIcon(VaadinIcons.LOCK);
                label2.setDescription(TRANSLATOR.translate("message.locked"));
            }
            if (!summary.isEmpty()) {
                if (summary.containsKey("result.fail")) {
                    //At least one failure means the test case is failing
                    message = "result.fail";
                } else if (summary.containsKey("result.blocked")) {
                    //It is blocked
                    message = "result.blocked";
                } else if (summary.containsKey("result.pending") && !summary.containsKey("result.pass")) {
                    //Still not done
                    message = "result.pending";
                } else if (summary.containsKey("result.pending") && summary.containsKey("result.pass")) {
                    //In progress
                    message = "result.progress";
                } else {
                    //All is pass
                    message = "result.pass";
                }
                label.setCaption(TRANSLATOR.translate(message));
                label.setDescription(TRANSLATOR.translate(message));
                //Completed. Now check result
                switch (message) {
                case "result.pass":
                    label.setIcon(VaadinIcons.CHECK);
                    break;
                case "result.fail":
                    label.setIcon(VaadinIcons.CLOSE);
                    break;
                case "result.blocked":
                    label.setIcon(VaadinIcons.PAUSE);
                    break;
                case "result.pending":
                    label.setIcon(VaadinIcons.CLOCK);
                    break;
                case "result.progress":
                    label.setIcon(VaadinIcons.AUTOMATION);
                    break;
                default:
                    label.setIcon(VaadinIcons.CLOCK);
                    break;
                }
                return icons;
            }
        }
        return new Label();
    });
    testCaseTree.addContainerProperty("general.summary", String.class, "");
    testCaseTree.addContainerProperty("general.assignment.date", String.class, "");
    testCaseTree.setVisibleColumns(
            new Object[] { "general.name", "general.status", "general.summary", "general.assignment.date" });
    testCaseTree.addActionHandler(new Action.Handler() {
        @Override
        public Action[] getActions(Object target, Object sender) {
            List<Action> actions = new ArrayList<>();
            if (target instanceof String) {
                String t = (String) target;
                int tcID = -1;
                TestCaseExecutionServer tce = null;
                if (t.startsWith("es")) {
                    tce = new TestCaseExecutionServer(
                            new ExecutionStepServer(extractExecutionStepPK(t)).getTestCaseExecution().getId());
                    tcID = Integer.parseInt(t.substring(t.lastIndexOf("-") + 1));
                } else if (t.startsWith("tce")) {
                    tce = new TestCaseExecutionServer(Integer.parseInt(t.substring(3)));
                }
                if (!isLocked(tce, tcID) && ExecutionScreen.this instanceof TesterScreenProvider) {
                    actions.add(new Action(TRANSLATOR.translate("general.execute"), VMUI.EXECUTION_ICON));
                } else if (isLocked(tce, tcID) && ExecutionScreen.this instanceof QualityScreenProvider) {
                    actions.add(new Action(TRANSLATOR.translate("general.review"), VaadinIcons.EYE));
                }
                actions.add(new Action(TRANSLATOR.translate("general.export"), VaadinIcons.DOWNLOAD));
            }
            return actions.toArray(new Action[actions.size()]);
        }

        @Override
        public void handleAction(Action action, Object sender, Object target) {
            List<TestCaseExecutionServer> executions = new ArrayList<>();
            int tcID = -1;
            if (((String) target).startsWith("tce")) {
                executions.add(new TestCaseExecutionServer(Integer.parseInt(((String) target).substring(3))));
            } else if (((String) target).startsWith("es")) {
                executions.add(new TestCaseExecutionServer(
                        new ExecutionStepServer(extractExecutionStepPK((String) target)).getTestCaseExecution()
                                .getId()));
                tcID = Integer.parseInt(((String) target).substring(((String) target).lastIndexOf("-") + 1));
            }
            //Parse the information to get the exact Execution Step
            if (action.getCaption().equals(TRANSLATOR.translate("general.export"))) {
                viewExecutionScreen(executions, tcID);
            } else {
                showExecutionScreen(executions, tcID);
            }
        }
    });
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java

License:Apache License

private Component getMenu() {
    GridLayout gl = new GridLayout(3, 3);
    gl.addComponent(new Image("", LOGO), 0, 0);
    Label version = new Label(TRANSLATOR.translate("general.version") + ": " + getVersion());
    gl.addComponent(version, 2, 2);/*from  w  ww . jav a 2  s .co  m*/
    if (getUser() != null) {
        getUser().update();
        //Logout button
        Button logout = new Button(TRANSLATOR.translate("general.logout"));
        logout.addClickListener((Button.ClickEvent event) -> {
            try {
                user.update();
                user.write2DB();
                user = null;
                main = null;
                setLocale(Locale.ENGLISH);
                updateScreen();
                // Close the session
                closeSession();
            } catch (VMException ex) {
                LOG.log(Level.SEVERE, null, ex);
            }
        });
        gl.addComponent(logout, 1, 0);
        //Notification Button
        if (getUser().getNotificationList().isEmpty() && DataBaseManager.isDemo()) {
            //For demo add a notification for users
            try {
                Lookup.getDefault().lookup(INotificationManager.class).addNotification(
                        "Welcome to ValidationManager!", NotificationTypes.GENERAL, getUser().getEntity(),
                        new VMUserServer(1).getEntity());
            } catch (Exception ex) {
                LOG.log(Level.SEVERE, null, ex);
            }
        }
        Button notification = new Button();
        if (getUser().getPendingNotifications().size() > 0) {
            notification.setCaption("" + getUser().getPendingNotifications().size()); //any number, count, etc
        }
        notification.setHtmlContentAllowed(true);
        notification.setIcon(VaadinIcons.BELL);
        notification.addClickListener((Button.ClickEvent event) -> {
            //TODO: Show notifications screen
        });
        gl.addComponent(notification, 2, 0);
    }
    gl.setSizeFull();
    return gl;
}

From source file:org.activiti.explorer.ui.alfresco.AlfrescoProcessInstanceTableItem.java

License:Apache License

public AlfrescoProcessInstanceTableItem(final ProcessInstance processInstance) {
    addItemProperty(PROPERTY_ID, new ObjectProperty<String>(processInstance.getId(), String.class));

    if (processInstance.getBusinessKey() != null) {
        addItemProperty(PROPERTY_BUSINESSKEY,
                new ObjectProperty<String>(processInstance.getBusinessKey(), String.class));
    }//from w w w.j  a  v  a2 s  .c om

    Button viewProcessInstanceButton = new Button(
            ExplorerApp.get().getI18nManager().getMessage(Messages.PROCESS_ACTION_VIEW));
    viewProcessInstanceButton.addStyleName(Reindeer.BUTTON_LINK);
    viewProcessInstanceButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            ExplorerApp.get().getViewManager().showProcessInstancePage(processInstance.getId());
        }
    });

    viewProcessInstanceButton.setIcon(Images.MAGNIFIER_16);
    addItemProperty(PROPERTY_ACTIONS,
            new ObjectProperty<Component>(viewProcessInstanceButton, Component.class));
}

From source file:org.activiti.explorer.ui.custom.SelectUsersPopupWindow.java

License:Apache License

protected void initSelectMyselfButton(HorizontalLayout searchLayout) {
    final LoggedInUser loggedInUser = ExplorerApp.get().getLoggedInUser();
    if (ignoredUserIds == null || !ignoredUserIds.contains(loggedInUser.getId())) {
        Button meButton = new Button(i18nManager.getMessage(Messages.PEOPLE_SELECT_MYSELF));
        meButton.setIcon(Images.USER_16);
        searchLayout.addComponent(meButton);
        searchLayout.setComponentAlignment(meButton, Alignment.MIDDLE_LEFT);

        if (multiSelect) {
            meButton.addListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    selectUser(loggedInUser.getId(), loggedInUser.getFullName());
                }/*w  ww . j ava 2 s . c  o  m*/
            });
        } else {
            meButton.addListener(new ClickListener() {
                public void buttonClick(ClickEvent event) {
                    addMatchingUser(loggedInUser.getId(), loggedInUser.getFullName());
                    matchingUsersTable.select(loggedInUser.getId());
                    fireEvent(new SubmitEvent(doneButton, SubmitEvent.SUBMITTED));
                    close();
                }
            });
        }
    }
}

From source file:org.activiti.explorer.ui.mainlayout.MainMenuBar.java

License:Apache License

protected Button addMenuButton(String type, String label, Resource icon, boolean active, float width) {
    Button button = new Button(label);
    button.addStyleName(type);// w w w.ja v  a 2 s.c o m
    button.addStyleName(ExplorerLayout.STYLE_MAIN_MENU_BUTTON);
    button.addStyleName(Reindeer.BUTTON_LINK);
    button.setHeight(54, UNITS_PIXELS);
    button.setIcon(icon);
    button.setWidth(width, UNITS_PIXELS);

    addComponent(button);
    setComponentAlignment(button, Alignment.TOP_CENTER);

    return button;
}

From source file:org.activiti.explorer.ui.management.deployment.DeploymentDetailPanel.java

License:Apache License

protected void addActions() {
    // Delete button
    Button deleteButton = new Button(i18nManager.getMessage(Messages.DEPLOYMENT_DELETE));
    deleteButton.setIcon(Images.DELETE);
    deleteButton.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            viewManager.showPopupWindow(new DeleteDeploymentPopupWindow(deployment, parent));
        }/*from   ww w .  j a  v  a  2 s. c  o m*/
    });

    parent.getToolBar().removeAllButtons();
    parent.getToolBar().addButton(deleteButton);
}

From source file:org.activiti.explorer.ui.management.identity.GroupDetailPanel.java

License:Apache License

protected void initActions() {
    Button createGroupButton = new Button(i18nManager.getMessage(Messages.GROUP_CREATE));
    createGroupButton.setIcon(Images.GROUP_16);
    createGroupButton.addListener(new ClickListener() {
        public void buttonClick(ClickEvent event) {
            NewGroupPopupWindow popup = new NewGroupPopupWindow();
            ExplorerApp.get().getViewManager().showPopupWindow(popup);
        }//  w w w  .  j  a  v  a  2 s.  c  om
    });
    groupPage.getToolBar().removeAllButtons();
    groupPage.getToolBar().addButton(createGroupButton);
}

From source file:org.activiti.explorer.ui.management.identity.UserDetailPanel.java

License:Apache License

protected void initActions() {
    Button createUserButton = new Button(i18nManager.getMessage(Messages.USER_CREATE));
    createUserButton.setIcon(Images.USER_16);

    createUserButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            NewUserPopupWindow newUserPopupWindow = new NewUserPopupWindow();
            ExplorerApp.get().getViewManager().showPopupWindow(newUserPopupWindow);
        }//from w  ww  .  j  a  v a  2s  .  com
    });

    userPage.getToolBar().removeAllButtons();
    userPage.getToolBar().addButton(createUserButton);
}

From source file:org.activiti.explorer.ui.management.job.JobDetailPanel.java

License:Apache License

protected void addActions() {
    Button deleteButton = new Button(i18nManager.getMessage(Messages.JOB_DELETE));
    deleteButton.setIcon(Images.DELETE);
    deleteButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            managementService.deleteJob(job.getId());

            notificationManager.showInformationNotification(Messages.JOB_DELETED);
            jobPage.refreshSelectNext();
        }/*from  w w w. j  a v a  2s  .  c o m*/
    });

    Button executeButton = new Button(i18nManager.getMessage(Messages.JOB_EXECUTE));
    executeButton.setIcon(Images.EXECUTE);
    executeButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            try {
                managementService.executeJob(job.getId());
                jobPage.refreshSelectNext();
            } catch (ActivitiException ae) {
                String errorMessage = ae.getMessage()
                        + (ae.getCause() != null ? " (" + ae.getCause().getClass().getName() + ")" : "");
                notificationManager.showErrorNotification(Messages.JOB_ERROR, errorMessage);

                // Refresh the current job
                jobPage.refreshCurrentJobDetails();
            }
        }
    });

    jobPage.getToolBar().removeAllButtons();
    jobPage.getToolBar().addButton(executeButton);
    jobPage.getToolBar().addButton(deleteButton);
}

From source file:org.activiti.explorer.ui.management.process.ProcessInstanceDetailPanel.java

License:Apache License

protected void addDeleteButton() {
    Button deleteProcessInstanceButton = new Button(i18nManager.getMessage(Messages.PROCESS_INSTANCE_DELETE));
    deleteProcessInstanceButton.setIcon(Images.DELETE);
    deleteProcessInstanceButton/*from w  w w  .  j a va2s .  c  o m*/
            .addListener(new DeleteProcessInstanceClickListener(processInstance.getId(), processInstancePage));

    // Clear toolbar and add 'start' button
    processInstancePage.getToolBar().removeAllButtons();
    processInstancePage.getToolBar().addButton(deleteProcessInstanceButton);
}