added comparison of default and current external tools settings
This commit is contained in:
parent
2babc1c0ee
commit
1da6d10730
2 changed files with 35 additions and 3 deletions
|
@ -24,7 +24,7 @@
|
|||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $Id: GUI.java,v 1.25 2007/03/22 16:17:01 fros4943 Exp $
|
||||
* $Id: GUI.java,v 1.26 2007/03/22 16:41:50 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja;
|
||||
|
@ -130,6 +130,7 @@ public class GUI {
|
|||
private static Logger logger = Logger.getLogger(GUI.class);
|
||||
|
||||
// External tools setting names
|
||||
private static Properties defaultExternalToolsSettings;
|
||||
private static Properties currentExternalToolsSettings;
|
||||
|
||||
private static final String externalToolsSettingNames[] = new String[] {
|
||||
|
@ -1990,6 +1991,17 @@ public class GUI {
|
|||
return currentExternalToolsSettings.getProperty(name, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* Name of setting
|
||||
* @param defaultValue
|
||||
* Default value
|
||||
* @return Value
|
||||
*/
|
||||
public static String getExternalToolsDefaultSetting(String name, String defaultValue) {
|
||||
return defaultExternalToolsSettings.getProperty(name, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* Name of setting
|
||||
|
@ -2018,12 +2030,14 @@ public class GUI {
|
|||
in.close();
|
||||
|
||||
currentExternalToolsSettings = settings;
|
||||
defaultExternalToolsSettings = (Properties) currentExternalToolsSettings.clone();
|
||||
} catch (IOException e) {
|
||||
// Error while importing default properties
|
||||
logger.warn(
|
||||
"Error when reading external tools settings from " + filename, e);
|
||||
} finally {
|
||||
if (currentExternalToolsSettings == null) {
|
||||
defaultExternalToolsSettings = new Properties();
|
||||
currentExternalToolsSettings = new Properties();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: ExternalToolsDialog.java,v 1.1 2006/08/21 12:13:01 fros4943 Exp $
|
||||
* $Id: ExternalToolsDialog.java,v 1.2 2007/03/22 16:41:50 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.dialogs;
|
||||
|
@ -133,6 +133,7 @@ public class ExternalToolsDialog extends JDialog {
|
|||
|
||||
// Set actual used values into all text fields
|
||||
updateTextFields();
|
||||
compareWithDefaults();
|
||||
|
||||
mainPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
|
@ -149,6 +150,22 @@ public class ExternalToolsDialog extends JDialog {
|
|||
}
|
||||
}
|
||||
|
||||
private void compareWithDefaults() {
|
||||
for (int i = 0; i < GUI.getExternalToolsSettingsCount(); i++) {
|
||||
String currentValue = textFields[i].getText();
|
||||
|
||||
// Compare with default value
|
||||
String defaultValue = GUI.getExternalToolsDefaultSetting(GUI.getExternalToolsSettingName(i), "");
|
||||
if (currentValue.equals(defaultValue)) {
|
||||
textFields[i].setBackground(Color.WHITE);
|
||||
textFields[i].setToolTipText("");
|
||||
} else {
|
||||
textFields[i].setBackground(Color.LIGHT_GRAY);
|
||||
textFields[i].setToolTipText("Default value: " + defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ExternalToolsEventHandler
|
||||
implements
|
||||
ActionListener,
|
||||
|
@ -157,12 +174,13 @@ public class ExternalToolsDialog extends JDialog {
|
|||
// NOP
|
||||
}
|
||||
public void focusLost(FocusEvent e) {
|
||||
// NOP
|
||||
compareWithDefaults();
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("reset")) {
|
||||
GUI.loadExternalToolsDefaultSettings();
|
||||
updateTextFields();
|
||||
compareWithDefaults();
|
||||
} else if (e.getActionCommand().equals("ok")) {
|
||||
for (int i = 0; i < GUI.getExternalToolsSettingsCount(); i++) {
|
||||
GUI.setExternalToolsSetting(GUI.getExternalToolsSettingName(i), textFields[i].getText()
|
||||
|
|
Loading…
Reference in a new issue