Example usage for com.vaadin.event Action getCaption

List of usage examples for com.vaadin.event Action getCaption

Introduction

In this page you can find the example usage for com.vaadin.event Action getCaption.

Prototype

public String getCaption() 

Source Link

Document

Returns the action's caption.

Usage

From source file:me.uni.emuseo.view.users.UserTable.java

License:Open Source License

public UserTable() {

    setSortEnabled(false);/*  w ww. j a va2s.  com*/
    addActionHandler(new Handler() {

        private static final long serialVersionUID = -1458601748782504737L;

        @Override
        public void handleAction(Action action, Object sender, Object target) {
            if (target == null) {
                return;
            }
            switch (action.getCaption()) {
            case "Edytuj":
                onEdit((UserDTO) target);
                break;
            case "Usu":
                onDelete((UserDTO) target);
                break;
            default:
                break;
            }
        }

        @Override
        public Action[] getActions(Object target, Object sender) {

            Action actionEdit = new Action("Edytuj", FontAwesome.EDIT);
            Action actionDelete = new Action("Usu", FontAwesome.TRASH_O);
            return new Action[] { actionEdit, actionDelete };
        }
    });
    setItemDescriptionGenerator(new UserDescriptionGenerator());

    beans = new BeanItemContainer<UserDTO>(UserDTO.class);
    setContainerDataSource(beans);
    setVisibleColumns("firstName", "lastName", "login", "emailAddress", "phoneNumber", "userType");
    setColumnHeaders("Imi", "Nazwisko", "Login", "Adres e-mail", "Nr telefonu", "Typ konta");

}

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 v a  2 s . co  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:org.activiti.explorer.ui.task.SubTaskComponent.java

License:Apache License

protected void initAddSubTaskPanelKeyboardActions() {
    addSubTaskPanel.addActionHandler(new Handler() {
        public void handleAction(Action action, Object sender, Object target) {
            if ("escape".equals(action.getCaption())) {
                resetAddButton();//from w w w .j av  a  2  s .co  m
            } else if ("enter".equals(action.getCaption())) {
                if (newTaskTextField != null && newTaskTextField.getValue() != null
                        && !"".equals(newTaskTextField.getValue().toString())) {

                    LoggedInUser loggedInUser = ExplorerApp.get().getLoggedInUser();

                    // save task
                    Task newTask = taskService.newTask();
                    newTask.setParentTaskId(parentTask.getId());
                    if (parentTask.getAssignee() != null) {
                        newTask.setAssignee(parentTask.getAssignee());
                    } else {
                        newTask.setAssignee(loggedInUser.getId());
                    }
                    if (parentTask.getOwner() != null) {
                        newTask.setOwner(parentTask.getOwner());
                    } else {
                        newTask.setOwner(loggedInUser.getId());
                    }
                    newTask.setName(newTaskTextField.getValue().toString());
                    taskService.saveTask(newTask);

                    // Reset the add button to its original state
                    resetAddButton();

                    // refresh sub tasks section
                    refreshSubTasks();
                }
            }
        }

        public Action[] getActions(Object target, Object sender) {
            return new Action[] { new ShortcutAction("enter", ShortcutAction.KeyCode.ENTER, null),
                    new ShortcutAction("escape", ShortcutAction.KeyCode.ESCAPE, null) };
        }
    });
}

From source file:org.escidoc.browser.ui.navigation.ActionHandlerImpl.java

License:Open Source License

private void doActionIfAllowed(final Action action, final Object selectedResource, final String contextId,
        Object sender) throws EscidocClientException, URISyntaxException {
    if (action.equals(ActionList.ACTION_ADD_RESOURCE)) {
        tryShowCreateResourceView(selectedResource, contextId);
    } else if (action.equals(ActionList.ACTION_DELETE_CONTAINER)) {
        tryDeleteContainer(selectedResource, sender);
    } else if (action.equals(ActionList.ACTION_DELETE_RESOURCE)) {
        tryDeleteItem(selectedResource, sender);
    } else if (action.equals(ActionList.ACTION_ADD_CHILD)) {
        tryShowAddChildOrgUnit((ResourceModel) selectedResource);
    } else if (action.equals(ActionList.ACTION_DELETE_CONTEXT)) {
        if (canContextbeRemoved(((ContextModel) selectedResource).getId())) {
            tryDeleteContext(selectedResource, sender);
        } else {/*from w  w  w.  ja va  2s.  c om*/
            mainWindow.showNotification(
                    new Window.Notification(ViewConstants.CANNOT_REMOVE_CONTEXT_NOT_IN_STATUS_CREATED,
                            Window.Notification.TYPE_WARNING_MESSAGE));
        }
    } else if (action.equals(ActionList.ACTION_DELETE_CONTENT_MODEL)) {
        tryDeleteContentModel(selectedResource, sender);
    } else if (action.equals(ActionList.ACTION_DELETE_USER_ACCOUNT)) {
        tryDeleteUserAccount(selectedResource, sender);
    } else if (action.equals(ActionList.ACTION_DELETE_USER_GROUP)) {
        tryDeleteUserGroup(selectedResource, sender);
    } else if (action.equals(ActionList.ACTION_DELETE_ORG)) {
        tryDeleteOrg(selectedResource, sender);
    } else {
        mainWindow.showNotification("Unknown Action: " + action.getCaption(),
                Window.Notification.TYPE_ERROR_MESSAGE);
    }
}

From source file:org.opennms.features.vaadin.topology.TopologyComponent.java

License:Open Source License

@Override
public void paintContent(PaintTarget target) throws PaintException {
    super.paintContent(target);
    target.addAttribute("scale", (Double) m_scale.getValue());
    target.addAttribute("clientX", m_mapManager.getClientX());
    target.addAttribute("clientY", m_mapManager.getClientY());
    target.addAttribute("semanticZoomLevel", m_graphContainer.getSemanticZoomLevel());

    Set<Action> actions = new HashSet<Action>();
    m_actionMapper = new KeyMapper();

    List<String> bgActionList = new ArrayList<String>();
    for (Action.Handler handler : m_actionHandlers) {
        Action[] bgActions = handler.getActions(null, null);
        for (Action action : bgActions) {
            bgActionList.add(m_actionMapper.key(action));
            actions.add(action);/* ww  w  .ja v a  2s .co m*/
        }
    }

    target.addAttribute("backgroundActions", bgActionList.toArray());

    target.startTag("graph");
    for (Vertex group : getGraph().getVertices()) {
        if (!group.isLeaf()) {
            target.startTag("group");
            target.addAttribute("key", group.getKey());
            target.addAttribute("x", group.getX());
            target.addAttribute("y", group.getY());
            target.addAttribute("selected", group.isSelected());
            target.addAttribute("iconUrl", group.getIconUrl());
            target.addAttribute("semanticZoomLevel", group.getSemanticZoomLevel());

            List<String> groupActionList = new ArrayList<String>();
            for (Action.Handler handler : m_actionHandlers) {
                Action[] groupActions = handler.getActions(group.getItemId(), null);
                for (Action action : groupActions) {
                    groupActionList.add(m_actionMapper.key(action));
                    actions.add(action);
                }
            }

            target.addAttribute("actionKeys", groupActionList.toArray());
            target.endTag("group");

        }
    }

    for (Vertex vert : getGraph().getVertices()) {
        if (vert.isLeaf()) {
            target.startTag("vertex");
            target.addAttribute("id", vert.getKey());
            target.addAttribute("x", vert.getX());
            target.addAttribute("y", vert.getY());
            target.addAttribute("selected", vert.isSelected());
            target.addAttribute("iconUrl", vert.getIconUrl());
            target.addAttribute("semanticZoomLevel", vert.getSemanticZoomLevel());
            if (vert.getGroupId() != null) {
                target.addAttribute("groupKey", vert.getGroupKey());
            }

            List<String> vertActionList = new ArrayList<String>();
            for (Action.Handler handler : m_actionHandlers) {
                Action[] vertActions = handler.getActions(vert.getItemId(), null);
                for (Action action : vertActions) {
                    vertActionList.add(m_actionMapper.key(action));
                    actions.add(action);
                }
            }

            target.addAttribute("actionKeys", vertActionList.toArray());
            target.endTag("vertex");
        }
    }

    for (Edge edge : getGraph().getEdges()) {
        target.startTag("edge");
        target.addAttribute("key", edge.getKey());
        target.addAttribute("source", edge.getSource().getKey());
        target.addAttribute("target", edge.getTarget().getKey());

        List<String> edgeActionList = new ArrayList<String>();
        for (Action.Handler handler : m_actionHandlers) {
            Action[] vertActions = handler.getActions(edge.getItemId(), null);
            for (Action action : vertActions) {
                edgeActionList.add(m_actionMapper.key(action));
                actions.add(action);
            }
        }

        target.addAttribute("actionKeys", edgeActionList.toArray());
        target.endTag("edge");
    }

    for (Vertex group : getGraph().getVertices()) {
        if (!group.isLeaf()) {
            if (group.getGroupId() != null) {
                target.startTag("groupParent");
                target.addAttribute("key", group.getKey());
                target.addAttribute("parentKey", group.getGroupKey());

                target.endTag("groupParent");
            }
        }
    }

    target.endTag("graph");

    target.startTag("actions");

    // send available actions
    for (Action action : actions) {
        target.startTag("action");
        target.addAttribute("key", m_actionMapper.key(action));
        if (action.getCaption() != null) {
            target.addAttribute("caption", action.getCaption());
        }
        if (action.getIcon() != null) {
            target.addAttribute("icon", action.getIcon());
        }
        target.endTag("action");
    }

    target.endTag("actions");

}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.TreeActionHandler.java

License:Mozilla Public License

private void loadIconUploadForm(final Set set, final Action action) {
    // TODO improve icon
    addToTab(new IconUploadFormLayout(set, action, mainApp.getMultiTabPanel()), action.getCaption(),
            EditorIcon.SEMANTIC_ROLE.getIconImage());
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.TreeActionHandler.java

License:Mozilla Public License

private void loadSemanticRoleCreationForm(final Set set, final Action action) {
    addToTab(new SemanticInstanceCreationFormLayout(set, action, mainApp.getMultiTabPanel()),
            action.getCaption(), EditorIcon.SEMANTIC_ROLE.getIconImage());
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.TreeActionHandler.java

License:Mozilla Public License

private void loadSemanticDomainCreationForm(final Set set, final Action action) {
    addToTab(new SemanticInstanceCreationFormLayout(set, action, mainApp.getMultiTabPanel()),
            action.getCaption(), EditorIcon.SEMANTIC_DOMAIN.getIconImage());
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.TreeActionHandler.java

License:Mozilla Public License

private void loadSemanticIdentityCreationForm(final Set set, final Action action) {
    addToTab(new SemanticInstanceCreationFormLayout(set, action, mainApp.getMultiTabPanel()),
            action.getCaption(), EditorIcon.SEMANTIC_ID.getIconImage());
}

From source file:org.s23m.cell.editor.semanticdomain.ui.components.TreeActionHandler.java

License:Mozilla Public License

private void loadLinkCreationForm(final Set set, final Action action) {
    addToTab(new LinkCreationFormLayout(set, action, mainApp.getMultiTabPanel()), action.getCaption(),
            EditorIcon.VISIBILITY.getIconImage());
}