Commit 4ec27a83 authored by Bonita CI's avatar Bonita CI
Browse files

Merge branch 'master' into 'R2D2-7.2'

parents 4214020b 20e4007d
<?xml version="1.0" ?>
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<pubDate>2015-06-08</pubDate>
<pubDate>2016-01-07</pubDate>
<author>Bonitasoft</author>
<category>News</category>
<title>Bonitasoft latest blog posts</title>
......@@ -9,53 +9,53 @@
<description>Latest posts from the Bonitasoft blog</description>
<item>
<pubDate>2015-07-08</pubDate>
<pubDate>2016-01-05</pubDate>
<author>Miguel Valdés Faura</author>
<category>News</category>
<title>We’re a different kind of BPM company</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/were-different-kind-bpm-company</link>
<title>People to follow in 2016</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/people-follow-2016-blogs-twitter-and-linkedin</link>
<description></description>
</item>
<item>
<pubDate>2015-07-02</pubDate>
<author>Laura Balp</author>
</item>
<item>
<pubDate>2016-01-01</pubDate>
<author>Mickey Farrance</author>
<category>News</category>
<title>Bonita BPM 7.0.1 now available!</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/bonita-bpm-701-here</link>
<title>Happy 2016 from the Bonitasoft team!</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/happy-2016-bonitasoft-team</link>
<description></description>
</item>
<item>
<pubDate>2015-06-22</pubDate>
<author>Miguel Valdés Faura</author>
<item>
<pubDate>2015-12-15</pubDate>
<author>Mickey Farrance</author>
<category>News</category>
<title>Time to Set Developers Free</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/time-set-developers-free</link>
<title>CEO perspective</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/ceo-perspective-lessons-learned-launch-bonita-bpm-7</link>
<description></description>
</item>
<item>
<pubDate>2015-06-18</pubDate>
<author>Laura Balp</author>
<pubDate>2015-12-08</pubDate>
<author>Quauhtli Martínez</author>
<category>News</category>
<title>Bonita BPM 7.0.0 now available!</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/bonita-bpm-70-here</link>
<title>BPM for drones</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/bpm-drones-dronewares-view</link>
<description></description>
</item>
<item>
<pubDate>2015-06-16</pubDate>
<author>Miguel Valdés Faura</author>
<pubDate>2015-12-01</pubDate>
<author>Mickey Farrance</author>
<category>News</category>
<title>The benefits of creating "Living Applications"</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/benefits-creating-living-applications</link>
<title>EnerNOC: finalist, WfMC Global Awards</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/enernoc-finalist-wfmc-global-awards-excellence-bpm-workflow</link>
<description></description>
</item>
<item>
<pubDate>2015-06-01</pubDate>
<author>Miguel Valdés Faura</author>
<pubDate>2015-11-24</pubDate>
<author>Mickey Farrance</author>
<category>News</category>
<title>A new wave of customization</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/new-wave-customization</link>
<title>Amigolog offers Bonita BPM on the Cloud</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/blog/amigolog-offers-bonita-bpm-cloud</link>
<description></description>
</item>
</channel>
</rss>
\ No newline at end of file
</rss>
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<pubDate>2015-05-13</pubDate>
<pubDate>2015-12-07</pubDate>
<author>Bonitasoft</author>
<category>Community</category>
<title>Bonitasoft community</title>
......@@ -11,7 +11,7 @@
<author>Antoine Mottier</author>
<category>Community</category>
<title>Forums</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://community.bonitasoft.com/answers</link>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://community.bonitasoft.com/questions-and-answers</link>
<description></description>
</item>
<item>
......
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<pubDate>2015-05-13</pubDate>
<pubDate>2015-12-07</pubDate>
<author>Bonitasoft</author>
<category>Documentation</category>
<title>Bonitasoft Documentation</title>
......@@ -18,7 +18,7 @@
<author>Antoine Mottier</author>
<category>Documentation</category>
<title>Getting Started</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://documentation.bonitasoft.com/getting-started-0</link>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://documentation.bonitasoft.com/getting-started-tutorial-2</link>
<description></description>
</item>
<item>
......
......@@ -11,14 +11,14 @@
<author>Antoine Mottier</author>
<category>Examples</category>
<title>Expense report</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://community.bonitasoft.com/project?field_project_category_tid%3D360%26title%3D%26term_node_tid_depth%3D2241</link>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://community.bonitasoft.com/project/expense-report-example</link>
<description></description>
</item>
<item>
<author>Antoine Mottier</author>
<category>Examples</category>
<title>Vacation management</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://community.bonitasoft.com/project%3Ffield_project_category_tid%3D360%26title%3D%26term_node_tid_depth%3D2241</link>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://community.bonitasoft.com/project/vacation-management-example</link>
<description></description>
</item>
<item>
......
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<pubDate>2015-05-13</pubDate>
<pubDate>2015-05-18</pubDate>
<author>Bonitasoft</author>
<category>Training</category>
<title>Bonitasoft training</title>
<link>http://www.bonitasoft.com/how-we-do-it#how-we-do-it_training</link>
<link>http://www.bonitasoft.com/customer-success/training</link>
<description>Training feed from Bonitasoft</description>
<item>
<author>Antoine Mottier</author>
<category>Training</category>
<title>English</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/be-part-of-it/training%3Flanguage%3DEnglish</link>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/customer-success/training%3Flanguage%3DEnglish</link>
<description></description>
</item>
<item>
<author>Antoine Mottier</author>
<category>Training</category>
<title>Español</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/be-part-of-it/training%3Flanguage%3DSpanish</link>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/customer-success/training%3Flanguage%3DSpanish</link>
<description></description>
</item>
<item>
<author>Antoine Mottier</author>
<category>Training</category>
<title>Français</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/be-part-of-it/training%3Flanguage%3DFrench</link>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/customer-success/training%3Flanguage%3DFrench</link>
<description></description>
</item>
<item>
......
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<pubDate>2015-05-13</pubDate>
<pubDate>2016-01-07</pubDate>
<author>Bonitasoft</author>
<category>Videos</category>
<title>Bonitasoft community videos</title>
<title>Bonitasoft subscription videos</title>
<description>Videos from Bonitasoft</description>
<item>
<author>Antoine Mottier</author>
<category>Videos</category>
<title>Bonita BPM Camp</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/videos/bpm-camp-bonita-bpm-71</link>
<description></description>
</item>
<item>
<author>Antoine Mottier</author>
<category>Videos</category>
<title>Bonita BPM 7 Overview</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/videos</link>
<title>UI Designer deep dive</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/videos/bonita-bpm-7-ui-designer-technical-deep-dive</link>
<description></description>
</item>
<item>
<author>Antoine Mottier</author>
<category>Videos</category>
<title>Process Modeling with Bonita BPM</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/videos</link>
<title>Bonita BPM 7 UI Designer</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/videos/bonita-bpm-7-ui-designer-basics</link>
<description></description>
</item>
<item>
<author>Antoine Mottier</author>
<category>Videos</category>
<title>Manage business data efficiently</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/videos</link>
<title>Bonita BPM 7 Contract</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/videos/bonita-bpm-7-contract</link>
<description></description>
</item>
<item>
<author>Antoine Mottier</author>
<category>Videos</category>
<title>Keep your processes agile</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/videos</link>
<title>Manage business data efficiently</title>
<link>http://org.eclipse.ui.intro/runAction?pluginId=org.bonitasoft.studio.intro&amp;class=org.bonitasoft.studio.intro.actions.OpenInExternalBrowserIntroAction&amp;url=http://www.bonitasoft.com/for-you-to-read/videos/bonita-bpm-7-business-data-management</link>
<description></description>
</item>
</channel>
......
......@@ -244,4 +244,5 @@ unicityErrorMessage=\"{0}\" already exists.
validationFailureReservedKeywordsAPIREST=The following words cannot be used in Studio: content, API, theme
uiDesignerModuleName=UI Designer
pathDoesNotExist={0} does not exist.
invalidPath={0} has an invalid path.
\ No newline at end of file
invalidPath={0} has an invalid path.
moreDetails=More details
\ No newline at end of file
......@@ -282,5 +282,6 @@ public class Messages extends NLS {
public static String uiDesignerModuleName;
public static String invalidPath;
public static String pathDoesNotExist;
public static String moreDetails;
}
......@@ -14,30 +14,48 @@
*/
package org.bonitasoft.studio.common.properties;
import org.bonitasoft.studio.common.Messages;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.LineAttributes;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.FormToolkit;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
public class Well extends Composite {
private static final int ARC_SIZE = 15;
static Color infoSeprator = new Color(Display.getDefault(), 51, 102, 153);
static Color infoBackground = new Color(Display.getDefault(), 229, 245, 255);
static Color warningSeprator = new Color(Display.getDefault(), 255, 204, 51);
static Color warningSeprator = new Color(Display.getDefault(), 120, 110, 30);
static Color warningBackground = new Color(Display.getDefault(), 255, 255, 204);
static Color errorSeprator = new Color(Display.getDefault(), 204, 0, 0);
static Color errorBackground = new Color(Display.getDefault(), 255, 229, 229);
private final Label label;
private final Link label;
private Link moreInformationLink;
/**
* Display the given text in colored frame starting with a bold separator
......@@ -47,27 +65,122 @@ public class Well extends Composite {
* @param text
* @param toolkit
* @param severity
* @param help
*/
public Well(final Composite parent, final String text, final FormToolkit toolkit, final int severity) {
this(parent, text, null, toolkit, severity);
}
public Well(final Composite parent, final String text, final String moreDetails, final FormToolkit toolkit, final int severity) {
super(parent, SWT.NONE);
setLayout(GridLayoutFactory.fillDefaults().extendedMargins(10, 10, 5, 8).create());
setLayout(GridLayoutFactory.fillDefaults().extendedMargins(10, 10, 5, 8).spacing(0, 3).create());
addPaintListener(new PaintListener() {
@Override
public void paintControl(final PaintEvent e) {
e.gc.setForeground(separatorColor(toolkit, severity));
e.gc.setLineWidth(2);
e.gc.drawLine(5, -5, 5, e.height + 10);
final Control source = (Control) e.getSource();
final Rectangle bounds = source.getBounds();
final Rectangle borderBounds = new Rectangle(0, 0, bounds.width - 2, bounds.height - 2);
e.gc.setAntialias(SWT.ON);
e.gc.setBackground(backgroundColor(toolkit, severity));
e.gc.fillRectangle(6, -5, e.width, e.height + 10);
e.gc.fillRoundRectangle(0, 0, bounds.width - 1, bounds.height - 1, ARC_SIZE, ARC_SIZE);
e.gc.setForeground(separatorColor(toolkit, severity));
e.gc.setLineAttributes(new LineAttributes(1, SWT.CAP_ROUND, SWT.JOIN_ROUND));
e.gc.setLineWidth(1);
e.gc.drawRoundRectangle(0, 0, borderBounds.width, borderBounds.height, ARC_SIZE, ARC_SIZE);
}
});
label = toolkit.createLabel(this, text, SWT.WRAP);
label = new Link(this, SWT.WRAP);
label.setText(text);
label.setBackground(backgroundColor(toolkit, severity));
label.setForeground(separatorColor(toolkit, severity));
label.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, SWT.DEFAULT)
.create());
if (!Strings.isNullOrEmpty(moreDetails)) {
moreInformationLink = new Link(this, SWT.WRAP);
moreInformationLink.setText("<a>" + Messages.moreDetails + "</a>");
moreInformationLink.setBackground(backgroundColor(toolkit, severity));
moreInformationLink.setForeground(separatorColor(toolkit, severity));
moreInformationLink.setLayoutData(
GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.BOTTOM).grab(true, false).create());
final Shell tootltipShell = new Shell(getDisplay());
final org.eclipse.swt.widgets.ToolTip defaultToolTip = new org.eclipse.swt.widgets.ToolTip(tootltipShell, SWT.BALLOON | SWT.ICON_INFORMATION);
defaultToolTip.setMessage(moreDetails);
defaultToolTip.setAutoHide(false);
final Listener mouseUpFilter = mouseUpFilter(defaultToolTip);
moreInformationLink.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(final SelectionEvent e) {
if (!defaultToolTip.isVisible()) {
final Point point = moreInformationLink.toDisplay(moreInformationLink.getLocation());
final Rectangle location = moreInformationLink.getBounds();
defaultToolTip.setLocation(point.x - location.x + location.width, point.y - location.y + location.height);
defaultToolTip.setVisible(true);
getDisplay().addFilter(SWT.MouseUp, mouseUpFilter);
}
}
});
parent.addControlListener(new ControlAdapter() {
@Override
public void controlResized(final ControlEvent e) {
e.display.asyncExec(new Runnable() {
@Override
public void run() {
if (!Well.this.isDisposed()) {
Well.this.redraw();
}
defaultToolTip.setVisible(false);
getDisplay().removeFilter(SWT.MouseUp, mouseUpFilter);
}
});
defaultToolTip.setVisible(false);
getDisplay().removeFilter(SWT.MouseUp, mouseUpFilter);
}
@Override
public void controlMoved(final ControlEvent e) {
e.display.asyncExec(new Runnable() {
@Override
public void run() {
if (!Well.this.isDisposed()) {
Well.this.redraw();
}
defaultToolTip.setVisible(false);
getDisplay().removeFilter(SWT.MouseUp, mouseUpFilter);
}
});
}
});
}
}
private Listener mouseUpFilter(final org.eclipse.swt.widgets.ToolTip defaultToolTip) {
return new Listener() {
@Override
public void handleEvent(final Event event) {
if (!Objects.equal(event.widget, moreInformationLink)) {
defaultToolTip.setVisible(false);
getDisplay().removeFilter(SWT.MouseUp, this);
}
}
};
}
private Color separatorColor(final FormToolkit toolkit, final int style) {
......@@ -102,4 +215,8 @@ public class Well extends Composite {
return label.getText();
}
public void addSelectionListener(final SelectionListener listener) {
label.addSelectionListener(listener);
}
}
/**
* Copyright (C) 2015 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.connector.model.definition.wizard;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.connector.model.definition.Array;
import org.bonitasoft.studio.connector.model.definition.Input;
import org.bonitasoft.studio.connector.model.definition.ScriptEditor;
import org.bonitasoft.studio.connector.model.definition.TextArea;
import org.bonitasoft.studio.connector.model.definition.WidgetComponent;
import org.bonitasoft.studio.model.connectorconfiguration.ConnectorConfiguration;
import org.bonitasoft.studio.model.connectorconfiguration.ConnectorConfigurationFactory;
import org.bonitasoft.studio.model.connectorconfiguration.ConnectorParameter;
import org.bonitasoft.studio.model.expression.AbstractExpression;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionFactory;
import org.bonitasoft.studio.model.expression.ListExpression;
import org.bonitasoft.studio.model.expression.TableExpression;
public class ConnectorConfigurationSupport {
private final ConnectorConfiguration connectorConfiguration;
public ConnectorConfigurationSupport(ConnectorConfiguration connectorConfiguration) {
this.connectorConfiguration = connectorConfiguration;
}
public ConnectorParameter getConnectorParameter(final String inputName, final WidgetComponent object, final Input input) {
for (final ConnectorParameter param : connectorConfiguration.getParameters()) {
if (param.getKey().equals(inputName)) {
if (param.getExpression() == null) {
param.setExpression(createExpression(object, input));
} else {
if (param.getExpression() instanceof Expression) {
final Expression exp = (Expression) param.getExpression();
if (!exp.isReturnTypeFixed()) {
exp.setReturnTypeFixed(true);
}
final String type = input.getType();
if (type != null && !type.equals(exp.getReturnType())) {
exp.setReturnType(type);
}
}
}
return param;
}
}
final ConnectorParameter parameter = ConnectorConfigurationFactory.eINSTANCE.createConnectorParameter();
parameter.setKey(inputName);
parameter.setExpression(createExpression(object, input));
connectorConfiguration.getParameters().add(parameter);
return parameter;
}
public ConnectorParameter findConnectorParameter(final String inputName) {
for (final ConnectorParameter param : connectorConfiguration.getParameters()) {
if (param.getKey().equals(inputName)) {
return param;
}
}
return null;
}
private AbstractExpression createExpression(final WidgetComponent widget, final Input input) {
final String inputClassName = input.getType();
if (widget instanceof Array) {
final TableExpression expression = ExpressionFactory.eINSTANCE.createTableExpression();
return expression;
} else if (widget instanceof org.bonitasoft.studio.connector.model.definition.List) {
final ListExpression expression = ExpressionFactory.eINSTANCE.createListExpression();
return expression;