Commit 5ad4bcbd authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

feat(v6FormsRemoval) remove 6.x Application view (#1209)

* remove view and related properties
* remove associated tests

Closes BS-18461
parent ca7d2fb2
......@@ -182,13 +182,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
version="0.0.0"
unpack="false"/>
<plugin
id="org.bonitasoft.studio.diagram.form.properties"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.bonitasoft.studio.importer"
download-size="0"
......
......@@ -481,14 +481,6 @@
name="%overviewViewName"
restorable="true">
</view>
<view
category="org.bonitasoft.studio.application.bonita"
class="org.bonitasoft.studio.application.views.process.BonitaApplicationPropertiesView"
icon="icons/menuIcons/form.png"
id="org.bonitasoft.studio.views.properties.application"
name="%Application"
restorable="true">
</view>
<view
category="org.bonitasoft.studio.application.bonita"
class="org.bonitasoft.studio.application.views.process.BonitaGeneralProcessPropertiesView"
......@@ -497,14 +489,6 @@
name="%General_process"
restorable="true">
</view>
<view
category="org.bonitasoft.studio.application.bonita"
class="org.bonitasoft.studio.application.views.form.BonitaGeneralFormPropertiesView"
icon="icons/details.png"
id="org.bonitasoft.studio.views.properties.form.general"
name="%General_form"
restorable="true">
</view>
<view
category="org.bonitasoft.studio.application.bonita"
class="org.bonitasoft.studio.application.views.form.BonitaAppearancePropertiesView"
......
......@@ -32,14 +32,12 @@ import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.diagram.custom.repository.DiagramFileStore;
import org.bonitasoft.studio.diagram.custom.repository.DiagramRepositoryStore;
import org.bonitasoft.studio.model.form.Form;
import org.bonitasoft.studio.model.form.FormPackage;
import org.bonitasoft.studio.model.process.MainProcess;
import org.bonitasoft.studio.model.process.diagram.form.part.FormDiagramEditor;
import org.bonitasoft.studio.model.process.diagram.part.ProcessDiagramEditor;
import org.bonitasoft.studio.preferences.BonitaPreferenceConstants;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
import org.bonitasoft.studio.properties.operation.RenameDiagramOperation;
import org.bonitasoft.studio.properties.sections.forms.FormsUtils;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.URI;
......@@ -65,7 +63,6 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.handlers.SaveHandler;
import org.eclipse.ui.progress.IProgressService;
......@@ -111,7 +108,6 @@ public class SaveCommandHandler extends SaveHandler {
}
protected void doSaveDiagram(final DiagramEditor editorPart) {
String formName = null;
boolean changed = false;
final DiagramRepositoryStore diagramStore = RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class);
final MainProcess proc = findProc(editorPart);
......@@ -122,12 +118,6 @@ public class SaveCommandHandler extends SaveHandler {
editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
final IEditorInput editorInput = editorPart.getEditorInput();
final ResourceSet resourceSet = proc.eResource().getResourceSet();
final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor instanceof FormDiagramEditor) {
editorsWithSameResourceSet.add((DiagramDocumentEditor) editor);
formName = ((FormDiagramEditor) editor).getPartName();
}
maintainListOfEditorsWithSameResourceSet(editorsWithSameResourceSet, editorReferences, editorInput, resourceSet);
oldArtifact = diagramStore.getChild(NamingUtils.toDiagramFilename(getOldProcess(proc)));
changed = true;
......@@ -144,11 +134,7 @@ public class SaveCommandHandler extends SaveHandler {
diagramDocumentEditor.close(true);
}
oldArtifact.rename(NamingUtils.toDiagramFilename(proc));
final IWorkbenchPart newEditorOfDiagram = oldArtifact.open();
final List<EObject> forms = openDiagramsForFormsId(oldArtifact, formIds);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().bringToTop(newEditorOfDiagram);
openFormDiagramWithNameIfInList(formName, forms);
oldArtifact.open();
} else {
final EObject root = editorPart.getDiagramEditPart().resolveSemanticElement();
final Resource res = root.eResource();
......@@ -168,31 +154,6 @@ public class SaveCommandHandler extends SaveHandler {
}
}
private void openFormDiagramWithNameIfInList(final String formName,
final List<EObject> forms) {
if (formName != null) {
for (final EObject form : forms) {
if (form instanceof Form && ((Form) form).getName().equals(formName)) {
FormsUtils.openDiagram((Form) form, null);
break;
}
}
}
}
private List<EObject> openDiagramsForFormsId(final DiagramFileStore oldArtifact,
final Set<String> formIds) {
final MainProcess diagram = oldArtifact.getContent();
final List<EObject> forms = ModelHelper.getAllItemsOfType(diagram, FormPackage.Literals.FORM);
for (final EObject form : forms) {
final String id = ModelHelper.getEObjectID(form);
if (formIds.contains(id)) {
//TODO: find a way to just open the diagram without bringing them to top and make the UI blinking
FormsUtils.openDiagram((Form) form, null);
}
}
return forms;
}
private MainProcess findProc(final IEditorPart editorPart) {
MainProcess proc = null;
......
/**
* Copyright (C) 2010 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.application.views.form;
import org.bonitasoft.studio.application.views.BonitaPropertiesView;
import org.bonitasoft.studio.common.views.BonitaPropertiesBrowserPage;
import org.bonitasoft.studio.diagram.form.custom.part.BonitaGeneralFormPropertiesBrowserPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
/**
* @author Aurelien Pupier
*/
public class BonitaGeneralFormPropertiesView extends BonitaPropertiesView {
public static final String VIEW_ID = "org.bonitasoft.studio.views.properties.form.general";
protected String getViewId() {
return VIEW_ID;
}
@Override
protected BonitaPropertiesBrowserPage getBonitaPropertiesBrowserPage(
ITabbedPropertySheetPageContributor part) {
return new BonitaGeneralFormPropertiesBrowserPage(part);
}
}
/**
* Copyright (C) 2010 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.application.views.process;
import org.bonitasoft.studio.application.views.BonitaPropertiesView;
import org.bonitasoft.studio.common.views.BonitaPropertiesBrowserPage;
import org.bonitasoft.studio.diagram.custom.part.BonitaApplicationPropertiesBrowserPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
/**
* @author Aurelien Pupier
*/
public class BonitaApplicationPropertiesView extends BonitaPropertiesView {
public static final String VIEW_ID = "org.bonitasoft.studio.views.properties.application";
protected String getViewId() {
return VIEW_ID;
}
@Override
protected BonitaPropertiesBrowserPage getBonitaPropertiesBrowserPage(
ITabbedPropertySheetPageContributor part) {
return new BonitaApplicationPropertiesBrowserPage(part);
}
}
/**
* Copyright (C) 2015 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.tools.tree.selection.provider.process;
import static org.assertj.core.api.Assertions.assertThat;
import static org.bonitasoft.studio.model.form.builders.FileWidgetBuilder.aFileWidget;
import static org.bonitasoft.studio.model.form.builders.FormBuilder.aForm;
import static org.bonitasoft.studio.model.form.builders.ViewFormBuilder.aViewForm;
import static org.bonitasoft.studio.model.process.builders.PoolBuilder.aPool;
import static org.bonitasoft.studio.model.process.builders.TaskBuilder.aTask;
import static org.mockito.Mockito.when;
import org.eclipse.ui.IEditorReference;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class ApplicationFormTabbedPropertyProviderTest {
@Mock
private IEditorReference processEditorRef;
@Before
public void setUp() throws Exception {
when(processEditorRef.getId()).thenReturn("org.bonitasoft.studio.model.process.diagram.part.ProcessDiagramEditorID");
}
@Test
public void should_return_application_viewId() throws Exception {
final ApplicationFormTabbedPropertyProvider provider = new ApplicationFormTabbedPropertyProvider();
assertThat(provider.viewId()).isEqualTo("org.bonitasoft.studio.views.properties.application");
}
@Test
public void should_return_overview_form_tab_id_for_view_forms() throws Exception {
final ApplicationFormTabbedPropertyProvider provider = new ApplicationFormTabbedPropertyProvider();
assertThat(provider.tabId(aViewForm().build())).isEqualTo("tab.forms.overview");
}
@Test
public void should_return_entry_form_tab_id() throws Exception {
final ApplicationFormTabbedPropertyProvider provider = new ApplicationFormTabbedPropertyProvider();
assertThat(provider.tabId(null)).isEqualTo("tab.forms.entry");
}
@Test
public void should_return_tab_index_for_form_section() throws Exception {
final ApplicationFormTabbedPropertyProvider provider = new ApplicationFormTabbedPropertyProvider();
assertThat(provider.tabIndex()).isEqualTo(0);
}
@Test
public void should_appliesTo_Form() throws Exception {
final ApplicationFormTabbedPropertyProvider provider = new ApplicationFormTabbedPropertyProvider();
assertThat(provider.appliesTo(aForm().build(), processEditorRef)).isTrue();
}
@Test
public void should_appliesTo_form_child() throws Exception {
final ApplicationFormTabbedPropertyProvider provider = new ApplicationFormTabbedPropertyProvider();
assertThat(provider.appliesTo(aForm().havingWidget(aFileWidget()).in(aTask()).build().getWidgets().get(0), processEditorRef)).isTrue();
}
@Test
public void should_not_appliesTo_to_element_not_contained_in_a_form() throws Exception {
final ApplicationFormTabbedPropertyProvider provider = new ApplicationFormTabbedPropertyProvider();
assertThat(provider.appliesTo(aPool().build(), processEditorRef)).isFalse();
}
}
/**
* Copyright (C) 2015 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.tools.tree.selection.provider.process;
import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.studio.model.process.AssociatedFile;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.junit.Test;
public class AssociatedFileTabbedPropertyProviderTest {
@Test
public void should_return_application_viewId() throws Exception {
final AssociatedFileTabbedPropertyProvider provider = new AssociatedFileTabbedPropertyProvider();
assertThat(provider.viewId()).isEqualTo("org.bonitasoft.studio.views.properties.application");
}
@Test
public void should_return_looknfeel_tab_id_if_file_is_an_html_file() throws Exception {
final AssociatedFileTabbedPropertyProvider provider = new AssociatedFileTabbedPropertyProvider();
final AssociatedFile associatedFile = ProcessFactory.eINSTANCE.createAssociatedFile();
associatedFile.setPath("index.html");
assertThat(provider.tabId(associatedFile)).isEqualTo("tab.lookandfeel");
}
@Test
public void should_return_resource_tab_id_if_file_is_not_an_html_file() throws Exception {
final AssociatedFileTabbedPropertyProvider provider = new AssociatedFileTabbedPropertyProvider();
final AssociatedFile associatedFile = ProcessFactory.eINSTANCE.createAssociatedFile();
associatedFile.setPath("image.jpg");
assertThat(provider.tabId(associatedFile)).isEqualTo("tab.resource");
}
@Test
public void should_appliesTo_AssociatedFile() throws Exception {
final AssociatedFileTabbedPropertyProvider provider = new AssociatedFileTabbedPropertyProvider();
assertThat(provider.appliesTo(ProcessFactory.eINSTANCE.createAssociatedFile(), null)).isTrue();
assertThat(provider.appliesTo(null, null)).isFalse();
}
}
/**
* Copyright (C) 2015 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.tools.tree.selection.provider.process;
import static org.assertj.core.api.Assertions.assertThat;
import static org.bonitasoft.studio.model.expression.builders.ExpressionBuilder.anExpression;
import static org.bonitasoft.studio.model.process.builders.DataBuilder.aData;
import static org.bonitasoft.studio.model.process.builders.PoolBuilder.aPool;
import org.junit.Test;
public class PageflowDataTabbedPropertyProviderTest {
@Test
public void should_return_application_viewId() throws Exception {
final PageflowDataTabbedPropertyProvider provider = new PageflowDataTabbedPropertyProvider();
assertThat(provider.viewId()).isEqualTo("org.bonitasoft.studio.views.properties.application");
}
@Test
public void should_return_overview_form_tab_id_for_overview_pageflow_data() throws Exception {
final PageflowDataTabbedPropertyProvider provider = new PageflowDataTabbedPropertyProvider();
assertThat(provider.tabId(aData().inOverviewPageflow(aPool()).build())).isEqualTo("tab.forms.overview");
}
@Test
public void should_return_entry_form_tab_id_for_pageflow_data() throws Exception {
final PageflowDataTabbedPropertyProvider provider = new PageflowDataTabbedPropertyProvider();
assertThat(provider.tabId(aData().inPageflow(aPool()).build())).isEqualTo("tab.forms.entry");
}
@Test
public void should_return_tab_index_for_pageflow_data_section() throws Exception {
final PageflowDataTabbedPropertyProvider provider = new PageflowDataTabbedPropertyProvider();
assertThat(provider.tabIndex()).isEqualTo(1);
}
@Test
public void should_appliesTo_Data_in_a_Pageflow() throws Exception {
final PageflowDataTabbedPropertyProvider provider = new PageflowDataTabbedPropertyProvider();
assertThat(provider.appliesTo(aData().inPageflow(aPool()).build(), null)).isTrue();
}
@Test
public void should_appliesTo_Data_in_an_overview_Pageflow() throws Exception {
final PageflowDataTabbedPropertyProvider provider = new PageflowDataTabbedPropertyProvider();
assertThat(provider.appliesTo(aData().inOverviewPageflow(aPool()).build(), null)).isTrue();
}
@Test
public void should_appliesTo__Data_child_in_a_Pageflow() throws Exception {
final PageflowDataTabbedPropertyProvider provider = new PageflowDataTabbedPropertyProvider();
assertThat(provider.appliesTo(aData().havingDefaultValue(anExpression()).inPageflow(aPool()).build().getDefaultValue(), null)).isTrue();
}
@Test
public void should_not_appliesTo_to_process_data() throws Exception {
final PageflowDataTabbedPropertyProvider provider = new PageflowDataTabbedPropertyProvider();
assertThat(provider.appliesTo(aData().in(aPool()).build(), null)).isFalse();
}
@Test
public void should_not_appliesTo_to_element_not_contained_in_a_data_pageflow() throws Exception {
final PageflowDataTabbedPropertyProvider provider = new PageflowDataTabbedPropertyProvider();
assertThat(provider.appliesTo(aPool().build(), null)).isFalse();
}
}
/**
* Copyright (C) 2015 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.tools.tree.selection.provider.process;
import static org.assertj.core.api.Assertions.assertThat;
import static org.bonitasoft.studio.model.expression.builders.ExpressionBuilder.anExpression;
import static org.bonitasoft.studio.model.process.builders.PageflowTransitionBuilder.aPageflowTransition;
import static org.bonitasoft.studio.model.process.builders.PoolBuilder.aPool;
import org.junit.Test;
public class PageflowTransitionTabbedPropertyProviderTest {
@Test
public void should_return_application_viewId() throws Exception {
final PageflowTransitionTabbedPropertyProvider provider = new PageflowTransitionTabbedPropertyProvider();
assertThat(provider.viewId()).isEqualTo("org.bonitasoft.studio.views.properties.application");
}
@Test
public void should_return_overview_form_tab_id_for_overview_pageflow_transition() throws Exception {
final PageflowTransitionTabbedPropertyProvider provider = new PageflowTransitionTabbedPropertyProvider();
assertThat(provider.tabId(aPageflowTransition().inOverview(aPool()).build())).isEqualTo("tab.forms.overview");
}
@Test