|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ptc.windchill.upgrade.util.ThreadedOptionPane
A class that displays prompts that can be use to control worker threads. For example, this class can be used to show a "cancel work" dialog and if the user selects "cancel" run a command that will ask the worker thread to cancel what it is doing. Through use of the blockWhilePromptOpen() method you may control whether the worker thread will wait for a response before continuing.
Field Summary | |
private String |
message_
|
private int |
messageType_
|
private HashMap |
optionActionMap_
|
private JOptionPane |
optionPane_
|
private int |
optionType_
|
private JDialog |
promptDialog_
|
private Thread |
thread_
|
private String |
title_
|
Constructor Summary | |
ThreadedOptionPane(String message,
String title,
int message_type,
int option_type)
Create an instance that will open a JOptionPane with the specified arguments. |
Method Summary | |
void |
blockWhilePromptOpen()
Close the prompt if it's open. |
void |
closePromptIfOpen()
Worker threads should call this when they're done so that the prompt will go away when no longer needed. |
private void |
makeDialogNotVisible()
|
void |
openPromptIfNotOpen(Component parent_component)
Opens the prompt if it is not already open. |
void |
removeBehaviorForOption(int option)
Remove the behavior for the specified option. |
void |
setOptionBehavior(int option,
Runnable behavior)
Set the behavior that will be run when the user selects the given option. |
private void |
waitUpBlockers()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private String message_
private String title_
private int messageType_
private int optionType_
private HashMap optionActionMap_
private JDialog promptDialog_
private JOptionPane optionPane_
private Thread thread_
Constructor Detail |
public ThreadedOptionPane(String message, String title, int message_type, int option_type)
Method Detail |
public void setOptionBehavior(int option, Runnable behavior)
public void removeBehaviorForOption(int option)
public void openPromptIfNotOpen(Component parent_component)
private void waitUpBlockers()
public void closePromptIfOpen()
public void run() { ThreadedOptionPane prompt = ...; try { do work } finally { prompt.closePromptIfOpen(); } }
private void makeDialogNotVisible()
public void blockWhilePromptOpen()
public void run() { ThreadedOptionPane cancel_prompt = ...; // add cancel action that makes canceled() return true try { while(cancel_prompt.blockWhilePromptOpen() && !canceled()) { // canceled() second so that work is canceled as soon as possible after prompt closes do work } } finally { cancel_prompt.closePromptIfOpen(); } }
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |