Changeset 18364 for gli/branches
- Timestamp:
- 2009-01-12T11:40:15+13:00 (15 years ago)
- Location:
- gli/branches/rtl-gli/src/org/greenstone/gatherer/gui
- Files:
-
- 20 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/AboutDialog.java
r18297 r18364 34 34 import java.awt.event.*; 35 35 import javax.swing.*; 36 37 import org.greenstone.gatherer.Configuration; 36 38 import org.greenstone.gatherer.Dictionary; 37 39 import org.greenstone.gatherer.Gatherer; … … 73 75 upper_pane.setComponentOrientation(Dictionary.getOrientation()); 74 76 75 ImageIcon icon = JarTools.getImage("gatherer_medium.gif"); 77 String gmedium_image = "gatherer_medium.gif"; 78 if (Configuration.fedora_info.isActive()) { 79 gmedium_image = "fli-" + gmedium_image; 80 } 81 82 ImageIcon icon = JarTools.getImage(gmedium_image); 76 83 ImageIcon scaled_icon = new ImageIcon(icon.getImage().getScaledInstance(ICON_SIZE, ICON_SIZE, Image.SCALE_DEFAULT)); 77 84 JLabel icon_label = new JLabel(scaled_icon); -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/CreatePane.java
r18297 r18364 53 53 import org.greenstone.gatherer.shell.GBuildProgressMonitor; 54 54 import org.greenstone.gatherer.shell.GImportProgressMonitor; 55 import org.greenstone.gatherer.shell.GScheduleProgressMonitor; 55 56 import org.greenstone.gatherer.shell.GShell; 56 57 import org.greenstone.gatherer.shell.GShellEvent; … … 61 62 import org.greenstone.gatherer.util.Utility; 62 63 64 import org.greenstone.gatherer.collection.CollectionManager; 63 65 64 66 /** This class provides a GUI view showing some statistics on your current collection, and options for building it. As the collection is built this initial view is replaced with one showing progress bars and a message log of the creation process. This log can be later accessed via the options tree located in the center of the initial pane. This class is also responsible for creating the GShellProgressMonitors that are then attatched to external shell processes, and calling the methods in the CollectionManager for actually importing and building the collection. <br><BR> … … 93 95 /** This monitor tracks the import processes progress. */ 94 96 private GShellProgressMonitor import_monitor = null; 97 /** This monitor tracks the schedule processes progress. */ 98 private GShellProgressMonitor schedule_monitor = null; 95 99 /** The button for begining the building processes. */ 96 100 private JButton build_button = null; 97 101 /** The button for stopping the building processes. */ 98 102 private JButton cancel_button = null; 103 /** The button for setting up scheduling */ 104 private JButton schedule_button = null; 99 105 /** The button for viewing the collection. */ 100 106 private JButton preview_button = null; … … 149 155 public String homepage = null; 150 156 151 152 157 /** The constructor creates important helper classes, and initializes all the components. 153 158 * @see org.greenstone.gatherer.collection.CollectionManager … … 194 199 Gatherer.c_man.registerBuildMonitor(build_monitor); 195 200 201 //We only need a schedule monitor for text output. No use for a progress bar! 202 203 //progress_schedule_label = new JLabel(Dictionary.get("CreatePane.Schedule_Progress")); 204 205 schedule_monitor = new GScheduleProgressMonitor(); 206 Gatherer.c_man.registerScheduleMonitor(schedule_monitor); 207 196 208 // And the simple panel 197 209 slower_panel = new JPanel(); … … 238 250 } 239 251 252 BuildSimpleButtonListener bsbl = new BuildSimpleButtonListener(); 240 253 simple_build_button = new GLIButton(Dictionary.get("CreatePane.Build_Collection"), Dictionary.get("CreatePane.Build_Collection_Tooltip")); 241 simple_build_button.addActionListener(b bl);242 254 simple_build_button.addActionListener(bsbl); 255 243 256 simple_cancel_button = new GLIButton(Dictionary.get("CreatePane.Cancel_Build"), Dictionary.get("CreatePane.Cancel_Build_Tooltip")); 244 257 simple_cancel_button.addActionListener(cbl); … … 255 268 256 269 bbl = null; 270 bsbl = null; 257 271 cbl = null; 258 272 //pbl = null; … … 375 389 sargument_configuration_panel = options_pane.buildImport(null); 376 390 sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 391 // if(CollectionManager.canDoScheduling()) { 392 // sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 393 // } 377 394 } 378 395 else { … … 498 515 sargument_configuration_panel = options_pane.buildImport(null); 499 516 sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 517 // if(CollectionManager.canDoScheduling()) { 518 // sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 519 //} 500 520 } 501 521 else { … … 545 565 DebugStream.println("In CreatePane::processComplete(" + event.getType() + ")..."); 546 566 if(event.getStatus() == GShell.OK) { 547 if(event.getType() == GShell.BUILD) { 567 if(event.getType() == GShell.SCHEDULE) { 568 569 processing = false; 570 build_button.setEnabled(true); 571 cancel_button.setEnabled(false); 572 //preview_button.setEnabled(true); 573 //only enable preview if the collection has been built. 574 preview_button.setEnabled(Gatherer.c_man.built()); 575 simple_build_button.setEnabled(true); 576 simple_cancel_button.setEnabled(false); 577 simple_preview_button.setEnabled(Gatherer.c_man.built()); 578 int status = event.getStatus(); 579 document.setSpecialCharacter(OptionsPane.SCHEDULED); 580 options_pane.resetFileEntry(); 581 build_monitor.reset(); 582 import_monitor.reset(); 583 if(Configuration.getMode() >= THRESHOLD) { 584 control_pane.add(button_pane, BorderLayout.SOUTH); 585 card_layout.show(main_pane, CONTROL); 586 } 587 } 588 else if(event.getType() == GShell.BUILD) { 548 589 processing = false; 549 590 build_button.setEnabled(true); 550 591 cancel_button.setEnabled(false); 551 //preview_button.setEnabled(true);592 preview_button.setEnabled(true); 552 593 simple_build_button.setEnabled(true); 553 594 simple_cancel_button.setEnabled(false); … … 570 611 build_button.setEnabled(true); 571 612 // The build may have failed, but a previous index may still be in place 572 //preview_button.setEnabled(Gatherer.c_man.built());613 preview_button.setEnabled(Gatherer.c_man.built()); 573 614 574 615 simple_build_button.setEnabled(true); 575 616 simple_cancel_button.setEnabled(false); 576 //simple_preview_button.setEnabled(Gatherer.c_man.built());617 simple_preview_button.setEnabled(Gatherer.c_man.built()); 577 618 if(event.getStatus() == GShell.CANCELLED) { 578 619 document.setSpecialCharacter(OptionsPane.CANCELLED); … … 604 645 Collection current_collection = Gatherer.c_man.getCollection(); 605 646 if (current_collection != previous_collection && !Gatherer.c_man.isImporting()) { 606 this.options_pane = new OptionsPane(current_collection.import_options, current_collection.build_options );647 this.options_pane = new OptionsPane(current_collection.import_options, current_collection.build_options, current_collection.schedule_options); 607 648 if (previous_collection != null) { 608 649 // clear the log … … 620 661 sargument_configuration_panel = options_pane.buildImport(null); 621 662 sargument_configuration_panel = options_pane.buildBuild(sargument_configuration_panel); 663 //if(CollectionManager.canDoScheduling()) { 664 //sargument_configuration_panel = options_pane.buildSchedule(sargument_configuration_panel); 665 //} 622 666 sargument_configuration_scroll = new JScrollPane(sargument_configuration_panel); 623 667 sargument_configuration_scroll.setComponentOrientation(Dictionary.getOrientation()); … … 654 698 Collection collection = Gatherer.c_man.getCollection(); 655 699 String collection_name = collection.getName(); 656 if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 657 //Only design options have changes, and we want to be smart in the way we handle them. 658 int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 659 if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 660 // Just run the buildcol command. 661 DebugStream.println("Just want to run buildcol.pl"); 662 prepareForBuild(); 663 Gatherer.c_man.buildCollection(isIncremental()); 700 701 //if button is labelled for Building 702 if(event.getActionCommand().equals(Dictionary.get("CreatePane.Build_Collection"))) { 703 704 if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 705 //Only design options have changes, and we want to be smart in the way we handle them. 706 int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 707 if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 708 // Just run the buildcol command. 709 DebugStream.println("Just want to run buildcol.pl"); 710 prepareForBuild(); 711 Gatherer.c_man.buildCollection(isIncremental()); 712 } 713 else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 714 // Do both import and buildcol 715 DebugStream.println("Want to do a complete build"); 716 prepareForBuild(); 717 Gatherer.c_man.importCollection(); //This starts the building process. 718 } 719 else { 720 //Nothing at all needs doing. 721 //This is bad HCI. Maybe should disable the build button in this situation? 722 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 723 } 664 724 } 665 else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 666 // Do both import and buildcol 667 DebugStream.println("Want to do a complete build"); 725 else { 726 //Do a complete build. 668 727 prepareForBuild(); 669 728 Gatherer.c_man.importCollection(); //This starts the building process. 670 } 671 else { 672 //Nothing at all needs doing. 673 //This is bad HCI. Maybe should disable the build button in this situation? 674 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 675 } 676 } 677 else { 678 //Do a complete build. 679 prepareForBuild(); 680 Gatherer.c_man.importCollection(); //This starts the building process. 681 } 729 } 730 731 } else { //button is labelled for setting up scheduling 732 733 //this needs to be called to configure buttons... but no building is done 734 prepareForBuild(); 735 736 Gatherer.c_man.scheduleBuild(isIncremental()); 737 } 738 682 739 //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent) 683 740 } 684 741 685 742 /** 686 743 * This does some stuff that is needed before a collection can be built. … … 721 778 } 722 779 780 /** I hope this works. Wendy */ 781 private class BuildSimpleButtonListener 782 implements ActionListener { 783 /** 784 * This method checks to see what needs to be done for a build, and starts the process off. 785 * A complete build proccess is started by {@link CollectionManager.importCollection()}, which then imports and builds the collection. 786 * However, this doesn't always happen, as sometimes an incremental build will do :-) 787 * @param event An <strong>ActionEvent</strong> who, thanks to the power of object oriented programming, we don't give two hoots about. 788 * @see org.greenstone.gatherer.Gatherer 789 * @see org.greenstone.gatherer.collection.CollectionManager 790 * @see org.greenstone.gatherer.gui.BuildOptions 791 * @see org.greenstone.gatherer.shell.GShellProgressMonitor 792 */ 793 public void actionPerformed(ActionEvent event) { 794 Collection collection = Gatherer.c_man.getCollection(); 795 String collection_name = collection.getName(); 796 797 //prepareForBuild(); 798 if(!collection.getMetadataChanged() && !collection.getFilesChanged() && isIncremental()) { 799 //Only design options have changes, and we want to be smart in the way we handle them. 800 int rebuildTypeRequired = CollectionDesignManager.getRebuildTypeRequired(); 801 if (rebuildTypeRequired == CollectionDesignManager.BUILDCOL) { 802 // Just run the buildcol command. 803 DebugStream.println("Just want to run buildcol.pl"); 804 prepareForBuild(); 805 Gatherer.c_man.buildCollection(isIncremental()); 806 } 807 else if (rebuildTypeRequired == CollectionDesignManager.ALL) { 808 // Do both import and buildcol 809 DebugStream.println("Want to do a complete build"); 810 prepareForBuild(); 811 Gatherer.c_man.importCollection(); //This starts the building process. 812 } 813 else { 814 //Nothing at all needs doing. 815 //This is bad HCI. Maybe should disable the build button in this situation? 816 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CreatePane.Minimal_Build_Not_Required")); 817 } 818 } 819 else { 820 //Do a complete build. 821 prepareForBuild(); 822 Gatherer.c_man.importCollection(); //This starts the building process. 823 } 824 825 // have commented this out for now - scheduling currently not 826 // available except in expert mode 827 //only schedule in SYSTEM mode - also done in EXPERT mode, but that is handled elsewhere 828 /* if(Configuration.getMode() == Configuration.SYSTEMS_MODE) { 829 if(Gatherer.c_man.getCollection().schedule_options.getValueEnabled("schedule")) { 830 Gatherer.c_man.getCollection().schedule_options.setValue("action",true,"add"); 831 Gatherer.c_man.getCollection().schedule_options.setValue("email",false, null); 832 Gatherer.c_man.getCollection().schedule_options.setValue("smtp",false, null); 833 Gatherer.c_man.getCollection().schedule_options.setValue("toaddr",false, null); 834 Gatherer.c_man.getCollection().schedule_options.setValue("fromaddr",false, null); 835 Gatherer.c_man.getCollection().schedule_options.setValue("frequency",false, null); 836 Gatherer.c_man.scheduleBuild(isIncremental()); 837 } else { 838 //need to turn off existing scheduling 839 Gatherer.c_man.getCollection().schedule_options.setValue("action",true,"delete"); 840 Gatherer.c_man.scheduleBuild(isIncremental()); 841 842 } 843 } 844 */ 845 //Re-setting the rebuildTypeRequired is handled by CollectionManager.processComplete(GShellEvent) 846 } 847 848 /** 849 * This does some stuff that is needed before a collection can be built. 850 * For example, buttons are enabled/disabled, and certain flags are set. 851 * This is called from {@link actionPerformed(ActionEvent)} 852 */ 853 private void prepareForBuild() { 854 // First we force the build options to be updated if we haven't already. 855 tree.valueChanged(null); 856 857 // Remember that for lower thresholds the above doesn't work, so try this instead 858 if(Configuration.getMode() < THRESHOLD) { 859 options_pane.update(sargument_configuration_panel); 860 } 861 862 // Now go about building. 863 build_button.setEnabled(false); 864 cancel_button.setEnabled(true); 865 preview_button.setEnabled(false); 866 867 simple_build_button.setEnabled(false); 868 simple_cancel_button.setEnabled(true); 869 simple_preview_button.setEnabled(false); 870 871 document = options_pane.createNewLogDocument(); 872 log_textarea.setDocument(document); 873 options_pane.log_textarea.setDocument(document); 874 // Change the view. 875 processing = true; 876 if(Configuration.getMode() >= THRESHOLD) { 877 progress_pane.add(button_pane, BorderLayout.SOUTH); 878 card_layout.show(main_pane, PROGRESS); 879 } 880 // Reset the stop flag in all the process monitors, just incase. 881 ((GBuildProgressMonitor)build_monitor).reset(); 882 import_monitor.setStop(false); 883 } 884 } 723 885 886 724 887 /** This class serves as the listener for actions on the cancel button. */ 725 888 private class CancelButtonListener … … 771 934 /** The node corresponding to the importing options view. */ 772 935 private OptionTreeNode importing = null; 936 /** The node corresponding to the scheduling options view. */ 937 private OptionTreeNode scheduling = null; 773 938 /** The node corresponding to the log view. */ 774 939 private OptionTreeNode log = null; … … 793 958 importing = new OptionTreeNode(Dictionary.get("CreatePane.Import")); 794 959 importing.setToolTipText(Dictionary.get("CreatePane.Import_Tooltip")); 960 scheduling = new OptionTreeNode(Dictionary.get("CreatePane.Schedule")); 961 scheduling.setToolTipText(Dictionary.get("CreatePane.Schedule_Tooltip")); 962 795 963 log = new OptionTreeNode(Dictionary.get("CreatePane.Log")); 796 964 log.setToolTipText(Dictionary.get("CreatePane.Log_Tooltip")); … … 801 969 model.insertNodeInto(importing, options, 0); 802 970 model.insertNodeInto(building, options, 1); 803 model.insertNodeInto(log, options, 2); 971 model.insertNodeInto(scheduling, options, 2); 972 model.insertNodeInto(log, options, 3); 804 973 // Expand the root node 805 974 expandPath(new TreePath(options)); … … 831 1000 scroll_pane = null; 832 1001 } 1002 if(node != null && node.equals(log)) { 1003 build_button.setActionCommand(Dictionary.get("CreatePane.Build_Collection")); 1004 build_button.setText(Dictionary.get("CreatePane.Build_Collection")); 1005 } 833 1006 if(node != null && node.equals(building)) { 1007 build_button.setActionCommand(Dictionary.get("CreatePane.Build_Collection")); 1008 build_button.setText(Dictionary.get("CreatePane.Build_Collection")); 1009 1010 834 1011 previous_pane = options_pane.buildBuild(null); 835 1012 scroll_pane = new JScrollPane(previous_pane); … … 838 1015 } 839 1016 else if(node != null && node.equals(importing)) { 1017 build_button.setActionCommand(Dictionary.get("CreatePane.Build_Collection")); 1018 build_button.setText(Dictionary.get("CreatePane.Build_Collection")); 1019 840 1020 previous_pane = options_pane.buildImport(null); 841 1021 scroll_pane = new JScrollPane(previous_pane); 842 1022 right.add(scroll_pane, BorderLayout.CENTER); 843 1023 //target_pane.add(previous_pane, BorderLayout.CENTER); 1024 } 1025 else if(node != null && node.equals(scheduling) && CollectionManager.canDoScheduling()) { 1026 build_button.setActionCommand(Dictionary.get("CreatePane.Schedule_Build")); 1027 build_button.setText(Dictionary.get("CreatePane.Schedule_Build")); 1028 1029 previous_pane = options_pane.buildSchedule(null); 1030 scroll_pane = new JScrollPane(previous_pane); 1031 right.add(scroll_pane, BorderLayout.CENTER); 844 1032 } 845 1033 else { -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/DeleteCollectionPrompt.java
r18297 r18364 269 269 confirmation.setSelected(false); 270 270 if(!list.isSelectionEmpty()) { 271 confirmation.setEnabled(true);272 271 collection = (BasicCollectionConfiguration) list.getSelectedValue(); 273 args = new String[3]; 274 args[0] = collection.getCreator(); 275 args[1] = collection.getMaintainer(); 276 args[2] = collection.getDescription(); 277 details.setText(Dictionary.get("DeleteCollectionPrompt.Details", args)); 278 details.setCaretPosition(0); 272 273 String currentColName = (Gatherer.c_man.getCollection() == null) ? "" : Gatherer.c_man.getCollection().getName(); 274 if(!collection.getShortName().equals(currentColName)) { 275 // the selected collection can only be deleted if it is NOT the collection that is currently open 276 confirmation.setEnabled(true); 277 confirmation.setToolTipText(null); // no tooltip 278 ok_button.setToolTipText(null); 279 280 args = new String[3]; 281 args[0] = collection.getCreator(); 282 args[1] = collection.getMaintainer(); 283 args[2] = collection.getDescription(); 284 details.setText(Dictionary.get("DeleteCollectionPrompt.Details", args)); 285 details.setCaretPosition(0); 286 } else { // trying to delete the collection that is open at present 287 // add a tooltip saying to the confirmation checkbox saying that the current collection can't be deleted 288 String tooltip = Dictionary.get("DeleteCollectionPrompt.Cannot_Delete_Open_Collection_Tooltip", 289 collection.getName()); 290 confirmation.setToolTipText(tooltip); 291 ok_button.setToolTipText(tooltip); 292 // delete/ok button and confirmation checkbox should be disabled 293 ok_button.setEnabled(false); 294 confirmation.setEnabled(false); 295 confirmation.setSelected(false); 296 } 279 297 } 280 298 else { -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/DesignPane.java
r18297 r18364 40 40 import org.greenstone.gatherer.cdm.CollectionDesignManager; 41 41 import org.greenstone.gatherer.cdm.Control; 42 43 import org.greenstone.gatherer.Configuration; 44 42 45 public class DesignPane 43 46 extends BaseConfigPane { … … 46 49 public DesignPane() { 47 50 super(); 48 contents = new String [] { "CDM.GUI.Plugins", "CDM.GUI.Indexes", "CDM.GUI.Subcollections", "CDM.GUI.Classifiers" }; 51 if (Configuration.fedora_info.isActive()) { 52 contents = new String [] { "CDM.GUI.Plugins" }; 53 } 54 else { 55 contents = new String [] { "CDM.GUI.Plugins", "CDM.GUI.Indexes", "CDM.GUI.Subcollections", "CDM.GUI.Classifiers" }; 56 } 49 57 50 58 } -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/DownloadPane.java
r18297 r18364 185 185 edit_pane.add(mode_pane,BorderLayout.CENTER); 186 186 edit_pane.add(button_pane,BorderLayout.PAGE_END); 187 187 188 188 // Add to "this" 189 189 setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); … … 242 242 String launch = launch_str.toString(); 243 243 System.err.println("*** launch = " + launch); 244 244 245 245 URL launch_url = new URL(launch); 246 246 URLConnection launch_connection = launch_url.openConnection(); … … 514 514 implements ActionListener { 515 515 public void actionPerformed(ActionEvent event) { 516 516 517 517 if(checkURL(true) && checkProxy() == true) { 518 518 519 // Proxy settings are now set. Check that the url is not a redirect, else get 520 // redirect url (we do this step in order to avoid some unintuitive behaviour from wget) 521 Download current_download = (Download)download_map.get(mode); 522 Argument arg_url = current_download.getArgument("url"); 523 if(arg_url != null) { // it's null for z3950 and possibly for other downloaders 524 String url_str = arg_url.getValue(); 525 String redirect_url_str = getRedirectURL(url_str); 526 527 // only update the Argument and its GUI ArgumentControl if the URL 528 // has in fact changed 529 if(!url_str.equals(redirect_url_str)) { 530 arg_url.setValue(redirect_url_str); 531 updateArgument(arg_url, redirect_url_str); 532 } 533 } 519 534 getter.newDownloadJob((Download)download_map.get(mode) ,mode,proxy_url); 520 535 } 521 536 } 522 537 } 538 539 /** 540 * The Java code here will retrieve the page at the given url. If the response code is 541 * a redirect, it will get the redirect url so that wget may be called with the proper url. 542 * This preprocessing of the URL is necessary because: 543 * Wget does not behave the way the browser does when faced with urls of the form 544 * http://www.englishhistory.net/tudor/citizens and if that page does not exist. 545 * The directory listing with a slash at the end (http://www.englishhistory.net/tudor/citizens/) 546 * does exist, however. In order to prevent wget from assuming that the root URL 547 * to traverse is http://www.englishhistory.net/tudor/ instead of the intended 548 * http://www.englishhistory.net/tudor/citizens/, we need give wget the redirect location 549 * that's returned when we initially make a request for http://www.englishhistory.net/tudor/citizens 550 * The proper url is sent back in the Location header, allowing us to bypass wget's 551 * unexpected behaviour. 552 * This method ensures that urls like http://www.nzdl.org/niupepa also continue to work: 553 * there is no http://www.nzdl.org/niupepa/ page, because this url actually redirects to an 554 * entirely different URL. 555 * @return the redirect url for the given url if any redirection is involved, or the 556 * url_str. 557 */ 558 private String getRedirectURL(String url_str) { 559 HttpURLConnection connection = null; 560 if(url_str.startsWith("http:")) { // only test http urls 561 try { 562 URL url = new URL(url_str); 563 connection = (HttpURLConnection)url.openConnection(); //new HttpURLConnection(url); 564 // don't let it automatically follow redirects, since we want to 565 // find out whether we are dealing with redirects in the first place 566 connection.setInstanceFollowRedirects(false); 567 568 // now check for whether we get a redirect response 569 // HTTP Codes 3xx are redirects, http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 570 int responseCode = connection.getResponseCode(); 571 if(responseCode >= 300 && responseCode < 400) { 572 String responseMsg = connection.getResponseMessage(); 573 574 // Get the Location header since this specifies the new location of the resource 575 String location = connection.getHeaderField("Location"); 576 577 // this becomes the url that wget should download from 578 url_str = location.trim(); 579 } 580 581 connection.disconnect(); 582 } catch(Exception e) { 583 if(connection != null) { 584 connection.disconnect(); 585 } 586 System.err.println("Checking redirection. Tried to connect to " 587 + url_str + ",\nbut got exception: " + e); 588 } 589 } 590 591 return url_str; 592 } 593 523 594 595 /** For a string-based Argument whose value has changed, this method 596 * updates the GUI ArgumentControl's value correspondingly. */ 597 private void updateArgument(Argument arg, String value) { 598 for(int i = 0; i < options_pane.getComponentCount(); i++) { 599 Component component = options_pane.getComponent(i); 600 if(component instanceof ArgumentControl) { 601 ArgumentControl control = (ArgumentControl)component; 602 if(control.getArgument() == arg) { 603 control.setValue(value); 604 control.repaint(); 605 } 606 } 607 } 608 } 524 609 525 610 private boolean checkURL(boolean checkRequired){ … … 568 653 569 654 int count = 0; 655 // Only for wget, need to avoid a second automatic authentication popup (first asks 656 // the proxy authentication for wget, and the second will ask the same for the realm) 657 // Once the authentication has been reused, it will set the GAuthenticator state back to REGULAR 658 GAuthenticator.setMode(GAuthenticator.DOWNLOAD); 570 659 while(count < 3 && (user_pass = (String) GAuthenticator.authentications.get(address)) == null) { 571 660 Authenticator.requestPasswordAuthentication(proxy_host, null, Integer.parseInt(proxy_port), "http://", Dictionary.get("WGet.Prompt"), "HTTP"); 572 661 count++; 573 662 } 574 575 663 if(count >= 3) { 576 664 return false; … … 579 667 if(user_pass.indexOf("@") != -1) { 580 668 581 // Write the use proxy command - we don't do this anymore, instead we set environment variables - hopefully these can't be spied on like the foll woing can (using ps) - actually the environment stuff didn't work for windows, so lets go back to this669 // Write the use proxy command - we don't do this anymore, instead we set environment variables - hopefully these can't be spied on like the following can (using ps) - actually the environment stuff didn't work for windows, so lets go back to this 582 670 if (Utility.isWindows()) { 583 671 … … 607 695 608 696 } 609 697 610 698 return true; 611 699 } … … 615 703 616 704 } 617 705 618 706 return true; 619 707 } -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/EnrichPane.java
r18297 r18364 273 273 274 274 275 /** Called whenever the collection tree selection changes. This causes the metadata value table to be rebuilt. */ 276 public void valueChanged(TreeSelectionEvent event) 275 /** Allows other classes to request the enrich pane to prepare for metadata 276 * saving. 277 * @author John Thompson, DL Consulting Ltd 278 */ 279 public void stopEditingAndRebuild() 280 { 281 // Update the metadata value table (and consequently, the metadata value tree) 282 metadata_value_table_pane.stopEditingAndRebuild(file_nodes); 283 } 284 /** stopEditingAndRebuild() **/ 285 286 /** Called whenever the collection tree selection changes. This causes the metadata value table to be rebuilt. */ 287 public void valueChanged(TreeSelectionEvent event) 277 288 { 278 289 // If we haven't got focus then it must have been a selection in the Gather pane, so don't bother rebuilding -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/ExplodeMetadataDatabasePrompt.java
r18297 r18364 279 279 String collection_name = CollectionManager.getLoadedCollectionName(); 280 280 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(collection_name); 281 String metadata_file_relative_path = RemoteGreenstoneServer.getPathRelativeToDirectory(metadata_file, collection_directory_path); 281 String metadata_file_relative_path = Gatherer.remoteGreenstoneServer.getPathRelativeToDirectory( 282 metadata_file, collection_directory_path); 282 283 command_parts_list.add("-file"); 283 284 command_parts_list.add(metadata_file_relative_path); … … 350 351 if (Gatherer.isGsdlRemote) { 351 352 Utility.delete(metadata_file.getParentFile()); 352 RemoteGreenstoneServer.downloadCollectionFile(CollectionManager.getLoadedCollectionName(), metadata_file.getParentFile()); 353 Gatherer.remoteGreenstoneServer.downloadCollectionFile( 354 CollectionManager.getLoadedCollectionName(), metadata_file.getParentFile()); 353 355 } 354 356 -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/ExportAsPrompt.java
r18297 r18364 83 83 84 84 private ArrayList all_collections = null; 85 private ArrayList selected_collections= null;86 /** The list of collections to include in exported cd-rom/dvd image*/87 private CheckList list = null;85 private BasicCollectionConfiguration selected_collection = null; 86 /** The list of collections to export */ 87 private JList list = null; 88 88 /** The currently selected collection for deletion. */ 89 89 private BasicCollectionConfiguration collection = null; … … 159 159 plugoutMap.put("DSpace","dublin-core.xml"); 160 160 plugoutMap.put("MARCXML","doc.xml"); 161 plugoutMap.put("METS","doctxt.xml,docmets.xml"); 162 plugoutMap.put("GA","doc.xml"); 163 161 plugoutMap.put("GreenstoneMETS","doctxt.xml,docmets.xml"); 162 plugoutMap.put("FedoraMETS","doctxt.xml,docmets.xml"); 163 164 // this is the order we want them to appear in the list 165 String [] saveas_formats = {"GreenstoneMETS", "FedoraMETS", "MARCXML", "DSpace"}; 164 166 cancel_button = new GLIButton(Dictionary.get("General.Close"), Dictionary.get("General.Close_Tooltip")); 165 167 … … 179 181 instructions_textarea.setComponentOrientation(Dictionary.getOrientation()); 180 182 181 // Save As182 ArrayList saveas_formats = new ArrayList(plugoutMap.keySet());183 183 184 184 saveas_label = new JLabel(Dictionary.get("ExportAsPrompt.SaveAs") … … 187 187 //saveas_label.setPreferredSize(LABEL_SIZE); 188 188 189 saveas_combobox = new JComboBox(saveas_formats.toArray());189 saveas_combobox = new JComboBox(saveas_formats); 190 190 saveas_combobox.setOpaque(false); 191 191 saveas_combobox.setToolTipText(Dictionary.get("ExportAsPrompt.SaveAs_Tooltip")); … … 224 224 convert_xml_field1 = new JTextField(); 225 225 convert_xml_field1.setComponentOrientation(Dictionary.getOrientation()); 226 convert_xml_field1.setEnabled(false); 227 226 228 convert_xml_field2 = new JTextField(); 227 229 convert_xml_field2.setComponentOrientation(Dictionary.getOrientation()); 230 convert_xml_field2.setEnabled(false); 231 228 232 mapping_xml_field = new JTextField(); 229 233 mapping_xml_field.setComponentOrientation(Dictionary.getOrientation()); 234 mapping_xml_field.setEnabled(false); 230 235 231 236 convert_xml_pane1 = new JPanel(new BorderLayout()); … … 242 247 243 248 all_collections = new ArrayList(); 244 list = new CheckList(true); 249 //list = new CheckList(true); 250 list = new JList(getCollectionListModel()); 245 251 list_label = new JLabel(Dictionary.get("DeleteCollectionPrompt.Collection_List")); 246 252 list_label.setComponentOrientation(Dictionary.getOrientation()); … … 257 263 folder_button.addActionListener(new FolderButtonListener()); 258 264 259 260 scanForCollections(); 261 list.setListData(all_collections); 262 265 263 266 prompt = this; 264 267 setSize(SIZE); … … 299 302 ok_button = null; 300 303 prompt = null; 301 if (selected_collections!=null) { 302 selected_collections.clear(); 303 selected_collections = null; 304 } 304 selected_collection = null; 305 305 title_field = null; 306 306 title_label = null; … … 348 348 349 349 String saveas = (String)saveas_combobox.getSelectedItem(); 350 if (saveas.equals("MARCXML")){ 351 convert_xml_pane.add(mapping_xml_pane); 352 convert_xml_pane.add(output_single_checkbox); 353 } 354 else{ 355 if (saveas.equals("METS")){ 356 convert_xml_pane.add(convert_xml_pane2); 357 } 358 } 359 convert_xml_pane.revalidate(); 360 convert_xml_pane.repaint(); 350 // force the updating of which fields we are displaying 351 saveas_combobox.setSelectedIndex(0); 361 352 362 353 // Save as pane … … 441 432 DebugStream.println("ExportAsPrompt.exportAsCollections()"); 442 433 443 i nt num_collections = selected_collections.size();444 if (num_collections == 0) return; 434 if (selected_collection == null) return; 435 445 436 cd_title = title_field.getText(); 446 437 … … 479 470 command_parts_list.add(export_dir); 480 471 481 if (!export_type.e quals("METS") && xsl_file1 !=null){472 if (!export_type.endsWith("METS") && xsl_file1 !=null){ 482 473 command_parts_list.add("-xsltfile"); 483 474 command_parts_list.add(xsl_file1.getPath()); … … 508 499 509 500 510 if (export_type.e quals("METS") && xsl_file1 !=null){501 if (export_type.endsWith("METS") && xsl_file1 !=null){ 511 502 command_parts_list.add("-xslt_txt"); 512 503 command_parts_list.add(xsl_file1.getPath()); 513 504 } 514 505 515 if (export_type.e quals("METS") && xsl_file2 !=null){506 if (export_type.endsWith("METS") && xsl_file2 !=null){ 516 507 command_parts_list.add("-xslt_mets"); 517 508 command_parts_list.add(xsl_file2.getPath()); 518 509 } 519 510 520 for (int i = 0; i < num_collections; i++) { 521 command_parts_list.add(((BasicCollectionConfiguration) selected_collections.get(i)).getShortName()); 522 } 511 command_parts_list.add( selected_collection.getShortName()); 512 523 513 524 514 DebugStream.print("export command = "); … … 553 543 public void resultPrompt(boolean success, String extra) { 554 544 args = new String[2]; 555 StringBuffer coll_names = new StringBuffer(); 556 for (int i=0; i<selected_collections.size();i++) { 557 if (i>0) { 558 coll_names.append(", "); 559 } 560 BasicCollectionConfiguration complete_collection = (BasicCollectionConfiguration)selected_collections.get(i); 561 coll_names.append(complete_collection.getName() + StaticStrings.SPACE_CHARACTER + StaticStrings.OPEN_PARENTHESIS_CHARACTER + complete_collection.getShortName() + StaticStrings.CLOSE_PARENTHESIS_CHARACTER); 562 complete_collection = null; 563 } 564 565 args[0] = coll_names.toString(); 545 546 // coll name 547 args[0] = selected_collection.getName() + StaticStrings.SPACE_CHARACTER + StaticStrings.OPEN_PARENTHESIS_CHARACTER + selected_collection.getShortName() + StaticStrings.CLOSE_PARENTHESIS_CHARACTER; 566 548 567 549 String export_type = (String) saveas_combobox.getSelectedItem(); … … 588 570 589 571 if (success) { 590 String successMessage 591 = (selected_collections.size()==1) 592 ? "ExportAsPrompt.Successful_ExportOne" 593 : "ExportAsPrompt.Successful_ExportMany"; 594 595 title = Dictionary.get("ExportAsPrompt.Successful_Title"); 596 label = Dictionary.get(successMessage, args); 597 details = Dictionary.get("ExportAsPrompt.Successful_Details", args); 572 String successMessage = "ExportAsPrompt.Successful_ExportOne"; 573 title = Dictionary.get("ExportAsPrompt.Successful_Title"); 574 label = Dictionary.get(successMessage, args); 575 details = Dictionary.get("ExportAsPrompt.Successful_Details", args); 598 576 } else { 599 String failedMessage 600 = (selected_collections.size()==1) 601 ? "ExportAsPrompt.Failed_ExportOne" 602 : "ExportAsPrompt.Failed_ExportMany"; 603 604 title = Dictionary.get("ExportAsPrompt.Failed_Title"); 605 label = Dictionary.get(failedMessage, args); 606 details = Dictionary.get("ExportAsPrompt.Failed_Details", args); 607 } 608 SimpleResultDialog result_dialog = new SimpleResultDialog(title, label, details); 577 String failedMessage = "ExportAsPrompt.Failed_ExportOne"; 578 title = Dictionary.get("ExportAsPrompt.Failed_Title"); 579 label = Dictionary.get(failedMessage, args); 580 details = Dictionary.get("ExportAsPrompt.Failed_Details", args); 581 } 582 SimpleResultDialog result_dialog = new SimpleResultDialog(this, title, label, details); 609 583 result_dialog.setVisible(true); // Blocks 610 584 result_dialog.dispose(); … … 618 592 * @see org.greenstone.gatherer.util.Utility 619 593 */ 620 private void scanForCollections() { 594 private ListModel getCollectionListModel() { 595 DefaultListModel model = new DefaultListModel(); 621 596 // Start at the collect dir. 622 597 File collect_directory = new File(Gatherer.getCollectDirectoryPath()); … … 632 607 if (config_file.exists()) { 633 608 BasicCollectionConfiguration config = new BasicCollectionConfiguration(config_file); 634 all_collections.add(config);609 model.addElement(config); 635 610 config = null; 636 611 } … … 638 613 } 639 614 } 615 return model; 640 616 // Otherwise the collect directory doesn't actually exist, so there ain't much we can do. 641 617 } 642 618 643 619 … … 697 673 { 698 674 // Can only export when something is ticked 699 ok_button.setEnabled(!list.isNothingTicked());675 //ok_button.setEnabled(!list.isNothingTicked()); 700 676 701 677 if (list.isSelectionEmpty()) { 702 // This only happens when the dialog is first entered703 678 details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.No_Collection")); 704 return; 705 } 706 707 collection = (BasicCollectionConfiguration) ((CheckListEntry) list.getSelectedValue()).getObject(); 708 args = new String[3]; 709 args[0] = collection.getCreator(); 710 args[1] = collection.getMaintainer(); 711 args[2] = collection.getDescription(); 712 details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.Details", args)); 713 details_textarea.setCaretPosition(0); 714 } 715 } 716 717 679 ok_button.setEnabled(false); 680 } 681 else { 682 BasicCollectionConfiguration collection = (BasicCollectionConfiguration) list.getSelectedValue(); 683 args = new String[3]; 684 args[0] = collection.getCreator(); 685 args[1] = collection.getMaintainer(); 686 args[2] = collection.getDescription(); 687 details_textarea.setText(Dictionary.get("DeleteCollectionPrompt.Details", args)); 688 details_textarea.setCaretPosition(0); 689 ok_button.setEnabled(true); 690 } 691 } 692 693 } 718 694 /** The OK button listener implementation. */ 719 695 private class OKButtonListener … … 732 708 ///ystem.err.println("OK Clicked"); 733 709 // Make sure there are some colls specified 734 selected_collection s = list.getTicked();710 selected_collection = (BasicCollectionConfiguration)list.getSelectedValue(); 735 711 error_message = new StringBuffer(); 736 712 … … 837 813 838 814 convert_xml_button1.setEnabled(convert_xml_checkbox1.isSelected()); 815 convert_xml_field1.setEnabled(convert_xml_checkbox1.isSelected()); 839 816 convert_xml_button2.setEnabled(convert_xml_checkbox2.isSelected()); 817 convert_xml_field2.setEnabled(convert_xml_checkbox2.isSelected()); 840 818 convert_xml_button3.setEnabled(mapping_xml_checkbox.isSelected()); 819 mapping_xml_field.setEnabled(mapping_xml_checkbox.isSelected()); 841 820 842 821 } … … 871 850 } 872 851 873 if (!saveas.e quals("METS")){852 if (!saveas.endsWith("METS")){ 874 853 875 854 convert_xml_checkbox1.setText(Dictionary.get("ExportAsPrompt.ApplyXSL",(String)plugoutMap.get(saveas))); -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/Filter.java
r18297 r18364 74 74 static final private Dimension SIZE = new Dimension(100,30); 75 75 /** Preprogrammed default filters. */ 76 static final private String DEFAULTS[] = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.*\\.gif$)|(^.*\\.bmp$)|(^.*\\.tiff?$)"}; 76 static final private String DEFAULTS[] 77 = {"^.*\\.html?$", "^.*\\.xml$", "^.*\\.txt$", 78 "(^.*\\.jpe?g$)|(^.*\\.png$)|(^.*\\.gif$)|(^.*\\.bmp$)|(^.*\\.tiff?$)", 79 "^.*\\.pdf$", 80 "(^.*\\.docx?$)|(^.*\\.pptx?$)|(^.*\\.xlsx?$)|(^.*\\.od(t|s|p)$)"}; 77 81 78 82 /** Constructor. … … 241 245 else if(temp_str.equals(Dictionary.get("Filter.3"))) { 242 246 } 247 // PDF 248 else if(temp_str.equals(Dictionary.get("Filter.4"))) { 249 } 250 // Office Docs 251 else if(temp_str.equals(Dictionary.get("Filter.5"))) { 252 } 243 253 else { 244 254 // Make sure the filter isn't already in the list -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/FormatPane.java
r18297 r18364 70 70 contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation" }; 71 71 } else { 72 contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation", "CDM.GUI.SuperCollection","CDM.GUI.Macros" };72 contents = new String []{ "CDM.GUI.General", "CDM.GUI.SearchMetadata", "CDM.GUI.Formats", "CDM.GUI.Translation", "CDM.GUI.SuperCollection","CDM.GUI.Macros", "CDM.GUI.DepositorMetadata" }; 73 73 } 74 74 JPanel side_panel = new JPanel (); … … 173 173 return CollectionDesignManager.supercollection_manager.getControls (); 174 174 } 175 if(type.equals ("CDM.GUI.DepositorMetadata")) { 176 return CollectionDesignManager.depositormetadata_manager.getControls (); 177 } 175 178 return null; 176 179 } -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/GUIManager.java
r18297 r18364 60 60 import org.greenstone.gatherer.gui.tree.DragTree; 61 61 import org.greenstone.gatherer.metadata.MetadataSet; 62 import org.greenstone.gatherer.metadata.MetadataXMLFileManager; 62 63 import org.greenstone.gatherer.remote.RemoteGreenstoneServer; 63 64 import org.greenstone.gatherer.util.JarTools; … … 204 205 } 205 206 else if (esrc == menu_bar.file_save) { 206 Gatherer.c_man.saveCollection(); 207 // Very important: make sure metadata values are saved too 208 enrich_pane.stopEditingAndRebuild(); 209 // Make sure all the metadata has been saved to file 210 MetadataXMLFileManager.saveMetadataXMLFiles(); 211 212 Gatherer.c_man.saveCollection(); 207 213 } 208 214 … … 346 352 347 353 // Pretty corner icon 348 this.setIconImage(JarTools.getImage("gatherer_small.gif").getImage()); 354 String gsmall_image = "gatherer_small.gif"; 355 if (Configuration.fedora_info.isActive()) { 356 gsmall_image = "fli-" + gsmall_image; 357 } 358 this.setIconImage(JarTools.getImage(gsmall_image).getImage()); 349 359 // BorderLayout for the main screen. I'll try my best to avoid these in subcomponents as they're space greedy. 350 360 content_pane.setLayout(new BorderLayout()); … … 392 402 if (Configuration.get("workflow.design", true)) { 393 403 // "GUI.Design_Tooltip" is used automatically 394 tab_pane.addTab(Dictionary.get("GUI.Design"), JarTools.getImage("design.gif"), design_pane, Dictionary.get("GUI.Design_Tooltip")); 404 if (Configuration.fedora_info.isActive()) { 405 tab_pane.addTab("Plugins", JarTools.getImage("design.gif"), design_pane, Dictionary.get("GUI.Design_Tooltip")); 406 } 407 else { 408 tab_pane.addTab(Dictionary.get("GUI.Design"), JarTools.getImage("design.gif"), design_pane, Dictionary.get("GUI.Design_Tooltip")); 409 } 410 395 411 tab_pane.setEnabledAt(tab_pane.indexOfComponent(design_pane), false); 396 412 } … … 441 457 remote_greenstone_server_progress_panel.setLayout(new BorderLayout()); 442 458 remote_greenstone_server_progress_panel.add(remote_greenstone_server_progress_label, BorderLayout.LINE_START); 443 remote_greenstone_server_progress_panel.add( RemoteGreenstoneServer.getProgressBar(), BorderLayout.CENTER);459 remote_greenstone_server_progress_panel.add(Gatherer.remoteGreenstoneServer.getProgressBar(), BorderLayout.CENTER); 444 460 content_pane.add(remote_greenstone_server_progress_panel, BorderLayout.SOUTH); 445 461 } … … 467 483 // If we have a collection open remember it for next time, then save it and close it 468 484 if (Gatherer.c_man.ready()) { 469 Configuration.setString("general.open_collection", true, CollectionManager.getLoadedCollectionColFilePath()); 485 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), 486 true, CollectionManager.getLoadedCollectionColFilePath()); 470 487 saveThenCloseCurrentCollection(); 471 488 } 472 489 else { 473 Configuration.setString("general.open_collection" , true, null);490 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, null); 474 491 } 475 492 … … 650 667 public void setTitle(String title, String name) { 651 668 // Finally display the collection name in the title bar. 652 StringBuffer title_buffer = new StringBuffer( Gatherer.PROGRAM_NAME);669 StringBuffer title_buffer = new StringBuffer(Configuration.getApplicationTitle()); 653 670 title_buffer.append(StaticStrings.SPACE_CHARACTER); 654 671 title_buffer.append(Gatherer.PROGRAM_VERSION); 655 672 title_buffer.append(StaticStrings.SPACE_CHARACTER); 656 673 title_buffer.append(StaticStrings.SPACE_CHARACTER); 674 // Server version information 675 title_buffer.append(Gatherer.getServerVersionAsString()); 676 title_buffer.append(StaticStrings.SPACE_CHARACTER); 677 title_buffer.append(StaticStrings.SPACE_CHARACTER); 657 678 // Describe the current user mode 658 679 title_buffer.append(StaticStrings.MODE_STR); -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/HelpFrame.java
r18297 r18364 120 120 setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); 121 121 122 122 123 // Pretty corner icon 123 this.setIconImage(JarTools.getImage("gatherer_small.gif").getImage()); 124 String gsmall_image = "gatherer_small.gif"; 125 if (Configuration.fedora_info.isActive()) { 126 gsmall_image = "fli-" + gsmall_image; 127 } 128 129 this.setIconImage(JarTools.getImage(gsmall_image).getImage()); 124 130 125 131 self = this; … … 238 244 try { 239 245 String help_index_file_path = getHelpFolder() + "help_index.xml"; 240 Document document = XMLTools.parseXMLFile(help_index_file_path, true); 241 246 Document document = null; 247 if (Gatherer.isApplet && JarTools.getResource(help_index_file_path) != null) { 248 document = XMLTools.parseXMLFile(help_index_file_path, true); 249 } 250 251 if (new File(help_index_file_path).exists()) { 252 document = XMLTools.parseXMLFile(help_index_file_path, false); 253 } 254 255 if (document == null) { 256 String errormsg = "HelpFrame.HelpContentsTreeModel constructor(): There's no help document after parsing"; 257 System.err.println(errormsg); 258 DebugStream.println(errormsg); 259 return; 260 } 242 261 // Traverse the help hierarchy, building a tree representing its structure 243 262 Node document_node = document.getFirstChild(); -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java
r18297 r18364 248 248 content_pane.add(bottom_pane, BorderLayout.SOUTH); 249 249 // Final dialog setup & positioning. 250 getRootPane().setDefaultButton(create_button); 250 251 Dimension screen_size = Configuration.screen_size; 251 252 setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2); … … 288 289 // Remote collections that aren't shared have the user's username prefixed to the collection name 289 290 if (Gatherer.isGsdlRemote && personal_collection_button.isSelected()) { 290 name_buffer = new StringBuffer( RemoteGreenstoneServer.getUsername() + "-" + name_buffer.toString());291 name_buffer = new StringBuffer(Gatherer.remoteGreenstoneServer.getUsername() + "-" + name_buffer.toString()); 291 292 } 292 293 -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/OpenCollectionDialog.java
r18297 r18364 269 269 return; 270 270 } 271 272 load_collection_configs(data,collect_directory); 273 274 } 275 276 277 protected void load_collection_configs(TreeSet data, File collect_directory) { 278 271 279 File[] collection_folders = collect_directory.listFiles(); 280 272 281 for(int i = 0; i < collection_folders.length; i++) { 273 282 File collection_folder = collection_folders[i]; 274 283 String collection_foldername = collection_folder.getName(); 284 275 285 if(collection_folder.isDirectory() && !collection_foldername.equals(StaticStrings.MODEL_COLLECTION_NAME)) { 276 // this 'file_name' has already been prefixed by 'etc' 277 String file_name = (Gatherer.GS3)? Utility.CONFIG_GS3_FILE : Utility.CONFIG_FILE; 286 // this 'file_name' has already been prefixed by 'etc' 287 String file_name; 288 if (Gatherer.GS3){ 289 convertToGS3Collection(collection_folder); 290 file_name = Utility.CONFIG_GS3_FILE; 291 }else{ 292 file_name = Utility.CONFIG_FILE; 293 } 294 278 295 File config_file = new File(collection_folder, file_name); 279 296 File collection_metadata_directory = new File(collection_folder, "metadata"); 280 297 if (collection_metadata_directory.exists() && config_file.exists()) { 281 298 BasicCollectionConfiguration collection_configuration = new BasicCollectionConfiguration(config_file); 282 data.add(collection_configuration); 299 300 // look to see if group set? 301 // => if it is, don't add, but recurse to look for child collections in collect-group 302 303 if (collection_configuration.getCollectGroup().equals("true")) { 304 load_collection_configs(data, collection_folder); 305 } 306 else { 307 data.add(collection_configuration); 308 } 283 309 } 284 310 config_file = null; … … 290 316 collect_directory = null; 291 317 } 318 319 292 320 293 321 public Object getElementAt(int index) { -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/OptionsPane.java
r18297 r18364 69 69 static final public char CANCELLED = 'c'; 70 70 static final public char UNKNOWN = 'x'; 71 static final public char SCHEDULED = 'd'; 71 72 72 73 static private int BUILD = 0; 73 74 static private int IMPORT = 1; 74 static private int MINIMUM_ROWS = 11; 75 static private int SCHEDULE = 2; 76 static private int MINIMUM_ROWS = 15; 75 77 76 78 /** All process messages are written to this log text area. */ … … 82 84 private ScriptOptions build_options = null; 83 85 private ScriptOptions import_options = null; 86 private ScriptOptions schedule_options = null; 84 87 85 88 private FileEntry file_entry = null; … … 93 96 94 97 /** The default constructor creates the few session length options, but either retrieves the rest from the current collection, or creates a default set of options. */ 95 public OptionsPane(ScriptOptions import_options, ScriptOptions build_options ) {98 public OptionsPane(ScriptOptions import_options, ScriptOptions build_options, ScriptOptions schedule_options) { 96 99 this.build_options = build_options; 97 100 this.import_options = import_options; 101 this.schedule_options = schedule_options; 98 102 this.current_controls = new ArrayList(); 99 103 this.writing_documents = new Vector(); … … 175 179 build_arguments = null; 176 180 return pane; 181 } 182 183 /**Wendy's attempt at writing a buildSchedule Jpanel. */ 184 public JPanel buildSchedule(JPanel pane) { 185 //reset the arguments 186 if(pane == null) { 187 current_controls.clear(); 188 } 189 190 ArrayList schedule_arguments = new ArrayList(); 191 int current_mode = Configuration.getMode(); 192 193 int total_schedule_argument_count = schedule_options.getArgumentCount(); 194 195 for(int i = 0; i < total_schedule_argument_count; i++) { 196 // Retrieve the argument so we know how to format the control. 197 Argument argument = schedule_options.getArgument(i); 198 199 //A hack to make the disable_OAI option visible in the GLI for Greenstone 3 200 if(argument.getName().equals(StaticStrings.DISABLEOAI_STR) && Gatherer.GS3) { 201 argument.setHiddenGLI(false); 202 } 203 if(!argument.isHiddenGLI() && argument.getModeLevel() <= current_mode) { 204 // Now attempt to retrieve any existing value for this argument. 205 boolean enabled = schedule_options.getValueEnabled(argument.getName()); 206 String value = schedule_options.getValue(argument.getName()); 207 MyArgumentControl argument_control = new MyArgumentControl(SCHEDULE, argument, enabled, value); 208 schedule_arguments.add(argument_control); 209 } 210 } 211 current_controls.addAll(schedule_arguments); 212 213 // Now that we know how many arguments there are we can build the pane to view them on. Modes lower than EXPERT can provide a previous pane on which to add the arguments. 214 if(pane == null || current_mode >= Configuration.EXPERT_MODE) { 215 pane = new JPanel(); 216 pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 217 pane.setBackground(Configuration.getColor("coloring.collection_tree_background", false)); 218 int argument_count = schedule_arguments.size(); 219 // If in any of the higher detail modes, and assuming we don't want super phat argument controls, we better ensure there is a minimum number of lines in the grid layout 220 if(current_mode >= Configuration.EXPERT_MODE) { 221 if(argument_count < MINIMUM_ROWS) { 222 argument_count = MINIMUM_ROWS; 223 } 224 pane.setLayout(new GridLayout(argument_count, 1, 5, 5)); 225 } 226 // Otherwise we're just going to throw them on one after another and chuck it in a scroll pane anyway 227 else { 228 // use GridLayout with 0 rows == as many rows as needed. Unfortunately, rows will 229 // grow fat if space too large, but we don't know how many rows we'll need yet. 230 pane.setLayout(new GridLayout(0, 1, 5, 5)); 231 } 232 } 233 234 for(int j = 0; j < schedule_arguments.size(); j++) { 235 pane.add((JComponent)schedule_arguments.get(j)); 236 } 237 pane.addMouseListener(this); 238 schedule_arguments = null; 239 return pane; 240 177 241 } 178 242 … … 422 486 build_options.removeValue(name); 423 487 } 488 else if(type == SCHEDULE) { 489 schedule_options.removeValue(name); 490 } 424 491 else { 425 492 import_options.removeValue(name); … … 430 497 if(type == BUILD) { 431 498 build_options.setValue(name, enable, value); 499 } 500 else if(type == SCHEDULE) { 501 schedule_options.setValue(name, enable, value); 432 502 } 433 503 else { … … 523 593 case CANCELLED: 524 594 d.append(Dictionary.get("OptionsPane.Cancelled")); 595 break; 596 case SCHEDULED: 597 d.append(Dictionary.get("OptionsPane.Scheduled")); 525 598 break; 526 599 default: -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/Preferences.java
r18297 r18364 731 731 public void actionPerformed(ActionEvent event) 732 732 { 733 // Several options requiring restarting the GLI to apply: 734 // interface font, interface language, changed gliserver url or library url 735 boolean restart_required = false; 736 String restart_message = ""; 737 738 733 739 // Connection preferences 734 740 String program_str = program_field.getText(); … … 738 744 Configuration.setPreviewCommand(program_str); 739 745 746 String old_library_url = (Configuration.library_url == null) ? null : Configuration.library_url.toString(); 740 747 String library_url_string = library_path_field.getText(); 748 if(old_library_url != null && !old_library_url.equals(library_url_string)) { 749 750 // If the server is remote and the library path's been changed, then GLI client needs restart 751 // If the server is local, GLI is going to work with the collection of GSDLPath anyway, 752 // even if the library path for previewing has changed 753 if (Gatherer.isGsdlRemote) { 754 restart_required = true; 755 restart_message = Dictionary.get("Preferences.General.Manual_Restart_Required"); 756 } 757 if(Gatherer.c_man.getCollection() != null) { 758 // if the gliserver url has changed while a collection is open, 759 // close the open collection of the old library URL 760 Gatherer.c_man.saveCollection(); 761 Gatherer.c_man.closeCollection(); 762 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, ""); 763 } 764 } 741 765 if (library_url_string.equals("")) { 742 766 Configuration.library_url = null; … … 750 774 } 751 775 } 752 Configuration.setString("general.library_url", true, library_url_string); 776 777 Configuration.setString("general.library_url"+Configuration.gliPropertyNameSuffix(), 778 true, library_url_string); 753 779 754 780 if (Gatherer.isGsdlRemote && !Gatherer.GS3) { 781 String old_gliserver_url = Configuration.gliserver_url.toString(); 755 782 String gliserver_url_string = gliserver_url_field.getText(); 783 if(!old_gliserver_url.equals(gliserver_url_string)) { 784 restart_required = true; 785 restart_message = Dictionary.get("Preferences.General.Manual_Restart_Required"); 786 787 if(Gatherer.c_man.getCollection() != null) { 788 // if the gliserver url has changed while a collection is open, 789 // close the open collection of the old gliserver URL 790 Gatherer.c_man.saveCollection(); 791 Gatherer.c_man.closeCollection(); 792 Configuration.setString("general.open_collection"+Configuration.gliPropertyNameSuffix(), true, ""); 793 } 794 } 756 795 if (gliserver_url_string.equals("")) { 757 796 Configuration.gliserver_url = null; … … 767 806 Configuration.setString("general.gliserver_url", true, gliserver_url_string); 768 807 } 808 769 809 770 810 boolean site_changed = false; … … 777 817 Configuration.setSiteAndServlet(new_site, (String)servlet_combobox.getSelectedItem()); 778 818 } 779 819 780 820 Configuration.set("general.use_proxy", true, use_proxy_checkbox.isSelected()); 781 821 Configuration.setString("general.proxy_host", true, proxy_host_field.getText()); … … 788 828 Configuration.set("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC, view_extracted_metadata_checkbox.isSelected()); 789 829 790 // Two options requiring restarting the GLI to apply: interface font, and interface language791 boolean restart_required = false;792 830 793 831 // GLI interface font … … 796 834 Configuration.setString("general.font", true, font_field.getText()); 797 835 restart_required = true; 836 restart_message = Dictionary.get("Preferences.General.Restart_Required"); 798 837 } 799 838 … … 803 842 Configuration.setLocale("general.locale", Configuration.GENERAL_SETTING, ((DictionaryEntry) language_combobox.getSelectedItem()).getLocale()); 804 843 restart_required = true; 844 restart_message = Dictionary.get("Preferences.General.Restart_Required"); 805 845 } 806 846 807 847 // Inform the user that a restart is required, if necessary 808 848 if (restart_required) { 809 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("Preferences.General.Restart_Required"), Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE);849 JOptionPane.showMessageDialog(Gatherer.g_man, restart_message, Dictionary.get("General.Warning"), JOptionPane.WARNING_MESSAGE); 810 850 } 811 851 … … 845 885 if (Gatherer.GS3 && site_changed && Gatherer.c_man.getCollection() != null && !Gatherer.isGsdlRemote) { 846 886 // shut down the collection 847 System.err.println("shutting down t ehcollection");887 System.err.println("shutting down the collection"); 848 888 Gatherer.g_man.saveThenCloseCurrentCollection(); 849 889 } … … 867 907 Configuration.save(); 868 908 if (Gatherer.isGsdlRemote && Gatherer.GS3 && site_changed ){ 869 RemoteGreenstoneServer.downloadCollectionConfigurations();909 Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations(); 870 910 } 871 911 // Refresh the GLI to account for the configuration changes … … 997 1037 if (Gatherer.c_man.getCollection()!=null){ 998 1038 File lock_file = new File(Gatherer.c_man.getLoadedCollectionDirectoryPath() + "gli.lck"); 999 RemoteGreenstoneServer.deleteCollectionFile(Gatherer.c_man.getLoadedCollectionName(),lock_file);1039 Gatherer.remoteGreenstoneServer.deleteCollectionFile(Gatherer.c_man.getLoadedCollectionName(),lock_file); 1000 1040 Gatherer.g_man.closeCurrentCollection(); 1001 1041 } 1002 1042 Configuration.site_name=site; 1003 RemoteGreenstoneServer.set_remote_greenstone_server_authentication_to_null();1004 RemoteGreenstoneServer.downloadCollectionConfigurations();1043 Gatherer.remoteGreenstoneServer.set_remote_greenstone_server_authentication_to_null(); 1044 Gatherer.remoteGreenstoneServer.downloadCollectionConfigurations(); 1005 1045 } 1006 1046 } -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/PreviewButton.java
r14046 r18364 75 75 protected void configureHomeURL() { 76 76 // set up the home page for the current collection 77 if (Gatherer.GS3 ) {77 if (Gatherer.GS3 && !Configuration.fedora_info.isActive()) { // GLI for GS3 case 78 78 // don't do anything fancy here 79 79 preview_address = Configuration.library_url.toString() + Configuration.getServletPath() + "?a=p&sa=about&c=" + CollectionManager.getLoadedCollectionName() + "&l=" + Configuration.getLanguage(); 80 80 return; 81 81 } 82 // FLI or GLI for GS2 case (no library_url) 82 83 preview_address = Configuration.library_url.toString() + "?c=" + CollectionManager.getLoadedCollectionName() + "&l=" + Configuration.getLanguage(); 83 84 -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/SimpleResultDialog.java
r18297 r18364 48 48 49 49 public class SimpleResultDialog 50 50 extends ModalDialog { 51 51 52 53 52 private Dimension size = new Dimension(600,300); 53 private SimpleResultDialog self; 54 54 55 56 57 55 public SimpleResultDialog(String title, String label, String results) { 56 super(Gatherer.g_man, title, true); 57 this.self = this; 58 58 this.setComponentOrientation(Dictionary.getOrientation()); 59 59 60 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 61 setSize(size); 60 setUpGUI(label, results); 61 } 62 63 /** If you are calling this from another dialog, and you want that dialog blocked while this is open, need to use this method, passing in the calling dialog as the parent */ 64 public SimpleResultDialog(Dialog parent, String title, String label, String results) { 65 66 super(parent, title, true); 67 this.self = this; 68 69 setUpGUI(label, results); 70 } 71 72 private void setUpGUI(String label, String results) { 73 setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 74 setSize(size); 62 75 63 64 65 66 76 JPanel content_pane = (JPanel) getContentPane(); 77 content_pane.setComponentOrientation(Dictionary.getOrientation()); 78 JLabel result_label = new JLabel(label); 79 result_label.setComponentOrientation(Dictionary.getOrientation()); 67 80 68 69 70 71 81 JPanel button_pane = new JPanel(); 82 button_pane.setComponentOrientation(Dictionary.getOrientation()); 83 JButton close_button = new GLIButton(Dictionary.get("General.Close")); 84 close_button.addActionListener(new CloseButtonListener()); 72 85 73 JPanel output_pane = new JPanel(); 74 output_pane.setComponentOrientation(Dictionary.getOrientation()); 75 JLabel output_label = new JLabel(Dictionary.get("General.Review_Output")); 76 output_label.setComponentOrientation(Dictionary.getOrientation()); 77 JTextArea output_textarea = new JTextArea(results); 78 output_textarea.setComponentOrientation(Dictionary.getOrientation()); 79 output_textarea.setCaretPosition(0); 80 output_textarea.setEditable(false); 81 output_textarea.setLineWrap(true); 82 output_textarea.setWrapStyleWord(true); 86 JPanel output_pane = new JPanel(); 87 output_pane.setComponentOrientation(Dictionary.getOrientation()); 88 JLabel output_label = new JLabel(Dictionary.get("General.Review_Output")); 89 output_label.setComponentOrientation(Dictionary.getOrientation()); 90 91 JTextArea output_textarea = new JTextArea(results); 92 output_textarea.setComponentOrientation(Dictionary.getOrientation()); 93 output_textarea.setCaretPosition(0); 94 output_textarea.setEditable(false); 95 output_textarea.setLineWrap(true); 96 output_textarea.setWrapStyleWord(true); 83 97 84 85 98 button_pane.setLayout(new BorderLayout()); 99 button_pane.add(close_button, BorderLayout.LINE_END); 86 100 87 88 89 90 101 output_pane.setBorder(BorderFactory.createEmptyBorder(5,0,5,0)); 102 output_pane.setLayout(new BorderLayout()); 103 output_pane.add(output_label, BorderLayout.NORTH); 104 output_pane.add(new JScrollPane(output_textarea), BorderLayout.CENTER); 91 105 92 93 94 95 96 106 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 107 content_pane.setLayout(new BorderLayout()); 108 content_pane.add(result_label, BorderLayout.NORTH); 109 content_pane.add(output_pane, BorderLayout.CENTER); 110 content_pane.add(button_pane, BorderLayout.SOUTH); 97 111 98 // Position 99 Rectangle frame_bounds = Gatherer.g_man.getBounds(); 100 setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2); 112 // Position 113 Rectangle frame_bounds = Gatherer.g_man.getBounds(); 114 setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2); 115 //new SimpleResultDialog(Gatherer.g_man, title, label, results); 116 } 117 118 119 private class CloseButtonListener 120 implements ActionListener { 121 public void actionPerformed(ActionEvent event) { 122 self.setVisible(false); 101 123 } 102 103 private class CloseButtonListener 104 implements ActionListener { 105 public void actionPerformed(ActionEvent event) { 106 self.setVisible(false); 107 } 108 } 124 } 109 125 } -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/URLField.java
r18297 r18364 4 4 import java.net.*; 5 5 import javax.swing.*; 6 import org.greenstone.gatherer.Dictionary; 7 8 6 import java.util.*; 7 import java.io.*; 8 import org.greenstone.gatherer.Gatherer; 9 import org.greenstone.gatherer.Configuration; 10 11 /** Modified. 12 * Class used by WarningDialog and Gatherer which represents a textual input control 13 * (TextField or Combobox) into which a URL can be entered. Provides some static methods 14 * shared by these controls and by a general JTextField control which can all be used 15 * in a WarningDialog. Class URLField also contains an inner Interface class and two 16 * static inner classes that implement this interface: Text and DropDown. 17 * Finally, another static inner class URLCollectionPair associates each Gliserver URL 18 * (or Library URL) that can be displayed in the DropDown with the last opened collection 19 * file for the Greenstone server at that URL. 20 */ 9 21 public class URLField 10 extends JTextField11 22 { 12 public URLField(Color foreground, Color background) 13 { 14 super(); 15 this.setComponentOrientation(Dictionary.getOrientation()); 16 setBackground(background); 17 setForeground(foreground); 18 } 19 20 21 public boolean validateURL() 22 { 23 String url_string = getText(); 23 static public String getText(JComponent control) 24 { 25 if(control instanceof JTextField) { // not specifically a URL Field, therefore, we're not meant to do checking 26 return ((JTextField)control).getText(); 27 } 28 else if(control instanceof URLField.DropDown) { 29 return (String)((JComboBox)control).getSelectedItem(); 30 } 31 32 // unknown control, shouldn't happen 33 return ""; 34 } 35 36 static public String setText(JComponent control, String text) 37 { 38 if(control instanceof JTextField) { // not specifically a URL Field, therefore, we're not meant to do checking 39 ((JTextField)control).setText(text); 40 } 41 else if(control instanceof URLField.DropDown) { 42 ((JComboBox)control).setSelectedItem(text); 43 } 44 45 // unknown control, shouldn't happen 46 return ""; 47 } 48 49 static public boolean validateURL(JComponent control) 50 { 51 if(control instanceof URLField.Text) { 52 return ((URLField.Text)control).validateURL(); 53 } 54 else if (control instanceof JTextField) { 55 return true; // not specifically a URL Field, therefore, we're not meant to do checking 56 } 57 else { // control is a DropDown 58 return ((URLField.DropDown)control).validateURL(); 59 } 60 } 61 62 static public boolean validateURL(String url_string) 63 { 24 64 if (!url_string.equals("")) { 25 65 // Check the URL string is valid by trying to create a URL object from it … … 36 76 return true; 37 77 } 78 79 static public void store(JComponent control, String affected_property) { 80 if(control instanceof JTextField) { 81 String value = ((JTextField)control).getText(); 82 Configuration.setString(affected_property, true, value); 83 Configuration.save(); // save it in case of a crash 84 } 85 else { // DropDown 86 ((DropDown)control).saveProperties(); // saves it already 87 } 88 } 89 90 91 /** INTERFACE CLASS IMPLEMENTED BY Static inner classes Text and DropDown */ 92 public static interface URLFieldControl { 93 public boolean validateURL(); 94 } 95 96 97 /** STATIC INNER CLASS URLTextField */ 98 public static class Text 99 extends JTextField implements URLFieldControl 100 { 101 public Text(Color foreground, Color background) 102 { 103 super(); 104 this.setComponentOrientation(Dictionary.getOrientation()); 105 setBackground(background); 106 setForeground(foreground); 107 } 108 109 public boolean validateURL() { 110 String url_string = getText(); 111 return URLField.validateURL(url_string); 112 } 113 } 114 115 116 /** STATIC INNER CLASS DropDown, an editable URLComboBox */ 117 public static class DropDown 118 extends JComboBox implements URLFieldControl 119 { 120 private String checkString = null; // optional string to check the URLs items against to see whether the URLs contain this 121 private String affectedProperty = null; // the Configuration property associated with this DropDown 122 private String coaffectedProperty = null; // the Configuration property whose suffix should change along with the affectedProperty 123 124 private static final int MAX_URLS = 5; 125 126 public DropDown(Color foreground, Color background, String[] defaultURLs, 127 String affectedProperty, String coaffectedProperty) 128 { 129 super(URLCollectionPair.createDefaultsArray(defaultURLs)); 130 this.setEditable(true); 131 this.getEditor().selectAll(); 132 this.setComponentOrientation(Dictionary.getOrientation()); 133 134 setBackground(background); 135 setForeground(foreground); 136 137 this.affectedProperty = affectedProperty; 138 this.coaffectedProperty = coaffectedProperty; 139 // read any URLS specified in the config file 140 setComboBoxValues(); 141 142 } 143 144 public DropDown(Color foreground, Color background, String[] defaultURLs, 145 String affectedProperty, String coaffectedProperty, String checkString) 146 { 147 this(foreground, background, defaultURLs, affectedProperty, coaffectedProperty); 148 this.checkString = checkString; 149 } 150 151 public boolean validateURL() { 152 //String url_string = (String)this.getEditor().getItem(); 153 String url_string = this.getSelectedItem().toString(); // returns url of the combobox item 154 155 if(checkString != null && !url_string.endsWith(checkString)) { 156 return false; 157 } else { 158 return URLField.validateURL(url_string); 159 } 160 } 161 162 public void saveProperties() { 163 // 1. Add the first url just edited (if any) 164 165 // The user might have created a new STRING, or selected an existing URLCollectionPair 166 // We don't know the type! 167 Object o = this.getSelectedItem(); 168 URLCollectionPair editedItem = (o instanceof URLCollectionPair) 169 ? (URLCollectionPair)o : new URLCollectionPair(o.toString()); 170 171 if(editedItem != null) { 172 insertItemAt(editedItem, 0); 173 } else { 174 editedItem = (URLCollectionPair)getItemAt(0); // else reuse the first default: 175 } 176 Configuration.setString(affectedProperty, true, editedItem.getURL()); 177 178 // concurrently set the last opened collection for this url 179 String lastOpenedCollection = editedItem.getCollection(); 180 if(lastOpenedCollection.equals("")) { 181 Configuration.setString(coaffectedProperty, true, null); 182 } else { 183 Configuration.setString(coaffectedProperty, true, lastOpenedCollection); 184 } 185 186 187 // 2. Add the remaining urls into the combobox 188 int url_count = 1; // remain under MAX_URLS AND under the number of actual URLs in the dropdown 189 for(int i = 0; url_count < MAX_URLS && i < getItemCount(); i++, url_count++) { 190 191 URLCollectionPair item = (URLCollectionPair)getItemAt(i); 192 String url = item.getURL(); 193 194 if(item == null || url.equals(editedItem.getURL()) || url.equals("")) { 195 // skip any duplicates of the just-edited URL and skip empty URLs 196 url_count--; 197 } 198 else { 199 Configuration.setString(affectedProperty+url_count, true, url); 200 201 // concurrently save the name of the corresponding open collection 202 if(item.getCollection().equals("")) { 203 Configuration.setString(coaffectedProperty+url_count, true, null); 204 } else { 205 Configuration.setString(coaffectedProperty+url_count, true, item.getCollection()); 206 } 207 208 } // else retain old value for this affectedProperty (general.gliserver_url) 209 } 210 Configuration.save(); 211 } 212 213 214 // Get values from Configuration file, or (if none) use defaultURLs. 215 // Put them into the combobox 216 private void setComboBoxValues() { 217 218 String url = Configuration.getString(affectedProperty, true); 219 String collection = Configuration.getString(coaffectedProperty, true); 220 boolean finished = url.equals(""); 221 if(!finished) { 222 this.removeAllItems(); // remove defaults, since config file now contains init values 223 this.addItem(new URLCollectionPair(url, collection)); 224 } // else urls and combobox already contains the defaults 225 226 227 for(int i = 1; !finished; i++) { 228 url = Configuration.getString(affectedProperty+i, true); 229 collection = Configuration.getString(coaffectedProperty+i, true); 230 if(url.equals("")) { 231 finished = true; 232 } 233 else { // url is not empty 234 this.addItem(new URLCollectionPair(url, collection)); 235 } 236 } 237 238 // setting the size of the dropdown control 239 Dimension newSize=new Dimension(getPreferredSize().width+20, getPreferredSize().height); 240 setPreferredSize(newSize); 241 } 242 } 243 244 245 /** STATIC INNER CLASS URLCollectionPair. 246 * Since the configuration for a (remote) Greenstone2 and Greenstone3 is now 247 * stored in a single file for both, we can have GLI connecting to different servers 248 * while for each server, a different collection may have been left open last time. 249 * This class URLCollectionPair will associate a GLIServer_URL or Library_URL with 250 * the last opened collection file for it. It is used by URLField.DropDown combobox. */ 251 public static class URLCollectionPair { 252 String url; // gliserverURL 253 String collection; // last opened collection for the corresponding gliserver 254 255 256 public static URLCollectionPair[] createDefaultsArray(String[] defaultURLs) { 257 URLCollectionPair[] pairs = new URLCollectionPair[defaultURLs.length]; 258 for(int i = 0; i < pairs.length; i++) { 259 pairs[i] = new URLCollectionPair(defaultURLs[i]); // no associated open collection 260 } 261 return pairs; 262 } 263 264 public URLCollectionPair(String url) { 265 this.set(url, ""); 266 } 267 268 public URLCollectionPair(String url, String collection) { 269 this.set(url, collection); 270 } 271 272 public void set(String url, String collection) { 273 this.url = url; 274 this.collection = collection; 275 } 276 277 public void setURL(String url) { 278 this.url = url; 279 } 280 281 public void setCollection(String collection) { 282 this.collection = collection; 283 } 284 285 public String getCollection() { 286 return collection; 287 } 288 289 public String getURL() { 290 return url; 291 } 292 293 /** For display in comboboxes */ 294 public String toString() { 295 return url; 296 } 297 298 /** @returns the number that is suffixed to the gliserver_url */ 299 public String getSuffixNumber() { 300 String numericSuffix = ""; 301 boolean stop = false; 302 for(int index = url.length()-1; index >= 0 && !stop; index--) { // work from the end 303 char character = url.charAt(index); 304 if(Character.isDigit(character)) { 305 numericSuffix = Character.toString(character) + numericSuffix; 306 } else { 307 stop = true; 308 } 309 } 310 311 return numericSuffix; 312 } 313 } 314 38 315 } -
gli/branches/rtl-gli/src/org/greenstone/gatherer/gui/WarningDialog.java
r18297 r18364 48 48 private JButton ok_button; 49 49 private JCheckBox show_check; 50 private J TextFieldvalue_field;50 private JComponent value_field; 51 51 private JPanel value_panel; 52 52 private String affected_property; 53 53 private String full_property; 54 55 56 public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel) 54 /** Whether or not to display the checkbox that will turn off this dialog in future */ 55 private final boolean showcheckbox; 56 57 58 public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel) 59 { 60 this(warning_name, warning_title, warning_message, affected_property, can_cancel, true); // true for show checkbox 61 } 62 63 64 public WarningDialog(String warning_name, String warning_title, String warning_message, String affected_property, boolean can_cancel, 65 boolean showcheckbox) 57 66 { 58 67 super(Gatherer.g_man, "Warning", true); 59 68 this.setComponentOrientation(Dictionary.getOrientation()); 69 this.showcheckbox = showcheckbox; 70 60 71 // Determine the name of this prompt. 61 72 this.affected_property = affected_property; … … 76 87 JPanel text_pane = new JPanel(); 77 88 text_pane.setComponentOrientation(Dictionary.getOrientation()); 78 JLabel icon_label = new JLabel(JarTools.getImage("gatherer_medium.gif")); 89 90 String gmedium_image = "gatherer_medium.gif"; 91 if (Configuration.fedora_info.isActive()) { 92 gmedium_image = "fli-" + gmedium_image; 93 } 94 95 JLabel icon_label = new JLabel(JarTools.getImage(gmedium_image)); 79 96 icon_label.setComponentOrientation(Dictionary.getOrientation()); 80 97 81 98 JTextArea text_area = new JTextArea(); 82 99 text_area.setComponentOrientation(Dictionary.getOrientation()); … … 96 113 JPanel bottom_pane = new JPanel(); 97 114 bottom_pane.setComponentOrientation(Dictionary.getOrientation()); 98 show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again")); 99 show_check.setComponentOrientation(Dictionary.getOrientation()); 115 100 116 JPanel control_pane = new JPanel(); 101 117 control_pane.setComponentOrientation(Dictionary.getOrientation()); … … 139 155 bottom_pane.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); 140 156 bottom_pane.setLayout(new BorderLayout()); 141 bottom_pane.add(show_check, BorderLayout.CENTER);142 157 bottom_pane.add(control_pane, BorderLayout.LINE_END); 158 if(showcheckbox) { 159 show_check = new JCheckBox(Dictionary.get("WarningDialog.Dont_Show_Again")); 160 show_check.setComponentOrientation(Dictionary.getOrientation()); 161 bottom_pane.add(show_check, BorderLayout.CENTER); 162 } 143 163 144 164 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); … … 160 180 161 181 public void actionPerformed(ActionEvent event) { 162 boolean bad_value = false;182 boolean valid_value = true; 163 183 if(event.getSource() == ok_button) { 164 184 if(affected_property != null && Configuration.self != null) { 165 String value = value_field.getText(); 166 if(value.length() > 0) { 167 if(value_field instanceof URLField) { 168 bad_value = !((URLField)value_field).validateURL(); 169 } 170 if(!bad_value) { 171 // Store the value of the property 172 Configuration.setString(affected_property, true, value_field.getText()); 173 } 185 valid_value = URLField.validateURL(value_field); 186 if(valid_value) { 187 // Store the value of the property 188 URLField.store(value_field, affected_property); //Configuration.setString(affected_property, true, value); 174 189 } 175 190 } 176 if( !bad_value) {191 if(valid_value) { 177 192 result = JOptionPane.OK_OPTION; 178 193 } 179 } 180 if(!bad_value) { 181 if (Configuration.self != null) { 194 } 195 196 if(valid_value) { 197 if (Configuration.self != null && showcheckbox) { 182 198 // Store the state of the show message checkbox. 183 199 Configuration.set(full_property, true, !show_check.isSelected()); … … 202 218 } 203 219 204 public void keyReleased(KeyEvent e) { 205 206 public void keyTyped(KeyEvent e) { 220 public void keyReleased(KeyEvent e) {} 221 222 public void keyTyped(KeyEvent e) {} 207 223 208 224 … … 226 242 */ 227 243 public void setMessageOnly(boolean message_only) { 244 if(!showcheckbox) { 245 return; 246 } 247 228 248 // If this is a message then change the checkbox 229 249 if(message_only) { … … 239 259 * @param control the JTextField subclass you want to use for the control 240 260 */ 241 public void setValueField(J TextFieldcontrol) {261 public void setValueField(JComponent control) { 242 262 // Remove the current control 243 263 value_panel.remove(value_field); … … 263 283 264 284 public void setValueField(String field_value){ 265 this.value_field.setText(field_value);285 URLField.setText(this.value_field, field_value); 266 286 } 267 287
Note:
See TracChangeset
for help on using the changeset viewer.