Commit 947ed580 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

fix(defects) minor defects (#1487)

* Explorer npe when uid artifacts are invalid (no json descriptor)
* Fix fr l10n in git
* Fix git issue when asking to save unsaved resources on commit
* Fix issue with Salesforce connector at login
* New uipath connector verison with l10n
parent d931728b
......@@ -1312,18 +1312,39 @@
id="org.bonitasoft.studio.navigator.actions.RefactorActions"
overrides="org.eclipse.ui.navigator.resources.actions.RefactorActions">
<enablement>
<and>
<or>
<and>
<instanceof value="org.eclipse.core.resources.IProject" />
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.jdt.core.javanature" />
</and>
<instanceof value="org.eclipse.jdt.core.IJavaElement" />
<instanceof value="org.eclipse.jdt.core.IJarEntryResource" />
<instanceof value="org.eclipse.jdt.internal.ui.packageview.PackageFragmentRootContainer" />
<adapt type="java.util.Collection">
<count value="0" />
</adapt>
</or>
<and>
<instanceof
value="org.eclipse.core.resources.IProject">
</instanceof>
<test
property="org.eclipse.core.resources.projectNature"
value="org.eclipse.jdt.core.javanature">
</test>
</and>
<instanceof
value="org.eclipse.jdt.core.IJavaElement">
</instanceof>
<instanceof
value="org.eclipse.jdt.core.IJarEntryResource">
</instanceof>
<instanceof
value="org.eclipse.jdt.internal.ui.packageview.PackageFragmentRootContainer">
</instanceof>
<adapt
type="java.util.Collection">
<count
value="0">
</count>
</adapt>
</or>
<not>
<instanceof
value="org.eclipse.jdt.core.IPackageFragmentRoot">
</instanceof>
</not>
</and>
</enablement>
</actionProvider>
</navigatorContent>
......
......@@ -18,6 +18,7 @@ import org.bonitasoft.studio.common.perspectives.BonitaPerspectivesUtils;
import org.bonitasoft.studio.common.views.BonitaPropertiesBrowserPage;
import org.bonitasoft.studio.model.process.diagram.part.ProcessDiagramEditor;
import org.eclipse.core.runtime.Adapters;
import org.eclipse.ui.ISaveablePart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
......@@ -35,10 +36,11 @@ import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributo
*/
public abstract class BonitaPropertiesView extends PropertySheet implements IContributedContentsView {
/*
* (non-Javadoc)
* Method declared on PageBookView.
*/
@Override
protected ISaveablePart getSaveablePart() {
return null;
}
@Override
protected PageBookView.PageRec doCreatePage(IWorkbenchPart part) {
// Get a custom property sheet page but not if the part is also a
......@@ -75,10 +77,7 @@ public abstract class BonitaPropertiesView extends PropertySheet implements ICon
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.views.properties.PropertySheet#isImportant(org.eclipse.ui.IWorkbenchPart)
*/
@Override
protected boolean isImportant(IWorkbenchPart part) {
// Don't interfere with other property views
......
......@@ -10,14 +10,15 @@ import org.bonitasoft.studio.common.repository.model.IRepositoryStore;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Adapters;
import org.eclipse.jdt.ui.JavaElementSorter;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.ui.internal.navigator.resources.workbench.ResourceExtensionSorter;
import org.eclipse.jface.viewers.ViewerSorter;
public class ProjectExplorerViewerComparator extends ViewerComparator {
private ResourceExtensionSorter defaultSorter = new ResourceExtensionSorter();
private ViewerSorter defaultSorter = new JavaElementSorter();
private static Map<String, Integer> ORDER = new HashMap<>();
static {
ORDER.put("organizations", 1);
......
......@@ -38,4 +38,5 @@ public class BonitaGeneralProcessPropertiesView extends BonitaPropertiesView {
ITabbedPropertySheetPageContributor part) {
return new BonitaGeneralProcessPropertiesBrowserPage(part);
}
}
......@@ -26,5 +26,13 @@ public class BonitaExplorerContentProvider extends JavaNavigatorContentProvider
return super.hasChildren(element);
}
@Override
public Object[] getChildren(Object parentElement) {
if (UIDArtifactFilters.isUIDArtifact(parentElement)) {
return new Object[0];
}
return super.getChildren(parentElement);
}
}
......@@ -22,9 +22,6 @@ import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.common.repository.model.IRepositoryStore;
import org.bonitasoft.studio.designer.core.repository.WebFragmentRepositoryStore;
import org.bonitasoft.studio.designer.core.repository.WebPageRepositoryStore;
import org.bonitasoft.studio.designer.core.repository.WebWidgetRepositoryStore;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
......@@ -75,15 +72,6 @@ public class BonitaExplorerLabelProvider extends JavaNavigatorLabelProvider {
if (!repositoryManager.hasActiveRepository() || !repositoryManager.getCurrentRepository().isLoaded()) {
return super.getImage(element);
}
if (UIDArtifactFilters.isUIDArtifactFrom(element, "web_page")) {
return repositoryManager.getRepositoryStore(WebPageRepositoryStore.class).getIcon();
}
if (UIDArtifactFilters.isUIDArtifactFrom(element, "web_widgets")) {
return repositoryManager.getRepositoryStore(WebWidgetRepositoryStore.class).getIcon();
}
if (UIDArtifactFilters.isUIDArtifactFrom(element, "web_fragments")) {
return repositoryManager.getRepositoryStore(WebFragmentRepositoryStore.class).getIcon();
}
if (!(element instanceof IJavaElement)) {
if (element instanceof IResource) {
IRepositoryFileStore fileStore = repositoryManager.getCurrentRepository().getFileStore((IResource) element);
......
......@@ -53,7 +53,8 @@ public class UIDArtifactFilters {
return element instanceof IFolder
&& ((IFolder) element).getParent() != null
&& Path.fromOSString(folderName).equals(((IFolder) element).getParent().getProjectRelativePath())
&& !((IFolder) element).getName().startsWith(".");
&& !((IFolder) element).getName().startsWith(".")
&& ((IFolder) element).getFile(((IFolder) element).getName() + ".json").exists();
}
private static boolean isAUIDFolder(Object element, String folderName) {
......
......@@ -122,8 +122,8 @@ public class RepositoryTest {
IRepositoryFileStore fileStore1 = mock(IRepositoryFileStore.class);
IRepositoryFileStore fileStore2 = mock(IRepositoryFileStore.class);
when(repositoryStore1.createRepositoryFileStore("name.xml")).thenReturn(fileStore1);
when(repositoryStore2.createRepositoryFileStore("name.xml")).thenReturn(fileStore2);
when(repositoryStore1.getChild("name.xml")).thenReturn(fileStore1);
when(repositoryStore2.getChild("name.xml")).thenReturn(fileStore2);
Repository repository = newRepository();
doReturn(Arrays.asList(repositoryStore1, repositoryStore2)).when(repository).getAllStores();
......
......@@ -589,7 +589,7 @@ public class Repository implements IRepository, IJavaContainer, IRenamable {
for (final IRepositoryStore<? extends IRepositoryFileStore> store : getAllStores()) {
IFolder container = store.getResource();
if (Objects.equals(resource.getParent(), container)) {
IRepositoryFileStore fStore = store.createRepositoryFileStore(resource.getName());
IRepositoryFileStore fStore = store.getChild(resource.getName());
if (fStore != null) {
return fStore;
}
......@@ -685,7 +685,7 @@ public class Repository implements IRepository, IJavaContainer, IRenamable {
return getRepositoryStoreByName(storeName)
.filter(repositoryStore -> belongToRepositoryStore(repositoryStore, file))
.map(repositoryStore -> repositoryStore
.createRepositoryFileStore(file.getName()))
.getChild(file.getName()))
.orElse(null);
}
}
......
......@@ -210,7 +210,7 @@ public abstract class AbstractFileStore
.findView("org.bonitasoft.studio.application.project.explorer");
if (viewPart != null) {
CommonViewer viewer = viewPart.getAdapter(CommonViewer.class);
if (viewer != null) {
if (viewer != null && !viewer.getTree().isDisposed()) {
viewer.refresh(true);
}
}
......
/**
* Copyright (C) 2018 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.designer.core.repository;
import java.util.ArrayList;
import java.util.List;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.model.IRepositoryFileStore;
import org.bonitasoft.studio.common.repository.store.AbstractFolderRepositoryStore;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
public abstract class WebArtifactRepositoryStore<T extends IRepositoryFileStore> extends AbstractFolderRepositoryStore<T> {
@Override
public List<T> getChildren() {
refresh();
final List<T> result = new ArrayList<>();
final IFolder folder = getResource();
try {
for (final IResource r : folder.members()) {
if (!r.isHidden() && !r.getName().startsWith(".") && r instanceof IFolder) {
IResource jsonDescriptorFile = ((IFolder) r).findMember(r.getName() + ".json");
if (jsonDescriptorFile != null && jsonDescriptorFile.exists()) {
result.add(createRepositoryFileStore(r.getName()));
}
}
}
} catch (final CoreException e) {
BonitaStudioLog.error(e);
}
return result;
}
@Override
public T getChild(final String folderName) {
if (folderName != null) {
final IFolder folder = getResource().getFolder(folderName);
refresh(folder);
IResource jsonDescriptorFile = folder.findMember(folderName + ".json");
if (folder.exists() && jsonDescriptorFile != null && jsonDescriptorFile.exists()) {
return createRepositoryFileStore(folderName);
}
}
return null;
}
}
......@@ -17,7 +17,6 @@ package org.bonitasoft.studio.designer.core.repository;
import java.util.HashSet;
import java.util.Set;
import org.bonitasoft.studio.common.repository.store.AbstractFolderRepositoryStore;
import org.bonitasoft.studio.designer.UIDesignerPlugin;
import org.bonitasoft.studio.designer.i18n.Messages;
import org.bonitasoft.studio.pics.Pics;
......@@ -26,10 +25,10 @@ import org.eclipse.swt.graphics.Image;
/**
* @author Romain Bioteau
*/
public class WebFragmentRepositoryStore extends AbstractFolderRepositoryStore<WebFragmentFileStore> {
public class WebFragmentRepositoryStore extends WebArtifactRepositoryStore<WebFragmentFileStore> {
private static final String FRAGMENT_ICON_PATH = "fragment.png";
private final static Set<String> extensions = new HashSet<String>();
private static final Set<String> extensions = new HashSet<>();
public static final String JSON_EXTENSION = "json";
public static final String WEB_FRAGMENT_REPOSITORY_NAME = "web_fragments";
......
......@@ -97,16 +97,17 @@ public class WebPageFileStore extends InFolderJSONFileStore implements IDeployab
}
}
/*
* (non-Javadoc)
* @see org.bonitasoft.studio.common.repository.filestore.AbstractFileStore#getStyledString()
*/
@Override
public StyledString getStyledString() {
StyledString styledString = new StyledString();
styledString.append(getDisplayName());
styledString.append(" ");
styledString.append(String.format("(%s)", getType()), StyledString.QUALIFIER_STYLER);
String name = getDisplayName();
styledString.append(name != null ? name : getName());
String type = getType();
if (type != null) {
styledString.append(" ");
styledString.append(String.format("(%s)", getType()), StyledString.QUALIFIER_STYLER);
}
return styledString;
}
......
......@@ -25,7 +25,6 @@ import java.util.stream.Stream;
import javax.inject.Inject;
import org.bonitasoft.studio.common.repository.store.AbstractFolderRepositoryStore;
import org.bonitasoft.studio.designer.UIDesignerPlugin;
import org.bonitasoft.studio.designer.core.UIDesignerServerManager;
import org.bonitasoft.studio.designer.core.bos.WebFormBOSArchiveFileStoreProvider;
......@@ -43,7 +42,7 @@ import com.google.common.io.Files;
/**
* @author Romain Bioteau
*/
public class WebPageRepositoryStore extends AbstractFolderRepositoryStore<WebPageFileStore> {
public class WebPageRepositoryStore extends WebArtifactRepositoryStore<WebPageFileStore> {
private static final String PAGE_ICON_PATH = "page.png";
private static final Set<String> extensions = new HashSet<>();
......@@ -77,6 +76,7 @@ public class WebPageRepositoryStore extends AbstractFolderRepositoryStore<WebPag
return extensions;
}
@Override
public WebPageFileStore createRepositoryFileStore(final String fileName) {
final WebPageFileStore webPageFileStore = new WebPageFileStore(fileName, this);
......@@ -104,7 +104,6 @@ public class WebPageRepositoryStore extends AbstractFolderRepositoryStore<WebPag
return page;
}
public String getDisplayNameFor(String uuid) {
File pageFolder = getResource().getLocation().toFile();
String id = new PageUUIDResolver(pageFolder).resolveUUID(uuid);
......
......@@ -14,7 +14,6 @@
*/
package org.bonitasoft.studio.designer.core.repository;
import org.bonitasoft.studio.common.repository.store.AbstractFolderRepositoryStore;
import org.bonitasoft.studio.designer.UIDesignerPlugin;
import org.bonitasoft.studio.designer.i18n.Messages;
import org.bonitasoft.studio.pics.Pics;
......@@ -23,7 +22,7 @@ import org.eclipse.swt.graphics.Image;
/**
* @author Romain Bioteau
*/
public class WebWidgetRepositoryStore extends AbstractFolderRepositoryStore<WebWidgetFileStore> {
public class WebWidgetRepositoryStore extends WebArtifactRepositoryStore<WebWidgetFileStore> {
private static final String CUSTOM_WIDGET_ICON_PATH = "custom_widget.png";
public static final String WEB_WIDGET_REPOSITORY_NAME = "web_widgets";
......
......@@ -80,8 +80,8 @@ public class EngineDataBuilder extends ProcessSwitch<DataDefinitionBuilder> {
return builder.addLongTextData(data.getName(), expr);
}
protected DataDefinitionBuilder addCollectionData(final String name, final Expression expr2) {
return builder.addData(data.getName(), Collection.class.getName(), expr);
protected DataDefinitionBuilder addCollectionData(final String name, final Expression defaultValue) {
return builder.addData(name, Collection.class.getName(), defaultValue);
}
@Override
......
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