Edit settings dialog now works asynchronously.
Annotation services still do not add annotations to the sequences.
{
WsParamSetI set = new HMMERPreset();
WsJobParameters params = new WsJobParameters(store, set, args);
- if (params.showRunDialog())
- {
- args = params.getJobParams();
- }
- else
- {
- return; // user cancelled
- }
+ params.showRunDialog().thenAccept((startJob) -> {
+ if (startJob)
+ {
+ var args2 = params.getJobParams();
+ new Thread(new HMMBuild(this, args2)).start();
+ }
+ });
+ }
+ else
+ {
+ new Thread(new HMMBuild(this, args)).start();
}
- new Thread(new HMMBuild(this, args)).start();
}
@Override
{
WsParamSetI set = new HMMERPreset();
WsJobParameters params = new WsJobParameters(store, set, args);
- if (params.showRunDialog())
- {
- args = params.getJobParams();
- }
- else
- {
- return; // user cancelled
- }
+ params.showRunDialog().thenAccept((startJob) -> {
+ if (startJob)
+ {
+ var args2 = params.getJobParams();
+ new Thread(new HMMAlign(this, args2)).start();
+ }
+ });
+ }
+ else
+ {
+ new Thread(new HMMAlign(this, args)).start();
}
- new Thread(new HMMAlign(this, args)).start();
}
@Override
{
WsParamSetI set = new HMMERPreset();
WsJobParameters params = new WsJobParameters(store, set, args);
- if (params.showRunDialog())
- {
- args = params.getJobParams();
- }
- else
- {
- return; // user cancelled
- }
+ params.showRunDialog().thenAccept((startJob) -> {
+ if (startJob)
+ {
+ var args2 = params.getJobParams();
+ new Thread(new HMMSearch(this, args2)).start();
+ alignPanel.repaint();
+ }
+ });
+ }
+ else
+ {
+ new Thread(new HMMSearch(this, args)).start();
+ alignPanel.repaint();
}
- new Thread(new HMMSearch(this, args)).start();
- alignPanel.repaint();
}
@Override
{
WsParamSetI set = new HMMERPreset();
WsJobParameters params = new WsJobParameters(store, set, args);
- if (params.showRunDialog())
- {
- args = params.getJobParams();
- }
- else
- {
- return; // user cancelled
- }
+ params.showRunDialog().thenAccept((startJob) -> {
+ if (startJob)
+ {
+ var args2 = params.getJobParams();
+ new Thread(new JackHMMER(this, args2)).start();
+ alignPanel.repaint();
+ }
+ });
+ }
+ else
+ {
+ new Thread(new JackHMMER(this, args)).start();
+ alignPanel.repaint();
}
- new Thread(new JackHMMER(this, args)).start();
- alignPanel.repaint();
-
}
/**
import java.util.Hashtable;
import java.util.List;
import java.util.Vector;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
+import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
+import javax.swing.WindowConstants;
import javax.swing.border.TitledBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
// TODO ABSRACT FROM JABAWS CLASSES
+ // completion stage representing whether start was clicked
+ private final CompletableFuture<Boolean> completionStage = new CompletableFuture<>();
+
/**
* manager for options and parameters.
*/
JTextArea setDescr = new JTextArea();
JScrollPane paramPane = new JScrollPane();
+
+ JButton startjob = JvSwingUtils.makeButton(
+ MessageManager.getString("action.start_job"),
+ MessageManager.getString("label.start_job_current_settings"),
+ this::startjob_actionPerformed);
+ JButton canceljob = JvSwingUtils.makeButton(
+ MessageManager.getString("action.cancel_job"),
+ MessageManager.getString("label.cancel_job_close_dialog"),
+ this::canceljob_actionPerformed);
ParamDatastoreI paramStore;
// set true when 'Start Job' is clicked
boolean startJob = false;
- JDialog frame = null;
+ JFrame frame = null;
UIinfo service;
*
* @return
*/
- public boolean showRunDialog()
+ public CompletionStage<Boolean> showRunDialog()
{
-
- frame = new JDialog(Desktop.getInstance(), true);
+ frame = new JFrame();
+ frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
if (service != null)
{
frame.setTitle(MessageManager.formatMessage("label.edit_params_for",
}
});
+
frame.setVisible(true);
-
- return startJob;
+ return completionStage;
}
private void jbInit()
updatepref = JvSwingUtils.makeButton(
MessageManager.getString("action.update"),
MessageManager.getString("label.update_user_parameter_set"),
- new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- update_actionPerformed();
- }
- });
+ this::update_actionPerformed);
deletepref = JvSwingUtils.makeButton(
MessageManager.getString("action.delete"),
MessageManager.getString("label.delete_user_parameter_set"),
- new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- delete_actionPerformed();
- }
- });
+ this::delete_actionPerformed);
createpref = JvSwingUtils.makeButton(
MessageManager.getString("action.create"),
MessageManager.getString("label.create_user_parameter_set"),
- new ActionListener()
- {
-
- @Override
- public void actionPerformed(ActionEvent e)
- {
- create_actionPerformed();
- }
- });
+ this::create_actionPerformed);
revertpref = JvSwingUtils.makeButton(
MessageManager.getString("action.revert"),
MessageManager
.getString("label.revert_changes_user_parameter_set"),
- new ActionListener()
- {
+ this::revert_actionPerformed);
- @Override
- public void actionPerformed(ActionEvent e)
- {
- revert_actionPerformed();
- }
- });
-
- JButton startjob = JvSwingUtils.makeButton(
- MessageManager.getString("action.start_job"),
- MessageManager.getString("label.start_job_current_settings"),
- new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- startjob_actionPerformed();
- }
- });
- JButton canceljob = JvSwingUtils.makeButton(
- MessageManager.getString("action.cancel_job"),
- MessageManager.getString("label.cancel_job_close_dialog"),
- new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent e)
- {
- canceljob_actionPerformed();
- }
- });
JPanel setDetails = new JPanel();
setDetails.setBorder(
validate();
}
- protected void revert_actionPerformed()
+ protected void revert_actionPerformed(ActionEvent e)
{
reInitDialog(lastParmSet);
updateWebServiceMenus();
}
- protected void update_actionPerformed()
+ protected void update_actionPerformed(ActionEvent e)
{
if (isUserPreset)
{
paramStore.deletePreset(lastParmSet2);
}
- protected void delete_actionPerformed()
+ protected void delete_actionPerformed(ActionEvent e)
{
if (isUserPreset)
{
updateWebServiceMenus();
}
- protected void create_actionPerformed()
+ protected void create_actionPerformed(ActionEvent e)
{
String curname = ((String) setName.getSelectedItem()).trim();
if (curname.length() > 0)
}
}
- protected void canceljob_actionPerformed()
+ protected void canceljob_actionPerformed(ActionEvent e)
{
startJob = false;
if (frame != null)
{
frame.setVisible(false);
}
+ completionStage.complete(false);
}
- protected void startjob_actionPerformed()
+ protected void startjob_actionPerformed(ActionEvent e)
{
startJob = true;
if (frame != null)
{
frame.setVisible(false);
}
+ completionStage.complete(true);
}
void initForService(WsParamSetI paramSet, List<ArgumentI> jobArgset)
*/
package jalview.ws;
+import jalview.bin.Cache;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
import jalview.gui.WebserviceInfo;
import jalview.ws.params.WsParamSetI;
import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
public abstract class WSClient // implements WSMenuEntryProviderI
{
* @param arguments
*/
public WSClient(AlignFrame _alignFrame, WsParamSetI preset,
- List<ArgumentI> arguments)
+ List<ArgumentI> arguments)
{
alignFrame = _alignFrame;
this.preset = preset;
if (!b)
{
return new WebserviceInfo(WebServiceJobTitle,
- WebServiceJobTitle + " using service hosted at "
- + WsURL + "\n"
- + (serv.getDescription() != null
- ? serv.getDescription()
- : ""),
- false);
+ WebServiceJobTitle + " using service hosted at "
+ + WsURL + "\n"
+ + (serv.getDescription() != null
+ ? serv.getDescription()
+ : ""),
+ false);
}
return null;
}
* @param editParams
* @return
*/
- protected boolean processParams(ServiceWithParameters sh,
- boolean editParams)
+ protected CompletionStage<Boolean> processParams(ServiceWithParameters sh,
+ boolean editParams)
{
return processParams(sh, editParams, false);
}
- protected boolean processParams(ServiceWithParameters sh,
- boolean editParams,
- boolean adjustingExisting)
+ protected CompletionStage<Boolean> processParams(ServiceWithParameters sh,
+ boolean editParams, boolean adjustingExisting)
{
if (editParams)
sh.initParamStore(Desktop.getUserParameterStore());
WsJobParameters jobParams = (preset == null && paramset != null
- && paramset.size() > 0)
- ? new WsJobParameters((ParamDatastoreI) null, sh,
- (WsParamSetI) null, paramset)
- : new WsJobParameters((ParamDatastoreI) null, sh,
- preset, (List<ArgumentI>) null);
+ && paramset.size() > 0)
+ ? new WsJobParameters((ParamDatastoreI) null, sh,
+ (WsParamSetI) null, paramset)
+ : new WsJobParameters((ParamDatastoreI) null, sh,
+ preset, (List<ArgumentI>) null);
if (adjustingExisting)
{
jobParams.setName(MessageManager
- .getString("label.adjusting_parameters_for_calculation"));
+ .getString("label.adjusting_parameters_for_calculation"));
}
- if (!jobParams.showRunDialog())
- {
- return false; // dialog cancelled
- }
-
- WsParamSetI prset = jobParams.getPreset();
- if (prset == null)
- {
- paramset = jobParams.isServiceDefaults() ? null
+ var stage = jobParams.showRunDialog();
+ return stage.thenApply((startJob) -> {
+ if (startJob)
+ {
+ WsParamSetI prset = jobParams.getPreset();
+ if (prset == null)
+ {
+ paramset = jobParams.isServiceDefaults() ? null
: jobParams.getJobParams();
- this.preset = null;
- }
- else
- {
- this.preset = prset; // ((JabaPreset) prset).p;
- paramset = null; // no user supplied parameters.
- }
+ this.preset = null;
+ }
+ else
+ {
+ this.preset = prset; // ((JabaPreset) prset).p;
+ paramset = null; // no user supplied parameters.
+ }
+ }
+ return startJob;
+ });
+
}
- return true;
+ return CompletableFuture.completedFuture(true);
}
}
AlignFrame _alignFrame)
{
super(_alignFrame, preset, arguments);
- if (!processParams(sh, editParams))
- {
- return;
- }
-
- if (!(sh instanceof JalviewServiceEndpointProviderI
- && ((JalviewServiceEndpointProviderI) sh)
- .getEndpoint() instanceof MultipleSequenceAlignmentI))
- {
- // redundant at mo - but may change
- JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
- MessageManager.formatMessage(
- "label.service_called_is_not_msa_service",
- new String[]
- { sh.getName() }),
- MessageManager.getString("label.internal_jalview_error"),
- JvOptionPane.WARNING_MESSAGE);
-
- return;
- }
- serviceHandle = sh;
- server = (MultipleSequenceAlignmentI) ((JalviewServiceEndpointProviderI) sh)
- .getEndpoint();
- if ((wsInfo = setWebService(sh, false)) == null)
- {
- JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), MessageManager
- .formatMessage("label.msa_service_is_unknown", new String[]
- { sh.getName() }),
- MessageManager.getString("label.internal_jalview_error"),
- JvOptionPane.WARNING_MESSAGE);
-
- return;
- }
-
- startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
-
+ processParams(sh, editParams).thenAccept((startJob) -> {
+ if (!startJob)
+ return;
+
+ if (!(sh instanceof JalviewServiceEndpointProviderI
+ && ((JalviewServiceEndpointProviderI) sh)
+ .getEndpoint() instanceof MultipleSequenceAlignmentI))
+ {
+ // redundant at mo - but may change
+ JvOptionPane.showMessageDialog(Desktop.getDesktopPane(),
+ MessageManager.formatMessage(
+ "label.service_called_is_not_msa_service",
+ new String[]
+ { sh.getName() }),
+ MessageManager.getString("label.internal_jalview_error"),
+ JvOptionPane.WARNING_MESSAGE);
+
+ return;
+ }
+ serviceHandle = sh;
+ server = (MultipleSequenceAlignmentI) ((JalviewServiceEndpointProviderI) sh)
+ .getEndpoint();
+ if ((wsInfo = setWebService(sh, false)) == null)
+ {
+ JvOptionPane.showMessageDialog(Desktop.getDesktopPane(), MessageManager
+ .formatMessage("label.msa_service_is_unknown", new String[]
+ { sh.getName() }),
+ MessageManager.getString("label.internal_jalview_error"),
+ JvOptionPane.WARNING_MESSAGE);
+
+ return;
+ }
+
+ startMsaWSClient(altitle, msa, submitGaps, preserveOrder, seqdataset);
+ });
}
public MsaWSClient()
// dan think. Do I need to change this method to run RNAalifold through the
// GUI
- public void initSequenceAnnotationWSClient(final ServiceWithParameters sh,
- AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
+ private void initSequenceAnnotationWSClient(final ServiceWithParameters sh,
+ AlignFrame alignFrame, final WsParamSetI preset, boolean editParams)
{
// dan changed! dan test. comment out if conditional
// if (alignFrame.getViewport().getAlignment().isNucleotide())
// columns
List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
- .getCalcManager()
- .getWorkersOfClass(SeqAnnotationServiceCalcWorker.class);
+ .getCalcManager()
+ .getWorkersOfClass(SeqAnnotationServiceCalcWorker.class);
- SeqAnnotationServiceCalcWorker worker = null;
+ SeqAnnotationServiceCalcWorker tmpworker = null;
if (clnts != null)
{
for (AlignCalcWorkerI _worker : clnts)
{
- worker = (SeqAnnotationServiceCalcWorker) _worker;
- if (worker.hasService()
- && worker.getService().getClass().equals(clientClass))
+ tmpworker = (SeqAnnotationServiceCalcWorker) _worker;
+ if (tmpworker.hasService()
+ && tmpworker.getService().getClass().equals(clientClass))
{
break;
}
- worker = null;
+ tmpworker = null;
}
}
+ final var worker = tmpworker;
if (worker == null)
{
- if (!processParams(sh, editParams))
- {
- return;
- }
- try
- {
- worker = new SeqAnnotationServiceCalcWorker(sh, alignFrame, this.preset,
+ processParams(sh, editParams).thenAccept((startJob) -> {
+ if (startJob)
+ {
+ final SeqAnnotationServiceCalcWorker worker_;
+ try
+ {
+ worker_ = new SeqAnnotationServiceCalcWorker(sh, alignFrame, this.preset,
paramset);
- } catch (Exception x)
- {
- x.printStackTrace();
- throw new Error(
+ } catch (Exception x)
+ {
+ x.printStackTrace();
+ throw new Error(
MessageManager.getString("error.implementation_error"),
x);
- }
- alignFrame.getViewport().getCalcManager().registerWorker(worker); // also
- // starts
- // the
- // worker
+ }
+ alignFrame.getViewport().getCalcManager().registerWorker(worker_);
+ // also starts the worker
+ startSeqAnnotationWorker(sh, alignFrame, preset, editParams);
+ }
+ });
}
else
{
+ WsParamSetI preset_;
if (editParams)
{
paramset = worker.getArguments();
- preset = worker.getPreset();
+ preset_ = worker.getPreset();
+ }
+ else
+ {
+ preset_ = preset;
}
+ processParams(sh, editParams, true).thenAccept((startJob) -> {
+ if (startJob)
+ {
+ // reinstate worker if it was blacklisted (might have happened due
+ // to
+ // invalid parameters)
+ alignFrame.getViewport().getCalcManager().enableWorker(worker);
+ worker.updateParameters(this.preset, paramset);
+ startSeqAnnotationWorker(sh, alignFrame, preset_, editParams);
+ }
+ });
- if (!processParams(sh, editParams, true))
+ if (!processParams(sh, editParams, true).toCompletableFuture().join())
{
return;
}
- // reinstate worker if it was blacklisted (might have happened due to
- // invalid parameters)
- alignFrame.getViewport().getCalcManager().enableWorker(worker);
- worker.updateParameters(this.preset, paramset);
}
}
+ else
+ {
+ startSeqAnnotationWorker(sh, alignFrame, preset, editParams);
+ }
+ }
+
+ private void startSeqAnnotationWorker(ServiceWithParameters sh,
+ AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
+ {
if (!sh.isInteractiveUpdate())
{
// build IUPred style client. take sequences, returns annotation per
// sequence.
- if (!processParams(sh, editParams))
- {
- return;
- }
-
- alignFrame.getViewport().getCalcManager().startWorker(
+ processParams(sh, editParams).thenAccept((startJob) -> {
+ if (startJob)
+ {
+ alignFrame.getViewport().getCalcManager().startWorker(
new SeqAnnotationServiceCalcWorker(sh, alignFrame, preset, paramset));
+ }
+ });
}
}