Commit 0d7cdc9e authored by Adrien's avatar Adrien

merge master into dev

parents 93d193e1 6f59766f
package org.bonitasoft.studio.actors.operation;
import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.studio.actors.model.organization.Organization;
import org.bonitasoft.studio.actors.model.organization.OrganizationFactory;
import org.bonitasoft.studio.actors.model.organization.PasswordType;
import org.bonitasoft.studio.actors.model.organization.User;
import org.junit.Test;
public class CleanPublishOrganizationOperationTest {
@Test
public void should_export_default_attribute_in_xml() throws Exception {
Organization organization = OrganizationFactory.eINSTANCE.createOrganization();
User user = OrganizationFactory.eINSTANCE.createUser();
PasswordType passwordType = OrganizationFactory.eINSTANCE.createPasswordType();
passwordType.setValue("testbpm");
user.setPassword(passwordType);
organization.setUsers( OrganizationFactory.eINSTANCE.createUsers());
organization.getUsers().getUser().add(user);
String xml = new CleanPublishOrganizationOperation(organization).toString(organization);
assertThat(xml).contains("<password encrypted=\"true\">testbpm</password>");
}
}
package org.bonitasoft.studio.actors.operation;
import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.studio.actors.model.organization.Organization;
import org.bonitasoft.studio.actors.model.organization.OrganizationFactory;
import org.bonitasoft.studio.actors.model.organization.PasswordType;
import org.bonitasoft.studio.actors.model.organization.User;
import org.junit.Test;
public class CleanPublishOrganizationOperationTest {
@Test
public void should_export_default_attribute_in_xml() throws Exception {
Organization organization = OrganizationFactory.eINSTANCE.createOrganization();
User user = OrganizationFactory.eINSTANCE.createUser();
PasswordType passwordType = OrganizationFactory.eINSTANCE.createPasswordType();
passwordType.setValue("testbpm");
user.setPassword(passwordType);
organization.setUsers( OrganizationFactory.eINSTANCE.createUsers());
organization.getUsers().getUser().add(user);
String xml = new CleanPublishOrganizationOperation(organization).toString(organization);
assertThat(xml).contains("<password encrypted=\"true\">testbpm</password>");
}
}
/**
* Copyright (C) 2014 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.contract.ui.expression;
import org.bonitasoft.studio.common.jface.TableColumnSorter;
import org.bonitasoft.studio.contract.i18n.Messages;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableColumn;
/**
* @author Romain Bioteau
*/
public class ContractInputTableViewer extends TableViewer {
public ContractInputTableViewer(final Composite parent, final int style) {
super(parent, style);
}
public void initialize() {
final TableLayout layout = new TableLayout();
layout.addColumnData(new ColumnWeightData(100, false));
getTable().setLayout(layout);
getTable().setHeaderVisible(true);
final TableViewerColumn columnViewer = new TableViewerColumn(this, SWT.NONE);
final TableColumn column = columnViewer.getColumn();
column.setText(Messages.name);
columnViewer.setLabelProvider(new ContractInputLabelProvider());
final TableColumnSorter sorter = new TableColumnSorter(this);
sorter.setColumn(column);
setContentProvider(ArrayContentProvider.getInstance());
}
}
/**
* Copyright (C) 2014 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.contract.ui.expression;
import org.bonitasoft.studio.common.jface.TableColumnSorter;
import org.bonitasoft.studio.contract.i18n.Messages;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableColumn;
/**
* @author Romain Bioteau
*/
public class ContractInputTableViewer extends TableViewer {
public ContractInputTableViewer(final Composite parent, final int style) {
super(parent, style);
}
public void initialize() {
final TableLayout layout = new TableLayout();
layout.addColumnData(new ColumnWeightData(100, false));
getTable().setLayout(layout);
getTable().setHeaderVisible(true);
final TableViewerColumn columnViewer = new TableViewerColumn(this, SWT.NONE);
final TableColumn column = columnViewer.getColumn();
column.setText(Messages.name);
columnViewer.setLabelProvider(new ContractInputLabelProvider());
final TableColumnSorter sorter = new TableColumnSorter(this);
sorter.setColumn(column);
setContentProvider(ArrayContentProvider.getInstance());
}
}
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 31 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.expression.editor.provider;
import java.util.ArrayList;
import java.util.List;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.expression.editor.ExpressionEditorPlugin;
import org.bonitasoft.studio.expression.editor.filter.ExpressionReturnTypeFilter;
import org.bonitasoft.studio.model.expression.Expression;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.jface.dialogs.DialogTray;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
/**
* @author Romain Bioteau
*/
public abstract class SelectionAwareExpressionEditor implements IExpressionEditor {
private final List<Listener> listeners = new ArrayList<Listener>();
private boolean isPageFlowContext;
private boolean isOverviewContext;
@Override
public void addListener(final Listener listener) {
listeners.add(listener);
}
@Override
public void dispose() {
listeners.clear();
}
protected void fireSelectionChanged() {
for (final Listener l : listeners) {
l.handleEvent(new Event());
}
}
@Override
public List<Listener> getListeners() {
return listeners;
}
@Override
public boolean provideDialogTray() {
return false;
}
@Override
public DialogTray createDialogTray() {
return null;
}
@Override
public IObservable getContentObservable() {
return null;
}
@Override
public Control createExpressionEditor(final Composite contentComposite, final EMFDataBindingContext ctx,
final boolean isPassword) {
return createExpressionEditor(contentComposite, ctx);
}
protected boolean compatibleReturnType(final Expression inputExpression, final Expression e) {
final RepositoryAccessor repositoryAccessor = new RepositoryAccessor();
repositoryAccessor.init();
final ExpressionReturnTypeFilter expressionReturnTypeFilter = new ExpressionReturnTypeFilter(repositoryAccessor);
final String currentReturnType = inputExpression.getReturnType();
final String expressionReturnType = e.getReturnType();
if (currentReturnType.equals(expressionReturnType)) {
return true;
}
try {
final Class<?> currentReturnTypeClass = Class.forName(currentReturnType);
final Class<?> expressionReturnTypeClass = Class.forName(expressionReturnType);
return currentReturnTypeClass.isAssignableFrom(expressionReturnTypeClass);
} catch (final Exception ex) {
BonitaStudioLog.debug("Failed to determine the compatibility between " + expressionReturnType + " and " + currentReturnType,
ExpressionEditorPlugin.PLUGIN_ID);
}
return expressionReturnTypeFilter.compatibleReturnTypes(currentReturnType, expressionReturnType);
}
@Override
public boolean isPageFlowContext() {
return isPageFlowContext;
}
@Override
public void setIsPageFlowContext(final boolean isPageFlowContext) {
this.isPageFlowContext = isPageFlowContext;
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.IBonitaVariableContext#isOverViewContext()
*/
@Override
public boolean isOverViewContext() {
return isOverviewContext;
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.IBonitaVariableContext#setIsOverviewContext(boolean)
*/
@Override
public void setIsOverviewContext(final boolean isOverviewContext) {
this.isOverviewContext = isOverviewContext;
}
@Override
public void okPressed() {
//Implement behavior in subclasses
}
@Override
public Control getTextControl() {
//No text control by default
return null;
}
}
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 31 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.expression.editor.provider;
import java.util.ArrayList;
import java.util.List;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.expression.editor.ExpressionEditorPlugin;
import org.bonitasoft.studio.expression.editor.filter.ExpressionReturnTypeFilter;
import org.bonitasoft.studio.model.expression.Expression;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.jface.dialogs.DialogTray;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
/**
* @author Romain Bioteau
*/
public abstract class SelectionAwareExpressionEditor implements IExpressionEditor {
private final List<Listener> listeners = new ArrayList<Listener>();
private boolean isPageFlowContext;
private boolean isOverviewContext;
@Override
public void addListener(final Listener listener) {
listeners.add(listener);
}
@Override
public void dispose() {
listeners.clear();
}
protected void fireSelectionChanged() {
for (final Listener l : listeners) {
l.handleEvent(new Event());
}
}
@Override
public List<Listener> getListeners() {
return listeners;
}
@Override
public boolean provideDialogTray() {
return false;
}
@Override
public DialogTray createDialogTray() {
return null;
}
@Override
public IObservable getContentObservable() {
return null;
}
@Override
public Control createExpressionEditor(final Composite contentComposite, final EMFDataBindingContext ctx,
final boolean isPassword) {
return createExpressionEditor(contentComposite, ctx);
}
protected boolean compatibleReturnType(final Expression inputExpression, final Expression e) {
final RepositoryAccessor repositoryAccessor = new RepositoryAccessor();
repositoryAccessor.init();
final ExpressionReturnTypeFilter expressionReturnTypeFilter = new ExpressionReturnTypeFilter(repositoryAccessor);
final String currentReturnType = inputExpression.getReturnType();
final String expressionReturnType = e.getReturnType();
if (currentReturnType.equals(expressionReturnType)) {
return true;
}
try {
final Class<?> currentReturnTypeClass = Class.forName(currentReturnType);
final Class<?> expressionReturnTypeClass = Class.forName(expressionReturnType);
return currentReturnTypeClass.isAssignableFrom(expressionReturnTypeClass);
} catch (final Exception ex) {
BonitaStudioLog.debug("Failed to determine the compatibility between " + expressionReturnType + " and " + currentReturnType,
ExpressionEditorPlugin.PLUGIN_ID);
}
return expressionReturnTypeFilter.compatibleReturnTypes(currentReturnType, expressionReturnType);
}
@Override
public boolean isPageFlowContext() {
return isPageFlowContext;
}
@Override
public void setIsPageFlowContext(final boolean isPageFlowContext) {
this.isPageFlowContext = isPageFlowContext;
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.IBonitaVariableContext#isOverViewContext()
*/
@Override
public boolean isOverViewContext() {
return isOverviewContext;
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.IBonitaVariableContext#setIsOverviewContext(boolean)
*/
@Override
public void setIsOverviewContext(final boolean isOverviewContext) {
this.isOverviewContext = isOverviewContext;
}
@Override
public void okPressed() {
//Implement behavior in subclasses
}
@Override
public Control getTextControl() {
//No text control by default
return null;
}
}
/**
* Copyright (C) 2014 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.intro.actions;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Properties;
import org.bonitasoft.studio.common.ProductVersion;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.preferences.browser.OpenBrowserOperation;
import org.eclipse.ui.intro.IIntroSite;
import org.eclipse.ui.intro.config.IIntroAction;
/**
* @author Aurelien Pupier
*/
public class SearchDocumentationInExternalBrowser implements IIntroAction {
private final static String SEARCH_DOC_URL = String.format(
"http://www.bonitasoft.com/bos_redirect.php?bos_redirect_id=668&bos_redirect_product=bos&bos_redirect_major_version=%s&bos_redirect_minor_version=0",
ProductVersion.majorVersion());
@Override
public void run(final IIntroSite arg0, final Properties params) {
final String urlToOpen = calculateURLToOpen(params);
openInExternalBrowser(urlToOpen);
}
private void openInExternalBrowser(final String urlToOpen) {
try {
final URL url = new URL(urlToOpen);
new OpenBrowserOperation(url).execute();
} catch (final MalformedURLException e) {
BonitaStudioLog.error(e);
}
}
private String calculateURLToOpen(final Properties params) {
String searchField = "";
try {
searchField = URLEncoder.encode(params.getProperty("keys"), "UTF-8");
} catch (final UnsupportedEncodingException e) {
BonitaStudioLog.error(e);
}
return SEARCH_DOC_URL + "&start=0&pageSize=10&searchRequest=" + searchField;
}
}
/**
* Copyright (C) 2014 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.intro.actions;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Properties;
import org.bonitasoft.studio.common.ProductVersion;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.preferences.browser.OpenBrowserOperation;
import org.eclipse.ui.intro.IIntroSite;
import org.eclipse.ui.intro.config.IIntroAction;
/**
* @author Aurelien Pupier
*/
public class SearchDocumentationInExternalBrowser implements IIntroAction {
private final static String SEARCH_DOC_URL = String.format(
"http://www.bonitasoft.com/bos_redirect.php?bos_redirect_id=668&bos_redirect_product=bos&bos_redirect_major_version=%s&bos_redirect_minor_version=0",
ProductVersion.majorVersion());
@Override
public void run(final IIntroSite arg0, final Properties params) {
final String urlToOpen = calculateURLToOpen(params);
openInExternalBrowser(urlToOpen);
}
private void openInExternalBrowser(final String urlToOpen) {
try {
final URL url = new URL(urlToOpen);
new OpenBrowserOperation(url).execute();
} catch (final MalformedURLException e) {
BonitaStudioLog.error(e);
}
}
private String calculateURLToOpen(final Properties params) {
String searchField = "";
try {
searchField = URLEncoder.encode(params.getProperty("keys"), "UTF-8");
} catch (final UnsupportedEncodingException e) {
BonitaStudioLog.error(e);
}
return SEARCH_DOC_URL + "&start=0&pageSize=10&searchRequest=" + searchField;
}
}
package org.eclipse.emf.edapt.internal.migration.internal;
import java.util.List;
import org.eclipse.emf.edapt.spi.migration.Instance;
/**
* Helper methods for migration.
*
* @author herrmi
* @author $Author: hummelb $
* @version $Rev: 18709 $
* @levd.rating RED Rev:
*/
public final class MigrationUtils {
/** Constructor. */
private MigrationUtils() {
// hidden, since this class only provides static helper methods
}
/**
* Choose a value from a list of values for a context element based on a
* message.
*/
public static <V> V choose(Instance context, List<V> values, String message) {
return MigratorOptions.getInstance().getOracle()
.choose(context, values, message);
}
/** Debug the migration for a context element based on a message. */
public static void debug(Instance context, String message) {
MigratorOptions.getInstance().getDebugger().debug(context, message);
}
}
package org.eclipse.emf.edapt.internal.migration.internal;
import java.util.List;