Line 0
Link Here
|
|
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 2014 Oracle and/or its affiliates. All rights reserved. |
5 |
* |
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
7 |
* Other names may be trademarks of their respective owners. |
8 |
* |
9 |
* The contents of this file are subject to the terms of either the GNU |
10 |
* General Public License Version 2 only ("GPL") or the Common |
11 |
* Development and Distribution License("CDDL") (collectively, the |
12 |
* "License"). You may not use this file except in compliance with the |
13 |
* License. You can obtain a copy of the License at |
14 |
* http://www.netbeans.org/cddl-gplv2.html |
15 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
16 |
* specific language governing permissions and limitations under the |
17 |
* License. When distributing the software, include this License Header |
18 |
* Notice in each file and include the License file at |
19 |
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this |
20 |
* particular file as subject to the "Classpath" exception as provided |
21 |
* by Oracle in the GPL Version 2 section of the License file that |
22 |
* accompanied this code. If applicable, add the following below the |
23 |
* License Header, with the fields enclosed by brackets [] replaced by |
24 |
* your own identifying information: |
25 |
* "Portions Copyrighted [year] [name of copyright owner]" |
26 |
* |
27 |
* If you wish your version of this file to be governed by only the CDDL |
28 |
* or only the GPL Version 2, indicate your decision by adding |
29 |
* "[Contributor] elects to include this software in this distribution |
30 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
31 |
* single choice of license, a recipient has the option to distribute |
32 |
* your version of this file under either the CDDL, the GPL Version 2 or |
33 |
* to extend the choice of license to its licensees as provided above. |
34 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
35 |
* Version 2 license, then the option applies only if the new code is |
36 |
* made subject to such option by the copyright holder. |
37 |
* |
38 |
* Contributor(s): |
39 |
* |
40 |
* Portions Copyrighted 2014 Sun Microsystems, Inc. |
41 |
*/ |
42 |
package org.netbeans.modules.db.dataview.options; |
43 |
|
44 |
import org.netbeans.modules.db.dataview.api.DataViewPageContext; |
45 |
|
46 |
final class DataViewSettingsPanel extends javax.swing.JPanel { |
47 |
|
48 |
private final DataViewSettingsOptionsPanelController controller; |
49 |
|
50 |
DataViewSettingsPanel(DataViewSettingsOptionsPanelController controller) { |
51 |
this.controller = controller; |
52 |
initComponents(); |
53 |
pageSizeButtonGroup.add(rbRememberPageSize); |
54 |
pageSizeButtonGroup.add(rbShowAllRows); |
55 |
pageSizeButtonGroup.add(rbFixedPageSize); |
56 |
} |
57 |
|
58 |
/** |
59 |
* This method is called from within the constructor to initialize the form. WARNING: Do NOT |
60 |
* modify this code. The content of this method is always regenerated by the Form Editor. |
61 |
*/ |
62 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
63 |
private void initComponents() { |
64 |
bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); |
65 |
|
66 |
pageSizeButtonGroup = new javax.swing.ButtonGroup(); |
67 |
chkShowTruncateTableButton = new javax.swing.JCheckBox(); |
68 |
chkShowAbsoluteRowNumbers = new javax.swing.JCheckBox(); |
69 |
chkPackColumns = new javax.swing.JCheckBox(); |
70 |
chkCopyRowValuesWithHeaders = new javax.swing.JCheckBox(); |
71 |
rbRememberPageSize = new javax.swing.JRadioButton(); |
72 |
rbFixedPageSize = new javax.swing.JRadioButton(); |
73 |
spnFixedPageSize = new javax.swing.JSpinner(); |
74 |
lblPageSize = new javax.swing.JLabel(); |
75 |
rbShowAllRows = new javax.swing.JRadioButton(); |
76 |
|
77 |
chkShowTruncateTableButton.setSelected(true); |
78 |
org.openide.awt.Mnemonics.setLocalizedText(chkShowTruncateTableButton, org.openide.util.NbBundle.getMessage(DataViewSettingsPanel.class, "DataViewSettingsPanel.chkShowTruncateTableButton.text")); // NOI18N |
79 |
|
80 |
org.openide.awt.Mnemonics.setLocalizedText(chkShowAbsoluteRowNumbers, org.openide.util.NbBundle.getMessage(DataViewSettingsPanel.class, "DataViewSettingsPanel.chkShowAbsoluteRowNumbers.text")); // NOI18N |
81 |
|
82 |
org.openide.awt.Mnemonics.setLocalizedText(chkPackColumns, org.openide.util.NbBundle.getMessage(DataViewSettingsPanel.class, "DataViewSettingsPanel.chkPackColumns.text")); // NOI18N |
83 |
|
84 |
org.openide.awt.Mnemonics.setLocalizedText(chkCopyRowValuesWithHeaders, org.openide.util.NbBundle.getMessage(DataViewSettingsPanel.class, "DataViewSettingsPanel.chkCopyRowValuesWithHeaders.text")); // NOI18N |
85 |
|
86 |
rbRememberPageSize.setSelected(true); |
87 |
org.openide.awt.Mnemonics.setLocalizedText(rbRememberPageSize, org.openide.util.NbBundle.getMessage(DataViewSettingsPanel.class, "DataViewSettingsPanel.rbRememberPageSize.text")); // NOI18N |
88 |
|
89 |
org.openide.awt.Mnemonics.setLocalizedText(rbFixedPageSize, org.openide.util.NbBundle.getMessage(DataViewSettingsPanel.class, "DataViewSettingsPanel.rbFixedPageSize.text")); // NOI18N |
90 |
|
91 |
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, rbFixedPageSize, org.jdesktop.beansbinding.ELProperty.create("${selected}"), spnFixedPageSize, org.jdesktop.beansbinding.BeanProperty.create("enabled")); |
92 |
bindingGroup.addBinding(binding); |
93 |
|
94 |
org.openide.awt.Mnemonics.setLocalizedText(lblPageSize, org.openide.util.NbBundle.getMessage(DataViewSettingsPanel.class, "DataViewSettingsPanel.lblPageSize.text")); // NOI18N |
95 |
|
96 |
org.openide.awt.Mnemonics.setLocalizedText(rbShowAllRows, org.openide.util.NbBundle.getMessage(DataViewSettingsPanel.class, "DataViewSettingsPanel.rbShowAllRows.text")); // NOI18N |
97 |
|
98 |
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
99 |
this.setLayout(layout); |
100 |
layout.setHorizontalGroup( |
101 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
102 |
.addGroup(layout.createSequentialGroup() |
103 |
.addContainerGap() |
104 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
105 |
.addComponent(chkShowAbsoluteRowNumbers) |
106 |
.addComponent(chkShowTruncateTableButton) |
107 |
.addComponent(chkCopyRowValuesWithHeaders) |
108 |
.addComponent(chkPackColumns) |
109 |
.addComponent(lblPageSize) |
110 |
.addComponent(rbRememberPageSize) |
111 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) |
112 |
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() |
113 |
.addComponent(rbFixedPageSize) |
114 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
115 |
.addComponent(spnFixedPageSize, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) |
116 |
.addComponent(rbShowAllRows, javax.swing.GroupLayout.Alignment.LEADING))) |
117 |
.addContainerGap(251, Short.MAX_VALUE)) |
118 |
); |
119 |
layout.setVerticalGroup( |
120 |
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
121 |
.addGroup(layout.createSequentialGroup() |
122 |
.addContainerGap() |
123 |
.addComponent(lblPageSize) |
124 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
125 |
.addComponent(rbRememberPageSize) |
126 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
127 |
.addComponent(rbShowAllRows) |
128 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
129 |
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
130 |
.addComponent(rbFixedPageSize) |
131 |
.addComponent(spnFixedPageSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) |
132 |
.addGap(18, 18, 18) |
133 |
.addComponent(chkPackColumns) |
134 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
135 |
.addComponent(chkShowTruncateTableButton) |
136 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
137 |
.addComponent(chkShowAbsoluteRowNumbers) |
138 |
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
139 |
.addComponent(chkCopyRowValuesWithHeaders) |
140 |
.addContainerGap(129, Short.MAX_VALUE)) |
141 |
); |
142 |
|
143 |
bindingGroup.bind(); |
144 |
}// </editor-fold>//GEN-END:initComponents |
145 |
|
146 |
void load() { |
147 |
int defaultPageSize = DataViewSettings.getDefaultPageSize(); |
148 |
if (defaultPageSize == DataViewSettings.PAGE_SIZE_REMEMBER) { |
149 |
rbRememberPageSize.setSelected(true); |
150 |
spnFixedPageSize.setValue(DataViewPageContext.DEFAULT_PAGE_SIZE); |
151 |
} else if (defaultPageSize == DataViewSettings.PAGE_SIZE_SHOW_ALL) { |
152 |
rbShowAllRows.setSelected(true); |
153 |
spnFixedPageSize.setValue(DataViewPageContext.DEFAULT_PAGE_SIZE); |
154 |
} else { |
155 |
rbFixedPageSize.setSelected(true); |
156 |
spnFixedPageSize.setValue(defaultPageSize); |
157 |
} |
158 |
chkPackColumns.setSelected(DataViewSettings.getPackColumns()); |
159 |
chkShowTruncateTableButton.setSelected(DataViewSettings.getShowTruncateTableButton()); |
160 |
chkShowAbsoluteRowNumbers.setSelected(DataViewSettings.getShowAbsoluteRowNumbers()); |
161 |
chkCopyRowValuesWithHeaders.setSelected(DataViewSettings.getCopyRowValuesWithHeaders()); |
162 |
} |
163 |
|
164 |
void store() { |
165 |
if (rbRememberPageSize.isSelected()) { |
166 |
DataViewSettings.setDefautPageSize(DataViewSettings.PAGE_SIZE_REMEMBER); |
167 |
} else if (rbShowAllRows.isSelected()) { |
168 |
DataViewSettings.setDefautPageSize(DataViewSettings.PAGE_SIZE_SHOW_ALL); |
169 |
} else { |
170 |
DataViewSettings.setDefautPageSize((int) spnFixedPageSize.getValue()); |
171 |
} |
172 |
DataViewSettings.setPackColumns(chkPackColumns.isSelected()); |
173 |
DataViewSettings.setShowTruncateTableButton(chkShowTruncateTableButton.isSelected()); |
174 |
DataViewSettings.setShowAbsoluteRowNumbers(chkShowAbsoluteRowNumbers.isSelected()); |
175 |
DataViewSettings.setCopyRowValuesWithHeaders(chkCopyRowValuesWithHeaders.isSelected()); |
176 |
} |
177 |
|
178 |
boolean valid() { |
179 |
return true; |
180 |
} |
181 |
|
182 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
183 |
private javax.swing.JCheckBox chkCopyRowValuesWithHeaders; |
184 |
private javax.swing.JCheckBox chkPackColumns; |
185 |
private javax.swing.JCheckBox chkShowAbsoluteRowNumbers; |
186 |
private javax.swing.JCheckBox chkShowTruncateTableButton; |
187 |
private javax.swing.JLabel lblPageSize; |
188 |
private javax.swing.ButtonGroup pageSizeButtonGroup; |
189 |
private javax.swing.JRadioButton rbFixedPageSize; |
190 |
private javax.swing.JRadioButton rbRememberPageSize; |
191 |
private javax.swing.JRadioButton rbShowAllRows; |
192 |
private javax.swing.JSpinner spnFixedPageSize; |
193 |
private org.jdesktop.beansbinding.BindingGroup bindingGroup; |
194 |
// End of variables declaration//GEN-END:variables |
195 |
} |