Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google and Athena web links #76

Merged
merged 5 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/org/ohdsi/usagi/ui/AboutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@
public class AboutDialog extends JDialog {

private static final long serialVersionUID = 2028328868610404663L;
private JEditorPane text;

public AboutDialog() {
setTitle("About Usagi");
setTitle("About Usagi v" + UsagiMain.version);
setLayout(new GridBagLayout());

GridBagConstraints g = new GridBagConstraints();
Expand All @@ -60,9 +59,11 @@ public AboutDialog() {
g.gridx = 1;
g.gridy = 0;

text = new JEditorPane(
JEditorPane text = new JEditorPane(
"text/html",
"Usagi was developed by Martijn Schuemie in <a href=\"http://ohdsi.org\">Observational Health Data Sciences and Informatics</a> (OHDSI).<br/><br/>For help, please review the <a href =\"http://www.ohdsi.org/web/wiki/doku.php?id=documentation:software:usagi\">Usagi Wiki</a>.");
"Usagi was developed by Martijn Schuemie" +
"<br/>in <a href=\"http://ohdsi.org\">Observational Health Data Sciences and Informatics</a> (OHDSI)." +
"<br/><br/>For help, please review the <a href =\"http://www.ohdsi.org/web/wiki/doku.php?id=documentation:software:usagi\">Usagi Wiki</a>.");

text.setEditable(false);
text.setOpaque(false);
Expand Down
2 changes: 1 addition & 1 deletion src/org/ohdsi/usagi/ui/ConceptTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public Class<?> getColumnClass(int col) {
}

public boolean isCellEditable(int row, int col) {
return true;
return false;
}

public void setValueAt(Object value, int row, int col) {
Expand Down
14 changes: 7 additions & 7 deletions src/org/ohdsi/usagi/ui/DataChangeListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@

public interface DataChangeListener {

public static DataChangeEvent APPROVE_EVENT = new DataChangeEvent(true, false);
public static DataChangeEvent SIMPLE_UPDATE_EVENT = new DataChangeEvent(false, false);
public static DataChangeEvent RESTRUCTURE_EVENT = new DataChangeEvent(false, true);
DataChangeEvent APPROVE_EVENT = new DataChangeEvent(true, false);
DataChangeEvent SIMPLE_UPDATE_EVENT = new DataChangeEvent(false, false);
DataChangeEvent RESTRUCTURE_EVENT = new DataChangeEvent(false, true);

public void dataChanged(DataChangeEvent event);
void dataChanged(DataChangeEvent event);

public static class DataChangeEvent {
class DataChangeEvent {
public DataChangeEvent(boolean approved, boolean structureChange) {
this.approved = approved;
this.structureChange = structureChange;
}

public boolean approved = false;
public boolean structureChange = false;
public boolean approved;
public boolean structureChange;
}
}
18 changes: 3 additions & 15 deletions src/org/ohdsi/usagi/ui/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,7 @@

import org.ohdsi.usagi.BerkeleyDbEngine;
import org.ohdsi.usagi.UsagiSearchEngine;
import org.ohdsi.usagi.ui.actions.AboutAction;
import org.ohdsi.usagi.ui.actions.ApplyPreviousMappingAction;
import org.ohdsi.usagi.ui.actions.ApproveAction;
import org.ohdsi.usagi.ui.actions.ApproveAllAction;
import org.ohdsi.usagi.ui.actions.ClearAllAction;
import org.ohdsi.usagi.ui.actions.ConceptInformationAction;
import org.ohdsi.usagi.ui.actions.ExitAction;
import org.ohdsi.usagi.ui.actions.ExportForReviewAction;
import org.ohdsi.usagi.ui.actions.ExportSourceToConceptMapAction;
import org.ohdsi.usagi.ui.actions.ImportAction;
import org.ohdsi.usagi.ui.actions.OpenAction;
import org.ohdsi.usagi.ui.actions.RebuildIndexAction;
import org.ohdsi.usagi.ui.actions.SaveAction;
import org.ohdsi.usagi.ui.actions.SaveAsAction;
import org.ohdsi.usagi.ui.actions.ShowStatsAction;
import org.ohdsi.usagi.ui.actions.*;

public class Global {
public static JFrame frame;
Expand All @@ -57,6 +43,8 @@ public class Global {
public static ApproveAllAction approveAllAction;
public static ClearAllAction clearAllAction;
public static ConceptInformationAction conceptInfoAction;
public static AthenaAction athenaAction;
public static GoogleSearchAction googleSearchAction;
public static AboutAction aboutAction;
public static ExportSourceToConceptMapAction exportAction;
public static ExportForReviewAction exportForReviewAction;
Expand Down
52 changes: 26 additions & 26 deletions src/org/ohdsi/usagi/ui/MappingDetailPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,21 @@ private Component createSearchResultsPanel() {
searchTable.setPreferredScrollableViewportSize(new Dimension(100, 100));
searchTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
searchTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
searchTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
int viewRow = searchTable.getSelectedRow();
if (viewRow == -1) {
addButton.setEnabled(false);
replaceButton.setEnabled(false);
} else {
addButton.setEnabled(true);
replaceButton.setEnabled(true);
Global.conceptInfoAction.setEnabled(true);
int modelRow = searchTable.convertRowIndexToModel(viewRow);
Global.conceptInformationDialog.setConcept(searchTableModel.getConcept(modelRow));
}
searchTable.getSelectionModel().addListSelectionListener(event -> {
int viewRow = searchTable.getSelectedRow();
if (viewRow == -1) {
addButton.setEnabled(false);
replaceButton.setEnabled(false);
} else {
addButton.setEnabled(true);
replaceButton.setEnabled(true);
int modelRow = searchTable.convertRowIndexToModel(viewRow);
Global.conceptInfoAction.setEnabled(true);
Global.conceptInformationDialog.setConcept(searchTableModel.getConcept(modelRow));
Global.athenaAction.setEnabled(true);
Global.athenaAction.setConcept(searchTableModel.getConcept(modelRow));
Global.googleSearchAction.setEnabled(false);
}

});
// searchTable.hideColumn("Synonym");
searchTable.hideColumn("Valid start date");
Expand Down Expand Up @@ -321,19 +321,19 @@ private JPanel createTargetConceptsPanel() {
targetConceptTable.setPreferredScrollableViewportSize(new Dimension(500, 45));
targetConceptTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
targetConceptTable.setRowSelectionAllowed(true);
targetConceptTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
int viewRow = targetConceptTable.getSelectedRow();
if (viewRow == -1) {
removeButton.setEnabled(false);
} else {
removeButton.setEnabled(true);
Global.conceptInfoAction.setEnabled(true);
int modelRow = targetConceptTable.convertRowIndexToModel(viewRow);
Global.conceptInformationDialog.setConcept(targetConceptTableModel.getConcept(modelRow));
}
targetConceptTable.getSelectionModel().addListSelectionListener(event -> {
int viewRow = targetConceptTable.getSelectedRow();
if (viewRow == -1) {
removeButton.setEnabled(false);
} else {
removeButton.setEnabled(true);
int modelRow = targetConceptTable.convertRowIndexToModel(viewRow);
Global.conceptInfoAction.setEnabled(true);
Global.conceptInformationDialog.setConcept(targetConceptTableModel.getConcept(modelRow));
Global.athenaAction.setEnabled(true);
Global.athenaAction.setConcept(targetConceptTableModel.getConcept(modelRow));
Global.googleSearchAction.setEnabled(false);
}

});
targetConceptTable.hideColumn("Valid start date");
targetConceptTable.hideColumn("Valid end date");
Expand Down
44 changes: 25 additions & 19 deletions src/org/ohdsi/usagi/ui/MappingTablePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,32 @@ public MappingTablePanel() {
table.setPreferredScrollableViewportSize(new Dimension(1200, 200));
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
if (!ignoreSelection) {
int viewRow = table.getSelectedRow();
if (viewRow != -1) {
int modelRow = table.convertRowIndexToModel(viewRow);
for (CodeSelectedListener listener : listeners)
listener.codeSelected(tableModel.getCodeMapping(modelRow));
Global.approveAction.setEnabled(true);
Global.approveAllAction.setEnabled(true);
Global.clearAllAction.setEnabled(true);
if (tableModel.getCodeMapping(modelRow).targetConcepts.size() > 0) {
Global.conceptInfoAction.setEnabled(true);
Global.conceptInformationDialog.setConcept(tableModel.getCodeMapping(modelRow).targetConcepts.get(0));
}
} else {
Global.approveAllAction.setEnabled(false);
Global.approveAction.setEnabled(false);
Global.clearAllAction.setEnabled(false);
table.getSelectionModel().addListSelectionListener(event -> {
if (!ignoreSelection) {
int viewRow = table.getSelectedRow();
if (viewRow != -1) {
int modelRow = table.convertRowIndexToModel(viewRow);
for (CodeSelectedListener listener : listeners) {
listener.codeSelected(tableModel.getCodeMapping(modelRow));
}

Global.googleSearchAction.setEnabled(true);
Global.googleSearchAction.setSourceTerm(tableModel.getCodeMapping(modelRow).sourceCode.sourceName);

Global.approveAction.setEnabled(true);
Global.approveAllAction.setEnabled(true);
Global.clearAllAction.setEnabled(true);
if (tableModel.getCodeMapping(modelRow).targetConcepts.size() > 0) {
Concept firstConcept = tableModel.getCodeMapping(modelRow).targetConcepts.get(0);
Global.conceptInfoAction.setEnabled(true);
Global.conceptInformationDialog.setConcept(firstConcept);
Global.athenaAction.setEnabled(true);
Global.athenaAction.setConcept(firstConcept);
}
} else {
Global.approveAllAction.setEnabled(false);
Global.approveAction.setEnabled(false);
Global.clearAllAction.setEnabled(false);
}
}
});
Expand Down
8 changes: 7 additions & 1 deletion src/org/ohdsi/usagi/ui/UsagiMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@
*/
public class UsagiMain implements ActionListener {

public static String version = "1.2.9-SNAPSHOT";

public static void main(String[] args) {
new UsagiMain(args);
}

public UsagiMain(String[] args) {
JFrame frame = new JFrame("Usagi");
JFrame frame = new JFrame("Usagi v" + UsagiMain.version);

// Initialize global variables:
Global.mapping = new Mapping();
Expand All @@ -72,6 +74,8 @@ public UsagiMain(String[] args) {
Global.saveAsAction = new SaveAsAction();
Global.approveAction = new ApproveAction();
Global.conceptInfoAction = new ConceptInformationAction();
Global.athenaAction = new AthenaAction();
Global.googleSearchAction = new GoogleSearchAction();
Global.showStatsAction = new ShowStatsAction();
Global.aboutAction = new AboutAction();
Global.approveAllAction = new ApproveAllAction();
Expand All @@ -88,6 +92,8 @@ public UsagiMain(String[] args) {
Global.clearAllAction = new ClearAllAction();
Global.clearAllAction.setEnabled(false);
Global.conceptInfoAction.setEnabled(false);
Global.athenaAction.setEnabled(false);
Global.googleSearchAction.setEnabled(false);

frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
Expand Down
10 changes: 6 additions & 4 deletions src/org/ohdsi/usagi/ui/UsagiMenubar.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class UsagiMenubar extends JMenuBar {

public UsagiMenubar() {
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic(new Integer(KeyEvent.VK_F));
fileMenu.setMnemonic(KeyEvent.VK_F);
add(fileMenu);

fileMenu.add(Global.openAction);
Expand All @@ -38,21 +38,23 @@ public UsagiMenubar() {
fileMenu.add(Global.exitAction);

JMenu editMenu = new JMenu("Edit");
editMenu.setMnemonic(new Integer(KeyEvent.VK_E));
editMenu.setMnemonic(KeyEvent.VK_E);
add(editMenu);

editMenu.add(Global.approveAction);
editMenu.add(Global.approveAllAction);
editMenu.add(Global.clearAllAction);

JMenu viewMenu = new JMenu("View");
viewMenu.setMnemonic(new Integer(KeyEvent.VK_V));
viewMenu.setMnemonic(KeyEvent.VK_V);
add(viewMenu);

viewMenu.add(Global.conceptInfoAction);
viewMenu.add(Global.athenaAction);
viewMenu.add(Global.googleSearchAction);

JMenu helpMenu = new JMenu("Help");
helpMenu.setMnemonic(new Integer(KeyEvent.VK_H));
helpMenu.setMnemonic(KeyEvent.VK_H);
add(helpMenu);

helpMenu.add(Global.rebuildIndexAction);
Expand Down
3 changes: 2 additions & 1 deletion src/org/ohdsi/usagi/ui/actions/AboutAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@

import org.ohdsi.usagi.ui.AboutDialog;
import org.ohdsi.usagi.ui.Global;
import org.ohdsi.usagi.ui.UsagiMain;

public class AboutAction extends AbstractAction {

private static final long serialVersionUID = -6399524936473823131L;

public AboutAction() {
putValue(Action.NAME, "About Usagi");
putValue(Action.NAME, "About Usagi v" + UsagiMain.version);
putValue(Action.SHORT_DESCRIPTION, "About Usagi");
putValue(Action.MNEMONIC_KEY, KeyEvent.VK_A);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.swing.filechooser.FileNameExtensionFilter;

import org.ohdsi.usagi.CodeMapping;
import org.ohdsi.usagi.ui.DataChangeListener;
import org.ohdsi.usagi.ui.Global;
import org.ohdsi.usagi.ui.Mapping;

Expand Down Expand Up @@ -79,6 +80,7 @@ public void actionPerformed(ActionEvent arg0) {
+ " were applied to the current mapping and " + mappingsAdded + " were newly added.";
Global.mappingTablePanel.updateUI();
Global.mappingDetailPanel.updateUI();
Global.mapping.fireDataChanged(DataChangeListener.APPROVE_EVENT); // To update the footer
if (mappingsAdded > 0) {
Global.usagiSearchEngine.close();
Global.usagiSearchEngine.createDerivedIndex(Global.mapping.getSourceCodes(), Global.frame);
Expand Down
58 changes: 58 additions & 0 deletions src/org/ohdsi/usagi/ui/actions/AthenaAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright 2019 Observational Health Data Sciences and Informatics
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.ohdsi.usagi.ui.actions;

import org.ohdsi.usagi.Concept;
import org.ohdsi.usagi.ui.AboutDialog;
import org.ohdsi.usagi.ui.Global;
import org.ohdsi.usagi.ui.UsagiMain;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class AthenaAction extends AbstractAction {

private static final long serialVersionUID = -25905854723973L;
private static final String ATHENA_URL = "https://athena.ohdsi.org/search-terms/terms/";
private Concept selectedConcept;

public AthenaAction() {
putValue(Action.NAME, "Athena (web)");
putValue(Action.SHORT_DESCRIPTION, "Link out to Athena web based concept browser, showing page of currently selected OMOP concept.");
putValue(Action.MNEMONIC_KEY, KeyEvent.VK_W);
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.ALT_MASK));
}

@Override
public void actionPerformed(ActionEvent arg0) {
try {
Desktop desktop = Desktop.getDesktop();
desktop.browse(new URI(ATHENA_URL + selectedConcept.conceptId));
} catch (URISyntaxException | IOException ex) {

}
}

public void setConcept(Concept concept) {
selectedConcept = concept;
}
}
3 changes: 2 additions & 1 deletion src/org/ohdsi/usagi/ui/actions/ConceptInformationAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.ohdsi.usagi.ui.actions;

import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
Expand All @@ -32,7 +33,7 @@ public ConceptInformationAction() {
putValue(Action.NAME, "Concept information");
putValue(Action.SHORT_DESCRIPTION, "Show additional concept information");
putValue(Action.MNEMONIC_KEY, KeyEvent.VK_C);
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.ALT_MASK));
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK));
}

@Override
Expand Down
Loading