Changeset 11993 for trunk/gli/src/org
- Timestamp:
- 2006-07-04T09:34:05+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/FormatManager.java
r11890 r11993 33 33 import javax.swing.*; 34 34 import javax.swing.event.*; 35 import javax.swing.undo.*; 35 36 import org.greenstone.gatherer.Configuration; 36 37 import org.greenstone.gatherer.DebugStream; … … 72 73 static final private String DOCUMENTBUTTONS = "DocumentButtons"; 73 74 static final private String DOCUMENTBUTTONS_DEFAULT_FORMAT = "Detach|Highlight"; 74 75 static private HashMap format_map = null ; 76 75 77 /** The controls used to edit the format commands. */ 76 78 private Control controls = null; 77 79 /** A reference to ourselves so inner classes can get at the model. */ 78 80 private DOMProxyListModel model = null; 79 81 82 80 83 /** Constructor. */ 81 84 public FormatManager() { 82 85 super(CollectionDesignManager.collect_config.getDocumentElement(), CollectionConfiguration.FORMAT_ELEMENT, new Format()); 83 86 this.model = this; 87 88 format_map = new HashMap(); 89 format_map.put(DATELIST,"<td>[link][icon][/link]</td>\n<td>[highlight]{Or}{[dls.Title],[dc.Title],[ex.Title],Untitled}[/highlight]</td>\n<td>[ex.Date]</td>"); 90 format_map.put(HLIST,"[link][highlight][ex.Title][/highlight][/link]"); 91 format_map.put(VLIST,"<td valign=\"top\">[link][icon][/link]</td>\n<td valign=\"top\">[ex.srclink]{Or}{[ex.thumbicon],[ex.srcicon]}[ex./srclink]</td>\n<td valign=\"top\">[highlight]\n{Or}{[dls.Title],[dc.Title],[ex.Title],Untitled}\n[/highlight]{If}{[ex.Source],<br><i>([ex.Source])</i>}</td>"); 92 format_map.put(DOCUMENTHEADING,"{Or}{[parent(Top):Title],[Title],untitled}<br>"); 93 format_map.put(DOCUMENTTEXT,"[Text]"); 94 format_map.put( DOCUMENTBUTTONS,"Detach|Highlight"); 95 format_map.put( "",""); 96 84 97 DebugStream.println("FormatManager: parsed " + getSize() + " format statements."); 85 98 // Establish all of the format objects, so that classifier indexes are initially correct (subsequent refreshes of the model will be sufficient to keep these up to date, as long as we start with a live reference to a classifier. 86 99 int size = getSize(); 87 for(int i = 0; i < size; i++) {100 for(int i = 0; i < size; i++) { 88 101 getElementAt(i); 89 102 } 90 91 // Ensure the default formats for DateList, HList and VList are assigned103 104 // Ensure the default formats for DateList, HList and VList are assigned 92 105 if (getFormat(DATELIST) == null) { 93 addFormat(new Format("",DATELIST,DATELIST_DEFAULT_FORMAT)); 94 } 95 106 addFormat(new Format("",DATELIST,DATELIST_DEFAULT_FORMAT)); 107 } 108 109 96 110 if (getFormat(HLIST) == null) { 97 addFormat(new Format("",HLIST,HLIST_DEFAULT_FORMAT)); 98 } 99 111 addFormat(new Format("",HLIST,HLIST_DEFAULT_FORMAT)); 112 } 113 114 100 115 if (getFormat(VLIST) == null) { 101 addFormat(new Format("",VLIST,VLIST_DEFAULT_FORMAT)); 102 } 116 addFormat(new Format("",VLIST,VLIST_DEFAULT_FORMAT)); 117 } 118 103 119 104 120 if (getFormat(DOCUMENTHEADING) == null) { 105 121 addFormat(new Format(DOCUMENTHEADING, "", DOCUMENTHEADING_DEFAULT_FORMAT)); 106 } 107 if (getFormat(DOCUMENTTEXT) == null) { 122 } 123 124 125 if (getFormat(DOCUMENTTEXT)== null) { 108 126 addFormat(new Format(DOCUMENTTEXT,"",DOCUMENTTEXT_DEFAULT_FORMAT)); 109 } 110 if (getFormat(DOCUMENTBUTTONS) == null) { 127 } 128 129 130 131 if (getFormat(DOCUMENTBUTTONS) == null) { 111 132 addFormat(new Format(DOCUMENTBUTTONS,"",DOCUMENTBUTTONS_DEFAULT_FORMAT)); 112 }113 133 } 134 114 135 } 115 136 … … 118 139 */ 119 140 private void addFormat(Format format) { 120 if(!contains(format)) {141 if(!contains(format)) { 121 142 Element element = format.getElement(); 122 143 // Locate where we should insert this new classifier. … … 126 147 } 127 148 } 149 128 150 129 151 public void destroy() { … … 181 203 remove(format); 182 204 Gatherer.c_man.configurationChanged(); 205 183 206 } 184 207 … … 212 235 { 213 236 ArrayList variable_model = new ArrayList(); 237 variable_model.add(""); 214 238 variable_model.add("[Text]"); 215 239 ArrayList every_metadata_set_element = MetadataSetManager.getEveryMetadataSetElement(); … … 235 259 private class FormatControl 236 260 extends JPanel 237 implements Control 261 implements Control{ 238 262 239 263 private ArrayList feature_model; … … 246 270 private JButton insert_button; 247 271 private JButton remove_button; 248 private JButton replace_button; 249 private JCheckBox enabled_checkbox; 272 private JButton default_button; 273 private JButton undo_button; 274 private JButton redo_button; 275 private JCheckBox enabled_checkbox; 250 276 private JComboBox feature_combobox; 251 277 private JComboBox part_combobox; … … 258 284 private JPanel selection_pane; 259 285 private String view_type; 260 261 private final Dimension FIELD_SIZE = new Dimension(200, 30); 262 public FormatControl() { 286 private final Dimension FIELD_SIZE = new Dimension(200, 30); 287 private final UndoManager undo = new UndoManager(); 288 private boolean newtext = true; 289 private Format previousFormat = null; 290 private Format currentFormat = null; 291 private boolean fresh = true; 292 293 public FormatControl() { 263 294 feature_model = buildFeatureModel(); 264 295 part_model = buildPartModel(); 265 296 variable_model = buildVariableModel(); 266 297 267 298 // Create 268 299 JPanel header_pane = new DesignPaneHeader("CDM.GUI.Formats", "formatstatements"); … … 310 341 editor_textarea.setRows(6); 311 342 editor_textarea.setWrapStyleWord(false); 312 Dictionary.registerTooltip(editor_textarea, "CDM.FormatManager. Editor_Tooltip");343 Dictionary.registerTooltip(editor_textarea, "CDM.FormatManager.Add_Tooltip"); 313 344 314 345 JPanel variable_pane = new JPanel(); … … 321 352 insert_button.setMnemonic(KeyEvent.VK_I); 322 353 Dictionary.registerBoth(insert_button, "CDM.FormatManager.Insert", "CDM.FormatManager.Insert_Tooltip"); 323 354 355 default_button = new GLIButton(); 356 default_button.setMnemonic(KeyEvent.VK_D); 357 Dictionary.registerBoth(default_button, "CDM.FormatManager.Default", "CDM.FormatManager.Default_Tooltip"); 358 324 359 JPanel flag_pane = new JPanel(); 325 360 enabled_checkbox = new JCheckBox(); … … 331 366 add_button.setMnemonic(KeyEvent.VK_A); 332 367 Dictionary.registerBoth(add_button, "CDM.FormatManager.Add", "CDM.FormatManager.Add_Tooltip"); 333 replace_button = new GLIButton(); 334 replace_button.setEnabled(false); 335 replace_button.setMnemonic(KeyEvent.VK_C); 336 Dictionary.registerBoth(replace_button, "CDM.FormatManager.Replace", "CDM.FormatManager.Replace_Tooltip"); 368 369 337 370 remove_button = new GLIButton(); 338 371 remove_button.setEnabled(false); … … 340 373 Dictionary.registerBoth(remove_button, "CDM.FormatManager.Remove", "CDM.FormatManager.Remove_Tooltip"); 341 374 375 undo_button = new GLIButton(); 376 undo_button.setEnabled(false); 377 undo_button.setMnemonic(KeyEvent.VK_U); 378 Dictionary.registerBoth(undo_button, "CDM.FormatManager.Undo", "CDM.FormatManager.Undo_Tooltip"); 379 380 redo_button = new GLIButton(); 381 redo_button.setEnabled(false); 382 redo_button.setMnemonic(KeyEvent.VK_O); 383 Dictionary.registerBoth(redo_button, "CDM.FormatManager.Redo", "CDM.FormatManager.Redo_Tooltip"); 384 385 342 386 // Connect 343 387 add_button.addActionListener(new AddListener()); 344 388 add_button.addActionListener(CollectionDesignManager.collect_cfg_change_listener); 345 insert_button.addActionListener(new InsertListener()); 346 insert_button.addActionListener(CollectionDesignManager.collect_cfg_change_listener); 389 347 390 remove_button.addActionListener(new RemoveListener()); 348 391 remove_button.addActionListener(CollectionDesignManager.collect_cfg_change_listener); 349 replace_button.addActionListener(new ReplaceListener()); 350 replace_button.addActionListener(CollectionDesignManager.collect_cfg_change_listener); 392 default_button.addActionListener(new DefaultListener()); 393 default_button.addActionListener(CollectionDesignManager.collect_cfg_change_listener); 394 undo_button.addActionListener(new UndoListener()); 395 redo_button.addActionListener(new RedoListener()); 351 396 enabled_checkbox.addActionListener(new EnabledListener()); 352 397 enabled_checkbox.addActionListener(CollectionDesignManager.collect_cfg_change_listener); 353 398 feature_combobox.addActionListener(new FeatureListener()); 354 399 part_combobox.addActionListener(new PartListener()); 355 editor_textarea.getDocument().addDocumentListener(new EditorListener()); 356 format_list.addListSelectionListener(new FormatListListener()); 400 401 editor_textarea.getDocument().addDocumentListener(new EditorListener()); 402 // Listen for undo and redo events 403 editor_textarea.getDocument().addUndoableEditListener(new UndoableEditListener() { 404 public void undoableEditHappened(UndoableEditEvent evt) { 405 undo.addEdit(evt.getEdit()); 406 } 407 }); 408 409 410 format_list.addListSelectionListener(new FormatListListener()); 411 variable_combobox.addActionListener(new VariableListener()); 357 412 358 413 // Layout … … 361 416 format_list_pane.setLayout(new BorderLayout()); 362 417 format_list_pane.add(new JScrollPane(format_list), BorderLayout.CENTER); 418 363 419 364 420 feature_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); … … 372 428 part_pane.add(part_combobox, BorderLayout.CENTER); 373 429 374 //selection_pane.setLayout(new GridLayout(2,1,0,2));375 //selection_pane.add(feature_pane);376 //selection_pane.add(part_pane);377 430 378 431 flag_pane.add(enabled_checkbox); … … 381 434 editor_header_pane.setLayout(new GridLayout(1,3)); 382 435 editor_header_pane.add(editor_label); 383 436 437 JPanel rupanel = new JPanel(); 438 rupanel.setLayout(new GridLayout(1,2)); 439 rupanel.add(undo_button); 440 rupanel.add(redo_button); 441 384 442 variable_pane.setBorder(BorderFactory.createEmptyBorder(2,0,2,0)); 385 443 variable_pane.setLayout(new GridLayout(1,3)); 386 444 variable_pane.add(variable_label); 387 445 variable_pane.add(variable_combobox); 388 variable_pane.add( insert_button);446 variable_pane.add(rupanel); 389 447 390 448 editor_pane.setLayout(new BorderLayout()); 391 449 editor_pane.add(editor_header_pane, BorderLayout.NORTH); 392 editor_pane.add(new JScrollPane(editor_textarea), BorderLayout.CENTER); 393 //editor_pane.add(variable_pane, BorderLayout.SOUTH); 450 editor_pane.add(new JScrollPane(editor_textarea), BorderLayout.CENTER); 394 451 395 452 selection_pane.setLayout(new BorderLayout()); … … 402 459 control_pane.add(selection_pane, VALUE); 403 460 control_pane.add(blank_pane, BLANK); 404 461 462 405 463 button_pane.setLayout(new GridLayout(1,3)); 406 464 button_pane.add(add_button); 407 button_pane.add(replace_button);408 465 button_pane.add(remove_button); 466 button_pane.add(default_button); 467 409 468 410 469 center_pane.setLayout(new BorderLayout()); … … 424 483 } 425 484 485 486 426 487 /** Overriden to ensure that the instructions pane is scrolled to the top. 427 488 */ … … 442 503 variable_combobox.setModel(new DefaultComboBoxModel(variable_model.toArray())); 443 504 variable_combobox.setSelectedItem(selected_variable); 444 }505 } 445 506 } 446 507 … … 451 512 } 452 513 514 515 453 516 /** Listens for clicks on the add button, and if the relevant details are provided adds a new format. Note that formats are responsible for codecing the values into something that can be a) stored in a DOM and b) written to file */ 454 517 private class AddListener … … 457 520 public void actionPerformed(ActionEvent event) 458 521 { 522 459 523 ignore_event = true; // Prevent format_list excetera propagating events 460 524 … … 470 534 if (view_type.equals(FLAG)) { 471 535 format = new Format(f, p, enabled_checkbox.isSelected()); 472 536 } 473 537 else { 474 538 format = new Format(f, p, editor_textarea.getText()); 539 475 540 } 541 542 476 543 addFormat(format); 477 544 existingFormat(); 478 545 // Save the collection configuration file immediately 479 Gatherer.g_man.design_pane.saveConfiguration(); 480 481 add_button.setEnabled(false); 482 replace_button.setEnabled(false); 483 remove_button.setEnabled(true); 484 485 // Update list selection 546 547 Gatherer.c_man.configurationChanged(); 548 549 // Update list selection 486 550 format_list.setSelectedValue(format, true); 487 551 format = null; … … 497 561 498 562 public void changedUpdate(DocumentEvent e) { 563 499 564 update(); 500 565 } 501 566 502 567 public void insertUpdate(DocumentEvent e) { 503 update(); 568 update(); 569 updateUndo("insert"); 570 504 571 } 505 572 506 573 public void removeUpdate(DocumentEvent e) { 507 574 update(); 575 updateUndo("remove"); 576 577 } 578 579 private void updateUndo(String from){ 580 581 if (!newtext){ 582 undo_button.setEnabled(true); 583 } 584 585 if (editor_textarea.getText().length()!=0 && newtext){ 586 newtext = false; 587 } 508 588 } 509 589 510 590 public void update() { 591 511 592 // Determine if replace should be enabled 512 593 if(!format_list.isSelectionEmpty()) { 513 594 Format format = (Format)format_list.getSelectedValue(); 514 replace_button.setEnabled(!format.isParamType() && editor_textarea.getText() != format.getValue()); 595 boolean shouldSave = !format.isParamType(); 596 597 if (shouldSave){ 598 format.setValue(editor_textarea.getText()); 599 Gatherer.c_man.configurationChanged(); 600 model.refresh((DOMProxyListEntry)format); 601 } 602 515 603 } 516 604 else { 517 replace_button.setEnabled(false); 605 add_button.setEnabled(false); 606 518 607 } 608 519 609 } 520 610 } … … 527 617 if(!format_list.isSelectionEmpty()) { 528 618 Format format = (Format)format_list.getSelectedValue(); 529 replace_button.setEnabled(format.isParamType() && enabled_checkbox.isSelected() != format.getState()); 619 boolean shouldSave = format.isParamType(); 620 if (shouldSave){ 621 format.setState(enabled_checkbox.isSelected()); 622 Gatherer.c_man.configurationChanged(); 623 model.refresh((DOMProxyListEntry)format); 624 } 530 625 } 626 531 627 // Thats it. Add would have been enabled upon feature/part selection depending if no existing format, um, existed. 532 628 } … … 536 632 implements ActionListener { 537 633 public void actionPerformed(ActionEvent event) { 634 undo_button.setEnabled(false); 635 redo_button.setEnabled(false); 636 default_button.setEnabled(true); 637 newtext = true; 638 538 639 if(!ignore_event) { 539 640 ignore_event = true; … … 549 650 } 550 651 // Step two: the rest 551 652 552 653 String name = entry.toString(); 553 654 // Add is only enabled if there isn't already a format for the choosen feature and part. Create a dummy format and test if itsa already in the model … … 558 659 if(f.toString().length() == 0 && pname.length() == 0) { 559 660 add_button.setEnabled(false); 560 replace_button.setEnabled(false);561 661 remove_button.setEnabled(false); 562 662 } … … 565 665 Format format = getFormat(Format.generateName(f, pname)); 566 666 // If there is an existing feature, select it, and use it to determine what controls are visible 667 567 668 if(format != null) { 568 669 ///ystem.err.println("There is an existing format!"); … … 584 685 view_type = VALUE; 585 686 // Initial value 586 editor_textarea.setText(format.getValue()); 687 688 editor_textarea.setText(format.getValue()); 689 editor_textarea.setCaretPosition(0); 690 587 691 } 692 existingFormat(); 588 693 control_pane.updateUI(); 589 remove_button.setEnabled(true);590 add_button.setEnabled(false);591 694 } 592 695 // Otherwise there is no existing format, so we proceed by checking against the feature name 593 696 else { 594 697 ///ystem.err.println("No existing format"); 595 698 format_list.clearSelection(); 596 699 if(Format.isParamType(name)) { 597 700 ///ystem.err.println("Flag type"); … … 602 705 // Initial value 603 706 enabled_checkbox.setSelected(false); 707 enabled_checkbox.setEnabled(false); 604 708 } 605 709 else { … … 609 713 view_type = VALUE; 610 714 // Initial value 715 611 716 editor_textarea.setText(part.getDefaultFormat()); 717 editor_textarea.setCaretPosition(0); 718 612 719 } 613 add_button.setEnabled(true);720 newFormat(); 614 721 } 615 722 format = null; … … 619 726 pname = null; 620 727 f = null; 621 replace_button.setEnabled(false);622 728 name = null; 623 729 entry = null; 624 730 ignore_event = false; 625 731 } 732 undo.discardAllEdits(); 626 733 } 627 734 } … … 630 737 implements ListSelectionListener { 631 738 public void valueChanged(ListSelectionEvent event) { 739 undo_button.setEnabled(false); 740 redo_button.setEnabled(false); 741 default_button.setEnabled(true); 742 newtext = true; 743 632 744 if(!ignore_event && !event.getValueIsAdjusting()) { 745 633 746 if(!format_list.isSelectionEmpty()) { 634 ignore_event = true; 747 existingFormat(); 748 ignore_event = true; 635 749 Format format = (Format)format_list.getSelectedValue(); 636 750 // Try to match the target, remembering the entries within are Entry's … … 679 793 part_combobox.insertItemAt(a_part, part_combobox.getItemCount()); 680 794 part_combobox.setSelectedItem(a_part); 681 }682 795 796 } 797 683 798 editor_textarea.setText(format.getValue()); 684 } 799 editor_textarea.setCaretPosition(0); 800 801 } 802 685 803 //control_pane.updateUI(); 686 remove_button.setEnabled(true);687 804 ignore_event = false; 688 805 } 689 else { 690 remove_button.setEnabled(false); 691 } 692 add_button.setEnabled(false); 693 replace_button.setEnabled(false); 806 694 807 } 695 } 696 } 697 698 private class InsertListener 808 undo.discardAllEdits(); 809 } 810 811 } 812 813 private void newFormat(){ 814 editor_textarea.setEditable(false); 815 editor_textarea.setBackground(Color.lightGray); 816 Dictionary.registerTooltip(editor_textarea, "CDM.FormatManager.Add_Tooltip"); 817 818 enabled_checkbox.setEnabled(false); 819 undo_button.setEnabled(false); 820 redo_button.setEnabled(false); 821 variable_combobox.setEnabled(false); 822 add_button.setEnabled(true); 823 remove_button.setEnabled(false); 824 default_button.setEnabled(false); 825 826 } 827 828 private void existingFormat(){ 829 editor_textarea.setEditable(true); 830 editor_textarea.setBackground(Color.white); 831 Dictionary.registerTooltip(editor_textarea, "CDM.FormatManager.Edit_Tooltip"); 832 enabled_checkbox.setEnabled(true); 833 variable_combobox.setEnabled(true); 834 add_button.setEnabled(false); 835 remove_button.setEnabled(true); 836 default_button.setEnabled(true); 837 838 } 839 840 private class VariableListener 699 841 implements ActionListener { 700 842 public void actionPerformed(ActionEvent event) { 701 editor_textarea.insert((String)variable_combobox.getSelectedItem(), editor_textarea.getCaretPosition()); 702 } 703 } 704 843 String selected_value = (String)variable_combobox.getSelectedItem(); 844 845 if (!selected_value.equals("")){ 846 editor_textarea.insert(selected_value, editor_textarea.getCaretPosition()); 847 undo_button.setEnabled(true); 848 849 } 850 } 851 852 } 853 705 854 private class PartListener 706 855 implements ActionListener { 707 856 public void actionPerformed(ActionEvent event) { 708 if(!ignore_event) { 857 undo_button.setEnabled(false); 858 redo_button.setEnabled(false); 859 default_button.setEnabled(true); 860 newtext = true; 861 if(!ignore_event) { 709 862 // Add is only enabled if there isn't already a format for the choosen feature and part. Create a dummy format and test if its already in the model 710 863 Entry entry = (Entry) feature_combobox.getSelectedItem(); … … 715 868 if(f.toString().length() == 0 && pname.length() == 0) { 716 869 add_button.setEnabled(false); 717 replace_button.setEnabled(false);718 870 remove_button.setEnabled(false); 719 871 } … … 738 890 view_type = VALUE; 739 891 // Initial value 892 740 893 editor_textarea.setText(format.getValue()); 894 editor_textarea.setCaretPosition(0); 895 741 896 } 742 897 control_pane.updateUI(); 743 remove_button.setEnabled(true);898 existingFormat(); 744 899 } 745 900 else { … … 752 907 // Initial value 753 908 enabled_checkbox.setSelected(false); 909 enabled_checkbox.setEnabled(false); 754 910 } 755 911 else { … … 758 914 view_type = VALUE; 759 915 // Initial value 760 editor_textarea.setText(part.getDefaultFormat()); 916 917 editor_textarea.setText(part.getDefaultFormat()); 918 editor_textarea.setCaretPosition(0); 919 761 920 } 762 add_button.setEnabled(true);921 newFormat(); 763 922 } 764 923 format = null; … … 770 929 f = null; 771 930 entry = null; 772 replace_button.setEnabled(false);773 931 } 932 undo.discardAllEdits(); 774 933 } 775 934 } … … 785 944 786 945 // Save the collection configuration file immediately 787 Gatherer.g_man.design_pane.saveConfiguration(); 788 946 Gatherer.c_man.configurationChanged(); 789 947 // Change buttons 790 948 add_button.setEnabled(true); 791 replace_button.setEnabled(false); 949 newFormat(); 950 792 951 } 793 794 remove_button.setEnabled(false);795 } 796 } 797 798 private class ReplaceListener952 } 953 } 954 955 956 957 private class DefaultListener 799 958 implements ActionListener { 800 959 801 960 public void actionPerformed(ActionEvent event) 802 961 { 803 ignore_event = true; // Prevent format_list excetera propagating events 804 805 if (!format_list.isSelectionEmpty()) { 806 // Remove the current format 807 removeFormat((Format) format_list.getSelectedValue()); 808 962 newtext = false; 963 if(!ignore_event) { 809 964 Entry entry = (Entry) feature_combobox.getSelectedItem(); 810 965 Object f = entry.getFeature(); 811 String p = ""; 812 if (entry.canHavePart()) { 813 p = part_combobox.getSelectedItem().toString(); 814 } 815 816 // Add a new format string of the appropriate type 817 Format format = null; 818 if (view_type.equals(FLAG)) { 819 format = new Format(f, p, enabled_checkbox.isSelected()); 966 String name =""; 967 String pname=""; 968 Part part = null; 969 970 if (entry.canHavePart()){ 971 part = (Part) part_combobox.getSelectedItem(); 972 pname = part.getName(); 973 name = Format.generateName(f, pname); 974 } 975 else{ 976 name = entry.toString(); 977 } 978 979 Format format = getFormat(name); 980 // If there is an existing feature, select it. 981 if(format != null) { 982 remove_button.setEnabled(true); 820 983 } 821 984 else { 822 format = new Format(f, p, editor_textarea.getText()); 823 } 824 addFormat(format); 825 826 // Save the collection configuration file immediately 827 Gatherer.g_man.design_pane.saveConfiguration(); 828 829 add_button.setEnabled(false); 830 remove_button.setEnabled(true); 831 // Update list selection 832 format_list.setSelectedValue(format, true); 833 format = null; 834 p = null; 835 f = null; 836 entry = null; 985 986 add_button.setEnabled(true); 987 }//endif (format !=null) 988 989 if(Format.isParamType(name)) { 990 // Flags first. 991 card_layout.show(control_pane, FLAG); 992 view_type = FLAG; 993 // Initial value 994 enabled_checkbox.setSelected(false); 995 } 996 else { 997 card_layout.show(control_pane, VALUE); 998 view_type = VALUE; 999 // Initial value 1000 if (pname !=null && pname.length()!=0 ){ 1001 editor_textarea.setText((String)format_map.get(pname)); 1002 editor_textarea.setCaretPosition(0); 1003 } 1004 else{ 1005 editor_textarea.setText((String)format_map.get(name)); 1006 editor_textarea.setCaretPosition(0); 1007 } 1008 } 1009 837 1010 } 838 839 replace_button.setEnabled(false); 840 ignore_event = false; 841 } 842 } 1011 } 1012 1013 } 1014 1015 private class UndoListener 1016 implements ActionListener { 1017 1018 public void actionPerformed(ActionEvent event) 1019 { 1020 try { 1021 if (undo.canUndo()) { 1022 int pos = editor_textarea.getCaretPosition(); 1023 undo.undo(); 1024 editor_textarea.setCaretPosition(pos); 1025 redo_button.setEnabled(true); 1026 1027 } 1028 if (!undo.canUndo()){ 1029 undo_button.setEnabled(false); 1030 } 1031 else{ 1032 undo_button.setEnabled(true); 1033 } 1034 1035 } catch (Exception e) { 1036 } 1037 } 1038 } 1039 1040 private class RedoListener 1041 implements ActionListener { 1042 public void actionPerformed(ActionEvent evt) { 1043 try { 1044 if (undo.canRedo()) { 1045 int pos = editor_textarea.getCaretPosition(); 1046 undo.redo(); 1047 editor_textarea.setCaretPosition(pos); 1048 } 1049 if (!undo.canRedo()){ 1050 redo_button.setEnabled(false); 1051 } 1052 else{ 1053 redo_button.setEnabled(true); 1054 } 1055 1056 } catch (Exception e) {} 1057 } 1058 } 1059 843 1060 } 844 1061
Note:
See TracChangeset
for help on using the changeset viewer.