Commit 74b9decc authored by Bonita CI's avatar Bonita CI
Browse files

Merge branch 'master' into 'BS-9421_BizData_MultiInstance'

parents 1842427d 854b6f84
/**
* Copyright (C) 2014 Bonitasoft S.A.
* import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
ense, 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.common.gmf;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
public class ChangeBoundsRequestUtil {
public static boolean isMovingToAnotherProcess(final EditPart host, final ChangeBoundsRequest request) {
//find the target EditPart on which we will move the getHost()
if (host.getViewer().findObjectAt(request.getLocation()) instanceof IGraphicalEditPart) {
final IGraphicalEditPart target = (IGraphicalEditPart) host.getViewer().findObjectAt(request.getLocation());
EObject source = null;
for (final Object e : request.getEditParts()) {
source = ((IGraphicalEditPart) e).resolveSemanticElement();
}
return areInSameProcess(source, target.resolveSemanticElement());
}
return true;
}
private static boolean areInSameProcess(final EObject o, final EObject hostObject) {
return ModelHelper.getParentProcess(o).equals(ModelHelper.getParentProcess(hostObject));
}
}
/**
* Copyright (C) 2010 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
*
* Copyright (C) 2010-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
* 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.common.gmf;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
import org.eclipse.gmf.runtime.diagram.ui.figures.LabelLocator;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
/**
* @author Baptiste Mesta
*
*/
public class CustomEventLabelEditPart extends LabelEditPart {
/**
* @param view
*/
public CustomEventLabelEditPart(View view) {
super(view);
}
/**
* @param view
*/
public CustomEventLabelEditPart(final View view) {
super(view);
}
/**
* @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#createDefaultEditPolicies()
*/
@Override
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(
EditPolicy.PRIMARY_DRAG_ROLE,
new CustomNonResizableLabelEditPolicy());
}
public void refreshBounds() {
IFigure refFigure = ((GraphicalEditPart) getParent()).getFigure();
int dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE
.getLocation_X())).intValue();
int dy = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE
.getLocation_Y())).intValue();
Point offset = new Point(dx, dy);
if(getFigure().getParent() != null){
getFigure().getParent().setConstraint(getFigure(),
new LabelLocator(refFigure, offset, getKeyPoint()) {
@Override
public void refreshBounds() {
final IFigure refFigure = ((GraphicalEditPart) getParent()).getFigure();
final int dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE
.getLocation_X())).intValue();
final int dy = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE
.getLocation_Y())).intValue();
final Point offset = new Point(dx, dy);
if(getFigure().getParent() != null){
getFigure().getParent().setConstraint(getFigure(),
new LabelLocator(refFigure, offset, getKeyPoint()) {
public void relocate(IFigure target) {
Point location = getReferencePoint().getTranslated(
getOffset());
location.translate(-target.getBounds().width / 2, 0);
target.setLocation(location);
target.setSize(new Dimension(
target.getPreferredSize().width, target
.getPreferredSize().height));
}
@Override
public void relocate(final IFigure target) {
final Point location = getReferencePoint().getTranslated(
getOffset());
location.translate(-target.getBounds().width / 2, 0);
target.setLocation(location);
target.setSize(new Dimension(
target.getPreferredSize().width, target
.getPreferredSize().height));
}
protected Point getReferencePoint() {
return getLabelLocation(parent);
}
});
}
}
@Override
protected Point getReferencePoint() {
return getLabelLocation(parent);
}
});
}
}
@Override
public Point getReferencePoint() {
return getLabelLocation(((GraphicalEditPart) getParent()).getFigure());
}
@Override
public Point getReferencePoint() {
return getLabelLocation(((GraphicalEditPart) getParent()).getFigure());
}
protected Point getLabelLocation(IFigure parent) {
return parent.getBounds().getBottom();
}
protected Point getLabelLocation(final IFigure parent) {
return parent.getBounds().getBottom();
}
}
/**
* 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.common.gmf;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.NonResizableLabelEditPolicy;
public class CustomNonResizableLabelEditPolicy extends NonResizableLabelEditPolicy {
@Override
protected Command getMoveCommand(final ChangeBoundsRequest request) {
if (moveNotAllowed(request)) {
return UnexecutableCommand.INSTANCE;
}
return super.getMoveCommand(request);
}
private boolean moveNotAllowed(final ChangeBoundsRequest request) {
return !ChangeBoundsRequestUtil.isMovingToAnotherProcess(getHost(), request);
}
}
......@@ -210,6 +210,9 @@ public class Repository implements IRepository {
jProject.open(NULL_PROGRESS_MONITOR);
}
new ClasspathValidation(jProject).validate();
} else {
BonitaStudioLog.log("Cannot retrieve the JavaProject Nature from the project: " + project.getName());
project.open(NULL_PROGRESS_MONITOR);//Open anyway
}
}
} catch (final CoreException e) {
......@@ -326,6 +329,7 @@ public class Repository implements IRepository {
final Set<String> additionalNatures = getNatures();
final Set<String> notExistingNature = new HashSet<String>();
for (final String natureId : additionalNatures) {
BonitaStudioLog.log("Plan to add Project Nature " + natureId);
@SuppressWarnings("restriction")
final
Object naturDesc = ((Workspace) ResourcesPlugin.getWorkspace()).getNatureManager().getNatureDescriptor(natureId);
......@@ -353,6 +357,7 @@ public class Repository implements IRepository {
@Override
public void run() {
try {
BonitaStudioLog.log("Setting Project Descritor with natures:" + descriptor.getNatureIds());
project.setDescription(descriptor, null);
} catch (final CoreException e) {
throw new RuntimeException(e);
......
......@@ -307,4 +307,5 @@ outlineDialogRefactoringText=Here are the references found for the {0}\:
errorValidationMessage=Some errors have been found in the diagram
errorValidationContinueAnywayMessage=\n Do you want to continue anyway? {0}\:
validationFailedTitle=Some errors have been found in the diagram
removalConfirmationDialogTitle=Removal confirmation
\ No newline at end of file
removalConfirmationDialogTitle=Removal confirmation
endWarningMessage=If you click OK, the refactor window is displayed and you can update the scripts that use
......@@ -295,60 +295,61 @@ public class Messages extends NLS {
public static String differentCaseSameNameError;
public static String diagramAlreadyExists;
public static String descriptionTitle;
public static String noToAll;
public static String yesToAll;
public static String overwriteTitle;
public static String overwriteMessage;
public static String deleteConfirmationTitle;
public static String deleteConfirmationMsg;
public static String noToAll;
public static String yesToAll;
public static String overwriteTitle;
public static String overwriteMessage;
public static String deleteConfirmationTitle;
public static String deleteConfirmationMsg;
public static String seeDetailsButtonLabel;
public static String diagramNameOrVersionMustBeChanged;
public static String bonitaName;
public static String bosProductName;
public static String bosSPProductName;
public static String bonitaStudioModuleName;
public static String bonitaPortalModuleName;
public static String bonitaEngineModuleName;
public static String bonitaBPMCommunity;
public static String bonitaBPMTeamworkSubscription;
public static String bonitaBPMEfficiencySubscription;
public static String bonitaBPMPerformanceSubscription;
public static String corporateName;
public static String seeDetailsButtonLabel;
public static String diagramNameOrVersionMustBeChanged;
public static String bonitaName;
public static String bosProductName;
public static String bosSPProductName;
public static String bonitaStudioModuleName;
public static String bonitaPortalModuleName;
public static String bonitaEngineModuleName;
public static String bonitaBPMCommunity;
public static String bonitaBPMTeamworkSubscription;
public static String bonitaBPMEfficiencySubscription;
public static String bonitaBPMPerformanceSubscription;
public static String corporateName;
public static String nameMustStartWithLowerCase;
public static String reservedKeyword;
public static String nameFieldIssue;
public static String filterLabel;
public static String InvalidCharacterError;
public static String toolAlignHorizontal;
public static String toolAlignHorizontalDesc;
public static String toolAlignVertical;
public static String toolAlignVerticalDesc;
public static String fieldIsTooShort;
public static String nonInterruptingTimerEvent_desc;
public static String nonInterruptingTimerEvent_title;
public static String currentScript;
public static String refactoredScript;
public static String refactorTitle;
public static String reviewChangesMessageRefactoring;
public static String reviewChangesMessageRemoving;
public static String deleteFormFieldDialogTitle;
public static String askConfirmationForDeleting;
public static String removingWidgetReferences;
public static String removeTitle;
public static String delete;
public static String nameCantHaveAWhitespace;
public static String emptyListExpressionName;
public static String referenceTreeViewerTitle;
public static String dataListViewerTitle;
public static String searchIndexListViewerTitle;
public static String parameterListTitle;
public static String widgetListViewerTitle;
public static String outlineDialogRefactoringText;
public static String removalConfirmationDialogTitle;
public static String errorValidationMessage;
public static String errorValidationContinueAnywayMessage;
public static String validationFailedTitle;
public static String reservedKeyword;
public static String nameFieldIssue;
public static String filterLabel;
public static String InvalidCharacterError;
public static String toolAlignHorizontal;
public static String toolAlignHorizontalDesc;
public static String toolAlignVertical;
public static String toolAlignVerticalDesc;
public static String fieldIsTooShort;
public static String nonInterruptingTimerEvent_desc;
public static String nonInterruptingTimerEvent_title;
public static String currentScript;
public static String refactoredScript;
public static String refactorTitle;
public static String reviewChangesMessageRefactoring;
public static String reviewChangesMessageRemoving;
public static String deleteFormFieldDialogTitle;
public static String askConfirmationForDeleting;
public static String removingWidgetReferences;
public static String removeTitle;
public static String delete;
public static String nameCantHaveAWhitespace;
public static String emptyListExpressionName;
public static String referenceTreeViewerTitle;
public static String dataListViewerTitle;
public static String searchIndexListViewerTitle;
public static String parameterListTitle;
public static String widgetListViewerTitle;
public static String outlineDialogRefactoringText;
public static String removalConfirmationDialogTitle;
public static String errorValidationMessage;
public static String errorValidationContinueAnywayMessage;
public static String validationFailedTitle;
public static String endWarningMessage;
}
......@@ -57,183 +57,207 @@ import org.eclipse.swt.widgets.Shell;
*
*/
public class OutlineDialog extends MessageDialog{
private String message;
private Label messageLabel;
private List<Object> elementToDisplay;
private ComposedAdapterFactory adapterFactory;
private ListViewer objectListViewer;
private TreeViewer outline;
private Image warningImg;
public OutlineDialog( Shell parentShell, String dialogTitle,
Image dialogTitleImage, String dialogMessage,
int dialogImageType, String[] dialogButtonLabels,
int defaultIndex, List<Object> elementToDisplay) {
super(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
dialogImageType, dialogButtonLabels, defaultIndex);
this.message = dialogMessage;
this.elementToDisplay = elementToDisplay;
this.adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
this.warningImg=dialogTitleImage;
updateListOfElementToDisplay();
}
/** Remove objects that are not referenced in expressions in the parent process in the <i>elementToDisplay</i> list field.
*
*/
protected void updateListOfElementToDisplay() {
List<Object> filteredElements = new ArrayList<Object>();
Iterator<Object> elementIter = elementToDisplay.iterator();
while (elementIter.hasNext()){
Object elem = elementIter.next();
AbstractProcess process = ModelHelper.getParentProcess((EObject)elem);
List<Expression> listExpr = ModelHelper.getAllItemsOfType(process, ExpressionPackage.Literals.EXPRESSION);
for(Expression expr : listExpr){
if(ModelHelper.isObjectIsReferencedInExpression(expr, elem) && !filteredElements.contains(elem)){
filteredElements.add(elem);
}
}
}
elementToDisplay=filteredElements;
}
@Override
protected Control createMessageArea(Composite parent) {
Composite mainComposite = new Composite(parent,SWT.NONE);
mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(10,20).create());
mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
createMessageComposite(mainComposite);
if(elementToDisplay!=null && !elementToDisplay.isEmpty()){
createMessageInformation(mainComposite);
Composite viewersComposite = new Composite(mainComposite,SWT.NONE);
viewersComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).spacing(5,5).create());
viewersComposite.setLayoutData(GridDataFactory.fillDefaults().hint(450,250).grab(true,true).create());
createTableHeader(viewersComposite);
createObjectListViewer(viewersComposite);
createOutline(viewersComposite);
objectListViewer.setSelection(new StructuredSelection(elementToDisplay.get(0)),true);
}
return mainComposite;
}
private void createMessageInformation(Composite mainComposite) {
Label information = new Label(mainComposite, SWT.NONE);
information.setText(Messages.bind(Messages.outlineDialogRefactoringText, getElementNameListHeader().toLowerCase()));
}
private void createTableHeader(Composite viewersComposite) {
Label headerObjectList= new Label(viewersComposite, SWT.BOTTOM | SWT.LEFT );
headerObjectList.setText(getElementNameListHeader());
Label headerOutline= new Label(viewersComposite, SWT.BOTTOM | SWT.LEFT);
headerOutline.setText(Messages.referenceTreeViewerTitle);
}
private String getElementNameListHeader() {
if(elementToDisplay!=null && !elementToDisplay.isEmpty()){
Object element = elementToDisplay.get(0);
if(element instanceof Parameter){
return Messages.parameterListTitle;
}
if(element instanceof SearchIndex){
return Messages.searchIndexListViewerTitle;
}
if(element instanceof Widget){
return Messages.widgetListViewerTitle;
}
if(element instanceof Element){
return Messages.dataListViewerTitle;
}
}
return "";
}
private void createMessageComposite(Composite mainComposite) {
Composite messageComposite = new Composite(mainComposite,SWT.NONE);
messageComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
messageComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
Label imageLabel = new Label(messageComposite,SWT.NULL);
warningImg.setBackground(imageLabel.getBackground());
imageLabel.setImage(warningImg);
GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(imageLabel);
createMessageLabel(messageComposite);
}
private void createMessageLabel(Composite messageComposite) {
messageLabel = new Label(messageComposite,SWT.WRAP);
if (message!=null){
messageLabel.setText(message);
GridDataFactory
.fillDefaults()
.align(SWT.FILL, SWT.BEGINNING)
.grab(true, true)
.hint(400,
SWT.DEFAULT).applyTo(messageLabel);
}
}
private void createOutline(Composite viewersComposite) {
outline = new TreeViewer(viewersComposite);
outline.getTree().setLayoutData(GridDataFactory.fillDefaults().hint(300,200).create());
outline.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
outline.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
ViewerFilter[] filters = {new OutlineFilter()};
outline.setFilters(filters);
if (!(elementToDisplay.get(0) instanceof Widget)){
outline.setInput(ModelHelper.getParentProcess((EObject)elementToDisplay.get(0)));
} else {
outline.setInput(ModelHelper.getPageFlow((Widget)elementToDisplay.get(0)));
}
}
private void createObjectListViewer(Composite viewersComposite) {
objectListViewer = new ListViewer(viewersComposite);
objectListViewer.getList().setLayoutData(GridDataFactory.fillDefaults().hint(100,200).create());
objectListViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
objectListViewer.setContentProvider(new ArrayContentProvider());
objectListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
EObject selectedObject = (EObject)selection.getFirstElement();
OutlineFilter filter =(OutlineFilter) outline.getFilters()[0];
filter.setElementToDisplay(selectedObject);
if (outline!=null){
outline.refresh(true);
}
}
});
objectListViewer.setInput(elementToDisplay);
}
public String getMessage() {
return message;