Commit ebc46c4f authored by Romain Bioteau's avatar Romain Bioteau
Browse files

BS-10726

Integrate new groovy definition
parent 7e407d5e
......@@ -443,8 +443,7 @@ public class PageComponentSwitchBuilder {
if (parameter != null) {
createFieldLabel(composite, SWT.CENTER, object.getId(), input.isMandatory());
final ExpressionViewer viewer = new GroovyOnlyExpressionViewer(composite, SWT.BORDER,
ConnectorConfigurationPackage.Literals.CONNECTOR_PARAMETER__EXPRESSION);
final ExpressionViewer viewer = new GroovyOnlyExpressionViewer(composite, SWT.BORDER | SWT.SHORT);
viewer.setIsPageFlowContext(isPageFlowContext);
viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
viewer.setContext(container);
......
......@@ -215,4 +215,16 @@
name="DBConnectors">
</page>
</extension>
<extension
point="org.bonitasoft.studio.connectors.connectorWizard">
<connectorWizard
DefinitionId="scripting-groovy-script"
priority="1"
useDefaultGeneratedPages="false"
useDefaultOutputPage="true">
<configurationPage
page="org.bonitasoft.studio.connectors.ui.wizard.custom.GroovyScriptConfigurationWizardPage">
</configurationPage>
</connectorWizard>
</extension>
</plugin>
......@@ -400,6 +400,13 @@
<classifier>connector</classifier>
<type>zip</type>
</artifactItem>
<artifactItem>
<groupId>org.bonitasoft.connectors</groupId>
<artifactId>bonita-connector-scripting-groovy-script-impl</artifactId>
<version>1.0.0</version>
<classifier>connector</classifier>
<type>zip</type>
</artifactItem>
<artifactItem>
<groupId>org.bonitasoft.connectors</groupId>
<artifactId>bonita-connector-scripting-shell-impl</artifactId>
......
......@@ -83,8 +83,7 @@ public class GroovyScriptConfigurationWizardPage extends AbstractConnectorConfig
final ConnectorParameter dependenciesParameter = getConnectorParameter(getInput(DEPENDENCIES_INPUT_NAME));
final ConnectorParameter parameter = buildScriptConnectorParameter();
builder.createFieldLabel(composite, SWT.CENTER, SCRIPT_INPUT_NAME, true);
final ExpressionViewer viewer = new GroovyOnlyExpressionViewer(composite, SWT.BORDER,
ConnectorConfigurationPackage.Literals.CONNECTOR_PARAMETER__EXPRESSION);
final ExpressionViewer viewer = new GroovyOnlyExpressionViewer(composite, SWT.BORDER);
viewer.setIsPageFlowContext(isPageFlowContext());
viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
viewer.setContext(getElementContainer());
......
......@@ -68,7 +68,7 @@ public class DocumentWizardPageTest {
doReturn(expressionViewerMock).when(documentWizardPageUnderTest).createExpressionViewer(Mockito.any(Composite.class), Mockito.any(EReference.class));
when(groovyOnlyExpressionViewerMock.getControl()).thenReturn(mock(Control.class));
doReturn(groovyOnlyExpressionViewerMock).when(documentWizardPageUnderTest).createExpressionViewerWitrhGroovyScriptOnly(Mockito.any(Composite.class));
doReturn(groovyOnlyExpressionViewerMock).when(documentWizardPageUnderTest).createExpressionViewerWithGroovyScriptOnly(Mockito.any(Composite.class));
}
......@@ -99,7 +99,7 @@ public class DocumentWizardPageTest {
@Test
public void should_createDocumentInitialMultipleContent_should_create_ExpressionViwer_with_filter_accepting_only_Groovy_script() throws Exception {
documentWizardPageUnderTest.createDocumentInitialMultipleContent(mock(Composite.class));
verify(documentWizardPageUnderTest).createExpressionViewerWitrhGroovyScriptOnly(Mockito.any(Composite.class));
verify(documentWizardPageUnderTest).createExpressionViewerWithGroovyScriptOnly(Mockito.any(Composite.class));
}
}
......@@ -259,9 +259,8 @@ public class DocumentWizardPage extends WizardPage {
return new ExpressionViewer(parent, SWT.BORDER);
}
protected GroovyOnlyExpressionViewer createExpressionViewerWitrhGroovyScriptOnly(final Composite parent) {
return new GroovyOnlyExpressionViewer(parent, SWT.READ_ONLY | SWT.BORDER,
ProcessPackage.Literals.DOCUMENT__INITIAL_MULTIPLE_CONTENT);
protected GroovyOnlyExpressionViewer createExpressionViewerWithGroovyScriptOnly(final Composite parent) {
return new GroovyOnlyExpressionViewer(parent, SWT.READ_ONLY | SWT.BORDER);
}
private void createDocumentManageMimeTypeLink(final Composite detailsComposite) {
......@@ -408,7 +407,7 @@ public class DocumentWizardPage extends WizardPage {
}
protected void createDocumentInitialMultipleContent(final Composite parent) {
multipleInitialContentExpressionViewer = createExpressionViewerWitrhGroovyScriptOnly(parent);
multipleInitialContentExpressionViewer = createExpressionViewerWithGroovyScriptOnly(parent);
multipleInitialContentExpressionViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
multipleInitialContentExpressionViewer.setInput(document);
}
......
......@@ -30,16 +30,17 @@ import org.eclipse.swt.widgets.Shell;
*/
public class GroovyOnlyEditExpressionDialog extends EditExpressionDialog {
protected GroovyOnlyEditExpressionDialog(Shell parentShell,boolean isPassword, Expression inputExpression,EObject context,EditingDomain domain, ViewerFilter[] viewerTypeFilters,ExpressionViewer expressionViewer) {
protected GroovyOnlyEditExpressionDialog(final Shell parentShell, final boolean isPassword, final Expression inputExpression, final EObject context,
final EditingDomain domain, final ViewerFilter[] viewerTypeFilters, final ExpressionViewer expressionViewer) {
super(parentShell,isPassword,inputExpression,context,domain,viewerTypeFilters,expressionViewer);
this.inputExpression.setType(ExpressionConstants.SCRIPT_TYPE) ;
}
@Override
protected void createExpressionTypePanel(Composite parentForm) {
@Override
protected void createExpressionTypePanel(final Composite parentForm) {
//DO NOT CREATE EXPRESSION TYPE PANEL
}
@Override
public void create() {
super.create();
......
......@@ -18,7 +18,6 @@ package org.bonitasoft.studio.expression.editor.viewer;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.widgets.Composite;
......@@ -29,16 +28,18 @@ import org.eclipse.swt.widgets.Composite;
*/
public class GroovyOnlyExpressionViewer extends ExpressionViewer {
public GroovyOnlyExpressionViewer(final Composite composite, final int style,final EReference expressionReference) {
super(composite, style, expressionReference);
public GroovyOnlyExpressionViewer(final Composite composite, final int style) {
super(composite, style);
getContentAssistText().getToolbar().getItem(0).setEnabled(false);
}
@Override
protected EditExpressionDialog createEditDialog(final EObject editInput) {
return new GroovyOnlyEditExpressionDialog(control.getShell(), isPassword, EcoreUtil.copy(getSelectedExpression()), editInput, getEditingDomain(),
final GroovyOnlyEditExpressionDialog groovyOnlyEditExpressionDialog = new GroovyOnlyEditExpressionDialog(control.getShell(), isPassword,
EcoreUtil.copy(getSelectedExpression()), editInput, getEditingDomain(),
filters.toArray(new ViewerFilter[filters.size()]), this);
return groovyOnlyEditExpressionDialog;
}
@Override
......
/**
* 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.groovy.ui.viewer;
import java.util.ResourceBundle;
import org.codehaus.groovy.eclipse.editor.GroovyEditor;
import org.codehaus.groovy.eclipse.refactoring.actions.FormatKind;
import org.codehaus.groovy.eclipse.refactoring.actions.OrganizeGroovyImportsAction;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.ui.texteditor.TextOperationAction;
/**
* @author Romain Bioteau
*
*/
public class GroovyEditorActionFactory {
private TextOperationAction deleteAction;
private final GroovyEditor editor;
private BonitaFormatGroovyAction formatAction;
private OrganizeGroovyImportsAction organizeImportsAction;
public GroovyEditorActionFactory(final GroovyEditor editor) {
this.editor = editor;
}
protected TextOperationAction getDeleteAction() {
if (deleteAction == null) {
deleteAction = new TextOperationAction(
getTextEditorBundle(), "Editor.Delete.", editor, ITextOperationTarget.DELETE);
}
return deleteAction;
}
protected ResourceBundle getTextEditorBundle() {
return ResourceBundle.getBundle("org.eclipse.ui.texteditor.ConstructedEditorMessages");
}
protected TextOperationAction getUndoAction() {
if (deleteAction == null) {
deleteAction = new TextOperationAction(
getTextEditorBundle(), "Editor.Undo.", editor, ITextOperationTarget.UNDO);
}
return deleteAction;
}
protected TextOperationAction getRedoAction() {
if (deleteAction == null) {
deleteAction = new TextOperationAction(
getTextEditorBundle(), "Editor.Redo.", editor, ITextOperationTarget.REDO);
}
return deleteAction;
}
protected BonitaFormatGroovyAction getFormatAction() {
if (formatAction == null) {
formatAction = new BonitaFormatGroovyAction(editor.getEditorSite(), FormatKind.FORMAT, editor, editor
.getGroovyCompilationUnit());
}
return formatAction;
}
public OrganizeGroovyImportsAction getOrganizeImportAction() {
if (organizeImportsAction == null) {
organizeImportsAction = new OrganizeGroovyImportsAction(editor);
}
return organizeImportsAction;
}
}
......@@ -24,7 +24,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.ResourceBundle;
import java.util.Set;
import org.bonitasoft.studio.common.ExpressionConstants;
......@@ -53,8 +52,6 @@ import org.codehaus.groovy.eclipse.GroovyPlugin;
import org.codehaus.groovy.eclipse.codeassist.requestor.CompletionNodeFinder;
import org.codehaus.groovy.eclipse.codeassist.requestor.ContentAssistContext;
import org.codehaus.groovy.eclipse.core.preferences.PreferenceConstants;
import org.codehaus.groovy.eclipse.refactoring.actions.FormatKind;
import org.codehaus.groovy.eclipse.refactoring.actions.OrganizeGroovyImportsAction;
import org.codehaus.jdt.groovy.model.GroovyCompilationUnit;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
......@@ -72,7 +69,6 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.source.Annotation;
......@@ -92,7 +88,6 @@ import org.eclipse.ui.handlers.IHandlerActivation;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.TextOperationAction;
/**
* @author Romain Bioteau
......@@ -156,16 +151,14 @@ public class GroovyViewer {
editor = new BonitaGroovyEditor(GroovyPlugin.getDefault().getPreferenceStore());
try {
editor.getDocumentProvider().connect(input);
editor.init(new DummyEditorSite(mainComposite.getShell(), editor), this.input);
editor.createPartControl(mainComposite);
editor.createJavaSourceViewerConfiguration();
} catch (final Exception e1) {
BonitaStudioLog.error(e1);
}
final GroovyEditorActionFactory actionFactory = new GroovyEditorActionFactory(editor);
getSourceViewer().getTextWidget().setTextLimit(MAX_SCRIPT_LENGTH);
getSourceViewer().addTextListener(new ITextListener() {
......@@ -203,16 +196,11 @@ public class GroovyViewer {
@Override
public void keyReleased(final KeyEvent e) {
if ((e.stateMask == SWT.CTRL || e.stateMask == SWT.COMMAND) && e.keyCode == 'z') {
final TextOperationAction action = new TextOperationAction(
ResourceBundle.getBundle("org.eclipse.ui.texteditor.ConstructedEditorMessages"), "Editor.Undo.", editor, ITextOperationTarget.UNDO); //$NON-NLS-1$ //$NON-NLS-2$
action.run();
actionFactory.getUndoAction().run();
} else if ((e.stateMask == SWT.CTRL || e.stateMask == SWT.COMMAND) && e.keyCode == 'y') {
final TextOperationAction action = new TextOperationAction(
ResourceBundle.getBundle("org.eclipse.ui.texteditor.ConstructedEditorMessages"), "Editor.Redo.", editor, ITextOperationTarget.REDO); //$NON-NLS-1$ //$NON-NLS-2$
action.run();
actionFactory.getRedoAction().run();
} else if (e.stateMask == (SWT.CTRL | SWT.SHIFT) && e.keyCode == 'o') {
final OrganizeGroovyImportsAction action = new OrganizeGroovyImportsAction(editor);
action.run();
actionFactory.getOrganizeImportAction().run();
}
}
......@@ -220,15 +208,14 @@ public class GroovyViewer {
@Override
public void keyPressed(final KeyEvent e) {
if (e.keyCode == SWT.DEL) {
final TextOperationAction action = new TextOperationAction(
ResourceBundle.getBundle("org.eclipse.ui.texteditor.ConstructedEditorMessages"), "Editor.Delete.", editor, ITextOperationTarget.DELETE); //$NON-NLS-1$ //$NON-NLS-2$
action.run();
} else if ((e.stateMask == SWT.CTRL || e.stateMask == SWT.COMMAND) && e.keyCode == 'i') {
final BonitaFormatGroovyAction action = new BonitaFormatGroovyAction(editor.getEditorSite(), FormatKind.FORMAT, editor, editor
.getGroovyCompilationUnit());
action.run();
actionFactory.getDeleteAction().run();
} else
if ((e.stateMask == SWT.CTRL || e.stateMask == SWT.COMMAND) && e.keyCode == 'i') {
actionFactory.getFormatAction().run();
}
}
});
enableContextAssitShortcut();
......@@ -286,6 +273,8 @@ public class GroovyViewer {
});
}
public void enableContextAssitShortcut() {
final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
fHandlerActivation = handlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, triggerAssistantHandler);
......
Supports Markdown
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