本文整理汇总了Java中ca.sqlpower.swingui.SPSwingWorker类的典型用法代码示例。如果您正苦于以下问题:Java SPSwingWorker类的具体用法?Java SPSwingWorker怎么用?Java SPSwingWorker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SPSwingWorker类属于ca.sqlpower.swingui包,在下文中一共展示了SPSwingWorker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runInBackground
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void runInBackground(final Runnable runner) {
SPSwingWorker worker = new SPSwingWorker(this) {
@Override
public void doStuff() throws Exception {
runner.run();
}
@Override
public void cleanup() throws Exception {
//do nothing
}
};
new Thread(worker).start();
}
示例2: ActiveWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
ActiveWorker(@NonNull SPSwingWorker worker) {
if (worker == null) {
throw new NullPointerException("Null worker!");
}
this.worker = worker;
if (worker.getResponsibleObject() instanceof WabitObject) {
WabitObject responsibleObject = (WabitObject) worker.getResponsibleObject();
pathToResponsibleObject =
workspaceTreeModel.createTreePathForObject(responsibleObject);
} else {
pathToResponsibleObject = null;
}
}
示例3: removeSwingWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void removeSwingWorker(@NonNull final SPSwingWorker worker) {
synchronized (activeWorkers) {
for (Iterator<ActiveWorker> it = activeWorkers.iterator(); it.hasNext(); ) {
ActiveWorker aw = it.next();
if (aw.getWorker().equals(worker)) {
it.remove();
}
}
}
}
示例4: TaskTerminationEvent
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public TaskTerminationEvent(SPSwingWorker source) {
this.source = source;
}
示例5: getSource
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public SPSwingWorker getSource() {
return source;
}
示例6: registerSwingWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void registerSwingWorker(SPSwingWorker worker) {
workers.add(worker);
}
示例7: removeSwingWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void removeSwingWorker(SPSwingWorker worker) {
workers.remove(worker);
}
示例8: registerSwingWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void registerSwingWorker(SPSwingWorker worker) {
swingWorkers.add(worker);
}
示例9: removeSwingWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void removeSwingWorker(SPSwingWorker worker) {
swingWorkers.remove(worker);
}
示例10: showProgressWindow
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
/**
* This method displays a modal dialog that shows the progress of a
* workspace loading. The progress window will appear immediately and make
* the Wabit window unresponsive. When the worker completes the dialog will
* be disposed of and the Wabit window will become responsive again.
*
* @param parent
* The frame to parent the dialog to. This frame will be
* unresponsive while the progress dialog is displayed.
* @param worker
* The worker this progress window will monitor. When the worker
* finishes this dialog will go away.
*/
public static void showProgressWindow(final JFrame parent, final SPSwingWorker worker) {
final JDialog progressDialog = new JDialog(parent, "Loading");
final JLabel messageLabel = new JLabel("Loading");
final JProgressBar progressBar = new JProgressBar();
final JButton cancelButton = new JButton(new AbstractAction("Cancel") {
public void actionPerformed(ActionEvent e) {
worker.setCancelled(true);
}
});
// sticking the timer in an array so it can be accessed from inside the innerO class
final Timer[] timerHandle = new Timer[1];
timerHandle[0] = new Timer(50, new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (worker.isFinished() || worker.isCancelled()) {
timerHandle[0].stop();
progressDialog.setVisible(false);
progressDialog.dispose();
parent.setEnabled(true);
parent.toFront(); // hack for bug in Windows which sends parent behind other applications
}
}
});
timerHandle[0].start();
progressDialog.setLayout(new MigLayout("fillx"));
progressDialog.add(messageLabel, "grow, wrap");
progressDialog.add(progressBar, "grow, wrap");
progressDialog.add(cancelButton, "align right");
ProgressWatcher.watchProgress(progressBar, worker, messageLabel);
messageLabel.setMinimumSize(new Dimension(300, (int) messageLabel.getPreferredSize().getHeight()));
messageLabel.setPreferredSize(new Dimension(300, (int) messageLabel.getPreferredSize().getHeight()));
progressDialog.pack();
progressDialog.setLocationRelativeTo(parent);
progressDialog.setVisible(true);
parent.setEnabled(false);
}
示例11: registerSwingWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void registerSwingWorker(@NonNull SPSwingWorker worker) {
activeWorkers.add(new ActiveWorker(worker));
}
示例12: registerSwingWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void registerSwingWorker(SPSwingWorker worker) {
activeWorkers.add(worker);
}
示例13: removeSwingWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void removeSwingWorker(SPSwingWorker worker) {
activeWorkers.remove(worker);
}
示例14: close
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
public void close() {
for (SPSwingWorker worker : activeWorkers) {
worker.kill();
}
}
示例15: getWorker
import ca.sqlpower.swingui.SPSwingWorker; //导入依赖的package包/类
/**
* Returns the worker.
*
* @return The worker (never null)
*/
@NonNull
public SPSwingWorker getWorker() {
return worker;
}