提交 abbb944e 编写于 作者: J Joram Barrez

ACT-1458: added activation of process definitions to Explorer

上级 06e88beb
......@@ -45,6 +45,11 @@ public interface Job {
*/
String getExecutionId();
/**
* Returns the specific process definition on which the job was created
*/
String getProcessDefinitionId();
/**
* Returns the number of retries this job has left.
* Whenever the jobexecutor fails to execute the job, this value is decremented.
......
......@@ -12,6 +12,8 @@
*/
package org.activiti.explorer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
......@@ -36,6 +38,9 @@ public class Constants {
public static final String DEFAULT_DATE_FORMAT = "dd-MM-yyyy";
public static final String DEFAULT_TIME_FORMAT = "dd-MM-yyyy hh:mm:ss";
public static final DateFormat DEFAULT_DATE_FORMATTER = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
public static final DateFormat DEFAULT_TIME_FORMATTER = new SimpleDateFormat(DEFAULT_TIME_FORMAT);
// Default diagram image extension, when name cannot be deducted from resource name
public static final String DEFAULT_DIAGRAM_IMAGE_EXTENSION = "png";
......
......@@ -35,6 +35,7 @@ import org.activiti.explorer.ui.management.identity.GroupPage;
import org.activiti.explorer.ui.management.identity.UserPage;
import org.activiti.explorer.ui.management.job.JobPage;
import org.activiti.explorer.ui.management.processdefinition.ActiveProcessDefinitionPage;
import org.activiti.explorer.ui.management.processdefinition.SuspendedProcessDefinitionPage;
import org.activiti.explorer.ui.process.MyProcessInstancesPage;
import org.activiti.explorer.ui.process.ProcessDefinitionPage;
import org.activiti.explorer.ui.process.ProcessMenuBar;
......@@ -246,11 +247,11 @@ public class DefaultViewManager implements ViewManager {
}
public void showSuspendedProcessDefinitionsPage() {
// TODO
switchView(new SuspendedProcessDefinitionPage(), ViewManager.MAIN_NAVIGATION_MANAGE, ManagementMenuBar.ENTRY_SUSPENDED_PROCESS_DEFINITIONS);
}
public void showSuspendedProcessDefinitionsPage(String processDefinitionsId) {
// TODO
public void showSuspendedProcessDefinitionsPage(String processDefinitionId) {
switchView(new SuspendedProcessDefinitionPage(processDefinitionId), ViewManager.MAIN_NAVIGATION_MANAGE, ManagementMenuBar.ENTRY_SUSPENDED_PROCESS_DEFINITIONS);
}
public void showJobPage() {
......
......@@ -216,6 +216,15 @@ public class ExplorerApp extends Application implements HttpServletRequestListen
}
}
// Error handling ---------------------------------------------------------------------------------
@Override
public void terminalError(com.vaadin.terminal.Terminal.ErrorEvent event) {
super.terminalError(event);
notificationManager.showErrorNotification(Messages.UNCAUGHT_EXCEPTION, event.getThrowable().getCause().getMessage());
}
// URL Handling ---------------------------------------------------------------------------------
public void setCurrentUriFragment(UriFragment fragment) {
......
......@@ -28,6 +28,7 @@ public interface Messages {
static final String BUTTON_OK = "button.ok";
static final String BUTTON_CREATE = "button.create";
static final String BUTTON_CANCEL = "button.cancel";
static final String UNCAUGHT_EXCEPTION = "uncaught.exception";
// Navigation
static final String NAVIGATION_ERROR_NOT_INVOLVED_TITLE = "navigation.error.not.involved.title";
......@@ -193,6 +194,9 @@ public interface Messages {
static final String PROCESS_DEPLOY_TIME = "process.deploy.time";
static final String PROCESS_HEADER_DIAGRAM = "process.header.diagram";
static final String PROCESS_NO_DIAGRAM = "process.no.diagram";
static final String PROCESS_HEADER_SUSPENSION_STATE = "process.header.suspension.state";
static final String PROCESS_SCHEDULED_SUSPEND = "process.scheduled.suspend";
static final String PROCESS_SCHEDULED_ACTIVATE = "process.scheduled.activate";
static final String PROCESS_START = "process.start";
static final String PROCESS_EDIT = "process.edit";
static final String PROCESS_COPY = "process.copy";
......@@ -201,6 +205,8 @@ public interface Messages {
static final String PROCESS_DEPLOY = "process.deploy";
static final String PROCESS_ACTIVATE = "process.activate";
static final String PROCESS_ACTIVATE_POPUP = "process.activate.popup";
static final String PROCESS_ACTIVATE_POPUP_TIME_DESCRIPTION = "process.activate.popup.time.description";
static final String PROCESS_ACTIVATE_POPUP_INCLUDE_PROCESS_INSTANCES_DESCRIPTION = "process.activate.popup.process.instances.description";
static final String PROCESS_SUSPEND = "process.suspend";
static final String PROCESS_SUSPEND_POPUP = "process.suspend.popup";
static final String PROCESS_SUSPEND_POPUP_TIME_DESCRIPTION = "process.suspend.popup.time.description";
......@@ -264,6 +270,8 @@ public interface Messages {
static final String JOB_NO_DUEDATE = "job.no.dudedate";
static final String JOB_ERROR = "job.error";
static final String JOB_NOT_EXECUTED = "job.not.executed";
static final String JOB_SUSPEND_PROCESSDEFINITION = "job.suspend.processdefinition";
static final String JOB_ACTIVATE_PROCESSDEFINITION = "job.activate.processdefinition";
// Deployment page
static final String DEPLOYMENT_DELETE = "deployment.delete";
......
......@@ -95,7 +95,7 @@ public interface ViewManager {
void showSuspendedProcessDefinitionsPage();
void showSuspendedProcessDefinitionsPage(String processDefinitionsId);
void showSuspendedProcessDefinitionsPage(String processDefinitionId);
void showJobPage();
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.explorer.navigation;
import org.activiti.explorer.ExplorerApp;
/**
* @author Joram Barrez
*/
public class SuspendedProcessDefinitionNavigator extends ManagementNavigator {
public static final String SUSPENDED_PROC_DEF_URI_PART = "suspendedProcessDefinition";
public String getTrigger() {
return SUSPENDED_PROC_DEF_URI_PART;
}
public void handleManagementNavigation(UriFragment uriFragment) {
String processDefinitionId = uriFragment.getUriPart(1);
if(processDefinitionId != null) {
ExplorerApp.get().getViewManager().showActiveProcessDefinitionsPage(processDefinitionId);
} else {
ExplorerApp.get().getViewManager().showActiveProcessDefinitionsPage();
}
}
}
......@@ -72,7 +72,6 @@ public interface ExplorerLayout {
static final String STYLE_ADD = "add";
static final String STYLE_NO_LINE = "no-line";
static final String STYLE_APPLICATION_LOGO = "logo";
static final String STYLE_WORKFLOW_CONSOLE_LOGO = "workflow-console-logo";
static final String STYLE_MAIN_MENU_BUTTON = "main-menu-button";
......@@ -129,6 +128,10 @@ public interface ExplorerLayout {
static final String STYLE_JOB_EXCEPTION_MESSAGE = "job-exception-message";
static final String STYLE_JOB_EXCEPTION_TRACE = "job-exception-trace";
static final String STYLE_JOB_HEADER_DUE_DATE = "job-duedate";
// Process definitions page
static final String STYLE_PROCESS_DEFINITION_SUSPEND_CHOICE = "process-definition-suspend-choice";
// Related content
static final String STYLE_RELATED_CONTENT_LIST = "related-content-list";
......
......@@ -15,6 +15,9 @@ package org.activiti.explorer.ui.management.job;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ManagementService;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.impl.jobexecutor.TimerActivateProcessDefinitionHandler;
import org.activiti.engine.impl.jobexecutor.TimerSuspendProcessDefinitionHandler;
import org.activiti.engine.impl.persistence.entity.JobEntity;
import org.activiti.engine.impl.persistence.entity.MessageEntity;
import org.activiti.engine.impl.persistence.entity.TimerEntity;
import org.activiti.engine.runtime.Job;
......@@ -94,31 +97,31 @@ public class JobDetailPanel extends DetailPanel {
}
protected void addHeader() {
GridLayout taskDetails = new GridLayout(3, 2);
taskDetails.setWidth(100, UNITS_PERCENTAGE);
taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
taskDetails.setSpacing(true);
taskDetails.setMargin(false, false, true, false);
GridLayout jobDetails = new GridLayout(3, 2);
jobDetails.setWidth(100, UNITS_PERCENTAGE);
jobDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
jobDetails.setSpacing(true);
jobDetails.setMargin(false, false, true, false);
// Add image
Embedded image = new Embedded(null, Images.JOB_50);
taskDetails.addComponent(image, 0, 0, 0, 1);
jobDetails.addComponent(image, 0, 0, 0, 1);
// Add job name
Label nameLabel = new Label(getJobLabel(job));
nameLabel.addStyleName(Reindeer.LABEL_H2);
taskDetails.addComponent(nameLabel, 1, 0, 2, 0);
jobDetails.addComponent(nameLabel, 1, 0, 2, 0);
// Add due date
PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.JOB_DUEDATE),
job.getDuedate(), i18nManager.getMessage(Messages.JOB_NO_DUEDATE), false);
dueDateLabel.addStyleName(ExplorerLayout.STYLE_JOB_HEADER_DUE_DATE);
taskDetails.addComponent(dueDateLabel, 1, 1);
jobDetails.addComponent(dueDateLabel, 1, 1);
taskDetails.setColumnExpandRatio(1, 1.0f);
taskDetails.setColumnExpandRatio(2, 1.0f);
jobDetails.setColumnExpandRatio(1, 1.0f);
jobDetails.setColumnExpandRatio(2, 1.0f);
addDetailComponent(taskDetails);
addDetailComponent(jobDetails);
}
protected String getJobLabel(Job theJob) {
......@@ -177,11 +180,35 @@ public class JobDetailPanel extends DetailPanel {
layout.addComponent(stackPanel);
layout.setExpandRatio(stackPanel, 1.0f);
} else {
Label noException = new Label(i18nManager.getMessage(Messages.JOB_NOT_EXECUTED));
layout.addComponent(noException);
layout.setExpandRatio(noException, 1.0f);
if (job.getProcessDefinitionId() != null) {
// This is a hack .. need to cleanify this in the engine
JobEntity jobEntity = (JobEntity) job;
if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)) {
Label processDefinitionLabel = new Label(i18nManager.getMessage(Messages.JOB_SUSPEND_PROCESSDEFINITION, job.getProcessDefinitionId()));
layout.addComponent(processDefinitionLabel);
} else if (jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) {
Label processDefinitionLabel = new Label(i18nManager.getMessage(Messages.JOB_ACTIVATE_PROCESSDEFINITION, job.getProcessDefinitionId()));
layout.addComponent(processDefinitionLabel);
} else {
addNotYetExecutedLabel(layout);
}
} else {
addNotYetExecutedLabel(layout);
}
}
}
private void addNotYetExecutedLabel(VerticalLayout layout) {
Label noException = new Label(i18nManager.getMessage(Messages.JOB_NOT_EXECUTED));
layout.addComponent(noException);
layout.setExpandRatio(noException, 1.0f);
}
protected String getRetriesLabel(Job theJob) {
String retriesString;
......
......@@ -39,9 +39,11 @@ public class ActiveProcessDefinitionDetailPanel extends AbstractProcessDefinitio
Button suspendButton = new Button(i18nManager.getMessage(Messages.PROCESS_SUSPEND));
suspendButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
ChangeProcessSuspensionStatePopupWindow popupWindow =
new ChangeProcessSuspensionStatePopupWindow(processDefinition.getId(), parentPage);
new ChangeProcessSuspensionStatePopupWindow(processDefinition.getId(), parentPage, true);
ExplorerApp.get().getViewManager().showPopupWindow(popupWindow);
}
......
......@@ -22,8 +22,6 @@ import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.explorer.data.AbstractLazyLoadingQuery;
import com.vaadin.data.Item;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.data.util.PropertysetItem;
/**
......@@ -50,14 +48,14 @@ public class ActiveProcessDefinitionListQuery extends AbstractLazyLoadingQuery {
List<Item> processDefinitionItems = new ArrayList<Item>();
for (ProcessDefinition processDefinition : processDefinitions) {
processDefinitionItems.add(new ActiveProcessDefinitionListItem(processDefinition));
processDefinitionItems.add(new ProcessDefinitionListItem(processDefinition));
}
return processDefinitionItems;
}
public Item loadSingleResult(String id) {
return new ActiveProcessDefinitionListItem(repositoryService.createProcessDefinitionQuery()
return new ProcessDefinitionListItem(repositoryService.createProcessDefinitionQuery()
.processDefinitionId(id).singleResult());
}
......@@ -65,39 +63,4 @@ public class ActiveProcessDefinitionListQuery extends AbstractLazyLoadingQuery {
throw new UnsupportedOperationException();
}
class ActiveProcessDefinitionListItem extends PropertysetItem implements Comparable<ActiveProcessDefinitionListItem> {
private static final long serialVersionUID = 1L;
public ActiveProcessDefinitionListItem(ProcessDefinition processDefinition) {
addItemProperty("id", new ObjectProperty<String>(processDefinition.getId(), String.class));
addItemProperty("key", new ObjectProperty<String>(processDefinition.getKey(), String.class));
addItemProperty("name", new ObjectProperty<String>(processDefinition.getName() ,String.class));
addItemProperty("version", new ObjectProperty<Integer>(processDefinition.getVersion() ,Integer.class));
}
public int compareTo(ActiveProcessDefinitionListItem other) {
String name = (String) getItemProperty("name").getValue();
String otherName = (String) other.getItemProperty("name").getValue();
int comparison = name.compareTo(otherName);
if (comparison != 0) {
return comparison;
} else {
String key = (String) getItemProperty("key").getValue();
String otherKey = (String) other.getItemProperty("key").getValue();
comparison = key.compareTo(otherKey);
if (comparison != 0) {
return comparison;
} else {
Integer version = (Integer) getItemProperty("version").getValue();
Integer otherVersion = (Integer) other.getItemProperty("version").getValue();
return version.compareTo(otherVersion);
}
}
}
}
}
......@@ -21,6 +21,7 @@ import org.activiti.explorer.I18nManager;
import org.activiti.explorer.Messages;
import org.activiti.explorer.ui.AbstractPage;
import org.activiti.explorer.ui.custom.PopupWindow;
import org.activiti.explorer.ui.mainlayout.ExplorerLayout;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
......@@ -52,12 +53,13 @@ public class ChangeProcessSuspensionStatePopupWindow extends PopupWindow {
protected DateField dateField;
protected CheckBox includeProcessInstancesCheckBox;
public ChangeProcessSuspensionStatePopupWindow(String processDefinitionId, AbstractPage parentPage) {
public ChangeProcessSuspensionStatePopupWindow(String processDefinitionId, AbstractPage parentPage, boolean suspend) {
this.processDefinitionId = processDefinitionId;
this.parentPage = parentPage;
this.i18nManager = ExplorerApp.get().getI18nManager();
setCaption(i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP));
setCaption(suspend ? i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP) :
i18nManager.getMessage(Messages.PROCESS_ACTIVATE_POPUP));
setModal(true);
center();
setResizable(false);
......@@ -67,17 +69,19 @@ public class ChangeProcessSuspensionStatePopupWindow extends PopupWindow {
verticalLayout = new VerticalLayout();
addComponent(verticalLayout);
addTimeSection();
addIncludeProcessInstancesSection();
addOkButton();
addTimeSection(suspend);
addIncludeProcessInstancesSection(suspend);
addOkButton(suspend);
}
protected void addTimeSection() {
Label timeLabel = new Label(i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_DESCRIPTION));
protected void addTimeSection(boolean suspend) {
Label timeLabel = new Label(suspend ? i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_DESCRIPTION)
: i18nManager.getMessage(Messages.PROCESS_ACTIVATE_POPUP_TIME_DESCRIPTION));
verticalLayout.addComponent(timeLabel);
verticalLayout.addComponent(new Label("&nbsp", Label.CONTENT_XHTML));
nowCheckBox = new CheckBox(i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_NOW), true);
nowCheckBox.addStyleName(ExplorerLayout.STYLE_PROCESS_DEFINITION_SUSPEND_CHOICE);
nowCheckBox.setImmediate(true);
nowCheckBox.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
......@@ -96,6 +100,7 @@ public class ChangeProcessSuspensionStatePopupWindow extends PopupWindow {
verticalLayout.addComponent(dateLayout);
dateCheckBox = new CheckBox(i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_TIME_DATE));
dateCheckBox.addStyleName(ExplorerLayout.STYLE_PROCESS_DEFINITION_SUSPEND_CHOICE);
dateCheckBox.setImmediate(true);
dateCheckBox.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
......@@ -125,20 +130,21 @@ public class ChangeProcessSuspensionStatePopupWindow extends PopupWindow {
dateLayout.addComponent(dateField);
}
protected void addIncludeProcessInstancesSection() {
protected void addIncludeProcessInstancesSection(boolean suspend) {
verticalLayout.addComponent(new Label("&nbsp", Label.CONTENT_XHTML));
verticalLayout.addComponent(new Label("&nbsp", Label.CONTENT_XHTML));
includeProcessInstancesCheckBox = new CheckBox(i18nManager.getMessage(
Messages.PROCESS_SUSPEND_POPUP_INCLUDE_PROCESS_INSTANCES_DESCRIPTION));
includeProcessInstancesCheckBox = new CheckBox(suspend ?
i18nManager.getMessage(Messages.PROCESS_SUSPEND_POPUP_INCLUDE_PROCESS_INSTANCES_DESCRIPTION) :
i18nManager.getMessage(Messages.PROCESS_ACTIVATE_POPUP_INCLUDE_PROCESS_INSTANCES_DESCRIPTION));
verticalLayout.addComponent(includeProcessInstancesCheckBox);
}
protected void addOkButton() {
protected void addOkButton(final boolean suspend) {
verticalLayout.addComponent(new Label("&nbsp", Label.CONTENT_XHTML));
verticalLayout.addComponent(new Label("&nbsp", Label.CONTENT_XHTML));
Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
okButton.setWidth("110px");
okButton.setHeight("80px");
verticalLayout.addComponent(okButton);
verticalLayout.setComponentAlignment(okButton, Alignment.BOTTOM_CENTER);
......@@ -148,8 +154,15 @@ public class ChangeProcessSuspensionStatePopupWindow extends PopupWindow {
public void buttonClick(ClickEvent event) {
RepositoryService repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
repositoryService.suspendProcessDefinitionById(processDefinitionId,
(Boolean) includeProcessInstancesCheckBox.getValue(), (Date) dateField.getValue());
boolean includeProcessInstances = (Boolean) includeProcessInstancesCheckBox.getValue();
if (suspend) {
repositoryService.suspendProcessDefinitionById(processDefinitionId,
includeProcessInstances, (Date) dateField.getValue());
} else {
repositoryService.activateProcessDefinitionById(processDefinitionId,
includeProcessInstances, (Date) dateField.getValue());
}
close();
parentPage.refreshSelectNext(); // select next item in list on the left
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.explorer.ui.management.processdefinition;
import org.activiti.engine.repository.ProcessDefinition;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.data.util.PropertysetItem;
/**
* @author Joram Barrez
*/
public class ProcessDefinitionListItem extends PropertysetItem implements Comparable<ProcessDefinitionListItem> {
private static final long serialVersionUID = 1L;
public ProcessDefinitionListItem(ProcessDefinition processDefinition) {
addItemProperty("id", new ObjectProperty<String>(processDefinition.getId(), String.class));
addItemProperty("key", new ObjectProperty<String>(processDefinition.getKey(), String.class));
addItemProperty("name", new ObjectProperty<String>(processDefinition.getName() ,String.class));
addItemProperty("version", new ObjectProperty<Integer>(processDefinition.getVersion() ,Integer.class));
}
public int compareTo(ProcessDefinitionListItem other) {
String name = (String) getItemProperty("name").getValue();
String otherName = (String) other.getItemProperty("name").getValue();
int comparison = name.compareTo(otherName);
if (comparison != 0) {
return comparison;
} else {
String key = (String) getItemProperty("key").getValue();
String otherKey = (String) other.getItemProperty("key").getValue();
comparison = key.compareTo(otherKey);
if (comparison != 0) {
return comparison;
} else {
Integer version = (Integer) getItemProperty("version").getValue();
Integer otherVersion = (Integer) other.getItemProperty("version").getValue();
return version.compareTo(otherVersion);
}
}
}
}
\ No newline at end of file
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.explorer.ui.management.processdefinition;
import org.activiti.explorer.ExplorerApp;
import org.activiti.explorer.Messages;
import org.activiti.explorer.ui.AbstractPage;
import org.activiti.explorer.ui.process.AbstractProcessDefinitionDetailPanel;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
/**
* @author Joram Barrez
*/
public class SuspendedProcessDefinitionDetailPanel extends AbstractProcessDefinitionDetailPanel {
private static final long serialVersionUID = 1L;
public SuspendedProcessDefinitionDetailPanel(String processDefinitionId, SuspendedProcessDefinitionPage suspendedProcessDefinitionPage) {
super(processDefinitionId, suspendedProcessDefinitionPage);
}
protected void initActions(final AbstractPage parentPage) {
SuspendedProcessDefinitionPage processDefinitionPage = (SuspendedProcessDefinitionPage) parentPage;
Button activateButton = new Button(i18nManager.getMessage(Messages.PROCESS_ACTIVATE));
activateButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
ChangeProcessSuspensionStatePopupWindow popupWindow =
new ChangeProcessSuspensionStatePopupWindow(processDefinition.getId(), parentPage, false);
ExplorerApp.get().getViewManager().showPopupWindow(popupWindow);
}
});
// Clear toolbar and add 'start' button
processDefinitionPage.getToolBar().removeAllButtons();
processDefinitionPage.getToolBar().addButton(activateButton);
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.explorer.ui.management.processdefinition;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.explorer.data.AbstractLazyLoadingQuery;
import com.vaadin.data.Item;
/**
* @author Joram Barrez
*/
public class SuspendedProcessDefinitionListQuery extends AbstractLazyLoadingQuery {
protected RepositoryService repositoryService;
public SuspendedProcessDefinitionListQuery() {
this.repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
}
public int size() {
return (int) repositoryService.createProcessDefinitionQuery().suspended().count();
}
public List<Item> loadItems(int start, int count) {
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
.suspended()
.orderByProcessDefinitionName().asc()
.orderByProcessDefinitionVersion().asc()
.listPage(start, count);
List<Item> processDefinitionItems = new ArrayList<Item>();
for (ProcessDefinition processDefinition : processDefinitions) {
processDefinitionItems.add(new ProcessDefinitionListItem(processDefinition));
}
return processDefinitionItems;
}
public Item loadSingleResult(String id) {
return new ProcessDefinitionListItem(repositoryService.createProcessDefinitionQuery()
.processDefinitionId(id).singleResult());
}
public void setSorting(Object[] propertyIds, boolean[] ascending) {
throw new UnsupportedOperationException();
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.explorer.ui.management.processdefinition;
import org.activiti.explorer.ExplorerApp;
import org.activiti.explorer.data.LazyLoadingContainer;
import org.activiti.explorer.data.LazyLoadingQuery;
import org.activiti.explorer.navigation.ActiveProcessDefinitionNavigator;
import org.activiti.explorer.navigation.SuspendedProcessDefinitionNavigator;
import org.activiti.explorer.navigation.UriFragment;
import org.activiti.explorer.ui.management.ManagementPage;
import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.ui.Table;
/**
* @author Joram Barrez
*/
public class SuspendedProcessDefinitionPage extends ManagementPage {
private static final long serialVersionUID = 1L;
protected String processDefinitionId;
protected Table processDefinitionTable;
protected LazyLoadingQuery processDefinitionListQuery;
protected LazyLoadingContainer processDefinitionListContainer;
public SuspendedProcessDefinitionPage() {
ExplorerApp.get().setCurrentUriFragment(
new UriFragment(SuspendedProcessDefinitionNavigator.SUSPENDED_PROC_DEF_URI_PART));
}
public SuspendedProcessDefinitionPage(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
@Override
protected void initUi() {
super.initUi();
if (processDefinitionId == null) {
selectElement(0);
} else {
selectElement(processDefinitionListContainer.getIndexForObjectId(processDefinitionId));
}
}
protected Table createList() {
processDefinitionTable = new Table();
processDefinitionListQuery = new SuspendedProcessDefinitionListQuery();
processDefinitionListContainer = new LazyLoadingContainer(processDefinitionListQuery);
processDefinitionTable.setContainerDataSource(processDefinitionListContainer);
// Column headers
processDefinitionTable.addContainerProperty("name", String.class, null);
processDefinitionTable.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
// Listener to change right panel when clicked on a user
processDefinitionTable.addListener(new Property.ValueChangeListener() {
private static final long serialVersionUID = 1L;
public void valueChange(ValueChangeEvent event) {
Item item = processDefinitionTable.getItem(event.getProperty().getValue()); // the value of the property is the itemId of the table entry
if (item != null) {
String processDefinitionId = (String) item.getItemProperty("id").getValue();
setDetailComponent(new SuspendedProcessDefinitionDetailPanel(processDefinitionId, SuspendedProcessDefinitionPage.this));
// Update URL
ExplorerApp.get().setCurrentUriFragment(
new UriFragment(ActiveProcessDefinitionNavigator.ACTIVE_PROC_DEF_URI_PART, processDefinitionId));
} else {
// Nothing selected
setDetailComponent(null);
ExplorerApp.get().setCurrentUriFragment(new UriFragment(ActiveProcessDefinitionNavigator.ACTIVE_PROC_DEF_URI_PART));
}
}
});
return processDefinitionTable;
}
}
......@@ -13,6 +13,7 @@
package org.activiti.explorer.ui.process;
import org.activiti.engine.FormService;
import org.activiti.engine.ManagementService;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
......@@ -53,6 +54,7 @@ public abstract class AbstractProcessDefinitionDetailPanel extends DetailPanel {
// Services
protected RepositoryService repositoryService;
protected ManagementService managementService;
protected FormService formService;
protected I18nManager i18nManager;
......@@ -67,6 +69,7 @@ public abstract class AbstractProcessDefinitionDetailPanel extends DetailPanel {
public AbstractProcessDefinitionDetailPanel(String processDefinitionId, AbstractPage parentPage) {
this.repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
this.managementService = ProcessEngines.getDefaultProcessEngine().getManagementService();
this.formService = ProcessEngines.getDefaultProcessEngine().getFormService();
this.i18nManager = ExplorerApp.get().getI18nManager();
......
......@@ -13,10 +13,19 @@
package org.activiti.explorer.ui.process;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.ManagementService;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.impl.jobexecutor.TimerActivateProcessDefinitionHandler;
import org.activiti.engine.impl.jobexecutor.TimerSuspendProcessDefinitionHandler;
import org.activiti.engine.impl.persistence.entity.JobEntity;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.Job;
import org.activiti.explorer.Constants;
import org.activiti.explorer.ExplorerApp;
import org.activiti.explorer.I18nManager;
import org.activiti.explorer.Messages;
......@@ -34,6 +43,7 @@ import com.vaadin.ui.themes.Reindeer;
/**
* @author Frederik Heremans
* @author Joram Barrez
*/
public class ProcessDefinitionInfoComponent extends VerticalLayout {
......@@ -41,6 +51,7 @@ public class ProcessDefinitionInfoComponent extends VerticalLayout {
// Services
protected RepositoryService repositoryService;
protected ManagementService managementService;
protected I18nManager i18nManager;
// Members
......@@ -55,6 +66,7 @@ public class ProcessDefinitionInfoComponent extends VerticalLayout {
public ProcessDefinitionInfoComponent(ProcessDefinition processDefinition, Deployment deployment) {
super();
this.repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
this.managementService = ProcessEngines.getDefaultProcessEngine().getManagementService();
this.i18nManager = ExplorerApp.get().getI18nManager();
this.processDefinition = processDefinition;
......@@ -62,9 +74,49 @@ public class ProcessDefinitionInfoComponent extends VerticalLayout {
addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
initSuspensionStateInformation();
initImage();
}
protected void initSuspensionStateInformation() {
List<Job> jobs = managementService.createJobQuery()
.processDefinitionId(processDefinition.getId()).orderByJobDuedate().asc().list();
List<JobEntity> suspensionStateJobs = new ArrayList<JobEntity>();
// TODO: this is a hack (ie the cast to JobEntity)... we must clean this in the engine!
for (Job job : jobs) {
JobEntity jobEntity = (JobEntity) job;
if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)
|| jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) {
suspensionStateJobs.add(jobEntity);
}
}
if (suspensionStateJobs.size() > 0) {
// Header
Label suspensionStateTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_SUSPENSION_STATE));
suspensionStateTitle.addStyleName(ExplorerLayout.STYLE_H3);
addComponent(suspensionStateTitle);
addEmptySpace(this);
// Actual suspend/activation jobs
for (JobEntity jobEntity : suspensionStateJobs) {
if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)) {
Label suspendLabel = new Label(i18nManager.getMessage(Messages.PROCESS_SCHEDULED_SUSPEND,
Constants.DEFAULT_TIME_FORMATTER.format(jobEntity.getDuedate())), Label.CONTENT_XHTML);
addComponent(suspendLabel);
} else if (jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) {
Label suspendLabel = new Label(i18nManager.getMessage(Messages.PROCESS_SCHEDULED_ACTIVATE,
Constants.DEFAULT_TIME_FORMATTER.format(jobEntity.getDuedate())), Label.CONTENT_XHTML);
addComponent(suspendLabel);
}
}
}
addEmptySpace(this);
}
protected void initImage() {
processImageContainer = new VerticalLayout();
......
......@@ -7,6 +7,7 @@ confirmation.dialog.no= No
button.ok = Ok
button.create = Create
button.cancel = Cancel
uncaught.exception = Warning!
# Navigation
navigation.error.not.involved.title = Cannot view task
......@@ -175,6 +176,9 @@ process.version = Version {0}
process.deploy.time = Deployed {0}
process.header.diagram = Process Diagram
process.no.diagram = No image available for this process.
process.header.suspension.state = Suspension state changes
process.scheduled.suspend = This process definition is scheduled to be <b>suspended on {0}</b>
process.scheduled.activate = This process definition is scheduled to be <b>activated on {0}</b>
process.start = Start process
process.edit = Edit model
process.copy = Copy model
......@@ -183,6 +187,8 @@ process.new = New model
process.deploy = Deploy
process.activate = Activate
process.activate.popup = Activate process definition
process.activate.popup.time.description = When do you want to activate this process definition?
process.activate.popup.process.instances.description = Also activate all process instances for this process definitions
process.suspend = Suspend
process.suspend.popup = Suspend process definition
process.suspend.popup.time.description = When do you want to suspend this process definition?
......@@ -246,6 +252,8 @@ job.duedate = Due {0}
job.no.dudedate = No duedate
job.error = Error occurred while executing job
job.not.executed = Job hasn't been executed yet.
job.suspend.processdefinition = This job will suspend process definition {0}
job.activate.processdefinition = This job will activate process definition {0}
# Deployment page
deployment.delete = Delete
......
......@@ -915,6 +915,14 @@ div.searchbox {
.v-table-related-content-create-list .v-table-row-odd.v-selected {
background: #DFF5FF;
}
/**********************
* Process definitions *
***********************/
.process-definition-suspend-choice {
margin: 5px 5px 5px 10px;
}
/**********************
* Custom Scrollbar CSS
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册