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

tr(refactorPlugin) merge debug into

connectors
parent 9256529b
......@@ -355,13 +355,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
version="0.0.0"
unpack="false"/>
<plugin
id="org.bonitasoft.studio.debug"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.bonitasoft.studio.connectors.model.edit"
download-size="0"
......
......@@ -42,7 +42,6 @@ Require-Bundle: org.bonitasoft.studio.diagram,
org.bonitasoft.studio.engine,
org.eclipse.jdt.launching;bundle-version="3.6.1",
org.bonitasoft.studio.form.preview,
org.bonitasoft.studio.debug,
org.eclipse.e4.ui.model.workbench;bundle-version="1.0.0",
org.eclipse.e4.core.contexts;bundle-version="1.3.0",
org.eclipse.e4.ui.workbench;bundle-version="1.0.0",
......
......@@ -15,7 +15,6 @@
package org.bonitasoft.studio.application;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.debug.DebugPlugin;
import org.bonitasoft.studio.validation.ValidationPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.resource.ImageDescriptor;
......@@ -59,7 +58,6 @@ public class ApplicationPlugin extends AbstractUIPlugin {
getDialogSettings().put(BAR_DEFAULT_PATH, System.getProperty("user.home"));
}
try {
DebugPlugin.getDefault().getBundle().start();
ValidationPlugin.getDefault().getBundle().start();
if (ConsolePlugin.getDefault() == null) {
new ConsolePlugin();
......
......@@ -40,7 +40,8 @@ Require-Bundle: org.eclipse.ui,
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.mockito;bundle-version="1.9.5";resolution:=optional,
org.bonitasoft.studio.tests-utils;bundle-version="6.4.0";resolution:=optional,
org.bonitasoft.studio.model.edit
org.bonitasoft.studio.model.edit,
org.bonitasoft.studio.diagram
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.connectors,
......
......@@ -142,4 +142,10 @@ move=Move
connectorInChoice={0} (Connectors in)
connectorOutChoice={0} (Connectors out)
connectorEventLabel=Connector execution event
providedDefinitionAlreadyExists={0} definition is already provided and has not been imported.
\ No newline at end of file
providedDefinitionAlreadyExists={0} definition is already provided and has not been imported.
DebugProcessButtonLabel=Debug
selectConnectorTitle=Configure the debug execution
selectConnectorMessage=The debug execution will skip unchecked connectors to ease the debug of the execution.\nUncheck the connectors to skip.
selectAll=Select all
unSelectAll=Deselect all
debugProcessWizardtitle=Debug configuration
\ No newline at end of file
......@@ -9,3 +9,4 @@ editConnectorImplementation=Edit implementation...
newConnectorImplementation=New implementation...
testConnector=Test connector...
editConnectorConfiguration=Edit configuration...
debugLabel=Debug
\ No newline at end of file
......@@ -241,4 +241,37 @@
</configurationPage>
</connectorWizard>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="org.bonitasoft.studio.connectors.handler.DebugProcessCommand"
id="org.bonitasoft.studio.debug.debugProcess"
name="%debugLabel">
<commandParameter
id="configuration"
name="configuration"
optional="true">
</commandParameter>
</command>
</extension>
<extension
point="org.bonitasoft.studio.coolbarContributionItem">
<coolbarItem
class="org.bonitasoft.studio.connectors.ui.DebugCoolbarItem"
priority="0"
toolbarPosition="12">
</coolbarItem>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.bonitasoft.studio.menu.run?after=org.bonitasoft.studio.engine.runCommand">
<command
commandId="org.bonitasoft.studio.debug.debugProcess"
icon="icons/debug.png"
style="push">
</command>
</menuContribution>
</extension>
</plugin>
......@@ -12,28 +12,23 @@
* 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.debug.command;
package org.bonitasoft.studio.connectors.handler;
import java.util.Set;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.jface.CustomWizardDialog;
import org.bonitasoft.studio.debug.i18n.Messages;
import org.bonitasoft.studio.debug.wizard.DebugProcessWizard;
import org.bonitasoft.studio.connectors.i18n.Messages;
import org.bonitasoft.studio.connectors.ui.wizard.DebugProcessWizard;
import org.bonitasoft.studio.engine.command.RunProcessCommand;
import org.bonitasoft.studio.model.form.Form;
import org.bonitasoft.studio.model.process.Element;
import org.bonitasoft.studio.model.process.MainProcess;
import org.bonitasoft.studio.model.process.diagram.form.part.FormDiagramEditor;
import org.bonitasoft.studio.model.process.diagram.part.ProcessDiagramEditor;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Display;
......@@ -68,7 +63,7 @@ public class DebugProcessCommand extends AbstractHandler {
private MainProcess getSelectedProcess() {
IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editorPart instanceof ProcessDiagramEditor) {
if (editorPart instanceof DiagramEditor) {
Object selection = ((IStructuredSelection) editorPart.getSite().getSelectionProvider().getSelection())
.getFirstElement();
if (selection instanceof IGraphicalEditPart) {
......@@ -77,10 +72,6 @@ public class DebugProcessCommand extends AbstractHandler {
return ModelHelper.getMainProcess(semanticObject);
}
}
} else if (editorPart instanceof FormDiagramEditor) {
DiagramEditPart formDiagram = ((DiagramDocumentEditor) editorPart).getDiagramEditPart();
Form form = (Form) formDiagram.resolveSemanticElement();
return ModelHelper.getMainProcess(form.eContainer());
}
return null;
}
......
......@@ -182,6 +182,12 @@ public class Messages extends NLS {
public static String copy;
public static String providedDefinitionAlreadyExists;
public static String selectConnectorTitle;
public static String selectConnectorMessage;
public static String selectAll;
public static String unSelectAll;
public static String DebugProcessButtonLabel;
public static String debugProcessWizardtitle;
/**
* @param event
......
......@@ -12,19 +12,17 @@
* 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.debug.coolbar;
package org.bonitasoft.studio.connectors.ui;
import java.util.List;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.extension.IBonitaContributionItem;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.debug.i18n.Messages;
import org.bonitasoft.studio.connectors.i18n.Messages;
import org.bonitasoft.studio.model.form.Form;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.bonitasoft.studio.profiles.manager.BonitaProfilesManager;
import org.bonitasoft.studio.profiles.manager.IBonitaActivitiesCategory;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.emf.ecore.EObject;
......@@ -90,7 +88,7 @@ public class DebugCoolbarItem extends ContributionItem implements IBonitaContrib
*/
@Override
public boolean isVisible() {
return BonitaProfilesManager.getInstance().isEnabled(IBonitaActivitiesCategory.EXECUTION);
return true;
}
@Override
......
/**
* Copyright (C) 2011 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.connectors.ui.wizard;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.connectors.ConnectorPlugin;
import org.bonitasoft.studio.connectors.i18n.Messages;
import org.bonitasoft.studio.diagram.custom.repository.DiagramRepositoryStore;
import org.bonitasoft.studio.model.process.AbstractProcess;
import org.bonitasoft.studio.model.process.CallActivity;
import org.bonitasoft.studio.model.process.ConnectableElement;
import org.bonitasoft.studio.model.process.Connector;
import org.bonitasoft.studio.model.process.MainProcess;
import org.bonitasoft.studio.model.process.PageFlow;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.pics.Pics;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ICheckStateProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
/**
* @author Romain Bioteau
*/
public class ConnectorsSelectionPage extends WizardPage {
private static final String DEBUG_KEY = "debug_connector";
private final MainProcess mainProcess;
private CheckboxTreeViewer connectorsTree;
private List<EObject> input;
private ICheckStateProvider checkStateProvider;
private final Set<EObject> checked;
public ConnectorsSelectionPage(MainProcess sourceProcesses) {
super(ConnectorsSelectionPage.class.getName(), Messages.selectConnectorTitle, Pics.getWizban());
setDescription(Messages.selectConnectorMessage);
mainProcess = sourceProcesses;
checked = new HashSet<EObject>();
}
/*
* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
Composite mainComposite = new Composite(parent, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
mainComposite.setLayout(gl);
createSelectionButtonBar(mainComposite);
createTreeViewer(mainComposite);
createSelectionButtonBar(mainComposite);
getContainer().updateButtons();
setControl(mainComposite);
}
protected void createTreeViewer(Composite mainComposite) {
connectorsTree = new CheckboxTreeViewer(mainComposite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
connectorsTree.setLabelProvider(new DebugConnectorLabelProvider());
final ITreeContentProvider provider = new ITreeContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
@Override
public void dispose() {
}
@Override
public boolean hasChildren(Object element) {
if (element instanceof Connector) {
return false;
}
return true;
}
@Override
public Object getParent(Object element) {
if (element instanceof Connector) {
return ((EObject) element).eContainer();
}
return null;
}
@Override
public Object[] getElements(Object inputElement) {
return ((Set<EObject>) inputElement).toArray();
}
@Override
public Object[] getChildren(Object parentElement) {
List<EObject> children = new ArrayList<EObject>();
if (parentElement instanceof ConnectableElement) {
children.addAll(((ConnectableElement) parentElement).getConnectors());
}
if (parentElement instanceof PageFlow) {
children.addAll(((PageFlow) parentElement).getPageFlowConnectors());
}
return children.toArray();
}
};
connectorsTree.setContentProvider(provider);
input = new ArrayList<EObject>();
retrieveAllConnectors(mainProcess, input);
Set<EObject> parentSet = new HashSet<EObject>();
for (EObject object : input) {
parentSet.add(object.eContainer());
}
connectorsTree.setInput(parentSet);
connectorsTree.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (!(event.getElement() instanceof Connector)) {
for (Object child : provider.getChildren(event.getElement())) {
connectorsTree.setChecked(child, event.getChecked());
if (event.getChecked()) {
checked.add((EObject) child);
} else {
checked.remove(child);
}
}
} else {
if (event.getChecked()) {
checked.add((EObject) event.getElement());
} else {
checked.remove(event.getElement());
}
Object parent = provider.getParent(event.getElement());
boolean atLeastOne = false;
for (Object child : provider.getChildren(parent)) {
if (connectorsTree.getChecked(child)) {
atLeastOne = true;
break;
}
}
connectorsTree.setChecked(parent, atLeastOne);
}
}
});
checkStateProvider = new ICheckStateProvider() {
@Override
public boolean isGrayed(Object element) {
if (!(element instanceof Connector)) {
return true;
}
return false;
}
@Override
public boolean isChecked(Object element) {
if (element instanceof Connector) {
if (ConnectorPlugin.getDefault().getDialogSettings()
.get(DEBUG_KEY + ModelHelper.getEObjectID((EObject) element)) != null) {
boolean isExceuting = ConnectorPlugin.getDefault().getDialogSettings()
.getBoolean(DEBUG_KEY + ModelHelper.getEObjectID((EObject) element));
if (isExceuting) {
checked.add((EObject) element);
} else {
checked.remove(element);
}
return isExceuting;
} else {
checked.add((EObject) element);
return true;
}
} else {
boolean allChecked = true;
for (Object child : provider.getChildren(element)) {
if (!isChecked(child)) {
allChecked = false;
break;
}
}
return allChecked;
}
}
};
connectorsTree.setCheckStateProvider(checkStateProvider);
connectorsTree.collapseAll();
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 350;
gd.heightHint = 400;
connectorsTree.getTree().setLayoutData(gd);
}
private void retrieveAllConnectors(MainProcess diagram, List<EObject> result) {
ModelHelper.findAllConnectors(diagram, result);
final List<CallActivity> callActivities = ModelHelper.getAllItemsOfType(diagram,
ProcessPackage.Literals.CALL_ACTIVITY);
final DiagramRepositoryStore store = (DiagramRepositoryStore) RepositoryManager.getInstance()
.getRepositoryStore(DiagramRepositoryStore.class);
final List<AbstractProcess> allProcesses = store.getAllProcesses();
for (CallActivity activity : callActivities) {
final String procName = activity.getCalledActivityName().getContent();
if (procName != null && !procName.isEmpty()) {
final String procVersion = activity.getCalledActivityVersion().getContent();
for (AbstractProcess proc : allProcesses) {
if (!ModelHelper.getMainProcess(proc).equals(diagram)) {//NOT ON THE SAME DIAGRAM
if (procVersion == null || procVersion.isEmpty()) {
if (procName.equals(proc.getName())) {
retrieveAllConnectors(ModelHelper.getMainProcess(proc), result);
}
} else {
if (procName.equals(proc.getName()) && procVersion.equals(proc.getVersion())) {
retrieveAllConnectors(ModelHelper.getMainProcess(proc), result);
}
}
}
}
}
}
}
protected void createSelectionButtonBar(Composite mainComposite) {
Composite buttonComposite = new Composite(mainComposite, SWT.NONE);
RowLayout rl = new RowLayout();
rl.spacing = 10;
buttonComposite.setLayout(rl);
buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(-3, 0).create());
final Button selectAll = new Button(buttonComposite, SWT.FLAT);
selectAll.setText(Messages.selectAll);
selectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
connectorsTree.setAllChecked(true);
for (Object element : input) {
connectorsTree.setChecked(element, true);
}
checked.addAll(input);
}
});
final Button unselectAll = new Button(buttonComposite, SWT.FLAT);
unselectAll.setText(Messages.unSelectAll);
unselectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
connectorsTree.setAllChecked(false);
for (Object element : input) {
connectorsTree.setChecked(element, false);
}
checked.addAll(input);
checked.clear();
}
});
}
@Override
public boolean isPageComplete() {
return true;
}
public Set<EObject> getExcludedConnectors() {
Set<EObject> unchecked = new HashSet<EObject>();
for (EObject o : input) {
if (checked.contains(o)) {
ConnectorPlugin.getDefault().getDialogSettings().put(DEBUG_KEY + ModelHelper.getEObjectID(o), true);
} else {
ConnectorPlugin.getDefault().getDialogSettings().put(DEBUG_KEY + ModelHelper.getEObjectID(o), false);
unchecked.add(o);
}
}
return unchecked;
}
}
......@@ -15,7 +15,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.debug.wizard;
package org.bonitasoft.studio.connectors.ui.wizard;
import org.bonitasoft.studio.connectors.ui.provider.StyledConnectorLabelProvider;
import org.bonitasoft.studio.model.process.Connector;
......
/**
* Copyright (C) 2011 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