From f5293668c517cbd14e099aada1b325a7ef68a7ef Mon Sep 17 00:00:00 2001
From: Richard Pajersky <xpajersk@fi.muni.cz>
Date: Wed, 2 Dec 2020 14:49:17 +0100
Subject: [PATCH] Added Canvas as Window

---
 GUI/pom.xml                                   |  20 ++++
 .../analyst/gui/CanvasTopComponent.form       |  67 +++++++++++
 .../analyst/gui/CanvasTopComponent.java       | 109 ++++++++++++++++++
 GUI/src/main/nbm/manifest.mf                  |  12 +-
 4 files changed, 202 insertions(+), 6 deletions(-)
 create mode 100644 GUI/src/main/java/cz/fidentis/analyst/gui/CanvasTopComponent.form
 create mode 100644 GUI/src/main/java/cz/fidentis/analyst/gui/CanvasTopComponent.java

diff --git a/GUI/pom.xml b/GUI/pom.xml
index af49c765..b1342d8c 100644
--- a/GUI/pom.xml
+++ b/GUI/pom.xml
@@ -101,6 +101,26 @@
             <artifactId>vecmath</artifactId>
             <version>${version.javax.vecmath}</version>
         </dependency>
+        <dependency>
+            <groupId>org.netbeans.api</groupId>
+            <artifactId>org-openide-windows</artifactId>
+            <version>${netbeans.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.netbeans.api</groupId>
+            <artifactId>org-openide-util-ui</artifactId>
+            <version>${netbeans.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.netbeans.api</groupId>
+            <artifactId>org-openide-util-lookup</artifactId>
+            <version>${netbeans.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.netbeans.api</groupId>
+            <artifactId>org-netbeans-modules-settings</artifactId>
+            <version>${netbeans.version}</version>
+        </dependency>
     </dependencies>
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/CanvasTopComponent.form b/GUI/src/main/java/cz/fidentis/analyst/gui/CanvasTopComponent.form
new file mode 100644
index 00000000..45c7d463
--- /dev/null
+++ b/GUI/src/main/java/cz/fidentis/analyst/gui/CanvasTopComponent.form
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+
+<Form version="1.4" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="575" max="32767" attributes="0"/>
+          <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
+                  <Component id="canvas1" max="32767" attributes="0"/>
+                  <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
+              </Group>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="411" max="32767" attributes="0"/>
+          <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
+                  <Component id="canvas1" max="32767" attributes="0"/>
+                  <EmptySpace min="0" pref="0" max="-2" attributes="0"/>
+              </Group>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="cz.fidentis.analyst.gui.Canvas" name="canvas1">
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/GUI/src/main/java/cz/fidentis/analyst/gui/CanvasTopComponent.java b/GUI/src/main/java/cz/fidentis/analyst/gui/CanvasTopComponent.java
new file mode 100644
index 00000000..c5253611
--- /dev/null
+++ b/GUI/src/main/java/cz/fidentis/analyst/gui/CanvasTopComponent.java
@@ -0,0 +1,109 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package cz.fidentis.analyst.gui;
+
+import org.netbeans.api.settings.ConvertAsProperties;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.windows.TopComponent;
+import org.openide.util.NbBundle.Messages;
+
+/**
+ *
+ * @author Richard PajerskĂ˝
+ * 
+ * Window for Canvas
+ */
+@ConvertAsProperties(
+        dtd = "-//cz.fidentis.analyst.gui//Canvas//EN",
+        autostore = false
+)
+@TopComponent.Description(
+        preferredID = "CanvasTopComponent",
+        //iconBase="SET/PATH/TO/ICON/HERE",
+        persistenceType = TopComponent.PERSISTENCE_ALWAYS
+)
+@TopComponent.Registration(mode = "editor", openAtStartup = true)
+@ActionID(category = "Window", id = "cz.fidentis.analyst.gui.CanvasTopComponent")
+@ActionReference(path = "Menu/Window" /*, position = 333 */)
+@TopComponent.OpenActionRegistration(
+        displayName = "#CTL_CanvasAction",
+        preferredID = "CanvasTopComponent"
+)
+@Messages({
+    "CTL_CanvasAction=Canvas",
+    "CTL_CanvasTopComponent=Canvas",
+    "HINT_CanvasTopComponent=This is a Canvas window"
+})
+public final class CanvasTopComponent extends TopComponent {
+
+    public CanvasTopComponent() {
+        initComponents();
+        setName(Bundle.CTL_CanvasTopComponent());
+        setToolTipText(Bundle.HINT_CanvasTopComponent());
+        putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE);
+        putClientProperty(TopComponent.PROP_DRAGGING_DISABLED, Boolean.TRUE);
+        putClientProperty(TopComponent.PROP_UNDOCKING_DISABLED, Boolean.TRUE);
+
+    }
+
+    /**
+     * This method is called from within the constructor to initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is always
+     * regenerated by the Form Editor.
+     */
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        canvas1 = new cz.fidentis.analyst.gui.Canvas();
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 575, Short.MAX_VALUE)
+            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addGroup(layout.createSequentialGroup()
+                    .addGap(0, 0, 0)
+                    .addComponent(canvas1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addGap(0, 0, 0)))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 411, Short.MAX_VALUE)
+            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addGroup(layout.createSequentialGroup()
+                    .addGap(0, 0, 0)
+                    .addComponent(canvas1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addGap(0, 0, 0)))
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private cz.fidentis.analyst.gui.Canvas canvas1;
+    // End of variables declaration//GEN-END:variables
+    @Override
+    public void componentOpened() {
+        // TODO add custom code on component opening
+    }
+
+    @Override
+    public void componentClosed() {
+        // TODO add custom code on component closing
+    }
+
+    void writeProperties(java.util.Properties p) {
+        // better to version settings since initial version as advocated at
+        // http://wiki.apidesign.org/wiki/PropertyFiles
+        p.setProperty("version", "1.0");
+        // TODO store your settings
+    }
+
+    void readProperties(java.util.Properties p) {
+        String version = p.getProperty("version");
+        // TODO read your settings according to their version
+    }
+}
diff --git a/GUI/src/main/nbm/manifest.mf b/GUI/src/main/nbm/manifest.mf
index cc2b72af..1ecced8c 100644
--- a/GUI/src/main/nbm/manifest.mf
+++ b/GUI/src/main/nbm/manifest.mf
@@ -1,6 +1,6 @@
-Manifest-Version: 1.0
-OpenIDE-Module: cz.fidentis.analyst.gui
-OpenIDE-Module-Install: cz/fidentis/analyst/gui/Installer.class
-OpenIDE-Module-Localizing-Bundle: cz/fidentis/analyst/gui/Bundle.properties
-OpenIDE-Module-Requires: org.openide.windows.WindowManager
-OpenIDE-Module-Specification-Version: 1.0
+Manifest-Version: 1.0
+OpenIDE-Module: cz.fidentis.analyst.gui
+OpenIDE-Module-Install: cz/fidentis/analyst/gui/Installer.class
+OpenIDE-Module-Localizing-Bundle: cz/fidentis/analyst/gui/Bundle.properties
+OpenIDE-Module-Requires: org.openide.windows.WindowManager
+OpenIDE-Module-Specification-Version: 1.0
-- 
GitLab