User: andreas
Date: 00/10/14 22:26:59
Modified: src/main/com/dreambean/ejx Util.java
Added: src/main/com/dreambean/ejx ResourceManager.java
ResourceManagerFactory.java
Removed: src/main/com/dreambean/ejx FileManager.java
FileManagerFactory.java
Log:
Replaced FileManager and FileManagerFactory by the new
ResourceManager and ResourceManagerFactory supporting
URL instead of just files.
ATTENTION:
- At the moment you can still only use files to open and store
Data because of unresolved issues (FilterFilter and JFile-
Chooser)
- These changes are NOT PORTED to jBoss CVS module
Revision Changes Path
1.2 +20 -1 ejx/src/main/com/dreambean/ejx/Util.java
Index: Util.java
===================================================================
RCS file: /products/cvs/ejboss/ejx/src/main/com/dreambean/ejx/Util.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Util.java 2000/07/27 13:52:44 1.1
+++ Util.java 2000/10/15 05:26:58 1.2
@@ -8,6 +8,7 @@
import java.io.FileOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
+import java.net.URL;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Vector;
@@ -18,7 +19,7 @@
*
* @see <related>
* @author Rickard Oberg ([EMAIL PROTECTED])
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public abstract class Util
{
@@ -89,5 +90,23 @@
metaFile.delete();
metaFile.getParentFile().delete();
+ }
+ /**
+ * Converts a given URL to a File if possible
+ *
+ * @param resource URL to be converted to a file
+ *
+ * @return File if conversion was possible otherwise
+ * null
+ **/
+ public static File convertURL( URL resource ) {
+ if( resource != null ) {
+ if( resource.getProtocol().equalsIgnoreCase( "file" ) ) {
+//AS Why does this not work ??
+//AS return new File( resource.getPath(), resource.getFile() );
+ return new File( resource.getFile() );
+ }
+ }
+ return null;
}
}
1.1 ejx/src/main/com/dreambean/ejx/ResourceManager.java
Index: ResourceManager.java
===================================================================
/*
* Copyright 1999 by dreamBean Software,
* All rights reserved.
*/
package com.dreambean.ejx;
import java.beans.beancontext.*;
import java.net.URL;
/**
* All plugins must implement this interface. It represents an opened/created
resource.
*
* Note that you must implement "getComponent" which will be used by EJX to show
this
* editor in a window.
*
* @see ResourceManagerFactory.
* @author Rickard Oberg ([EMAIL PROTECTED])
* @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad"
Schaefer</A>
* @version $Revision: 1.1 $
*/
public interface ResourceManager
extends BeanContextChildComponentProxy, BeanContextChild
{
// Constants -----------------------------------------------------
// Static --------------------------------------------------------
// Public --------------------------------------------------------
/**
* Should return true if the resource has changed since last save.
*
* This is not yet used by the EJX framework, but is included for future use.
*
* @return true if changed
*/
public boolean isChanged();
/**
* Create a new editor.
*
*/
public void createNew();
/**
* Load the given resource.
*
* @param resource URL to the resource to be loaded
* @exception Exception
*/
public void load(URL resource)
throws Exception;
/**
* Save to the given resource. This is "Save" if same as used in load() call,
* and "Save as" if not same.
*
* @param resource URL to the resource to be saved
* @exception Exception
*/
public void save(URL resource)
throws Exception;
/**
* Get the resource of this editor. Null means "just created and not saved",
* i.e. the GUI will show "Untitled".
*
* @return the resource that is being edited
*/
public URL getResource();
/**
* Return the factory that created this editor.
*
* @return the parent factory
*/
public ResourceManagerFactory getFactory();
}
1.1 ejx/src/main/com/dreambean/ejx/ResourceManagerFactory.java
Index: ResourceManagerFactory.java
===================================================================
/*
* Copyright 1999 by dreamBean Software,
* All rights reserved.
*/
package com.dreambean.ejx;
import javax.swing.filechooser.FileFilter;
/**
* This factory interface must be implemented by all plugins. A factory
* represents a resource-type in EJX.
*
* The file-filter is used by "Open" and "Save" dialogs
* to filter out legal alternatives for filenames (AS FIXME: has to be
* replaced by a getURLFilter() which returns an URLFilter dealing with
* URLs instead of files.
*
* @see ResourceManager
* @author Rickard Oberg ([EMAIL PROTECTED])
* @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad"
Schaefer</A>
* @version $Revision: 1.1 $
*/
public interface ResourceManagerFactory
{
// Constants -----------------------------------------------------
// Static --------------------------------------------------------
// Public --------------------------------------------------------
/**
* @return Resource Manager to deal with the selected resource
**/
public ResourceManager createResourceManager();
/**
* AS FIXME: Replace by a URLFilter
*
* @return File Filter to select a valid resource
**/
public FileFilter getFileFilter();
}