-/**
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
*
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.ws.jws2;
+import jalview.api.AlignCalcWorkerI;
+import jalview.gui.AlignFrame;
+import jalview.gui.Desktop;
+import jalview.gui.JvSwingUtils;
+import jalview.util.MessageManager;
+import jalview.ws.api.ServiceWithParameters;
+import jalview.ws.params.AutoCalcSetting;
+import jalview.ws.params.WsParamSetI;
+import jalview.ws.uimodel.AlignAnalysisUIText;
+
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-
-import compbio.metadata.Argument;
-
-import jalview.api.AlignCalcWorkerI;
-import jalview.datamodel.AlignmentView;
-import jalview.gui.AlignFrame;
-import jalview.gui.Desktop;
-import jalview.gui.JalviewDialog;
-import jalview.gui.JvSwingUtils;
-import jalview.ws.jws2.jabaws2.Jws2Instance;
-import jalview.ws.params.WsParamSetI;
/**
- * @author jimp
+ * @author jprocter
*
*/
public class SequenceAnnotationWSClient extends Jws2Client
{
-
/**
* initialise a client so its attachWSMenuEntry method can be called.
*/
// TODO Auto-generated constructor stub
}
- public SequenceAnnotationWSClient(final Jws2Instance sh,
+ public SequenceAnnotationWSClient(final ServiceWithParameters sh,
AlignFrame alignFrame, WsParamSetI preset, boolean editParams)
{
super(alignFrame, preset, null);
- if (alignFrame.getViewport().getAlignment().isNucleotide())
- {
- JOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
- + " can only be used\nfor amino acid alignments.",
- "Wrong type of sequences!", JOptionPane.WARNING_MESSAGE);
- return;
+ initSequenceAnnotationWSClient(sh, alignFrame, preset, editParams);
+ }
- }
- if (sh.action.toLowerCase().contains("conservation"))
+ // 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)
+ {
+ // dan changed! dan test. comment out if conditional
+ // if (alignFrame.getViewport().getAlignment().isNucleotide())
+ // {
+ // JvOptionPane.showMessageDialog(Desktop.desktop, sh.serviceType
+ // + " can only be used\nfor amino acid alignments.",
+ // "Wrong type of sequences!", JvOptionPane.WARNING_MESSAGE);
+ // return;
+ //
+ // }
+ AlignAnalysisUIText aaui = sh.getAlignAnalysisUI();
+ if (aaui != null)
{
- // Build an AACons style client - take alignment, return annotation for
+ Class clientClass = aaui.getClient();
+
+ // Build an AACon style client - take alignment, return annotation for
// columns
List<AlignCalcWorkerI> clnts = alignFrame.getViewport()
.getCalcManager()
- .getRegisteredWorkersOfClass(AAConsClient.class);
- if (clnts == null || clnts.size() == 0)
+ .getRegisteredWorkersOfClass(SeqAnnotationServiceCalcWorker.class);
+
+ SeqAnnotationServiceCalcWorker worker = null;
+ if (clnts != null)
+ {
+ for (AlignCalcWorkerI _worker : clnts)
+ {
+ worker = (SeqAnnotationServiceCalcWorker) _worker;
+ if (worker.hasService()
+ && worker.getService().getClass().equals(clientClass))
+ {
+ break;
+ }
+ worker = null;
+ }
+ }
+ if (worker == null)
{
if (!processParams(sh, editParams))
{
return;
}
- alignFrame
- .getViewport()
- .getCalcManager()
- .registerWorker(
- new AAConsClient(sh, alignFrame, preset, paramset));
+ try
+ {
+ worker = new SeqAnnotationServiceCalcWorker(sh, alignFrame, this.preset,
+ paramset);
+ } catch (Exception x)
+ {
+ x.printStackTrace();
+ throw new Error(
+ MessageManager.getString("error.implementation_error"),
+ x);
+ }
+ alignFrame.getViewport().getCalcManager().registerWorker(worker); // also
+ // starts
+ // the
+ // worker
}
else
{
- AAConsClient worker = (AAConsClient) clnts.get(0);
if (editParams)
{
paramset = worker.getArguments();
}
if (!processParams(sh, editParams, true))
+ {
return;
+ }
// reinstate worker if it was blacklisted (might have happened due to
// invalid parameters)
- alignFrame.getViewport().getCalcManager().workerMayRun(worker);
- worker.updateParameters(preset, paramset);
-
+ alignFrame.getViewport().getCalcManager().enableWorker(worker);
+ worker.updateParameters(this.preset, paramset);
}
}
- if (sh.action.toLowerCase().contains("disorder"))
+ if (!sh.isInteractiveUpdate())
{
// build IUPred style client. take sequences, returns annotation per
// sequence.
return;
}
- alignFrame
- .getViewport()
- .getCalcManager()
- .startWorker(
- new AADisorderClient(sh, alignFrame, preset, paramset));
+ alignFrame.getViewport().getCalcManager().startWorker(
+ new SeqAnnotationServiceCalcWorker(sh, alignFrame, preset, paramset));
}
+ }
+ public SequenceAnnotationWSClient(AutoCalcSetting fave,
+ AlignFrame alignFrame, boolean b)
+ {
+ super(alignFrame, fave.getPreset(), fave.getArgumentSet());
+ initSequenceAnnotationWSClient(fave.getService(), alignFrame,
+ fave.getPreset(), b);
}
/*
* @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu,
* jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame)
*/
- public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service,
+ @Override
+ public void attachWSMenuEntry(JMenu wsmenu,
+ final ServiceWithParameters service,
final AlignFrame alignFrame)
{
+ if (Jws2ClientFactory.registerAAConWSInstance(wsmenu,
+ service, alignFrame))
+ {
+ // Alignment dependent analysis calculation WS gui
+ return;
+ }
boolean hasparams = service.hasParameters();
- // Assume name ends in WS
- String calcName = service.serviceType.substring(0,
- service.serviceType.length() - 2);
+ String calcName = service.getName();
+ if (calcName.endsWith("WS"))
+ {
+ // Remove "WS" suffix
+ calcName = calcName.substring(0, calcName.length() - 2);
+ }
- JMenuItem aacons = new JMenuItem(calcName + " Defaults");
- aacons.addActionListener(new ActionListener()
+ JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage(
+ "label.calcname_with_default_settings", new String[]
+ { calcName }));
+ annotservice.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- new SequenceAnnotationWSClient(service, alignFrame, null, false);
+ new SequenceAnnotationWSClient(service, alignFrame,
+ null, false);
}
});
- wsmenu.add(aacons);
+ wsmenu.add(annotservice);
if (hasparams)
{
// only add these menu options if the service has user-modifiable
// arguments
- aacons = new JMenuItem("Edit settings and run ...");
- aacons.setToolTipText("View and change parameters before running calculation");
+ annotservice = new JMenuItem(
+ MessageManager.getString("label.edit_settings_and_run"));
+ annotservice.setToolTipText(MessageManager.getString(
+ "label.view_and_change_parameters_before_running_calculation"));
- aacons.addActionListener(new ActionListener()
+ annotservice.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
- new SequenceAnnotationWSClient(service, alignFrame, null, true);
+ new SequenceAnnotationWSClient(service, alignFrame,
+ null, true);
}
});
- wsmenu.add(aacons);
+ wsmenu.add(annotservice);
List<WsParamSetI> presets = service.getParamStore().getPresets();
if (presets != null && presets.size() > 0)
{
- JMenu presetlist = new JMenu("Run " + calcName + "with preset");
+ JMenu presetlist = new JMenu(MessageManager
+ .formatMessage("label.run_with_preset", new String[]
+ { calcName }));
for (final WsParamSetI preset : presets)
{
final JMenuItem methodR = new JMenuItem(preset.getName());
- methodR.setToolTipText("<html><p>"
- + JvSwingUtils.wrapTooltip("<strong>"
- + (preset.isModifiable() ? "User Preset"
- : "Service Preset") + "</strong><br/>"
- + preset.getDescription() + "</p>") + "</html>");
+ methodR.setToolTipText(JvSwingUtils.wrapTooltip(true, "<strong>"
+ + (preset.isModifiable()
+ ? MessageManager.getString("label.user_preset")
+ : MessageManager
+ .getString("label.service_preset"))
+ + "</strong><br/>" + preset.getDescription()));
methodR.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
- new SequenceAnnotationWSClient(service, alignFrame, preset,
+ new SequenceAnnotationWSClient(service,
+ alignFrame, preset,
false);
}
}
}
+ else
+ {
+ annotservice = new JMenuItem(
+ MessageManager.getString("label.view_documentation"));
+ if (service != null && service.hasDocumentationUrl())
+ {
+ annotservice.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent arg0)
+ {
+ Desktop.instance.showUrl(service.getDocumentationUrl());
+ }
+ });
+ annotservice.setToolTipText(
+ JvSwingUtils.wrapTooltip(true, MessageManager.formatMessage(
+ "label.view_service_doc_url", new String[]
+ { service.getDocumentationUrl(),
+ service.getDocumentationUrl() })));
+ wsmenu.add(annotservice);
+ }
+ }
}
}