diff --git a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/Constants.java b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/Constants.java index 1d0d83554ba560717525c7e590460877d2813246..798e05f311001aab354a855fbebb3197ae11ee1b 100644 --- a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/Constants.java +++ b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/Constants.java @@ -67,4 +67,10 @@ public class Constants { public static final String USER_INFO_TWITTER = "twitterName"; public static final String USER_INFO_SKYPE = "skype"; + public static final String EMAIL_RECIPIENT = "recipients"; + public static final String EMAIL_SENT_DATE = "sentDate"; + public static final String EMAIL_RECEIVED_DATE = "receivedDate"; + public static final String EMAIL_SUBJECT = "subject"; + public static final String EMAIL_HTML_CONTENT = "htmlContent"; + } diff --git a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/Messages.java b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/Messages.java index f0b613eecdbf42cfb2059d9f48359d844135b5ab..04c88b221f0354cf91a4ba4a490c79b13f78bbd3 100644 --- a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/Messages.java +++ b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/Messages.java @@ -299,6 +299,8 @@ public interface Messages { static final String RELATED_CONTENT_CONFIRM_DELETE = "related.content.confirm.delete"; static final String RELATED_CONTENT_SHOW_FULL_SIZE = "related.content.show.full.size"; + static final String RELATED_CONTENT_TYPE_EMAIL = "related.content.type.email"; + // People involvement static final String PEOPLE_SEARCH = "people.search"; static final String PEOPLE_INVOLVE_POPUP_CAPTION = "people.involve.popup.caption"; @@ -308,4 +310,10 @@ public interface Messages { static final String TASK_AUTHORISATION_MEMBERSHIP_ERROR = "task.authorisation.membership.error"; static final String TASK_AUTHORISATION_INBOX_ERROR = "task.authorisation.inbox.error"; + static final String EMAIL_SUBJECT = "email.subject"; + static final String EMAIL_SENT_DATE = "email.sent.date"; + static final String EMAIL_RECEIVED_DATE = "email.received.date"; + static final String EMAIL_HTML_CONTENT = "email.html.content"; + static final String EMAIL_RECIPIENTS = "email.recipients"; + } diff --git a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/AttachmentDetailPopupWindow.java b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/AttachmentDetailPopupWindow.java index 277975f4c052e63bc290a359e29083029beed070..20efffc754c66f0e64d07959ce12309b412d1e5c 100644 --- a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/AttachmentDetailPopupWindow.java +++ b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/AttachmentDetailPopupWindow.java @@ -35,6 +35,7 @@ public class AttachmentDetailPopupWindow extends PopupWindow { addStyleName(Reindeer.PANEL_LIGHT); center(); + setModal(true); setResizable(false); AttachmentRenderer renderer = ExplorerApp.get().getAttachmentRendererManager().getRenderer(attachment.getType()); diff --git a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/AttachmentRendererManager.java b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/AttachmentRendererManager.java index b857eeb14f8a43e7bb2a62022322473b36d6cca2..34f5e70c5c45d1586cd09784b688b92137fcb193 100644 --- a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/AttachmentRendererManager.java +++ b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/AttachmentRendererManager.java @@ -22,6 +22,7 @@ import java.util.Map; import org.activiti.engine.ActivitiException; import org.activiti.engine.task.Attachment; +import org.activiti.explorer.ui.content.email.EmailAttachmentRenderer; import org.activiti.explorer.ui.content.file.FileAttachmentEditor; import org.activiti.explorer.ui.content.file.ImageAttachmentRenderer; import org.activiti.explorer.ui.content.file.PdfAttachmentRenderer; @@ -93,5 +94,6 @@ public class AttachmentRendererManager implements InitializingBean, Serializable // Basic types addAttachmentRenderer(new PdfAttachmentRenderer()); addAttachmentRenderer(new ImageAttachmentRenderer()); + addAttachmentRenderer(new EmailAttachmentRenderer()); } } diff --git a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/email/EmailAttachmentRenderer.java b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/email/EmailAttachmentRenderer.java new file mode 100644 index 0000000000000000000000000000000000000000..c36ac2c4a623ba25acb0b38adc4cea6366f21d09 --- /dev/null +++ b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/email/EmailAttachmentRenderer.java @@ -0,0 +1,50 @@ +/* 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.content.email; + +import org.activiti.engine.task.Attachment; +import org.activiti.explorer.I18nManager; +import org.activiti.explorer.Messages; +import org.activiti.explorer.ui.Images; +import org.activiti.explorer.ui.content.GenericAttachmentRenderer; + +import com.vaadin.terminal.Resource; +import com.vaadin.ui.Component; + + +/** + * @author Frederik Heremans + */ +public class EmailAttachmentRenderer extends GenericAttachmentRenderer { + + public static final String EMAIL_TYPE = "email"; + + public boolean canRenderAttachment(String type) { + return EMAIL_TYPE.equals(type); + } + + public String getName(I18nManager i18nManager) { + return i18nManager.getMessage(Messages.RELATED_CONTENT_TYPE_EMAIL); + } + + public Resource getImage(Attachment attachment) { + return Images.IMAP; + } + + + public Component getDetailComponent(Attachment attachment) { + return new EmailDetailPanel(attachment); + } + +} diff --git a/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/email/EmailDetailPanel.java b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/email/EmailDetailPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..6dba935cb15cbdcb3b95f30f35dd052f9ad89464 --- /dev/null +++ b/modules/activiti-webapp-explorer2/src/main/java/org/activiti/explorer/ui/content/email/EmailDetailPanel.java @@ -0,0 +1,119 @@ +/* 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.content.email; + +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.activiti.engine.ProcessEngines; +import org.activiti.engine.TaskService; +import org.activiti.engine.impl.util.json.JSONObject; +import org.activiti.engine.impl.util.json.JSONTokener; +import org.activiti.engine.task.Attachment; +import org.activiti.explorer.Constants; +import org.activiti.explorer.ExplorerApp; +import org.activiti.explorer.I18nManager; +import org.activiti.explorer.Messages; +import org.activiti.explorer.ui.ExplorerLayout; + +import com.vaadin.ui.AbstractLayout; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Layout.SpacingHandler; +import com.vaadin.ui.themes.Reindeer; +import com.vaadin.ui.Panel; + +/** + * @author Frederik Heremans + */ +public class EmailDetailPanel extends Panel { + + private static final long serialVersionUID = 1L; + + protected I18nManager i18nManager; + protected TaskService taskService; + + protected Label content; + protected Attachment attachment; + + protected GridLayout gridLayout; + + + public EmailDetailPanel(Attachment attachment) { + setSizeFull(); + ((AbstractLayout) getContent()).setMargin(true); + ((SpacingHandler) getContent()).setSpacing(true); + addStyleName(Reindeer.PANEL_LIGHT); + + this.attachment = attachment; + this.i18nManager = ExplorerApp.get().getI18nManager(); + this.taskService = ProcessEngines.getDefaultProcessEngine().getTaskService(); + + gridLayout = new GridLayout(2, 4); + gridLayout.setSpacing(true); + addComponent(gridLayout); + + InputStream contentStream = taskService.getAttachmentContent(attachment.getId()); + // TODO: Error handling + JSONObject emailJson = new JSONObject(new JSONTokener(new InputStreamReader(contentStream))); + + String html = emailJson.getString(Constants.EMAIL_HTML_CONTENT); + String subject = emailJson.getString(Constants.EMAIL_SUBJECT); + String recipients = emailJson.getString(Constants.EMAIL_RECIPIENT); + String sentDate = emailJson.getString(Constants.EMAIL_SENT_DATE); + String receivedDate = emailJson.getString(Constants.EMAIL_RECEIVED_DATE); + + // Add subject + addSimpleRow(Messages.EMAIL_SUBJECT, subject); + addSimpleRow(Messages.EMAIL_RECIPIENTS, recipients); + addSimpleRow(Messages.EMAIL_SENT_DATE, sentDate); + addSimpleRow(Messages.EMAIL_RECEIVED_DATE, receivedDate); + + // Add HTML content + addHtmlContent(html); + + } + + protected void addHtmlContent(String html) { + Panel panel = new Panel(); + panel.setWidth(800, UNITS_PIXELS); + panel.setHeight(300, UNITS_PIXELS); + + content = new Label(html, Label.CONTENT_XHTML); + content.setHeight(100, UNITS_PERCENTAGE); + + panel.addComponent(content); + addComponent(panel); + } + + protected void addSimpleRow(String labelMessageKey, String content) { + addLabel(labelMessageKey); + + Label subjectLabel = new Label(content); + subjectLabel.setSizeUndefined(); + subjectLabel.addStyleName(ExplorerLayout.STYLE_LABEL_BOLD); + + gridLayout.addComponent(subjectLabel); + gridLayout.setComponentAlignment(subjectLabel, Alignment.MIDDLE_LEFT); + } + + protected void addLabel(String messageKey) { + Label theLabel = new Label(i18nManager.getMessage(messageKey)); + theLabel.setSizeUndefined(); + gridLayout.addComponent(theLabel); + + } + +} diff --git a/modules/activiti-webapp-explorer2/src/main/resources/messages.properties b/modules/activiti-webapp-explorer2/src/main/resources/messages.properties index e125d799136e8d94bcd3d0614c6d5059ba8d3352..1323f249d26341c593b32b31679f43bdeae66beb 100644 --- a/modules/activiti-webapp-explorer2/src/main/resources/messages.properties +++ b/modules/activiti-webapp-explorer2/src/main/resources/messages.properties @@ -279,8 +279,15 @@ related.content.type.file.uploaded=File ''{0}'' uploaded. related.content.type.file.required=Please upload a file to use as attachment related.content.confirm.delete = Are you sure you want to delete attachment ''{0}''? related.content.show.full.size = Show full size: +related.content.type.email = Email # People involvement people.search = Search people ... people.involve.popup.caption = Involve people -people.select.myself = Select myself \ No newline at end of file +people.select.myself = Select myself + +# Email +email.recipients = Recipients +email.subject = Subject +email.sent.date = Date sent +email.received.date = Date received \ No newline at end of file