Sweet Home 3D 4.1

com.eteks.sweethome3d.swing
Class FileContentManager

java.lang.Object
  extended by com.eteks.sweethome3d.swing.FileContentManager
All Implemented Interfaces:
ContentManager
Direct Known Subclasses:
AppletContentManager

public class FileContentManager
extends Object
implements ContentManager

Content manager for files with Swing file choosers.

Author:
Emmanuel Puybaret

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.eteks.sweethome3d.viewcontroller.ContentManager
ContentManager.ContentType
 
Constructor Summary
FileContentManager(UserPreferences preferences)
           
 
Method Summary
protected  boolean confirmOverwrite(View parentView, String path)
          Displays a dialog that let user choose whether he wants to overwrite file path or not.
 Content getContent(String contentPath)
          Returns a URL content object that references the given file path.
 String getDefaultFileExtension(ContentManager.ContentType contentType)
          Returns the default file extension of a given content type.
protected  String getFileDialogTitle(boolean save)
          Returns default file dialog title.
protected  FileFilter[] getFileFilter(ContentManager.ContentType contentPath)
          Returns the file filters available for a given content type.
protected  File getLastDirectory(ContentManager.ContentType contentType)
          Returns the last directory used for the given content type.
 String getPresentationName(String contentPath, ContentManager.ContentType contentType)
          Returns the file name of the file path in parameter.
 boolean isAcceptable(String contentPath, ContentManager.ContentType contentType)
          Returns true if the file path in parameter is accepted for contentType.
protected  boolean isDirectory(ContentManager.ContentType contentType)
          Returns true if the given content type is for directories.
protected  void setLastDirectory(ContentManager.ContentType contentType, File directory)
          Stores the last directory for the given content type.
 String showOpenDialog(View parentView, String dialogTitle, ContentManager.ContentType contentType)
          Returns the file path chosen by user with an open file dialog.
 String showSaveDialog(View parentView, String dialogTitle, ContentManager.ContentType contentType, String path)
          Returns the file path chosen by user with a save file dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileContentManager

public FileContentManager(UserPreferences preferences)
Method Detail

getContent

public Content getContent(String contentPath)
                   throws RecorderException
Returns a URL content object that references the given file path.

Specified by:
getContent in interface ContentManager
Throws:
RecorderException

getPresentationName

public String getPresentationName(String contentPath,
                                  ContentManager.ContentType contentType)
Returns the file name of the file path in parameter.

Specified by:
getPresentationName in interface ContentManager

getFileFilter

protected FileFilter[] getFileFilter(ContentManager.ContentType contentPath)
Returns the file filters available for a given content type. This method may be overridden to add some file filters to existing content types or to define the filters of a user defined content type.


getDefaultFileExtension

public String getDefaultFileExtension(ContentManager.ContentType contentType)
Returns the default file extension of a given content type. If not null this extension will be appended automatically to the file name chosen by user in save dialog. This method may be overridden to change the default file extension of an existing content type or to define the default file extension of a user defined content type.


isAcceptable

public boolean isAcceptable(String contentPath,
                            ContentManager.ContentType contentType)
Returns true if the file path in parameter is accepted for contentType.

Specified by:
isAcceptable in interface ContentManager

isDirectory

protected boolean isDirectory(ContentManager.ContentType contentType)
Returns true if the given content type is for directories.


showOpenDialog

public String showOpenDialog(View parentView,
                             String dialogTitle,
                             ContentManager.ContentType contentType)
Returns the file path chosen by user with an open file dialog.

Specified by:
showOpenDialog in interface ContentManager
Returns:
the file path or null if user canceled its choice.

showSaveDialog

public String showSaveDialog(View parentView,
                             String dialogTitle,
                             ContentManager.ContentType contentType,
                             String path)
Returns the file path chosen by user with a save file dialog. If this file already exists, the user will be prompted whether he wants to overwrite this existing file.

Specified by:
showSaveDialog in interface ContentManager
Returns:
the chosen file path or null if user canceled its choice.

getLastDirectory

protected File getLastDirectory(ContentManager.ContentType contentType)
Returns the last directory used for the given content type.

Returns:
the last directory for contentType or the default last directory if it's not set. If contentType is null, the returned directory will be the default last one or null if it's not set yet.

setLastDirectory

protected void setLastDirectory(ContentManager.ContentType contentType,
                                File directory)
Stores the last directory for the given content type.


getFileDialogTitle

protected String getFileDialogTitle(boolean save)
Returns default file dialog title.


confirmOverwrite

protected boolean confirmOverwrite(View parentView,
                                   String path)
Displays a dialog that let user choose whether he wants to overwrite file path or not.

Returns:
true if user confirmed to overwrite.

Sweet Home 3D 4.1

© Copyrights 2006-2013 eTeks - All rights reserved
Distributed under GNU General Public License