Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package net.sf.gluebooster.java.booster.basic.gui;
import javax.swing.JOptionPane;
import net.sf.gluebooster.java.booster.essentials.utils.Constants;
/**
* Configuration of a dialog.
*
* @defaultParamText fileMustExist must the file exist?
*
* @author cbauer
*
*/
public class DialogConfiguration {
// /**
// * The type to choose a file and not a directory
// */
// public static final int TYPE_CHOOSE_FILE = -1;
//
// /**
// * The type to choose a directory and not a file
// */
// public static final int TYPE_CHOOSE_DIRECTORY = -2;
//
// public static final int TYPE_OK_CANCEL = -3;
/**
* The parent (component) of the dialog.
*/
private Object parent;
/**
* The message of the dialog;
*/
private Object message;
/**
* The title of the dialog
*/
private String title;
/**
* The type of the options. Uses:
*
* @see JOptionPane
*/
private Object type;
/**
* The initial value of the dialog;
*/
private Object initialValue;
/**
* should an exception be thrown when nothing is entered/found or the dialog is cancelled.
*/
private boolean throwExceptionIfNothingSelected;
/**
* Must the result of the dialog exist (not be null, existing file).
*/
private boolean resultMustExist;
/**
* Should the initial value be returned if the dialog is cancelled.
*/
private boolean returnValueIfCancelled = false;
/**
* Create a configuration to choose a file.
*
* @return the created configuration
*/
public static DialogConfiguration chooseFile(String title, boolean fileMustExist) {
DialogConfiguration result = new DialogConfiguration(title, Constants.FILE, null, false);
result.resultMustExist = fileMustExist;
return result;
}
/**
* Create a configuration to choose a directory.
*
* @return the created configuration
*/
public static DialogConfiguration chooseDirectory(String title, boolean fileMustExist) {
DialogConfiguration result = new DialogConfiguration(title, Constants.DIRECTORY, null, false);
result.resultMustExist = fileMustExist;
return result;
}
/**
* Create a configuration for an ok-cancel-dialog.
*
* @return the created configuration
*/
public static DialogConfiguration okCancel(String title, String message) {
DialogConfiguration result = new DialogConfiguration(title, Constants.OK_CANCEL, null, false);
result.setMessage(message);
return result;
}
/**
* Create a configuration of a message dialog.
*
* @return the created configuration
*/
public static DialogConfiguration message(String title, String message) {
DialogConfiguration result = new DialogConfiguration(title, Constants.MESSAGE, null, false);
result.setMessage(message);
return result;
}
/**
* Create a configuration of a yes-no-dialog.
*
* @return the created configuration
*/
public static DialogConfiguration yesNo(String title, String message) {
DialogConfiguration result = new DialogConfiguration(title, Constants.YES_NO, null, false);
result.setMessage(message);
return result;
}
/**
* Create a configuration of an input dialog with one line.
*
* @param initialSelectionValue
* the initial value of the dialog
* @return the created configuration
*/
public static DialogConfiguration input(Object title, Object message, Object initialSelectionValue) {
DialogConfiguration result = new DialogConfiguration(title.toString(), Constants.INPUT, initialSelectionValue, false);
result.setMessage(message);
return result;
}
/**
* Create a configuration of an input dialog with multiple lines.
*
* @param initialSelectionValue
* the initial value of the dialog
* @return the created configuration
*/
public static DialogConfiguration inputText(Object title, Object message, Object initialSelectionValue) {
DialogConfiguration result = new DialogConfiguration(title.toString(), Constants.TEXT, initialSelectionValue, false);
result.setMessage(message);
return result;
}
/**
*
* @param optionType
* the type of the dialog according to the JOptionDialog
*/
private DialogConfiguration(Object parent, Object message, String title, int optionType) {
super();
this.parent = parent;
this.message = message;
this.title = title;
this.type = optionType;
}
/**
*
* @param value
* the initial value
*/
public DialogConfiguration(Object message, Object value) {
super();
this.message = message;
this.initialValue = value;
}
/**
*
* @param dialogType
* the type of the dialog
* @param value
* the initial value
* @param throwExceptionIfCancelled
* should an exception be thrown if the dialog is cancelled.
*/
private DialogConfiguration(String title, Object dialogType, Object value, boolean throwExceptionIfCancelled) {
this.title = title;
this.type = dialogType;
this.initialValue = value;
this.throwExceptionIfNothingSelected = throwExceptionIfCancelled;
}
public Object getParent() {
return parent;
}
public void setParent(Object parent) {
this.parent = parent;
}
public Object getMessage() {
return message;
}
public void setMessage(Object message) {
this.message = message;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Object getType() {
return type;
}
private void setType(Object optionType) {
this.type = optionType;
}
public Object getInitialValue() {
return initialValue;
}
public void setInitialValue(Object value) {
this.initialValue = value;
}
public boolean isThrowExceptionIfNothingSelected() {
return throwExceptionIfNothingSelected;
}
public void setThrowExceptionIfNothingSelected(boolean throwExceptionIfCancelled) {
this.throwExceptionIfNothingSelected = throwExceptionIfCancelled;
}
public boolean isResultMustExist() {
return resultMustExist;
}
public void setResultMustExist(boolean resultMustExist) {
this.resultMustExist = resultMustExist;
}
public boolean isReturnValueIfCancelled() {
return returnValueIfCancelled;
}
public void setReturnValueIfCancelled(boolean returnValueIfCancelled) {
this.returnValueIfCancelled = returnValueIfCancelled;
}
@Override
public String toString() {
return getClass().getSimpleName() + ": " + getType();
}
}