Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbouthillie2011-05-27 19:46:00 +0000
committerjbouthillie2011-05-27 19:46:00 +0000
commit2bc0d264bc8e1c01523a646da718919fcabc22b8 (patch)
tree2b0ab1a95658f5e9ee51ca8be4fb79983599a663
parentbe50eeee5532933eb6905766f8d1ddb6a8967e95 (diff)
downloadorg.eclipse.mylyn.reviews.r4e-2bc0d264bc8e1c01523a646da718919fcabc22b8.tar.gz
org.eclipse.mylyn.reviews.r4e-2bc0d264bc8e1c01523a646da718919fcabc22b8.tar.xz
org.eclipse.mylyn.reviews.r4e-2bc0d264bc8e1c01523a646da718919fcabc22b8.zip
Initial release of SMTP connector for R4E
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/.classpath7
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/.project28
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/META-INF/MANIFEST.MF21
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/OSGI-INF/l10n/bundle.properties3
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/about.html28
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/build.properties8
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/plugin.properties13
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/plugin.xml29
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/preferences.ini5
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/Activator.java68
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/SMTPHostString.properties34
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/MailDialog.java322
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/Smtp.java344
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/MailData.java98
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/MailInputValidator.java37
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/SMTPHostString.java104
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/dialogs/CalendarDialog.java155
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/dialogs/ScheduleMeetingInputDialog.java369
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/PreferenceConstants.java42
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/PreferenceInitializer.java58
-rw-r--r--org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/SmtpHostPreferencePage.java202
22 files changed, 1983 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/.classpath b/org.eclipse.mylyn.reviews.r4e.mail.smtp/.classpath
new file mode 100644
index 00000000..2d1a4302
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/.project b/org.eclipse.mylyn.reviews.r4e.mail.smtp/.project
new file mode 100644
index 00000000..38649a07
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.mylyn.reviews.r4e.mail.smtp</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.mylyn.reviews.r4e.mail.smtp/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..55084bba
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Tue Apr 12 14:05:26 EDT 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/META-INF/MANIFEST.MF b/org.eclipse.mylyn.reviews.r4e.mail.smtp/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..85da7683
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.mylyn.reviews.r4e.mail.smtp;singleton:=true
+Bundle-Version: 0.8.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.mylyn.reviews.notifications;bundle-version="0.8.0",
+ org.eclipse.mylyn.reviews.VCalendar;bundle-version="0.1.0",
+ org.eclipse.mylyn.commons.core;bundle-version="3.5.0",
+ javax.activation;bundle-version="1.1.0",
+ javax.mail;bundle-version="1.4.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.eclipse.ui.forms,
+ org.eclipse.ui.forms.events,
+ org.eclipse.ui.forms.widgets
+Bundle-Vendor: %providerName
+Export-Package: org.eclipse.mylyn.reviews.r4e.mail.smtp,
+ org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.preferences
+Bundle-Activator: org.eclipse.mylyn.reviews.r4e.mail.smtp.Activator
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/OSGI-INF/l10n/bundle.properties b/org.eclipse.mylyn.reviews.r4e.mail.smtp/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 00000000..4fd6f765
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.mylyn.reviews.r4e.mail.smtp
+extension.name = SMTP
+Bundle-Name = Smtp \ No newline at end of file
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/about.html b/org.eclipse.mylyn.reviews.r4e.mail.smtp/about.html
new file mode 100644
index 00000000..23193b85
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>January, 2011</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/build.properties b/org.eclipse.mylyn.reviews.r4e.mail.smtp/build.properties
new file mode 100644
index 00000000..f95f89c3
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/build.properties
@@ -0,0 +1,8 @@
+output.. = bin/
+bin.includes = META-INF/,\
+ plugin.xml,\
+ OSGI-INF/l10n/bundle.properties,\
+ preferences.ini,\
+ .classpath,\
+ plugin.properties,\
+ about.html
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/plugin.properties b/org.eclipse.mylyn.reviews.r4e.mail.smtp/plugin.properties
new file mode 100644
index 00000000..7e350b27
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/plugin.properties
@@ -0,0 +1,13 @@
+
+ ###############################################################################
+# Copyright (c) 2010 2011 Ericsson and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Ericsson Research Canada - initial API and implementation
+###############################################################################
+pluginName = Mylyn Reviews R4E (Incubation)
+providerName = Eclipse Mylyn
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/plugin.xml b/org.eclipse.mylyn.reviews.r4e.mail.smtp/plugin.xml
new file mode 100644
index 00000000..bde7ff30
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ id="reviews.r4e.mail.smtp"
+ name="%Bundle-Name"
+ point="org.eclipse.mylyn.reviews.notifications.connectors">
+ <connector
+ core="org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.Smtp"
+ id="mylyn.reviews.r4e.mail.smtp.connector">
+ </connector>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.mylyn.reviews.r4e.ui.preferences.R4EPreferencePage"
+ class="org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.preferences.SmtpHostPreferencePage"
+ id="org.eclipse.mylyn.reviews.r4e.mail.smtp.page1"
+ name="SMTP Host">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.preferences.PreferenceInitializer">
+ </initializer>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/preferences.ini b/org.eclipse.mylyn.reviews.r4e.mail.smtp/preferences.ini
new file mode 100644
index 00000000..d4732927
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/preferences.ini
@@ -0,0 +1,5 @@
+#
+# The list of SMTP Host should be separated by ":" if more than one is created
+#
+#serverList=smtp.eamcs.ericsson.se:smtp.eapac.ericsson.se:se-smtp.ericsson.se:mailgate.al.sw.ericsson.se
+
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/Activator.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/Activator.java
new file mode 100644
index 00000000..2411f6af
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/Activator.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2011 Ericsson and others.
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson Research Canada - Initial implementation SMTP mail
+ *
+ */
+package org.eclipse.mylyn.reviews.r4e.mail.smtp;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Jacques Bouthillier
+ *
+ * @version $Revision: 1.0 $
+ */
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String FPLUGIN_ID = "org.eclipse.mylyn.reviews.r4e.mail.smtp"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator fPlugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ fPlugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ fPlugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return fPlugin;
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/SMTPHostString.properties b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/SMTPHostString.properties
new file mode 100644
index 00000000..38af9b7c
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/SMTPHostString.properties
@@ -0,0 +1,34 @@
+#
+# File describing the string use in the SMTP plug-in
+#
+#
+#
+MailDialog.label.title=New Email...
+MailDialog.label.toLabel=To:
+MailDialog.label.subjectLabel=Subject:
+MailDialog.label.send=Send
+MailDialog.label.toLabel.tooltip=Mail deliver to the following users.
+MailDialog.label.subjectLabel.tooltip=Subject this e-mail is looking information about.
+MailDialog.label.send.tooltip=Send message to the list of Authors.
+MailDialog.label.close.tooltip=Close the popup window
+#
+#
+#
+basic_parameter=Basic Parameters
+enter_meet_info=Enter Meeting Information
+start_time_label=Starts:
+duration_label=Duration (minutes):
+location_label=Location:
+dialog_title_error= "R4E Error"
+no_input_given=No Input given
+duration_Error=No input given for duration field
+location_Error=No input given for location field
+to_Error=No destination input given for To: field
+subject_Error=No input given for subject field
+message_body_Error=No message input given
+#
+# SMTP Pref page
+#
+smtp_pref_title =Enter a SMTP Server
+smtp_pref_dialog_msg=SMTP Server:
+
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/MailDialog.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/MailDialog.java
new file mode 100644
index 00000000..1e16c2f9
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/MailDialog.java
@@ -0,0 +1,322 @@
+/**
+ * Copyright (c) 2011 Ericsson and others.
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson Research Canada - Dialog used to display SMTP mail
+ *
+ */
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.Activator;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.MailData;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.MailInputValidator;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.SMTPHostString;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+
+
+/**
+ * @author Jacques Bouthillier
+ *
+ * @version $Revision: 1.0 $
+ */
+public class MailDialog extends FormDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field MIN_X_WIN_SIZE.
+ * (value is 700)
+ */
+ private static final int MIN_X_WIN_SIZE = 700;
+
+ /**
+ * Field MIN_Y_WIN_SIZE.
+ * (value is 425)
+ */
+ private static final int MIN_Y_WIN_SIZE = 425;
+
+ // ------------------------------------------------------------------------
+ // Member variables
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field fDestinationsInputTextField.
+ */
+ private Text fDestinationsInputTextField = null;
+ /**
+ * Field fSubjectInputTextField.
+ */
+ private Text fSubjectInputTextField = null;
+ /**
+ * Field fMessageBodyInputTextField.
+ */
+ protected Text fMessageBodyInputTextField = null;
+ /**
+ * Field fAttachment.
+ */
+ private String fAttachment = null;
+ /**
+ * Field fMailData.
+ */
+ private MailData fMailData = null;
+
+ /**
+ * The input validator, or <code>null</code> if none.
+ */
+ private final IInputValidator fValidator;
+
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for MailDialog.
+ * @param aParentShell Shell
+ */
+ public MailDialog(Shell aParentShell) {
+ super(aParentShell);
+ setBlockOnOpen(true);
+ fValidator = new MailInputValidator();
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method buttonPressed.
+ * @param buttonId int
+
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) */
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.OK_ID) {
+
+ //Validate Destinations
+ String validateResult = validateEmptyInput(fDestinationsInputTextField);
+ if (null != validateResult) {
+
+ //Validation of input failed
+ final ErrorDialog dialog = new ErrorDialog(null,
+ SMTPHostString.getString("dialog_title_error"),
+ SMTPHostString.getString("to_Error"),
+ new Status(IStatus.ERROR,
+ Activator.FPLUGIN_ID, 0, validateResult, null), IStatus.ERROR);
+ dialog.open();
+ this.getShell().setCursor(this.getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
+ return;
+ }
+ final String[] destinationValues = fDestinationsInputTextField.getText().split(";");
+
+ //Validate Subject
+ validateResult = validateEmptyInput(fSubjectInputTextField);
+ if (null != validateResult) {
+ //Validation of input failed
+ final ErrorDialog dialog = new ErrorDialog(null,
+ SMTPHostString.getString("dialog_title_error"),
+ SMTPHostString.getString("subject_Error"),
+ new Status(IStatus.ERROR,
+ Activator.FPLUGIN_ID, 0, validateResult, null), IStatus.ERROR);
+ dialog.open();
+ this.getShell().setCursor(this.getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
+ return;
+ }
+ final String subjectValue = fSubjectInputTextField.getText();
+
+ //Validate Message Body
+ validateResult = validateEmptyInput(fMessageBodyInputTextField);
+ if (null != validateResult) {
+ //Validation of input failed
+ final ErrorDialog dialog = new ErrorDialog(null,
+ SMTPHostString.getString("dialog_title_error"),
+ SMTPHostString.getString("message_body_Error"),
+ new Status(IStatus.ERROR,
+ Activator.FPLUGIN_ID, 0, validateResult, null), IStatus.ERROR);
+ dialog.open();
+ this.getShell().setCursor(this.getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
+ return;
+ }
+ final String messageBodyValue = fMessageBodyInputTextField.getText();
+
+ fMailData = new MailData(subjectValue, messageBodyValue, destinationValues, fAttachment);
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /**
+ * Method configureShell.
+ * @param shell Shell
+
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(SMTPHostString.getString("MailDialog.label.title"));
+ }
+
+ /**
+ * Configures the dialog form and creates form content. Clients should
+ * override this method.
+ * @param mform - the dialog form
+ */
+ @Override
+ protected void createFormContent(final IManagedForm mform) {
+
+ final FormToolkit toolkit = mform.getToolkit();
+ final ScrolledForm sform = mform.getForm();
+ sform.setExpandVertical(true);
+ final Composite composite = sform.getBody();
+ final FormLayout layout = new FormLayout();
+ layout.marginWidth = 7;
+ layout.marginHeight = 3;
+ composite.setLayout(layout);
+
+ createMailForm(composite, toolkit);
+ getShell().setMinimumSize(MIN_X_WIN_SIZE, MIN_Y_WIN_SIZE);
+ }
+
+ /**
+ * Creates new mail form area
+ * @param aParent Composite
+ * @param aToolkit FormToolkit
+ */
+ private void createMailForm(Composite aParent, FormToolkit aToolkit) {
+
+ final Composite mailForm = aToolkit.createComposite(aParent);
+ mailForm.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
+ final FormLayout layout = new FormLayout();
+ layout.marginWidth = 7;
+ layout.marginHeight = 3;
+ mailForm.setLayout(layout);
+
+ final FormData mailFormData = new FormData();
+ mailFormData.top = new FormAttachment(0, 0);
+ mailFormData.left = new FormAttachment(0);
+ mailFormData.right = new FormAttachment(100);
+ mailFormData.bottom = new FormAttachment(100);
+ mailForm.setLayoutData(mailFormData);
+
+ //Destinations
+ final Label destinationsLabel = aToolkit.createLabel(mailForm, SMTPHostString.getString("MailDialog.label.toLabel"), SWT.NONE);
+ destinationsLabel.setToolTipText(SMTPHostString.getString("MailDialog.label.toLabel.tooltip"));
+ final FormData destinationsLabelData = new FormData();
+ destinationsLabelData.top = new FormAttachment(0, 2);
+ destinationsLabelData.left = new FormAttachment(0);
+ destinationsLabel.setLayoutData(destinationsLabelData);
+
+ fDestinationsInputTextField = aToolkit.createText(mailForm, "", SWT.BORDER);
+ fDestinationsInputTextField.setEnabled(true);
+ final FormData toTextData = new FormData();
+ toTextData.top = new FormAttachment(0);
+ toTextData.left = new FormAttachment(destinationsLabel, 34);
+ toTextData.right = new FormAttachment(98);
+ fDestinationsInputTextField.setLayoutData(toTextData);
+
+ //Subject
+ final Label subjectLabel = aToolkit.createLabel(mailForm, SMTPHostString.getString("MailDialog.label.subjectLabel"), SWT.NONE);
+ subjectLabel.setToolTipText(SMTPHostString.getString("MailDialog.label.subjectLabel.tooltip"));
+ final FormData subjectLabelData = new FormData();
+ subjectLabelData.top = new FormAttachment(destinationsLabel, 15, SWT.BOTTOM);
+ subjectLabelData.left = new FormAttachment(0);
+ subjectLabel.setLayoutData(subjectLabelData);
+
+ fSubjectInputTextField = aToolkit.createText(mailForm, "", SWT.BORDER);
+ final FormData subjectData = new FormData();
+ subjectData.top = new FormAttachment(fDestinationsInputTextField, 10, SWT.BOTTOM);
+ subjectData.left = new FormAttachment(subjectLabel, 10);
+ subjectData.right = new FormAttachment(98);
+ fSubjectInputTextField.setLayoutData(subjectData);
+
+ // Description Text
+ fMessageBodyInputTextField = new Text(mailForm, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ final FormData messageBodyEditorData = new FormData();
+ messageBodyEditorData.top = new FormAttachment(subjectLabel, 15, SWT.BOTTOM);
+ messageBodyEditorData.left = new FormAttachment(0);
+ messageBodyEditorData.right = new FormAttachment(98);
+ messageBodyEditorData.bottom = new FormAttachment(98);
+ fMessageBodyInputTextField.setLayoutData(messageBodyEditorData);
+ mailForm.setSize(MIN_X_WIN_SIZE, MIN_Y_WIN_SIZE);
+
+ // Adjust the to text offset
+ final FormData data = (FormData) fDestinationsInputTextField.getLayoutData();
+ data.left = new FormAttachment(fSubjectInputTextField, 0, SWT.LEFT);
+ fDestinationsInputTextField.setLayoutData(data);
+ }
+
+ /**
+ * Method isResizable.
+
+ * @return boolean */
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ /**
+ * Method getEmailData.
+
+ * @return MailData */
+ public MailData getEmailData() {
+ return fMailData;
+ }
+
+ /**
+ * Set the data to display in the box
+ * @param aDestinations String[]
+ * @param aSubject String
+ * @param aMessageBody String
+ * @param aAttachment String
+ */
+ public void setMailInfo(String[] aDestinations, String aSubject, String aMessageBody, String aAttachment) {
+
+ final StringBuilder recipient = new StringBuilder();
+ for (int i = 0; i < aDestinations.length; i++) {
+ recipient.append(aDestinations[i]);
+ if (i < aDestinations.length - 1) {
+ recipient.append(';');
+ }
+ }
+ fDestinationsInputTextField.setText(recipient.toString());
+ fSubjectInputTextField.setText(aSubject);
+ fMessageBodyInputTextField.setText(aMessageBody);
+ fAttachment = aAttachment;
+ }
+
+ /**
+ * Method validateEmptyInput.
+ * @param aText Text
+
+ * @return String */
+ private String validateEmptyInput(Text aText) {
+ if (null != fValidator) {
+ return fValidator.isValid(aText.getText());
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/Smtp.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/Smtp.java
new file mode 100644
index 00000000..1df111dd
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/Smtp.java
@@ -0,0 +1,344 @@
+/**
+ * Copyright (c) 2011 Ericsson and others.
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson Research Canada - Initial implementation SMTP mail
+ *
+ */
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion;
+
+import java.util.Date;
+import java.util.Properties;
+import java.util.TimeZone;
+
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.window.Window;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.reviews.notifications.core.IMeetingData;
+import org.eclipse.mylyn.reviews.notifications.core.NotificationFilter;
+import org.eclipse.mylyn.reviews.notifications.core.NotificationsCore;
+import org.eclipse.mylyn.reviews.notifications.spi.NotificationsConnector;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.Activator;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.MailData;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.dialogs.ScheduleMeetingInputDialog;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.preferences.SmtpHostPreferencePage;
+import org.eclipse.mylyn.reviews.vcalendar.core.VCalendar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+
+
+/**
+ * @author Jacques Bouthillier
+ *
+ * @version $Revision: 1.0 $
+ */
+public class Smtp extends NotificationsConnector {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for Smtp.
+ */
+ public Smtp() {
+ setEnable();
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Set the flag for the connector when running on any environment
+ */
+ private void setEnable () {
+ enabled = true;
+ }
+
+ /**
+ * Creates and send an e-mail. Will try for each host defined to send e-mail with the main
+ * SMP servers. The catch block of the caller would
+ * look like this } catch (MessagingException aEex) {
+ * if (try all defined SMTP server) {
+ * throw new CoreException(new Status(Status.ERROR, FPLUGIN_ID,
+ * ex.getMessage())
+ *
+ * @param aEmailFrom String
+ * @param aEmailsTo String[]
+ * @param aSubject String
+ * @param aBody String
+ * @param aAttachment String
+ * @param aFilter NotificationFilter
+ * @throws CoreException
+ */
+ @Override
+ public void sendEmail(String aEmailFrom, String[] aEmailsTo,
+ String aSubject, String aBody, String aAttachment,
+ NotificationFilter aFilter) throws CoreException {
+ // The SMTP connection will be tried in this order stored in the preference page.
+ // After all try the exception is thrown to the caller.
+
+ String[] smtpHost = getSMTPHost ();
+ int numHost = smtpHost.length;
+ for (int i = 0; i < numHost; i++) {
+ try {
+ createAndSendEmail(smtpHost[i], aEmailFrom, aEmailsTo, aSubject,
+ aBody, aAttachment);
+ break;
+ } catch (MessagingException aEex) {
+ if ((i + 1) >= numHost) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("ComponentObjectModelException: ");
+ sb.append(aEex.getMessage());
+ throw new CoreException(new Status(Status.ERROR, Activator.FPLUGIN_ID,
+ sb.toString()) {
+ });
+ }
+ }
+
+ }
+ }
+
+ /**
+ * method sendEmailGraphical
+ * @param aEmailFrom String
+ * @param aEmailsTo String[]
+ * @param aSubject String
+ * @param aBody String
+ * @param aAttachment String
+ * @param aFilter NotificationFilter
+
+
+ * @throws CoreException * @see org.eclipse.mylyn.reviews.notifications.NotificationConnector#sendEmailGraphical(String,
+ * String[], String, String, String, NotificationFilter) */
+ @Override
+ public void sendEmailGraphical(String aEmailFrom, String[] aEmailsTo,
+ String aSubject, String aBody, String aAttachment,
+ NotificationFilter aFilter) throws CoreException {
+
+ final MailDialog mailD = new MailDialog(getShell());
+ mailD.create();
+ mailD.setMailInfo(aEmailsTo, aSubject, aBody, aAttachment);
+
+ final int ok = mailD.open();
+ if (ok == IDialogConstants.OK_ID) {
+ //Send the email message
+ final MailData mailData = mailD.getEmailData();
+ sendEmail(aEmailFrom, mailData.getSendTo(), mailData.getSubject(),
+ mailData.getBody(), mailData.getAttachment(), aFilter);
+ }
+ }
+
+
+ /**
+ * method createMeetingRequest
+ * @param aSubject String
+ * @param aBody String
+ * @param aEmailsTo String[]
+ * @param aStartDate Long
+ * @param aDuration Integer
+ * @return IMeetingData * @throws CoreException * @see org.eclipse.mylyn.reviews.notifications.NotificationConnector#createMeetingRequest(String,
+ * String, String[], Long, Integer) */
+ @Override
+ public IMeetingData createMeetingRequest(String aSubject, String aBody,
+ String[] aEmailsTo, Long aStartDate, Integer aDuration)
+ throws CoreException {
+ IMeetingData r4eMeetingData = null;
+
+ final ScheduleMeetingInputDialog dialog = new ScheduleMeetingInputDialog(getShell());
+ dialog.create();
+ final int result = dialog.open();
+ if (result == Window.OK) {
+ final String customID = aSubject + System.currentTimeMillis();
+ final String defaultUserId = System.getProperty("user.name");
+
+ //Lets create a Vcalendar
+ r4eMeetingData = NotificationsCore.createMeetingData(
+ customID, aSubject, aBody,
+ dialog.getLocation(),
+ dialog.getStartTime().longValue(),
+ dialog.getDuration().intValue(),
+ defaultUserId, aEmailsTo);
+ final VCalendar vcal = new VCalendar();
+ final String vcalAttachment = vcal.createVCalendar(r4eMeetingData, defaultUserId, aEmailsTo);
+
+ //Now send the message
+ sendEmail(defaultUserId, aEmailsTo, r4eMeetingData.getSubject(),
+ r4eMeetingData.getBody(), vcalAttachment, null);
+ }
+
+ return r4eMeetingData;
+ }
+
+ /**
+ * method createMeetingRequest
+ * @param aMeetingData IMeetingData
+ * @param aSearchFrom Date
+
+ * @see org.eclipse.mylyn.reviews.notifications.NotificationConnector#openAndUpdateMeeting(IMeetingData, Date) */
+ @Override
+ public void openAndUpdateMeeting(IMeetingData aMeetingData, Date aSearchFrom) {
+
+ final ScheduleMeetingInputDialog dialog = new ScheduleMeetingInputDialog(getShell());
+ dialog.create();
+
+ //Set the received value
+ final Long zoneStartTime = Long.valueOf(aMeetingData.getStartTime().longValue()
+ + Long.valueOf(TimeZone.getDefault().getOffset(System.currentTimeMillis())).longValue());
+
+ dialog.setStartTime(zoneStartTime);
+ dialog.setDuration(aMeetingData.getDuration());
+ dialog.setLocation(aMeetingData.getLocation());
+
+ final int result = dialog.open();
+ if (result == Window.OK) {
+ final String defaultUserId = System.getProperty("user.name");
+
+ IMeetingData newMeetingData = null;
+ //Lets create a Vcalendar
+ try {
+ newMeetingData = NotificationsCore.createMeetingData(
+ aMeetingData.getCustomID(),
+ aMeetingData.getSubject(),
+ aMeetingData.getBody(),
+ dialog.getLocation(),
+ dialog.getStartTime().longValue(),
+ dialog.getDuration().intValue(),
+ aMeetingData.getSender(),
+ aMeetingData.getReceivers());
+ } catch (CoreException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, Activator.FPLUGIN_ID, IStatus.OK, e.toString(), e));
+ }
+ final VCalendar vcal = new VCalendar();
+ final String vcalAttachment = vcal.createVCalendar(newMeetingData, defaultUserId, aMeetingData.getReceivers());
+
+ //Now send the message
+ if (null != newMeetingData) {
+ try {
+ sendEmail(defaultUserId, newMeetingData.getReceivers(), newMeetingData.getSubject(),
+ newMeetingData.getBody(), vcalAttachment, null);
+ } catch (CoreException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, Activator.FPLUGIN_ID, IStatus.OK, e.toString(), e));
+ }
+ }
+ }
+ }
+
+ /**
+ * method fetchSystemMeetingData
+ * @param aLocalData IMeetingData
+ * @param aSearchFrom Date
+
+ * @return IMeetingData
+ * @see org.eclipse.mylyn.reviews.notifications.NotificationConnector#fetchSystemMeetingData(IMeetingData, Date) */
+ @Override
+ public IMeetingData fetchSystemMeetingData(IMeetingData aLocalData, Date aSearchFrom) {
+ return aLocalData;
+ }
+
+ /**
+ * method fetchSystemMeetingData
+ * @param aSMTPServer String
+ * @param aFrom String
+ * @param aEmails String[]
+ * @param aSubject String
+ * @param aBody String
+ * @param aAttachment String
+
+
+ * @throws MessagingException * @see org.eclipse.mylyn.reviews.notifications.NotificationConnector#fetchSystemMeetingData(IMeetingData, Date) */
+ private static void createAndSendEmail(String aSMTPServer, String aFrom, String[] aEmails,
+ String aSubject, String aBody, String aAttachment) throws MessagingException {
+ final Properties props = new Properties();
+ props.setProperty("mail.smtp.host", aSMTPServer);
+ final Session session = Session.getInstance(props, null);
+ final Message msg = new MimeMessage(session);
+ msg.setFrom(new InternetAddress(aFrom));
+
+ for (int i = 0; i < aEmails.length; i++) {
+ msg.addRecipient(Message.RecipientType.TO, new InternetAddress(aEmails[i]));
+ }
+
+ msg.setSubject(aSubject);
+ if (null == aAttachment) {
+
+ // Regular message
+ msg.setText(aBody);
+
+ } else {
+ //Message with a vCalendar in attachment
+ //Create the message part
+ BodyPart messageBodyPart = new MimeBodyPart();
+
+ //Fill the message
+ messageBodyPart.setText(aBody);
+
+ //Create a Multipart
+ final Multipart multipart = new MimeMultipart();
+
+ //Add part one
+ multipart.addBodyPart(messageBodyPart);
+
+ //Part two is attachment
+ //Create second body part
+ messageBodyPart = new MimeBodyPart();
+ final String filename = "review calendar.vcs";
+ messageBodyPart.setFileName(filename);
+ messageBodyPart.setContent(aAttachment, "text/plain");
+
+ //Add part two
+ multipart.addBodyPart(messageBodyPart);
+
+ //Put parts in message
+ msg.setContent(multipart);
+ }
+ msg.setSentDate(new Date());
+ Transport.send(msg);
+ }
+
+ /**
+ * method getShell
+
+ * @return Shell */
+ private Shell getShell() {
+ final Shell sh = PlatformUI.getWorkbench().getDisplay().getActiveShell();
+ return sh;
+ }
+
+ private String[] getSMTPHost () {
+ String[] host = null;
+ SmtpHostPreferencePage prefOrder = new SmtpHostPreferencePage();
+ host = prefOrder.getSmtpServer();
+ // for (int i = 0; i < host.length; i++) {
+ // System.out.println("Host [ " + i + " ] : " +
+ // host[i]);
+ // }
+ return host;
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/MailData.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/MailData.java
new file mode 100644
index 00000000..8038f2e5
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/MailData.java
@@ -0,0 +1,98 @@
+/**
+ * Copyright (c) 2011 Ericsson and others.
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson Research Canada - Mail data information structure
+ *
+ */
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal;
+
+/**
+ * @author Jacques Bouthillier
+ *
+ * @version $Revision: 1.0 $
+ */
+public class MailData {
+
+ // ------------------------------------------------------------------------
+ // Member variables
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field fSubject.
+ */
+ private final String fSubject;
+ /**
+ * Field fBody.
+ */
+ private final String fBody;
+ /**
+ * Field fSendTo.
+ */
+ private final String[] fSendTo;
+ /**
+ * Field fAttachment.
+ */
+ private final String fAttachment;
+
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for MailData.
+ * @param aSubject String
+ * @param aBody String
+ * @param aSendTo String[]
+ * @param aAttachment String
+ */
+ public MailData(String aSubject, String aBody, String[] aSendTo, String aAttachment) {
+ fSubject = aSubject;
+ fBody = aBody;
+ fSendTo = aSendTo;
+ fAttachment = aAttachment;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method getSubject.
+ * @return String
+ */
+ public String getSubject () {
+ return fSubject;
+ }
+
+ /**
+ * Method getBody.
+ * @return String
+ */
+ public String getBody () {
+ return fBody;
+ }
+
+ /**
+ * Method getSendTo.
+ * @return String[]
+ */
+ public String[] getSendTo () {
+ return fSendTo;
+ }
+
+ /**
+ * Method getAttachment.
+ * @return String
+ */
+ public String getAttachment () {
+ return fAttachment;
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/MailInputValidator.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/MailInputValidator.java
new file mode 100644
index 00000000..1463b8cf
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/MailInputValidator.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2011 Ericsson and others.
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson Research Canada - Mail data information structure
+ *
+ */
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+
+/**
+ * @author lmcdubo
+ * @version $Revision: 1.0 $
+ */
+public class MailInputValidator implements IInputValidator {
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method isEmpty.
+ * @param aNewText String
+ * @return String
+ */
+ public String isValid(String aNewText) {
+ if (null == aNewText || 0 == aNewText.length()) return SMTPHostString.getString("no_input_given");
+ return null;
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/SMTPHostString.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/SMTPHostString.java
new file mode 100644
index 00000000..159cdba0
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/SMTPHostString.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2011 Ericsson and others.
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson Research Canada - Provides resources from resource bundle.
+ *
+ */
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.Activator;
+
+/**
+ *
+ *
+ * @author Jacques Bouthillier
+ * @version $Id: R4EString.java
+ */
+public class SMTPHostString {
+ /**
+ * Field FBUNDLE_NAME.
+ * (value is ""org.eclipse.mylyn.reviews.r4e.mail.smtp.R4EString"")
+ */
+ private static final String FBUNDLE_NAME = "org.eclipse.mylyn.reviews.r4e.mail.smtp.SMTPHostString"; //$NON-NLS-1$
+
+ /**
+ * Field RESOURCE_BUNDLE.
+ */
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(FBUNDLE_NAME);
+
+ /**
+ * Private Constructor
+ */
+ private SMTPHostString() {
+ //Prevents clients from instantiating this class.
+ }
+
+ /**
+ * Gets the key from the value, or 'value' if not found.
+ *
+ * @param key the value to search value.
+
+ * @return the key from the value, or 'value' if not found. */
+ public static String getString(String key) {
+ // Debug.print("In getString for: " + key);
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, Activator.FPLUGIN_ID, IStatus.OK, e.toString(), e));
+ // Debug.print("EXCEPTION In getString for:" + key);
+ return '!' + key + '!';
+ }
+ }
+
+ /**
+ * Format the String according to the object pass
+ *
+ * @param key
+ * String
+ * @param arg
+ * Object
+
+ * @return the key from the value, or 'value' if not found. */
+ public static String getFormattedString(String key, Object arg) {
+ String format = null;
+ try {
+ format = RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, Activator.FPLUGIN_ID, IStatus.OK, e.toString(), e));
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ if (null == arg) {
+ arg = ""; //$NON-NLS-1$
+ }
+ return MessageFormat.format(format, new Object[] { arg });
+ }
+
+ /**
+ * Format the String according to the object pass
+ *
+ * @param key
+ * String
+
+
+ * @param args String[]
+ * @return the key from the value, or 'value' if not found. */
+ public static String getFormattedString(String key, String[] args) {
+ return MessageFormat.format(RESOURCE_BUNDLE.getString(key),
+ args);
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/dialogs/CalendarDialog.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/dialogs/CalendarDialog.java
new file mode 100644
index 00000000..a294682b
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/dialogs/CalendarDialog.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson Research Canada
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Description:
+ *
+ * This class implements the dialog used to display and select a date in a calendar
+ *
+ * Contributors:
+ * Sebastien Dubois - Created for Mylyn Review R4E project
+ *
+ ******************************************************************************/
+
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.dialogs;
+
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DateTime;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * @author lmcdubo
+ * @version $Revision: 1.0 $
+ */
+public class CalendarDialog extends FormDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field ADD_CALENDAR_DIALOG_TITLE.
+ * (value is ""Select Date"")
+ */
+ private static final String ADD_CALENDAR_DIALOG_TITLE = "Select Date";
+
+
+ // ------------------------------------------------------------------------
+ // Member variables
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field fIncludeTime.
+ */
+ private final boolean fIncludeTime;
+
+ /**
+ * Field fCalendar.
+ */
+ private DateTime fCalendar = null;
+
+ /**
+ * Field fTime.
+ */
+ private DateTime fTime = null;
+
+ /**
+ * Field fDate.
+ */
+ private GregorianCalendar fDate = null;
+
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for CalendarDialog.
+ * @param aParentShell Shell
+ * @param aIncludeTime boolean
+ */
+ public CalendarDialog(Shell aParentShell, boolean aIncludeTime) {
+ super(aParentShell);
+ setBlockOnOpen(true);
+ fIncludeTime = aIncludeTime;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method configureShell.
+ * @param shell Shell
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(ADD_CALENDAR_DIALOG_TITLE);
+ }
+
+ /**
+ * Method buttonPressed.
+ * @param buttonId int
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.OK_ID) {
+ if (fIncludeTime) {
+ fDate = new GregorianCalendar(fCalendar.getYear(), fCalendar.getMonth(), fCalendar.getDay(),
+ fTime.getHours(), fTime.getMinutes());
+ } else {
+ fDate = new GregorianCalendar(fCalendar.getYear(), fCalendar.getMonth(), fCalendar.getDay());
+ }
+ }
+ super.buttonPressed(buttonId);
+ }
+
+ /**
+ * Configures the dialog form and creates form content. Clients should
+ * override this method.
+ *
+ * @param mform
+ * the dialog form
+ */
+ @Override
+ protected void createFormContent(final IManagedForm mform) {
+
+ final ScrolledForm sform = mform.getForm();
+ sform.setExpandVertical(true);
+ final Composite composite = sform.getBody();
+ final GridLayout layout = new GridLayout();
+ composite.setLayout(layout);
+ fCalendar = new DateTime(composite, SWT.CALENDAR | SWT.BORDER);
+ fCalendar.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+ if (fIncludeTime) {
+ fTime = new DateTime(composite, SWT.TIME | SWT.SHORT | SWT.BORDER);
+ fTime.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
+ }
+ }
+
+ /**
+ * Method getDate.
+ * @return Date
+ */
+ public Date getDate() {
+ return fDate.getTime();
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/dialogs/ScheduleMeetingInputDialog.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/dialogs/ScheduleMeetingInputDialog.java
new file mode 100644
index 00000000..61101adc
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/dialogs/ScheduleMeetingInputDialog.java
@@ -0,0 +1,369 @@
+// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.constructorsOnlyInvokeFinalMethods, useForLoop, com.instantiations.assist.eclipse.analysis.deserializeabilitySecurity, com.instantiations.assist.eclipse.analysis.disallowReturnMutable, com.instantiations.assist.eclipse.analysis.enforceCloneableUsageSecurity, explicitThisUsage
+/*******************************************************************************
+ * Copyright (c) 2011 Ericsson Research Canada
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Description:
+ *
+ * This class implements the dialog used to fill in the meeting request information
+ *
+ * Contributors:
+ * Sebastien Dubois - Created for Mylyn Review R4E project
+ *
+ ******************************************************************************/
+
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.dialogs;
+
+import java.text.SimpleDateFormat;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.Activator;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.MailInputValidator;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.SMTPHostString;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.events.ExpansionAdapter;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * @author lmcdubo
+ * @version $Revision: 1.0 $
+ */
+public class ScheduleMeetingInputDialog extends FormDialog {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field MEETING_DIALOG_TITLE.
+ * (value is ""Meeting Information"")
+ */
+ private static final String MEETING_DIALOG_TITLE = "Meeting Information";
+
+ /**
+ * Field BASIC_PARAMS_HEADER_MSG.
+ * (value is ""Enter Meeting Information"")
+ */
+ private static final String BASIC_PARAMS_HEADER_MSG = "Enter Meeting Information";
+
+ /**
+ * Field SIMPLE_DATE_FORMAT.
+ * (value is ""yyyy/MM/dd"")
+ */
+ public static final String SIMPLE_DATE_FORMAT = "yyyy-MMM-dd HH:mm";
+
+
+ // ------------------------------------------------------------------------
+ // Member variables
+ // ------------------------------------------------------------------------
+
+ /**
+ * Field fStartTime.
+ */
+ protected Long fStartTime = null;
+
+ /**
+ * Field fCalendarButton.
+ */
+ protected Button fCalendarButton = null;
+
+ /**
+ * Field fDuration.
+ */
+ private Integer fDuration = null;
+
+ /**
+ * Field fLocation.
+ */
+ private String fLocation = null;
+
+ /**
+ * Field fStartTimeInputTextField.
+ */
+ protected Text fStartTimeInputTextField = null;
+
+ /**
+ * Field fDurationInputTextField.
+ */
+ private Text fDurationInputTextField = null;
+
+ /**
+ * Field fLocationInputTextField.
+ */
+ private Text fLocationInputTextField = null;
+
+ /**
+ * The input validator, or <code>null</code> if none.
+ */
+ private final IInputValidator fValidator;
+
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor for ScheduleMeetingInputDialog.
+ * @param aParentShell Shell
+ */
+ public ScheduleMeetingInputDialog(Shell aParentShell) {
+ super(aParentShell);
+ setBlockOnOpen(true);
+ fValidator = new MailInputValidator();
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method buttonPressed.
+ * @param buttonId int
+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
+ */
+ @Override
+ protected void buttonPressed(int buttonId) {
+ if (buttonId == IDialogConstants.OK_ID) {
+
+ //NOTE fStartTime is set below
+ //Validate StartTime
+ String validateResult = validateEmptyInput(fDurationInputTextField);
+ if (null != validateResult) {
+
+ //Validation of input failed
+ final ErrorDialog dialog = new ErrorDialog(null,
+ SMTPHostString.getString("dialog_title_error"),
+ SMTPHostString.getString("duration_Error"),
+ new Status(IStatus.ERROR,
+ Activator.FPLUGIN_ID, 0, validateResult, null), IStatus.ERROR);
+ dialog.open();
+ this.getShell().setCursor(this.getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
+ return;
+ }
+ fDuration = Integer.valueOf(fDurationInputTextField.getText());
+
+ //Validate Location
+ validateResult = validateEmptyInput(fLocationInputTextField);
+ if (null != validateResult) {
+ //Validation of input failed
+ final ErrorDialog dialog = new ErrorDialog(null,
+ SMTPHostString.getString("dialog_title_error"),
+ SMTPHostString.getString("location_Error"),
+ new Status(IStatus.ERROR,
+ Activator.FPLUGIN_ID, 0, validateResult, null), IStatus.ERROR);
+ dialog.open();
+ this.getShell().setCursor(this.getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
+ return;
+ }
+ fLocation = fLocationInputTextField.getText();
+ } else {
+ fStartTime = null;
+ fDuration = null;
+ fLocation = null;
+ }
+ this.getShell().setCursor(this.getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
+ super.buttonPressed(buttonId);
+ }
+
+ /**
+ * Method configureShell.
+ * @param shell Shell
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(MEETING_DIALOG_TITLE);
+ }
+
+ /**
+ * Configures the dialog form and creates form content. Clients should
+ * override this method.
+ *
+ * @param mform
+ * the dialog form
+ */
+ @Override
+ protected void createFormContent(final IManagedForm mform) {
+
+ final FormToolkit toolkit = mform.getToolkit();
+ final ScrolledForm sform = mform.getForm();
+ sform.setExpandVertical(true);
+ final Composite composite = sform.getBody();
+ final GridLayout layout = new GridLayout(1, false);
+ composite.setLayout(layout);
+
+ //Basic parameters section
+ final Section basicSection = toolkit.createSection(composite, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR |
+ ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+ final GridData basicSectionGridData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ basicSectionGridData.horizontalSpan = 4;
+ basicSection.setLayoutData(basicSectionGridData);
+
+
+ basicSection.setText(SMTPHostString.getString("basic_parameter"));
+ basicSection.setDescription(BASIC_PARAMS_HEADER_MSG);
+ basicSection.addExpansionListener(new ExpansionAdapter()
+ {
+ @Override
+ public void expansionStateChanged(ExpansionEvent e){
+ getShell().setSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ }
+ });
+ final Composite basicSectionClient = toolkit.createComposite(basicSection);
+ basicSectionClient.setLayout(layout);
+ basicSection.setClient(basicSectionClient);
+
+ //Meeting composite
+ final Composite meetingComposite = toolkit.createComposite(basicSectionClient);
+ GridData textGridData = new GridData(GridData.FILL, GridData.FILL, true, true);
+ textGridData.horizontalSpan = 3;
+ meetingComposite.setLayoutData(textGridData);
+ meetingComposite.setLayout(new GridLayout(4, false));
+
+ //Meeting Start Time
+ final Label meetingStartTimeLabel = toolkit.createLabel(meetingComposite,
+ SMTPHostString.getString("start_time_label"));
+ meetingStartTimeLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
+ fStartTimeInputTextField = toolkit.createText(meetingComposite, "", SWT.BORDER);
+ textGridData = new GridData(GridData.FILL, GridData.FILL, false, false);
+ textGridData.horizontalSpan = 2;
+ fStartTimeInputTextField.setLayoutData(textGridData);
+
+ //Calendar Button
+ fCalendarButton = toolkit.createButton(meetingComposite, "...", SWT.NONE);
+ fCalendarButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
+ fCalendarButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+// final CalendarDialog dialog = new CalendarDialog(R4EUIModelController.getNavigatorView().
+// getSite().getWorkbenchWindow().getShell(), true);
+ final CalendarDialog dialog = new CalendarDialog(getShell(), true);
+ final int result = dialog.open();
+ if (result == Window.OK) {
+ final SimpleDateFormat dateFormat = new SimpleDateFormat(SIMPLE_DATE_FORMAT);
+ fStartTimeInputTextField.setText(dateFormat.format(dialog.getDate()));
+ fStartTime = Long.valueOf(dialog.getDate().getTime());
+ getShell().setSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ }
+ }
+ public void widgetDefaultSelected(SelectionEvent e) { // $codepro.audit.disable emptyMethod
+ // No implementation needed
+ }
+ });
+
+ //Meeting Duration
+ final Label meetingEndTimeLabel = toolkit.createLabel(meetingComposite, SMTPHostString.getString("duration_label") );
+ meetingEndTimeLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
+ fDurationInputTextField = toolkit.createText(meetingComposite, "", SWT.BORDER);
+ textGridData = new GridData(GridData.FILL, GridData.FILL, false, false);
+ textGridData.horizontalSpan = 2;
+ fDurationInputTextField.setLayoutData(textGridData);
+ toolkit.createLabel(meetingComposite, ""); //dummy label for alignment purposes
+
+ //Meeting Location
+ final Label meetingLocationLabel = toolkit.createLabel(meetingComposite,
+ SMTPHostString.getString("location_label"));
+ meetingLocationLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
+ fLocationInputTextField = toolkit.createText(meetingComposite, "", SWT.BORDER);
+ textGridData = new GridData(GridData.FILL, GridData.FILL, true, false);
+ textGridData.horizontalSpan = 2;
+ fLocationInputTextField.setLayoutData(textGridData);
+ toolkit.createLabel(meetingComposite, ""); //dummy label for alignment purposes
+ }
+
+ /**
+ * Method isResizable.
+ * @return boolean
+ */
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ /**
+ * Method getStartTime
+ * @return Long
+ */
+ public Long getStartTime() {
+ return fStartTime;
+ }
+
+ /**
+ * Method getDuration
+ * @return Integer
+ */
+ public Integer getDuration() {
+ return fDuration;
+ }
+
+ /**
+ * Method getLocation
+ * @return String
+ */
+ public String getLocation() {
+ return fLocation;
+ }
+
+ /**
+ * Method validateEmptyInput.
+ * @param aText Text
+ * @return String
+ */
+ private String validateEmptyInput(Text aText) {
+ if (null != fValidator) {
+ return fValidator.isValid(aText.getText());
+ }
+ return null;
+ }
+
+ /**
+ * Method setStartTime
+ * @param aSt Long
+ */
+ public void setStartTime(Long aSt) {
+ final SimpleDateFormat dateFormat = new SimpleDateFormat(SIMPLE_DATE_FORMAT);
+ fStartTimeInputTextField.setText(dateFormat.format(aSt));
+ }
+
+ /**
+ * Method setDuration
+ * @param aDuration Long
+ */
+ public void setDuration(Integer aDuration) {
+ fDurationInputTextField.setText(aDuration.toString());
+ }
+
+ /**
+ * Method setLocation
+ * @param aLoc String
+ */
+ public void setLocation(String aLoc) {
+ fLocationInputTextField.setText(aLoc);
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/PreferenceConstants.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/PreferenceConstants.java
new file mode 100644
index 00000000..6fbac70c
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/PreferenceConstants.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Ericsson Research Canada
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Description:
+ *
+ * This class holds Review SMTP Host preferences constants
+ *
+ * Contributors:
+ * Jacques Bouthillier - Created for Mylyn Review R4E SMTP preferences
+ *
+ *******************************************************************************/
+
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.preferences;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class PreferenceConstants {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * Server information
+ */
+
+ /**
+ * The group to keep the information about the SMTP server
+ */
+ public static final String FP_SERVER_HOST_GROUP = "Server Host Information";
+
+ public static final String FP_SMTP_SERVER_LABEL = "Host:";
+
+ public static final String FP_SMTP_SERVER_LIST_ID = "serverList";
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/PreferenceInitializer.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/PreferenceInitializer.java
new file mode 100644
index 00000000..0700a4ea
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/PreferenceInitializer.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Ericsson Research Canada
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Description:
+ *
+ * This class is used to initialize SMTP host preferences
+ *
+ * Contributors:
+ * Jacques Bouthillier - Created for Mylyn Review SMTP host preferences
+ *
+ *******************************************************************************/
+
+
+
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Method initializeDefaultPreferences.
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ //final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+
+ // Default Host Information
+ //store.setDefault(PreferenceConstants.FP_SMTP_SERVER_LIST_ID, F_HOST_LIST);
+
+ }
+
+ /**
+ * Load the default value to the store value Use in Junit to reset the value
+ */
+ public void storeDefaultPreferences() {
+ // final IPreferenceStore store =
+ // Activator.getDefault().getPreferenceStore();
+ //
+ // // Default Host Information
+ // store.setValue(PreferenceConstants.FP_SMTP_SERVER_LIST_ID, "389");
+
+ }
+
+}
diff --git a/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/SmtpHostPreferencePage.java b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/SmtpHostPreferencePage.java
new file mode 100644
index 00000000..080f1b27
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.r4e.mail.smtp/src/org/eclipse/mylyn/reviews/r4e/mail/smtp/mailVersion/internal/preferences/SmtpHostPreferencePage.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson Research Canada
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Description:
+ *
+ * This class represents a preference page that is contributed to the Preferences dialog. By
+ * subclassing <samp>FieldEditorPreferencePage</samp>, we can use the field support built into JFace that allows
+ * us to create a page that is small and knows how to save, restore and apply itself.
+ * <p>
+ * This page is used to modify preferences only. They are stored in the preference store that belongs to
+ * the main plug-in class. That way, preferences can be accessed directly via the preference store.
+ *
+ * Contributors:
+ * Jacques Bouthillier - Created for Mylyn Review SMTP Host preference page
+ *
+ *******************************************************************************/
+package org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.preferences;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.ListEditor;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.Activator;
+import org.eclipse.mylyn.reviews.r4e.mail.smtp.mailVersion.internal.SMTPHostString;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * @author Jacques Bouthillier
+ */
+public class SmtpHostPreferencePage extends FieldEditorPreferencePage implements
+ IWorkbenchPreferencePage {
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+ private static IPreferenceStore FStore = Activator.getDefault()
+ .getPreferenceStore();
+
+ private String fLIST_SEPARATOR = ":";
+
+ /**
+ * Field PREFS_CONTAINER_DATA_SPAN. (value is 1)
+ */
+ private static final int FPREFS_CONTAINER_DATA_SPAN = 1;
+ /**
+ * Field PREFS_CONTAINER_DATA_NUM_COLUMNS. (value is 4)
+ */
+ private static final int FPREFS_CONTAINER_DATA_NUM_COLUMNS = 4;
+
+ /**
+ * Field R4E_PREFS_CONTAINER_DATA_SPAN. (value is 2)
+ */
+ private static final int FGROUP_PREFS_SERVER_DATA_SPAN = 2;
+
+ // ------------------------------------------------------------------------
+ // Member Variables
+ // ------------------------------------------------------------------------
+
+ private ListEditor fserverlListBox;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ public SmtpHostPreferencePage() {
+ super(GRID);
+ setPreferenceStore(FStore);
+ }
+
+ // ------------------------------------------------------------------------
+ // Methods
+ // ------------------------------------------------------------------------
+ @Override
+ protected void createFieldEditors() {
+
+ // The Main preferences composite
+ final Composite prefsContainer = new Composite(getFieldEditorParent(),
+ SWT.NONE);
+ final GridData prefsContainerData = new GridData(GridData.FILL,
+ GridData.FILL, true, false);
+ prefsContainerData.horizontalSpan = FPREFS_CONTAINER_DATA_SPAN;
+ prefsContainer.setLayoutData(prefsContainerData);
+ final GridLayout prefsLayout = new GridLayout(
+ FPREFS_CONTAINER_DATA_NUM_COLUMNS, false);
+ prefsContainer.setLayout(prefsLayout);
+
+ // Create the Server host information area
+ createServerHostInformation(prefsContainer);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /**
+ * Create the Server host information GUI
+ *
+ * @param Composite
+ * aPrefsContainer
+ */
+ private void createServerHostInformation(Composite aPrefsContainer) {
+ // Create a Group to hold SMTP user preferences
+ final Group smtpHostPrefsGroup = new Group(aPrefsContainer,
+ SWT.BORDER_SOLID);
+ final GridData smtpHostPrefsGroupData = new GridData(GridData.FILL,
+ GridData.FILL, true, false);
+ smtpHostPrefsGroupData.horizontalSpan = FGROUP_PREFS_SERVER_DATA_SPAN;
+ smtpHostPrefsGroup
+ .setText(PreferenceConstants.FP_SERVER_HOST_GROUP);
+ smtpHostPrefsGroup.setLayoutData(smtpHostPrefsGroupData);
+ smtpHostPrefsGroup.setLayout(new GridLayout(
+ FGROUP_PREFS_SERVER_DATA_SPAN, false));
+
+ // dummy spacer label
+ final Label smtpPrefsSpacer = new Label(smtpHostPrefsGroup,
+ SWT.FILL);
+ final GridData smtpPrefsSpacerData = new GridData(GridData.FILL,
+ GridData.FILL, true, false);
+ smtpPrefsSpacerData.horizontalSpan = FGROUP_PREFS_SERVER_DATA_SPAN;
+ smtpPrefsSpacer.setLayoutData(smtpPrefsSpacerData);
+
+ fserverlListBox = new ListEditor(
+ PreferenceConstants.FP_SMTP_SERVER_LIST_ID,
+ PreferenceConstants.FP_SMTP_SERVER_LABEL,
+ smtpHostPrefsGroup) {
+
+ @Override
+ protected String createList(String[] aItems) {
+ StringBuilder sb = new StringBuilder();
+ int itemSize = aItems.length;
+ for (int i = 0; i < itemSize; i++) {
+ sb.append(aItems[i]);
+ if (i + 1 < itemSize) {
+ sb.append(fLIST_SEPARATOR);
+ }
+ }
+ return sb.toString();
+ }
+
+ @Override
+ protected String getNewInputObject() {
+ // New button selected
+
+ InputDialog dialog = new InputDialog(getShell(),
+ SMTPHostString.getString("smtp_pref_title"),
+ SMTPHostString.getString("smtp_pref_dialog_msg"),
+ "",
+ SmtpInputValidator());
+ dialog.create();
+ dialog.open();
+ String text = dialog.getValue();
+ return text;
+
+ }
+
+ private IInputValidator SmtpInputValidator() {
+ // No validation yet
+ return null;
+ }
+
+ @Override
+ protected String[] parseString(String aStringList) {
+ String[] star = aStringList.split(fLIST_SEPARATOR);
+ return star;
+ }
+ };
+
+ addField(fserverlListBox);
+
+ }
+
+ /**
+ * Get the SMTP server information from store information
+ *
+ * @return String []
+ */
+ public String[] getSmtpServer() {
+ String listServerStr = FStore
+ .getString(PreferenceConstants.FP_SMTP_SERVER_LIST_ID);
+ String[] star = listServerStr.split(fLIST_SEPARATOR);
+
+ return star;
+ }
+
+}

Back to the top