tmf: Open XML editor when clicking Edit in XML analysis manager
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Fri, 8 Apr 2016 06:21:16 +0000 (02:21 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Fri, 8 Jul 2016 04:04:53 +0000 (00:04 -0400)
This change adds an Edit button the the XML analysis manager dialog
which opens a simple XML editor (from WTP). Dependencies are included
in the RCP on a per-plugin basis but work is being done to make a
feature containing the minimum set of plugins for a simple XML editor
(see bug 480141). Once this feature is available, the RCP will be
updated to use that instead, for better maintainability.

Change-Id: I6fef003210b3457815de0ce15b22e81be2eb2f9f
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/70200
Reviewed-by: Hudson CI
doc/org.eclipse.tracecompass.doc.user/doc/User-Guide.mediawiki
doc/org.eclipse.tracecompass.doc.user/doc/images/ManageXMLAnalysis.png
rcp/org.eclipse.tracecompass.rcp/feature.xml
rcp/org.eclipse.tracecompass.rcp/pom.xml
releng/org.eclipse.tracecompass.target/tracecompass-e4.5.target
releng/org.eclipse.tracecompass.target/tracecompass-e4.6.target
releng/org.eclipse.tracecompass.target/tracecompass-eStaging.target
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/META-INF/MANIFEST.MF
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/handler/ManageXMLAnalysisDialog.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/handler/Messages.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/handler/messages.properties

index f999c1e6c90649aef4d586b581e6950d775c331a..4fae5629915e68ddeea6a63b6f99c82adc8c058f 100644 (file)
@@ -2700,6 +2700,10 @@ Click the '''Import''' button and select a file from the opened file dialog to i
 
 Select an XML file from the list, click the '''Export''' button and enter or select a file in the opened file dialog to export the XML analysis. Note that if an existing file containing an analysis is selected, its content will be replaced with the analysis to export.
 
+* Edit
+
+Select an XML file from the list, click the '''Edit''' to open the XML editor. When the file is saved after being modified, it is validated and traces that are affected by this file are closed.
+
 * Delete
 
 Select an XML file from the list and click the '''Delete''' button to remove the XML file. Deleting an XML file will close all the traces for which this analysis applies and remove the analysis.
index 0e5601cd7cc6a43221c25773797b8718df00c90b..5d23978de5157797d33f7a1d0134abe3e85753d4 100644 (file)
Binary files a/doc/org.eclipse.tracecompass.doc.user/doc/images/ManageXMLAnalysis.png and b/doc/org.eclipse.tracecompass.doc.user/doc/images/ManageXMLAnalysis.png differ
index e4349b3c501b2f6d07b35ae26a4bb2d7a19bd887..8ef07477bd0160e2b7fe877bc3db6f589ebb753a 100644 (file)
          version="0.0.0"
          unpack="false"/>
 
+   <plugin
+         id="org.eclipse.wst.common.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.common.environment"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.common.frameworks"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.common.frameworks.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.common.project.facet.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.common.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.common.uriresolver"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.sse.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.sse.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.validation"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.validation.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.xml.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.wst.xml.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.apache.xerces"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.apache.xml.resolver"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.apache.xml.serializer"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
 </feature>
index de6754b30f93d54e7edfe7542344f289696a802c..5a82418cef450ded0afc6658ab3d300cc4aff05f 100644 (file)
@@ -36,6 +36,9 @@
             </goals>
             <configuration>
               <excludes>
+                <plugin id="org.apache.xerces"/>
+                <plugin id="org.apache.xml.resolver"/>
+                <plugin id="org.apache.xml.serializer"/>
                 <plugin id="org.eclipse.cdt.core"/>
                 <plugin id="org.eclipse.cdt.core.native"/>
                 <plugin id="org.eclipse.core.runtime.compatibility.auth"/>
                 <plugin id="org.eclipse.remote.jsch.ui"/>
                 <plugin id="org.eclipse.remote.ui"/>
                 <plugin id="org.eclipse.remote.console"/>
+                <plugin id="org.eclipse.wst.common.core"/>
+                <plugin id="org.eclipse.wst.common.environment"/>
+                <plugin id="org.eclipse.wst.common.frameworks"/>
+                <plugin id="org.eclipse.wst.common.frameworks.ui"/>
+                <plugin id="org.eclipse.wst.common.project.facet.core"/>
+                <plugin id="org.eclipse.wst.common.ui"/>
+                <plugin id="org.eclipse.wst.common.uriresolver"/>
+                <plugin id="org.eclipse.wst.sse.core"/>
+                <plugin id="org.eclipse.wst.sse.ui"/>
+                <plugin id="org.eclipse.wst.validation"/>
+                <plugin id="org.eclipse.wst.validation.ui"/>
+                <plugin id="org.eclipse.wst.xml.core"/>
+              <plugin id="org.eclipse.wst.xml.ui"/>
               </excludes>
             </configuration>
           </execution>
index 9deed0a17cb707d2554cc8fe851262855a396784..fd38c8d850aa92ab51eca36f14b7079237d539db 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="tracecompass-e4.5" sequenceNumber="71">
+<?pde version="3.8"?><target name="tracecompass-e4.5" sequenceNumber="72">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/>
 <unit id="org.eclipse.tracecompass.testtraces.tracecompass-test-traces-ctf" version="1.5.0"/>
 <repository location="http://archive.eclipse.org/tracecompass/tracecompass-test-traces/repository/1.5.0"/>
 </location>
+<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
+<unit id="org.eclipse.wst.xml.core" version="0.0.0"/>
+<unit id="org.eclipse.wst.xml.ui" version="0.0.0"/>
+<repository location="http://download.eclipse.org/webtools/downloads/drops/R3.7.2/R-3.7.2-20160217020110/repository/"/>
+</location>
 </locations>
 <targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 <launcherArgs>
index fe5178f139a069c4d91b691ece0d86a12feeb369..93af9ab27b33c4c068326e6185ef8fd3467fb565 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="tracecompass-e4.6" sequenceNumber="18">
+<?pde version="3.8"?><target name="tracecompass-e4.6" sequenceNumber="19">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/>
 <unit id="org.eclipse.tracecompass.testtraces.tracecompass-test-traces-ctf" version="1.5.0"/>
 <repository location="http://archive.eclipse.org/tracecompass/tracecompass-test-traces/repository/1.5.0"/>
 </location>
+<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
+<unit id="org.eclipse.wst.xml.core" version="0.0.0"/>
+<unit id="org.eclipse.wst.xml.ui" version="0.0.0"/>
+<repository location="http://download.eclipse.org/webtools/downloads/drops/R3.8.0/R-3.8.0-20160608130753/repository/"/>
+</location>
 </locations>
 <targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 <launcherArgs>
index 7502b6fc74c335a16100d506e93fe09b5f3233cf..dd4540a064d95b6ff4c2ff2504cf59a157cb4cda 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?pde version="3.8"?><target name="tracecompass-eStaging" sequenceNumber="70">
+<?pde version="3.8"?><target name="tracecompass-eStaging" sequenceNumber="71">
 <locations>
 <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
 <unit id="org.eclipse.cdt.gnu.dsf.feature.group" version="0.0.0"/>
 <unit id="org.eclipse.tracecompass.testtraces.tracecompass-test-traces-ctf" version="1.5.0"/>
 <repository location="http://archive.eclipse.org/tracecompass/tracecompass-test-traces/repository/1.5.0"/>
 </location>
+<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
+<unit id="org.eclipse.wst.xml.core" version="0.0.0"/>
+<unit id="org.eclipse.wst.xml.ui" version="0.0.0"/>
+<repository location="http://download.eclipse.org/webtools/downloads/drops/R3.8.0/R-3.8.0-20160608130753/repository/"/>
+</location>
 </locations>
 <targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 <launcherArgs>
index cd4681ef2496cba247e4cc7032fa2dc31e5f0526..4111c9334e51fecd38eb9bde2a2970a281374373 100644 (file)
@@ -18,7 +18,10 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.tracecompass.analysis.timing.core,
  org.eclipse.tracecompass.analysis.timing.ui,
  org.eclipse.tracecompass.segmentstore.core,
- org.swtchart
+ org.swtchart,
+ org.eclipse.wst.xml.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.core.filesystem
 Export-Package: org.eclipse.tracecompass.internal.tmf.analysis.xml.ui;x-friends:="org.eclipse.tracecompass.tmf.analysis.xml.ui.tests",
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.handler;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.module;x-internal:=true,
index 321b5fd91510c367c97eac4eee51a7bfaa72574b..ed79990dd117562d644acab7456e26ae519fa566 100644 (file)
@@ -12,6 +12,7 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Map;
 
+import org.eclipse.core.filesystem.EFS;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.ResourcesPlugin;
@@ -19,6 +20,7 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -47,10 +49,14 @@ import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectElement;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectModelElement;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
 import org.eclipse.tracecompass.tmf.ui.project.model.TraceUtils;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.ISaveablePart;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
 
 /**
  * Dialog for XML analysis files
@@ -64,6 +70,7 @@ public class ManageXMLAnalysisDialog extends Dialog {
     private Button fDeleteButton;
     private Button fImportButton;
     private Button fExportButton;
+    private Button fEditButton;
     private Label fInvalidFileLabel;
 
     /**
@@ -103,9 +110,11 @@ public class ManageXMLAnalysisDialog extends Dialog {
                 if (fAnalysesList.getSelectionCount() == 0) {
                     fDeleteButton.setEnabled(false);
                     fExportButton.setEnabled(false);
+                    fEditButton.setEnabled(false);
                 } else {
                     fDeleteButton.setEnabled(true);
                     fExportButton.setEnabled(true);
+                    fEditButton.setEnabled(true);
                     handleSelection(fAnalysesList.getSelection());
                 }
             }
@@ -150,6 +159,22 @@ public class ManageXMLAnalysisDialog extends Dialog {
             }
         });
 
+        fEditButton = new Button(buttonContainer, SWT.PUSH);
+        fEditButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        fEditButton.setText(Messages.ManageXMLAnalysisDialog_Edit);
+        fEditButton.setEnabled(false);
+        fEditButton.addSelectionListener(new SelectionListener() {
+            @Override
+            public void widgetDefaultSelected(SelectionEvent e) {
+            }
+
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                editAnalysis();
+            }
+
+        });
+
         fDeleteButton = new Button(buttonContainer, SWT.PUSH);
         fDeleteButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
         fDeleteButton.setText(Messages.ManageXMLAnalysisDialog_Delete);
@@ -246,29 +271,38 @@ public class ManageXMLAnalysisDialog extends Dialog {
         String path = dialog.open();
         if (path != null) {
             File file = new File(path);
-            IStatus status = XmlUtils.xmlValidate(file);
-            if (status.isOK()) {
-                deleteSupplementaryFile(file.getName());
+            if (loadXmlFile(file, true)) {
+                fillAnalysesList();
+            }
+        }
+    }
+
+    private static boolean loadXmlFile(File file, boolean addFile) {
+        IStatus status = XmlUtils.xmlValidate(file);
+        if (status.isOK()) {
+            deleteSupplementaryFile(file.getName());
+            if (addFile) {
                 status = XmlUtils.addXmlFile(file);
-                if (status.isOK()) {
-                    fillAnalysesList();
-                    XmlAnalysisModuleSource.notifyModuleChange();
-                    /*
-                     * FIXME: It refreshes the list of analysis under a trace,
-                     * but since modules are instantiated when the trace opens,
-                     * the changes won't apply to an opened trace, it needs to
-                     * be closed then reopened
-                     */
-                    refreshProject();
-                } else {
-                    Activator.logError(Messages.ManageXMLAnalysisDialog_ImportFileFailed);
-                    TraceUtils.displayErrorMsg(Messages.ManageXMLAnalysisDialog_ImportFileFailed, status.getMessage());
-                }
-            } else {
-                Activator.logError(Messages.ManageXMLAnalysisDialog_ImportFileFailed);
-                TraceUtils.displayErrorMsg(Messages.ManageXMLAnalysisDialog_ImportFileFailed, status.getMessage());
             }
+            if (status.isOK()) {
+                XmlAnalysisModuleSource.notifyModuleChange();
+                /*
+                 * FIXME: It refreshes the list of analysis under a trace,
+                 * but since modules are instantiated when the trace opens,
+                 * the changes won't apply to an opened trace, it needs to
+                 * be closed then reopened
+                 */
+                refreshProject();
+                return true;
+            }
+
+            Activator.logError(Messages.ManageXMLAnalysisDialog_ImportFileFailed);
+            TraceUtils.displayErrorMsg(Messages.ManageXMLAnalysisDialog_ImportFileFailed, status.getMessage());
+        } else {
+            Activator.logError(Messages.ManageXMLAnalysisDialog_ImportFileFailed);
+            TraceUtils.displayErrorMsg(Messages.ManageXMLAnalysisDialog_ImportFileFailed, status.getMessage());
         }
+        return false;
     }
 
     private void exportAnalysis() {
@@ -285,6 +319,35 @@ public class ManageXMLAnalysisDialog extends Dialog {
         }
     }
 
+    private void editAnalysis() {
+        String selection = createXmlFileString(fAnalysesList.getSelection()[0]);
+        @Nullable
+        File file = XmlUtils.listFiles().get(selection);
+        if (file == null) {
+            Activator.logError(NLS.bind(Messages.ManageXMLAnalysisDialog_FailedToEdit, selection));
+            TraceUtils.displayErrorMsg(NLS.bind(Messages.ManageXMLAnalysisDialog_FailedToEdit, selection), NLS.bind(Messages.ManageXMLAnalysisDialog_FailedToEdit, selection));
+            return;
+        }
+        try {
+            IEditorPart editorPart = IDE.openEditorOnFileStore(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), EFS.getStore(file.toURI()));
+            editorPart.addPropertyListener(new IPropertyListener() {
+                @Override
+                public void propertyChanged(Object source, int propId) {
+                    if (ISaveablePart.PROP_DIRTY == propId) {
+                        if (!editorPart.isDirty()) {
+                            // Editor is not dirty anymore, i.e. it was saved
+                            loadXmlFile(file, false);
+                        }
+                    }
+                }
+            });
+            close();
+        } catch (CoreException e) {
+            Activator.logError(NLS.bind(Messages.ManageXMLAnalysisDialog_FailedToEdit, selection));
+            TraceUtils.displayErrorMsg(NLS.bind(Messages.ManageXMLAnalysisDialog_FailedToEdit, selection), e.getMessage());
+        }
+    }
+
     private void deleteAnalysis() {
         boolean confirm = MessageDialog.openQuestion(
                 getShell(),
index 12a117fa3f2a3b50177ab68c7fb94a4139bca878..fc05d9d37c931b187e93b9c9d65702dcfeacb2ab 100644 (file)
@@ -47,6 +47,16 @@ public class Messages extends NLS {
      */
     public static String ManageXMLAnalysisDialog_Export;
 
+    /**
+     * Edit XML file message
+     */
+    public static String ManageXMLAnalysisDialog_Edit;
+
+    /**
+     * Edit failed message
+     */
+    public static String ManageXMLAnalysisDialog_FailedToEdit;
+
     /**
      * Export failed message
      */
index e0b7915a050410d1b1885c1d5214ff8659450618..6b78473cbd37474a7400df3200c27d1e6841f291 100644 (file)
@@ -12,6 +12,8 @@ ManageXMLAnalysisDialog_DeleteConfirmation=Are you sure you want to delete {0}
 ManageXMLAnalysisDialog_DeleteFile=Delete XML file
 ManageXMLAnalysisDialog_DeleteFileError=Failed to delete resource : {0}
 ManageXMLAnalysisDialog_Export=Export
+ManageXMLAnalysisDialog_Edit=Edit...
+ManageXMLAnalysisDialog_FailedToEdit=Failed to open file {0} for edit
 ManageXMLAnalysisDialog_FailedToExport=Failed to export {0}
 ManageXMLAnalysisDialog_Import=Import
 ManageXMLAnalysisDialog_ImportFileFailed=Import XML analysis file failed.
This page took 0.034594 seconds and 5 git commands to generate.