Search in sources :

Example 26 with ValueChangeEvent

use of com.vaadin.data.Property.ValueChangeEvent in project Activiti by Activiti.

the class AdminCompletedInstancesPanel method initDefinitionsTable.

protected void initDefinitionsTable() {
    if (instanceList == null || instanceList.isEmpty()) {
        noMembersTable = new Label(i18nManager.getMessage(Messages.ADMIN_COMPLETED_NONE_FOUND));
        definitionsLayout.addComponent(noMembersTable);
    } else {
        completedDefinitions = new HashMap<String, ManagementProcessDefinition>();
        for (HistoricProcessInstance instance : instanceList) {
            String processDefinitionId = instance.getProcessDefinitionId();
            ManagementProcessDefinition managementDefinition = null;
            if (completedDefinitions.containsKey(processDefinitionId)) {
                managementDefinition = completedDefinitions.get(processDefinitionId);
            } else {
                ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
                if (definition == null) {
                    // this process has a missing definition - skip
                    continue;
                }
                managementDefinition = new ManagementProcessDefinition();
                managementDefinition.processDefinition = definition;
                managementDefinition.runningInstances = new ArrayList<HistoricProcessInstance>();
                completedDefinitions.put(definition.getId(), managementDefinition);
            }
            managementDefinition.runningInstances.add(instance);
        }
        definitionsTable = new Table();
        definitionsTable.setWidth(100, UNITS_PERCENTAGE);
        definitionsTable.setHeight(250, UNITS_PIXELS);
        definitionsTable.setEditable(false);
        definitionsTable.setImmediate(true);
        definitionsTable.setSelectable(true);
        definitionsTable.setSortDisabled(false);
        definitionsTable.addContainerProperty("id", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_ID), null, Table.ALIGN_LEFT);
        definitionsTable.addContainerProperty("name", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_NAME), null, Table.ALIGN_LEFT);
        definitionsTable.addContainerProperty("nr of instances", String.class, null, i18nManager.getMessage(Messages.ADMIN_NR_INSTANCES), null, Table.ALIGN_LEFT);
        for (ManagementProcessDefinition managementDefinition : completedDefinitions.values()) {
            definitionsTable.addItem(new String[] { managementDefinition.processDefinition.getId(), managementDefinition.processDefinition.getName(), String.valueOf(managementDefinition.runningInstances.size()) }, managementDefinition.processDefinition.getId());
        }
        definitionsTable.addListener(new Property.ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {
                // the value of the property is the itemId of the table entry
                Item item = definitionsTable.getItem(event.getProperty().getValue());
                if (item != null) {
                    String definitionId = (String) item.getItemProperty("id").getValue();
                    selectedManagementDefinition = completedDefinitions.get(definitionId);
                    refreshInstancesTable();
                }
            }
        });
        definitionsLayout.addComponent(definitionsTable);
    }
}
Also used : Table(com.vaadin.ui.Table) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) HistoricFormProperty(org.activiti.engine.history.HistoricFormProperty) Property(com.vaadin.data.Property)

Example 27 with ValueChangeEvent

use of com.vaadin.data.Property.ValueChangeEvent in project Activiti by Activiti.

the class TaskPage method getListSelectionListener.

protected ValueChangeListener getListSelectionListener() {
    return new Property.ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            // the value of the property is the itemId of the table entry
            Item item = taskTable.getItem(event.getProperty().getValue());
            if (item != null) {
                String id = (String) item.getItemProperty("id").getValue();
                setDetailComponent(createDetailComponent(id));
                UriFragment taskFragment = getUriFragment(id);
                ExplorerApp.get().setCurrentUriFragment(taskFragment);
            } else {
                // Nothing is selected
                setDetailComponent(null);
                taskEventPanel.setTaskId(null);
                ExplorerApp.get().setCurrentUriFragment(getUriFragment(null));
            }
        }
    };
}
Also used : Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) UriFragment(org.activiti.explorer.navigation.UriFragment)

Example 28 with ValueChangeEvent

use of com.vaadin.data.Property.ValueChangeEvent in project Activiti by Activiti.

the class EditorProcessDefinitionDetailPanel method initActions.

protected void initActions() {
    newModelButton = new Button(i18nManager.getMessage(Messages.PROCESS_NEW));
    newModelButton.addListener(new NewModelClickListener());
    importModelButton = new Button(i18nManager.getMessage(Messages.PROCESS_IMPORT));
    importModelButton.addListener(new ImportModelClickListener());
    editModelButton = new Button(i18nManager.getMessage(Messages.PROCESS_EDIT));
    editModelButton.addListener(new EditModelClickListener(modelData));
    actionLabel = new Label(i18nManager.getMessage(Messages.MODEL_ACTION));
    actionLabel.setSizeUndefined();
    actionSelect = new Select();
    actionSelect.addItem(i18nManager.getMessage(Messages.PROCESS_COPY));
    actionSelect.addItem(i18nManager.getMessage(Messages.PROCESS_DELETE));
    actionSelect.addItem(i18nManager.getMessage(Messages.PROCESS_DEPLOY));
    actionSelect.addItem(i18nManager.getMessage(Messages.PROCESS_EXPORT));
    actionSelect.setWidth("100px");
    actionSelect.setFilteringMode(Filtering.FILTERINGMODE_OFF);
    actionSelect.setImmediate(true);
    actionSelect.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (i18nManager.getMessage(Messages.PROCESS_COPY).equals(event.getProperty().getValue())) {
                ExplorerApp.get().getViewManager().showPopupWindow(new CopyModelPopupWindow(modelData));
            } else if (i18nManager.getMessage(Messages.PROCESS_DELETE).equals(event.getProperty().getValue())) {
                ExplorerApp.get().getViewManager().showPopupWindow(new DeleteModelPopupWindow(modelData));
            } else if (i18nManager.getMessage(Messages.PROCESS_DEPLOY).equals(event.getProperty().getValue())) {
                deployModel();
            } else if (i18nManager.getMessage(Messages.PROCESS_EXPORT).equals(event.getProperty().getValue())) {
                exportModel();
            }
        }
    });
    // Clear toolbar and add 'start' button
    processDefinitionPage.getToolBar().removeAllButtons();
    processDefinitionPage.getToolBar().removeAllAdditionalComponents();
    processDefinitionPage.getToolBar().addButton(newModelButton);
    processDefinitionPage.getToolBar().addButton(importModelButton);
    processDefinitionPage.getToolBar().addButton(editModelButton);
    processDefinitionPage.getToolBar().addAdditionalComponent(actionLabel);
    processDefinitionPage.getToolBar().setComponentAlignment(actionLabel, Alignment.MIDDLE_LEFT);
    processDefinitionPage.getToolBar().addAdditionalComponent(actionSelect);
    processDefinitionPage.getToolBar().setComponentAlignment(actionSelect, Alignment.MIDDLE_RIGHT);
}
Also used : ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) Button(com.vaadin.ui.Button) ImportModelClickListener(org.activiti.explorer.ui.process.listener.ImportModelClickListener) Label(com.vaadin.ui.Label) Select(com.vaadin.ui.Select) EditModelClickListener(org.activiti.explorer.ui.process.listener.EditModelClickListener) NewModelClickListener(org.activiti.explorer.ui.process.listener.NewModelClickListener)

Example 29 with ValueChangeEvent

use of com.vaadin.data.Property.ValueChangeEvent in project Activiti by Activiti.

the class CreateAttachmentPopupWindow method initTable.

protected void initTable() {
    attachmentTypes = new Table();
    attachmentTypes.setSizeUndefined();
    attachmentTypes.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
    attachmentTypes.setSelectable(true);
    attachmentTypes.setImmediate(true);
    attachmentTypes.setNullSelectionAllowed(false);
    attachmentTypes.setWidth(200, UNITS_PIXELS);
    attachmentTypes.setHeight(100, UNITS_PERCENTAGE);
    attachmentTypes.setCellStyleGenerator(new CellStyleGenerator() {

        private static final long serialVersionUID = 1L;

        public String getStyle(Object itemId, Object propertyId) {
            if ("name".equals(propertyId)) {
                return ExplorerLayout.STYLE_RELATED_CONTENT_CREATE_LIST_LAST_COLUMN;
            }
            return null;
        }
    });
    attachmentTypes.addStyleName(ExplorerLayout.STYLE_RELATED_CONTENT_CREATE_LIST);
    attachmentTypes.addContainerProperty("type", Embedded.class, null);
    attachmentTypes.setColumnWidth("type", 16);
    attachmentTypes.addContainerProperty("name", String.class, null);
    // Add all possible attachment types
    for (AttachmentEditor editor : attachmentRendererManager.getAttachmentEditors()) {
        String name = editor.getTitle(i18nManager);
        Embedded image = null;
        Resource resource = editor.getImage();
        if (resource != null) {
            image = new Embedded(null, resource);
        }
        Item item = attachmentTypes.addItem(editor.getName());
        item.getItemProperty("type").setValue(image);
        item.getItemProperty("name").setValue(name);
    }
    // Add listener to show editor component
    attachmentTypes.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            String type = (String) event.getProperty().getValue();
            selectType(type);
        }
    });
    layout.addComponent(attachmentTypes);
}
Also used : Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Table(com.vaadin.ui.Table) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) Resource(com.vaadin.terminal.Resource) CellStyleGenerator(com.vaadin.ui.Table.CellStyleGenerator) Embedded(com.vaadin.ui.Embedded)

Example 30 with ValueChangeEvent

use of com.vaadin.data.Property.ValueChangeEvent in project Activiti by Activiti.

the class EditorProcessDefinitionPage method createList.

@Override
protected Table createList() {
    final Table processDefinitionTable = new Table();
    processDefinitionTable.addStyleName(ExplorerLayout.STYLE_PROCESS_DEFINITION_LIST);
    // Set non-editable, selectable and full-size
    processDefinitionTable.setEditable(false);
    processDefinitionTable.setImmediate(true);
    processDefinitionTable.setSelectable(true);
    processDefinitionTable.setNullSelectionAllowed(false);
    processDefinitionTable.setSortDisabled(true);
    processDefinitionTable.setSizeFull();
    // Listener to change right panel when clicked on a model
    processDefinitionTable.addListener(new Property.ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            showProcessDefinitionDetail((String) event.getProperty().getValue());
        }
    });
    // Create columns
    processDefinitionTable.addGeneratedColumn("icon", new ThemeImageColumnGenerator(Images.PROCESS_22));
    processDefinitionTable.setColumnWidth("icon", 22);
    processDefinitionTable.addContainerProperty("name", String.class, null);
    processDefinitionTable.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
    List<Model> modelList = repositoryService.createModelQuery().list();
    for (Model modelData : modelList) {
        Item item = processDefinitionTable.addItem(modelData.getId());
        item.getItemProperty("name").setValue(modelData.getName());
    }
    return processDefinitionTable;
}
Also used : Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Table(com.vaadin.ui.Table) ThemeImageColumnGenerator(org.activiti.explorer.ui.util.ThemeImageColumnGenerator) Model(org.activiti.engine.repository.Model) Property(com.vaadin.data.Property)

Aggregations

ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)30 Table (com.vaadin.ui.Table)21 Item (com.vaadin.data.Item)20 Property (com.vaadin.data.Property)19 UriFragment (org.activiti.explorer.navigation.UriFragment)13 ValueChangeListener (com.vaadin.data.Property.ValueChangeListener)11 LazyLoadingContainer (org.activiti.explorer.data.LazyLoadingContainer)11 ThemeImageColumnGenerator (org.activiti.explorer.ui.util.ThemeImageColumnGenerator)10 Label (com.vaadin.ui.Label)6 ClickEvent (com.vaadin.ui.Button.ClickEvent)5 Button (com.vaadin.ui.Button)4 ClickListener (com.vaadin.ui.Button.ClickListener)4 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)4 LazyLoadingQuery (org.activiti.explorer.data.LazyLoadingQuery)4 CheckBox (com.vaadin.ui.CheckBox)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)3 CellStyleGenerator (com.vaadin.ui.Table.CellStyleGenerator)2 HistoricFormProperty (org.activiti.engine.history.HistoricFormProperty)2 PrettyTimeLabel (org.activiti.explorer.ui.custom.PrettyTimeLabel)2