Skip to content

Commit

Permalink
Pick the latest version if there are multiple Philosopher versions in…
Browse files Browse the repository at this point in the history
… the directory.

Avoid the errors such as
#1727
#1719 (comment)
#1650 (comment)
  • Loading branch information
fcyu committed Aug 18, 2024
1 parent 039a3b0 commit fb8153c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@
import java.util.StringJoiner;

public class MessageLoadShepherdDefaults {
public final boolean doAskUser;

public final SearchTypeProp type;

public MessageLoadShepherdDefaults(boolean doAskUser, SearchTypeProp type) {
this.doAskUser = doAskUser;
public MessageLoadShepherdDefaults(SearchTypeProp type) {
this.type = type;
}

@Override
public String toString() {
return new StringJoiner(", ", MessageLoadShepherdDefaults.class.getSimpleName() + "[",
"]")
.add("doAskUser=" + doAskUser)
.add("type=" + type)
.toString();
}
Expand Down
6 changes: 1 addition & 5 deletions MSFragger-GUI/src/com/dmtavt/fragpipe/tabs/TabGlyco.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ private JPanel createPanelLoadGlycans() {
List<String> glycanDBnames = new ArrayList<>(glycanDBs.keySet());
glycanDBnames.add(0, "Custom"); // for custom DB loading
uiComboLoadBuiltinGlycans = UiUtils.createUiCombo(glycanDBnames);

JButton btnLoadGlycanMasses = new JButton("Load Glycan Database");
btnLoadGlycanMasses.addActionListener(this::actionBtnLoadGlycans);
btnLoadGlycanMasses.setToolTipText("Load glycans from a file. Supported formats: Byonic, pGlyco, text (.csv, .tsv, .txt, .glyc files)");
uiComboLoadBuiltinGlycans.addActionListener(this::actionBtnLoadGlycans);
textLoadGlycans = new UiText();

JButton btnEditGlycanResiduesTable = new JButton("Edit Glycan Residue Definitions");
Expand All @@ -125,7 +122,6 @@ private JPanel createPanelLoadGlycans() {

mu.add(p, jLabelLoadGlycanDB).split();
mu.add(p, uiComboLoadBuiltinGlycans).split();
mu.add(p, btnLoadGlycanMasses).spanX().split().wrap();
mu.add(p, textLoadGlycans).spanX().growX().wrap();
mu.add(p, btnEditGlycanResiduesTable).split();
mu.add(p, btnEditGlycanModsTable).split();
Expand Down
39 changes: 18 additions & 21 deletions MSFragger-GUI/src/com/dmtavt/fragpipe/tabs/TabWorkflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,14 @@ private JPanel createPanelWorkflows() {
epWorkflowsDesc.setText("");
}
});
JButton btnWorkflowLoad = UiUtils.createButton("Load workflow", this::actionLoadSelectedWorkflow);
uiComboWorkflows.addActionListener(this::actionLoadSelectedWorkflow);

FormEntry feComboWorkflow = Fragpipe.feNoCache(uiComboWorkflows, "workflow-option").label("Select a workflow:").tooltip("Conveniently loads appropriate defaults for various standard workflows\n").create();
JButton btnOpenInExplorer = SwingUtils.createButtonOpenInFileManager(this, "Open built-in folder", () -> FragpipeLocations.get().getDirWorkflows());

mu.add(p, epWorkflowsInfo).growX().spanX().wrap();
mu.add(p, feComboWorkflow.label()).split();
mu.add(p, feComboWorkflow.comp);
mu.add(p, btnWorkflowLoad);
mu.add(p, new JLabel("or save current settings as workflow")).gapLeft("15px");
mu.add(p, UiUtils.createButton("Save to built-in folder", e -> Bus.post(new MessageSaveAsWorkflow(false))));
mu.add(p, UiUtils.createButton("Save to custom folder", e -> Bus.post(new MessageSaveAsWorkflow(true))));
Expand Down Expand Up @@ -1734,28 +1734,25 @@ private void actionLoadSelectedWorkflow(ActionEvent e) {

Bus.post(new MessageLoadUi(propsFile, true, false));
} else {
int confirmation = SwingUtils.showConfirmDialog(this, new JLabel("Do you want to load workflow: " + workflow + "?"), "Confirmation");
if (JOptionPane.OK_OPTION == confirmation) {
log.debug("Loading workflow/ui state: {}", workflow);
PropsFile propsFile = workflows.get(workflow);
if (propsFile == null) {
SwingUtils.showErrorDialog(this, "Couldn't load workflow file: " + workflow, "Workflow loading error");
return;
}
log.debug("Loading workflow/ui state: {}", workflow);
PropsFile propsFile = workflows.get(workflow);
if (propsFile == null) {
SwingUtils.showErrorDialog(this, "Couldn't load workflow file: " + workflow, "Workflow loading error");
return;
}

log.debug("Reloading file from disk, in case it has changed: {}", propsFile.getPath());
try {
propsFile.load();
} catch (IOException ex) {
SwingUtils.showErrorDialogWithStacktrace(ex, this, true);
log.error("Error re-loading workflow file", ex);
}
log.debug("Reloading file from disk, in case it has changed: {}", propsFile.getPath());
try {
propsFile.load();
} catch (IOException ex) {
SwingUtils.showErrorDialogWithStacktrace(ex, this, true);
log.error("Error re-loading workflow file", ex);
}

if (propsFile.containsKey("workflow.workflow-option")) {
propsFile.setProperty("workflow.workflow-option", workflow);
}
Bus.post(new MessageLoadUi(propsFile, true, false));
if (propsFile.containsKey("workflow.workflow-option")) {
propsFile.setProperty("workflow.workflow-option", workflow);
}
Bus.post(new MessageLoadUi(propsFile, true, false));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import java.util.ArrayList;
import java.util.LinkedHashMap;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
Expand Down Expand Up @@ -138,11 +137,11 @@ protected void init() {
defaults.put("Non-Specific Search", SearchTypeProp.nonspecific);
defaults.put("Offset Search", SearchTypeProp.offset);
final UiCombo uiComboDefaults = UiUtils.createUiCombo(new ArrayList<>(defaults.keySet()));
JButton btnLoadDefaults = UiUtils
.createButton("Load", "Load PeptideProphet settings for given search type", e -> {
SearchTypeProp type = defaults.get((String) uiComboDefaults.getSelectedItem());
loadDefaults(type);
});
uiComboDefaults.addActionListener(e -> {
SearchTypeProp type = defaults.get((String) uiComboDefaults.getSelectedItem());
loadDefaults(type);
});

uiTextCmdOpts = UiUtils.uiTextBuilder().cols(20).text(defaultCmdOpts()).create();
FormEntry feCmdOpts = fe(uiTextCmdOpts, "cmd-opts")
.label("Cmd line opts:")
Expand All @@ -169,7 +168,6 @@ protected void init() {
mu.add(pTop, checkRun).split();
mu.add(pTop, labelDefaults);
mu.add(pTop, uiComboDefaults);
mu.add(pTop, btnLoadDefaults);
mu.add(pTop, uiCheckCombinePepxml).gapLeft("80px").wrap();

pContent = mu.newPanel(null, mu.lcFillXNoInsetsTopBottom());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import net.java.balloontip.BalloonTip;
Expand Down Expand Up @@ -199,13 +198,6 @@ protected String getComponentNamePrefix() {
@Subscribe
public void on(MessageLoadShepherdDefaults m) {
log.debug("Got MessageLoadShepherdDefaults: {}", m);
if (m.doAskUser) {
int answer = SwingUtils.showConfirmDialog(this, new JLabel(String.format("<html>Load PTMShepherd defaults for %s?", m.type.name())));
if (JOptionPane.OK_OPTION != answer) {
log.debug("User cancelled Loading Shepherd defaults");
return;
}
}
loadDefaults(2, m.type);
}

Expand Down Expand Up @@ -342,11 +334,10 @@ private JPanel createPanelTop() {
defaults.put("Offset Search", SearchTypeProp.offset);
defaults.put("Glyco Search", SearchTypeProp.glyco);
final UiCombo uiComboDefaults = UiUtils.createUiCombo(new ArrayList<>(defaults.keySet()));
JButton btnLoadDefaults = UiUtils
.createButton("Load", "Load PTM-Shepherd settings for given search type", e -> {
SearchTypeProp type = defaults.get(uiComboDefaults.getSelectedItem());
Bus.post(new MessageLoadShepherdDefaults(true, type));
});
uiComboDefaults.addActionListener(e -> {
SearchTypeProp type = defaults.get(uiComboDefaults.getSelectedItem());
Bus.post(new MessageLoadShepherdDefaults(type));
});

FormEntry feExtendedOut = new FormEntry(PROP_output_extended, "not-shown",
new UiCheck("Extended output", null, false),
Expand All @@ -365,7 +356,6 @@ private JPanel createPanelTop() {

mu.add(pTop, labelDefaults).split(4);
mu.add(pTop, uiComboDefaults);
mu.add(pTop, btnLoadDefaults);
mu.add(pTop, feExtendedOut.comp).wrap();

return pTop;
Expand Down

0 comments on commit fb8153c

Please sign in to comment.