Commit 3050e4c8 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

feat(explorer) add new menu on project (#1315)

Closes BS-18694
parent 19c3c51f
......@@ -28,3 +28,5 @@ newFilterImpl=New implementation...
editFilterDef=Edit definition...
newFilterDef=New definition...
installOrganization=Install organization
newFilterImplMenu=Actor filter definition...
newFilterDefMenu=Actor filter implementation...
\ No newline at end of file
......@@ -100,6 +100,88 @@
</command>
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new">
<command
commandId="org.bonitasoft.studio.organization.manage"
id="org.bonitasoft.studio.organization.manage.popup.menu"
label="%actors_Label"
mnemonic="O"
style="push">
<visibleWhen
checkEnabled="true">
<and>
<count
value="1">
</count>
<or>
<iterate>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.bonitasoft.studio.application.isBonitaProject">
</test>
</iterate>
</or>
</and>
</visibleWhen>
</command>
<separator
name="group1"
visible="true">
</separator>
<command
commandId="org.bonitasoft.studio.connectors.newDefinition"
label="%newFilterDefMenu"
style="push">
<visibleWhen
checkEnabled="true">
<and>
<count
value="1">
</count>
<or>
<iterate>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.bonitasoft.studio.application.isBonitaProject">
</test></iterate>
</or>
</and>
</visibleWhen>
</command>
<command
commandId="org.bonitasoft.studio.connectors.newImplementation"
label="%newFilterImplMenu"
style="push">
<visibleWhen
checkEnabled="true">
<and>
<count
value="1">
</count>
<or>
<iterate>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.bonitasoft.studio.application.isBonitaProject">
</test>
</iterate>
</or>
</and>
</visibleWhen>
</command>
<separator
name="group2"
visible="true">
</separator>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
......
......@@ -49,4 +49,5 @@ RecentlyModified=Recently modified
renameLabel=Rename diagram...
importLabel=Import
openUidLog=Bonita UI-Designer log
projectExplorer=Project explorer
\ No newline at end of file
projectExplorer=Project explorer
new=New
\ No newline at end of file
......@@ -367,6 +367,19 @@
</visibleWhen>
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.bonitasoft.studio.application.project.explorer?after=group.new">
<menu
id="org.bonitasoft.studio.application.project.explorer.new"
label="%new"
mnemonic="w">
</menu>
<separator
name="newSeparator"
visible="true">
</separator>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
......@@ -1131,5 +1144,15 @@
</selectionEnablement>
</linkHelper>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="org.bonitasoft.studio.application.views.BonitaProjectPropertyTester"
id="org.bonitasoft.studio.application.project.propertyTester"
namespace="org.bonitasoft.studio.application"
properties="isBonitaProject"
type="org.eclipse.core.resources.IResource">
</propertyTester>
</extension>
</plugin>
......@@ -93,7 +93,6 @@ public class BonitaProjectExplorer extends CommonNavigator {
new CustomPopupMenuExtender(ID, menuMgr, getSite().getSelectionProvider(), getSite().getPart(), e4Context, true);
}
protected void fillContextMenu(IMenuManager aMenuManager) {
ISelection selection = getCommonViewer().getSelection();
NavigatorActionService navigatorActionService = getNavigatorActionService();
......
package org.bonitasoft.studio.application.views;
import java.util.Objects;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.BonitaProjectNature;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
public class BonitaProjectPropertyTester extends PropertyTester {
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (receiver instanceof IProject) {
try {
return receiver instanceof IProject && ((IProject) receiver).isOpen()
&& ((IProject) receiver).hasNature(BonitaProjectNature.NATURE_ID);
} catch (CoreException e) {
BonitaStudioLog.error(e);
return false;
}
} else if (receiver instanceof IFolder && expectedValue != null) {
return receiver instanceof IFolder && Objects.equals(((IResource) receiver).getName(), expectedValue);
}
return false;
}
}
......@@ -54,7 +54,6 @@ public class CustomObjectActionContributorManager extends ObjectActionContributo
actionIds.add(COMPARE_ACTIONS_ID);
actionIds.add(REPLACE_WITH_EDITION_ID);
actionIds.add(COMPARE_WITH_EDITION_ID);
actionIds.add(ADD_FROM_HISTORY_ID);
}
return actionIds;
}
......
......@@ -75,10 +75,6 @@ public class CustomPopupMenuExtender implements IMenuListener2,
private static Set<String> INCLUDES = new HashSet<>();
static {
INCLUDES.add("team.main");
INCLUDES.add("compareWithMenu");
INCLUDES.add("replaceWithMenu");
INCLUDES.add("org.eclipse.jdt.ui.source.menu");
INCLUDES.add("org.eclipse.jdt.ui.refactoring.menu");
}
/**
......@@ -344,18 +340,28 @@ public class CustomPopupMenuExtender implements IMenuListener2,
*/
@Override
public void menuAboutToShow(IMenuManager mgr) {
INCLUDES.add("compareWithMenu");
INCLUDES.add("replaceWithMenu");
INCLUDES.add("org.eclipse.jdt.ui.source.menu");
INCLUDES.add("org.eclipse.jdt.ui.refactoring.menu");
IProject project = RepositoryManager.getInstance().getCurrentRepository().getProject();
StructuredSelection repositoryProject = new StructuredSelection(project);
ISelection selection = selProvider.getSelection();
if (repositoryProject.equals(selection)) {
return;
INCLUDES.remove("compareWithMenu");
INCLUDES.remove("replaceWithMenu");
INCLUDES.remove("org.eclipse.jdt.ui.source.menu");
INCLUDES.remove("org.eclipse.jdt.ui.refactoring.menu");
}
Object resource = ((StructuredSelection) selection).getFirstElement();
if (resource instanceof IResource) {
IProject parentProject = ((IResource) resource).getProject();
StructuredSelection structuredSelection = new StructuredSelection(parentProject);
if (structuredSelection.equals(repositoryProject)) {
return;
INCLUDES.remove("compareWithMenu");
INCLUDES.remove("replaceWithMenu");
INCLUDES.remove("org.eclipse.jdt.ui.source.menu");
INCLUDES.remove("org.eclipse.jdt.ui.refactoring.menu");
}
}
......@@ -417,8 +423,10 @@ public class CustomPopupMenuExtender implements IMenuListener2,
for (MMenuElement e : menuModel.getChildren()) {
if (!(e instanceof MMenuSeparator || INCLUDES.contains(e.getElementId())
|| e.getElementId() == null)) {
toRemove.add(e);
e.setVisible(false);
if (e.getElementId() != null && !e.getElementId().startsWith("org.bonitasoft.studio.")) {
toRemove.add(e);
e.setVisible(false);
}
}
}
menuModel.getChildren().removeAll(toRemove);
......
......@@ -65,7 +65,8 @@ Require-Bundle: org.bonitasoft.studio.engine;bundle-version="1.0.0",
org.eclipse.e4.core.commands;bundle-version="0.12.100",
org.eclipse.e4.core.contexts;bundle-version="1.6.0",
org.eclipse.e4.ui.workbench;bundle-version="1.5.0",
org.apache.commons.io;bundle-version="2.2.0"
org.apache.commons.io;bundle-version="2.2.0",
org.eclipse.core.expressions
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Import-Package: org.bonitasoft.engine.api,
......
......@@ -3,4 +3,5 @@ Export=Export...
manageBusinessObjects=Define...
createBusinessDataLabel=<a>Create a Business data...</a>
openH2Console=Browse data (h2 console)...
import=Import...
\ No newline at end of file
import=Import...
defineBDMMenu=Business Data Model...
\ No newline at end of file
......@@ -44,6 +44,41 @@
</command>
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new?after=org.bonitasoft.studio.organization.manage.popup.menu">
<separator
name="bdmSeparator"
visible="true">
</separator>
<command
commandId="org.bonitasoft.studio.businessobject.manage"
id="org.bonitasoft.studio.businessobject.manage.popup.menu"
label="%defineBDMMenu"
mnemonic="B"
style="push">
<visibleWhen>
<and>
<count
value="1">
</count>
<or>
<iterate>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.bonitasoft.studio.application.isBonitaProject">
</test>
<test
property="org.bonitasoft.studio.businessobject.bdmExists">
</test>
</iterate>
</or>
</and>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.bonitasoft.studio.bosArchiveProvider">
......@@ -87,6 +122,16 @@
uri="fragment.e4xmi">
</fragment>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="org.bonitasoft.studio.businessobject.ui.BDMPropertyTester"
id="org.bonitasoft.studio.businessobject.CheckBDMExists"
namespace="org.bonitasoft.studio.businessobject"
properties="bdmExists"
type="org.eclipse.core.resources.IProject">
</propertyTester>
</extension>
......
package org.bonitasoft.studio.businessobject.ui;
import org.bonitasoft.studio.businessobject.core.repository.BusinessObjectModelFileStore;
import org.bonitasoft.studio.businessobject.core.repository.BusinessObjectModelRepositoryStore;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.eclipse.core.expressions.PropertyTester;
public class BDMPropertyTester extends PropertyTester {
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
BusinessObjectModelRepositoryStore store = RepositoryManager.getInstance()
.getRepositoryStore(BusinessObjectModelRepositoryStore.class);
return store.getChild(BusinessObjectModelFileStore.BOM_FILENAME) == null;
}
}
......@@ -644,7 +644,12 @@ public class Repository implements IRepository, IJavaContainer {
|| Objects.equals(org.eclipse.core.runtime.Path.fromOSString(".."), resourcePath)) {
return null;
}
final IResource iResource = isFile(resourcePath) ? project.getFile(resourcePath) : project.getFolder(resourcePath);
IResource iResource = null;
try {
iResource = isFile(resourcePath) ? project.getFile(resourcePath) : project.getFolder(resourcePath);
} catch (IllegalArgumentException e) {
return null;
}
if (!iResource.exists()) {
iResource.getParent().refreshLocal(IResource.DEPTH_INFINITE, NULL_PROGRESS_MONITOR);
if (!iResource.exists()) {
......
......@@ -9,4 +9,6 @@ editConnectorImplementation=Edit implementation...
newConnectorImplementation=New implementation...
testConnector=Test connector...
editConnectorConfiguration=Edit configuration...
debugLabel=Debug
\ No newline at end of file
debugLabel=Debug
newConnectorImplementationMenu=Connector implementation...
newConnectorDefMenu=Connector definition...
\ No newline at end of file
......@@ -187,6 +187,64 @@
</visibleWhen>
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new">
<separator
name="groupConnector1"
visible="true">
</separator>
<command
commandId="org.bonitasoft.studio.connectors.newDefinition"
label="%newConnectorDefMenu"
style="push">
<visibleWhen
checkEnabled="true">
<and>
<count
value="1">
</count>
<or>
<iterate>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.bonitasoft.studio.application.isBonitaProject">
</test>
</iterate>
</or>
</and>
</visibleWhen>
</command>
<command
commandId="org.bonitasoft.studio.connectors.newImplementation"
label="%newConnectorImplementationMenu"
style="push">
<visibleWhen
checkEnabled="true">
<and>
<count
value="1">
</count>
<or>
<iterate>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.bonitasoft.studio.application.isBonitaProject">
</test>
</iterate>
</or>
</and>
</visibleWhen>
</command>
<separator
name="groupConnector2"
visible="true">
</separator>
</menuContribution>
</extension>
<extension
point="org.bonitasoft.studio.configuration.synchronizer">
......
......@@ -9,7 +9,7 @@ removingJar=Removing
informationDeleteJarTitle=Delete issue
informationDeleteJarMessage=Deletion is currently not working due to some lock issues on Windows. You should restart in order that the deletion takes effect.
search=Search
manageJarTitle=Manage jars
manageJarTitle=Manage dependencies
popUpMessage=Select needed jar files to test the connector
selectMissingJarTitle=Manage jars
zipFileIsCorrupted = Zip file is corrupted.
......
manageJars=Manage jars...
development=Development
\ No newline at end of file
manageJars=Manage dependencies...
development=Development
......@@ -50,6 +50,37 @@
</visibleWhen>
</menu>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.bonitasoft.studio.application.project.explorer?after=org.bonitasoft.studio.application.project.explorer.new">
<command
commandId="org.bonitasoft.studio.dependencies.manageJars"
id="org.bonitasoft.studio.dependencies.manageDependencies.menu"
style="push">
<visibleWhen
checkEnabled="true">
<and>
<count
value="1">
</count>
<or>
<iterate>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.bonitasoft.studio.application.isBonitaProject">
</test>
</iterate>
</or>
</and>
</visibleWhen>
</command>
<separator
name="group1"
visible="true">
</separator>
</menuContribution>
</extension>
<extension
point="org.bonitasoft.studio.common.barResourcesProvider">
......
......@@ -11,4 +11,5 @@ zoomOut=Zoom out
resetZoom=Zoom to 100%
extractSubprocess=Extract subprocess
processPerspective=Process perspective
bpmnPalette=BPMN elements
\ No newline at end of file
bpmnPalette=BPMN elements
newDiagram=Diagram
\ No newline at end of file
......@@ -359,6 +359,33 @@
style="push">
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new?before=org.bonitasoft.studio.organization.manage.popup.menu">
<command
commandId="org.bonitasoft.studio.diagram.command.newDiagram"
id="org.bonitasoft.studio.diagram.command.newDiagram.popup.menu"
mnemonic="D"
style="push">
<visibleWhen
checkEnabled="true">
<and>
<count
value="1">
</count>
<or>
<iterate>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.bonitasoft.studio.application.isBonitaProject">
</test>
</iterate></or>
</and>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
......@@ -398,7 +425,7 @@
<command
defaultHandler="org.bonitasoft.studio.diagram.custom.commands.NewDiagramCommandHandler"
id="org.bonitasoft.studio.diagram.command.newDiagram"
name="NewDiagram">
name="%newDiagram">
</command>
<command
defaultHandler="org.bonitasoft.studio.diagram.custom.commands.OpenDiagramCommandHandler"
......
......@@ -43,6 +43,32 @@
</reference>
</visibleWhen>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.bonitasoft.studio.application.project.explorer?after=org.bonitasoft.studio.dependencies.manageDependencies.menu">
<command
commandId="org.bonitasoft.studio.groovy.ui.editscripts"
style="push">
<visibleWhen
checkEnabled="true">
<and>
<count
value="1">
</count>
<or>
<iterate>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.bonitasoft.studio.application.isBonitaProject">
</test>
</iterate>
</or>
</and>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
......
......@@ -5,4 +5,5 @@ ApplicationPerspective=Application Development Perspective
deleteApplication=Delete...
exportApplication=Export...
importApplication=Import...
deployApplication=Deploy...
\ No newline at end of file
deployApplication=Deploy...
newApplicationMenu=Application descriptor...
\ No newline at end of file