author | Jaroslav Tulach <jtulach@netbeans.org> |
Sun, 01 Feb 2009 16:29:46 +0100 | |
changeset 312 | 0678c9589013 |
permissions | -rw-r--r-- |
jtulach@312 | 1 |
package org.apidesign.exceptions.trycatchredo.api; |
jtulach@312 | 2 |
|
jtulach@312 | 3 |
import java.net.URL; |
jtulach@312 | 4 |
import javax.swing.Action; |
jtulach@312 | 5 |
import javax.swing.JDialog; |
jtulach@312 | 6 |
import javax.swing.JOptionPane; |
jtulach@312 | 7 |
|
jtulach@312 | 8 |
/** |
jtulach@312 | 9 |
* |
jtulach@312 | 10 |
* @author Jaroslav Tulach <jtulach@netbeans.org> |
jtulach@312 | 11 |
*/ |
jtulach@312 | 12 |
public final class IOManager { |
jtulach@312 | 13 |
IOManager() { |
jtulach@312 | 14 |
} |
jtulach@312 | 15 |
|
jtulach@312 | 16 |
/** Action that can store a text to given URL. |
jtulach@312 | 17 |
* |
jtulach@312 | 18 |
* @param where the url to upload the text to |
jtulach@312 | 19 |
* @param what the text to upload |
jtulach@312 | 20 |
* @return action that can be invoked anytime to save the content |
jtulach@312 | 21 |
*/ |
jtulach@312 | 22 |
public static Action createSaveAction(URL where, CharSequence what) { |
jtulach@312 | 23 |
if (old) { |
jtulach@312 | 24 |
return new SaveAction(where, what); |
jtulach@312 | 25 |
} else { |
jtulach@312 | 26 |
return new SaveActionWithQuery(where, what); |
jtulach@312 | 27 |
} |
jtulach@312 | 28 |
} |
jtulach@312 | 29 |
|
jtulach@312 | 30 |
// |
jtulach@312 | 31 |
// Support for executing mock objects in tests |
jtulach@312 | 32 |
// |
jtulach@312 | 33 |
|
jtulach@312 | 34 |
static boolean old; |
jtulach@312 | 35 |
static Object setVisibleOption; |
jtulach@312 | 36 |
static void setVisible(JDialog d, JOptionPane p) { |
jtulach@312 | 37 |
if (setVisibleOption == null) { |
jtulach@312 | 38 |
d.setVisible(true); |
jtulach@312 | 39 |
} else { |
jtulach@312 | 40 |
// only in test mode |
jtulach@312 | 41 |
p.setValue(setVisibleOption); |
jtulach@312 | 42 |
} |
jtulach@312 | 43 |
} |
jtulach@312 | 44 |
} |