Commit fa99091a authored by Romain Bioteau's avatar Romain Bioteau

fix stack when using Finish & Create Button in Data wizard

parent 0fab48fb
...@@ -69,11 +69,9 @@ public abstract class FinishAndAddCustomWizardDialog extends CustomWizardDialog ...@@ -69,11 +69,9 @@ public abstract class FinishAndAddCustomWizardDialog extends CustomWizardDialog
@Override @Override
protected void buttonPressed(final int buttonId) { protected void buttonPressed(final int buttonId) {
super.buttonPressed(buttonId); super.buttonPressed(buttonId);
if (buttonId == CREATE_AND_NEW_ID) { if (buttonId == CREATE_AND_NEW_ID && getWizard().performFinish()) {
if (getWizard().performFinish()) {
close(); close();
Display.getDefault().asyncExec(() -> actionOnFinishAndAdd()); Display.getDefault().asyncExec(this::actionOnFinishAndAdd);
}
} }
} }
......
...@@ -16,7 +16,6 @@ package org.bonitasoft.studio.data.ui.wizard; ...@@ -16,7 +16,6 @@ package org.bonitasoft.studio.data.ui.wizard;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
...@@ -80,7 +79,6 @@ public class DataWizardTest { ...@@ -80,7 +79,6 @@ public class DataWizardTest {
doReturn(workingCopy).when(wizard).getWorkingCopy(); doReturn(workingCopy).when(wizard).getWorkingCopy();
doReturn(wizardContainer).when(wizard).getContainer(); doReturn(wizardContainer).when(wizard).getContainer();
doReturn(true).when(wizard).isEdited(workingCopy); doReturn(true).when(wizard).isEdited(workingCopy);
doNothing().when(wizard).refreshXtextReferences();
} }
@Test @Test
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
package org.bonitasoft.studio.data.ui.property.section; package org.bonitasoft.studio.data.ui.property.section;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -25,6 +26,7 @@ import org.bonitasoft.studio.common.jface.DataStyledTreeLabelProvider; ...@@ -25,6 +26,7 @@ import org.bonitasoft.studio.common.jface.DataStyledTreeLabelProvider;
import org.bonitasoft.studio.common.jface.SWTBotConstants; import org.bonitasoft.studio.common.jface.SWTBotConstants;
import org.bonitasoft.studio.common.log.BonitaStudioLog; import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.properties.AbstractBonitaDescriptionSection; import org.bonitasoft.studio.common.properties.AbstractBonitaDescriptionSection;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.widgets.GTKStyleHandler; import org.bonitasoft.studio.common.widgets.GTKStyleHandler;
import org.bonitasoft.studio.data.DataPlugin; import org.bonitasoft.studio.data.DataPlugin;
import org.bonitasoft.studio.data.commands.MoveDataCommand; import org.bonitasoft.studio.data.commands.MoveDataCommand;
...@@ -46,6 +48,8 @@ import org.eclipse.core.databinding.conversion.Converter; ...@@ -46,6 +48,8 @@ import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.map.IObservableMap; import org.eclipse.core.databinding.observable.map.IObservableMap;
import org.eclipse.core.databinding.observable.set.IObservableSet; import org.eclipse.core.databinding.observable.set.IObservableSet;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.emf.databinding.EMFDataBindingContext; import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFObservables; import org.eclipse.emf.databinding.EMFObservables;
...@@ -88,6 +92,8 @@ import org.eclipse.swt.widgets.Shell; ...@@ -88,6 +92,8 @@ import org.eclipse.swt.widgets.Shell;
*/ */
public abstract class AbstractDataSection extends AbstractBonitaDescriptionSection implements IDoubleClickListener, IBonitaVariableContext, IAddData { public abstract class AbstractDataSection extends AbstractBonitaDescriptionSection implements IDoubleClickListener, IBonitaVariableContext, IAddData {
private static final String XTEXT_BUILDER_ID = "org.eclipse.xtext.ui.shared.xtextBuilder";
private Button updateDataButton; private Button updateDataButton;
private Button removeDataButton; private Button removeDataButton;
...@@ -282,6 +288,17 @@ public abstract class AbstractDataSection extends AbstractBonitaDescriptionSecti ...@@ -282,6 +288,17 @@ public abstract class AbstractDataSection extends AbstractBonitaDescriptionSecti
wizard.setIsOverviewContext(isOverViewContext()); wizard.setIsOverviewContext(isOverViewContext());
if (new DataWizardDialog(Display.getCurrent().getActiveShell(), wizard, this).open() == Dialog.OK) { if (new DataWizardDialog(Display.getCurrent().getActiveShell(), wizard, this).open() == Dialog.OK) {
dataTableViewer.refresh(); dataTableViewer.refresh();
refreshXtextReferences();
}
}
protected void refreshXtextReferences() {
try {
RepositoryManager.getInstance().getCurrentRepository().getProject()
.build(IncrementalProjectBuilder.FULL_BUILD, XTEXT_BUILDER_ID, Collections.<String, String> emptyMap(),
null);
} catch (final CoreException e) {
BonitaStudioLog.error(e, DataPlugin.PLUGIN_ID);
} }
} }
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
package org.bonitasoft.studio.data.ui.wizard; package org.bonitasoft.studio.data.ui.wizard;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
...@@ -25,8 +24,6 @@ import org.bonitasoft.studio.common.IBonitaVariableContext; ...@@ -25,8 +24,6 @@ import org.bonitasoft.studio.common.IBonitaVariableContext;
import org.bonitasoft.studio.common.emf.tools.EMFModelUpdater; import org.bonitasoft.studio.common.emf.tools.EMFModelUpdater;
import org.bonitasoft.studio.common.emf.tools.ModelHelper; import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.log.BonitaStudioLog; import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.data.DataPlugin;
import org.bonitasoft.studio.data.i18n.Messages; import org.bonitasoft.studio.data.i18n.Messages;
import org.bonitasoft.studio.model.process.Activity; import org.bonitasoft.studio.model.process.Activity;
import org.bonitasoft.studio.model.process.Data; import org.bonitasoft.studio.model.process.Data;
...@@ -36,9 +33,7 @@ import org.bonitasoft.studio.model.process.ProcessPackage; ...@@ -36,9 +33,7 @@ import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.pics.Pics; import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.refactoring.core.RefactorDataOperation; import org.bonitasoft.studio.refactoring.core.RefactorDataOperation;
import org.bonitasoft.studio.refactoring.core.RefactoringOperationType; import org.bonitasoft.studio.refactoring.core.RefactoringOperationType;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.command.AddCommand; import org.eclipse.emf.edit.command.AddCommand;
...@@ -76,8 +71,6 @@ public class DataWizard extends Wizard implements IBonitaVariableContext { ...@@ -76,8 +71,6 @@ public class DataWizard extends Wizard implements IBonitaVariableContext {
private EMFModelUpdater<Data> dataUpdater; private EMFModelUpdater<Data> dataUpdater;
private static final String XTEXT_BUILDER_ID = "org.eclipse.xtext.ui.shared.xtextBuilder";
public DataWizard(final TransactionalEditingDomain editingDomain, final EObject container, final EStructuralFeature dataContainmentFeature, public DataWizard(final TransactionalEditingDomain editingDomain, final EObject container, final EStructuralFeature dataContainmentFeature,
final Set<EStructuralFeature> featureToCheckForUniqueID, final Set<EStructuralFeature> featureToCheckForUniqueID,
final boolean showAutogenerateForm) { final boolean showAutogenerateForm) {
...@@ -204,7 +197,6 @@ public class DataWizard extends Wizard implements IBonitaVariableContext { ...@@ -204,7 +197,6 @@ public class DataWizard extends Wizard implements IBonitaVariableContext {
if (page != null) { if (page != null) {
page.setWorkingCopy(createWorkingCopy(container)); page.setWorkingCopy(createWorkingCopy(container));
} }
refreshXtextReferences();
return true; return true;
} }
...@@ -217,15 +209,6 @@ public class DataWizard extends Wizard implements IBonitaVariableContext { ...@@ -217,15 +209,6 @@ public class DataWizard extends Wizard implements IBonitaVariableContext {
.equals(workingCopy.getDataType())); .equals(workingCopy.getDataType()));
} }
protected void refreshXtextReferences() {
try {
RepositoryManager.getInstance().getCurrentRepository().getProject()
.build(IncrementalProjectBuilder.FULL_BUILD, XTEXT_BUILDER_ID, Collections.<String, String> emptyMap(), null);
} catch (final CoreException e) {
BonitaStudioLog.error(e, DataPlugin.PLUGIN_ID);
}
}
protected RefactorDataOperation createRefactorOperation(final TransactionalEditingDomain editingDomain, final Data workingCopy) { protected RefactorDataOperation createRefactorOperation(final TransactionalEditingDomain editingDomain, final Data workingCopy) {
final RefactorDataOperation op = new RefactorDataOperation(RefactoringOperationType.UPDATE); final RefactorDataOperation op = new RefactorDataOperation(RefactoringOperationType.UPDATE);
op.setEditingDomain(editingDomain); op.setEditingDomain(editingDomain);
......
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