Commit ae5caebc authored by Romain Bioteau's avatar Romain Bioteau

update Form Mapping

parent 17b14dff
......@@ -17,7 +17,6 @@ package org.bonitasoft.studio.common.repository;
import javax.annotation.PostConstruct;
import javax.inject.Singleton;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Creatable;
/**
......@@ -30,7 +29,7 @@ public class RepositoryAccessor {
private RepositoryManager repositoryManagerInstance;
@PostConstruct
protected void init(final IEclipseContext context) {
public void init() {
repositoryManagerInstance = RepositoryManager.getInstance();
}
......
......@@ -57,6 +57,7 @@ Export-Package: org.bonitasoft.studio.common,
org.bonitasoft.studio.common.jface.databinding.observables,
org.bonitasoft.studio.common.jface.databinding.validator,
org.bonitasoft.studio.common.jface.dialog,
org.bonitasoft.studio.common.jface.selection,
org.bonitasoft.studio.common.log,
org.bonitasoft.studio.common.palette,
org.bonitasoft.studio.common.perspectives,
......
......@@ -12,7 +12,7 @@
* 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.pagedesigner.ui.property.section;
package org.bonitasoft.studio.common.jface.selection;
import java.util.ArrayList;
import java.util.List;
......
......@@ -5,22 +5,22 @@
* 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
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.connectors.expression;
import java.util.Collections;
import java.util.Set;
import javax.inject.Inject;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.connector.model.definition.ConnectorDefinition;
import org.bonitasoft.studio.connectors.repository.ConnectorDefRepositoryStore;
import org.bonitasoft.studio.expression.editor.provider.IExpressionEditor;
......@@ -32,82 +32,76 @@ import org.eclipse.swt.graphics.Image;
/**
* @author Florine Boudin
*
*/
public class ConnectorExpressionProvider implements IExpressionProvider {
private final ConnectorDefRepositoryStore store;
public ConnectorExpressionProvider(){
store = (ConnectorDefRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(ConnectorDefRepositoryStore.class);
}
@Override
public Set<Expression> getExpressions(EObject context) {
return Collections.emptySet();
}
private EObject getConnectorDefinition(EObject context) {
EObject definition = context ;
if(context != null){
while (definition != null && !(definition instanceof ConnectorDefinition)) {
if(definition instanceof Connector){
String defId = ((Connector) definition).getDefinitionId() ;
String defVersion = ((Connector) definition).getDefinitionVersion() ;
definition = store.getDefinition(defId, defVersion) ;
break ;
}
definition = definition.eContainer() ;
}
}
return definition;
}
@Override
public String getExpressionType() {
return ExpressionConstants.CONNECTOR_TYPE;
}
@Override
public Image getIcon(Expression expression) {
if(expression.getConnectors().isEmpty()){
return null ;
}
final Connector connector = expression.getConnectors().get(0);
final ConnectorDefinition def = (ConnectorDefinition) getConnectorDefinition(connector);
if(def != null){
return store.getResourceProvider().getDefinitionIcon(def);
}
return null;
}
@Override
public String getProposalLabel(Expression expression) {
return expression.getName() ;
}
@Override
public boolean isRelevantFor(EObject context) {
return false;
}
@Override
public Image getTypeIcon() {
return null;
}
@Override
public String getTypeLabel() {
return "";
}
@Override
public IExpressionEditor getExpressionEditor(Expression expression,EObject context) {
return null;
}
@Inject
private RepositoryAccessor repositoryAccessor;
@Override
public Set<Expression> getExpressions(final EObject context) {
return Collections.emptySet();
}
private EObject getConnectorDefinition(final EObject context) {
final ConnectorDefRepositoryStore store = repositoryAccessor.getRepositoryStore(ConnectorDefRepositoryStore.class);
EObject definition = context;
if (context != null) {
while (definition != null && !(definition instanceof ConnectorDefinition)) {
if (definition instanceof Connector) {
final String defId = ((Connector) definition).getDefinitionId();
final String defVersion = ((Connector) definition).getDefinitionVersion();
definition = store.getDefinition(defId, defVersion);
break;
}
definition = definition.eContainer();
}
}
return definition;
}
@Override
public String getExpressionType() {
return ExpressionConstants.CONNECTOR_TYPE;
}
@Override
public Image getIcon(final Expression expression) {
final ConnectorDefRepositoryStore store = repositoryAccessor.getRepositoryStore(ConnectorDefRepositoryStore.class);
if (expression.getConnectors().isEmpty()) {
return null;
}
final Connector connector = expression.getConnectors().get(0);
final ConnectorDefinition def = (ConnectorDefinition) getConnectorDefinition(connector);
if (def != null) {
return store.getResourceProvider().getDefinitionIcon(def);
}
return null;
}
@Override
public String getProposalLabel(final Expression expression) {
return expression.getName();
}
@Override
public boolean isRelevantFor(final EObject context) {
return false;
}
@Override
public Image getTypeIcon() {
return null;
}
@Override
public String getTypeLabel() {
return "";
}
@Override
public IExpressionEditor getExpressionEditor(final Expression expression, final EObject context) {
return null;
}
}
......@@ -31,7 +31,7 @@ Require-Bundle: org.eclipse.ui,
org.junit;bundle-version="4.11.0";resolution:=optional,
org.fest-assert;bundle-version="1.4.2";resolution:=optional,
org.mockito;bundle-version="1.9.5";resolution:=optional,
com.google.guava;bundle-version="15.0.0"
com.google.guava;bundle-version="11.0.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.diagram.custom; x-friends:="org.
......
......@@ -34,6 +34,7 @@ import org.bonitasoft.studio.common.extension.BonitaStudioExtensionRegistryManag
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.platform.tools.PlatformUtil;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.engine.i18n.Messages;
import org.bonitasoft.studio.pagedesigner.PageDesignerPlugin;
......@@ -248,12 +249,12 @@ public class BOSWebServerManager {
@Override
public void run() {
MessageDialog
.openInformation(
.openInformation(
PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getShell(),
"",
"Tomcat cannot be launched:\nthe port might be already used by another application.\nPossible causes are that another Studio or another Tomcat is already running.");
"",
"Tomcat cannot be launched:\nthe port might be already used by another application.\nPossible causes are that another Studio or another Tomcat is already running.");
}
});
......@@ -551,7 +552,9 @@ public class BOSWebServerManager {
addSystemProperty(args, "eclipse.product", Platform.getProduct()
.getApplication());
final WorkspaceSystemProperties workspaceSystemProperties = new WorkspaceSystemProperties();
final RepositoryAccessor repositoryAccessor = new RepositoryAccessor();
repositoryAccessor.init();
final WorkspaceSystemProperties workspaceSystemProperties = new WorkspaceSystemProperties(repositoryAccessor);
addSystemProperty(args, workspaceSystemProperties.getPageRepositoryLocation());
addSystemProperty(args, workspaceSystemProperties.getWidgetRepositoryLocation());
addSystemProperty(args, workspaceSystemProperties.getFragmentRepositoryLocation());
......
......@@ -49,7 +49,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.mockito;bundle-version="1.9.5";resolution:=optional,
org.bonitasoft.studio.tests-utils;bundle-version="6.4.0";resolution:=optional,
org.bonitasoft.studio.document,
com.google.guava;bundle-version="15.0.0"
com.google.guava;bundle-version="11.0.1"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.bonitasoft.studio.exporter.Activator
Import-Package: org.bonitasoft.engine.bpm,
......
......@@ -51,7 +51,8 @@ Require-Bundle: org.eclipse.ui,
org.bonitasoft.studio.tests-utils;bundle-version="6.4.0";resolution:=optional,
org.eclipse.e4.core.contexts,
org.eclipse.e4.core.di;bundle-version="1.4.0",
org.eclipse.e4.ui.model.workbench;bundle-version="1.1.0.v20140512-1820"
org.eclipse.e4.ui.model.workbench;bundle-version="1.1.0.v20140512-1820",
org.eclipse.e4.ui.workbench;bundle-version="1.2.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.bonitasoft.engine.bpm.document,
org.bonitasoft.engine.expression
......
......@@ -27,9 +27,12 @@ import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.process.SearchIndex;
import org.bonitasoft.studio.model.process.SequenceFlow;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.InvalidRegistryObjectException;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.di.InjectionException;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.bindings.keys.KeyStroke;
......@@ -71,6 +74,8 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.Workbench;
/**
* ContentProposalAdapter can be used to attach content proposal behavior to a
......@@ -730,8 +735,11 @@ public class BonitaContentProposalAdapter implements SWTBotConstants {
createDataLink = new Link(creationZoneComposite, SWT.NONE);
final String name = element.getAttribute("name");
createDataLink.setText(name);
final Workbench workbench = (Workbench) PlatformUI.getWorkbench();
try {
final IProposalListener listener = (IProposalListener) element.createExecutableExtension("providerClass");
final IProposalListener listener = (IProposalListener) ContextInjectionFactory.make(Platform.getBundle(
element.getDeclaringExtension().getNamespaceIdentifier()).loadClass(
element.getAttribute("providerClass")), workbench.getContext());
createDataLink.addSelectionListener(new SelectionAdapter() {
@Override
......@@ -742,8 +750,12 @@ public class BonitaContentProposalAdapter implements SWTBotConstants {
}
});
} catch (final CoreException e) {
BonitaStudioLog.error(e);
} catch (final InjectionException e1) {
BonitaStudioLog.error(e1);
} catch (final ClassNotFoundException e1) {
BonitaStudioLog.error(e1);
} catch (final InvalidRegistryObjectException e1) {
BonitaStudioLog.error(e1);
}
linkList.add(createDataLink);
}
......
......@@ -14,6 +14,7 @@
*/
package org.bonitasoft.studio.expression.editor.autocompletion;
import org.assertj.core.util.Strings;
import org.bonitasoft.studio.model.expression.Expression;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.fieldassist.IContentProposal;
......@@ -34,7 +35,8 @@ public class ExpressionProposal implements IContentProposal {
this.expression = expression;
content = labelProvider.getContent(expression);
description = labelProvider.getDescription(expression);
label = String.format("%s -- %s", labelProvider.getText(expression), description);
label = Strings.isNullOrEmpty(description) ? labelProvider.getText(expression) : String.format("%s -- %s", labelProvider.getText(expression),
description);
}
/*
......
......@@ -5,14 +5,12 @@
* 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
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.expression.editor.provider;
......@@ -22,17 +20,18 @@ import org.bonitasoft.studio.model.expression.Expression;
/**
* @author Romain Bioteau
*
*/
public class ExpressionComparator implements Comparator<Expression> {
@Override
public int compare(Expression exp0, Expression exp1) {
if(exp0.getType().equals(exp1.getType()) && exp0.getName() != null && exp1.getName() != null){
return exp0.getName().compareTo(exp1.getName()) ;
}
return exp0.getType().compareTo(exp1.getType());
}
@Override
public int compare(final Expression exp0, final Expression exp1) {
if (exp0.getType().equals(exp1.getType())) {
if (exp0.hasName() && exp1.hasName() && !exp0.getName().equals(exp1.getName())) {
return exp0.getName().compareTo(exp1.getName());
} else if (exp0.hasContent() && exp1.hasContent() && !exp0.getContent().equals(exp1.getContent())) {
return exp0.getContent().compareTo(exp1.getContent());
}
}
return exp0.getType().compareTo(exp1.getType());
}
}
......@@ -5,116 +5,80 @@
* 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
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.expression.editor.provider;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.expression.editor.ExpressionEditorService;
import org.bonitasoft.studio.expression.editor.autocompletion.ExpressionProposal;
import org.bonitasoft.studio.expression.editor.autocompletion.IExpressionProposalLabelProvider;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.TableExpression;
import org.bonitasoft.studio.model.process.AbstractCatchMessageEvent;
import org.bonitasoft.studio.model.process.AbstractProcess;
import org.bonitasoft.studio.model.process.CatchMessageEvent;
import org.bonitasoft.studio.model.process.FlowElement;
import org.bonitasoft.studio.model.process.Message;
import org.bonitasoft.studio.model.process.MessageFlow;
import org.bonitasoft.studio.model.process.ThrowMessageEvent;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.eclipse.emf.common.util.EList;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
/**
* @author Romain Bioteau
*
*/
public class ExpressionLabelProvider extends LabelProvider implements IExpressionProposalLabelProvider {
@Override
public Image getImage(Object expression) {
if (expression instanceof ExpressionProposal) {
expression = ((ExpressionProposal) expression).getExpression();
}
if (expression instanceof Expression) {
for (final IExpressionProvider provider : ExpressionEditorService.getInstance().getExpressionProviders()) {
if (provider.getExpressionType().equals(((Expression) expression).getType())) {
return provider.getIcon((Expression) expression);
}
}
if (ExpressionConstants.CONSTANT_TYPE.equals(((Expression) expression).getType()) && ((Expression) expression).getContent() != null
&& !((Expression) expression).getContent().isEmpty()) {
return Pics.getImage(PicsConstants.constant);
}
@Override
public Image getImage(Object expression) {
if(expression instanceof ExpressionProposal){
expression = ((ExpressionProposal) expression).getExpression() ;
}
if(expression instanceof Expression){
for(IExpressionProvider provider : ExpressionEditorService.getInstance().getExpressionProviders()){
if(provider.getExpressionType().equals(((Expression) expression).getType())){
return provider.getIcon((Expression) expression) ;
}
}
if(ExpressionConstants.CONSTANT_TYPE.equals(((Expression) expression).getType()) && ((Expression) expression).getContent() != null && !((Expression) expression).getContent().isEmpty()){
return Pics.getImage(PicsConstants.constant) ;
}
}
return super.getImage(expression);
}
}
return super.getImage(expression) ;
}
@Override
public String getText(Object expression) {
if (expression instanceof ExpressionProposal) {
expression = ((ExpressionProposal) expression).getExpression();
}
if (expression instanceof Expression) {
for (final IExpressionProvider provider : ExpressionEditorService.getInstance().getExpressionProviders()) {
if (provider.getExpressionType().equals(((Expression) expression).getType())) {
return provider.getProposalLabel((Expression) expression);
}
}
if (ExpressionConstants.CONSTANT_TYPE.equals(((Expression) expression).getType()) && !((Expression) expression).getContent().isEmpty()) {
return ((Expression) expression).getName();
}
@Override
public String getText(Object expression) {
if(expression instanceof ExpressionProposal){
expression = ((ExpressionProposal) expression).getExpression() ;
}
if(expression instanceof Expression){
for(IExpressionProvider provider : ExpressionEditorService.getInstance().getExpressionProviders()){
if(provider.getExpressionType().equals(((Expression) expression).getType())){
return provider.getProposalLabel((Expression) expression) ;
}
}
if(ExpressionConstants.CONSTANT_TYPE.equals(((Expression) expression).getType()) && !((Expression) expression).getContent().isEmpty()){
return ((Expression) expression).getName() ;
}
}
return super.getText(expression);
}
}
return super.getText(expression) ;
}
@Override
public String getDescription(final Expression expression) {
if (ExpressionConstants.MESSAGE_ID_TYPE.equals(expression.getType())) {
return "";
}
return expression.getReturnType();
}
@Override
public String getDescription(Expression expression) {
if(ExpressionConstants.MESSAGE_ID_TYPE.equals(expression.getType())){
// final FlowElement parentFlowElement = ModelHelper.getParentFlowElement(expression);
// final AbstractProcess parentProcess = ModelHelper.getParentProcess(expression);
// if(parentFlowElement instanceof AbstractCatchMessageEvent){
// MessageFlow incomingMessag = ((AbstractCatchMessageEvent) parentFlowElement).getIncomingMessag();
// if(incomingMessag != null){
// final ThrowMessageEvent source = incomingMessag.getSource();
// EList<Message> events = source.getEvents();
// for (Message message : events) {
// Expression targetProcessExpression = message.getTargetProcessExpression();
// if(ExpressionConstants.CONSTANT_TYPE.equals(targetProcessExpression.getType())){
// if(parentProcess.getName().equals(targetProcessExpression.getContent())){
// Expression targetElementExpression = message.getTargetElementExpression();
// if(ExpressionConstants.CONSTANT_TYPE.equals(targetElementExpression.getType())){
// if(parentFlowElement.getName().equals(targetElementExpression.getContent())){
// //TableExpression messageContent = message.getMessageContent();
// //TODO: implement return type for message content
// }
// }
// }
// }
// }
// }
// }
return "";
}
return expression.getReturnType();
}
@Override
public String getContent(Expression expression) {
return expression.getContent();