Lines 65-74
Link Here
|
65 |
import javax.swing.JPanel; |
65 |
import javax.swing.JPanel; |
66 |
import javax.swing.JTable; |
66 |
import javax.swing.JTable; |
67 |
import javax.swing.JTextField; |
67 |
import javax.swing.JTextField; |
|
|
68 |
import javax.swing.event.ListSelectionEvent; |
68 |
import javax.swing.table.AbstractTableModel; |
69 |
import javax.swing.table.AbstractTableModel; |
69 |
import javax.swing.table.DefaultTableCellRenderer; |
70 |
import javax.swing.table.DefaultTableCellRenderer; |
70 |
import javax.swing.table.TableCellEditor; |
71 |
import javax.swing.table.TableCellEditor; |
71 |
import javax.swing.AbstractCellEditor; |
72 |
import javax.swing.AbstractCellEditor; |
|
|
73 |
import javax.swing.event.ListSelectionListener; |
74 |
import javax.swing.text.Document; |
75 |
import javax.swing.text.Position; |
72 |
import org.netbeans.api.java.classpath.ClassPath; |
76 |
import org.netbeans.api.java.classpath.ClassPath; |
73 |
|
77 |
|
74 |
import org.netbeans.modules.i18n.HardCodedString; |
78 |
import org.netbeans.modules.i18n.HardCodedString; |
Lines 98-104
Link Here
|
98 |
* @author Marian Petras |
102 |
* @author Marian Petras |
99 |
* @see Panel |
103 |
* @see Panel |
100 |
*/ |
104 |
*/ |
101 |
final class HardStringWizardPanel extends JPanel { |
105 |
final class HardStringWizardPanel extends JPanel implements ListSelectionListener { |
102 |
|
106 |
|
103 |
/** Column index of check box column. */ |
107 |
/** Column index of check box column. */ |
104 |
private static final int COLUMN_INDEX_CHECK = 0; |
108 |
private static final int COLUMN_INDEX_CHECK = 0; |
Lines 129-146
Link Here
|
129 |
initAccessibility(); |
133 |
initAccessibility(); |
130 |
} |
134 |
} |
131 |
|
135 |
|
|
|
136 |
@Override |
137 |
public void doLayout() { |
138 |
super.doLayout(); |
139 |
jSplitPane1.setDividerLocation(0.5D); |
140 |
} |
141 |
|
132 |
|
142 |
|
133 |
/** Sets combo model only for source which were some found strings in. */ |
143 |
/** Sets combo model only for source which were some found strings in. */ |
134 |
private void setComboModel(Map<DataObject,SourceData> sourceMap) { |
144 |
private void setComboModel(Map<DataObject,SourceData> sourceMap) { |
135 |
List<DataObject> nonEmptySources = new ArrayList<DataObject>(); |
145 |
List<DataObject> nonEmptySources = new ArrayList<DataObject>(); |
136 |
|
146 |
String mimeType = null; |
137 |
for (Map.Entry<DataObject,SourceData> entry : sourceMap.entrySet()) { |
147 |
for (Map.Entry<DataObject,SourceData> entry : sourceMap.entrySet()) { |
138 |
if (!entry.getValue().getStringMap().isEmpty()) { |
148 |
if (!entry.getValue().getStringMap().isEmpty()) { |
139 |
nonEmptySources.add(entry.getKey()); |
149 |
nonEmptySources.add(entry.getKey()); |
|
|
150 |
mimeType = entry.getKey().getPrimaryFile().getMIMEType(); |
140 |
} |
151 |
} |
141 |
} |
152 |
} |
142 |
|
153 |
|
143 |
sourceCombo.setModel(new DefaultComboBoxModel(nonEmptySources.toArray())); |
154 |
sourceCombo.setModel(new DefaultComboBoxModel(nonEmptySources.toArray())); |
|
|
155 |
if (mimeType != null) { |
156 |
preview.setContentType(mimeType); |
157 |
} |
158 |
sourceComboActionPerformed(null); |
144 |
} |
159 |
} |
145 |
|
160 |
|
146 |
/** Adds additional init of components. */ |
161 |
/** Adds additional init of components. */ |
Lines 279-284
Link Here
|
279 |
// PENDING: Setting the size of columns with check box and customize button editor. |
294 |
// PENDING: Setting the size of columns with check box and customize button editor. |
280 |
hardStringTable.getColumnModel().getColumn(COLUMN_INDEX_CHECK).setMaxWidth(30); |
295 |
hardStringTable.getColumnModel().getColumn(COLUMN_INDEX_CHECK).setMaxWidth(30); |
281 |
hardStringTable.getColumnModel().getColumn(COLUMN_INDEX_CUSTOM).setMaxWidth(30); |
296 |
hardStringTable.getColumnModel().getColumn(COLUMN_INDEX_CUSTOM).setMaxWidth(30); |
|
|
297 |
hardStringTable.getSelectionModel().addListSelectionListener(this); |
282 |
} |
298 |
} |
283 |
|
299 |
|
284 |
private void initAccessibility() { |
300 |
private void initAccessibility() { |
Lines 295-309
Link Here
|
295 |
* WARNING: Do NOT modify this code. The content of this method is |
311 |
* WARNING: Do NOT modify this code. The content of this method is |
296 |
* always regenerated by the Form Editor. |
312 |
* always regenerated by the Form Editor. |
297 |
*/ |
313 |
*/ |
298 |
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents |
314 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
299 |
private void initComponents() { |
315 |
private void initComponents() { |
300 |
java.awt.GridBagConstraints gridBagConstraints; |
316 |
java.awt.GridBagConstraints gridBagConstraints; |
301 |
|
317 |
|
302 |
sourceLabel = new javax.swing.JLabel(); |
318 |
sourceLabel = new javax.swing.JLabel(); |
303 |
sourceCombo = new javax.swing.JComboBox(); |
319 |
sourceCombo = new javax.swing.JComboBox(); |
304 |
hardStringLabel = new javax.swing.JLabel(); |
320 |
hardStringLabel = new javax.swing.JLabel(); |
|
|
321 |
jSplitPane1 = new javax.swing.JSplitPane(); |
305 |
scrollPane = new javax.swing.JScrollPane(); |
322 |
scrollPane = new javax.swing.JScrollPane(); |
306 |
hardStringTable = new javax.swing.JTable(); |
323 |
hardStringTable = new javax.swing.JTable(); |
|
|
324 |
jScrollPane1 = new javax.swing.JScrollPane(); |
325 |
preview = new javax.swing.JEditorPane(); |
307 |
|
326 |
|
308 |
setLayout(new java.awt.GridBagLayout()); |
327 |
setLayout(new java.awt.GridBagLayout()); |
309 |
|
328 |
|
Lines 330-343
Link Here
|
330 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
349 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
331 |
gridBagConstraints.gridx = 0; |
350 |
gridBagConstraints.gridx = 0; |
332 |
gridBagConstraints.gridy = 2; |
351 |
gridBagConstraints.gridy = 2; |
|
|
352 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
333 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
353 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
334 |
gridBagConstraints.insets = new java.awt.Insets(11, 0, 0, 0); |
354 |
gridBagConstraints.insets = new java.awt.Insets(11, 0, 0, 0); |
335 |
add(hardStringLabel, gridBagConstraints); |
355 |
add(hardStringLabel, gridBagConstraints); |
|
|
356 |
|
357 |
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); |
358 |
jSplitPane1.setResizeWeight(0.5); |
336 |
|
359 |
|
337 |
scrollPane.setPreferredSize(new java.awt.Dimension(100, 100)); |
360 |
scrollPane.setPreferredSize(new java.awt.Dimension(100, 100)); |
338 |
|
361 |
|
339 |
hardStringTable.setModel(tableModel); |
362 |
hardStringTable.setModel(tableModel); |
340 |
scrollPane.setViewportView(hardStringTable); |
363 |
scrollPane.setViewportView(hardStringTable); |
|
|
364 |
|
365 |
jSplitPane1.setLeftComponent(scrollPane); |
366 |
|
367 |
preview.setEditable(false); |
368 |
jScrollPane1.setViewportView(preview); |
369 |
|
370 |
jSplitPane1.setRightComponent(jScrollPane1); |
341 |
|
371 |
|
342 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
372 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
343 |
gridBagConstraints.gridx = 0; |
373 |
gridBagConstraints.gridx = 0; |
Lines 345-352
Link Here
|
345 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
375 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
346 |
gridBagConstraints.weightx = 1.0; |
376 |
gridBagConstraints.weightx = 1.0; |
347 |
gridBagConstraints.weighty = 1.0; |
377 |
gridBagConstraints.weighty = 1.0; |
348 |
gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); |
378 |
add(jSplitPane1, gridBagConstraints); |
349 |
add(scrollPane, gridBagConstraints); |
|
|
350 |
}// </editor-fold>//GEN-END:initComponents |
379 |
}// </editor-fold>//GEN-END:initComponents |
351 |
|
380 |
|
352 |
private void sourceComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sourceComboActionPerformed |
381 |
private void sourceComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sourceComboActionPerformed |
Lines 359-373
Link Here
|
359 |
scrollPane.setViewportView(hardStringTable); |
388 |
scrollPane.setViewportView(hardStringTable); |
360 |
tableModel.fireTableDataChanged(); |
389 |
tableModel.fireTableDataChanged(); |
361 |
} |
390 |
} |
|
|
391 |
SourceData data = sourceMap.get(sourceCombo.getSelectedItem()); |
392 |
Document doc = data.getSupport().getDocument(); |
393 |
preview.setDocument(doc); |
362 |
}//GEN-LAST:event_sourceComboActionPerformed |
394 |
}//GEN-LAST:event_sourceComboActionPerformed |
363 |
|
395 |
|
364 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
396 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
365 |
private javax.swing.JLabel hardStringLabel; |
397 |
private javax.swing.JLabel hardStringLabel; |
366 |
private javax.swing.JTable hardStringTable; |
398 |
private javax.swing.JTable hardStringTable; |
|
|
399 |
private javax.swing.JScrollPane jScrollPane1; |
400 |
private javax.swing.JSplitPane jSplitPane1; |
401 |
private javax.swing.JEditorPane preview; |
367 |
private javax.swing.JScrollPane scrollPane; |
402 |
private javax.swing.JScrollPane scrollPane; |
368 |
private javax.swing.JComboBox sourceCombo; |
403 |
private javax.swing.JComboBox sourceCombo; |
369 |
private javax.swing.JLabel sourceLabel; |
404 |
private javax.swing.JLabel sourceLabel; |
370 |
// End of variables declaration//GEN-END:variables |
405 |
// End of variables declaration//GEN-END:variables |
|
|
406 |
|
407 |
public void valueChanged(ListSelectionEvent e) { |
408 |
int ix = hardStringTable.getSelectedRow(); |
409 |
if (ix >= 0) { |
410 |
Object o = hardStringTable.getModel().getValueAt (ix, COLUMN_INDEX_HARDSTRING); |
411 |
if (o instanceof HardCodedString) { |
412 |
HardCodedString hard = (HardCodedString) o; |
413 |
Position start = hard.getStartPosition(); |
414 |
Position end = hard.getEndPosition(); |
415 |
preview.setSelectionStart (start.getOffset()); |
416 |
preview.setSelectionEnd(end.getOffset()); |
417 |
} |
418 |
} |
419 |
} |
420 |
// End of variables declaration |
371 |
|
421 |
|
372 |
/** Table model for this class. */ |
422 |
/** Table model for this class. */ |
373 |
private class HardCodedStringTableModel extends AbstractTableModel { |
423 |
private class HardCodedStringTableModel extends AbstractTableModel { |