Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / dialogs / ManageCustomParsersDialog.java
index fb80cfe12b101842ed00828dd42f406851e438c9..0eb3318a4cf4d50932923c37eaca0d0669cb6f6e 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.internal.tmf.ui.dialogs;\r
-\r
-import org.eclipse.jface.dialogs.Dialog;\r
-import org.eclipse.jface.dialogs.IDialogConstants;\r
-import org.eclipse.jface.dialogs.MessageDialog;\r
-import org.eclipse.jface.window.Window;\r
-import org.eclipse.jface.wizard.WizardDialog;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomTxtParserWizard;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomXmlParserWizard;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.FileDialog;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.List;\r
-import org.eclipse.swt.widgets.Shell;\r
-\r
-public class ManageCustomParsersDialog extends Dialog {\r
-\r
-    private static final Image image = Activator.getDefault().getImageFromPath("/icons/etool16/customparser_wizard.gif"); //$NON-NLS-1$\r
-\r
-    Button txtButton;\r
-    Button xmlButton;\r
-    List parserList;\r
-    Button newButton;\r
-    Button editButton;\r
-    Button deleteButton;\r
-    Button importButton;\r
-    Button exportButton;\r
-\r
-    public ManageCustomParsersDialog(Shell parent) {\r
-        super(parent);\r
-        setShellStyle(SWT.RESIZE | SWT.MAX | getShellStyle());\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)\r
-     */\r
-    @Override\r
-    protected Control createDialogArea(Composite parent) {\r
-        getShell().setText(Messages.ManageCustomParsersDialog_DialogHeader);\r
-        getShell().setImage(image);\r
-\r
-        Composite composite = (Composite) super.createDialogArea(parent);\r
-        composite.setLayout(new GridLayout(2, false));\r
-\r
-        Composite listContainer = new Composite(composite, SWT.NONE);\r
-        listContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        GridLayout lcgl = new GridLayout();\r
-        lcgl.marginHeight = 0;\r
-        lcgl.marginWidth = 0;\r
-        listContainer.setLayout(lcgl);\r
-\r
-        Composite radioContainer = new Composite(listContainer, SWT.NONE);\r
-        GridLayout rcgl = new GridLayout(2, true);\r
-        rcgl.marginHeight = 0;\r
-        rcgl.marginWidth = 0;\r
-        radioContainer.setLayout(rcgl);\r
-\r
-        txtButton = new Button(radioContainer, SWT.RADIO);\r
-        txtButton.setText(Messages.ManageCustomParsersDialog_TextButtonLabel);\r
-        txtButton.setSelection(true);\r
-        txtButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                fillParserList();\r
-            }});\r
-\r
-        xmlButton = new Button(radioContainer, SWT.RADIO);\r
-        xmlButton.setText("XML"); //$NON-NLS-1$\r
-        xmlButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                fillParserList();\r
-            }});\r
-\r
-        parserList = new List(listContainer, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);\r
-        parserList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        parserList.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                if (parserList.getSelectionCount() == 0) {\r
-                    editButton.setEnabled(false);\r
-                    deleteButton.setEnabled(false);\r
-                    exportButton.setEnabled(false);\r
-                } else {\r
-                    editButton.setEnabled(true);\r
-                    deleteButton.setEnabled(true);\r
-                    exportButton.setEnabled(true);\r
-                }\r
-            }});\r
-\r
-        Composite buttonContainer = new Composite(composite, SWT.NULL);\r
-        buttonContainer.setLayout(new GridLayout());\r
-        buttonContainer.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));\r
-\r
-        newButton = new Button(buttonContainer, SWT.PUSH);\r
-        newButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        newButton.setText(Messages.ManageCustomParsersDialog_NewButtonLabel);\r
-        newButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                WizardDialog dialog = null;\r
-                if (txtButton.getSelection()) {\r
-                    dialog = new WizardDialog(getShell(), new CustomTxtParserWizard());\r
-                } else if (xmlButton.getSelection()) {\r
-                    dialog = new WizardDialog(getShell(), new CustomXmlParserWizard());\r
-                }\r
-                if (dialog != null) {\r
-                    dialog.open();\r
-                    if (dialog.getReturnCode() == Window.OK) {\r
-                        fillParserList();\r
-                    }\r
-                }\r
-            }});\r
-\r
-        editButton = new Button(buttonContainer, SWT.PUSH);\r
-        editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        editButton.setText(Messages.ManageCustomParsersDialog_EditButtonLabel);\r
-        editButton.setEnabled(false);\r
-        editButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                WizardDialog dialog = null;\r
-                if (txtButton.getSelection()) {\r
-                    dialog = new WizardDialog(getShell(),\r
-                            new CustomTxtParserWizard(CustomTxtTraceDefinition.load(parserList.getSelection()[0])));\r
-                } else if (xmlButton.getSelection()) {\r
-                    dialog = new WizardDialog(getShell(),\r
-                            new CustomXmlParserWizard(CustomXmlTraceDefinition.load(parserList.getSelection()[0])));\r
-                }\r
-                if (dialog != null) {\r
-                    dialog.open();\r
-                    if (dialog.getReturnCode() == Window.OK) {\r
-                        fillParserList();\r
-                    }\r
-                }\r
-            }});\r
-\r
-        deleteButton = new Button(buttonContainer, SWT.PUSH);\r
-        deleteButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        deleteButton.setText(Messages.ManageCustomParsersDialog_DeleteButtonLabel);\r
-        deleteButton.setEnabled(false);\r
-        deleteButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                boolean confirm = MessageDialog.openQuestion(\r
-                        getShell(),\r
-                        Messages.ManageCustomParsersDialog_DeleteParserDialogHeader,\r
-                        Messages.ManageCustomParsersDialog_DeleteConfirmation + parserList.getSelection()[0] + "?"); //$NON-NLS-1$\r
-                if (confirm) {\r
-                    if (txtButton.getSelection()) {\r
-                        CustomTxtTraceDefinition.delete(parserList.getSelection()[0]);\r
-                    } else if (xmlButton.getSelection()) {\r
-                        CustomXmlTraceDefinition.delete(parserList.getSelection()[0]);\r
-                    }\r
-                    fillParserList();\r
-                }\r
-            }});\r
-\r
-        new Label(buttonContainer, SWT.NONE); // filler\r
-\r
-        importButton = new Button(buttonContainer, SWT.PUSH);\r
-        importButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        importButton.setText(Messages.ManageCustomParsersDialog_ImportButtonLabel);\r
-        importButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);\r
-                dialog.setText(Messages.ManageCustomParsersDialog_ImportParserSelection);\r
-                dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$\r
-                String path = dialog.open();\r
-                if (path != null) {\r
-                    CustomTraceDefinition[] defs = null;\r
-                    if (txtButton.getSelection()) {\r
-                        defs = CustomTxtTraceDefinition.loadAll(path);\r
-                    } else if (xmlButton.getSelection()) {\r
-                        defs = CustomXmlTraceDefinition.loadAll(path);\r
-                    }\r
-                    if (defs != null && defs.length > 0) {\r
-                        for (CustomTraceDefinition def : defs) {\r
-                            def.save();\r
-                        }\r
-                        fillParserList();\r
-                    }\r
-                }\r
-            }});\r
-\r
-        exportButton = new Button(buttonContainer, SWT.PUSH);\r
-        exportButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));\r
-        exportButton.setText(Messages.ManageCustomParsersDialog_ExportButtonLabel);\r
-        exportButton.setEnabled(false);\r
-        exportButton.addSelectionListener(new SelectionListener(){\r
-            @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {}\r
-            @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-                FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);\r
-                dialog.setText(Messages.ManageCustomParsersDialog_ExportParserSelection + parserList.getSelection()[0]);\r
-                dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$\r
-                String path = dialog.open();\r
-                if (path != null) {\r
-                    CustomTraceDefinition def = null;\r
-                    if (txtButton.getSelection()) {\r
-                        def = CustomTxtTraceDefinition.load(parserList.getSelection()[0]);\r
-                    } else if (xmlButton.getSelection()) {\r
-                        def = CustomXmlTraceDefinition.load(parserList.getSelection()[0]);\r
-                    }\r
-                    if (def != null) {\r
-                        def.save(path);\r
-                    }\r
-                }\r
-            }});\r
-\r
-        fillParserList();\r
-\r
-        getShell().setMinimumSize(300, 275);\r
-        return composite;\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)\r
-     */\r
-    @Override\r
-    protected void createButtonsForButtonBar(Composite parent) {\r
-        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, false);\r
-    }\r
-\r
-    private void fillParserList() {\r
-        parserList.removeAll();\r
-        if (txtButton.getSelection()) {\r
-            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r
-                parserList.add(def.definitionName);\r
-            }\r
-        } else if (xmlButton.getSelection()) {\r
-            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r
-                parserList.add(def.definitionName);\r
-            }\r
-        }\r
-        editButton.setEnabled(false);\r
-        deleteButton.setEnabled(false);\r
-        exportButton.setEnabled(false);\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.tmf.ui.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomTxtParserWizard;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards.CustomXmlParserWizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+
+public class ManageCustomParsersDialog extends Dialog {
+
+    private static final Image image = Activator.getDefault().getImageFromPath("/icons/etool16/customparser_wizard.gif"); //$NON-NLS-1$
+
+    Button txtButton;
+    Button xmlButton;
+    List parserList;
+    Button newButton;
+    Button editButton;
+    Button deleteButton;
+    Button importButton;
+    Button exportButton;
+
+    public ManageCustomParsersDialog(Shell parent) {
+        super(parent);
+        setShellStyle(SWT.RESIZE | SWT.MAX | getShellStyle());
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+    protected Control createDialogArea(Composite parent) {
+        getShell().setText(Messages.ManageCustomParsersDialog_DialogHeader);
+        getShell().setImage(image);
+
+        Composite composite = (Composite) super.createDialogArea(parent);
+        composite.setLayout(new GridLayout(2, false));
+
+        Composite listContainer = new Composite(composite, SWT.NONE);
+        listContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        GridLayout lcgl = new GridLayout();
+        lcgl.marginHeight = 0;
+        lcgl.marginWidth = 0;
+        listContainer.setLayout(lcgl);
+
+        Composite radioContainer = new Composite(listContainer, SWT.NONE);
+        GridLayout rcgl = new GridLayout(2, true);
+        rcgl.marginHeight = 0;
+        rcgl.marginWidth = 0;
+        radioContainer.setLayout(rcgl);
+
+        txtButton = new Button(radioContainer, SWT.RADIO);
+        txtButton.setText(Messages.ManageCustomParsersDialog_TextButtonLabel);
+        txtButton.setSelection(true);
+        txtButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                fillParserList();
+            }});
+
+        xmlButton = new Button(radioContainer, SWT.RADIO);
+        xmlButton.setText("XML"); //$NON-NLS-1$
+        xmlButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                fillParserList();
+            }});
+
+        parserList = new List(listContainer, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+        parserList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        parserList.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                if (parserList.getSelectionCount() == 0) {
+                    editButton.setEnabled(false);
+                    deleteButton.setEnabled(false);
+                    exportButton.setEnabled(false);
+                } else {
+                    editButton.setEnabled(true);
+                    deleteButton.setEnabled(true);
+                    exportButton.setEnabled(true);
+                }
+            }});
+
+        Composite buttonContainer = new Composite(composite, SWT.NULL);
+        buttonContainer.setLayout(new GridLayout());
+        buttonContainer.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
+
+        newButton = new Button(buttonContainer, SWT.PUSH);
+        newButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        newButton.setText(Messages.ManageCustomParsersDialog_NewButtonLabel);
+        newButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                WizardDialog dialog = null;
+                if (txtButton.getSelection()) {
+                    dialog = new WizardDialog(getShell(), new CustomTxtParserWizard());
+                } else if (xmlButton.getSelection()) {
+                    dialog = new WizardDialog(getShell(), new CustomXmlParserWizard());
+                }
+                if (dialog != null) {
+                    dialog.open();
+                    if (dialog.getReturnCode() == Window.OK) {
+                        fillParserList();
+                    }
+                }
+            }});
+
+        editButton = new Button(buttonContainer, SWT.PUSH);
+        editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        editButton.setText(Messages.ManageCustomParsersDialog_EditButtonLabel);
+        editButton.setEnabled(false);
+        editButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                WizardDialog dialog = null;
+                if (txtButton.getSelection()) {
+                    dialog = new WizardDialog(getShell(),
+                            new CustomTxtParserWizard(CustomTxtTraceDefinition.load(parserList.getSelection()[0])));
+                } else if (xmlButton.getSelection()) {
+                    dialog = new WizardDialog(getShell(),
+                            new CustomXmlParserWizard(CustomXmlTraceDefinition.load(parserList.getSelection()[0])));
+                }
+                if (dialog != null) {
+                    dialog.open();
+                    if (dialog.getReturnCode() == Window.OK) {
+                        fillParserList();
+                    }
+                }
+            }});
+
+        deleteButton = new Button(buttonContainer, SWT.PUSH);
+        deleteButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        deleteButton.setText(Messages.ManageCustomParsersDialog_DeleteButtonLabel);
+        deleteButton.setEnabled(false);
+        deleteButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                boolean confirm = MessageDialog.openQuestion(
+                        getShell(),
+                        Messages.ManageCustomParsersDialog_DeleteParserDialogHeader,
+                        Messages.ManageCustomParsersDialog_DeleteConfirmation + parserList.getSelection()[0] + "?"); //$NON-NLS-1$
+                if (confirm) {
+                    if (txtButton.getSelection()) {
+                        CustomTxtTraceDefinition.delete(parserList.getSelection()[0]);
+                    } else if (xmlButton.getSelection()) {
+                        CustomXmlTraceDefinition.delete(parserList.getSelection()[0]);
+                    }
+                    fillParserList();
+                }
+            }});
+
+        new Label(buttonContainer, SWT.NONE); // filler
+
+        importButton = new Button(buttonContainer, SWT.PUSH);
+        importButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        importButton.setText(Messages.ManageCustomParsersDialog_ImportButtonLabel);
+        importButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.OPEN);
+                dialog.setText(Messages.ManageCustomParsersDialog_ImportParserSelection);
+                dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$
+                String path = dialog.open();
+                if (path != null) {
+                    CustomTraceDefinition[] defs = null;
+                    if (txtButton.getSelection()) {
+                        defs = CustomTxtTraceDefinition.loadAll(path);
+                    } else if (xmlButton.getSelection()) {
+                        defs = CustomXmlTraceDefinition.loadAll(path);
+                    }
+                    if (defs != null && defs.length > 0) {
+                        for (CustomTraceDefinition def : defs) {
+                            def.save();
+                        }
+                        fillParserList();
+                    }
+                }
+            }});
+
+        exportButton = new Button(buttonContainer, SWT.PUSH);
+        exportButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+        exportButton.setText(Messages.ManageCustomParsersDialog_ExportButtonLabel);
+        exportButton.setEnabled(false);
+        exportButton.addSelectionListener(new SelectionListener(){
+            @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
+                dialog.setText(Messages.ManageCustomParsersDialog_ExportParserSelection + parserList.getSelection()[0]);
+                dialog.setFilterExtensions(new String[] {"*.xml", "*"}); //$NON-NLS-1$ //$NON-NLS-2$
+                String path = dialog.open();
+                if (path != null) {
+                    CustomTraceDefinition def = null;
+                    if (txtButton.getSelection()) {
+                        def = CustomTxtTraceDefinition.load(parserList.getSelection()[0]);
+                    } else if (xmlButton.getSelection()) {
+                        def = CustomXmlTraceDefinition.load(parserList.getSelection()[0]);
+                    }
+                    if (def != null) {
+                        def.save(path);
+                    }
+                }
+            }});
+
+        fillParserList();
+
+        getShell().setMinimumSize(300, 275);
+        return composite;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+    protected void createButtonsForButtonBar(Composite parent) {
+        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.CLOSE_LABEL, false);
+    }
+
+    private void fillParserList() {
+        parserList.removeAll();
+        if (txtButton.getSelection()) {
+            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
+                parserList.add(def.definitionName);
+            }
+        } else if (xmlButton.getSelection()) {
+            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
+                parserList.add(def.definitionName);
+            }
+        }
+        editButton.setEnabled(false);
+        deleteButton.setEnabled(false);
+        exportButton.setEnabled(false);
+    }
+
+}
This page took 0.038985 seconds and 5 git commands to generate.