summaryrefslogtreecommitdiff
path: root/java/ImageProcessing/framework
diff options
context:
space:
mode:
authorpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-17 03:50:01 +0000
committerpjain <pjain@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-04-17 03:50:01 +0000
commitd84f671cb4cb8c07b471a51bb15b95ffbd24cdb0 (patch)
treedaf45104db8bb84579c429b3c368ae696f90aabb /java/ImageProcessing/framework
parent6a89b3ea6110d8822275bf38588e2dcc00e6f057 (diff)
downloadATCD-d84f671cb4cb8c07b471a51bb15b95ffbd24cdb0.tar.gz
Made some changes -- combine open and browse buttons into one and also allow
user to press <Enter> to indicate selection.
Diffstat (limited to 'java/ImageProcessing/framework')
-rw-r--r--java/ImageProcessing/framework/URLFrame.java104
1 files changed, 67 insertions, 37 deletions
diff --git a/java/ImageProcessing/framework/URLFrame.java b/java/ImageProcessing/framework/URLFrame.java
index d9cdca04a5c..fcf905b47a0 100644
--- a/java/ImageProcessing/framework/URLFrame.java
+++ b/java/ImageProcessing/framework/URLFrame.java
@@ -4,13 +4,14 @@ import java.awt.*;
import java.awt.image.*;
import java.net.*;
import java.io.*;
-import gjt.ComponentScroller;
class URLFrame extends Frame
{
- public URLFrame (String title, ImageApp parent)
+ public URLFrame (String title, ImageApp parent, boolean open)
{
super (title);
+ // Cache information -- whether we are a load window or a save window
+ this.open_ = open;
this.parent_ = parent;
this.resize (500,130);
@@ -23,26 +24,24 @@ class URLFrame extends Frame
Panel buttonPanel = new Panel ();
buttonPanel.setLayout (new FlowLayout (FlowLayout.CENTER));
- buttonPanel.add (this.browseButton_);
- buttonPanel.add (this.loadButton_);
+
+ if (this.open_)
+ buttonPanel.add (this.openButton_);
+ else
+ buttonPanel.add (this.saveButton_);
+
buttonPanel.add (this.clearButton_);
buttonPanel.add (this.cancelButton_);
this.add ("North", textPanel);
this.add ("South", buttonPanel);
- this.loadButton_.nextFocus ();
}
- private int browseFiles ()
+ private int browseFiles (String url)
{
- String pString = this.openURLText_.getText ();
- if (pString.compareTo ("ru") == 0)
- pString = "http://www.cs/~pjain/java";
-
fileBrowser_ = new FileBrowser ("Browse", this.parent_);
- // this.scroller_ = new ComponentScroller (fileBrowser_);
ListFiles list = new ListFiles (this.fileBrowser_, this.parent_);
- return this.fileBrowser_.initialize (pString, list);
+ return this.fileBrowser_.initialize (url, list);
}
// Handle all action events
@@ -50,9 +49,13 @@ class URLFrame extends Frame
{
if (e.target instanceof Button)
{
- if (e.target == this.loadButton_)
+ if (e.target == this.openButton_)
{
- this.parent_.openURL (this.openURLText_.getText ());
+ this.getURL ();
+ }
+ if (e.target == this.saveButton_)
+ {
+ this.parent_.saveFile (this.openURLText_.getText ());
this.dispose ();
}
else if (e.target == this.clearButton_)
@@ -62,26 +65,6 @@ class URLFrame extends Frame
}
else if (e.target == this.cancelButton_)
this.dispose ();
- else if (e.target == this.browseButton_)
- {
- this.dispose ();
- ListFiles list = new ListFiles ();
- switch (this.browseFiles ())
- {
- case 1:
- this.fileBrowser_.show ();
- break;
- case 0:
- DialogManager.popDialog (DialogType.MALFORMED_URL,
- "Error: Directory contains index.html");
- break;
- default:
- DialogManager.popDialog (DialogType.MALFORMED_URL,
- "Error: Malformed URL");
- break;
- }
- }
-
validate ();
return true;
}
@@ -89,10 +72,55 @@ class URLFrame extends Frame
return false;
}
+ public boolean keyDown (Event e, int key)
+ {
+ if (key == 10)
+ {
+ this.getURL ();
+ return true;
+ }
+ else
+ return false;
+ }
+
+ private void getURL ()
+ {
+ this.dispose ();
+ String url = this.openURLText_.getText ();
+
+ // The following is only for debugging
+ if (url.compareTo ("ru") == 0)
+ url = "http://www.cs/~pjain/gifs/";
+ else if (url.compareTo ("pj") == 0)
+ url = "http://www.cs/~pjain/myphoto.gif";
+
+ if (!url.endsWith ("/") &&
+ (this.parent_.openURL (url) != -1)) // Try to open it as an image
+ return;
+ else
+ {
+ ListFiles list = new ListFiles ();
+ switch (this.browseFiles (url))
+ {
+ case 1:
+ this.fileBrowser_.show ();
+ break;
+ case 0:
+ DialogManager.popDialog (DialogType.MALFORMED_URL,
+ "Error: Directory contains index.html");
+ break;
+ default:
+ DialogManager.popDialog (DialogType.MALFORMED_URL,
+ "Error: Not a valid image or URL not found");
+ break;
+ }
+ }
+ }
+
// Create the Open URL Frame and also the buttons which appear in
// it
- private Button browseButton_ = new Button ("Browse");
- private Button loadButton_ = new Button ("Load");
+ private Button openButton_ = new Button ("Open");
+ private Button saveButton_ = new Button ("Save");
private Button clearButton_ = new Button ("Clear");
private Button cancelButton_ = new Button ("Cancel");
@@ -100,7 +128,9 @@ class URLFrame extends Frame
private FileBrowser fileBrowser_ = null;
private ImageApp parent_;
- private ComponentScroller scroller_;
+
+ // Flag indicating if this is a load window or a save window
+ private boolean open_ = true;
}