KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > subversion > ui > commit > CommitPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.subversion.ui.commit;
21
22 import org.netbeans.modules.subversion.SvnModuleConfig;
23 import org.netbeans.modules.versioning.util.ListenersSupport;
24 import org.netbeans.modules.versioning.util.VersioningListener;
25 import org.netbeans.modules.versioning.util.Utils;
26 import org.netbeans.modules.versioning.util.StringSelector;
27 import org.openide.util.NbBundle;
28
29 import javax.swing.event.TableModelListener JavaDoc;
30 import javax.swing.event.TableModelEvent JavaDoc;
31 import java.util.prefs.PreferenceChangeEvent JavaDoc;
32 import java.util.prefs.PreferenceChangeListener JavaDoc;
33 import java.util.*;
34 import java.awt.event.MouseAdapter JavaDoc;
35 import java.awt.event.MouseEvent JavaDoc;
36 import java.awt.Cursor JavaDoc;
37
38 /**
39  *
40  * @author pk97937
41  */

42 public class CommitPanel extends javax.swing.JPanel JavaDoc implements PreferenceChangeListener JavaDoc, TableModelListener JavaDoc {
43
44     static final Object JavaDoc EVENT_SETTINGS_CHANGED = new Object JavaDoc();
45
46     private CommitTable commitTable;
47     
48     /** Creates new form CommitPanel */
49     public CommitPanel() {
50         initComponents();
51     }
52
53     void setCommitTable(CommitTable commitTable) {
54         this.commitTable = commitTable;
55     }
56     
57     void setErrorLabel(String JavaDoc htmlErrorLabel) {
58         jLabel2.setText(htmlErrorLabel);
59     }
60
61     public void addNotify() {
62         super.addNotify();
63         SvnModuleConfig.getDefault().getPreferences().addPreferenceChangeListener(this);
64         commitTable.getTableModel().addTableModelListener(this);
65         listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
66
67         recentLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
68         recentLink.addMouseListener(new MouseAdapter JavaDoc() {
69             public void mouseClicked(MouseEvent JavaDoc e) {
70                 onBrowseRecentMessages();
71             }
72         });
73         
74         List<String JavaDoc> messages = Utils.getStringList(SvnModuleConfig.getDefault().getPreferences(), CommitAction.RECENT_COMMIT_MESSAGES);
75         if (messages.size() > 0) {
76             messageTextArea.setText(messages.get(0));
77         }
78         messageTextArea.selectAll();
79     }
80
81     public void removeNotify() {
82         commitTable.getTableModel().removeTableModelListener(this);
83         SvnModuleConfig.getDefault().getPreferences().removePreferenceChangeListener(this);
84         super.removeNotify();
85     }
86     
87     private void onBrowseRecentMessages() {
88         String JavaDoc message = StringSelector.select(NbBundle.getMessage(CommitPanel.class, "CTL_CommitForm_RecentTitle"),
89                                                NbBundle.getMessage(CommitPanel.class, "CTL_CommitForm_RecentPrompt"),
90             Utils.getStringList(SvnModuleConfig.getDefault().getPreferences(), CommitAction.RECENT_COMMIT_MESSAGES));
91         if (message != null) {
92             messageTextArea.replaceSelection(message);
93         }
94     }
95     
96     public void preferenceChange(PreferenceChangeEvent JavaDoc evt) {
97         if (evt.getKey().startsWith(SvnModuleConfig.PROP_COMMIT_EXCLUSIONS)) {
98             commitTable.dataChanged();
99             listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
100         }
101     }
102
103     public void tableChanged(TableModelEvent JavaDoc e) {
104         listenerSupport.fireVersioningEvent(EVENT_SETTINGS_CHANGED);
105     }
106     
107     /** This method is called from within the constructor to
108      * initialize the form.
109      * WARNING: Do NOT modify this code. The content of this method is
110      * always regenerated by the Form Editor.
111      */

112     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
113
private void initComponents() {
114
115         setMinimumSize(new java.awt.Dimension JavaDoc(400, 300));
116         setPreferredSize(new java.awt.Dimension JavaDoc(650, 400));
117
118         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(CommitPanel.class, "CTL_CommitForm_Message")); // NOI18N
119

120         messageTextArea.setColumns(30);
121         messageTextArea.setLineWrap(true);
122         messageTextArea.setRows(6);
123         messageTextArea.setTabSize(4);
124         messageTextArea.setWrapStyleWord(true);
125         messageTextArea.setMinimumSize(new java.awt.Dimension JavaDoc(100, 18));
126         jScrollPane1.setViewportView(messageTextArea);
127
128         org.openide.awt.Mnemonics.setLocalizedText(filesLabel, org.openide.util.NbBundle.getMessage(CommitPanel.class, "CTL_CommitForm_FilesToCommit")); // NOI18N
129

130         filesPanel.setPreferredSize(new java.awt.Dimension JavaDoc(240, 108));
131
132         org.jdesktop.layout.GroupLayout filesPanelLayout = new org.jdesktop.layout.GroupLayout(filesPanel);
133         filesPanel.setLayout(filesPanelLayout);
134         filesPanelLayout.setHorizontalGroup(
135             filesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
136             .add(0, 630, Short.MAX_VALUE)
137         );
138         filesPanelLayout.setVerticalGroup(
139             filesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
140             .add(0, 187, Short.MAX_VALUE)
141         );
142
143         recentLink.setIcon(new javax.swing.ImageIcon JavaDoc(getClass().getResource("/org/netbeans/modules/subversion/resources/icons/recent_messages.png")));
144         recentLink.setToolTipText(org.openide.util.NbBundle.getMessage(CommitPanel.class, "CTL_CommitForm_RecentMessages")); // NOI18N
145

146         org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
147         this.setLayout(layout);
148         layout.setHorizontalGroup(
149             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
150             .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
151                 .addContainerGap()
152                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
153                     .add(org.jdesktop.layout.GroupLayout.LEADING, filesPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 630, Short.MAX_VALUE)
154                     .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 630, Short.MAX_VALUE)
155                     .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
156                         .add(jLabel1)
157                         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 530, Short.MAX_VALUE)
158                         .add(recentLink))
159                     .add(org.jdesktop.layout.GroupLayout.LEADING, filesLabel)
160                     .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel2))
161                 .addContainerGap())
162         );
163         layout.setVerticalGroup(
164             layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
165             .add(layout.createSequentialGroup()
166                 .addContainerGap()
167                 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
168                     .add(jLabel1)
169                     .add(recentLink))
170                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
171                 .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
172                 .add(15, 15, 15)
173                 .add(filesLabel)
174                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
175                 .add(filesPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
176                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
177                 .add(jLabel2)
178                 .addContainerGap())
179         );
180     }// </editor-fold>//GEN-END:initComponents
181

182     ListenersSupport listenerSupport = new ListenersSupport(this);
183     public void addVersioningListener(VersioningListener listener) {
184         listenerSupport.addListener(listener);
185     }
186
187     public void removeVersioningListener(VersioningListener listener) {
188         listenerSupport.removeListener(listener);
189     }
190     
191     // Variables declaration - do not modify//GEN-BEGIN:variables
192
final javax.swing.JLabel JavaDoc filesLabel = new javax.swing.JLabel JavaDoc();
193     final javax.swing.JPanel JavaDoc filesPanel = new javax.swing.JPanel JavaDoc();
194     final javax.swing.JLabel JavaDoc jLabel1 = new javax.swing.JLabel JavaDoc();
195     final javax.swing.JLabel JavaDoc jLabel2 = new javax.swing.JLabel JavaDoc();
196     final javax.swing.JScrollPane JavaDoc jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
197     final javax.swing.JTextArea JavaDoc messageTextArea = new javax.swing.JTextArea JavaDoc();
198     final javax.swing.JLabel JavaDoc recentLink = new javax.swing.JLabel JavaDoc();
199     // End of variables declaration//GEN-END:variables
200

201 }
202
Popular Tags