Search in sources :

Example 11 with ValueChangeEvent

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

the class TabbedSelectionWindow method initSelectionTable.

protected void initSelectionTable() {
    selectionTable = new Table();
    selectionTable.setSizeUndefined();
    selectionTable.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
    selectionTable.setSelectable(true);
    selectionTable.setImmediate(true);
    selectionTable.setNullSelectionAllowed(false);
    selectionTable.setWidth(150, UNITS_PIXELS);
    selectionTable.setHeight(100, UNITS_PERCENTAGE);
    selectionTable.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;
        }
    });
    selectionTable.addStyleName(ExplorerLayout.STYLE_RELATED_CONTENT_CREATE_LIST);
    selectionTable.addContainerProperty("type", Embedded.class, null);
    selectionTable.setColumnWidth("type", 22);
    selectionTable.addContainerProperty("name", String.class, null);
    // Listener to switch to the selected component
    selectionTable.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            String name = (String) event.getProperty().getValue();
            if (name != null) {
                currentSelection = name;
                currentComponent = components.get(name);
                selectedComponentLayout.removeComponent(selectedComponentLayout.getComponent(0, 0));
                if (currentComponent != null) {
                    currentComponent.setSizeFull();
                    selectedComponentLayout.addComponent(currentComponent, 0, 0);
                    okButton.setEnabled(true);
                } else {
                    okButton.setEnabled(false);
                }
            }
        }
    });
    windowLayout.addComponent(selectionTable);
}
Also used : ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Table(com.vaadin.ui.Table) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) CellStyleGenerator(com.vaadin.ui.Table.CellStyleGenerator)

Example 12 with ValueChangeEvent

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

the class AdminCompletedInstancesPanel method initInstancesTable.

protected void initInstancesTable() {
    instancesTable = new Table();
    instancesTable.setWidth(100, UNITS_PERCENTAGE);
    instancesTable.setHeight(250, UNITS_PIXELS);
    instancesTable.setEditable(false);
    instancesTable.setImmediate(true);
    instancesTable.setSelectable(true);
    instancesTable.setSortDisabled(false);
    instancesTable.addContainerProperty("id", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_ID), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("business key", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_BUSINESSKEY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start user id", String.class, null, i18nManager.getMessage(Messages.ADMIN_STARTED_BY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start activity id", String.class, null, i18nManager.getMessage(Messages.ADMIN_START_ACTIVITY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start time", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_STARTED), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("end time", String.class, null, i18nManager.getMessage(Messages.TASK_COMPLETE_TIME), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("duration", String.class, null, i18nManager.getMessage(Messages.TASK_DURATION), null, Table.ALIGN_LEFT);
    instancesTable.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 = instancesTable.getItem(event.getProperty().getValue());
            if (item != null) {
                String instanceId = (String) item.getItemProperty("id").getValue();
                HistoricProcessInstance processInstance = null;
                for (HistoricProcessInstance instance : selectedManagementDefinition.runningInstances) {
                    if (instance.getId().equals(instanceId)) {
                        processInstance = instance;
                        break;
                    }
                }
                if (processInstance != null)
                    addProcessImage(selectedManagementDefinition.processDefinition, processInstance);
                addTasks(processInstance);
                addVariables(processInstance);
            }
        }
    });
    instancesLayout.addComponent(instancesTable);
}
Also used : Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Table(com.vaadin.ui.Table) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoricFormProperty(org.activiti.engine.history.HistoricFormProperty) Property(com.vaadin.data.Property)

Example 13 with ValueChangeEvent

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

the class AdminRunningInstancesPanel method initDefinitionsTable.

protected void initDefinitionsTable() {
    if (instanceList == null || instanceList.isEmpty()) {
        noMembersTable = new Label(i18nManager.getMessage(Messages.ADMIN_RUNNING_NONE_FOUND));
        definitionsLayout.addComponent(noMembersTable);
    } else {
        runningDefinitions = new HashMap<String, ManagementProcessDefinition>();
        for (HistoricProcessInstance instance : instanceList) {
            String processDefinitionId = instance.getProcessDefinitionId();
            ManagementProcessDefinition managementDefinition = null;
            if (runningDefinitions.containsKey(processDefinitionId)) {
                managementDefinition = runningDefinitions.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>();
                runningDefinitions.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 : runningDefinitions.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 = runningDefinitions.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) Property(com.vaadin.data.Property)

Example 14 with ValueChangeEvent

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

the class AdminRunningInstancesPanel method initInstancesTable.

protected void initInstancesTable() {
    instancesTable = new Table();
    instancesTable.setWidth(100, UNITS_PERCENTAGE);
    instancesTable.setHeight(250, UNITS_PIXELS);
    instancesTable.setEditable(false);
    instancesTable.setImmediate(true);
    instancesTable.setSelectable(true);
    instancesTable.setSortDisabled(false);
    instancesTable.addContainerProperty("id", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_ID), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("business key", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_BUSINESSKEY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start user id", String.class, null, i18nManager.getMessage(Messages.ADMIN_STARTED_BY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start activity id", String.class, null, i18nManager.getMessage(Messages.ADMIN_START_ACTIVITY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start time", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_STARTED), null, Table.ALIGN_LEFT);
    instancesTable.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 = instancesTable.getItem(event.getProperty().getValue());
            if (item != null) {
                String instanceId = (String) item.getItemProperty("id").getValue();
                HistoricProcessInstance processInstance = null;
                for (HistoricProcessInstance instance : selectedManagementDefinition.runningInstances) {
                    if (instance.getId().equals(instanceId)) {
                        processInstance = instance;
                        break;
                    }
                }
                if (processInstance != null)
                    addProcessImage(selectedManagementDefinition.processDefinition, processInstance);
                addTasks(processInstance);
                addVariables(processInstance);
            }
        }
    });
    instancesLayout.addComponent(instancesTable);
}
Also used : Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Table(com.vaadin.ui.Table) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Property(com.vaadin.data.Property)

Example 15 with ValueChangeEvent

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

the class EventOverviewPanel method initProcessInstances.

protected void initProcessInstances() {
    HorizontalLayout instancesHeader = new HorizontalLayout();
    instancesHeader.setSpacing(false);
    instancesHeader.setMargin(false);
    instancesHeader.setWidth(100, UNITS_PERCENTAGE);
    instancesHeader.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    addDetailComponent(instancesHeader);
    initProcessInstanceTitle(instancesHeader);
    HorizontalLayout selectLayout = new HorizontalLayout();
    selectLayout.setSpacing(true);
    selectLayout.setMargin(true);
    selectLayout.setWidth(50, UNITS_PERCENTAGE);
    addDetailComponent(selectLayout);
    definitionSelect = new NativeSelect(i18nManager.getMessage(Messages.DEPLOYMENT_HEADER_DEFINITIONS));
    definitionSelect.setImmediate(true);
    for (ProcessDefinition definition : definitionList) {
        definitionSelect.addItem(definition.getId());
        definitionSelect.setItemCaption(definition.getId(), definition.getName());
    }
    definitionSelect.addListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            if (definitionSelect.getValue() != null) {
                String selectedDefinitionId = (String) definitionSelect.getValue();
                ExplorerApp.get().setCrystalBallCurrentDefinitionId(selectedDefinitionId);
                refreshInstances(selectedDefinitionId);
            }
        }
    });
    selectLayout.addComponent(definitionSelect);
    replayButton = new Button(i18nManager.getMessage(Messages.CRYSTALBALL_BUTTON_REPLAY));
    replayButton.setEnabled(false);
    replayButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (instanceTable.getValue() != null) {
                String processInstanceId = (String) instanceTable.getValue();
                ExplorerApp.get().setCrystalBallCurrentInstanceId(processInstanceId);
                List<EventLogEntry> eventLogEntries = managementService.getEventLogEntriesByProcessInstanceId(processInstanceId);
                if (eventLogEntries == null || eventLogEntries.isEmpty())
                    return;
                EventLogTransformer transformer = new EventLogTransformer(getTransformers());
                simulationEvents = transformer.transform(eventLogEntries);
                ExplorerApp.get().setCrystalBallSimulationEvents(simulationEvents);
                SimpleEventCalendar eventCalendar = new SimpleEventCalendar(ProcessEngines.getDefaultProcessEngine().getProcessEngineConfiguration().getClock(), new SimulationEventComparator());
                eventCalendar.addEvents(simulationEvents);
                // replay process instance run
                simulationDebugger = new ReplaySimulationRun(ProcessEngines.getDefaultProcessEngine(), eventCalendar, getReplayHandlers(processInstanceId));
                ExplorerApp.get().setCrystalBallSimulationDebugger(simulationDebugger);
                simulationDebugger.init(new NoExecutionVariableScope());
                simulationDebugger.step();
                // replay process was started
                List<HistoricProcessInstance> replayProcessInstanceList = historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey(SIMULATION_BUSINESS_KEY).orderByProcessInstanceStartTime().desc().list();
                if (replayProcessInstanceList != null && !replayProcessInstanceList.isEmpty()) {
                    replayHistoricInstance = replayProcessInstanceList.get(0);
                }
                refreshEvents();
            }
        }
    });
    selectLayout.addComponent(replayButton);
    selectLayout.setComponentAlignment(replayButton, Alignment.MIDDLE_LEFT);
    instanceLayout = new HorizontalLayout();
    instanceLayout.setWidth(100, UNITS_PERCENTAGE);
    addDetailComponent(instanceLayout);
    initInstancesTable();
}
Also used : ReplaySimulationRun(org.activiti.crystalball.simulator.ReplaySimulationRun) ClickEvent(com.vaadin.ui.Button.ClickEvent) SimpleEventCalendar(org.activiti.crystalball.simulator.SimpleEventCalendar) NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) SimulationEventComparator(org.activiti.crystalball.simulator.SimulationEventComparator) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) EventLogTransformer(org.activiti.crystalball.simulator.delegate.event.impl.EventLogTransformer) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) ValueChangeListener(com.vaadin.data.Property.ValueChangeListener) Button(com.vaadin.ui.Button) NativeSelect(com.vaadin.ui.NativeSelect) ArrayList(java.util.ArrayList) List(java.util.List) ClickListener(com.vaadin.ui.Button.ClickListener)

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