diff --git a/pom.xml b/pom.xml index e8ad738..79cb521 100644 --- a/pom.xml +++ b/pom.xml @@ -294,7 +294,7 @@ - http://central.maven.org/maven2/ + https://repo1.maven.org/maven2/ central default diff --git a/src/main/groovy/cfa/vo/vodml/gui/Controller.groovy b/src/main/groovy/cfa/vo/vodml/gui/Controller.groovy deleted file mode 100644 index ffc5e8f..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/Controller.groovy +++ /dev/null @@ -1,47 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import cfa.vo.vodml.io.VodmlReader - -class Controller { - private status = StatusPanel.STATUS_LOGGER - PresentationModel model - - public PresentationModel load(String path) throws FileNotFoundException { - status.info("Reading ${path}...") - def retVal = new PresentationModel(new VodmlReader().read(new File(path))) - status.info("Successfully Read ${path}") - return retVal - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/MainView.groovy b/src/main/groovy/cfa/vo/vodml/gui/MainView.groovy deleted file mode 100644 index fcd6a5a..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/MainView.groovy +++ /dev/null @@ -1,139 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import groovy.swing.SwingBuilder - -import javax.swing.* -import java.awt.* - -/** - * Main GUI Application class. It sets up the main frame for the application. - */ -class MainView { - private swing = new SwingBuilder() - JFileChooser chooser = swing.fileChooser() - private controller = new Controller() - static JFrame frame - private StatusPanel statusPanel - private JTabbedPane tabs - - private MainView() { - swing.registerBeanFactory("statusPanel", StatusPanel) - swing.registerFactory("modelTab", new ModelTabFactory()) - - swing.edt { - lookAndFeel('system') - frame = frame(id: "root", title: 'VODML Model Builder', minimumSize: [800, 600], locationRelativeTo: null, - pack:true, show: true, defaultCloseOperation: JFrame.EXIT_ON_CLOSE,) { - borderLayout() - menuBar { - menu(mnemonic: 'F', text: 'File') { - menuItem(actionLoad) - } - } - tabs = tabbedPane(name: "main") - statusPanel = statusPanel(constraints: BorderLayout.SOUTH) - } - } - StatusPanel.STATUS_LOGGER.warning("No Model Selected") - } - - /** - * Overload left shift operator for opening models into the GUI - * - * @param model The model to be open. - */ - def void leftShift(PresentationModel model) { - swing.edt { - String name = model.toString() - ModelTab tab = swing.modelTab(model) - tabs.addTab(name, tab) - model.propertyChange = { - swing.edt { - def i = tabs.getSelectedIndex() - tabs.setTitleAt(i, model.toString()) - } - } - } - } - - /** - * Main function. - * @param argv If any arguments are passed to the command line, a test URL will be opened automatically. - * At this time the location of the test file is not portable. - */ - public static void main(String[] argv) { - Icon empty = new TreeIcon(); - UIManager.put("Tree.collapsedIcon", empty); - UIManager.put("Tree.expandedIcon", empty); - MainView view = new MainView() - if (argv) { - Controller c = new Controller() - view << c.load("C:/Users/Omar/IdeaProjects/jovial/src/test/resources/DatasetMetadata-1.0.vo-dml.xml") - } - } - - def actionLoad = swing.action( - id: 'actionLoad', - name: 'Load...', - closure: this.&load, - mnemonic: 'L', - accelerator: 'F5' - ) - - def load = { - int result = chooser.showOpenDialog(frame) - if (result == JFileChooser.APPROVE_OPTION) { - swing.doOutside { - this << controller.load(chooser.getSelectedFile().absolutePath) - } - } - } - - static class TreeIcon implements Icon { - - private static int SIZE = 0; - - public int getIconWidth() { - return SIZE; - } - - public int getIconHeight() { - return SIZE; - } - - public void paintIcon(Component c, Graphics g, int x, int y) { - } - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/ModelTab.groovy b/src/main/groovy/cfa/vo/vodml/gui/ModelTab.groovy deleted file mode 100644 index 1bb9c7b..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/ModelTab.groovy +++ /dev/null @@ -1,59 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import cfa.vo.vodml.gui.tree.PresentationModelJTree -import groovy.swing.SwingBuilder - -import javax.swing.* -import java.awt.BorderLayout - -class ModelTab extends JPanel { - private SwingBuilder swing = new SwingBuilder() - PresentationModel model - - public ModelTab(PresentationModel model) { - swing.registerBeanFactory("tree", PresentationModelJTree) - this.model = model - JPanel panel = swing.panel() { - borderLayout() - splitPane( - leftComponent: scrollPane(minimumSize: [300, 600]) { - tree(model: model.treeModel) - }, - rightComponent: new ModelView(model)) - } - layout = new BorderLayout() - add(panel, BorderLayout.CENTER) - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/ModelTabFactory.groovy b/src/main/groovy/cfa/vo/vodml/gui/ModelTabFactory.groovy deleted file mode 100644 index 9465606..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/ModelTabFactory.groovy +++ /dev/null @@ -1,47 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - - -class ModelTabFactory extends AbstractFactory { - @Override - Object newInstance(FactoryBuilderSupport fbs, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException { - if (value == null) { - throw new InstantiationException("Please provide a PresentationModel value, none was provided") - } - if (attributes) { - throw new InstantiationException("No attributes allowed in building element. Only a value accepted") - } - return new ModelTab(value) - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/ModelView.groovy b/src/main/groovy/cfa/vo/vodml/gui/ModelView.groovy deleted file mode 100644 index ea5b64f..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/ModelView.groovy +++ /dev/null @@ -1,261 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package cfa.vo.vodml.gui - -import ca.odell.glazedlists.gui.TableFormat -import ca.odell.glazedlists.swing.AdvancedListSelectionModel -import ca.odell.glazedlists.swing.GlazedListsSwing -import cfa.vo.vodml.metamodel.ModelImport -import groovy.swing.SwingBuilder -import org.joda.time.DateTime - -import javax.swing.* -import javax.swing.event.DocumentListener -import java.awt.* -import java.util.logging.Logger - -import static java.awt.GridBagConstraints.* - -/** - * Main View for models. - */ -class ModelView extends JPanel { - private SwingBuilder swing = new SwingBuilder() - private Logger status = StatusPanel.STATUS_LOGGER - private AdvancedListSelectionModel importsSelectionModel - private AdvancedListSelectionModel authorsSelectionModel - private defaultInsets = [5, 5, 5, 5] - - PresentationModel model - - public ModelView(PresentationModel model) { - this.model = model - labelConstraints.delegate = swing - fieldConstraints.delegate = swing - - authorsSelectionModel = GlazedListsSwing.eventSelectionModelWithThreadProxyList(model.authors) - importsSelectionModel = GlazedListsSwing.eventSelectionModelWithThreadProxyList(model.imports) - def columnNames = ["name", "version", "url", "documentationURL"] - def tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(model.imports, [ - getColumnCount: { return 4 }, - getColumnName: { int index -> - columnNames[index].capitalize() - }, - getColumnValue: { ModelImport object, int index -> - object."${columnNames[index]}" - }] as TableFormat) - - JPanel panel = swing.panel(border: BorderFactory.createEtchedBorder()) { - def fields = [] - - def labelField = { order, name -> - label("${name.capitalize()}:", constraints: labelConstraints(order)) - fields << textField(id: "${name}Field", text: model."${name}", constraints: fieldConstraints(order)) - } - - borderLayout() - panel(border: BorderFactory.createTitledBorder("Model")) { - gridBagLayout() - labelField(0, "name") - labelField(1, "title") - labelField(2, "version") - labelField(3, "lastModified") - label("Description", constraints: labelConstraints(4)) - scrollPane(constraints: gbc(weighty:0.6, gridx:1, gridy:4, insets: defaultInsets, fill:BOTH, anchor: WEST)) { - fields << textArea(id: "descriptionField", rows: 20, text: model.description, wrapStyleWord: true, lineWrap: true, autoscrolls: true) - } - // Authors - label("Authors:", constraints: gbc(weighty: 0.2, gridx: 0, gridy: 5, insets: defaultInsets, fill: BOTH, anchor: WEST)) - panel(id:"authors", constraints: gbc(gridx: 1, gridy: 5, weightx: 1, fill: BOTH, gridwidth: REMAINDER, insets: defaultInsets, anchor: EAST)) { - borderLayout() - scrollPane() { - list(selectionModel: authorsSelectionModel, model: GlazedListsSwing.eventListModelWithThreadProxyList(model.authors)) - } - panel(constraints: BorderLayout.EAST) { - vbox { - button(border: null, action: addAuthorAction, name:"add", icon: new ImageIcon(getClass().getResource("/icons/list-add.png"))) - button(border: null, action: removeAuthorAction, name:"remove", icon: new ImageIcon(getClass().getResource("/icons/list-remove.png"))) - } - } - } - - // Imports - label("Imports:", constraints: gbc(gridx: 0, gridy: 6, weighty: 0.2, insets: defaultInsets, fill: BOTH, anchor: WEST)) - panel(id:"imports", constraints: gbc(gridx: 1, gridy: 6, weighty: 0.2, weightx: 1, - fill: BOTH, insets: defaultInsets, anchor: EAST)) { - borderLayout() - scrollPane() { - table(selectionModel: importsSelectionModel, model: tableModel) - } - panel(constraints: BorderLayout.EAST) { - vbox { - button(border: null, action: addImportAction, name:"add", icon: new ImageIcon(getClass().getResource("/icons/list-add.png"))) - button(border: null, action: removeImportAction, name:"remove", icon: new ImageIcon(getClass().getResource("/icons/list-remove.png"))) - } - } - } - } - - def updateModel = { - - } - fields.each { - it.document.addDocumentListener( - [insertUpdate : updateModel, - removeUpdate : updateModel, - changedUpdate: updateModel] as DocumentListener) - } - - bean(model, - name: bind { nameField.text }, - description: bind { descriptionField.text }, - version: bind { versionField.text }, - title: bind { titleField.text }, - lastModified: bind(converter: convertDate) { lastModifiedField.text }, - ) - } - layout = new BorderLayout() - add(panel) - } - - private convertDate = {String date -> - try { - def retVal = new DateTime(date) - status.info("Parsed date $date") - retVal - } catch (Exception ex) { - status.warning("Cannot parse date $date") - } - } - - private convertUrl = {String val -> - try { - new URI(val) - } catch (Exception ex) { - status.warning("Cannot parse URI $val") - } - } - - private addAuthorAction = swing.action( - id: 'addAuthorAction', - closure: this.&showAddAuthor - ) - - private addImportAction = swing.action( - id: 'addImportAction', - closure: this.&showAddImport - ) - - private removeImportAction = swing.action( - id: 'removeImportAction', - closure: { - if (!importsSelectionModel.selectionEmpty) { - model.imports.removeAll(importsSelectionModel.selected) - } - } - ) - - private removeAuthorAction = swing.action( - id: 'removeAuthorAction', - closure: { - if (!authorsSelectionModel.selectionEmpty) { - model.authors.removeAll(authorsSelectionModel.selected) - } - } - ) - - private showAddAuthor = { - swing.edt { - dialog(id: "dialog", title:"Add Author", modal:true, locationRelativeTo: MainView.frame, pack: true, show: true) { - panel(border: BorderFactory.createEmptyBorder(10,10,10,10)) { - vbox { - hbox { - label("Author: ") - textField(id: "authorField", columns: 30) - } - vstrut(height: 10) - hbox { - button("OK", actionPerformed: { model.authors.add(authorField.text); dialog.dispose(); }) - hstrut(width: 10) - button("Cancel", actionPerformed: { dialog.dispose()}) - } - } - } - } - } - } - - private showAddImport = { - swing.edt { - ModelImport imp = new ModelImport() - dialog(id: "dialog", title:"Add Author", modal:true, locationRelativeTo: MainView.frame, pack: true, show: true) { - vbox { - panel(border: BorderFactory.createEmptyBorder(10, 10, 10, 10)) { - gridBagLayout() - label("Name: ", constraints: labelConstraints(0)) - textField(id: "impNameField", constraints: fieldConstraints(0), columns: 20) - label("Version: ", constraints: labelConstraints(1)) - textField(id: "impVersionField", constraints: fieldConstraints(1), columns: 20) - label("URL: ", constraints: labelConstraints(2)) - textField(id: "impUrlField", constraints: fieldConstraints(2), columns: 20) - label("DocURL: ", constraints: labelConstraints(3)) - textField(id: "impDocUrlField", constraints: fieldConstraints(3), columns: 20) - } - panel { - hbox { - button("OK", actionPerformed: { model.imports.add(imp); dialog.dispose() }) - hstrut(width: 10) - button("Cancel", actionPerformed: { dialog.dispose()}) - } - } - } - bean(imp, - name: bind { impNameField.text }, - version: bind { impVersionField.text }, - url: bind(converter: convertUrl) { impUrlField.text }, - documentationURL: bind(converter: convertUrl) { impDocUrlField.text }, - ) - } - } - } - - def labelConstraints = { order -> - gbc(gridx: 0, gridy: order, anchor: WEST, insets: defaultInsets) - } - - def fieldConstraints = { order -> - gbc(gridx: 1, gridy: order, gridwidth: REMAINDER, weightx: 1, - fill: HORIZONTAL, anchor: EAST, insets: defaultInsets) - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/PresentationModel.groovy b/src/main/groovy/cfa/vo/vodml/gui/PresentationModel.groovy deleted file mode 100644 index 32c2572..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/PresentationModel.groovy +++ /dev/null @@ -1,69 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import cfa.vo.vodml.gui.tree.PresentationModelTreeModel -import cfa.vo.vodml.metamodel.Model -import groovy.beans.Bindable -import groovy.transform.EqualsAndHashCode - -@EqualsAndHashCode(excludes=["dirty", "treeModel"]) -@Bindable -class PresentationModel extends Model { - boolean dirty - PresentationModelTreeModel treeModel - - public PresentationModel() { - this(new Model()) - } - - public PresentationModel(Model model) { - decorate(model) - initTree() - } - - private initTree() { - treeModel = new PresentationModelTreeModel(this) - } - - // Hack because Traits do not support AST trasformations, so @Delegate won't work. - // Falling back on decorate constructor instead - private decorate(Model model) { - def properties = model.properties - properties.remove("class") - properties.remove("propertyChangeListeners") - properties.each { - this."$it.key" = it.value - } - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/StatusPanel.groovy b/src/main/groovy/cfa/vo/vodml/gui/StatusPanel.groovy deleted file mode 100644 index af3a7ff..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/StatusPanel.groovy +++ /dev/null @@ -1,89 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import groovy.swing.SwingBuilder - -import javax.swing.* -import java.awt.* -import java.util.logging.Handler -import java.util.logging.LogRecord -import java.util.logging.Logger - -/** - * Specialization of {@link JPanel} for a Status Panel that is updated through a special logger. - * - * Simply grab the logger from {@link #STATUS_LOGGER} and log to it as usual. Messages will be used - * to set the text of this panel's status label. - * - * For convenience, a {@link #setStatus(String)} setter is provided for setting the status text directly. - * However, this should be used only to - */ -class StatusPanel extends JPanel { - private JLabel statusLabel - private SwingBuilder swing = new SwingBuilder() - public static final Logger STATUS_LOGGER = Logger.getLogger("status") - - public StatusPanel() { - swing.build { - statusLabel = label(name: "status", border: BorderFactory.createEmptyBorder(5,5,5,5)) - } - layout = new BorderLayout() - border = BorderFactory.createBevelBorder(1) - add(statusLabel) - - STATUS_LOGGER.addHandler(new StatusHandler()) - } - - public void setStatus(String status) { - statusLabel.text = status - } - - private class StatusHandler extends Handler { - - @Override - void publish(LogRecord record) { - swing.edt { - statusLabel.text = "${record.level}: ${record.message}" - } - } - - @Override - void flush() { - } - - @Override - void close() throws SecurityException { - } - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/DataTypeListNode.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/DataTypeListNode.groovy deleted file mode 100644 index 649eade..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/DataTypeListNode.groovy +++ /dev/null @@ -1,42 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import ca.odell.glazedlists.EventList -import cfa.vo.vodml.metamodel.DataType - -class DataTypeListNode extends ListTreeNode { - DataTypeListNode(EventList userObject, Object parent) { - super("Data Type", userObject, parent) - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/EnumerationListNode.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/EnumerationListNode.groovy deleted file mode 100644 index 1465d4e..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/EnumerationListNode.groovy +++ /dev/null @@ -1,43 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import ca.odell.glazedlists.EventList -import cfa.vo.vodml.metamodel.Enumeration_ - - -class EnumerationListNode extends ListTreeNode { - EnumerationListNode(EventList userObject, Object parent) { - super("Enumeration", userObject, parent) - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/ListTreeNode.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/ListTreeNode.groovy deleted file mode 100644 index affdc9f..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/ListTreeNode.groovy +++ /dev/null @@ -1,95 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import ca.odell.glazedlists.EventList - -import javax.swing.tree.DefaultMutableTreeNode -import javax.swing.tree.TreeNode - -class ListTreeNode implements TreeNode { - String name - def parent - EventList userObject - - public ListTreeNode(String name, EventList userObject, parent) { - this.userObject = userObject - userObject.addListEventListener { - if(parent) parent.listChanged() - } - this.name = name - this.parent = parent - } - - public String toString() { - return "${name}s" - } - - TreeNode getChildAt(int childIndex) { - return new DefaultMutableTreeNode(userObject.get(childIndex)) - } - - def menuItems = { swing -> - swing.menuItem(label: "Add ${name}") - } - - @Override - int getChildCount() { - return userObject.size() - } - - @Override - TreeNode getParent() { - return parent - } - - @Override - int getIndex(TreeNode node) { - return userObject.indexOf(node.userObject) - } - - @Override - boolean getAllowsChildren() { - return true - } - - @Override - boolean isLeaf() { - return userObject.isEmpty() - } - - @Override - Enumeration children() { - throw new UnsupportedOperationException() - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/ModelTreeNode.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/ModelTreeNode.groovy deleted file mode 100644 index 99e9764..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/ModelTreeNode.groovy +++ /dev/null @@ -1,47 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import cfa.vo.vodml.metamodel.PackageLike - - -class ModelTreeNode extends PackageLikeTreeNode { - ModelTreeNode(PackageLike userObject, parent) { - super(userObject, parent) - } - - @Override - String toString() { - userObject.toString() - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/ObjectTypeListNode.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/ObjectTypeListNode.groovy deleted file mode 100644 index 0ddd153..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/ObjectTypeListNode.groovy +++ /dev/null @@ -1,44 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import ca.odell.glazedlists.EventList -import cfa.vo.vodml.metamodel.ObjectType - - -class ObjectTypeListNode extends ListTreeNode { - - ObjectTypeListNode(EventList userObject, Object parent) { - super("Object Type", userObject, parent) - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/PackageLikeTreeNode.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/PackageLikeTreeNode.groovy deleted file mode 100644 index 66b0885..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/PackageLikeTreeNode.groovy +++ /dev/null @@ -1,103 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import cfa.vo.vodml.metamodel.PackageLike - -import javax.swing.tree.TreeNode - -class PackageLikeTreeNode implements TreeNode { - PackageLike userObject - def children = [] - def parent - - public PackageLikeTreeNode(PackageLike userObject, parent) { - this.parent = parent - this.userObject = userObject - children << new PrimitiveTypeListNode(userObject.primitiveTypes, this) - children << new EnumerationListNode(userObject.enumerations, this) - children << new DataTypeListNode(userObject.dataTypes, this) - children << new ObjectTypeListNode(userObject.objectTypes, this) - children << new PackageListNode(userObject.packages, this) - } - - def menuItems = { swing -> - children.each { - swing.menuItem(label: "Add ${it.name}") - } - } - - def listChanged() { - parent.listChanged()x - } - - @Override - TreeNode getChildAt(int childIndex) { - return children[childIndex] - } - - @Override - int getChildCount() { - return children.size() - } - - @Override - TreeNode getParent() { - return parent - } - - @Override - int getIndex(TreeNode node) { - return children.indexOf(node) - } - - @Override - boolean getAllowsChildren() { - return true - } - - @Override - boolean isLeaf() { - return false - } - - @Override - Enumeration children() { - throw new UnsupportedOperationException() - } - - @Override - String toString() { - userObject.name - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/PackageListNode.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/PackageListNode.groovy deleted file mode 100644 index 2fb3dcb..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/PackageListNode.groovy +++ /dev/null @@ -1,54 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import ca.odell.glazedlists.EventList -import cfa.vo.vodml.metamodel.PackageLike - -import javax.swing.tree.TreeNode - -class PackageListNode extends ListTreeNode { - def nodes = [:] - - PackageListNode(EventList userObject, Object parent) { - super("Package", userObject, parent) - } - - @Override - TreeNode getChildAt(int childIndex) { - if (!nodes[childIndex]) { - nodes[childIndex] = new PackageLikeTreeNode(userObject.get(childIndex), parent) - } - return nodes[childIndex] - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/PresentationModelJTree.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/PresentationModelJTree.groovy deleted file mode 100644 index 12a5811..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/PresentationModelJTree.groovy +++ /dev/null @@ -1,66 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import groovy.swing.SwingBuilder - -import javax.swing.* -import javax.swing.tree.TreePath -import javax.swing.tree.TreeSelectionModel -import java.awt.event.MouseEvent -import java.awt.event.MouseListener - -class PresentationModelJTree extends JTree { - private swing = new SwingBuilder() - - public PresentationModelJTree() { - selectionModel.selectionMode = TreeSelectionModel.SINGLE_TREE_SELECTION - this.addMouseListener( { MouseEvent e-> - if (e.popupTrigger) { - swing.edt { - popupMenu() { - TreePath path = this.getPathForLocation(e.x, e.y) - path.lastPathComponent.menuItems(swing) - }.show(e.source, e.x, e.y) - } - } - } as MouseListener) - } - - void repaint() { - super.repaint() - for (int i = 0; i < getRowCount(); i++) { - expandRow(i); - } - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/PresentationModelTreeModel.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/PresentationModelTreeModel.groovy deleted file mode 100644 index fa5cc18..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/PresentationModelTreeModel.groovy +++ /dev/null @@ -1,103 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import cfa.vo.vodml.gui.PresentationModel - -import javax.swing.event.TreeModelEvent -import javax.swing.event.TreeModelListener -import javax.swing.tree.TreeModel -import javax.swing.tree.TreePath - -class PresentationModelTreeModel implements TreeModel { - private final simpleAttrs = ["name", "version", "authors", "imports", "description", "title", "lastModified"] - private List listeners = new ArrayList<>() - ModelTreeNode model - - public PresentationModelTreeModel(PresentationModel model) { - this.model = new ModelTreeNode(model, this) - model.propertyChange = { e -> - if (e.propertyName in simpleAttrs) { - listeners*.treeNodesChanged(new TreeModelEvent(this.model, new TreePath(this.model))) - } else { - listChanged() - } - } - } - - def listChanged() { - listeners*.treeStructureChanged(new TreeModelEvent(this.model, new TreePath(this.model))) - } - - @Override - Object getRoot() { - return model - } - - @Override - Object getChild(Object parent, int index) { - parent.getChildAt(index) - } - - @Override - int getChildCount(Object parent) { - return parent.getChildCount() - } - - @Override - boolean isLeaf(Object node) { - node.isLeaf() - } - - @Override - void valueForPathChanged(TreePath path, Object newValue) { - listeners.each { - it.treeNodesChanged(new TreeModelEvent(newValue, path)) - } - } - - @Override - int getIndexOfChild(Object parent, Object child) { - return parent.getIndex(child) - } - - @Override - void addTreeModelListener(TreeModelListener l) { - listeners.add(l) - } - - @Override - void removeTreeModelListener(TreeModelListener l) { - listeners.remove(l) - } -} diff --git a/src/main/groovy/cfa/vo/vodml/gui/tree/PrimitiveTypeListNode.groovy b/src/main/groovy/cfa/vo/vodml/gui/tree/PrimitiveTypeListNode.groovy deleted file mode 100644 index 3835401..0000000 --- a/src/main/groovy/cfa/vo/vodml/gui/tree/PrimitiveTypeListNode.groovy +++ /dev/null @@ -1,42 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import ca.odell.glazedlists.EventList -import cfa.vo.vodml.metamodel.PrimitiveType - -class PrimitiveTypeListNode extends ListTreeNode { - PrimitiveTypeListNode(EventList userObject, Object parent) { - super("Primitive Type", userObject, parent) - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/ControllerSpec.groovy b/src/test/groovy/cfa/vo/vodml/gui/ControllerSpec.groovy deleted file mode 100644 index 85ef8b5..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/ControllerSpec.groovy +++ /dev/null @@ -1,69 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import cfa.vo.vodml.io.VodmlReader -import spock.lang.Specification - -import static org.junit.Assert.fail - -class ControllerSpec extends Specification { - private Controller controller - private String readPath - private MainView view - private PresentationModel expected - - void setup() { - view = Mock(MainView.class) - controller = new Controller() - readPath = this.class.getResource("/DatasetMetadata-1.0.vo-dml.xml").getFile() - expected = new PresentationModel(new VodmlReader().read(new File(readPath))) - } - - def "test load"() { - when: - PresentationModel actual = controller.load(readPath) - - then: - assert actual == expected - } - - void testLoadFileNotFound() { - try { - controller.load(readPath+"DOESNTEXIST") - } catch (FileNotFoundException e) { - return // should fail - } - fail("Should have thown exception") - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/GuiTestCase.groovy b/src/test/groovy/cfa/vo/vodml/gui/GuiTestCase.groovy deleted file mode 100644 index 5f31d13..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/GuiTestCase.groovy +++ /dev/null @@ -1,53 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import org.uispec4j.UISpec4J -import org.uispec4j.interception.toolkit.UISpecDisplay -import spock.lang.Specification - - -class GuiTestCase extends Specification { - static { - UISpec4J.init() - } - - public setup() { - UISpecDisplay.instance().reset() - } - - public teardown() { - UISpecDisplay.instance().rethrowIfNeeded() - UISpecDisplay.instance().reset() - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/MainViewTest.groovy b/src/test/groovy/cfa/vo/vodml/gui/MainViewTest.groovy deleted file mode 100644 index 089c409..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/MainViewTest.groovy +++ /dev/null @@ -1,133 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import org.uispec4j.UISpecTestCase -import org.uispec4j.assertion.Assertion -import org.uispec4j.assertion.UISpecAssert -import org.uispec4j.interception.FileChooserHandler -import org.uispec4j.interception.MainClassAdapter -import org.uispec4j.interception.WindowInterceptor - -class MainViewTest extends UISpecTestCase { - private String path = getClass().getResource("/DatasetMetadata-1.0.vo-dml.xml").file - - @Override - void setUp() { - setAdapter(new MainClassAdapter(MainView.class)) - } - - void testMainEmpty() { - mainWindow.titleEquals("VODML Model Builder").check() - mainWindow.getTextBox("status").textEquals("WARNING: No Model Selected").check() - } - - void testTabNameBinding() { - loadTestFile() - - mainWindow.getTextBox("nameField").text = "changed" - UISpecAssert.waitUntil({"changed v1.0" == mainWindow.tabGroup.awtComponent.getTitleAt(0)} as Assertion, 1000) - } - - void testLoad() { - loadTestFile() - - mainWindow.tree.contentEquals(""" -ds v1.0 - Primitive Types - Enumerations - Data Types - Object Types - Packages - experiment - Primitive Types - Enumerations - Data Types - Object Types - Observation - ObsConfig - BaseTarget - Target - AstroTarget - Facility - Instrument - Proposal - Characterisation - Derived - ObsDataset - DerivedElement - DerivedScalar - Packages - dataset - Primitive Types - Enumerations - DataProductType - CreationType - RightsType - SpectralBandType - Data Types - Object Types - DataModel - Dataset - DataID - Curation - Publisher - Contact - Creator - Contributor - Publication - Collection - Packages - party - Primitive Types - Enumerations - Data Types - Object Types - Party - Role - Individual - Organization - Packages - -""").check() - } - - private loadTestFile() { - WindowInterceptor - .init(mainWindow.menuBar.getMenu("File").getSubMenu("Load...").triggerClick()) - .process(FileChooserHandler.init().select(path)) - .run() - - UISpecAssert.waitUntil(mainWindow.getTabGroup("main").tabNamesEquals(["ds v1.0"] as String[]), 5000) - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/ModelTabFactoryTest.groovy b/src/test/groovy/cfa/vo/vodml/gui/ModelTabFactoryTest.groovy deleted file mode 100644 index 9dc2ab1..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/ModelTabFactoryTest.groovy +++ /dev/null @@ -1,69 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import spock.lang.Specification - - -class ModelTabFactoryTest extends Specification { - private FactoryBuilderSupport fbs = Stub(FactoryBuilderSupport) - private PresentationModel model = new PresentationModel() - private ModelTabFactory factory = new ModelTabFactory() - - def "Invoke with value only"(){ - when: "factory method is invoked with value only" - def tab = factory.newInstance(fbs, "name", model, null) - - then: "tab is an instance of ModelTab with correct model" - assert tab instanceof ModelTab - assert tab.model == model - } - - def "Invoke with value and attributes"() { - when: "factory method is invoked with value and attributes" - factory.newInstance(fbs, "name", model, [attr: "whatever"]) - - then: "exception is thrown" - def ex = thrown(InstantiationException) - ex.message == "No attributes allowed in building element. Only a value accepted" - } - - def "Invoke with null value"() { - when: "factory method is invoked with null value" - factory.newInstance(fbs, "name", null, null) - - then: "exception is thrown" - def ex = thrown(InstantiationException) - ex.message == "Please provide a PresentationModel value, none was provided" - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/ModelTabSpec.groovy b/src/test/groovy/cfa/vo/vodml/gui/ModelTabSpec.groovy deleted file mode 100644 index afb75f7..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/ModelTabSpec.groovy +++ /dev/null @@ -1,79 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import org.uispec4j.Panel -import org.uispec4j.assertion.UISpecAssert - -class ModelTabSpec extends GuiTestCase { - - def "tree root name is bound to model name"() { - given: - def modelTab = new ModelTab(new PresentationModel()) - Panel panel = new Panel(modelTab) - - when: "The model name is changed from the GUI" - panel.getTextBox("nameField").text = "changed" - - then: "The tree root element changes accordingly" - UISpecAssert.waitUntil(panel.tree.contentEquals(""" -changed v1.0 - Primitive Types - Enumerations - Data Types - Object Types - Packages - -"""), 1000) - } - - def "tree root name is bound to model version"() { - given: - def modelTab = new ModelTab(new PresentationModel()) - Panel panel = new Panel(modelTab) - - when: "The model name is changed from the GUI" - panel.getTextBox("versionField").text = "73.4" - - then: "The tree root element changes accordingly" - UISpecAssert.waitUntil(panel.tree.contentEquals(""" -my_model v73.4 - Primitive Types - Enumerations - Data Types - Object Types - Packages - -"""), 1000) - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/ModelTest.groovy b/src/test/groovy/cfa/vo/vodml/gui/ModelTest.groovy deleted file mode 100644 index 54d78aa..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/ModelTest.groovy +++ /dev/null @@ -1,57 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import cfa.vo.vodml.io.VodmlReader -import org.junit.Before -import org.junit.Test - -class ModelTest { - private PresentationModel model - - @Before - public void setUp() { - model = new PresentationModel(new VodmlReader().read(getClass().getResource("/DatasetMetadata-1.0.vo-dml.xml").openStream())) - } - - @Test - void testGetTreeModel() { - def treeModel = model.treeModel - def root = treeModel.getRoot() - assert root.userObject == model - assert root.getChildAt(4).toString() == "Packages" - (0..2).each { - assert root.getChildAt(4).getChildAt(it).userObject.name == model.packages.get(it).name - } - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/ModelViewSpec.groovy b/src/test/groovy/cfa/vo/vodml/gui/ModelViewSpec.groovy deleted file mode 100644 index 4acd782..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/ModelViewSpec.groovy +++ /dev/null @@ -1,147 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import ca.odell.glazedlists.BasicEventList -import cfa.vo.vodml.metamodel.ModelImport -import org.joda.time.DateTime -import org.joda.time.DateTimeZone -import org.uispec4j.Panel -import org.uispec4j.Window -import org.uispec4j.assertion.UISpecAssert -import org.uispec4j.interception.WindowInterceptor - -class ModelViewSpec extends GuiTestCase { - private PresentationModel model - private ModelView view - private Panel panel - - def setup() { - model = [name: "test", version: "1.0", description: "A description", - title: "Test Model", lastModified: new DateTime("2016-02-14T10:30Z").withZone(DateTimeZone.UTC), - authors: ["Titius", "Caius", "Sempronius"] as BasicEventList, - imports: [ - new ModelImport(name: "model1", version: "1.1", url: new URI("http://some"), documentationURL: new URI("http://some.doc")), - new ModelImport(name: "model2", version: "2.1", url: new URI("http://other"), documentationURL: new URI("http://other.doc")), - ] as BasicEventList - ] as PresentationModel - view = new ModelView(model) - panel = new Panel(view) - } - - def "test instantiation"() { - expect: - view.model == model - text("nameField") == "test" - text("descriptionField") == "A description" - text("versionField") == "1.0" - text("titleField") == "Test Model" - text("lastModifiedField") == new DateTime("2016-02-14T10:30:00.000Z") - .withZone(DateTimeZone.UTC).toString() - panel.listBox.contentEquals("Titius", "Caius", "Sempronius").check() - panel.table.contentEquals( - ["name", "version", "url", "documentationurl"] as String[], - [["model1", "1.1", "http://some", "http://some.doc"], - ["model2", "2.1", "http://other", "http://other.doc"]] as String[][]) - .check() - } - - def "test binding of text fields"() { - when: - panel.getTextBox("nameField").text = "new" - panel.getTextBox("descriptionField").text = "Different" - panel.getTextBox("versionField").text = "3.5" - panel.getTextBox("titleField").text = "Another" - panel.getTextBox("lastModifiedField").text = "2011-01-30T9:45" - - then: - view.model.name == "new" - view.model.description == "Different" - view.model.version == "3.5" - view.model.title == "Another" - view.model.lastModified == new DateTime("2011-01-30T9:45") - } - - def "test binding of authors list"() { - when: - WindowInterceptor.init(panel.getPanel("authors").getButton("add").triggerClick()) - .process { Window window -> - window.getInputTextBox().text = "Iulius" - window.getButton("OK").triggerClick() - }.run() - then: - view.model.authors == ["Titius", "Caius", "Sempronius", "Iulius"] - } - - def "test binding of model imports table"() { - when: - WindowInterceptor.init(panel.getPanel("imports").getButton("add").triggerClick()) - .process { Window window -> - window.getInputTextBox("nameField").text = "someImport" - window.getInputTextBox("versionField").text = "1.0" - window.getInputTextBox("impUrlField").text = "https://ideas" - window.getInputTextBox("impDocUrlField").text = "https://ideas.doc" - window.getButton("OK").triggerClick() - }.run() - then: - panel.table.contentEquals( - ["name", "version", "url", "documentationUrl"] as String[], - [["model1", "1.1", "http://some", "http://some.doc"], - ["model2", "2.1", "http://other", "http://other.doc"], - ["someImport", "1.0", "https://ideas", "https://ideas.doc"] - ] as String[][]) - .true - } - - def "test remove model imports"() { - when: - Panel imp = panel.getPanel("imports") - imp.table.selectAllRows() - imp.getButton("remove").click() - then: - UISpecAssert.waitUntil(imp.table.isEmpty(), 1000) - } - - def "test remove authors"() { - when: - Panel imp = panel.getPanel("authors") - imp.listBox.selectIndices(0,1,2) - imp.getButton("remove").click() - then: - UISpecAssert.waitUntil(imp.listBox.isEmpty(), 1000) - } - - def text = {String name -> - panel.getTextBox(name).text - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/StatusPanelTest.groovy b/src/test/groovy/cfa/vo/vodml/gui/StatusPanelTest.groovy deleted file mode 100644 index 7757f05..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/StatusPanelTest.groovy +++ /dev/null @@ -1,65 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui - -import org.uispec4j.Panel -import org.uispec4j.assertion.UISpecAssert -import spock.lang.Specification - -class StatusPanelTest extends Specification { - private StatusPanel panel - private Panel uiPanel - - def setup() { - panel = new StatusPanel() - uiPanel = new Panel(panel) - } - - def "test setStatus method updates status"() { - when: - panel.status = "Some Status" - then: - statusAssertion("Some Status").check() - } - - def "test status updates when logging remotely"() { - when: - StatusPanel.STATUS_LOGGER.info("message") - then: - UISpecAssert.waitUntil(statusAssertion("INFO: message"), 1000) - } - - def statusAssertion = { message -> - uiPanel.getTextBox("status").textEquals(message) - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/tree/PresentationModelJTreeSpec.groovy b/src/test/groovy/cfa/vo/vodml/gui/tree/PresentationModelJTreeSpec.groovy deleted file mode 100644 index 89845a8..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/tree/PresentationModelJTreeSpec.groovy +++ /dev/null @@ -1,119 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import cfa.vo.vodml.gui.GuiTestCase -import cfa.vo.vodml.gui.PresentationModel -import cfa.vo.vodml.metamodel.Model -import cfa.vo.vodml.metamodel.Package -import groovy.swing.SwingBuilder -import org.uispec4j.Trigger -import org.uispec4j.Window -import org.uispec4j.interception.PopupMenuInterceptor -import org.uispec4j.interception.WindowInterceptor - -class PresentationModelJTreeSpec extends GuiTestCase { - private Window window - private PresentationModel pModel - - def setup() { - def swing = new SwingBuilder() - swing.registerBeanFactory("tree", PresentationModelJTree) - Model model = new Model() - pModel = new PresentationModel(model) - PresentationModelTreeModel treeModel = new PresentationModelTreeModel(pModel) - - WindowInterceptor - .init({ - swing.edt { - frame(show:true, pack:true) { - scrollPane() { - tree(model: treeModel, showsRootHandles: false) - } - } - } - }) - .process({w-> window = w; return Trigger.DO_NOTHING}) - .run() - } - - def "test single selection"() { - when: - window.tree.select(["Primitive Types", "Enumerations"] as String[]) - - then: - window.tree.selectionEquals(["Primitive Types",] as String[]).check() - } - - def "test tree is restored to previous state after structure change"() { - given: - pModel.packages.add(new Package(name: "aPackage")) - window.tree.expandAll() - - when: - pModel.packages.add(new Package(name: "anotherPackage")) - - then: - window.tree.pathIsExpanded("Packages").check() - } - - def "test packageList popup menu"(String name) { - expect: - PopupMenuInterceptor - .run(window.tree.triggerRightClick("${name}s")) - .contentEquals( - ["Add $name"] as String[]) - .check() - where: - name | _ - "Package" | _ - "Primitive Type" | _ - "Enumeration" | _ - "Data Type" | _ - "Object Type" | _ - } - - def "test packageLike popup menu"() { - given: - pModel.packages.add(new Package(name: "aPackage")) - - expect: - PopupMenuInterceptor - .run(window.tree.triggerRightClick("Packages/aPackage")) - .contentEquals( - ["Primitive Type", "Enumeration", "Data Type", "Object Type", "Package"].collect { - "Add $it" - } as String[]) - .check() - } -} diff --git a/src/test/groovy/cfa/vo/vodml/gui/tree/PresentationModelTreeModelSpec.groovy b/src/test/groovy/cfa/vo/vodml/gui/tree/PresentationModelTreeModelSpec.groovy deleted file mode 100644 index 6ed910c..0000000 --- a/src/test/groovy/cfa/vo/vodml/gui/tree/PresentationModelTreeModelSpec.groovy +++ /dev/null @@ -1,212 +0,0 @@ -/* - * #%L - * jovial - * %% - * Copyright (C) 2016 Smithsonian Astrophysical Observatory - * %% - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the Smithsonian Astrophysical Observatory nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package cfa.vo.vodml.gui.tree - -import ca.odell.glazedlists.BasicEventList -import cfa.vo.vodml.gui.GuiTestCase -import cfa.vo.vodml.gui.PresentationModel -import cfa.vo.vodml.metamodel.* -import groovy.swing.SwingBuilder -import org.uispec4j.Panel -import org.uispec4j.assertion.UISpecAssert - -import javax.swing.* -import javax.swing.tree.TreeSelectionModel - -class PresentationModelTreeModelSpec extends GuiTestCase { - private Panel panel - private PresentationModel pModel - - def setup() { - Model model = new Model() - pModel = new PresentationModel(model) - PresentationModelTreeModel treeModel = new PresentationModelTreeModel(pModel) - JScrollPane jPanel - JTree jTree - - new SwingBuilder().edt { - jPanel = scrollPane() { - jTree = tree(model: treeModel, showsRootHandles: true) - } - } - - jTree.selectionModel.selectionMode = TreeSelectionModel.SINGLE_TREE_SELECTION - - panel = new Panel(jPanel) - } - - def "test basic info"() { - expect: - panel.tree.contentEquals(expectedInitialTree).check() - } - - def "test binding of packages"() { - when: - pModel.packages.add([name: "newPackage"] as Package) - - then: - UISpecAssert.waitUntil(panel.tree.contentEquals(treePackage), 1000) - } - - def "test nested packages"() { - when: - pModel.packages.add([name: "newPackage", packages: [[name: "nestedPackage"] as Package] as BasicEventList] as Package) - - then: - UISpecAssert.waitUntil(panel.tree.contentEquals(treeNestedPackage), 1000) - } - - def "test binding of primitive types"() { - when: - pModel.primitiveTypes.add([name: "aPrimitiveType"] as PrimitiveType) - - then: - UISpecAssert.waitUntil(panel.tree.contentEquals(treePrimitiveType), 1000) - } - - def "test binding of enumerations"() { - when: - pModel.enumerations.add(createEnumeration()) - - then: - UISpecAssert.waitUntil(panel.tree.contentEquals(enumerationTree), 1000) - } - - def "test binding of dataTypes"() { - when: - pModel.dataTypes.add([name: "aDataType", ] as DataType) - - then: - UISpecAssert.waitUntil(panel.tree.contentEquals(dataTypeTree), 1000) - } - - def "test binding of objectTypes"() { - when: - pModel.objectTypes.add([name: "anObjectType"] as ObjectType) - - then: - UISpecAssert.waitUntil(panel.tree.contentEquals(objectTypeTree), 1000) - } - - private Enumeration_ createEnumeration() { - Enumeration_ enumeration = new Enumeration_(name: "anEnumeration") - enumeration.literals.add([name: "A"] as EnumLiteral) - enumeration.literals.add([name: "B"] as EnumLiteral) - return enumeration - } - - def expectedInitialTree = """ -my_model v1.0 - Primitive Types - Enumerations - Data Types - Object Types - Packages -""" - - def treePackage = """ -my_model v1.0 - Primitive Types - Enumerations - Data Types - Object Types - Packages - newPackage - Primitive Types - Enumerations - Data Types - Object Types - Packages -""" - - def treeNestedPackage = """ -my_model v1.0 - Primitive Types - Enumerations - Data Types - Object Types - Packages - newPackage - Primitive Types - Enumerations - Data Types - Object Types - Packages - nestedPackage - Primitive Types - Enumerations - Data Types - Object Types - Packages -""" - - def treePrimitiveType = """ -my_model v1.0 - Primitive Types - aPrimitiveType - Enumerations - Data Types - Object Types - Packages -""" - - def enumerationTree = """ -my_model v1.0 - Primitive Types - Enumerations - anEnumeration - Data Types - Object Types - Packages -""" - - def dataTypeTree = """ -my_model v1.0 - Primitive Types - Enumerations - Data Types - aDataType - Object Types - Packages -""" - - def objectTypeTree = """ -my_model v1.0 - Primitive Types - Enumerations - Data Types - Object Types - anObjectType - Packages -""" -}