Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 200312 Details for
Bug 353047
[JFace] Introduce a file list editor for preference pages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Implementation for a File list field editor
patch.txt (text/plain), 3.88 KB, created by
Johan Westling
on 2011-07-25 17:04:02 EDT
(
hide
)
Description:
Implementation for a File list field editor
Filename:
MIME Type:
Creator:
Johan Westling
Created:
2011-07-25 17:04:02 EDT
Size:
3.88 KB
patch
obsolete
>Index: src/org/eclipse/jface/preference/FileListEditor.java >=================================================================== >RCS file: src/org/eclipse/jface/preference/FileListEditor.java >diff -N src/org/eclipse/jface/preference/FileListEditor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/preference/FileListEditor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,115 @@ >+package org.eclipse.jface.preference; >+ >+ >+import java.io.File; >+import java.util.ArrayList; >+import java.util.StringTokenizer; >+ >+import org.eclipse.jface.preference.ListEditor; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.FileDialog; >+ >+/** >+ * A field editor to edit files. >+ */ >+public class FileListEditor extends ListEditor { >+ >+ /** >+ * List of legal file extension suffixes, or <code>null</code> >+ * for system defaults. >+ */ >+ private String[] extensions = null; >+ >+ /** >+ * Initial path for the Browse dialog. >+ */ >+ private File filterPath = null; >+ >+ /** >+ * The special label text for file chooser, >+ * or <code>null</code> if none. >+ */ >+ private String fileChooserLabelText; >+ >+ /** >+ * Creates a new file list field editor >+ */ >+ protected FileListEditor() { >+ } >+ >+ /** >+ * Creates a file path field editor. >+ * >+ * @param name the name of the preference this field editor works on >+ * @param labelText the label text of the field editor >+ * @param fileChooserLabelText the label text displayed for the file chooser >+ * @param filterPath Initial path for the Browse dialog >+ * @param extensions List of legal file extension suffixes >+ * @param parent the parent of the field editor's control >+ */ >+ public FileListEditor(String name, String labelText, >+ String fileChooserLabelText, File filterPath, String[] extensions, Composite parent) { >+ init(name, labelText); >+ this.fileChooserLabelText = fileChooserLabelText; >+ this.filterPath = filterPath; >+ this.extensions = extensions; >+ createControl(parent); >+ } >+ >+ /* (non-Javadoc) >+ * Method declared on ListEditor. >+ * Creates a single string from the given array by separating each >+ * string with the appropriate OS-specific path separator. >+ */ >+ protected String createList(String[] items) { >+ StringBuffer path = new StringBuffer("");//$NON-NLS-1$ >+ >+ for (int i = 0; i < items.length; i++) { >+ path.append(items[i]); >+ path.append(File.pathSeparator); >+ } >+ return path.toString(); >+ } >+ >+ >+ /* (non-Javadoc) >+ * Method declared on ListEditor. >+ * Creates a new file element by means of a file dialog. >+ */ >+ protected String getNewInputObject() { >+ FileDialog dialog = new FileDialog(getShell(), SWT.OPEN | SWT.SHEET); >+ if (fileChooserLabelText != null) { >+ dialog.setText(fileChooserLabelText); >+ } >+ if (filterPath != null) { >+ dialog.setFilterPath(filterPath.getPath()); >+ } >+ if (extensions != null) { >+ dialog.setFilterExtensions(extensions); >+ } >+ String file = dialog.open(); >+ if (file != null) { >+ file = file.trim(); >+ if (file.length() > 0) { >+ return file; >+ } >+ } >+ >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * Method declared on ListEditor. >+ */ >+ protected String[] parseString(String stringList) { >+ StringTokenizer st = new StringTokenizer(stringList, File.pathSeparator >+ + "\n\r");//$NON-NLS-1$ >+ ArrayList v = new ArrayList(); >+ while (st.hasMoreElements()) { >+ v.add(st.nextElement()); >+ } >+ return (String[]) v.toArray(new String[v.size()]); >+ } >+} >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 353047
: 200312