zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject svn commit: r1584500 [4/9] - in /zookeeper/branches/branch-3.4: bin/ src/c/ src/contrib/loggraph/web/org/apache/zookeeper/graph/resources/ src/contrib/zooinspector/ src/contrib/zooinspector/lib/ src/contrib/zooinspector/src/java/org/apache/zookeeper/in...
Date Fri, 04 Apr 2014 01:30:25 GMT
Modified: zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorConnectionPropertiesDialog.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorConnectionPropertiesDialog.java?rev=1584500&r1=1584499&r2=1584500&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorConnectionPropertiesDialog.java
(original)
+++ zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorConnectionPropertiesDialog.java
Fri Apr  4 01:30:24 2014
@@ -1,321 +1,321 @@
-/**
- * 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.zookeeper.inspector.gui;
-
-import java.awt.BorderLayout;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Map.Entry;
-
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-import org.apache.zookeeper.inspector.logger.LoggerFactory;
-import org.apache.zookeeper.inspector.manager.Pair;
-
-/**
- * The connection properties dialog. This is used to determine the settings for
- * connecting to a zookeeper instance
- */
-public class ZooInspectorConnectionPropertiesDialog extends JDialog {
-
-    private final HashMap<String, JComponent> components;
-
-    /**
-     * @param lastConnectionProps
-     *            - the last connection properties used. if this is the first
-     *            conneciton since starting the applications this will be the
-     *            default settings
-     * @param connectionPropertiesTemplateAndLabels
-     *            - the connection properties and labels to show in this dialog
-     * @param zooInspectorPanel
-     *            - the {@link ZooInspectorPanel} linked to this dialog
-     */
-    public ZooInspectorConnectionPropertiesDialog(
-            Properties lastConnectionProps,
-            Pair<Map<String, List<String>>, Map<String, String>>
connectionPropertiesTemplateAndLabels,
-            final ZooInspectorPanel zooInspectorPanel) {
-        final Map<String, List<String>> connectionPropertiesTemplate = connectionPropertiesTemplateAndLabels
-                .getKey();
-        final Map<String, String> connectionPropertiesLabels = connectionPropertiesTemplateAndLabels
-                .getValue();
-        this.setLayout(new BorderLayout());
-        this.setTitle("Connection Settings");
-        this.setModal(true);
-        this.setAlwaysOnTop(true);
-        this.setResizable(false);
-        final JPanel options = new JPanel();
-        final JFileChooser fileChooser = new JFileChooser();
-        options.setLayout(new GridBagLayout());
-        int i = 0;
-        components = new HashMap<String, JComponent>();
-        for (Entry<String, List<String>> entry : connectionPropertiesTemplate
-                .entrySet()) {
-            int rowPos = 2 * i + 1;
-            JLabel label = new JLabel(connectionPropertiesLabels.get(entry
-                    .getKey()));
-            GridBagConstraints c1 = new GridBagConstraints();
-            c1.gridx = 0;
-            c1.gridy = rowPos;
-            c1.gridwidth = 1;
-            c1.gridheight = 1;
-            c1.weightx = 0;
-            c1.weighty = 0;
-            c1.anchor = GridBagConstraints.WEST;
-            c1.fill = GridBagConstraints.HORIZONTAL;
-            c1.insets = new Insets(5, 5, 5, 5);
-            c1.ipadx = 0;
-            c1.ipady = 0;
-            options.add(label, c1);
-            if (entry.getValue().size() == 0) {
-                JTextField text = new JTextField();
-                GridBagConstraints c2 = new GridBagConstraints();
-                c2.gridx = 2;
-                c2.gridy = rowPos;
-                c2.gridwidth = 1;
-                c2.gridheight = 1;
-                c2.weightx = 0;
-                c2.weighty = 0;
-                c2.anchor = GridBagConstraints.WEST;
-                c2.fill = GridBagConstraints.HORIZONTAL;
-                c2.insets = new Insets(5, 5, 5, 5);
-                c2.ipadx = 0;
-                c2.ipady = 0;
-                options.add(text, c2);
-                components.put(entry.getKey(), text);
-            } else if (entry.getValue().size() == 1) {
-                JTextField text = new JTextField(entry.getValue().get(0));
-                GridBagConstraints c2 = new GridBagConstraints();
-                c2.gridx = 2;
-                c2.gridy = rowPos;
-                c2.gridwidth = 1;
-                c2.gridheight = 1;
-                c2.weightx = 0;
-                c2.weighty = 0;
-                c2.anchor = GridBagConstraints.WEST;
-                c2.fill = GridBagConstraints.HORIZONTAL;
-                c2.insets = new Insets(5, 5, 5, 5);
-                c2.ipadx = 0;
-                c2.ipady = 0;
-                options.add(text, c2);
-                components.put(entry.getKey(), text);
-            } else {
-                List<String> list = entry.getValue();
-                JComboBox combo = new JComboBox(list.toArray(new String[list
-                        .size()]));
-                combo.setSelectedItem(list.get(0));
-                GridBagConstraints c2 = new GridBagConstraints();
-                c2.gridx = 2;
-                c2.gridy = rowPos;
-                c2.gridwidth = 1;
-                c2.gridheight = 1;
-                c2.weightx = 0;
-                c2.weighty = 0;
-                c2.anchor = GridBagConstraints.WEST;
-                c2.fill = GridBagConstraints.HORIZONTAL;
-                c2.insets = new Insets(5, 5, 5, 5);
-                c2.ipadx = 0;
-                c2.ipady = 0;
-                options.add(combo, c2);
-                components.put(entry.getKey(), combo);
-            }
-            i++;
-        }
-        loadConnectionProps(lastConnectionProps);
-        JPanel buttonsPanel = new JPanel();
-        buttonsPanel.setLayout(new GridBagLayout());
-        JButton loadPropsFileButton = new JButton("Load from file");
-        loadPropsFileButton.addActionListener(new ActionListener() {
-
-            public void actionPerformed(ActionEvent e) {
-                int result = fileChooser
-                        .showOpenDialog(ZooInspectorConnectionPropertiesDialog.this);
-                if (result == JFileChooser.APPROVE_OPTION) {
-                    File propsFilePath = fileChooser.getSelectedFile();
-                    Properties props = new Properties();
-                    try {
-                        FileReader reader = new FileReader(propsFilePath);
-                        try {
-                            props.load(reader);
-                            loadConnectionProps(props);
-                        } finally {
-                            reader.close();
-                        }
-                    } catch (IOException ex) {
-                        LoggerFactory
-                                .getLogger()
-                                .error(
-                                        "An Error occurred loading connection properties
from file",
-                                        ex);
-                        JOptionPane
-                                .showMessageDialog(
-                                        ZooInspectorConnectionPropertiesDialog.this,
-                                        "An Error occurred loading connection properties
from file",
-                                        "Error", JOptionPane.ERROR_MESSAGE);
-                    }
-                    options.revalidate();
-                    options.repaint();
-                }
-
-            }
-        });
-        GridBagConstraints c3 = new GridBagConstraints();
-        c3.gridx = 0;
-        c3.gridy = 0;
-        c3.gridwidth = 1;
-        c3.gridheight = 1;
-        c3.weightx = 0;
-        c3.weighty = 1;
-        c3.anchor = GridBagConstraints.SOUTHWEST;
-        c3.fill = GridBagConstraints.NONE;
-        c3.insets = new Insets(5, 5, 5, 5);
-        c3.ipadx = 0;
-        c3.ipady = 0;
-        buttonsPanel.add(loadPropsFileButton, c3);
-        JButton saveDefaultPropsFileButton = new JButton("Set As Default");
-        saveDefaultPropsFileButton.addActionListener(new ActionListener() {
-
-            public void actionPerformed(ActionEvent e) {
-
-                Properties connectionProps = getConnectionProps();
-                try {
-                    zooInspectorPanel
-                            .setdefaultConnectionProps(connectionProps);
-                } catch (IOException ex) {
-                    LoggerFactory
-                            .getLogger()
-                            .error(
-                                    "An Error occurred saving the default connection properties
file",
-                                    ex);
-                    JOptionPane
-                            .showMessageDialog(
-                                    ZooInspectorConnectionPropertiesDialog.this,
-                                    "An Error occurred saving the default connection properties
file",
-                                    "Error", JOptionPane.ERROR_MESSAGE);
-                }
-            }
-        });
-        GridBagConstraints c6 = new GridBagConstraints();
-        c6.gridx = 1;
-        c6.gridy = 0;
-        c6.gridwidth = 1;
-        c6.gridheight = 1;
-        c6.weightx = 1;
-        c6.weighty = 1;
-        c6.anchor = GridBagConstraints.SOUTHWEST;
-        c6.fill = GridBagConstraints.NONE;
-        c6.insets = new Insets(5, 5, 5, 5);
-        c6.ipadx = 0;
-        c6.ipady = 0;
-        buttonsPanel.add(saveDefaultPropsFileButton, c6);
-        JButton okButton = new JButton("OK");
-        okButton.addActionListener(new ActionListener() {
-
-            public void actionPerformed(ActionEvent e) {
-                ZooInspectorConnectionPropertiesDialog.this.dispose();
-                Properties connectionProps = getConnectionProps();
-                zooInspectorPanel.connect(connectionProps);
-            }
-        });
-        GridBagConstraints c4 = new GridBagConstraints();
-        c4.gridx = 2;
-        c4.gridy = 0;
-        c4.gridwidth = 1;
-        c4.gridheight = 1;
-        c4.weightx = 0;
-        c4.weighty = 1;
-        c4.anchor = GridBagConstraints.SOUTH;
-        c4.fill = GridBagConstraints.HORIZONTAL;
-        c4.insets = new Insets(5, 5, 5, 5);
-        c4.ipadx = 0;
-        c4.ipady = 0;
-        buttonsPanel.add(okButton, c4);
-        JButton cancelButton = new JButton("Cancel");
-        cancelButton.addActionListener(new ActionListener() {
-
-            public void actionPerformed(ActionEvent e) {
-                ZooInspectorConnectionPropertiesDialog.this.dispose();
-            }
-        });
-        GridBagConstraints c5 = new GridBagConstraints();
-        c5.gridx = 3;
-        c5.gridy = 0;
-        c5.gridwidth = 1;
-        c5.gridheight = 1;
-        c5.weightx = 0;
-        c5.weighty = 1;
-        c5.anchor = GridBagConstraints.SOUTH;
-        c5.fill = GridBagConstraints.HORIZONTAL;
-        c5.insets = new Insets(5, 5, 5, 5);
-        c5.ipadx = 0;
-        c5.ipady = 0;
-        buttonsPanel.add(cancelButton, c5);
-        this.add(options, BorderLayout.CENTER);
-        this.add(buttonsPanel, BorderLayout.SOUTH);
-        this.pack();
-    }
-
-    private void loadConnectionProps(Properties props) {
-        if (props != null) {
-            for (Object key : props.keySet()) {
-                String propsKey = (String) key;
-                if (components.containsKey(propsKey)) {
-                    JComponent component = components.get(propsKey);
-                    String value = props.getProperty(propsKey);
-                    if (component instanceof JTextField) {
-                        ((JTextField) component).setText(value);
-                    } else if (component instanceof JComboBox) {
-                        ((JComboBox) component).setSelectedItem(value);
-                    }
-                }
-            }
-        }
-    }
-
-    private Properties getConnectionProps() {
-        Properties connectionProps = new Properties();
-        for (Entry<String, JComponent> entry : components.entrySet()) {
-            String value = null;
-            JComponent component = entry.getValue();
-            if (component instanceof JTextField) {
-                value = ((JTextField) component).getText();
-            } else if (component instanceof JComboBox) {
-                value = ((JComboBox) component).getSelectedItem().toString();
-            }
-            connectionProps.put(entry.getKey(), value);
-        }
-        return connectionProps;
-    }
-}
+/**
+ * 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.zookeeper.inspector.gui;
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.apache.zookeeper.inspector.logger.LoggerFactory;
+import org.apache.zookeeper.inspector.manager.Pair;
+
+/**
+ * The connection properties dialog. This is used to determine the settings for
+ * connecting to a zookeeper instance
+ */
+public class ZooInspectorConnectionPropertiesDialog extends JDialog {
+
+    private final HashMap<String, JComponent> components;
+
+    /**
+     * @param lastConnectionProps
+     *            - the last connection properties used. if this is the first
+     *            conneciton since starting the applications this will be the
+     *            default settings
+     * @param connectionPropertiesTemplateAndLabels
+     *            - the connection properties and labels to show in this dialog
+     * @param zooInspectorPanel
+     *            - the {@link ZooInspectorPanel} linked to this dialog
+     */
+    public ZooInspectorConnectionPropertiesDialog(
+            Properties lastConnectionProps,
+            Pair<Map<String, List<String>>, Map<String, String>>
connectionPropertiesTemplateAndLabels,
+            final ZooInspectorPanel zooInspectorPanel) {
+        final Map<String, List<String>> connectionPropertiesTemplate = connectionPropertiesTemplateAndLabels
+                .getKey();
+        final Map<String, String> connectionPropertiesLabels = connectionPropertiesTemplateAndLabels
+                .getValue();
+        this.setLayout(new BorderLayout());
+        this.setTitle("Connection Settings");
+        this.setModal(true);
+        this.setAlwaysOnTop(true);
+        this.setResizable(false);
+        final JPanel options = new JPanel();
+        final JFileChooser fileChooser = new JFileChooser();
+        options.setLayout(new GridBagLayout());
+        int i = 0;
+        components = new HashMap<String, JComponent>();
+        for (Entry<String, List<String>> entry : connectionPropertiesTemplate
+                .entrySet()) {
+            int rowPos = 2 * i + 1;
+            JLabel label = new JLabel(connectionPropertiesLabels.get(entry
+                    .getKey()));
+            GridBagConstraints c1 = new GridBagConstraints();
+            c1.gridx = 0;
+            c1.gridy = rowPos;
+            c1.gridwidth = 1;
+            c1.gridheight = 1;
+            c1.weightx = 0;
+            c1.weighty = 0;
+            c1.anchor = GridBagConstraints.WEST;
+            c1.fill = GridBagConstraints.HORIZONTAL;
+            c1.insets = new Insets(5, 5, 5, 5);
+            c1.ipadx = 0;
+            c1.ipady = 0;
+            options.add(label, c1);
+            if (entry.getValue().size() == 0) {
+                JTextField text = new JTextField();
+                GridBagConstraints c2 = new GridBagConstraints();
+                c2.gridx = 2;
+                c2.gridy = rowPos;
+                c2.gridwidth = 1;
+                c2.gridheight = 1;
+                c2.weightx = 0;
+                c2.weighty = 0;
+                c2.anchor = GridBagConstraints.WEST;
+                c2.fill = GridBagConstraints.HORIZONTAL;
+                c2.insets = new Insets(5, 5, 5, 5);
+                c2.ipadx = 0;
+                c2.ipady = 0;
+                options.add(text, c2);
+                components.put(entry.getKey(), text);
+            } else if (entry.getValue().size() == 1) {
+                JTextField text = new JTextField(entry.getValue().get(0));
+                GridBagConstraints c2 = new GridBagConstraints();
+                c2.gridx = 2;
+                c2.gridy = rowPos;
+                c2.gridwidth = 1;
+                c2.gridheight = 1;
+                c2.weightx = 0;
+                c2.weighty = 0;
+                c2.anchor = GridBagConstraints.WEST;
+                c2.fill = GridBagConstraints.HORIZONTAL;
+                c2.insets = new Insets(5, 5, 5, 5);
+                c2.ipadx = 0;
+                c2.ipady = 0;
+                options.add(text, c2);
+                components.put(entry.getKey(), text);
+            } else {
+                List<String> list = entry.getValue();
+                JComboBox combo = new JComboBox(list.toArray(new String[list
+                        .size()]));
+                combo.setSelectedItem(list.get(0));
+                GridBagConstraints c2 = new GridBagConstraints();
+                c2.gridx = 2;
+                c2.gridy = rowPos;
+                c2.gridwidth = 1;
+                c2.gridheight = 1;
+                c2.weightx = 0;
+                c2.weighty = 0;
+                c2.anchor = GridBagConstraints.WEST;
+                c2.fill = GridBagConstraints.HORIZONTAL;
+                c2.insets = new Insets(5, 5, 5, 5);
+                c2.ipadx = 0;
+                c2.ipady = 0;
+                options.add(combo, c2);
+                components.put(entry.getKey(), combo);
+            }
+            i++;
+        }
+        loadConnectionProps(lastConnectionProps);
+        JPanel buttonsPanel = new JPanel();
+        buttonsPanel.setLayout(new GridBagLayout());
+        JButton loadPropsFileButton = new JButton("Load from file");
+        loadPropsFileButton.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                int result = fileChooser
+                        .showOpenDialog(ZooInspectorConnectionPropertiesDialog.this);
+                if (result == JFileChooser.APPROVE_OPTION) {
+                    File propsFilePath = fileChooser.getSelectedFile();
+                    Properties props = new Properties();
+                    try {
+                        FileReader reader = new FileReader(propsFilePath);
+                        try {
+                            props.load(reader);
+                            loadConnectionProps(props);
+                        } finally {
+                            reader.close();
+                        }
+                    } catch (IOException ex) {
+                        LoggerFactory
+                                .getLogger()
+                                .error(
+                                        "An Error occurred loading connection properties
from file",
+                                        ex);
+                        JOptionPane
+                                .showMessageDialog(
+                                        ZooInspectorConnectionPropertiesDialog.this,
+                                        "An Error occurred loading connection properties
from file",
+                                        "Error", JOptionPane.ERROR_MESSAGE);
+                    }
+                    options.revalidate();
+                    options.repaint();
+                }
+
+            }
+        });
+        GridBagConstraints c3 = new GridBagConstraints();
+        c3.gridx = 0;
+        c3.gridy = 0;
+        c3.gridwidth = 1;
+        c3.gridheight = 1;
+        c3.weightx = 0;
+        c3.weighty = 1;
+        c3.anchor = GridBagConstraints.SOUTHWEST;
+        c3.fill = GridBagConstraints.NONE;
+        c3.insets = new Insets(5, 5, 5, 5);
+        c3.ipadx = 0;
+        c3.ipady = 0;
+        buttonsPanel.add(loadPropsFileButton, c3);
+        JButton saveDefaultPropsFileButton = new JButton("Set As Default");
+        saveDefaultPropsFileButton.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+
+                Properties connectionProps = getConnectionProps();
+                try {
+                    zooInspectorPanel
+                            .setdefaultConnectionProps(connectionProps);
+                } catch (IOException ex) {
+                    LoggerFactory
+                            .getLogger()
+                            .error(
+                                    "An Error occurred saving the default connection properties
file",
+                                    ex);
+                    JOptionPane
+                            .showMessageDialog(
+                                    ZooInspectorConnectionPropertiesDialog.this,
+                                    "An Error occurred saving the default connection properties
file",
+                                    "Error", JOptionPane.ERROR_MESSAGE);
+                }
+            }
+        });
+        GridBagConstraints c6 = new GridBagConstraints();
+        c6.gridx = 1;
+        c6.gridy = 0;
+        c6.gridwidth = 1;
+        c6.gridheight = 1;
+        c6.weightx = 1;
+        c6.weighty = 1;
+        c6.anchor = GridBagConstraints.SOUTHWEST;
+        c6.fill = GridBagConstraints.NONE;
+        c6.insets = new Insets(5, 5, 5, 5);
+        c6.ipadx = 0;
+        c6.ipady = 0;
+        buttonsPanel.add(saveDefaultPropsFileButton, c6);
+        JButton okButton = new JButton("OK");
+        okButton.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                ZooInspectorConnectionPropertiesDialog.this.dispose();
+                Properties connectionProps = getConnectionProps();
+                zooInspectorPanel.connect(connectionProps);
+            }
+        });
+        GridBagConstraints c4 = new GridBagConstraints();
+        c4.gridx = 2;
+        c4.gridy = 0;
+        c4.gridwidth = 1;
+        c4.gridheight = 1;
+        c4.weightx = 0;
+        c4.weighty = 1;
+        c4.anchor = GridBagConstraints.SOUTH;
+        c4.fill = GridBagConstraints.HORIZONTAL;
+        c4.insets = new Insets(5, 5, 5, 5);
+        c4.ipadx = 0;
+        c4.ipady = 0;
+        buttonsPanel.add(okButton, c4);
+        JButton cancelButton = new JButton("Cancel");
+        cancelButton.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                ZooInspectorConnectionPropertiesDialog.this.dispose();
+            }
+        });
+        GridBagConstraints c5 = new GridBagConstraints();
+        c5.gridx = 3;
+        c5.gridy = 0;
+        c5.gridwidth = 1;
+        c5.gridheight = 1;
+        c5.weightx = 0;
+        c5.weighty = 1;
+        c5.anchor = GridBagConstraints.SOUTH;
+        c5.fill = GridBagConstraints.HORIZONTAL;
+        c5.insets = new Insets(5, 5, 5, 5);
+        c5.ipadx = 0;
+        c5.ipady = 0;
+        buttonsPanel.add(cancelButton, c5);
+        this.add(options, BorderLayout.CENTER);
+        this.add(buttonsPanel, BorderLayout.SOUTH);
+        this.pack();
+    }
+
+    private void loadConnectionProps(Properties props) {
+        if (props != null) {
+            for (Object key : props.keySet()) {
+                String propsKey = (String) key;
+                if (components.containsKey(propsKey)) {
+                    JComponent component = components.get(propsKey);
+                    String value = props.getProperty(propsKey);
+                    if (component instanceof JTextField) {
+                        ((JTextField) component).setText(value);
+                    } else if (component instanceof JComboBox) {
+                        ((JComboBox) component).setSelectedItem(value);
+                    }
+                }
+            }
+        }
+    }
+
+    private Properties getConnectionProps() {
+        Properties connectionProps = new Properties();
+        for (Entry<String, JComponent> entry : components.entrySet()) {
+            String value = null;
+            JComponent component = entry.getValue();
+            if (component instanceof JTextField) {
+                value = ((JTextField) component).getText();
+            } else if (component instanceof JComboBox) {
+                value = ((JComboBox) component).getSelectedItem().toString();
+            }
+            connectionProps.put(entry.getKey(), value);
+        }
+        return connectionProps;
+    }
+}

Propchange: zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorConnectionPropertiesDialog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorIconResources.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorIconResources.java?rev=1584500&r1=1584499&r2=1584500&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorIconResources.java
(original)
+++ zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorIconResources.java
Fri Apr  4 01:30:24 2014
@@ -1,118 +1,118 @@
-/**
- * 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.zookeeper.inspector.gui;
-
-import javax.swing.ImageIcon;
-
-/**
- * A class containing static methods for retrieving {@link ImageIcon}s used in
- * the application
- */
-public class ZooInspectorIconResources {
-
-    /**
-     * @return file icon
-     */
-    public static ImageIcon getTreeLeafIcon() {
-        return new ImageIcon("icons/file_obj.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return folder open icon
-     */
-    public static ImageIcon getTreeOpenIcon() {
-        return new ImageIcon("icons/fldr_obj.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return folder closed icon
-     */
-    public static ImageIcon getTreeClosedIcon() {
-        return new ImageIcon("icons/fldr_obj.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return connect icon
-     */
-    public static ImageIcon getConnectIcon() {
-        return new ImageIcon("icons/launch_run.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return disconnect icon
-     */
-    public static ImageIcon getDisconnectIcon() {
-        return new ImageIcon("icons/launch_stop.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return save icon
-     */
-    public static ImageIcon getSaveIcon() {
-        return new ImageIcon("icons/save_edit.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return add icon
-     */
-    public static ImageIcon getAddNodeIcon() {
-        return new ImageIcon("icons/new_con.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return delete icon
-     */
-    public static ImageIcon getDeleteNodeIcon() {
-        return new ImageIcon("icons/trash.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return refresh icon
-     */
-    public static ImageIcon getRefreshIcon() {
-        return new ImageIcon("icons/refresh.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return information icon
-     */
-    public static ImageIcon getInformationIcon() {
-        return new ImageIcon("icons/info_obj.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return node viewers icon
-     */
-    public static ImageIcon getChangeNodeViewersIcon() {
-        return new ImageIcon("icons/edtsrclkup_co.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return up icon
-     */
-    public static ImageIcon getUpIcon() {
-        return new ImageIcon("icons/search_prev.gif"); //$NON-NLS-1$
-    }
-
-    /**
-     * @return down icon
-     */
-    public static ImageIcon getDownIcon() {
-        return new ImageIcon("icons/search_next.gif"); //$NON-NLS-1$
-    }
-}
+/**
+ * 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.zookeeper.inspector.gui;
+
+import javax.swing.ImageIcon;
+
+/**
+ * A class containing static methods for retrieving {@link ImageIcon}s used in
+ * the application
+ */
+public class ZooInspectorIconResources {
+
+    /**
+     * @return file icon
+     */
+    public static ImageIcon getTreeLeafIcon() {
+        return new ImageIcon("icons/file_obj.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return folder open icon
+     */
+    public static ImageIcon getTreeOpenIcon() {
+        return new ImageIcon("icons/fldr_obj.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return folder closed icon
+     */
+    public static ImageIcon getTreeClosedIcon() {
+        return new ImageIcon("icons/fldr_obj.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return connect icon
+     */
+    public static ImageIcon getConnectIcon() {
+        return new ImageIcon("icons/launch_run.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return disconnect icon
+     */
+    public static ImageIcon getDisconnectIcon() {
+        return new ImageIcon("icons/launch_stop.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return save icon
+     */
+    public static ImageIcon getSaveIcon() {
+        return new ImageIcon("icons/save_edit.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return add icon
+     */
+    public static ImageIcon getAddNodeIcon() {
+        return new ImageIcon("icons/new_con.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return delete icon
+     */
+    public static ImageIcon getDeleteNodeIcon() {
+        return new ImageIcon("icons/trash.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return refresh icon
+     */
+    public static ImageIcon getRefreshIcon() {
+        return new ImageIcon("icons/refresh.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return information icon
+     */
+    public static ImageIcon getInformationIcon() {
+        return new ImageIcon("icons/info_obj.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return node viewers icon
+     */
+    public static ImageIcon getChangeNodeViewersIcon() {
+        return new ImageIcon("icons/edtsrclkup_co.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return up icon
+     */
+    public static ImageIcon getUpIcon() {
+        return new ImageIcon("icons/search_prev.gif"); //$NON-NLS-1$
+    }
+
+    /**
+     * @return down icon
+     */
+    public static ImageIcon getDownIcon() {
+        return new ImageIcon("icons/search_next.gif"); //$NON-NLS-1$
+    }
+}

Propchange: zookeeper/branches/branch-3.4/src/contrib/zooinspector/src/java/org/apache/zookeeper/inspector/gui/ZooInspectorIconResources.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message