001    // GraphLab Project: http://graphlab.sharif.edu
002    // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology
003    // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/
004    package graphlab.ui.components;
005    
006    import graphlab.platform.extension.Extension;
007    import graphlab.platform.extension.ExtensionExternalData;
008    
009    import javax.swing.*;
010    import java.awt.event.ActionEvent;
011    import java.awt.event.ActionListener;
012    
013    /**
014     * this is a frame fo showing the confiurations before running an Extension
015     *
016     * @author azin azadi
017     * @see graphlab.ui.AbstractExtensionAction
018     * @see Extension
019     */
020    public class ExtensionConfigFrame extends javax.swing.JFrame {
021    
022        Extension e;
023    
024        /**
025         * Creates new form ExtensionConfigFrame
026         */
027        public ExtensionConfigFrame(Extension e, final ExtensionExternalData data) {
028            this.e = e;
029            initComponents();
030            this.setDefaultCloseOperation(HIDE_ON_CLOSE);
031            if (data == null) {
032                sourceCodeBtn.setEnabled(false);
033                helpBtn.setEnabled(false);
034            } else {
035                if (data.helpURL() != null) {
036                    helpBtn.addActionListener(new ActionListener() {
037                        public void actionPerformed(ActionEvent e) {
038    //                        try {
039    //                            Browser.browse(new URL(data.helpURL()));
040    //                        } catch (MalformedURLException e1) {
041    //                            e1.printStackTrace();
042    //                        }
043    
044                        }
045                    });
046                }
047                if (data.sourceCodeURL() != null) {
048                    helpBtn.addActionListener(new ActionListener() {
049                        public void actionPerformed(ActionEvent e) {
050    //                        try {
051    //                            Browser.browse(new URL(data.sourceCodeURL()));
052    //                        } catch (MalformedURLException e1) {
053    //                            e1.printStackTrace();
054    //                        }
055    
056                        }
057                    });
058                }
059    
060            }
061            extensionParametersPanel.add(new JButton("Aaa"));
062            validate();
063        }
064    
065        /**
066         * This method is called from within the constructor to
067         * initialize the form.
068         * WARNING: Do NOT modify this code. The content of this method is
069         * always regenerated by the Form Editor.
070         */
071        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
072        private void initComponents() {
073            java.awt.GridBagConstraints gridBagConstraints;
074    
075            jPanel1 = new javax.swing.JPanel();
076            jLabel1 = new javax.swing.JLabel();
077            extensionParametersPanel = new javax.swing.JPanel();
078            jPanel2 = new javax.swing.JPanel();
079            helpBtn = new javax.swing.JButton();
080            sourceCodeBtn = new javax.swing.JButton();
081            descriptionLabel = new javax.swing.JLabel();
082    
083            getContentPane().setLayout(new java.awt.GridBagLayout());
084    
085            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
086            setTitle(e.getName());
087            jPanel1.setLayout(new java.awt.GridBagLayout());
088    
089            jLabel1.setText("Extension Parameters:");
090            gridBagConstraints = new java.awt.GridBagConstraints();
091            gridBagConstraints.gridx = 0;
092            gridBagConstraints.gridheight = 2;
093            gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
094            jPanel1.add(jLabel1, gridBagConstraints);
095    
096    //        extensionParametersPanel.setLayout();
097    
098            gridBagConstraints = new java.awt.GridBagConstraints();
099            gridBagConstraints.gridy = 1;
100            gridBagConstraints.gridheight = 2;
101            gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
102            gridBagConstraints.weightx = 1.0;
103            gridBagConstraints.weighty = 1.0;
104            jPanel1.add(extensionParametersPanel, gridBagConstraints);
105    
106            gridBagConstraints = new java.awt.GridBagConstraints();
107            gridBagConstraints.gridy = 2;
108            gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
109            gridBagConstraints.weighty = 1.0;
110            getContentPane().add(jPanel1, gridBagConstraints);
111    
112            jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
113    
114            helpBtn.setText("Help");
115            jPanel2.add(helpBtn);
116    
117            sourceCodeBtn.setText("Source Code");
118            jPanel2.add(sourceCodeBtn);
119    
120            gridBagConstraints = new java.awt.GridBagConstraints();
121            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
122            gridBagConstraints.weightx = 1.0;
123            getContentPane().add(jPanel2, gridBagConstraints);
124    
125            descriptionLabel.setText(e.getDescription());
126            gridBagConstraints = new java.awt.GridBagConstraints();
127            gridBagConstraints.gridy = 3;
128            gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
129            getContentPane().add(descriptionLabel, gridBagConstraints);
130    
131            pack();
132        }// </editor-fold>
133    
134    
135        // Variables declaration - do not modify
136        private javax.swing.JLabel descriptionLabel;
137        private javax.swing.JPanel extensionParametersPanel;
138        private javax.swing.JButton helpBtn;
139        private javax.swing.JLabel jLabel1;
140        private javax.swing.JPanel jPanel1;
141        private javax.swing.JPanel jPanel2;
142        private javax.swing.JButton sourceCodeBtn;
143        // End of variables declaration
144    
145    }