functionality for exporting current userplatforms as default external tools setting

This commit is contained in:
fros4943 2007-08-21 14:18:04 +00:00
parent 7f25afcfe4
commit 9be473e4b9

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ProjectDirectoriesDialog.java,v 1.3 2007/04/11 14:00:27 fros4943 Exp $
* $Id: ProjectDirectoriesDialog.java,v 1.4 2007/08/21 14:18:04 fros4943 Exp $
*/
package se.sics.cooja.dialogs;
@ -39,6 +39,7 @@ import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;
import javax.swing.*;
import org.apache.log4j.Logger;
import se.sics.cooja.GUI;
@ -160,17 +161,58 @@ public class ProjectDirectoriesDialog extends JDialog {
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
if (fixedProjects == null) {
button = new JButton("Set default");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Object[] options = { "Ok", "Cancel" };
String newDefaultProjectDirs = "";
for (String directory : changableProjectsList.getItems()) {
if (newDefaultProjectDirs != "") {
newDefaultProjectDirs += ";";
}
newDefaultProjectDirs += directory;
}
newDefaultProjectDirs = newDefaultProjectDirs.replace('\\', '/');
String question = "External tools setting DEFAULT_PROJECTDIRS will change from:\n"
+ GUI.getExternalToolsSetting("DEFAULT_PROJECTDIRS")
+ "\n to:\n"
+ newDefaultProjectDirs + "\n\nAre you sure?";
String title = "Change external tools settings?";
int answer = JOptionPane.showOptionDialog(myDialog, question, title,
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null,
options, options[0]);
if (answer != JOptionPane.YES_OPTION) {
return;
}
GUI.setExternalToolsSetting("DEFAULT_PROJECTDIRS",
newDefaultProjectDirs);
}
});
buttonPane.add(button);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
}
button = new JButton("OK");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changableProjects = new Vector<File>();
for (String directory : changableProjectsList.getItems()) {
File projectDir = new File(directory);
if (projectDir.exists() && projectDir.isDirectory())
if (projectDir.exists() && projectDir.isDirectory()) {
changableProjects.add(projectDir);
else
} else {
logger.fatal("Can't find project directory: " + projectDir);
}
}
dispose();
}
});
@ -204,8 +246,9 @@ public class ProjectDirectoriesDialog extends JDialog {
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int selectedIndex = changableProjectsList.getSelectedIndex();
if (selectedIndex <= 0)
if (selectedIndex <= 0) {
return;
}
File file = new File(changableProjectsList.getItem(selectedIndex));
@ -220,10 +263,12 @@ public class ProjectDirectoriesDialog extends JDialog {
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int selectedIndex = changableProjectsList.getSelectedIndex();
if (selectedIndex < 0)
if (selectedIndex < 0) {
return;
if (selectedIndex >= changableProjectsList.getItemCount() - 1)
}
if (selectedIndex >= changableProjectsList.getItemCount() - 1) {
return;
}
File file = new File(changableProjectsList.getItem(selectedIndex));
removeProjectDir(selectedIndex);
@ -238,8 +283,9 @@ public class ProjectDirectoriesDialog extends JDialog {
button = new JButton("Remove");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (changableProjectsList.getSelectedIndex() < 0)
if (changableProjectsList.getSelectedIndex() < 0) {
return;
}
removeProjectDir(changableProjectsList.getSelectedIndex());
}
@ -293,11 +339,12 @@ public class ProjectDirectoriesDialog extends JDialog {
}
// Show merged configuration
if (myParentFrame != null)
if (myParentFrame != null) {
ConfigViewer.showDialog(myParentFrame, config);
else
} else {
ConfigViewer.showDialog(myParentDialog, config);
}
}
});
addRemovePane.add(button);
@ -390,8 +437,9 @@ public class ProjectDirectoriesDialog extends JDialog {
JOptionPane.QUESTION_MESSAGE,
null, options, options[1]);
if (n == JOptionPane.NO_OPTION)
if (n == JOptionPane.NO_OPTION) {
return;
}
try {
projectConfigFile.createNewFile();
@ -502,11 +550,12 @@ class ConfigViewer extends JDialog {
String propertyName = allPropertyNames.nextElement();
keyPane.add(new JLabel(propertyName));
if (config.getStringValue(propertyName).equals(""))
if (config.getStringValue(propertyName).equals("")) {
valuePane.add(new JLabel(" "));
else
} else {
valuePane.add(new JLabel(config.getStringValue(propertyName)));
}
}
// Add components
Container contentPane = getContentPane();