Added a button to open the mods/ folder

This commit is contained in:
Vhati 2013-08-26 10:46:15 -04:00
parent 2033c80d6a
commit 950b5d664e

View file

@ -2,6 +2,7 @@ package net.vhati.modmanager.ui;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Desktop;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -99,6 +100,7 @@ public class ManagerFrame extends JFrame implements ActionListener, HashObserver
private JButton patchBtn; private JButton patchBtn;
private JButton toggleAllBtn; private JButton toggleAllBtn;
private JButton validateBtn; private JButton validateBtn;
private JButton modsFolderBtn;
private JButton aboutBtn; private JButton aboutBtn;
private ModInfoArea infoArea; private ModInfoArea infoArea;
@ -163,6 +165,13 @@ public class ManagerFrame extends JFrame implements ActionListener, HashObserver
validateBtn.addActionListener(this); validateBtn.addActionListener(this);
modActionsPanel.add( validateBtn ); modActionsPanel.add( validateBtn );
modsFolderBtn = new JButton("Open mods/");
modsFolderBtn.setMargin( actionInsets );
modsFolderBtn.addMouseListener( new StatusbarMouseListener( this, "Open the mods/ folder." ) );
modsFolderBtn.addActionListener(this);
modsFolderBtn.setEnabled( Desktop.isDesktopSupported() );
modActionsPanel.add( modsFolderBtn );
aboutBtn = new JButton("About"); aboutBtn = new JButton("About");
aboutBtn.setMargin( actionInsets ); aboutBtn.setMargin( actionInsets );
aboutBtn.addMouseListener( new StatusbarMouseListener( this, "Show info about this program." ) ); aboutBtn.addMouseListener( new StatusbarMouseListener( this, "Show info about this program." ) );
@ -171,7 +180,7 @@ public class ManagerFrame extends JFrame implements ActionListener, HashObserver
topPanel.add( modActionsPanel, BorderLayout.EAST ); topPanel.add( modActionsPanel, BorderLayout.EAST );
JButton[] actionBtns = new JButton[] {patchBtn, toggleAllBtn, validateBtn, aboutBtn}; JButton[] actionBtns = new JButton[] {patchBtn, toggleAllBtn, validateBtn, modsFolderBtn, aboutBtn};
int actionBtnWidth = Integer.MIN_VALUE; int actionBtnWidth = Integer.MIN_VALUE;
int actionBtnHeight = Integer.MIN_VALUE; int actionBtnHeight = Integer.MIN_VALUE;
for ( JButton btn : actionBtns ) { for ( JButton btn : actionBtns ) {
@ -564,6 +573,17 @@ public class ManagerFrame extends JFrame implements ActionListener, HashObserver
} }
infoArea.setDescription( "Results", resultBuf.toString() ); infoArea.setDescription( "Results", resultBuf.toString() );
} }
else if ( source == modsFolderBtn ) {
try {
if ( Desktop.isDesktopSupported() )
Desktop.getDesktop().open( modsDir.getCanonicalFile() );
else
log.error( "This feature is not available on your OS." );
}
catch ( IOException f ) {
log.error( "Error opening mods/ folder.", f );
}
}
else if ( source == aboutBtn ) { else if ( source == aboutBtn ) {
showAboutInfo(); showAboutInfo();
} }