summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT
diff options
context:
space:
mode:
authorGrant Gayed <ggayed>2003-01-13 20:54:33 +0000
committerGrant Gayed <ggayed>2003-01-13 20:54:33 +0000
commit7f8bf8760658a1115ba38f670e13909efd38b188 (patch)
tree71c6bf023607fd0f53bb8852019c3e6ebcf8718f /bundles/org.eclipse.swt/Eclipse SWT
parent52e20f102db42a003d4de919d7b6feaae485fc2b (diff)
downloadeclipse.platform.swt-7f8bf8760658a1115ba38f670e13909efd38b188.tar.gz
eclipse.platform.swt-7f8bf8760658a1115ba38f670e13909efd38b188.tar.xz
eclipse.platform.swt-7f8bf8760658a1115ba38f670e13909efd38b188.zip
remove class GtkFileDialog
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java61
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java38
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/GtkFileDialog.java69
3 files changed, 62 insertions, 106 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
index bb6a584114..3719a34de3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -20,8 +20,10 @@ import org.eclipse.swt.widgets.*;
* within the SWT implementation.
* </p>
*/
-public class DirectoryDialog extends GtkFileDialog {
- String message = "", filterPath = "";
+public class DirectoryDialog extends Dialog {
+ String message = "", filterPath = "", answer;
+ int handle;
+ static final char SEPARATOR = System.getProperty ("file.separator").charAt (0);
/**
* Constructs a new instance of this class given only its
@@ -101,7 +103,6 @@ public String getFilterPath () {
public String getMessage () {
return message;
}
-
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -115,9 +116,39 @@ public String getMessage () {
* </ul>
*/
public String open () {
- return super.open();
+ byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
+ handle = OS.gtk_file_selection_new (titleBytes);
+ if (parent!=null) {
+ OS.gtk_window_set_transient_for(handle, parent.topHandle());
+ }
+ answer = null;
+ if (filterPath != null) {
+ byte [] filterBytes = Converter.wcsToMbcs (null, filterPath, true);
+ OS.gtk_file_selection_set_filename (handle, filterBytes);
+ }
+ GtkFileSelection selection = new GtkFileSelection();
+ OS.memmove(selection, handle);
+ OS.gtk_file_selection_hide_fileop_buttons (handle);
+ int fileListParent = OS.gtk_widget_get_parent(selection.file_list);
+ OS.gtk_widget_hide(selection.file_list);
+ OS.gtk_widget_hide(fileListParent);
+ int response = OS.gtk_dialog_run(handle);
+ if (response == OS.GTK_RESPONSE_OK) {
+ int lpFilename = OS.gtk_file_selection_get_filename (handle);
+ int filenameLength = OS.strlen (lpFilename);
+ byte [] filenameBytes = new byte [filenameLength];
+ OS.memmove (filenameBytes, lpFilename, filenameLength);
+ String osAnswer = new String( Converter.mbcsToWcs (null, filenameBytes) );
+ if (osAnswer!=null) {
+ answer = osAnswer;
+ // add trailing separator if not already present
+ int separatorIndex = answer.lastIndexOf(SEPARATOR);
+ if (separatorIndex != answer.length() - 1) answer += SEPARATOR;
+ }
+ }
+ OS.gtk_widget_destroy(handle);
+ return answer;
}
-
/**
* Sets the path which the dialog will use to filter
* the directories it shows to the argument, which may be
@@ -143,24 +174,4 @@ public void setMessage (String string) {
*/
message = string;
}
-
-void interpretOsAnswer(String osAnswer) {
- if (osAnswer==null) return;
- answer = osAnswer;
- // add trailing separator if not already present
- int separatorIndex = calculateLastSeparatorIndex(answer);
- if (separatorIndex != answer.length() - 1) answer += separator;
-}
-void preset() {
- if (filterPath != null) {
- byte [] filterBytes = Converter.wcsToMbcs (null, filterPath, true);
- OS.gtk_file_selection_set_filename (handle, filterBytes);
- }
- GtkFileSelection selection = new GtkFileSelection();
- OS.memmove(selection, handle);
- OS.gtk_file_selection_hide_fileop_buttons (handle);
- int fileListParent = OS.gtk_widget_get_parent(selection.file_list);
- OS.gtk_widget_hide(selection.file_list);
- OS.gtk_widget_hide(fileListParent);
-}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
index a5c511e96a..ce5be74e2d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
@@ -25,13 +25,16 @@ import org.eclipse.swt.internal.gtk.*;
* within the SWT implementation.
* </p>
*/
-public class FileDialog extends GtkFileDialog {
+public class FileDialog extends Dialog {
String [] filterNames = new String [0];
String [] filterExtensions = new String [0];
String filterPath = "";
String fileName = "";
String[] fileNames;
String fullPath = "";
+ String answer;
+ int handle;
+ static final char SEPARATOR = System.getProperty ("file.separator").charAt (0);
/**
* Constructs a new instance of this class given only its
@@ -141,7 +144,6 @@ public String [] getFilterNames () {
public String getFilterPath () {
return filterPath;
}
-
/**
* Makes the dialog visible and brings it to the front
* of the display.
@@ -155,11 +157,24 @@ public String getFilterPath () {
* </ul>
*/
public String open () {
- /*
- * The only reason this method is not just left out to
- * fall through to the superclass, is the JavaDoc comment.
- */
- return super.open();
+ byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
+ handle = OS.gtk_file_selection_new (titleBytes);
+ if (parent!=null) {
+ OS.gtk_window_set_transient_for(handle, parent.topHandle());
+ }
+ answer = null;
+ preset();
+ int response = OS.gtk_dialog_run(handle);
+ if (response == OS.GTK_RESPONSE_OK) {
+ int lpFilename = OS.gtk_file_selection_get_filename (handle);
+ int filenameLength = OS.strlen (lpFilename);
+ byte [] filenameBytes = new byte [filenameLength];
+ OS.memmove (filenameBytes, lpFilename, filenameLength);
+ String osAnswer = new String( Converter.mbcsToWcs (null, filenameBytes) );
+ interpretOsAnswer(osAnswer);
+ }
+ OS.gtk_widget_destroy(handle);
+ return answer;
}
/**
* Set the initial filename which the dialog will
@@ -218,8 +233,8 @@ void preset() {
} else {
if (filterPath.length () > 0) {
stringBuffer.append (filterPath);
- if (filterPath.charAt (filterPath.length () - 1) != separator) {
- stringBuffer.append (separator);
+ if (filterPath.charAt (filterPath.length () - 1) != SEPARATOR) {
+ stringBuffer.append (SEPARATOR);
}
}
}
@@ -243,10 +258,9 @@ void preset() {
fullPath = null;
}
-
void interpretOsAnswer(String osAnswer) {
if (osAnswer==null) return;
- int separatorIndex = calculateLastSeparatorIndex(osAnswer);
+ int separatorIndex = osAnswer.lastIndexOf(SEPARATOR);
if (separatorIndex+1 == osAnswer.length()) {
/*
* the selected thing is a directory
@@ -286,7 +300,7 @@ void interpretOsAnswer(String osAnswer) {
// The better way to do it would be:
// fileNames[i] = new String(bytes);
String name = new String(Converter.mbcsToWcs(null, bytes));
- fileNames[i] = name.substring(calculateLastSeparatorIndex(name)+1);
+ fileNames[i] = name.substring(name.lastIndexOf(SEPARATOR)+1);
/*
* NB: Unlike other similar functions (e.g., g_convert), the glib
* documentation does not say the resulting UTF8 string should be
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/GtkFileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/GtkFileDialog.java
deleted file mode 100644
index 85ce18d1c7..0000000000
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/GtkFileDialog.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.eclipse.swt.widgets;
-
-/*
- * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
- * This file is made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.gtk.*;
-
-abstract class GtkFileDialog extends Dialog {
-
- String answer;
- int handle;
- char separator = System.getProperty ("file.separator").charAt (0);
-
-GtkFileDialog (Shell parent, int style) {
- super (parent, style);
-}
-
-public String open () {
- byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
- handle = OS.gtk_file_selection_new (titleBytes);
- if (parent!=null) {
- OS.gtk_window_set_transient_for(handle, parent.topHandle());
- }
- answer = null;
- preset();
- int response = OS.gtk_dialog_run(handle);
- if (response == OS.GTK_RESPONSE_OK) {
- int lpFilename = OS.gtk_file_selection_get_filename (handle);
- int filenameLength = OS.strlen (lpFilename);
- byte [] filenameBytes = new byte [filenameLength];
- OS.memmove (filenameBytes, lpFilename, filenameLength);
- String osAnswer = new String( Converter.mbcsToWcs (null, filenameBytes) );
- interpretOsAnswer(osAnswer);
- }
- OS.gtk_widget_destroy(handle);
- return answer;
-}
-
-/*
- * Subclasses must implement this to set things like
- * the filter or the initial selection, just before opening
- * the dialog.
- */
-abstract void preset();
-
-/*
- * Subclasses must implement this to set the right state
- * of the dialog just after its loop returned.
- */
-abstract void interpretOsAnswer(String osAnswer);
-
-/*
- * This is just a convenience function to help share code between subclasses
- */
-int calculateLastSeparatorIndex(String x) {
- int separatorIndex = x.indexOf (separator);
- int index = separatorIndex;
- while (index != -1) {
- separatorIndex = index;
- index = x.indexOf (separator, index + 1);
- }
- return separatorIndex;
-}
-}