marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject [12/13] git commit: MARMOTTA-419: Swiched UI to plain AWT/Swing
Date Fri, 10 Jan 2014 14:03:35 GMT
MARMOTTA-419: Swiched UI to plain AWT/Swing


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/0c8ccdb9
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/0c8ccdb9
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/0c8ccdb9

Branch: refs/heads/develop
Commit: 0c8ccdb98198f92247ae330dd37c8f974931cd8f
Parents: 75f106d
Author: Jakob Frank <jakob@apache.org>
Authored: Fri Jan 10 14:48:09 2014 +0100
Committer: Jakob Frank <jakob@apache.org>
Committed: Fri Jan 10 15:02:53 2014 +0100

----------------------------------------------------------------------
 launchers/marmotta-installer/pom.xml            |  18 ++
 .../src/main/resources/installer/standalone.xml |   1 +
 launchers/marmotta-splash/pom.xml               |   4 +
 .../marmotta/splash/ProgressListener.java       |   2 +-
 .../marmotta/splash/SplashContextListener.java  |   2 +-
 .../marmotta/splash/SplashScreenListener.java   |   2 +-
 .../splash/SplashScreenUpdaterBase.java         |   2 +-
 .../marmotta/splash/common/MarmottaContext.java |   2 +-
 .../splash/common/MarmottaStartupHelper.java    |   2 +-
 .../splash/common/ui/MessageDialog.java         | 142 ++++++++++++
 .../splash/common/ui/SelectionDialog.java       | 215 +++++++++++++++++++
 .../splash/startup/StartupListener.java         |  27 ++-
 .../splash/systray/SystrayListener.java         |  20 +-
 .../splash/startup/StartupListenerTest.java     |  26 +++
 14 files changed, 440 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-installer/pom.xml
----------------------------------------------------------------------
diff --git a/launchers/marmotta-installer/pom.xml b/launchers/marmotta-installer/pom.xml
index 1840233..2478fdd 100644
--- a/launchers/marmotta-installer/pom.xml
+++ b/launchers/marmotta-installer/pom.xml
@@ -210,6 +210,24 @@
                                 </configuration>
                             </execution>
                             <execution>
+                                <id>copy</id>
+                                <phase>compile</phase>
+                                <goals>
+                                    <goal>copy</goal>
+                                </goals>
+                                <configuration>
+                                    <artifactItems>
+                                        <artifactItem>
+                                            <groupId>org.apache.commons</groupId>
+                                            <artifactId>commons-lang3</artifactId>
+                                            <overWrite>false</overWrite>
+                                            <outputDirectory>${stagingDir}/lib</outputDirectory>
+                                            <destFileName>apache-commons-lang3.jar</destFileName>
+                                        </artifactItem>
+                                    </artifactItems>
+                                </configuration>
+                            </execution>
+                            <execution>
                                 <id>unpack</id>
                                 <phase>package</phase>
                                 <goals>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-installer/src/main/resources/installer/standalone.xml
----------------------------------------------------------------------
diff --git a/launchers/marmotta-installer/src/main/resources/installer/standalone.xml b/launchers/marmotta-installer/src/main/resources/installer/standalone.xml
index 804163f..d6d68be 100644
--- a/launchers/marmotta-installer/src/main/resources/installer/standalone.xml
+++ b/launchers/marmotta-installer/src/main/resources/installer/standalone.xml
@@ -89,6 +89,7 @@
             <file src="tomcat/index.jsp" targetdir="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/webapps/ROOT"
override="true" />
             <file src="log/catalina.out" targetdir="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/logs"
/>
             <file src="lib/marmotta-splash-${MARMOTTA_VERSION}.jar" targetdir="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/lib"
/>
+            <file src="lib/apache-commons-lang3.jar" targetdir="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/lib"
/>
             <!-- macos specific -->
             <file src="macos/Start Apache Marmotta.app" targetdir="\$INSTALL_PATH" os="mac"
/>
             <file src="images/icon_start.icns" targetdir="\$INSTALL_PATH/Start Apache
Marmotta.app/Contents/Resources" os="mac" />

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/pom.xml
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/pom.xml b/launchers/marmotta-splash/pom.xml
index af5c5db..4b1e73f 100644
--- a/launchers/marmotta-splash/pom.xml
+++ b/launchers/marmotta-splash/pom.xml
@@ -44,6 +44,10 @@
             <version>7.0.27.1</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/ProgressListener.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/ProgressListener.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/ProgressListener.java
index 6206d88..c105dd3 100644
--- a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/ProgressListener.java
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/ProgressListener.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashContextListener.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashContextListener.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashContextListener.java
index 2f46be4..32ee6e1 100644
--- a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashContextListener.java
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashContextListener.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenListener.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenListener.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenListener.java
index cb02101..9eb2df0 100644
--- a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenListener.java
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenListener.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenUpdaterBase.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenUpdaterBase.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenUpdaterBase.java
index 2a07610..43d0b92 100644
--- a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenUpdaterBase.java
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/SplashScreenUpdaterBase.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaContext.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaContext.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaContext.java
index edc4708..beb3402 100644
--- a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaContext.java
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaContext.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaStartupHelper.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaStartupHelper.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaStartupHelper.java
index 071cdcd..2fa9533 100644
--- a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaStartupHelper.java
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/MarmottaStartupHelper.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/ui/MessageDialog.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/ui/MessageDialog.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/ui/MessageDialog.java
new file mode 100644
index 0000000..e6ecf58
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/ui/MessageDialog.java
@@ -0,0 +1,142 @@
+/*
+ * 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.
+ */
+package org.apache.marmotta.splash.common.ui;
+
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.URL;
+
+import javax.swing.BorderFactory;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.WindowConstants;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.text.WordUtils;
+
+public class MessageDialog {
+    
+    public static final String MARMOTTA_ICON = "/org/apache/marmotta/splash/systray/systray.png";
+    
+    private MessageDialog() {
+        // static access only!
+    }
+
+    public static void info(String message) {
+        show("Info", message, "");
+    }
+    
+    public static void info(String title, String message) {
+        show(title, message, "");
+    }
+    
+    public static void show(String title, String message, String description) {
+        final JDialog dialog = new JDialog((Frame)null, title);
+        dialog.setModal(true);
+        dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
+        
+        final JPanel root = new JPanel(new GridBagLayout());
+        root.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+        dialog.getRootPane().setContentPane(root);
+
+        final JButton close = new JButton("OK");
+        close.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                dialog.setVisible(false);
+            }
+        });
+        GridBagConstraints cClose = new GridBagConstraints();
+        cClose.gridx = 0;
+        cClose.gridy = 2;
+        cClose.gridwidth = 2;
+        cClose.weightx = 1;
+        cClose.weighty = 0;
+        cClose.insets = new Insets(5, 5, 5, 5);
+        
+        root.add(close, cClose);
+        dialog.getRootPane().setDefaultButton(close);
+        
+        Icon icon = loadIcon(MARMOTTA_ICON) ;
+        if (icon != null) {
+            JLabel lblIcn = new JLabel(icon);
+
+            GridBagConstraints cIcon = new GridBagConstraints();
+            cIcon.gridx = 1;
+            cIcon.gridy = 0;
+            cIcon.gridheight = 2;
+            cIcon.fill = GridBagConstraints.NONE;
+            cIcon.weightx = 0;
+            cIcon.weighty = 1;
+            cIcon.anchor = GridBagConstraints.NORTH;
+            cIcon.insets = new Insets(10, 5, 5, 0);
+            root.add(lblIcn, cIcon);
+        }
+        
+        JLabel lblMsg = new JLabel("<html>"+StringEscapeUtils.escapeHtml3(message).replaceAll("\\n",
"<br>"));
+        lblMsg.setFont(lblMsg.getFont().deriveFont(Font.BOLD, 16f));
+        GridBagConstraints cLabel = new GridBagConstraints();
+        cLabel.gridx = 0;
+        cLabel.gridy = 0;
+        cLabel.fill = GridBagConstraints.BOTH;
+        cLabel.weightx = 1;
+        cLabel.weighty = 0.5;
+        cLabel.insets = new Insets(5, 5, 5, 5);
+        root.add(lblMsg, cLabel);
+        
+        JLabel lblDescr = new JLabel("<html>"+StringEscapeUtils.escapeHtml3(description).replaceAll("\\n",
"<br>"));
+        cLabel.gridy++;
+        cLabel.insets = new Insets(0, 5, 5, 5);
+        root.add(lblDescr, cLabel);
+        
+        
+        dialog.pack();
+        dialog.setLocationRelativeTo(null);
+        
+        dialog.setVisible(true);
+        dialog.dispose();
+    }
+    
+    static Icon loadIcon() {
+        return loadIcon(MARMOTTA_ICON);
+    }
+
+    static Icon loadIcon(String icon) {
+        if (icon == null) return null;
+        final URL rsc = MessageDialog.class.getResource(icon);
+        if (rsc != null) {
+            return new ImageIcon(rsc);
+        } else {
+            return null;
+        }
+    }
+
+    public static void main(String[] args) {
+        show("Hello", "This is a test", 
+                WordUtils.wrap("Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea
takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing
elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed
diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.", 55));
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/ui/SelectionDialog.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/ui/SelectionDialog.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/ui/SelectionDialog.java
new file mode 100644
index 0000000..8f287c9
--- /dev/null
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/common/ui/SelectionDialog.java
@@ -0,0 +1,215 @@
+/*
+ * 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.
+ */
+package org.apache.marmotta.splash.common.ui;
+
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.swing.AbstractButton;
+import javax.swing.BorderFactory;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.WindowConstants;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
+
+public class SelectionDialog {
+
+    
+    public static int select(String title, String message, String description, List<Option>
options, int defaultOption) {
+        final JDialog dialog = new JDialog((Frame)null, title);
+        dialog.setModal(true);
+        dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
+        
+        final AtomicInteger result = new AtomicInteger(Math.max(defaultOption,-1));
+        
+        JButton defaultBtn = null;
+        
+        final JPanel root = new JPanel(new GridBagLayout());
+        root.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+        dialog.getRootPane().setContentPane(root);
+
+        JLabel lblMsg = new JLabel("<html>"+StringEscapeUtils.escapeHtml3(message).replaceAll("\\n",
"<br>"));
+        lblMsg.setFont(lblMsg.getFont().deriveFont(Font.BOLD, 16f));
+        GridBagConstraints cLabel = new GridBagConstraints();
+        cLabel.gridx = 0;
+        cLabel.gridy = 0;
+        cLabel.fill = GridBagConstraints.BOTH;
+        cLabel.weightx = 1;
+        cLabel.weighty = 0.5;
+        cLabel.insets = new Insets(5, 5, 5, 5);
+        root.add(lblMsg, cLabel);
+        
+        JLabel lblDescr = new JLabel("<html>"+StringEscapeUtils.escapeHtml3(description).replaceAll("\\n",
"<br>"));
+        cLabel.gridy++;
+        cLabel.insets = new Insets(0, 5, 5, 5);
+        root.add(lblDescr, cLabel);
+
+        // All the options
+        cLabel.ipadx = 10;
+        cLabel.ipady = 10;
+        cLabel.insets = new Insets(5, 15, 0, 15);
+        for (int i = 0; i < options.size(); i++) {
+            cLabel.gridy++;
+            
+            final Option o = options.get(i);
+            final JButton btn = new JButton("<html>"+StringEscapeUtils.escapeHtml3(o.label).replaceAll("\\n",
"<br>"), MessageDialog.loadIcon(o.icon));
+            if (StringUtils.isNotBlank(o.info)) {
+                btn.setToolTipText("<html>"+StringEscapeUtils.escapeHtml3(o.info).replaceAll("\\n",
"<br>"));
+            }
+            
+            btn.setHorizontalAlignment(AbstractButton.LEADING);
+            btn.setVerticalTextPosition(AbstractButton.CENTER);
+            btn.setHorizontalTextPosition(AbstractButton.TRAILING);
+            
+            final int myAnswer = i;
+            btn.addActionListener(new ActionListener() {
+                @Override
+                public void actionPerformed(ActionEvent e) {
+                    result.set(myAnswer);
+                    dialog.setVisible(false);
+                }
+            });
+            
+            root.add(btn, cLabel);
+            if (i == defaultOption) {
+                dialog.getRootPane().setDefaultButton(btn);
+                defaultBtn = btn;
+            }
+        }
+        
+        final Icon icon = MessageDialog.loadIcon() ;
+        if (icon != null) {
+            JLabel lblIcn = new JLabel(icon);
+
+            GridBagConstraints cIcon = new GridBagConstraints();
+            cIcon.gridx = 1;
+            cIcon.gridy = 0;
+            cIcon.gridheight = 2 + options.size();
+            cIcon.fill = GridBagConstraints.NONE;
+            cIcon.weightx = 0;
+            cIcon.weighty = 1;
+            cIcon.anchor = GridBagConstraints.NORTH;
+            cIcon.insets = new Insets(10, 5, 5, 0);
+            root.add(lblIcn, cIcon);
+        }
+        
+        final JButton close = new JButton("Cancel");
+        close.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                result.set(-1);
+                dialog.setVisible(false);
+            }
+        });
+        GridBagConstraints cClose = new GridBagConstraints();
+        cClose.gridx = 0;
+        cClose.gridy = 2 + options.size();
+        cClose.gridwidth = 2;
+        cClose.weightx = 1;
+        cClose.weighty = 0;
+        cClose.insets = new Insets(15, 5, 5, 5);
+        
+        root.add(close, cClose);
+        if (defaultOption < 0) {
+            dialog.getRootPane().setDefaultButton(close);
+            defaultBtn = close;
+        }
+        
+        
+        dialog.pack();
+        dialog.setLocationRelativeTo(null);
+        defaultBtn.requestFocusInWindow();
+        
+        dialog.setVisible(true);
+        dialog.dispose();
+
+        
+        
+        
+        return result.get();
+    }
+    
+    public static class Option {
+        private String label, info;
+        private String icon;
+        
+        public Option(String label) {
+            this(label, "", null);
+        }
+        
+        public Option(String label, String info) {
+            this(label, info, null);
+        }
+
+        public Option(String label, String info, String icon) {
+            this.label = label;
+            this.info = info;
+            this.icon = icon;
+        }
+
+        public String getLabel() {
+            return label;
+        }
+
+        public void setLabel(String label) {
+            this.label = label;
+        }
+
+        public String getInfo() {
+            return info;
+        }
+
+        public void setInfo(String info) {
+            this.info = info;
+        }
+
+        public String getIcon() {
+            return icon;
+        }
+
+        public void setIcon(String icon) {
+            this.icon = icon;
+        }
+    }
+    
+    public static void main(String[] args) {
+        final List<Option> options = Arrays.asList(
+                new Option("Option1\nfoo"),
+                new Option("Option2", "this is \nalso valid"), 
+                new Option("Option3", "", MessageDialog.MARMOTTA_ICON));
+        final int choice = select("Question", "Please select", "what do you prefer?", options,
1);
+        if (choice < 0) {
+            System.out.println("No coice was made!");
+        } else {
+            System.out.printf("Your choice was %d%n%s (%s)", choice, options.get(choice).label,
options.get(choice).info);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/startup/StartupListener.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/startup/StartupListener.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/startup/StartupListener.java
index e53905e..458f7bb 100644
--- a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/startup/StartupListener.java
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/startup/StartupListener.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -37,10 +37,12 @@ import java.util.Properties;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
+import org.apache.commons.lang3.text.WordUtils;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.oxbow.swingbits.dialog.task.CommandLink;
-import org.oxbow.swingbits.dialog.task.TaskDialogs;
+import org.apache.marmotta.splash.common.ui.MessageDialog;
+import org.apache.marmotta.splash.common.ui.SelectionDialog;
+import org.apache.marmotta.splash.common.ui.SelectionDialog.Option;
 
 /**
  * Add file description here!
@@ -87,7 +89,7 @@ public class StartupListener implements LifecycleListener {
 
 
                         if(!checkServerName(serverName) || serverPort != getServerPort())
{
-                            TaskDialogs.inform(null,
+                            MessageDialog.show("Warning",
                                     "Configured server name not found",
                                     "The host name ("+serverName+") that has been used to
configure this \n" +
                                     "installation is no longer available on this server.
The system \n" +
@@ -99,16 +101,17 @@ public class StartupListener implements LifecycleListener {
                     } else {
                         // show a dialog listing all available addresses of this server and
allowing the user to
                         // chose
-                        List<CommandLink> choices = new ArrayList<CommandLink>();
+                        List<Option> choices = new ArrayList<>();
 
                         Map<String,List<InetAddress>> addressList = listHostAddresses();
 
                         List<String> hostNames = new ArrayList<String>(addressList.keySet());
                         Collections.sort(hostNames);
 
+                        String loopback = "localhost";
                         for(String hostName : hostNames) {
                             List<InetAddress> addresses = addressList.get(hostName);
-                            String label = hostName + " (";
+                            String label = hostName + " \n(";
                             for(Iterator<InetAddress> it = addresses.iterator(); it.hasNext();
) {
                                 label += it.next().getHostAddress();
                                 if(it.hasNext()) {
@@ -121,17 +124,21 @@ public class StartupListener implements LifecycleListener {
 
                             if(addresses.get(0).isLoopbackAddress()) {
                                 text = "Local IP-Address. Recommended for Laptop use or Demonstration
purposes";
+                                loopback = hostName;
                             } else {
                                 text = "Public IP-Address. Recommended for Workstation or
Server use";
                             }
 
-                            choices.add(new CommandLink(label,text));
+                            choices.add(new Option(label, text));
                         }
 
-                        int choice = TaskDialogs.choice(null,
-                                "Select host address to use for configuring the Apache Marmotta.",
-                                "For demonstration purposes or laptop installations it is
recommended to select \n\"localhost\" below. For server and workstation installations, please
select a \npublic IP address.", 0, choices);
+                        int choice = SelectionDialog.select("Select Server Address",
+                                "Select host address to use for configuring the\nApache Marmotta
Platform.",
+                                WordUtils.wrap("For demonstration purposes or laptop installations
it is recommended to select \""+loopback+"\" below. For server and workstation installations,
please select a public IP address.", 60), 
+                                choices, 0);
 
+                        
+                        if (choice < 0) return;
 
                         serverName = hostNames.get(choice);
                         serverPort = getServerPort();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/systray/SystrayListener.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/systray/SystrayListener.java
b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/systray/SystrayListener.java
index 4ccf170..17e5ca7 100644
--- a/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/systray/SystrayListener.java
+++ b/launchers/marmotta-splash/src/main/java/org/apache/marmotta/splash/systray/SystrayListener.java
@@ -1,4 +1,4 @@
-/**
+/*
  * 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
@@ -47,7 +47,7 @@ import org.apache.catalina.LifecycleListener;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.marmotta.splash.common.MarmottaContext;
-import org.oxbow.swingbits.dialog.task.TaskDialogs;
+import org.apache.marmotta.splash.common.ui.MessageDialog;
 
 /**
  * Add file description here!
@@ -84,6 +84,8 @@ public class SystrayListener implements LifecycleListener {
         if(event.getType().equals(Lifecycle.AFTER_START_EVENT) && SystemTray.isSupported())
{
             initContextLinks();
             initSysTray();
+        } else if (event.getType().equals(Lifecycle.BEFORE_STOP_EVENT) && SystemTray.isSupported())
{
+            SystemTray.getSystemTray().remove(icon);
         }
     }
 
@@ -132,8 +134,7 @@ public class SystrayListener implements LifecycleListener {
 
             //MenuItem mainPage = createMenuItem("Start Page", "http://"+getServerName()+":"+getServerPort()+"/");
             //popup.add(mainPage);
-
-            popup.addSeparator();
+            //popup.addSeparator();
 
 
             // launch browser action
@@ -163,8 +164,10 @@ public class SystrayListener implements LifecycleListener {
             }
             popup.add(shutdown);
 
-            popup.addSeparator();
-
+            
+            if (!demoLinks.isEmpty()) {
+                popup.addSeparator();
+            }
             for(final Map.Entry<String,String> linkEntry : demoLinks.entrySet()) {
                 boolean containsEntry = false;
                 for(int i = 0; i < popup.getItemCount(); i++) {
@@ -182,14 +185,13 @@ public class SystrayListener implements LifecycleListener {
             }
 
             popup.addSeparator();
-
             MenuItem about = new MenuItem("About");
             about.addActionListener(new ActionListener() {
                 @Override
                 public void actionPerformed(ActionEvent e) {
-                    TaskDialogs.inform(null,
+                    MessageDialog.show("Apache Marmotta",
                             "About Apache Marmotta \n",
-                            "(c)2013 The Apache Software Foundation \n" +
+                            "(c)2014 The Apache Software Foundation \n" +
                             "Visit http://marmotta.apache.org for further details");
                 }
             });

http://git-wip-us.apache.org/repos/asf/marmotta/blob/0c8ccdb9/launchers/marmotta-splash/src/test/java/org/apache/marmotta/splash/startup/StartupListenerTest.java
----------------------------------------------------------------------
diff --git a/launchers/marmotta-splash/src/test/java/org/apache/marmotta/splash/startup/StartupListenerTest.java
b/launchers/marmotta-splash/src/test/java/org/apache/marmotta/splash/startup/StartupListenerTest.java
new file mode 100644
index 0000000..5bd18a1
--- /dev/null
+++ b/launchers/marmotta-splash/src/test/java/org/apache/marmotta/splash/startup/StartupListenerTest.java
@@ -0,0 +1,26 @@
+package org.apache.marmotta.splash.startup;
+
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.marmotta.splash.common.MarmottaContext;
+
+public class StartupListenerTest {
+    
+    private final StartupListener sl;
+    private final MarmottaContext marmotta;
+
+    public StartupListenerTest() {
+        sl = new StartupListener();
+        marmotta = new MarmottaContext();
+    }
+    
+    public void testLifecycleEvent() {
+        sl.lifecycleEvent(new LifecycleEvent(marmotta, Lifecycle.AFTER_START_EVENT, null));
+    }
+
+    public static void main(String[] args) {
+        new StartupListenerTest().testLifecycleEvent();
+    }
+    
+    
+}


Mime
View raw message