Commit 15dc8335 authored by Adrien's avatar Adrien Committed by Romain Bioteau
Browse files

feat(project explorer) import / export actor filters from explorer (#1407)

* Import is only available on the impl folder
* Export from the impl folder -> all implementations are available
* Export from a given impl -> Only this impl is available
* Export from a given def -> all the impl of this def are available

closes [BS-18977](https://bonitasoft.atlassian.net/browse/BS-18977)
parent 32b2ec17
......@@ -458,6 +458,70 @@
</and>
</activeWhen>
</handler>
<handler
class="org.bonitasoft.studio.actors.ui.handler.ImportActorFilterHandler"
commandId="org.bonitasoft.studio.application.import">
<activeWhen>
<and>
<count
value="1">
</count>
<iterate>
<test
property="org.bonitasoft.studio.actors.isActorFilterImplFolder">
</test>
</iterate>
</and>
</activeWhen>
</handler>
<handler
class="org.bonitasoft.studio.actors.ui.handler.ExportActorFilterHandler"
commandId="org.bonitasoft.studio.application.export">
<activeWhen>
<and>
<count
value="1">
</count>
<iterate>
<test
property="org.bonitasoft.studio.actors.isActorFilterImplFolder">
</test>
</iterate>
</and>
</activeWhen>
</handler>
<handler
class="org.bonitasoft.studio.actors.ui.handler.ExportSingleActorFilterHandler"
commandId="org.bonitasoft.studio.application.export">
<activeWhen>
<and>
<count
value="1">
</count>
<iterate>
<test
property="org.bonitasoft.studio.actors.isActorFilterImplFile">
</test>
</iterate>
</and>
</activeWhen>
</handler>
<handler
class="org.bonitasoft.studio.actors.ui.handler.ExportActorFilterFromDefinitionHandler"
commandId="org.bonitasoft.studio.application.export">
<activeWhen>
<and>
<count
value="1">
</count>
<iterate>
<test
property="org.bonitasoft.studio.actors.isActorFilterDefFile">
</test>
</iterate>
</and>
</activeWhen>
</handler>
</extension>
<extension
id="org.bonitasoft.studio.actors.fragment"
......
/**
* Copyright (C) 2018 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.actors.ui.handler;
import org.bonitasoft.studio.actors.repository.ActorFilterDefFileStore;
import org.bonitasoft.studio.actors.ui.wizard.ExportActorFilterWizard;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.common.repository.filestore.FileStoreFinder;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
public class ExportActorFilterFromDefinitionHandler extends AbstractHandler {
private RepositoryAccessor repositoryAccessor;
private FileStoreFinder fileStoreFinder;
public ExportActorFilterFromDefinitionHandler() {
repositoryAccessor = new RepositoryAccessor();
repositoryAccessor.init();
fileStoreFinder = new FileStoreFinder();
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
fileStoreFinder.findSelectedFileStore(repositoryAccessor.getCurrentRepository())
.filter(ActorFilterDefFileStore.class::isInstance)
.map(ActorFilterDefFileStore.class::cast)
.map(ActorFilterDefFileStore::getContent)
.ifPresent(def -> {
WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(),
new ExportActorFilterWizard(def));
dialog.open();
});
return null;
}
}
/**
* Copyright (C) 2018 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.actors.ui.handler;
import org.bonitasoft.studio.actors.repository.ActorFilterImplFileStore;
import org.bonitasoft.studio.actors.ui.wizard.ExportActorFilterWizard;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.common.repository.filestore.FileStoreFinder;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
public class ExportSingleActorFilterHandler extends AbstractHandler {
private RepositoryAccessor repositoryAccessor;
private FileStoreFinder fileStoreFinder;
public ExportSingleActorFilterHandler() {
repositoryAccessor = new RepositoryAccessor();
repositoryAccessor.init();
fileStoreFinder = new FileStoreFinder();
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
fileStoreFinder
.findSelectedFileStore(repositoryAccessor.getCurrentRepository())
.filter(ActorFilterImplFileStore.class::isInstance)
.map(ActorFilterImplFileStore.class::cast)
.map(ActorFilterImplFileStore::getContent)
.ifPresent(impl -> {
WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(),
new ExportActorFilterWizard(impl));
dialog.open();
});
return null;
}
}
/**
* Copyright (C) 2009 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
* 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.actors.ui.wizard;
......@@ -23,46 +20,55 @@ import org.bonitasoft.studio.actors.repository.ActorFilterDefRepositoryStore;
import org.bonitasoft.studio.actors.repository.ActorFilterImplRepositoryStore;
import org.bonitasoft.studio.actors.repository.ExportActorFilterArchiveOperation;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.store.AbstractRepositoryStore;
import org.bonitasoft.studio.common.repository.model.IRepositoryStore;
import org.bonitasoft.studio.connector.model.definition.ConnectorDefinition;
import org.bonitasoft.studio.connector.model.definition.IDefinitionRepositoryStore;
import org.bonitasoft.studio.connector.model.implementation.ConnectorImplementation;
import org.bonitasoft.studio.connector.model.implementation.provider.ConnectorImplementationContentProvider;
import org.bonitasoft.studio.connector.model.implementation.provider.ConnectorImplementationLabelProvider;
import org.bonitasoft.studio.connectors.ui.wizard.ExportConnectorWizard;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
/**
* @author Romain Bioteau
*
*/
public class ExportActorFilterWizard extends ExportConnectorWizard {
public ExportActorFilterWizard() {
super();
setWindowTitle(Messages.exportActorFilterTitle);
}
public ExportActorFilterWizard(ConnectorImplementation connectorToExport) {
super(connectorToExport);
setWindowTitle(Messages.exportActorFilterTitle);
}
public ExportActorFilterWizard(){
super() ;
public ExportActorFilterWizard(ConnectorDefinition connectorDefToExport) {
super(connectorDefToExport);
setWindowTitle(Messages.exportActorFilterTitle);
}
@Override
protected ExportActorFilterArchiveOperation createExportOperation(ConnectorImplementation impl,boolean addSources,boolean addDependencies,String targetPath){
protected ExportActorFilterArchiveOperation createExportOperation(ConnectorImplementation impl, boolean addSources,
boolean addDependencies, String targetPath) {
final ExportActorFilterArchiveOperation operation = new ExportActorFilterArchiveOperation();
operation.setImplementation(impl) ;
operation.setIncludeSources(addSources) ;
operation.setTargetPath(targetPath) ;
operation.setAddDependencies(addDependencies) ;
return operation ;
operation.setImplementation(impl);
operation.setIncludeSources(addSources);
operation.setTargetPath(targetPath);
operation.setAddDependencies(addDependencies);
return operation;
}
@Override
protected LabelProvider getLabelProvider() {
return new ConnectorImplementationLabelProvider((IDefinitionRepositoryStore)RepositoryManager.getInstance().getRepositoryStore(ActorFilterDefRepositoryStore.class),ActorsPlugin.getDefault().getBundle());
return new ConnectorImplementationLabelProvider(
RepositoryManager.getInstance().getRepositoryStore(ActorFilterDefRepositoryStore.class),
ActorsPlugin.getDefault().getBundle());
}
@Override
protected IContentProvider getContentProvider() {
return new ConnectorImplementationContentProvider((AbstractRepositoryStore)RepositoryManager.getInstance().getRepositoryStore(ActorFilterImplRepositoryStore.class),false);
protected IRepositoryStore getRepositoryStore() {
return RepositoryManager.getInstance().getRepositoryStore(ActorFilterImplRepositoryStore.class);
}
@Override
......@@ -74,10 +80,10 @@ public class ExportActorFilterWizard extends ExportConnectorWizard {
protected String getPageTitle() {
return Messages.selectFilterImplementationToExportTitle;
}
@Override
protected IDefinitionRepositoryStore getDefRepositoryStore(){
return (IDefinitionRepositoryStore)RepositoryManager.getInstance().getRepositoryStore(ActorFilterDefRepositoryStore.class);
protected IDefinitionRepositoryStore getDefRepositoryStore() {
return RepositoryManager.getInstance().getRepositoryStore(ActorFilterDefRepositoryStore.class);
}
}
......@@ -82,12 +82,11 @@ public class ExportConnectorWizard extends Wizard {
@SuppressWarnings({ "rawtypes", "unchecked" })
protected IContentProvider getContentProvider() {
IRepositoryStore repositoryStore = getRepositoryStore();
if (connectorImplToExport.isPresent()) {
return (IStructuredContentProvider) inputElement -> new ConnectorImplementation[] {
connectorImplToExport.get() };
}
IRepositoryStore repositoryStore = RepositoryManager.getInstance()
.getRepositoryStore(ConnectorImplRepositoryStore.class);
if (connectorDefToExport.isPresent()) {
ConnectorDefinition definition = connectorDefToExport.get();
return new ConnectorImplementationContentProvider(repositoryStore, definition.getId(),
......@@ -96,6 +95,10 @@ public class ExportConnectorWizard extends Wizard {
return new ConnectorImplementationContentProvider(repositoryStore, false);
}
protected IRepositoryStore getRepositoryStore() {
return RepositoryManager.getInstance().getRepositoryStore(ConnectorImplRepositoryStore.class);
}
protected String getPageDescription() {
return Messages.selectConnectorImplementationToExportDesc;
}
......
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