Example usage for com.vaadin.event Action Action

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

Introduction

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

Prototype

public Action(String caption, Resource icon) 

Source Link

Document

Constructs a new action with the given caption string and icon.

Usage

From source file:me.uni.emuseo.view.categories.CategoryTable.java

License:Open Source License

public CategoryTable() {

    setSortEnabled(false);/*from   w w w. ja  va  2 s  . c o  m*/
    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((CategoryDTO) target);
                break;
            case "Usu":
                onDelete((CategoryDTO) 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 CategoryDescriptionGenerator());

    beans = new BeanItemContainer<CategoryDTO>(CategoryDTO.class);
    setContainerDataSource(beans);
    setVisibleColumns(new Object[] { "name", "exhibitsCount" });
    setColumnHeaders("Nazwa", "Ilo eksponatw");

}

From source file:me.uni.emuseo.view.exhibits.ExhibitTable.java

License:Open Source License

public ExhibitTable() {

    setSortEnabled(false);// ww w .ja va 2  s .  co m
    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((ExhibitDTO) target);
                break;
            case "Usu":
                onDelete((ExhibitDTO) target);
                break;
            case EDIT_IMAGE_CAPTION:
                onImageEdit((ExhibitDTO) target);
                break;
            case SHOW_CAPTION:
                onShow((ExhibitDTO) 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);
            Action actionEditImage = new Action(EDIT_IMAGE_CAPTION, FontAwesome.FILE_IMAGE_O);
            Action actionShow = new Action(SHOW_CAPTION, FontAwesome.EYE);
            return new Action[] { actionEdit, actionDelete, actionEditImage, actionShow };
        }
    });
    setItemDescriptionGenerator(new ExhibitDescriptionGenerator());

    beans = new BeanItemContainer<ExhibitDTO>(ExhibitDTO.class);
    setContainerDataSource(beans);
    beans.addNestedContainerBean("exhibitCategory");
    setVisibleColumns(new Object[] { "exhibitName", "exhibitNo", "genericYear", "exhibitCategory.name",
            "exhibitLocation" });
    setColumnHeaders("Nazwa", "Numer kat.", "Wiek w latach", "Kategoria", "Lokalizacja");

}

From source file:me.uni.emuseo.view.resources.ResourceTable.java

License:Open Source License

public ResourceTable() {

    setSortEnabled(false);/*from w w  w  .j  a  v  a 2 s .co m*/
    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((ResourceDTO) target);
                break;
            case "Usu":
                onDelete((ResourceDTO) target);
                break;
            case "Poka":
                onShow((ResourceDTO) target);
            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);
            Action actionShow = new Action("Poka", FontAwesome.EYE);
            return new Action[] { /* actionEdit, actionDelete, */actionShow };
        }
    });
    // setItemDescriptionGenerator(new ResourceDescriptionGenerator());

    beans = new BeanItemContainer<ResourceDTO>(ResourceDTO.class);
    setContainerDataSource(beans);
    setVisibleColumns("code", "fileName", "mimeType", "fileSize");
    setColumnHeaders("Kod", "Nazwa pliku", "Typ Mime", "Rozmiar");

}

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

License:Open Source License

public UserTable() {

    setSortEnabled(false);//from  ww  w  .  j ava 2  s . co m
    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;//w  w w .j  a v a  2 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);
            }
        }
    });
}