86 lines
2.8 KiB
Java
86 lines
2.8 KiB
Java
|
|
/*
|
||
|
|
* Copyright (c) 2003,2009 Declarative Engineering LLC.
|
||
|
|
* All rights reserved. This program and the accompanying materials
|
||
|
|
* are made available under the terms of the Declarative Engineering LLC
|
||
|
|
* verson 1 which accompanies this distribution, and is available at
|
||
|
|
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||
|
|
*/
|
||
|
|
package com.foundation.view.swt;
|
||
|
|
|
||
|
|
import com.common.debug.*;
|
||
|
|
import com.foundation.view.*;
|
||
|
|
|
||
|
|
public class DirectoryDialog extends Dialog {
|
||
|
|
public static final String fileSeparator = System.getProperty("file.separator");
|
||
|
|
/**
|
||
|
|
* DirectoryDialog constructor.
|
||
|
|
* @param parent The parent view which is required for this dialog.
|
||
|
|
*/
|
||
|
|
public DirectoryDialog(IView parent) {
|
||
|
|
super();
|
||
|
|
|
||
|
|
if(parent instanceof Container) {
|
||
|
|
setSwtDialog(new org.eclipse.swt.widgets.DirectoryDialog(((Container) parent).getSwtControl().getShell()));
|
||
|
|
}//if//
|
||
|
|
else {
|
||
|
|
Debug.log("Error: Cannot create a dialog without a valid SWT parent control.");
|
||
|
|
}//else//
|
||
|
|
}//DirectoryDialog()//
|
||
|
|
/**
|
||
|
|
* DirectoryDialog constructor.
|
||
|
|
* @param parent The parent view which is required for this dialog.
|
||
|
|
* @param style No styles are currently permissable.
|
||
|
|
*/
|
||
|
|
public DirectoryDialog(IView parent, int style) {
|
||
|
|
super();
|
||
|
|
|
||
|
|
if(parent instanceof Container) {
|
||
|
|
setSwtDialog(new org.eclipse.swt.widgets.DirectoryDialog(((Container) parent).getSwtControl().getShell(), style));
|
||
|
|
}//if//
|
||
|
|
else {
|
||
|
|
Debug.log("Error: Cannot create a dialog without a valid SWT parent control.");
|
||
|
|
}//else//
|
||
|
|
}//DirectoryDialog()//
|
||
|
|
/**
|
||
|
|
* Gets the SWT directory dialog instance.
|
||
|
|
* @return The SWT directory dialog.
|
||
|
|
*/
|
||
|
|
private org.eclipse.swt.widgets.DirectoryDialog getSwtDirectoryDialog() {
|
||
|
|
return (org.eclipse.swt.widgets.DirectoryDialog) getSwtDialog();
|
||
|
|
}//getSwtDirectoryDialog()//
|
||
|
|
/**
|
||
|
|
* Gets the dialog message.
|
||
|
|
* @return The message to be displayed to the user.
|
||
|
|
*/
|
||
|
|
public String getMessage() {
|
||
|
|
return getSwtDirectoryDialog().getMessage();
|
||
|
|
}//getMessage()//
|
||
|
|
/**
|
||
|
|
* Sets the dialog message.
|
||
|
|
* @param message The message to be displayed to the user.
|
||
|
|
*/
|
||
|
|
public void setMessage(String message) {
|
||
|
|
getSwtDirectoryDialog().setMessage(message);
|
||
|
|
}//setMessage()//
|
||
|
|
/**
|
||
|
|
* Gets the directory path the user will see.
|
||
|
|
* @return The directory seen by the user.
|
||
|
|
*/
|
||
|
|
public String getFilterPath() {
|
||
|
|
return getSwtDirectoryDialog().getFilterPath();
|
||
|
|
}//getFilterPath()//
|
||
|
|
/**
|
||
|
|
* Sets the directory path the user will see.
|
||
|
|
* @param filterPath The directory seen by the user.
|
||
|
|
*/
|
||
|
|
public void setFilterPath(String filterPath) {
|
||
|
|
getSwtDirectoryDialog().setFilterPath(filterPath);
|
||
|
|
}//setFilterPath()//
|
||
|
|
/**
|
||
|
|
* Opens the dialog making it visible to the user.
|
||
|
|
* @return The directory of the first selected file. This will be null if an error occured.
|
||
|
|
*/
|
||
|
|
public String open() {
|
||
|
|
return getSwtDirectoryDialog().open();
|
||
|
|
}//open()//
|
||
|
|
}//DirectoryDialog//
|