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

fix(svn) fix explorer support with svn

parent 99c87eb3
......@@ -16,7 +16,6 @@ import org.eclipse.ui.internal.IObjectContributor;
import org.eclipse.ui.internal.ObjectActionContributor;
import org.eclipse.ui.internal.ObjectActionContributorManager;
@SuppressWarnings("restriction")
public class CustomObjectActionContributorManager extends ObjectActionContributorManager {
private static final String MAVEN_PROJECT_MENU_ID = "org.eclipse.m2e.core.projectMenu";
......@@ -32,6 +31,7 @@ public class CustomObjectActionContributorManager extends ObjectActionContributo
private static final String COMPARE_ACTIONS_ID = "org.eclipse.compare.CompareAction";
private static final String REPLACE_WITH_EDITION_ID = "org.eclipse.compare.ReplaceWithEditionAction";
private static final String COMPARE_WITH_EDITION_ID = "org.eclipse.compare.CompareWithEditionAction";
private static final String SVN_ACTION_ID_PREFIX = "org.eclipse.team.svn.ui";
private static CustomObjectActionContributorManager sharedInstance;
......@@ -61,7 +61,7 @@ public class CustomObjectActionContributorManager extends ObjectActionContributo
public void registerContributor(IObjectContributor contributor, String targetType) {
if (contributor instanceof ObjectActionContributor) {
String id = ((ObjectActionContributor) contributor).getAdapter(IConfigurationElement.class).getAttribute("id");
if (getActions().contains(id)) {
if (getActions().contains(id) || id.startsWith(SVN_ACTION_ID_PREFIX)) {
super.registerContributor(contributor, targetType);
}
}
......
......@@ -94,7 +94,7 @@ public class BonitaExplorerLabelProvider extends JavaNavigatorLabelProvider {
private IRepositoryFileStore asFileStore(Object element, RepositoryManager repositoryManager) {
try {
if (element instanceof IResource) {
if (element instanceof IResource && ((IResource) element).getLocation() != null) {
return repositoryManager.getCurrentRepository()
.asRepositoryFileStore(((IResource) element).getLocation().toFile().toPath(), false);
}
......
......@@ -709,6 +709,11 @@ public class Repository implements IRepository, IJavaContainer {
@Override
public void migrate(final IProgressMonitor monitor) throws CoreException, MigrationException {
Assert.isNotNull(project);
IFolder settings = project.getFolder(".settings");
if (settings.exists()) {
settings.delete(true, null);
}
for (final IRepositoryStore<?> store : getAllStores()) {
store.createRepositoryStore(this);
store.migrate(monitor);
......@@ -743,8 +748,8 @@ public class Repository implements IRepository, IJavaContainer {
protected BonitaBPMProjectMigrationOperation newProjectMigrationOperation(final IProject project) {
return new BonitaBPMProjectMigrationOperation(project, this)
.addNature(BonitaProjectNature.NATURE_ID)
.addNature("org.eclipse.xtext.ui.shared.xtextNature")
.addNature("org.bonitasoft.studio.common.repository.bonitaNature")
.addNature(JavaCore.NATURE_ID)
.addNature("org.eclipse.pde.PluginNature")
.addNature("org.eclipse.jdt.groovy.core.groovyNature")
......
......@@ -14,7 +14,9 @@
*/
package org.bonitasoft.studio.common.repository.core;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bonitasoft.studio.common.ProductVersion;
......@@ -30,8 +32,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
public class BonitaBPMProjectMigrationOperation implements IWorkspaceRunnable {
private final IProject project;
private final Set<String> builders = new HashSet<String>();
private final Set<String> natures = new HashSet<String>();
private final Set<String> builders = new HashSet<>();
private final List<String> natures = new ArrayList<>();
private final Repository repository;
public BonitaBPMProjectMigrationOperation(final IProject project, final Repository repository) {
......
......@@ -19,10 +19,9 @@ import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.Socket;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.file.Path;
......@@ -61,6 +60,8 @@ import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.SocketUtil;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.restlet.resource.ClientResource;
import org.restlet.resource.ResourceException;
import com.google.common.base.Joiner;
......@@ -74,6 +75,7 @@ public class UIDesignerServerManager {
private int portalPort;
private static final String BONITA_CLIENT_HOME = "bonita.client.home";
private static final String PORTAL_BASE_URL = "bonita.portal.origin";
private static final int MAX_TIMEOUT = 60000;
private PageDesignerURLFactory pageDesignerURLBuilder;
private UIDesignerServerManager(RepositoryAccessor repositoryAccessor) {
......@@ -149,28 +151,18 @@ public class UIDesignerServerManager {
protected boolean waitForUID(final PageDesignerURLFactory pageDesignerURLBuilder) {
try {
connectToURL(pageDesignerURLBuilder.openPageDesignerHome());
} catch (MalformedURLException e) {
} catch (ResourceException | URISyntaxException | MalformedURLException e) {
return false;
}
return true;
}
private void connectToURL(final URL url) {
try {
final HttpURLConnection connection = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
connection.setRequestMethod("HEAD");
connection.setReadTimeout(200);
final int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
connectToURL(url);
}
} catch (final IOException e) {
try {
Thread.sleep(500);
} catch (final InterruptedException e1) {
}
connectToURL(url);
}
private void connectToURL(final URL url) throws URISyntaxException {
ClientResource cr = new ClientResource(url.toURI());
cr.setRetryOnError(true);
cr.setRetryDelay(500);
cr.setRetryAttempts(120);
cr.get();
}
private Path logLocation() {
......
......@@ -62,7 +62,6 @@ import org.bonitasoft.studio.tests.importer.extensions.TestImportExtensionPoint;
import org.bonitasoft.studio.tests.importer.jpdl.TestJBPMImport;
import org.bonitasoft.studio.tests.migration.DocumentMigrationIT;
import org.bonitasoft.studio.tests.migration.EdaptHistoryIT;
import org.bonitasoft.studio.tests.migration.MigrationReportPDFExportTest;
import org.bonitasoft.studio.tests.parameter.TestParametersRefactoring;
import org.bonitasoft.studio.tests.parameter.TestProcessParameters;
import org.bonitasoft.studio.tests.processzoo.TestProcessZoo;
......@@ -131,7 +130,6 @@ import org.junit.runners.Suite;
TestNonInterruptingBoundaryTimerEvent.class,
TestUserFilterMatchingEngineVersion.class,
TestDeployCommand.class,
MigrationReportPDFExportTest.class,
TestValidationConstraints.class,
TestTestConnectorOperation.class,
TestWebserviceVersionForBPMNImport.class,
......
......@@ -72,7 +72,6 @@ import org.bonitasoft.studio.tests.expressionEditor.TestConnectorExpression;
import org.bonitasoft.studio.tests.expressionEditor.TestPatternExpressionViewer;
import org.bonitasoft.studio.tests.groovy.TestBonitaGroovyEditorDialog;
import org.bonitasoft.studio.tests.iteration.MultiInstantiationIT;
import org.bonitasoft.studio.tests.migration.MigrationReporTest;
import org.bonitasoft.studio.tests.processzoo.examples.TestWebPurchase;
import org.bonitasoft.studio.tests.properties.CallActivityMappingIT;
import org.bonitasoft.studio.tests.properties.TestConditionExpression;
......@@ -135,7 +134,6 @@ import org.junit.runners.Suite;
DuplicateCommandTest.class,
TestSave.class,
TestMoveBetweenLane.class,
MigrationReporTest.class,
TestTimer.class,
ConnectorEditedInAsingleCommandIT.class,
ProcessDependenciesConfigurationIT.class,
......
/**
* 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.tests.migration;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import org.bonitasoft.studio.common.ModelVersion;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.diagram.custom.repository.DiagramRepositoryStore;
import org.eclipse.emf.edapt.migration.execution.Migrator;
import org.eclipse.emf.edapt.spi.history.Release;
import org.junit.Test;
public class DiagramRepositoryStoreMigrationTest {
@Test
public void testLatestVersionIsSameThanModelVersion() {
final DiagramRepositoryStore store = RepositoryManager.getInstance()
.getRepositoryStore(DiagramRepositoryStore.class);
final Migrator migrator = store.initializeMigrator();
final String latestReleaseLabel = getLatestRelease(migrator).getLabel();
assertThat(latestReleaseLabel).isEqualTo(ModelVersion.CURRENT_VERSION);
}
@Test
public void testCurrentModelVersionWontBeGoThroughMigration() {
final DiagramRepositoryStore store = RepositoryManager.getInstance()
.getRepositoryStore(DiagramRepositoryStore.class);
final Migrator migrator = store.initializeMigrator();
final String releaseForCurrentModelVersion = store.getRelease(migrator,
ModelVersion.CURRENT_VERSION).getLabel();
assertThat(releaseForCurrentModelVersion).isEqualTo(
ModelVersion.CURRENT_VERSION);
}
@Test
public void testReleaseVersionHistoryHaveCorrectFormat() {
final DiagramRepositoryStore store = RepositoryManager.getInstance()
.getRepositoryStore(DiagramRepositoryStore.class);
final Migrator migrator = store.initializeMigrator();
final String pattern = "(\\d+)\\.(\\d+)\\.(\\d+)-.*";
for (final Release release : migrator.getReleases()) {
final String releaseLabel = release.getLabel();
assertThat(releaseLabel).startsWith("6.");
assertThat(releaseLabel.matches(pattern)).isTrue();
}
}
public Release getLatestRelease(final Migrator migrator) {
final List<Release> releases = migrator.getReleases();
return releases.get(releases.size() - 1);
}
}
/**
* Copyright (C) 2012 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.tests.migration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.net.URL;
import org.bonitasoft.studio.common.jface.FileActionDialog;
import org.bonitasoft.studio.common.perspectives.BonitaPerspectivesUtils;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.diagram.custom.repository.DiagramRepositoryStore;
import org.bonitasoft.studio.importer.bos.operation.ImportBosArchiveOperation;
import org.bonitasoft.studio.migration.i18n.Messages;
import org.bonitasoft.studio.model.process.Pool;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.junit.BeforeClass;
import org.junit.Test;
public class MigrationReporTest {
private static RepositoryAccessor repositoryAccessor;
private SWTGefBot bot = new SWTGefBot();
private final DiagramRepositoryStore store = RepositoryManager.getInstance()
.getRepositoryStore(DiagramRepositoryStore.class);
@BeforeClass
public static void disablePopup() {
FileActionDialog.setDisablePopup(true);
repositoryAccessor = new RepositoryAccessor();
repositoryAccessor.init();
}
@Test
public void testAutomaticPerspectiveSwitch() throws Exception {
FileActionDialog.setDisablePopup(true);
final URL url = MigrationReporTest.class.getResource("TestMigrationReport-1.0.bos");
final ImportBosArchiveOperation op = new ImportBosArchiveOperation(repositoryAccessor);
op.setArchiveFile(FileLocator.toFileURL(url).getFile());
op.setCurrentRepository(repositoryAccessor.getCurrentRepository());
op.run(Repository.NULL_PROGRESS_MONITOR);
store.getChild("MonDiagramme1-1.0.proc").open();
assertEquals("Invalid perspective for process with migration report",
"org.bonitasoft.studio.migration.perspective.process",
BonitaPerspectivesUtils.getPerspectiveId(bot.activeEditor().getReference().getEditor(false)));
}
@Test
public void testCompleteReport() throws Exception {
FileActionDialog.setDisablePopup(true);
final URL url = MigrationReporTest.class.getResource("TestMigrationReport-1.0.bos");
final ImportBosArchiveOperation op = new ImportBosArchiveOperation(repositoryAccessor);
op.setArchiveFile(FileLocator.toFileURL(url).getFile());
op.setCurrentRepository(repositoryAccessor.getCurrentRepository());
op.run(Repository.NULL_PROGRESS_MONITOR);
store.getChild("MonDiagramme1-1.0.proc").open();
bot.viewById("org.bonitasoft.studio.migration.view").bot().button(Messages.completeImport).click();
bot.waitUntil(Conditions.shellIsActive(Messages.completeImport));
bot.checkBox().deselect();
bot.button(IDialogConstants.OK_LABEL).click();
assertEquals("Invalid perspective for process without migration report", "org.bonitasoft.studio.perspective.process",
BonitaPerspectivesUtils.getPerspectiveId(bot.activeEditor().getReference().getEditor(false)));
final EObject mainProcess = (EObject) bot.gefEditor(bot.activeEditor().getTitle()).mainEditPart().part().getModel();
assertEquals("Report model should have been deleted", 2, mainProcess.eResource().getContents().size());
}
@Test
public void testEditorSelectionSynchronization() throws Exception {
FileActionDialog.setDisablePopup(true);
final URL url = MigrationReporTest.class.getResource("TestMigrationReport-1.0.bos");
final ImportBosArchiveOperation op = new ImportBosArchiveOperation(repositoryAccessor);
op.setArchiveFile(FileLocator.toFileURL(url).getFile());
op.setCurrentRepository(repositoryAccessor.getCurrentRepository());
op.run(Repository.NULL_PROGRESS_MONITOR);
store.getChild("MonDiagramme1-1.0.proc").open();
bot.viewById("org.bonitasoft.studio.migration.view").toolbarToggleButton("Link with Editor").select();
bot.table().select(1);
final SWTBotGefEditPart part = bot.gefEditor(bot.activeEditor().getTitle()).selectedEditParts().get(0);
assertTrue(((IGraphicalEditPart) part.part()).resolveSemanticElement() instanceof Pool);
}
}
/**
* Copyright (C) 2012 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.tests.migration;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.net.URL;
import org.bonitasoft.studio.common.ProjectUtil;
import org.bonitasoft.studio.common.jface.FileActionDialog;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.diagram.custom.repository.DiagramRepositoryStore;
import org.bonitasoft.studio.importer.bos.operation.ImportBosArchiveOperation;
import org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter;
import org.eclipse.core.runtime.FileLocator;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* @author Romain Bioteau
*/
public class MigrationReportPDFExportTest {
private static RepositoryAccessor repositoryAccessor;
@BeforeClass
public static void disablePopup() {
FileActionDialog.setDisablePopup(true);
repositoryAccessor = new RepositoryAccessor();
repositoryAccessor.init();
}
@Test
public void testExportAsPDF() throws Exception {
FileActionDialog.setDisablePopup(true);
final URL url = MigrationReportPDFExportTest.class.getResource("TestMigrationReport-1.0.bos");
ImportBosArchiveOperation op = new ImportBosArchiveOperation(repositoryAccessor);
op.setArchiveFile(FileLocator.toFileURL(url).getFile());
op.setCurrentRepository(repositoryAccessor.getCurrentRepository());
op.run(Repository.NULL_PROGRESS_MONITOR);
DiagramRepositoryStore store = repositoryAccessor.getRepositoryStore(DiagramRepositoryStore.class);
final PDFMigrationReportWriter writer = new PDFMigrationReportWriter(
store.getDiagram("MonDiagramme1", "1.0").getMigrationReport());
final File targetFile = new File(
ProjectUtil.getBonitaStudioWorkFolder().getAbsolutePath() + File.separatorChar + "test.pdf");
targetFile.deleteOnExit();
writer.execute(targetFile.getAbsolutePath());
assertTrue(targetFile.exists());
assertTrue(targetFile.length() > 0);
}
}
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