Package com.iizigo.setup
Class UIFeedBack<RETURN_CODE>
- java.lang.Object
- com.iizigo.setup.UIFeedBack<RETURN_CODE>
- Type Parameters:
RETURN_CODE
- The return code.
- All Implemented Interfaces:
IUserInterfaceFeedback<RETURN_CODE>
public class UIFeedBack<RETURN_CODE> extends java.lang.Object implements IUserInterfaceFeedback<RETURN_CODE>
A feed-back class for the license system that can operate in headless or in non-SWT environments.- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CANCEL_STRING_CODE
The "\0" return code for cancel, to check by reference and not string comparison.protected RETURN_CODE
cancelCode
The cancel return code.
Constructor Summary
Constructors Constructor Description UIFeedBack(org.eclipse.swt.widgets.Shell parent, RETURN_CODE cancelCode)
A feed-back requires parent shell where dialog boxes are placed.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addCancelListener(java.lang.Runnable listener)
Adds a cancel listener.boolean
cancel()
Requests cancel of the feedback or dialog.void
createDialog(int type, java.lang.Object... params)
Creates the UI dialog.void
dispose()
Disposes of the dialog.RETURN_CODE
getCancelReturnCode()
Gets the cancel return code from the constructor parameter.org.eclipse.swt.widgets.Shell
getDialogShell()
Gets the dialog shell.org.eclipse.swt.widgets.Display
getDisplay()
Gets the display that is valid for the shells created, parent or dialog shell.RETURN_CODE
getReturnCode()
Gets the current return code.boolean
isCanceled()
Checks if cancel is requested by the user.RETURN_CODE
processDialogBlocked(java.lang.Thread threadToStart)
When this is method called from an unknown thread, it is blocked until the user feed-back dialog is closed.boolean
removeCancelListener(java.lang.Runnable listener)
Removes a cancel listener.void
setReturnCode(RETURN_CODE returnCode)
Assigns the return code BEFORE disposing the dialog.java.lang.String
updateFeedBack(java.lang.Object... objects)
Updates the feed-back dialog.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.iizix.license.IUserInterfaceFeedback
processDialogBlocked
Field Detail
CANCEL_STRING_CODE
public static final java.lang.String CANCEL_STRING_CODE
The "\0" return code for cancel, to check by reference and not string comparison.- See Also:
- Constant Field Values
cancelCode
protected final RETURN_CODE cancelCode
The cancel return code.
Constructor Detail
UIFeedBack
public UIFeedBack(org.eclipse.swt.widgets.Shell parent, RETURN_CODE cancelCode)
A feed-back requires parent shell where dialog boxes are placed.- Parameters:
parent
- The parent shell, null for none. If null, it will be the topmost one at the moment.cancelCode
- The cancel code.
Method Detail
getDialogShell
public final org.eclipse.swt.widgets.Shell getDialogShell()
Gets the dialog shell.- Returns:
- The shell of the dialog, and if not present, the shell of the parent opening the dialog.
createDialog
public void createDialog(int type, java.lang.Object... params)
Creates the UI dialog.- Specified by:
createDialog
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Parameters:
type
- Type of dialog: 1=connection feed-back, 2=final data received.params
- Parameters: params[0]=title, params[1]="Please wait...".
updateFeedBack
public java.lang.String updateFeedBack(java.lang.Object... objects)
Updates the feed-back dialog. This call can come from any thread.- Specified by:
updateFeedBack
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Parameters:
objects
- The objects to update.- Returns:
- The last String encountered, or null for none.
getDisplay
public final org.eclipse.swt.widgets.Display getDisplay()
Gets the display that is valid for the shells created, parent or dialog shell.- Returns:
- The display.
processDialogBlocked
public RETURN_CODE processDialogBlocked(java.lang.Thread threadToStart)
When this is method called from an unknown thread, it is blocked until the user feed-back dialog is closed.- Specified by:
processDialogBlocked
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Parameters:
threadToStart
- Thread to start when dialog is opened, null for none.- Returns:
- The return code Object, specific to the dialog type, null for CANCEL. If the "cancelCode" in the constructor has been set to e.g.
CANCEL_STRING_CODE
, this code will be returned as is, and NOT returnnull
.
getReturnCode
public RETURN_CODE getReturnCode()
Gets the current return code.- Specified by:
getReturnCode
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Returns:
- The return code, or null for none.
setReturnCode
public void setReturnCode(RETURN_CODE returnCode)
Assigns the return code BEFORE disposing the dialog. The dispose must be done usingdispose()
. This method can be called from any thread.- Specified by:
setReturnCode
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Parameters:
returnCode
- The return code Object, or null for cancel.
addCancelListener
public boolean addCancelListener(java.lang.Runnable listener)
Adds a cancel listener.- Specified by:
addCancelListener
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Parameters:
listener
- The listener to add.- Returns:
- true if added, false if already added.
removeCancelListener
public boolean removeCancelListener(java.lang.Runnable listener)
Removes a cancel listener.- Specified by:
removeCancelListener
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Parameters:
listener
- The listener to remove.- Returns:
- true if removed, false if already removed or never added.
getCancelReturnCode
public RETURN_CODE getCancelReturnCode()
Gets the cancel return code from the constructor parameter.- Specified by:
getCancelReturnCode
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Returns:
- The value passed in as
cancelCode
constructor parameterUIFeedBack(Shell, Object)
.
cancel
public boolean cancel()
Requests cancel of the feedback or dialog.- Specified by:
cancel
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Returns:
- true if cancel is accepted or false if rejected and ignored.
isCanceled
public boolean isCanceled()
Checks if cancel is requested by the user.- Specified by:
isCanceled
in interfaceIUserInterfaceFeedback<RETURN_CODE>
- Returns:
- true if cancel is requested, false otherwise.
dispose
public void dispose()
Disposes of the dialog. This method can be called from any thread.- Specified by:
dispose
in interfaceIUserInterfaceFeedback<RETURN_CODE>