|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ptc.windchill.upgrade.util.ThreadedCancelConfirmPrompt
A class that displays a JOptionPane dialog with a YES_NO option to confirm cancellation of a threaded work task. Allows the worker thread to decide if the work should continue while the user is being prompted.
Field Summary | |
private ThreadedOptionPane |
cancelOptionPane_
|
private boolean |
cancelRequested_
|
Constructor Summary | |
ThreadedCancelConfirmPrompt(String title,
String question)
|
Method Summary | |
void |
closePromptIfOpen()
Close the prompt if it's open. |
boolean |
hasCancelBeenRequested(boolean block_if_deciding)
Worker threads can call this if they want to halt work while the prompt is open and a decision has not yet been made. |
protected void |
onCancelRequested()
Subclasses can override this to do additional work when confirmation of a cancel is actually made. |
void |
openPromptIfNotOpen(Component parent_component)
Display a JDialog for the prompt if one is not currently open AND a cancel confirmation hasn't already been made. |
void |
reset()
Resets the cancel requested state so that an instance can be used over and over for confirming cancellations. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private ThreadedOptionPane cancelOptionPane_
private boolean cancelRequested_
Constructor Detail |
public ThreadedCancelConfirmPrompt(String title, String question)
Method Detail |
public boolean hasCancelBeenRequested(boolean block_if_deciding)
public void run() { ThreadedCancelConfirmPrompt cancel_prompt = ...; // add cancel action that makes canceled() return true while(!cancel_prompt.hasCancelBeenRequested(true)) { // block if prompting ... do work ... } ... }
hasCancelBeenRequested
in interface CancellationMonitor
block_if_deciding
- If true, block the caller if the decision is in progress, and return once a decision has been made. Otherwise, return the latest decision immediately.public void reset()
public void openPromptIfNotOpen(Component parent_component)
public void closePromptIfOpen()
public void run() { ThreadedCancelConfrmPrompt cancel_prompt = ...; try { ... do work ... } finally { cancel_prompt.closePromptIfOpen(); // makes sure you don't leave the dialog open } }
protected void onCancelRequested()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |