XFileDialogPeer.java revision 2153
381N/A * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A // This variable holds value exactly the same as value of the 'target.file' variable except: 0N/A // 1) is changed to null after quit (see handleQuitButton()) 0N/A // 2) keep the same value if 'target.file' is incorrect (see setFile()) 0N/A // It's not clear HOW we used it 0N/A // We should think about existence of this variable 0N/A // Seems that the purpose of this variable is cashing of 'target.file' variable in order to help method show() 0N/A // We should think about using 'target.file' instead of 'savedFile' 0N/A // Perhaps, 'target.file' just more correct (see target.setFile()) 0N/A // Holds value of the directory which was chosen before 0N/A // We use it in order to restore previously selected directory 0N/A // at the time of the next showing of the file dialog 0N/A // Holds value of the system property 'user.dir' 0N/A // in order to init current directory 0N/A // ************** Components in the fileDialogWindow *************** 0N/A // This variable holds the current text of the file which user select through the navigation 0N/A // It's important that updating of this variable must be correct 0N/A // since this value is used at the time of the file dialog closing 0N/A // Namely, we invoke target.setFile() and then user can get this value 0N/A // We update this field in cases: 0N/A // - ITEM_STATE_CHANGED was triggered on the file list component: set to the current selected item 0N/A // - at the time of the 'show': set to savedFile 0N/A // - at the time of the programmatically setting: set to new value 0N/A // This is the list component which is used for the showing of the file list of the current directory 0N/A // Shouldn't save 'user.dir' to 'savedDir' 0N/A // since getDirectory() will be incorrect after handleCancel 0N/A // create components 0N/A // the insets used by the components in the fileDialog 0N/A // add components to GridBagLayout "gbl" 0N/A // Fixed 6260650: FileDialog.getDirectory() does not return null when file dialog is cancelled 0N/A // After showing we should display 'user.dir' as current directory 0N/A // if user didn't set directory programatically 0N/A //addComponent(pathField, gbl, gbc, 0, 1, 2, 0N/A // GridBagConstraints.WEST, (Container)fileDialog, 0N/A // 1, 0, GridBagConstraints.HORIZONTAL, textFieldInset); 0N/A //addComponent(pathChoice, gbl, gbc, 1, 1, GridBagConstraints.RELATIVE, 0N/A // GridBagConstraints.WEST, (Container)fileDialog, 0N/A // 1, 0, GridBagConstraints.HORIZONTAL, textFieldInset); 0N/A // add buttons to GridBagLayout Buttons 0N/A // add ButtonPanel to the GridBagLayout of this class 0N/A // Update choice's popup width 0N/A // b6227750 FileDialog is not disposed when clicking the 'close' (X) button on the top right corner, XToolkit 0N/A // 6259434 PIT: Choice in FileDialog is not responding to keyboard interactions, XToolkit 0N/A * add Component comp to the container cont. 0N/A * add the component to the correct GridBagLayout 0N/A // Fixed within 6259434: PIT: Choice in FileDialog is not responding to keyboard interactions, XToolkit 0N/A // Here we restoring Motif behaviour 0N/A * handle the selection event 0N/A * handle the cancel event 0N/A * handle the quit event 0N/A * set the entry of the new dir with f 0N/A // Fixed 6260659: File Name set programmatically in FileDialog is overridden during navigation, XToolkit 0N/A // Here we restoring Motif behaviour 0N/A // REMIND: fileDialogFilter is not implemented yet 0N/A // Fixed 6358953: handling was added in case of I/O error happens 0N/A // Some code was removed 0N/A // Now we do updating of the pathChoice at the time of the choice opening 0N/A * set the text in the selectionField 0N/A * set the text in the filterField 0N/A * @see java.awt.event.ItemEvent 0N/A * ItemEvent.ITEM_STATE_CHANGED 0N/A * Update the selection ('folder name' text field) after 0N/A * the current item changing in the unfurled choice by the arrow keys. 0N/A * See 6259434, 6240074 for more information 0N/A * Updates the current directory only if directoryList-specific 0N/A * action occurred. Returns false if the forward directory is inaccessible 0N/A if (!
this.
dir.
equals(
"/"))
// If the current directory is "/" leave it alone. 0N/A // Fixed within 6259434: PIT: Choice in FileDialog is not responding to keyboard interactions, XToolkit 0N/A // We should handle the action based on the selection field 0N/A // Looks like mistake 0N/A //handleFilter( actionCommand + getFileName( filterField.getText() ) ); 0N/A // Fix for 6240084 Disposing a file dialog when the drop-down is active does not dispose the dropdown menu, on Xtoolkit 0N/A * FIXME: we should update 'savedDir' after programmatically 'setDirectory' 0N/A * Otherwise, SavedDir will be not null before second showing 0N/A * So the current directory of the file dialog will be incorrect after second showing 0N/A * since 'setDirectory' will be ignored 0N/A * We cann't update savedDir here now since it used very often 0N/A // Some code was removed 0N/A // Now we do updating of the pathChoice at the time of the choice opening 0N/A // The exception java.awt.IllegalComponentStateException will be thrown 0N/A // if the user invoke setDirectory after the closing of the file dialog 0N/A * set filenameFilter 1052N/A // 03/02/2005 b5097243 Pressing 'ESC' on a file dlg does not dispose the dlg on Xtoolkit 0N/A // Actually in Motif implementation lost file value which was saved after prevously showing 0N/A // Seems we shouldn't restore Motif behaviour in this case 0N/A // See 6240074 for more information 0N/A // See 6240074 for more information 0N/A * Adding items to the path choice based on the text string 0N/A * See 6240074 for more information 0N/A * Refresh the unfurled choice at the time of the opening choice according to the text of the path field 0N/A * See 6240074 for more information 0N/A // When the unfurled choice is opening the first time, we need only to add elements, otherwise we've got exception 0N/A // If the set of the directories the exactly same as the used to be then dummy 0N/A * Refresh the file dialog at the time of the closing choice according to the selected item of the choice 0N/A * See 6240074 for more information 0N/A // This is the exactly same code as invoking later at the time of the itemStateChanged 0N/A // Here is we restore Windows behaviour: change current directory if user press 'ESC' 0N/A * Motif file dialogs let the user specify a filter that controls the files that 0N/A * are displayed in the dialog. This filter is generally specified as a regular 0N/A * expression. The class is used to implement Motif-like filtering. 0N/A * Tells whether or not the specified file should be included in a file list 0N/A * Tells whether or not the input string matches the given filter 0N/A * Converts the filter into the form which is acceptable by Java's regexps