テキストの各行をキーと値に分離し、複数テキストファイルを読み込み、キーを突き合わせ照合し、その結果を表示するGUIユーテリティです。
リビジョン | 913f2b1ea4931337db081ebf515f62cd365693cb (tree) |
---|---|
日時 | 2011-10-24 02:27:18 |
作者 | seraphy <seraphy@192....> |
コミッター | seraphy |
・カラム削除の実装中
@@ -133,6 +133,9 @@ | ||
133 | 133 | </MenuItem> |
134 | 134 | <MenuItem class="javax.swing.JMenuItem" name="removeMenuItem"> |
135 | 135 | <Properties> |
136 | + <Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.swingapp.ActionEditor"> | |
137 | + <action class="textkeymatcher.ui.TextKeyMatcherView" id="onRemoveColumn" methodName="onRemoveColumn"/> | |
138 | + </Property> | |
136 | 139 | <Property name="mnemonic" type="int" value="82"/> |
137 | 140 | <Property name="text" type="java.lang.String" resourceKey="removeMenuItem.text"/> |
138 | 141 | <Property name="name" type="java.lang.String" value="removeMenuItem" noResource="true"/> |
@@ -428,6 +431,46 @@ | ||
428 | 431 | <AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="displayModeBinder.bindDataViewTableModel(dataViewTableModel);"/> |
429 | 432 | </AuxValues> |
430 | 433 | </Component> |
434 | + <Container class="javax.swing.JPanel" name="confirmRemoveColumnPanel"> | |
435 | + <Properties> | |
436 | + <Property name="name" type="java.lang.String" value="confirmRemoveColumnPanel" noResource="true"/> | |
437 | + </Properties> | |
438 | + | |
439 | + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> | |
440 | + <SubComponents> | |
441 | + <Component class="javax.swing.JLabel" name="removeColumnLabel"> | |
442 | + <Properties> | |
443 | + <Property name="horizontalAlignment" type="int" value="0"/> | |
444 | + <Property name="text" type="java.lang.String" resourceKey="removeColumnLabel.text"/> | |
445 | + <Property name="horizontalTextPosition" type="int" value="0"/> | |
446 | + <Property name="name" type="java.lang.String" value="removeColumnLabel" noResource="true"/> | |
447 | + </Properties> | |
448 | + <Constraints> | |
449 | + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> | |
450 | + <BorderConstraints direction="North"/> | |
451 | + </Constraint> | |
452 | + </Constraints> | |
453 | + </Component> | |
454 | + <Component class="javax.swing.JComboBox" name="removeColumnComboBox"> | |
455 | + <Properties> | |
456 | + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> | |
457 | + <StringArray count="4"> | |
458 | + <StringItem index="0" value="Item 1"/> | |
459 | + <StringItem index="1" value="Item 2"/> | |
460 | + <StringItem index="2" value="Item 3"/> | |
461 | + <StringItem index="3" value="Item 4"/> | |
462 | + </StringArray> | |
463 | + </Property> | |
464 | + <Property name="name" type="java.lang.String" value="removeColumnComboBox" noResource="true"/> | |
465 | + </Properties> | |
466 | + <Constraints> | |
467 | + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> | |
468 | + <BorderConstraints direction="Center"/> | |
469 | + </Constraint> | |
470 | + </Constraints> | |
471 | + </Component> | |
472 | + </SubComponents> | |
473 | + </Container> | |
431 | 474 | </NonVisualComponents> |
432 | 475 | <Properties> |
433 | 476 | <Property name="component" type="javax.swing.JComponent" editor="org.netbeans.modules.form.ComponentChooserEditor"> |
@@ -22,8 +22,10 @@ import java.awt.event.ActionListener; | ||
22 | 22 | import java.awt.event.InputEvent; |
23 | 23 | import java.awt.event.KeyEvent; |
24 | 24 | import java.io.File; |
25 | +import java.util.ArrayList; | |
25 | 26 | import java.util.logging.Level; |
26 | 27 | import java.util.logging.Logger; |
28 | +import javax.swing.DefaultComboBoxModel; | |
27 | 29 | import javax.swing.Timer; |
28 | 30 | import javax.swing.Icon; |
29 | 31 | import javax.swing.InputMap; |
@@ -39,6 +41,7 @@ import javax.swing.table.DefaultTableCellRenderer; | ||
39 | 41 | import org.jdesktop.application.Application; |
40 | 42 | import textkeymatcher.TextKeyMatcherApp; |
41 | 43 | import textkeymatcher.entity.FilteredRowMap; |
44 | +import textkeymatcher.entity.LineDataList; | |
42 | 45 | import textkeymatcher.io.DocArchive; |
43 | 46 | import textkeymatcher.io.FileDocArchive; |
44 | 47 | import textkeymatcher.service.LineDataBuilder; |
@@ -341,6 +344,9 @@ public class TextKeyMatcherView extends FrameView implements ExitListener { | ||
341 | 344 | dataViewTableModel = new textkeymatcher.ui.model.DataViewTableModel(); |
342 | 345 | keyMatcherBinder = new textkeymatcher.ui.model.KeyMatcherBinder(); |
343 | 346 | displayModeBinder = new textkeymatcher.ui.model.DisplayModeBinder(); |
347 | + confirmRemoveColumnPanel = new javax.swing.JPanel(); | |
348 | + removeColumnLabel = new javax.swing.JLabel(); | |
349 | + removeColumnComboBox = new javax.swing.JComboBox(); | |
344 | 350 | |
345 | 351 | mainPanel.setName("mainPanel"); // NOI18N |
346 | 352 |
@@ -407,6 +413,7 @@ public class TextKeyMatcherView extends FrameView implements ExitListener { | ||
407 | 413 | jSeparator2.setName("jSeparator2"); // NOI18N |
408 | 414 | dataMenu.add(jSeparator2); |
409 | 415 | |
416 | + removeMenuItem.setAction(actionMap.get("onRemoveColumn")); // NOI18N | |
410 | 417 | removeMenuItem.setMnemonic('R'); |
411 | 418 | removeMenuItem.setText(resourceMap.getString("removeMenuItem.text")); // NOI18N |
412 | 419 | removeMenuItem.setName("removeMenuItem"); // NOI18N |
@@ -596,6 +603,19 @@ public class TextKeyMatcherView extends FrameView implements ExitListener { | ||
596 | 603 | |
597 | 604 | displayModeBinder.bindDataViewTableModel(dataViewTableModel); |
598 | 605 | |
606 | + confirmRemoveColumnPanel.setName("confirmRemoveColumnPanel"); // NOI18N | |
607 | + confirmRemoveColumnPanel.setLayout(new java.awt.BorderLayout()); | |
608 | + | |
609 | + removeColumnLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); | |
610 | + removeColumnLabel.setText(resourceMap.getString("removeColumnLabel.text")); // NOI18N | |
611 | + removeColumnLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); | |
612 | + removeColumnLabel.setName("removeColumnLabel"); // NOI18N | |
613 | + confirmRemoveColumnPanel.add(removeColumnLabel, java.awt.BorderLayout.NORTH); | |
614 | + | |
615 | + removeColumnComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); | |
616 | + removeColumnComboBox.setName("removeColumnComboBox"); // NOI18N | |
617 | + confirmRemoveColumnPanel.add(removeColumnComboBox, java.awt.BorderLayout.CENTER); | |
618 | + | |
599 | 619 | setComponent(mainPanel); |
600 | 620 | setMenuBar(menuBar); |
601 | 621 | setStatusBar(statusPanel); |
@@ -715,6 +735,7 @@ public class TextKeyMatcherView extends FrameView implements ExitListener { | ||
715 | 735 | dataViewTableModel.addLineDataList(collector); |
716 | 736 | checkEnableSave(); |
717 | 737 | checkEnableNew(); |
738 | + checkEnableRemoveColumn(); | |
718 | 739 | statusMessageLabel.setText("done."); |
719 | 740 | } |
720 | 741 | } |
@@ -780,6 +801,7 @@ public class TextKeyMatcherView extends FrameView implements ExitListener { | ||
780 | 801 | |
781 | 802 | checkEnableSave(); |
782 | 803 | checkEnableNew(); |
804 | + checkEnableRemoveColumn(); | |
783 | 805 | |
784 | 806 | statusMessageLabel.setText("initialized."); |
785 | 807 | } |
@@ -823,6 +845,7 @@ public class TextKeyMatcherView extends FrameView implements ExitListener { | ||
823 | 845 | |
824 | 846 | checkEnableSave(); |
825 | 847 | checkEnableNew(); |
848 | + checkEnableRemoveColumn(); | |
826 | 849 | } |
827 | 850 | |
828 | 851 |
@@ -851,17 +874,61 @@ public class TextKeyMatcherView extends FrameView implements ExitListener { | ||
851 | 874 | } |
852 | 875 | } |
853 | 876 | |
877 | + /** | |
878 | + * カラムの削除アクション | |
879 | + */ | |
880 | + @Action(enabledProperty = "enableRemoveColumn") | |
881 | + public void onRemoveColumn() { | |
882 | + int mx = dataViewTableModel.getNumOfLineDataLists(); | |
883 | + if (mx <= 1) { | |
884 | + return; | |
885 | + } | |
886 | + | |
887 | + // カラム一覧を作成する. | |
888 | + ArrayList<Object> items = new ArrayList<Object>(); | |
889 | + for (int idx = 0; idx < mx; idx++) { | |
890 | + final LineDataList lineDataList = dataViewTableModel.getLineDataList(idx); | |
891 | + Object item = new Object() { | |
892 | + @Override | |
893 | + public String toString() { | |
894 | + return lineDataList.getTitle(); | |
895 | + } | |
896 | + }; | |
897 | + items.add(item); | |
898 | + } | |
899 | + | |
900 | + DefaultComboBoxModel comboboxModel = new DefaultComboBoxModel( | |
901 | + items.toArray(new Object[items.size()])); | |
902 | + | |
903 | + removeColumnComboBox.setModel(comboboxModel); | |
904 | + | |
905 | + JOptionPane optionPane = new JOptionPane(); | |
906 | + | |
907 | +// .showConfirmDialog( | |
908 | +// getFrame(), | |
909 | +// confirmRemoveColumnPanel, | |
910 | +// "CONFIRM", | |
911 | +// JOptionPane.YES_NO_OPTION, | |
912 | +// JOptionPane.QUESTION_MESSAGE | |
913 | +// ); | |
914 | + } | |
854 | 915 | |
855 | 916 | private void checkEnableSave() { |
856 | - boolean hasDataSource = dataViewTableModel.getDataListCount() > 0; | |
917 | + boolean hasDataSource = dataViewTableModel.getNumOfLineDataLists() > 0; | |
857 | 918 | setEnableSave(hasDataSource); |
858 | 919 | } |
859 | 920 | |
860 | 921 | private void checkEnableNew() { |
861 | - boolean hasDataSource = dataViewTableModel.getDataListCount() > 0; | |
922 | + boolean hasDataSource = dataViewTableModel.getNumOfLineDataLists() > 0; | |
862 | 923 | setEnableNew(hasDataSource); |
863 | 924 | } |
864 | 925 | |
926 | + private void checkEnableRemoveColumn() { | |
927 | + // key/valueはペアであるため、最低1列は残す必要があるため、2以上の場合のみ削除可能. | |
928 | + boolean hasDataSource = dataViewTableModel.getNumOfLineDataLists() > 1; | |
929 | + setEnableRemoveColumn(hasDataSource); | |
930 | + } | |
931 | + | |
865 | 932 | private boolean enableSave = false; |
866 | 933 | public boolean isEnableSave() { |
867 | 934 | return enableSave; |
@@ -884,8 +951,20 @@ public class TextKeyMatcherView extends FrameView implements ExitListener { | ||
884 | 951 | firePropertyChange("enableNew", old, isEnableNew()); |
885 | 952 | } |
886 | 953 | |
954 | + private boolean enableRemoveColumn = false; | |
955 | + public boolean isEnableRemoveColumn() { | |
956 | + return enableRemoveColumn; | |
957 | + } | |
958 | + | |
959 | + public void setEnableRemoveColumn(boolean b) { | |
960 | + boolean old = isEnableRemoveColumn(); | |
961 | + this.enableRemoveColumn = b; | |
962 | + firePropertyChange("enableRemoveColumn", old, isEnableRemoveColumn()); | |
963 | + } | |
964 | + | |
887 | 965 | // Variables declaration - do not modify//GEN-BEGIN:variables |
888 | 966 | private javax.swing.JRadioButtonMenuItem allRadioButtonMenuItem; |
967 | + private javax.swing.JPanel confirmRemoveColumnPanel; | |
889 | 968 | private javax.swing.JMenu dataMenu; |
890 | 969 | private javax.swing.JTable dataViewTable; |
891 | 970 | private textkeymatcher.ui.model.DataViewTableModel dataViewTableModel; |
@@ -910,6 +989,8 @@ public class TextKeyMatcherView extends FrameView implements ExitListener { | ||
910 | 989 | private javax.swing.JRadioButtonMenuItem numberRadioButtonMenuItem; |
911 | 990 | private javax.swing.JMenuItem openMenuItem; |
912 | 991 | private javax.swing.JProgressBar progressBar; |
992 | + private javax.swing.JComboBox removeColumnComboBox; | |
993 | + private javax.swing.JLabel removeColumnLabel; | |
913 | 994 | private javax.swing.JMenuItem removeMenuItem; |
914 | 995 | private javax.swing.JMenuItem saveMenuItem; |
915 | 996 | private javax.swing.JLabel statusAnimationLabel; |
@@ -140,10 +140,31 @@ public class DataViewTableModel extends KeyMatchedRowView implements TextKeyMatc | ||
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | + * 指定したインデックスのデータソースを取得する. | |
144 | + * @param index インデックス | |
145 | + * @return データソース | |
146 | + */ | |
147 | + public LineDataList getLineDataList(int index) { | |
148 | + return rowMap.getLineDataList(index); | |
149 | + } | |
150 | + | |
151 | + /** | |
152 | + * 指定したインデックスのデータソースを削除する. | |
153 | + * @param index インデックス | |
154 | + */ | |
155 | + public void removeLineDataList(int index) { | |
156 | + rowMap.removeLineDataList(index); | |
157 | + rowMap.remap(); | |
158 | + | |
159 | + renumbering(rowMap); | |
160 | + setDirty(true); | |
161 | + } | |
162 | + | |
163 | + /** | |
143 | 164 | * 保持しているデータソースの数を返す |
144 | 165 | * @return データソースの数 |
145 | 166 | */ |
146 | - public int getDataListCount() { | |
167 | + public int getNumOfLineDataLists() { | |
147 | 168 | return rowMap.getNumOfLineDataLists(); |
148 | 169 | } |
149 | 170 |
@@ -69,3 +69,6 @@ uniqueRadioButtonMenuItem.text=Unique | ||
69 | 69 | ununiqueRadioButtonMenuItem.text=Ununique |
70 | 70 | jRadioButtonMenuItem1.text=Unique (Strict) |
71 | 71 | jRadioButtonMenuItem2.text=Ununique (Strict) |
72 | +onRemoveColumn.Action.text= | |
73 | +onRemoveColumn.Action.shortDescription= | |
74 | +removeColumnLabel.text=Choose the Remove Column |