提交 5bc046f3 编写于 作者: F frederikheremans

Added email detail panel in explorer 2

上级 433e1856
......@@ -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";
}
......@@ -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";
}
......@@ -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());
......
......@@ -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());
}
}
/* 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);
}
}
/* 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);
}
}
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册