提交 e2dd6b07 编写于 作者: J jbarrez

ACT-696: started with deployment page

上级 36e463fd
......@@ -28,6 +28,8 @@ public class Images {
public static final Resource CLOCK = new ThemeResource("img/clock.png");
public static final Resource PEOPLE = new ThemeResource("img/people.png");
public static final Resource PROCESS = new ThemeResource("img/process.png");
public static final Resource PROCESS_48 = new ThemeResource("img/process_48.png");
public static final Resource RESOURCE = new ThemeResource("img/resource.png");
// Accounts
public static final Resource SKYPE = new ThemeResource("img/skype.png");
......
......@@ -15,7 +15,7 @@ package org.activiti.explorer.ui;
import org.activiti.explorer.ExplorerApplication;
import org.activiti.explorer.ui.flow.FlowPage;
import org.activiti.explorer.ui.management.DatabasePage;
import org.activiti.explorer.ui.management.db.DatabasePage;
import org.activiti.explorer.ui.task.TaskInboxPage;
import com.vaadin.ui.Button;
......
......@@ -15,6 +15,8 @@ package org.activiti.explorer.ui.management;
import org.activiti.explorer.Constants;
import org.activiti.explorer.ExplorerApplication;
import org.activiti.explorer.ui.MenuBar;
import org.activiti.explorer.ui.management.db.DatabasePage;
import org.activiti.explorer.ui.management.deployment.DeploymentPage;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
......@@ -34,12 +36,21 @@ public class ManagementMenuBar extends MenuBar {
addStyleName(Constants.STYLE_MENUBAR);
Button database = createMenuBarButton("Database");
database.addListener(new ClickListener() {
Button databaseButton = createMenuBarButton("Database");
databaseButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
ExplorerApplication.getCurrent().switchView(new DatabasePage());
}
});
Button deploymentButton = createMenuBarButton("Deployments");
deploymentButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
ExplorerApplication.getCurrent().switchView(new DeploymentPage());
}
});
fillRemainingSpace();
}
}
......@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.explorer.ui.management;
package org.activiti.explorer.ui.management.db;
import org.activiti.engine.ManagementService;
import org.activiti.engine.ProcessEngines;
......@@ -39,7 +39,7 @@ public class DatabaseDetailPanel extends VerticalLayout {
this.tableName = tableName;
this.managementService = ProcessEngines.getDefaultProcessEngine().getManagementService();
addStyleName(Constants.STYLE_DATABASE_DETAILS);
addStyleName(Reindeer.LAYOUT_WHITE);
setSizeFull();
addTableName();
......@@ -49,31 +49,42 @@ public class DatabaseDetailPanel extends VerticalLayout {
protected void addTableName() {
Label name = new Label(tableName);
name.addStyleName(Reindeer.LABEL_H1);
name.addStyleName(Constants.STYLE_DATABASE_DETAILS);
addComponent(name);
addComponent(new Label(" ", Label.CONTENT_XHTML));
}
protected void addTableData() {
Table data = new Table();
data.setEditable(false);
data.setSelectable(true);
data.setColumnReorderingAllowed(true);
addComponent(data);
data.setWidth("95%");
data.setHeight("80%");
data.addStyleName(Constants.STYLE_DATABASE_TABLE_ROW);
data.addStyleName(Reindeer.TABLE_STRONG);
setExpandRatio(data, 1.0f);
LazyLoadingQuery lazyLoadingQuery = new TableDataQuery(tableName, managementService);
LazyLoadingContainer lazyLoadingContainer = new LazyLoadingContainer(lazyLoadingQuery, 10);
data.setContainerDataSource(lazyLoadingContainer);
// Create column headers
TableMetaData metaData = managementService.getTableMetaData(tableName);
for (String columnName : metaData.getColumnNames()) {
data.addContainerProperty(columnName, String.class, null);
if (lazyLoadingContainer.size() > 0) {
Table data = new Table();
data.setContainerDataSource(lazyLoadingContainer);
data.setEditable(false);
data.setSelectable(true);
data.setColumnReorderingAllowed(true);
addComponent(data);
data.setWidth("95%");
data.setHeight("80%");
data.addStyleName(Constants.STYLE_DATABASE_TABLE_ROW);
data.addStyleName(Reindeer.TABLE_STRONG);
data.addStyleName(Constants.STYLE_DATABASE_DETAILS);
setExpandRatio(data, 1.0f);
// Create column headers
TableMetaData metaData = managementService.getTableMetaData(tableName);
for (String columnName : metaData.getColumnNames()) {
data.addContainerProperty(columnName, String.class, null);
}
} else {
Label noDataLabel = new Label("Table contains no rows");
noDataLabel.addStyleName(Constants.STYLE_DATABASE_DETAILS);
addComponent(noDataLabel);
setExpandRatio(noDataLabel, 1.0f);
}
}
......
......@@ -10,13 +10,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.explorer.ui.management;
package org.activiti.explorer.ui.management.db;
import java.util.TreeMap;
import org.activiti.engine.ManagementService;
import org.activiti.engine.ProcessEngines;
import org.activiti.explorer.Images;
import org.activiti.explorer.ui.management.ManagementPage;
import com.vaadin.data.Item;
import com.vaadin.data.Property;
......@@ -40,7 +41,6 @@ public class DatabasePage extends ManagementPage {
protected Table tableList;
public DatabasePage() {
super();
this.managementService = ProcessEngines.getDefaultProcessEngine().getManagementService();
addTableList();
......
......@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.explorer.ui.management;
package org.activiti.explorer.ui.management.db;
import java.util.ArrayList;
import java.util.List;
......
/* 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.deployment;
import java.util.List;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.explorer.Images;
import com.ocpsoft.pretty.time.PrettyTime;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;
/**
* @author Joram Barrez
*/
public class DeploymentDetailPanel extends VerticalLayout {
private static final long serialVersionUID = 1L;
protected RepositoryService repositoryService;
protected Deployment deployment;
public DeploymentDetailPanel(String deploymentId) {
this.repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
this.deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
setSpacing(true);
addStyleName(Reindeer.LAYOUT_WHITE);
addDeploymentName();
addDeploymentTime();
addProcessDefinitionLinks();
addResourceLinks();
}
protected void addDeploymentName() {
Label nameLabel = new Label(deployment.getName());
nameLabel.addStyleName(Reindeer.LABEL_H1);
addComponent(nameLabel);
}
protected void addDeploymentTime() {
Label emptySpace = new Label(" ", Label.CONTENT_XHTML);
emptySpace.setSizeUndefined();
addComponent(emptySpace);
HorizontalLayout timeDetails = new HorizontalLayout();
timeDetails.setSpacing(true);
addComponent(timeDetails);
Embedded clockImage = new Embedded(null, Images.CLOCK);
timeDetails.addComponent(clockImage);
Label timeLabel = new Label("Deployed " + new PrettyTime().format(deployment.getDeploymentTime()));
timeDetails.addComponent(timeLabel);
timeDetails.setComponentAlignment(timeLabel, Alignment.MIDDLE_CENTER);
}
protected void addProcessDefinitionLinks() {
List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
.deploymentId(deployment.getId())
.list();
if (processDefinitions.size() > 0) {
HorizontalLayout processDefinitionLayout = new HorizontalLayout();
processDefinitionLayout.setSpacing(true);
addComponent(processDefinitionLayout);
// process icon
Embedded processIcon = new Embedded(null, Images.PROCESS_48);
processDefinitionLayout.addComponent(processIcon);
// processes
VerticalLayout processDefinitionLinksLayout = new VerticalLayout();
processDefinitionLayout.addComponent(processDefinitionLinksLayout);
for (ProcessDefinition processDefinition : processDefinitions) {
Label processDefinitionLabel = new Label(processDefinition.getName());
processDefinitionLinksLayout.addComponent(processDefinitionLabel);
}
}
}
protected void addResourceLinks() {
List<String> resourceNames = repositoryService.getDeploymentResourceNames(deployment.getId());
if (resourceNames.size() > 0) {
HorizontalLayout resourceLayout = new HorizontalLayout();
addComponent(resourceLayout);
// resource icon
Embedded resourceIcon = new Embedded(null, Images.RESOURCE);
resourceLayout.addComponent(resourceIcon);
// resources
VerticalLayout resourceLinksLayout = new VerticalLayout();
resourceLayout.addComponent(resourceLinksLayout);
for (String resourceName : resourceNames) {
resourceLinksLayout.addComponent(new Label(resourceName));
}
}
}
}
/* 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.deployment;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.explorer.data.AbstractLazyLoadingQuery;
import com.vaadin.data.Item;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.data.util.PropertysetItem;
/**
* @author Joram Barrez
*/
public class DeploymentListQuery extends AbstractLazyLoadingQuery {
protected RepositoryService repositoryService;
public DeploymentListQuery() {
this.repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
}
public int size() {
return (int) repositoryService.createDeploymentQuery().count();
}
public List<Item> loadItems(int start, int count) {
List<Deployment> deployments = repositoryService.createDeploymentQuery()
.orderByDeploymentName().asc()
.orderByDeploymentId().asc()
.list();
List<Item> items = new ArrayList<Item>();
for (Deployment deployment : deployments) {
items.add(new DeploymentListitem(deployment));
}
return items;
}
public Item loadSingleResult(String id) {
return new DeploymentListitem(repositoryService.createDeploymentQuery().deploymentId(id).singleResult());
}
public void setSorting(Object[] propertyIds, boolean[] ascending) {
throw new UnsupportedOperationException();
}
class DeploymentListitem extends PropertysetItem implements Comparable<DeploymentListitem> {
private static final long serialVersionUID = 1L;
public DeploymentListitem(Deployment deployment) {
addItemProperty("id", new ObjectProperty<String>(deployment.getId()));
addItemProperty("name", new ObjectProperty<String>(deployment.getName()));
}
public int compareTo(DeploymentListitem 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 id = (String) getItemProperty("id").getValue();
String otherId = (String) other.getItemProperty("id").getValue();
return id.compareTo(otherId);
}
}
}
}
/* 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.deployment;
import org.activiti.explorer.data.LazyLoadingContainer;
import org.activiti.explorer.data.LazyLoadingQuery;
import org.activiti.explorer.ui.management.ManagementPage;
import org.activiti.explorer.ui.task.TaskDetailPanel;
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 DeploymentPage extends ManagementPage {
private static final long serialVersionUID = 1L;
protected Table deploymentTable;
public DeploymentPage() {
addDeploymentList();
}
protected void addDeploymentList() {
this.deploymentTable = new Table();
mainSplitPanel.setFirstComponent(deploymentTable);
// Set non-editable, selectable and full-size
deploymentTable.setEditable(false);
deploymentTable.setImmediate(true);
deploymentTable.setSelectable(true);
deploymentTable.setNullSelectionAllowed(false);
deploymentTable.setSizeFull();
LazyLoadingQuery deploymentListQuery = new DeploymentListQuery();
LazyLoadingContainer deploymentListContainer = new LazyLoadingContainer(deploymentListQuery, 10);
deploymentTable.setContainerDataSource(deploymentListContainer);
// Listener to change right panel when clicked on a task
deploymentTable.addListener(new Property.ValueChangeListener() {
private static final long serialVersionUID = 8811553575319455854L;
public void valueChange(ValueChangeEvent event) {
Item item = deploymentTable.getItem(event.getProperty().getValue()); // the value of the property is the itemId of the table entry
String deploymentId = (String) item.getItemProperty("id").getValue();
mainSplitPanel.setSecondComponent(new DeploymentDetailPanel(deploymentId));
}
});
// Create column headers
deploymentTable.addContainerProperty("name", String.class, null);
deploymentTable.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
}
}
......@@ -47,7 +47,6 @@ public class TaskDetailPanel extends HorizontalLayout {
protected Panel rightPanel;
public TaskDetailPanel(String taskId) {
super();
setSizeFull();
addStyleName(Reindeer.LAYOUT_WHITE);
......@@ -96,13 +95,6 @@ public class TaskDetailPanel extends HorizontalLayout {
}
protected void initTimeDetails() {
// Label detailsHeader = new Label("Details");
// detailsHeader.addStyleName(Reindeer.LABEL_H2);
// addComponent(detailsHeader);
// Label horizontalLine = new Label("<hr />", Label.CONTENT_XHTML);
// horizontalLine.addStyleName(Constants.STYLE_HORIZONTAL_SEPARATOR);
// addComponent(horizontalLine);
HorizontalLayout timeDetailsLayout = new HorizontalLayout();
timeDetailsLayout.setSpacing(true);
timeDetailsLayout.setSizeUndefined();
......
......@@ -47,20 +47,13 @@ public class TaskListQuery extends AbstractLazyLoadingQuery {
List<Task> tasks = createBaseQuery().listPage(start, count);
List<Item> items = new ArrayList<Item>();
for (Task task : tasks) {
items.add(createTaskListItem(task));
items.add(new TaskListItem(task));
}
return items;
}
public Item loadSingleResult(String id) {
return createTaskListItem(createBaseQuery().taskId(id).singleResult());
}
protected TaskListItem createTaskListItem(Task task) {
TaskListItem taskListItem = new TaskListItem();
taskListItem.addItemProperty("id", new ObjectProperty<String>(task.getId()));
taskListItem.addItemProperty("name", new ObjectProperty<String>(task.getName()));
return taskListItem;
return new TaskListItem(createBaseQuery().taskId(id).singleResult());
}
protected TaskQuery createBaseQuery() {
......@@ -75,6 +68,11 @@ public class TaskListQuery extends AbstractLazyLoadingQuery {
class TaskListItem extends PropertysetItem implements Comparable<TaskListItem>{
private static final long serialVersionUID = 1L;
public TaskListItem(Task task) {
addItemProperty("id", new ObjectProperty<String>(task.getId()));
addItemProperty("name", new ObjectProperty<String>(task.getName()));
}
public int compareTo(TaskListItem other) {
String taskId = (String) getItemProperty("id").getValue();
......
......@@ -13,9 +13,16 @@
package org.activiti.explorer.ui.task;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.explorer.Constants;
import org.activiti.explorer.ExplorerApplication;
import org.activiti.explorer.ui.MenuBar;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
/**
......@@ -24,18 +31,22 @@ import org.activiti.explorer.ui.MenuBar;
public class TaskMenuBar extends MenuBar {
private static final long serialVersionUID = 7957488256766569264L;
protected TaskService taskService;
public TaskMenuBar() {
super();
this.taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
addStyleName(Constants.STYLE_MENUBAR);
createMenuBarButton("Inbox (12)");
createMenuBarButton("Todo (4)");
createMenuBarButton("Planned (9)");
createMenuBarButton("Queued (58)");
createMenuBarButton("Delegated (2)");
createMenuBarButton("Archived");
Button inboxButton = createMenuBarButton("Inbox");
inboxButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
ExplorerApplication.getCurrent().switchView(new TaskInboxPage());
}
});
fillRemainingSpace();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册