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

feat(app) manage errors from source (#391)

* Editor switch in error mode when an error in the xml file is detected

closes [BS-16452](https://bonitasoft.atlassian.net/browse/BS-16452)
parent c5ee464e
......@@ -50,4 +50,5 @@ applicationInfo=An application file contains one or several application descript
applicationDetails=Application descriptors hold meta data about the application (url token, name, version, user profile), but also its navigation,\nas well as links to the pages it needs to access.\nThey were created in the Portal prior to Bonita BPM 7.5 and are now handled in the Studio to ease packaging and deployment.\nThe Studio is not aware of what is created in the Portal, so deploying an application descriptor may overwrite some Portal content.
doNotShowMeAgain=Do not show me this dialog again
exportApplicationDescriptorTitle=Export
exportApplicationDescriptorMessage=You are about to export an application descriptor file.\nApplication(s) REST API extensions, pages and profiles are not part of the file. \nMake sure they are already installed before you import this file in the Portal.
\ No newline at end of file
exportApplicationDescriptorMessage=You are about to export an application descriptor file.\nApplication(s) REST API extensions, pages and profiles are not part of the file. \nMake sure they are already installed before you import this file in the Portal.
unparsableApplicationFile=Unable to parse xml
......@@ -74,4 +74,26 @@ public class LivingApplicationPlugin extends AbstractUIPlugin {
return result;
}
public static ImageDescriptor getImageDescriptor(String imageName) {
final ImageRegistry reg = getDefault().getImageRegistry();
ImageDescriptor result = reg.getDescriptor(imageName);
if (result != null) {
return result;
}
final ImageDescriptor descriptor = ImageDescriptor.createFromURL(getDefault().getBundle().getResource(imageName));
if (descriptor != null) {
result = descriptor;
}
reg.remove(imageName);
if (result != null) {
reg.put(imageName, result);
}
return result;
}
}
......@@ -71,6 +71,7 @@ public class Messages extends NLS {
public static String applicationDetails;
public static String exportApplicationDescriptorTitle;
public static String exportApplicationDescriptorMessage;
public static String unparsableApplicationFile;
static {
NLS.initializeMessages("messages", Messages.class);
......
......@@ -26,6 +26,7 @@ import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.swt.SWT;
......@@ -57,6 +58,8 @@ public class OpenApplicationPage implements ControlSupplier {
applicationsTableViewer
.setInput(repositoryAccessor.getRepositoryStore(ApplicationRepositoryStore.class).getChildren());
ColumnViewerToolTipSupport.enableFor(applicationsTableViewer);
ctx.bindList(ViewersObservables.observeMultiSelection(applicationsTableViewer), applicationFileStoreObservable);
ctx.addValidationStatusProvider(new org.eclipse.core.databinding.validation.MultiValidator() {
......
......@@ -31,6 +31,7 @@ import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.wizard.IWizardContainer;
......@@ -66,6 +67,8 @@ public class SelectApplicationDescriptorPage implements ControlSupplier {
.setInput(repositoryAccessor.getRepositoryStore(ApplicationRepositoryStore.class).getChildren());
applicationsTableViewer.addDoubleClickListener(new WizardDoubleClickListener((WizardDialog) wizardContainer));
ColumnViewerToolTipSupport.enableFor(applicationsTableViewer);
IViewerObservableList multiSelection = ViewersObservables.observeMultiSelection(applicationsTableViewer);
ctx.addValidationStatusProvider(new MultiValidator() {
......
......@@ -15,7 +15,11 @@
package org.bonitasoft.studio.la.ui.providers;
import org.bonitasoft.studio.common.repository.model.ReadFileStoreException;
import org.bonitasoft.studio.la.LivingApplicationPlugin;
import org.bonitasoft.studio.la.i18n.Messages;
import org.bonitasoft.studio.la.repository.ApplicationFileStore;
import org.eclipse.jface.viewers.DecorationOverlayIcon;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.StyledCellLabelProvider;
import org.eclipse.jface.viewers.StyledString;
......@@ -31,14 +35,18 @@ public class ApplicationLabelProvider extends StyledCellLabelProvider implements
final StyledString styledString = new StyledString();
styledString.append(fileStore.getName());
cell.setText(styledString.getString());
cell.setImage(getImage(cell.getElement()));
try {
if (!fileStore.getContent().getApplications().isEmpty()) {
cell.setText(appendAppTokens(fileStore, styledString));
}
} catch (ReadFileStoreException e) {
throw new RuntimeException("Impossible to read application descriptor", e);
//Do not display app descriptors
cell.setImage(new DecorationOverlayIcon(getImage(cell.getElement()),
LivingApplicationPlugin.getImageDescriptor("icons/problem.gif"), IDecoration.BOTTOM_RIGHT)
.createImage());
}
cell.setImage(getImage(cell.getElement()));
cell.setStyleRanges(styledString.getStyleRanges());
}
}
......@@ -52,6 +60,20 @@ public class ApplicationLabelProvider extends StyledCellLabelProvider implements
return styledString.getString().substring(0, styledString.getString().length() - 2);
}
/**
* @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
*/
@Override
public String getToolTipText(Object element) {
final ApplicationFileStore fileStore = (ApplicationFileStore) element;
try {
fileStore.getContent();
} catch (ReadFileStoreException e) {
return Messages.unparsableApplicationFile;
}
return super.getToolTipText(element);
}
@Override
public Image getImage(Object element) {
return ((ApplicationFileStore) element).getIcon();
......
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