01: /**
02: * L2FProd.com Common Components 7.3 License.
03: *
04: * Copyright 2005-2007 L2FProd.com
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package com.l2fprod.common.beans.editor;
18:
19: //import com.l2fprod.common.swing.JDirectoryChooser;
20: import com.l2fprod.common.swing.UserPreferences;
21: import com.l2fprod.common.util.ResourceManager;
22:
23: import java.io.File;
24: import java.io.IOException;
25:
26: import javax.swing.JFileChooser;
27:
28: /**
29: * DirectoryPropertyEditor.<br>
30: *
31: */
32: public class DirectoryPropertyEditor extends FilePropertyEditor {
33:
34: protected void selectFile() {
35: ResourceManager rm = ResourceManager
36: .all(FilePropertyEditor.class);
37:
38: JFileChooser chooser = UserPreferences
39: .getDefaultDirectoryChooser();
40:
41: chooser.setDialogTitle(rm
42: .getString("DirectoryPropertyEditor.dialogTitle"));
43: chooser
44: .setApproveButtonText(rm
45: .getString("DirectoryPropertyEditor.approveButtonText"));
46: chooser
47: .setApproveButtonMnemonic(rm
48: .getChar("DirectoryPropertyEditor.approveButtonMnemonic"));
49:
50: File oldFile = (File) getValue();
51: if (oldFile != null && oldFile.isDirectory()) {
52: try {
53: chooser.setCurrentDirectory(oldFile.getCanonicalFile());
54: } catch (IOException e) {
55: e.printStackTrace();
56: }
57: }
58:
59: if (JFileChooser.APPROVE_OPTION == chooser
60: .showOpenDialog(editor)) {
61: File newFile = chooser.getSelectedFile();
62: String text = newFile.getAbsolutePath();
63: textfield.setText(text);
64: firePropertyChange(oldFile, newFile);
65: }
66: }
67:
68: }
|