Skip to content

Commit

Permalink
Version 0.6.0
Browse files Browse the repository at this point in the history
User interactions link to FirstGlance in Jmol.
  • Loading branch information
aalhossary committed Dec 11, 2021
1 parent 990dfe1 commit d8df42b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>corsslinx</artifactId>
<version>0.5.5</version>
<version>0.6.0</version>
<repositories>
<repository>
<id>local-maven-repo</id>
Expand Down
53 changes: 53 additions & 0 deletions src/amralhossary/bonds/ParsingUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Scanner;

Expand Down Expand Up @@ -51,6 +56,8 @@
import org.biojava.nbio.structure.align.gui.jmol.JmolPanel;

import amralhossary.bonds.SettingsManager.SettingListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class ParsingUI implements ProteinParsingGUI, SettingListener{

Expand Down Expand Up @@ -726,6 +733,41 @@ private JScrollPane getJScrollPane2() {
private JList<PdbId> getFoundStructuresWithInteractionsList() {
if (foundStructuresWithInteractionsList == null) {
foundStructuresWithInteractionsList = new JList<PdbId>(new PdbIdListModel());
foundStructuresWithInteractionsList.setToolTipText("Click an item to preview. \r\nDoubleClick or Enter for more details.");
foundStructuresWithInteractionsList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton()==MouseEvent.BUTTON1 && e.getClickCount() >= 2) {
final int itemIndex = foundStructuresWithInteractionsList.locationToIndex(e.getPoint());
final PdbId pdbId = foundStructuresWithInteractionsList.getModel().getElementAt(itemIndex);
openPdbIdInFGJM(pdbId);
}
}
});

foundStructuresWithInteractionsList.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
final int numOfSelectedItems = foundStructuresWithInteractionsList.getSelectedIndices().length;
if(numOfSelectedItems < 1)
return;
if (numOfSelectedItems == 1) {
final PdbId pdbId = foundStructuresWithInteractionsList.getSelectedValue();
openPdbIdInFGJM(pdbId);
} else {
int userChoice = JOptionPane.showConfirmDialog(getJFrame(), "Are you sure you want to open these "+numOfSelectedItems + " Items?", "Open structures", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (userChoice == JOptionPane.YES_OPTION) {
int[] selectedIndices = foundStructuresWithInteractionsList.getSelectedIndices();
for (int i = 0; i < selectedIndices.length; i++) {
final PdbId pdbId = foundStructuresWithInteractionsList.getModel().getElementAt(i);
openPdbIdInFGJM(pdbId);
}
}
}
}
}
});

foundStructuresWithInteractionsList.setFixedCellHeight(foundStructuresWithInteractionsList.getFont().getSize()+1);
foundStructuresWithInteractionsList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
Expand Down Expand Up @@ -772,6 +814,17 @@ public void valueChanged(ListSelectionEvent e) {
}
return foundStructuresWithInteractionsList;
}

public void openPdbIdInFGJM(final PdbId pdbId) {
String url = "http://firstglance.jmol.org/fg.htm?mol="+pdbId;
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException e1) {
e1.printStackTrace();
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
}

private JList<BondListItem> getFoundLinksList() {
if (foundLinksList == null) {
Expand Down
Binary file modified target/crosslinx.jar
Binary file not shown.

0 comments on commit d8df42b

Please sign in to comment.