Commit 611693c3 authored by Romain Bioteau's avatar Romain Bioteau

Minor fixes

* Templating connector ui & wording
* Improve code completion in REST API extension editor
parent 28d451d4
......@@ -425,9 +425,7 @@ public class PageComponentSwitchBuilder {
} else {
viewer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
}
for (int i = 0; i < array.getCols().intValue(); i++) {
viewer.addFilter(connectorExpressionContentTypeFilter);
}
configureArrayColumnFilters(array, viewer);
if (input.isMandatory()) {
viewer.setMandatoryField(getLabel(array.getId()), context);
}
......@@ -465,6 +463,12 @@ public class PageComponentSwitchBuilder {
return null;
}
protected void configureArrayColumnFilters(final Array array, final ExpressionCollectionViewer viewer) {
for (int i = 0; i < array.getCols().intValue(); i++) {
viewer.addFilter(connectorExpressionContentTypeFilter);
}
}
public Section createGroupControl(final Composite composite, final Group object) {
final String desc = getDescription(object.getId());
int style = Section.NO_TITLE_FOCUS_BOX | Section.TWISTIE | Section.CLIENT_INDENT;
......
......@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Set;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.NamingUtils;
import org.bonitasoft.studio.common.jface.DataStyledTreeLabelProvider;
import org.bonitasoft.studio.common.jface.TableColumnSorter;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
......@@ -96,6 +97,10 @@ public class JavaExpressionEditor extends SelectionAwareExpressionEditor impleme
private boolean isPageFlowContext = false;
private MultiValidator validationStatusProvider;
private EMFDataBindingContext dataBindingContext;
@Override
public Control createExpressionEditor(final Composite parent, final EMFDataBindingContext ctx) {
mainComposite = new Composite(parent, SWT.NONE);
......@@ -245,7 +250,7 @@ public class JavaExpressionEditor extends SelectionAwareExpressionEditor impleme
public void bindExpression(final EMFDataBindingContext dataBindingContext, final EObject context, final Expression inputExpression,
final ViewerFilter[] filters,
final ExpressionViewer expressionViewer) {
this.dataBindingContext = dataBindingContext;
editorInputExpression = inputExpression;
setContentProvider(new PojoBrowserContentProvider());
javaTreeviewer.setContentProvider(getContentProvider());
......@@ -273,10 +278,11 @@ public class JavaExpressionEditor extends SelectionAwareExpressionEditor impleme
@Override
public Object convert(final Object data) {
if (data instanceof Data) {
return ((Data) data).getName() + " - " + ((JavaObjectData) data).getClassName() + "#" + editorInputExpression.getContent();
return ((Data) data).getName() + " - " + NamingUtils.getSimpleName(((JavaObjectData) data).getClassName()) + "#"
+ editorInputExpression.getContent();
} else if (data instanceof IMethod) {
final JavaObjectData data2 = (JavaObjectData) editorInputExpression.getReferencedElements().get(0);
return data2.getName() + " - " + data2.getClassName() + "#" + ((IMethod) data).getElementName();
return data2.getName() + " - " + NamingUtils.getSimpleName(data2.getClassName()) + "#" + ((IMethod) data).getElementName();
}
return null;
}
......@@ -396,13 +402,27 @@ public class JavaExpressionEditor extends SelectionAwareExpressionEditor impleme
dataBindingContext.bindValue(javaViewerSingleSelection, returnTypeObservable, selectionToReturnType,
new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
dataBindingContext.bindValue(SWTObservables.observeText(typeText, SWT.Modify), returnTypeObservable);
dataBindingContext.addValidationStatusProvider(new MultiValidator() {
validationStatusProvider = new MultiValidator() {
@Override
protected IStatus validate() {
return javaViewerSingleSelection.getValue() instanceof IMethod ? ValidationStatus.ok() : ValidationStatus.error("");
}
});
};
dataBindingContext.addValidationStatusProvider(validationStatusProvider);
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.expression.editor.provider.SelectionAwareExpressionEditor#dispose()
*/
@Override
public void dispose() {
if (validationStatusProvider != null) {
dataBindingContext.removeValidationStatusProvider(validationStatusProvider);
validationStatusProvider.dispose();
}
super.dispose();
}
private boolean acceptExpression(final ExpressionViewer viewer, final Expression e, final EObject context, final ViewerFilter[] filters) {
......
......@@ -28,6 +28,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
......@@ -53,6 +54,7 @@ public class CellExpressionViewer extends ExpressionViewer {
protected void createToolbar(final int style, final TabbedPropertySheetWidgetFactory widgetFactory) {
toolbar = new ToolBar(control, SWT.FLAT | SWT.NO_FOCUS);
toolbar.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).create());
toolbar.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
final ToolItem editControl = new ToolItem(toolbar, SWT.FLAT);
editControl.setImage(Pics.getImage(PicsConstants.edit));
editControl.setData(SWTBOT_WIDGET_ID_KEY, SWTBOT_ID_EDITBUTTON);
......
......@@ -325,13 +325,15 @@ public class EditExpressionDialog extends TrayDialog implements IBonitaVariableC
if (currentExpressionEditor != null) {
currentExpressionEditor.dispose();
}
if (dataBindingContext != null) {
dataBindingContext.dispose();
}
currentExpressionEditor = provider.getExpressionEditor(inputExpression, context);
currentExpressionEditor.setIsPageFlowContext(isPageFlowContext);
if (currentExpressionEditor != null) {
if (dataBindingContext != null) {
dataBindingContext.dispose();
}
// if (dataBindingContext != null) {
// dataBindingContext.dispose();
// }
dataBindingContext = new EMFDataBindingContext();
currentExpressionEditor.createExpressionEditor(contentComposite, dataBindingContext, isPassword);
contentComposite.layout(true, true);
......@@ -389,6 +391,9 @@ public class EditExpressionDialog extends TrayDialog implements IBonitaVariableC
if (getTray() != null) {
closeTray();
}
if (dataBindingContext != null) {
dataBindingContext.dispose();
}
if (currentExpressionEditor != null) {
currentExpressionEditor.dispose();
}
......
......@@ -15,6 +15,7 @@
package org.bonitasoft.studio.expression.editor.viewer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bonitasoft.studio.common.IBonitaVariableContext;
......@@ -134,6 +135,7 @@ public class ExpressionCollectionViewer implements IBonitaVariableContext {
private EMFDataBindingContext validationContext;
private String mandatoryLabel;
private Binding bindValue;
private final List<IAddLineListener> addLineLineListeners = new ArrayList<>();
public void setEditingDomain(final EditingDomain editingDomain) {
this.editingDomain = editingDomain;
......@@ -297,7 +299,8 @@ public class ExpressionCollectionViewer implements IBonitaVariableContext {
} else {
buttonComposite = new Composite(parent, SWT.NONE);
}
buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).align(SWT.FILL, SWT.TOP).create());
final int topIndent = captions.isEmpty() ? 0 : 15;
buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, false).align(SWT.FILL, SWT.TOP).indent(0, topIndent).create());
final RowLayout rl = new RowLayout(SWT.VERTICAL);
rl.spacing = 3;
......@@ -533,14 +536,22 @@ public class ExpressionCollectionViewer implements IBonitaVariableContext {
AbstractExpression newExpression = null;
if (expressionInput instanceof ListExpression) {
newExpression = addElementInListExpression(expressionInput);
fireLineAdded(Collections.<Expression> singletonList((Expression) newExpression));
} else if (expressionInput instanceof TableExpression) {
newExpression = addLineInTableExpression(expressionInput);
fireLineAdded(((ListExpression) newExpression).getExpressions());
}
refresh();
putCursorOnNewElement(colIndexToEdit, newExpression);
}
protected void fireLineAdded(List<Expression> expressions) {
for (final IAddLineListener listener : addLineLineListeners) {
listener.newLinedAdded(expressions);
}
}
private AbstractExpression addElementInListExpression(final Object expressionInput) {
AbstractExpression newExpression;
newExpression = ExpressionFactory.eINSTANCE.createExpression();
......@@ -548,8 +559,7 @@ public class ExpressionCollectionViewer implements IBonitaVariableContext {
return newExpression;
}
private AbstractExpression addLineInTableExpression(final Object expressionInput) {
AbstractExpression newExpression;
private ListExpression addLineInTableExpression(final Object expressionInput) {
final ListExpression rowExp = createListExpressionForNewLineInTable();
if (editingDomain == null) {
editingDomain = TransactionUtil.getEditingDomain(expressionInput);
......@@ -566,8 +576,8 @@ public class ExpressionCollectionViewer implements IBonitaVariableContext {
} else {
((TableExpression) expressionInput).getExpressions().add(rowExp);
}
newExpression = rowExp;
return newExpression;
return rowExp;
}
private ListExpression createListExpressionForNewLineInTable() {
......@@ -1192,4 +1202,8 @@ public class ExpressionCollectionViewer implements IBonitaVariableContext {
}
public void addLineListener(IAddLineListener listener) {
addLineLineListeners.add(listener);
}
}
......@@ -489,7 +489,7 @@ public class ExpressionViewer extends ContentViewer implements ExpressionConstan
if ((style & SWT.BORDER) != 0) {
indent = 16;
}
contentAssistText.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).indent(indent, 0)
contentAssistText.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).indent(indent, 0)
.grab(true, false).create());
}
......
/**
* Copyright (C) 2016 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.expression.editor.viewer;
import java.util.List;
import org.bonitasoft.studio.model.expression.Expression;
public interface IAddLineListener {
void newLinedAdded(List<Expression> expressions);
}
......@@ -7,7 +7,7 @@
point="org.codehaus.groovy.eclipse.ui.syntaxHighlightingExtension">
<highlightingExtender
extender="org.bonitasoft.studio.groovy.ui.contentassist.BonitaSyntaxHighlighting"
natureID="org.eclipse.jdt.groovy.core.groovyNature">
natureID="org.bonitasoft.studio.common.repository.bonitaNature">
</highlightingExtender>
</extension>
<extension
......@@ -84,10 +84,7 @@
<proposalFilter
proposalFilter="org.bonitasoft.studio.groovy.ui.contentassist.BonitaProposalFilter">
<appliesTo
projectNature="org.eclipse.jdt.groovy.core.groovyNature">
</appliesTo>
<appliesTo
projectNature="org.eclipse.jdt.core.javanature">
projectNature="org.bonitasoft.studio.common.repository.bonitaNature">
</appliesTo>
</proposalFilter>
</extension>
......@@ -123,7 +120,7 @@
</extension>
<extension point="org.eclipse.jdt.groovy.core.typeLookup">
<lookup lookup="org.bonitasoft.studio.groovy.ui.contentassist.BonitaConstantsTypeLookup">
<appliesTo projectNature="org.eclipse.jdt.groovy.core.groovyNature"/>
<appliesTo projectNature="org.bonitasoft.studio.common.repository.bonitaNature"/>
</lookup>
</extension>
......
......@@ -59,6 +59,9 @@ public class VariablesCompletionProposalProvider implements IJavaCompletionPropo
if (unit instanceof GroovyCompilationUnit) {
final ITextViewer viewer = context.getViewer();
final List<ScriptVariable> variables = getScriptVariables(viewer);
if (variables.isEmpty()) {
return list;
}
if (((GroovyCompilationUnit) unit).getModuleNode() == null) {
return Collections.emptyList();
}
......
......@@ -79,6 +79,9 @@ public class VariablesTypeCompletionProposal implements IJavaCompletionProposalC
if (unit instanceof GroovyCompilationUnit) {
final ITextViewer viewer = context.getViewer();
final List<ScriptVariable> scriptVariables = getScriptVariables(viewer);
if (scriptVariables.isEmpty()) {
return list;
}
if (((GroovyCompilationUnit) unit).getModuleNode() == null) {
return Collections.emptyList();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment