Commit 1364b7d9 authored by Bonita CI's avatar Bonita CI

Merge branch 'master' into 'BS-9425_StepContract'

parents e5dffd30 336cd9e6
# Declare files that will always have LF line ending on checkout
*.properties text eol=lf
fileMenu_Label=&Diagram
newProcessAction_Label=New
openProcess_label=Open...
deleteProcess_label=Delete...
exitAction_label=Exit
printLabel=&Print
saveProcess_label=&Save
......
......@@ -107,6 +107,14 @@
label="%openProcess_label"
style="push">
</command>
<command
commandId="org.bonitasoft.studio.diagram.command.deleteDiagram"
disabledIcon="icons/menuIcons/open_disabled.png"
hoverIcon="icons/menuIcons/open_hover.png"
icon="icons/menuIcons/open.png"
label="%deleteProcess_label"
style="push">
</command>
<command
commandId="org.bonitasoft.studio.application.command.rename"
label="%renameLabel"
......
......@@ -303,7 +303,8 @@ dataListViewerTitle=Data
searchIndexListViewerTitle=Search index
parameterListTitle=Parameter
widgetListViewerTitle=Widget
outlineDialogRefactoringText=Here are the references found for theerrorValidationMessage=Some errors have been found in the diagram
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}\:
errorValidationMessage = Some errors have been found in the diagram
validationFailedTitle=Some errors have been found in the diagram
\ No newline at end of file
validationFailedTitle=Some errors have been found in the diagram
removalConfirmationDialogTitle=Removal confirmation
\ No newline at end of file
......@@ -20,7 +20,7 @@ openProcessWizardPage_title=Open an existing diagram
openProcessWizardPage_desc=Select the diagram you wish to view and edit.
removeProcessLabel=Delete
confirmProcessDeleteTitle=Delete diagram ?
confirmProcessDeleteMessage=Are you sure you want to delete {0} ?
confirmProcessDeleteMessage=Are you sure you want to delete the following diagram(s)? {0}
confirmProcessOverrideMessage=Opening an unsaved diagram will overwrite it to the last saved version.\n Are you sure you want to overwrite {0} ?
confirmProcessOverrideTitle=Opening diagram
openingDiagramProgressText=Opening diagram...
......@@ -52,4 +52,6 @@ GridRulerPreferencePage_gridSpacing_label_cm=Grid spacing (in centimeters)
extractAsSubprocessNewPoolName=Extracted_Subprocess
poolAlreadyExistWarningMessage=Warning: the following pool(s) name(s) & version(s) already exist in your repository {0}\nYou can't have two pools with the same name and version within your repository
warningDuplicateDialogTitle=Pools already exist
duplicatingDiagram=Duplicating diagram...
\ No newline at end of file
duplicatingDiagram=Duplicating diagram...
DeleteDiagramWizardPage_title=Delete a diagram
DeleteDiagramWizardPage_desc=Select the diagram or diagrams you wish to delete.
\ No newline at end of file
......@@ -405,6 +405,11 @@
id="org.bonitasoft.studio.diagram.command.openDiagram"
name="Open diagram">
</command>
<command
defaultHandler="org.bonitasoft.studio.diagram.custom.commands.DeleteDiagramCommandHandler"
id="org.bonitasoft.studio.diagram.command.deleteDiagram"
name="Delete diagram">
</command>
</extension>
<extension
......
......@@ -80,5 +80,7 @@ public class Messages extends NLS {
public static String warningDuplicateDialogTitle;
public static String poolAlreadyExistWarningMessage;
public static String duplicatingDiagram;
public static String DeleteDiagramWizardPage_title;
public static String DeleteDiagramWizardPage_desc;
}
/**
* 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.diagram.custom.commands;
import org.bonitasoft.studio.common.jface.CustomWizardDialog;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.diagram.custom.Messages;
import org.bonitasoft.studio.diagram.custom.repository.DiagramRepositoryStore;
import org.bonitasoft.studio.diagram.custom.wizard.DeleteDiagramWizard;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.ui.PlatformUI;
/**
* @author aurelie
*
*/
public class DeleteDiagramCommandHandler extends AbstractHandler implements IHandler {
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(final ExecutionEvent arg0) throws ExecutionException {
final DeleteDiagramWizard wizard = new DeleteDiagramWizard();
new CustomWizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
wizard, false, Messages.removeProcessLabel).open();
return null;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#isEnabled()
*/
@Override
public boolean isEnabled() {
final DiagramRepositoryStore diagramSotre = (DiagramRepositoryStore) RepositoryManager.getInstance().getCurrentRepository()
.getRepositoryStore(DiagramRepositoryStore.class);
return !diagramSotre.getChildren().isEmpty();
}
}
/**
* 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.diagram.custom.wizard;
import java.util.List;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.platform.tools.PlatformUtil;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.diagram.custom.Messages;
import org.bonitasoft.studio.diagram.custom.repository.DiagramFileStore;
import org.bonitasoft.studio.diagram.custom.repository.ProcessConfigurationRepositoryStore;
import org.bonitasoft.studio.model.process.AbstractProcess;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
/**
* @author aurelie zara
*/
public abstract class AbstractManageDiagramWizard extends Wizard implements IWizard {
public boolean deleteDiagrams(final AbstractManageDiagramWizardPage page) {
if (page.getDiagramTree().isEnabled() && !page.getDiagramTree().getViewer().getSelection().isEmpty()) {
try {
final List<DiagramFileStore> files = page.getDiagrams();
final StringBuilder stringBuilder = new StringBuilder(files.size()==1?"":"\n");
for (final DiagramFileStore file : files) {
stringBuilder.append(file.getName());
stringBuilder.append("\n");
}
if (MessageDialog.openQuestion(page.getMainComposite().getShell(), Messages.confirmProcessDeleteTitle,
NLS.bind(Messages.confirmProcessDeleteMessage,stringBuilder.toString()))) {
for (final DiagramFileStore file : files) {
for(final AbstractProcess process : file.getProcesses()){
final String uuid = ModelHelper.getEObjectID(process) ;
final IRepositoryFileStore resourceFolder = page.getApplicationResourceStore().getChild(uuid);
if(resourceFolder != null){
resourceFolder.delete() ;
}
final IRepositoryFileStore confFile = page.getProcessConfStore()
.getChild(uuid + "." + ProcessConfigurationRepositoryStore.CONF_EXT);
if(confFile != null){
confFile.delete() ;
}
}
for(final IEditorPart editor : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getDirtyEditors() ){
if(editor.getEditorInput().getName().equals(file.getName()) ){
file.save(editor);
break;
}
}
file.close();
file.delete() ;
}
page.getDiagramTree().getViewer().setInput(new Object());
if(PlatformUtil.isIntroOpen()){
PlatformUtil.closeIntro();
PlatformUtil.openIntro();
}
return true;
}
} catch (final Exception e1) {
BonitaStudioLog.error(e1);
}
}
return false;
}
/*
* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
// TODO Auto-generated method stub
return false;
}
}
/**
* 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.diagram.custom.wizard;
import java.util.List;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.provider.FileStoreLabelProvider;
import org.bonitasoft.studio.diagram.custom.repository.ApplicationResourceRepositoryStore;
import org.bonitasoft.studio.diagram.custom.repository.DiagramFileStore;
import org.bonitasoft.studio.diagram.custom.repository.ProcessConfigurationRepositoryStore;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
/**
* @author aurelie zara
*/
public abstract class AbstractManageDiagramWizardPage extends WizardPage implements IWizardPage {
private FilteredTree diagramTree;
private Composite mainComposite;
private final ProcessConfigurationRepositoryStore processConfStore;
private final ApplicationResourceRepositoryStore applicationResourceStore;
/**
* @param pageName
*/
protected AbstractManageDiagramWizardPage(final String pageName) {
super(pageName);
processConfStore = RepositoryManager.getInstance().getRepositoryStore(ProcessConfigurationRepositoryStore.class);
applicationResourceStore = RepositoryManager.getInstance().getRepositoryStore(ApplicationResourceRepositoryStore.class);
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(final Composite parent) {
createDiagramTreeViewer(parent);
}
public void createDiagramTreeViewer(final Composite parent) {
mainComposite = new Composite(parent, SWT.NONE);
mainComposite.setLayout(new GridLayout(2, true));
//Composite repositoryComposite = new Composite(composite, SWT.NONE);
diagramTree = new FilteredTree(mainComposite, SWT.MULTI | SWT.BORDER, new PatternFilter(), false);
diagramTree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 250).create());
diagramTree.getViewer().setContentProvider(new DiagramTreeContentProvider());
final LabelProvider fileStoreLabelProvider = new FileStoreLabelProvider();
diagramTree.getViewer().setLabelProvider(new DiagramLabelProvider(fileStoreLabelProvider));
diagramTree.getViewer().addSelectionChangedListener(diagramTreeSelectionChangeListener());
diagramTree.getViewer().addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(final DoubleClickEvent arg0) {
if (getWizard().canFinish()) {
if (getWizard().performFinish()) {
((WizardDialog) getContainer()).close();
}
}
}
});
}
public abstract ISelectionChangedListener diagramTreeSelectionChangeListener();
/**
* @return the diagramTree
*/
public FilteredTree getDiagramTree() {
return diagramTree;
}
/**
* @param diagramTree the diagramTree to set
*/
public void setDiagramTree(final FilteredTree diagramTree) {
this.diagramTree = diagramTree;
}
/**
* @return the mainComposite
*/
public Composite getMainComposite() {
return mainComposite;
}
/**
* @param mainComposite the mainComposite to set
*/
public void setMainComposite(final Composite mainComposite) {
this.mainComposite = mainComposite;
}
public List<DiagramFileStore> getDiagrams() {
if (!getDiagramTree().getViewer().getSelection().isEmpty()) {
return ((ITreeSelection) getDiagramTree().getViewer().getSelection()).toList();
}
return null;
}
/**
* @return the processConfStore
*/
public ProcessConfigurationRepositoryStore getProcessConfStore() {
return processConfStore;
}
/**
* @return the applicationResourceStore
*/
public ApplicationResourceRepositoryStore getApplicationResourceStore() {
return applicationResourceStore;
}
protected void setWorkspaceThingsEnabled(final boolean enabled) {
getDiagramTree().getFilterControl().setEnabled(enabled);
getDiagramTree().getViewer().getTree().setEnabled(enabled);
}
}
/**
* 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.diagram.custom.wizard;
import org.bonitasoft.studio.diagram.custom.Messages;
public class DeleteDiagramWizard extends AbstractManageDiagramWizard {
DeleteDiagramWizardPage page;
public DeleteDiagramWizard() {
setNeedsProgressMonitor(true);
setWindowTitle(Messages.DeleteDiagramWizardPage_title);
}
/*
* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
@Override
public void addPages() {
page = new DeleteDiagramWizardPage(Messages.DeleteDiagramWizardPage_title);
super.addPage(page);
}
@Override
public boolean performFinish() {
return deleteDiagrams(page);
}
}
/**
* 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.diagram.custom.wizard;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.diagram.custom.Messages;
import org.bonitasoft.studio.diagram.custom.repository.DiagramFileStore;
import org.bonitasoft.studio.diagram.custom.repository.DiagramRepositoryStore;
import org.bonitasoft.studio.model.process.MainProcess;
import org.bonitasoft.studio.pics.Pics;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
/**
* @author aurelie zara
*/
public class DeleteDiagramWizardPage extends AbstractManageDiagramWizardPage {
private final DiagramRepositoryStore diagramStore;
/**
* @param pageName
*/
protected DeleteDiagramWizardPage(final String pageName) {
super(pageName);
setTitle(pageName);
setDescription(Messages.DeleteDiagramWizardPage_desc);
setImageDescriptor(Pics.getWizban());
diagramStore = (DiagramRepositoryStore) RepositoryManager.getInstance().getCurrentRepository().getRepositoryStore(DiagramRepositoryStore.class);
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.diagram.custom.wizard.AbstractManageDiagramWizardPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(final Composite parent) {
super.createControl(parent);
final Composite blank = new Composite(getMainComposite(), SWT.NONE);
blank.setLayoutData(new GridData(SWT.DEFAULT, 40));
getDiagramTree().getViewer().setInput(new Object());
setWorkspaceThingsEnabled(true);
setControl(getMainComposite());
selectCurrentDiagram();
}
private void selectCurrentDiagram() {
final MainProcess currentProc = getDiagramInEditor();
if (currentProc != null) {
final DiagramFileStore diagram = diagramStore.getDiagram(currentProc.getName(), currentProc.getVersion());
if (diagram != null) {
getDiagramTree().getViewer().setSelection(new StructuredSelection(diagram));
}
}
}
protected MainProcess getDiagramInEditor() {
if (PlatformUI.getWorkbench().getWorkbenchWindows() == null || PlatformUI.getWorkbench().getWorkbenchWindows().length == 0) {
return null;
}
final IEditorPart editor = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage().getActiveEditor();
final boolean isADiagram = editor != null && editor instanceof DiagramEditor;
if (isADiagram) {
final EObject root = ((DiagramEditor) editor).getDiagramEditPart().resolveSemanticElement();
final MainProcess mainProc = ModelHelper.getMainProcess(root);
return mainProc;
}
return null;
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.diagram.custom.wizard.AbstractManageDiagramWizardPage#diagramTreeSelectionChangeListener()
*/
@Override
public ISelectionChangedListener diagramTreeSelectionChangeListener() {
return new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
setPageComplete(isPageComplete());
}
};
}
}
......@@ -31,8 +31,6 @@ import org.bonitasoft.studio.diagram.custom.repository.DiagramFileStore;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
......@@ -42,7 +40,7 @@ import org.eclipse.ui.PlatformUI;
* @author Mickael Istria
*
*/
public class OpenDiagramWizard extends Wizard implements IWizard {
public class OpenDiagramWizard extends AbstractManageDiagramWizard {
private OpenDiagramWizardPage page;
......@@ -69,18 +67,19 @@ public class OpenDiagramWizard extends Wizard implements IWizard {
try {
getContainer().run(false, false, new IRunnableWithProgress(){
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.openingDiagramProgressText, IProgressMonitor.UNKNOWN) ;
List<DiagramFileStore> files = page.getDiagrams();
List<DiagramFileStore> dirtyFiles = new ArrayList<DiagramFileStore>(0);
final List<DiagramFileStore> files = page.getDiagrams();
final List<DiagramFileStore> dirtyFiles = new ArrayList<DiagramFileStore>(0);
Map<DiagramFileStore, Boolean> filesToOpen= new HashMap<DiagramFileStore, Boolean>();
StringBuilder stringBuilder = new StringBuilder(files.size()==1?"":"\n");
final Map<DiagramFileStore, Boolean> filesToOpen= new HashMap<DiagramFileStore, Boolean>();
final StringBuilder stringBuilder = new StringBuilder(files.size()==1?"":"\n");
// get dirtyEditor and list of processes related to them
for (DiagramFileStore file : files) {
for (final DiagramFileStore file : files) {
filesToOpen.put(file, true);
for(IEditorPart editor : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getDirtyEditors()){
for(final IEditorPart editor : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getDirtyEditors()){
if(editor.getEditorInput().getName().equals(file.getName())){
dirtyFiles.add(file);
stringBuilder.append(file.getName());
......@@ -92,20 +91,20 @@ public class OpenDiagramWizard extends Wizard implements IWizard {
// case of dirty diagrams
if (!dirtyFiles.isEmpty() && !MessageDialog.openQuestion(page.getShell(), Messages.confirmProcessOverrideTitle,
NLS.bind(Messages.confirmProcessOverrideMessage,stringBuilder.toString()))) {
for(DiagramFileStore file : dirtyFiles){
for(final DiagramFileStore file : dirtyFiles){
filesToOpen.put(file, false);
}
}
// Open closed, already open, not dirty diagrams, for dirty ones, depending on openQuestion called before
for(DiagramFileStore file : files){
for(final DiagramFileStore file : files){
if(filesToOpen.get(file)){
final IEditorReference openEditor = PlatformUtil.getOpenEditor(file.getName());
if(openEditor!=null){
PlatformUtil.swtichToOpenedEditor(openEditor);
} else {
file.open();
}
final IEditorReference openEditor = PlatformUtil.getOpenEditor(file.getName());
if(openEditor!=null){
PlatformUtil.swtichToOpenedEditor(openEditor);