Skip to content

Commit

Permalink
Fix null pointer exception when no component is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
alexyida committed Jan 20, 2013
1 parent acbd9da commit 694a846
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ public void mouseClicked(MouseEvent e) {
}

public String getSelectedID() {
return this.selectedAF.getId();
if (this.selectedAF != null)
return this.selectedAF.getId();
return null;
}

public String getSelectedVer() {
return this.selectedAF.getVersion();
if (this.selectedAF != null)
return this.selectedAF.getVersion();
return null;
}

private void addEntry(VCArtifact toAdd) {
Expand Down
11 changes: 9 additions & 2 deletions VersionChecker/src/versionchecker/actions/VCMainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

Expand Down Expand Up @@ -120,15 +121,21 @@ public void actionPerformed(ActionEvent event) {
fetchButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
String id = tablePanel.getSelectedID();
VCCloneTask task = new VCCloneTask(id,null);
if (id != null)
new VCCloneTask(id,null);
else
JOptionPane.showMessageDialog(null, "No component is selected.", "VersionChecker", 1);;
}
});

cloneButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
String id = tablePanel.getSelectedID();
String ver = tablePanel.getSelectedVer();
VCCloneTask task = new VCCloneTask(id,ver);
if (id != null)
new VCCloneTask(id,ver);
else
JOptionPane.showMessageDialog(null, "No component is selected.", "VersionChecker", 1);;
}
});

Expand Down

0 comments on commit 694a846

Please sign in to comment.