/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
class XFileDialogPeer extends XDialogPeer implements FileDialogPeer, ActionListener, ItemListener, KeyEventDispatcher, XChoicePeerListener {
// This variable holds value exactly the same as value of the 'target.file' variable except:
// 1) is changed to null after quit (see handleQuitButton())
// 2) keep the same value if 'target.file' is incorrect (see setFile())
// It's not clear HOW we used it
// We should think about existence of this variable
int mode;
// Seems that the purpose of this variable is cashing of 'target.file' variable in order to help method show()
// We should think about using 'target.file' instead of 'savedFile'
// Perhaps, 'target.file' just more correct (see target.setFile())
// Holds value of the directory which was chosen before
// We use it in order to restore previously selected directory
// at the time of the next showing of the file dialog
// Holds value of the system property 'user.dir'
// in order to init current directory
// ************** Components in the fileDialogWindow ***************
// This variable holds the current text of the file which user select through the navigation
// It's important that updating of this variable must be correct
// since this value is used at the time of the file dialog closing
// Namely, we invoke target.setFile() and then user can get this value
// We update this field in cases:
// - ITEM_STATE_CHANGED was triggered on the file list component: set to the current selected item
// - at the time of the 'show': set to savedFile
// - at the time of the programmatically setting: set to new value
// This is the list component which is used for the showing of the file list of the current directory
void installStrings() {
}
}
// Shouldn't save 'user.dir' to 'savedDir'
// since getDirectory() will be incorrect after handleCancel
new PrivilegedAction() {
}
});
gbl = new GridBagLayout();
gblButtons = new GridBagLayout();
gbc = new GridBagConstraints();
// create components
directoryList = new List();
filterField = new TextField();
selectionField = new TextField();
boolean isMultipleMode =
// the insets used by the components in the fileDialog
// add components to GridBagLayout "gbl"
// Fixed 6260650: FileDialog.getDirectory() does not return null when file dialog is cancelled
// After showing we should display 'user.dir' as current directory
// if user didn't set directory programatically
pathChoice = new Choice() {
public Dimension getPreferredSize() {
}
};
//addComponent(pathField, gbl, gbc, 0, 1, 2,
// GridBagConstraints.WEST, (Container)fileDialog,
// 1, 0, GridBagConstraints.HORIZONTAL, textFieldInset);
//addComponent(pathChoice, gbl, gbc, 1, 1, GridBagConstraints.RELATIVE,
// GridBagConstraints.WEST, (Container)fileDialog,
// 1, 0, GridBagConstraints.HORIZONTAL, textFieldInset);
// add buttons to GridBagLayout Buttons
// add ButtonPanel to the GridBagLayout of this class
// Update choice's popup width
choicePeer.setDrawSelectedItem(false);
filterField.addActionListener(this);
selectionField.addActionListener(this);
directoryList.addActionListener(this);
directoryList.addItemListener(this);
fileList.addItemListener(this);
fileList.addActionListener(this);
openButton.addActionListener(this);
filterButton.addActionListener(this);
cancelButton.addActionListener(this);
pathChoice.addItemListener(this);
pathField.addActionListener(this);
// b6227750 FileDialog is not disposed when clicking the 'close' (X) button on the top right corner, XToolkit
new WindowAdapter(){
public void windowClosing(WindowEvent e){
handleCancel();
}
}
);
// 6259434 PIT: Choice in FileDialog is not responding to keyboard interactions, XToolkit
pathChoice.addItemListener(this);
}
public void updateMinimumSize() {
}
public void updateIconImages() {
winAttr.iconsInherited = false;
}
}
/**
* add Component comp to the container cont.
* add the component to the correct GridBagLayout
*/
}
/**
* get fileName
*/
return "";
}
if (index == -1) {
return str;
} else {
}
}
/** handleFilter
*
*/
if (f == null) {
return;
}
setFilterEntry(dir,f);
// Fixed within 6259434: PIT: Choice in FileDialog is not responding to keyboard interactions, XToolkit
// Here we restoring Motif behaviour
} else {
}
}
/**
* handle the selection event
*/
if (index == -1) {
} else {
}
for (int i = 0; i < filesNumber; i++) {
}
}
/**
* handle the cancel event
*/
void handleCancel() {
.removeKeyEventDispatcher(this);
}
/**
* handle the quit event
*/
void handleQuitButton() {
}
/**
* set the entry of the new dir with f
*/
// Fixed 6260659: File Name set programmatically in FileDialog is overridden during navigation, XToolkit
// Here we restoring Motif behaviour
if (f.equals("")) {
f = "*";
setFilterField(f);
} else {
setFilterField(f);
}
String l[];
if (f.equals("*")) {
} else {
// REMIND: fileDialogFilter is not implemented yet
}
// Fixed 6358953: handling was added in case of I/O error happens
if (l == null) {
this.dir = getParentDirectory();
return;
}
directoryList.setVisible(false);
fileList.setVisible(false);
for (int i = 0 ; i < l.length ; i++) {
if (file.isDirectory()) {
} else {
}
}
}
this.dir = d;
// Some code was removed
// Now we do updating of the pathChoice at the time of the choice opening
directoryList.setVisible(true);
fileList.setVisible(true);
}
}
int numSlashes = 0;
if (charr[i] == '/')
numSlashes++;
}
int j=0;
if (charr[i] == '/')
{
}
}
return starr;
}
/**
* set the text in the selectionField
*/
}
/**
* set the text in the filterField
*/
}
/**
*
* @see java.awt.event.ItemEvent
* ItemEvent.ITEM_STATE_CHANGED
*/
return;
}
if (source == pathChoice) {
/*
* Update the selection ('folder name' text field) after
* the current item changing in the unfurled choice by the arrow keys.
* See 6259434, 6240074 for more information
*/
} else if (directoryList == source) {
}
}
/*
* Updates the current directory only if directoryList-specific
* action occurred. Returns false if the forward directory is inaccessible
*/
dir = getParentDirectory();
}
else {
}
return true;
}else {
return false;
}
}
{
}
return parent;
}
handleCancel();
// Fixed within 6259434: PIT: Choice in FileDialog is not responding to keyboard interactions, XToolkit
// We should handle the action based on the selection field
// Looks like mistake
}
//handleFilter( actionCommand + getFileName( filterField.getText() ) );
}
}
}
}
synchronized (target.getTreeLock()) {
// Fix for 6240084 Disposing a file dialog when the drop-down is active does not dispose the dropdown menu, on Xtoolkit
// See also 6259493
if (comp == pathChoice) {
if (choicePeer.isUnfurled()){
return false;
}
}
handleCancel();
return true;
}
}
}
}
return false;
}
/**
* set the file
*/
return;
}
String d = "./";
if (f.isFile()) {
setDirectory(d);
}
} else {
if (f.isFile()) {
}
}
}
/**
* set the directory
* FIXME: we should update 'savedDir' after programmatically 'setDirectory'
* Otherwise, SavedDir will be not null before second showing
* So the current directory of the file dialog will be incorrect after second showing
* since 'setDirectory' will be ignored
* We cann't update savedDir here now since it used very often
*/
return;
}
return;
}
int i;
}
if (!fe.isDirectory()) {
dir = "./";
if (!fe.isDirectory()) {
return;
}
}
try {
}
handleFilter("");
} else {
handleFilter("");
}
// Some code was removed
// Now we do updating of the pathChoice at the time of the choice opening
// Fixed problem:
// The exception java.awt.IllegalComponentStateException will be thrown
// if the user invoke setDirectory after the closing of the file dialog
}
/**
* set filenameFilter
*
*/
}
public void dispose() {
}
super.dispose();
}
// 03/02/2005 b5097243 Pressing 'ESC' on a file dlg does not dispose the dlg on Xtoolkit
public void setVisible(boolean b){
if (fileDialog == null) {
}
}
// Actually in Motif implementation lost file value which was saved after prevously showing
// Seems we shouldn't restore Motif behaviour in this case
}
super.setVisible(b);
if (b == true){
// See 6240074 for more information
choicePeer.addXChoicePeerListener(this);
}else{
// See 6240074 for more information
}
}
/*
* Adding items to the path choice based on the text string
* See 6240074 for more information
*/
}
/*
* Refresh the unfurled choice at the time of the opening choice according to the text of the path field
* See 6240074 for more information
*/
// When the unfurled choice is opening the first time, we need only to add elements, otherwise we've got exception
return;
}
// If the set of the directories the exactly same as the used to be then dummy
return;
}
/*
* Refresh the file dialog at the time of the closing choice according to the selected item of the choice
* See 6240074 for more information
*/
public void unfurledChoiceClosing(){
// This is the exactly same code as invoking later at the time of the itemStateChanged
// Here is we restore Windows behaviour: change current directory if user press 'ESC'
}
}
int orientation;
super();
if (orient == HORIZONTAL) {
} else {
// VERTICAL
}
}
Color c = getBackground();
if (orientation == HORIZONTAL) {
x1 = 0;
} else {
// VERTICAL
y1 = 0;
}
if (orientation == HORIZONTAL)
else
}
}
/*
* Motif file dialogs let the user specify a filter that controls the files that
* are displayed in the dialog. This filter is generally specified as a regular
* expression. The class is used to implement Motif-like filtering.
*/
filter = f;
}
/*
* Tells whether or not the specified file should be included in a file list
*/
if (f.isDirectory()) {
return true;
} else {
}
}
/*
* Tells whether or not the input string matches the given filter
*/
}
/*
* Converts the filter into the form which is acceptable by Java's regexps
*/
return regex;
}
}