Source Code Cross Referenced for Settings.java in  » Database-Client » SQL-Workbench » workbench » resource » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database Client » SQL Workbench » workbench.resource 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Settings.java
0003:         *
0004:         * This file is part of SQL Workbench/J, http://www.sql-workbench.net
0005:         *
0006:         * Copyright 2002-2008, Thomas Kellerer
0007:         * No part of this code maybe reused without the permission of the author
0008:         *
0009:         * To contact the author please send an email to: support@sql-workbench.net
0010:         *
0011:         */
0012:        package workbench.resource;
0013:
0014:        import java.awt.Color;
0015:        import java.awt.Component;
0016:        import java.awt.Dimension;
0017:        import java.awt.Font;
0018:        import java.awt.Point;
0019:        import java.awt.Toolkit;
0020:        import java.awt.event.InputEvent;
0021:        import java.awt.print.PageFormat;
0022:        import java.awt.print.Paper;
0023:        import java.beans.PropertyChangeListener;
0024:        import java.io.BufferedInputStream;
0025:        import java.io.File;
0026:        import java.io.FileInputStream;
0027:        import java.io.IOException;
0028:        import java.io.InputStream;
0029:        import java.text.DecimalFormat;
0030:        import java.text.DecimalFormatSymbols;
0031:        import java.text.SimpleDateFormat;
0032:        import java.util.ArrayList;
0033:        import java.util.Collection;
0034:        import java.util.Date;
0035:        import java.util.HashSet;
0036:        import java.util.List;
0037:        import java.util.Locale;
0038:        import java.util.Set;
0039:        import java.util.StringTokenizer;
0040:        import javax.swing.UIDefaults;
0041:        import javax.swing.UIManager;
0042:        import workbench.WbManager;
0043:        import workbench.db.ConnectionProfile;
0044:        import workbench.db.WbConnection;
0045:        import workbench.gui.WbSwingUtilities;
0046:        import workbench.gui.profiles.ProfileKey;
0047:        import workbench.interfaces.PropertyStorage;
0048:        import workbench.interfaces.FontChangedListener;
0049:        import workbench.log.LogMgr;
0050:        import workbench.sql.DelimiterDefinition;
0051:        import workbench.sql.BatchRunner;
0052:        import workbench.storage.PkMapping;
0053:        import workbench.util.FileDialogUtil;
0054:        import workbench.util.StringUtil;
0055:        import workbench.util.ToolDefinition;
0056:        import workbench.util.WbFile;
0057:        import workbench.util.WbLocale;
0058:        import workbench.util.WbProperties;
0059:
0060:        /**
0061:         *	@author  support@sql-workbench.net
0062:         */
0063:        public class Settings implements  PropertyStorage {
0064:            // <editor-fold defaultstate="collapsed" desc="Property Keys">
0065:            public static final String PROPERTY_ANIMATED_ICONS = "workbench.gui.animatedicon";
0066:            public static final String PROPERTY_ENCRYPT_PWD = "workbench.profiles.encryptpassword";
0067:            public static final String PROPERTY_DATE_FORMAT = "workbench.gui.display.dateformat";
0068:            public static final String PROPERTY_DATETIME_FORMAT = "workbench.gui.display.datetimeformat";
0069:            public static final String PROPERTY_TIME_FORMAT = "workbench.gui.display.timeformat";
0070:            public static final String PROPERTY_PDF_READER_PATH = "workbench.gui.pdfreader.path";
0071:            public static final String PROPERTY_SHOW_TOOLBAR = "workbench.gui.mainwindow.showtoolbar";
0072:            public static final String PROPERTY_SHOW_LINE_NUMBERS = "workbench.editor.showlinenumber";
0073:            public static final String PROPERTY_HIGHLIGHT_CURRENT_STATEMENT = "workbench.editor.highlightcurrent";
0074:            public static final String PROPERTY_AUTO_JUMP_STATEMENT = "workbench.editor.autojumpnext";
0075:            public static final String PROPERTY_DBEXP_REMEMBER_SORT = "workbench.dbexplorer.remembersort";
0076:
0077:            public static final String PROPERTY_EDITOR_FONT = "editor";
0078:            public static final String PROPERTY_STANDARD_FONT = "std";
0079:            public static final String PROPERTY_MSGLOG_FONT = "msglog";
0080:            public static final String PROPERTY_DATA_FONT = "data";
0081:            public static final String PROPERTY_PRINTER_FONT = "printer";
0082:            /**
0083:             * The property that identifies the name of the file containing the connection profiles.
0084:             */
0085:            public static final String PROPERTY_PROFILE_STORAGE = "workbench.settings.profilestorage";
0086:            public static final String PROPERTY_EDITOR_TAB_WIDTH = "workbench.editor.tabwidth";
0087:            public static final String PROPERTY_EDITOR_CURRENT_LINE_COLOR = "workbench.editor.currentline.color";
0088:            public static final String PROPERTY_EDITOR_ELECTRIC_SCROLL = "workbench.editor.electricscroll";
0089:            // </editor-fold>
0090:
0091:            public static final String PK_MAPPING_FILENAME_PROPERTY = "workbench.pkmapping.file";
0092:            public static final String UNIX_LINE_TERMINATOR_PROP_VALUE = "lf";
0093:            public static final String DOS_LINE_TERMINATOR_PROP_VALUE = "crlf";
0094:            public static final String DEFAULT_LINE_TERMINATOR_PROP_VALUE = "default";
0095:
0096:            private static final String LIB_DIR_KEY = "%LibDir%";
0097:
0098:            private WbProperties props;
0099:            private WbFile configfile;
0100:
0101:            private List<FontChangedListener> fontChangeListeners = new ArrayList<FontChangedListener>(
0102:                    5);
0103:
0104:            private ShortcutManager keyManager;
0105:
0106:            private static class LazyInstanceHolder {
0107:                private static Settings instance = new Settings();
0108:            }
0109:
0110:            public static final Settings getInstance() {
0111:                return LazyInstanceHolder.instance;
0112:            }
0113:
0114:            private Settings() {
0115:                initialize();
0116:                this .renameOldProps();
0117:                this .migrateProps();
0118:                this .removeObsolete();
0119:            }
0120:
0121:            /**
0122:             * Only to be used in JUnit tests!
0123:             */
0124:            public final void initialize() {
0125:                final String configFilename = "workbench.settings";
0126:
0127:                WbFile cfd = null;
0128:                try {
0129:                    String configDir = System.getProperty(
0130:                            "workbench.configdir", null);
0131:                    if (StringUtil.isWhitespaceOrEmpty(configDir)) {
0132:                        // check the current directory for a configuration file
0133:                        // if it is not present, then use the directory of the jar file
0134:                        // this means that upon first startup, the settings file
0135:                        // will be created in the directory of the jar file
0136:                        File f = new File(System.getProperty("user.dir"),
0137:                                configFilename);
0138:                        if (f.exists()) {
0139:                            cfd = new WbFile(f.getParentFile());
0140:                        } else if (WbManager.getInstance() != null) {
0141:                            cfd = new WbFile(WbManager.getInstance()
0142:                                    .getJarPath());
0143:                            f = new File(cfd, configFilename);
0144:                            if (!f.exists()) {
0145:                                cfd = null;
0146:                            }
0147:                        }
0148:                    } else {
0149:                        configDir = StringUtil
0150:                                .replace(configDir, "${user.home}", System
0151:                                        .getProperty("user.home"));
0152:                        cfd = new WbFile(configDir);
0153:                    }
0154:                } catch (Exception e) {
0155:                    cfd = new WbFile(System.getProperty("user.home"),
0156:                            ".sqlworkbench");
0157:                }
0158:
0159:                if (cfd == null) {
0160:                    // no config file in the jar directory --> create a config directory in user.home
0161:                    cfd = new WbFile(System.getProperty("user.home"),
0162:                            ".sqlworkbench");
0163:                }
0164:
0165:                if (!cfd.exists()) {
0166:                    cfd.mkdirs();
0167:                }
0168:
0169:                WbFile settings = new WbFile(cfd, configFilename);
0170:
0171:                boolean configLoaded = loadConfig(settings);
0172:
0173:                boolean logSysErr = getBoolProperty("workbench.log.console",
0174:                        false);
0175:                LogMgr.logToSystemError(logSysErr);
0176:
0177:                String format = getProperty("workbench.log.format",
0178:                        "{type} {timestamp} {message} {error}");
0179:                LogMgr.setMessageFormat(format);
0180:
0181:                String level = getProperty("workbench.log.level", "INFO");
0182:                LogMgr.setLevel(level);
0183:
0184:                try {
0185:                    String logfilename = getProperty("workbench.log.filename",
0186:                            "workbench.log");
0187:
0188:                    // Replace old System.out or System.err settings
0189:                    if (logfilename.equalsIgnoreCase("System.out")
0190:                            || logfilename.equalsIgnoreCase("System.err")) {
0191:                        logfilename = "workbench.log";
0192:                        setProperty("workbench.log.filename", "workbench.log");
0193:                    }
0194:
0195:                    WbFile logfile = new WbFile(logfilename);
0196:                    if (!logfile.isAbsolute()) {
0197:                        logfile = new WbFile(getConfigDir(), logfilename);
0198:                    }
0199:
0200:                    String old = null;
0201:                    if (!logfile.isWriteable()) {
0202:                        old = logfile.getFullPath();
0203:                        logfile = new WbFile(getConfigDir(), "workbench.log");
0204:                        setProperty("workbench.log.filename", "workbench.log");
0205:                    }
0206:
0207:                    int maxSize = this .getMaxLogfileSize();
0208:                    LogMgr.setOutputFile(logfile, maxSize);
0209:                    if (old != null) {
0210:                        LogMgr.logWarning("Settings.<init>",
0211:                                "Could not write requested logfile '" + old
0212:                                        + "'");
0213:                    }
0214:                } catch (Throwable e) {
0215:                    System.err.println("Error initializing log system!");
0216:                    e.printStackTrace(System.err);
0217:                }
0218:
0219:                if (configLoaded) {
0220:                    // This message should not be logged before LogMgr.setOutputFile() has 
0221:                    // been called with the correct value
0222:                    LogMgr.logInfo("Settings.<init>", "Using configdir: "
0223:                            + configfile.getParentFile().getAbsolutePath());
0224:                }
0225:
0226:            }
0227:
0228:            private boolean loadConfig(WbFile cfile) {
0229:                if (cfile == null)
0230:                    return false;
0231:                if (cfile.equals(this .configfile))
0232:                    return false;
0233:
0234:                this .configfile = cfile;
0235:                this .props = new WbProperties(this );
0236:                // first read the built-in defaults
0237:                // this ensures that new defaults will be applied automatically.
0238:                fillDefaults();
0239:
0240:                BufferedInputStream in = null;
0241:                try {
0242:                    in = new BufferedInputStream(new FileInputStream(
0243:                            this .configfile));
0244:                    this .props.load(in);
0245:                } catch (IOException e) {
0246:                    fillDefaults();
0247:                } finally {
0248:                    try {
0249:                        in.close();
0250:                    } catch (Throwable th) {
0251:                    }
0252:                }
0253:                return true;
0254:            }
0255:
0256:            // <editor-fold defaultstate="collapsed" desc="Manual">
0257:            public String getPdfPath() {
0258:                String pdfManual = getProperty("workbench.manual.pdf.file",
0259:                        "SQLWorkbench-Manual.pdf");
0260:
0261:                File f = new File(pdfManual);
0262:                if (f.isDirectory()) {
0263:                    f = new File(f, "SQLWorkbench-Manual.pdf");
0264:                }
0265:
0266:                if (f.exists() && f.canRead()) {
0267:                    return f.getAbsolutePath();
0268:                }
0269:
0270:                String jarDir = WbManager.getInstance().getJarPath();
0271:                WbFile pdf = new WbFile(jarDir, pdfManual);
0272:
0273:                if (!pdf.exists()) {
0274:                    pdf = new WbFile(getConfigDir(), pdfManual);
0275:                }
0276:
0277:                if (pdf.exists() && pdf.canRead()) {
0278:                    return pdf.getFullPath();
0279:                } else {
0280:                    return null;
0281:                }
0282:            }
0283:
0284:            /**
0285:             * Returns the directory where the HTML manual is located.
0286:             * 
0287:             * @return the directory where the HTML manual is located or null if it cannot be found
0288:             */
0289:            public File getHtmlManualDir() {
0290:                // Allow overriding the default location of the HTML manual
0291:                String dir = getProperty("workbench.manual.html.dir", null);
0292:                File htmldir = null;
0293:
0294:                if (dir == null) {
0295:                    // First look in the directory of the jar file.
0296:                    File jardir = WbManager.getInstance().getJarFile()
0297:                            .getParentFile();
0298:                    htmldir = new File(jardir, "manual");
0299:                } else {
0300:                    htmldir = new File(dir);
0301:                }
0302:
0303:                if (!htmldir.exists()) {
0304:                    htmldir = new File(getConfigDir(), "manual");
0305:                }
0306:
0307:                if (htmldir.exists()) {
0308:                    return htmldir;
0309:                }
0310:
0311:                return null;
0312:            }
0313:
0314:            // </editor-fold>
0315:
0316:            // <editor-fold defaultstate="collapsed" desc="Language settings">
0317:            public void setLanguage(Locale locale) {
0318:                setProperty("workbench.gui.language", locale.getLanguage());
0319:            }
0320:
0321:            public List<WbLocale> getLanguages() {
0322:                String prop = getProperty("workbench.gui.languages.available",
0323:                        "en,de");
0324:                List<String> codes = StringUtil.stringToList(prop, ",", true,
0325:                        true, false);
0326:                List<WbLocale> result = new ArrayList<WbLocale>(codes.size());
0327:                for (String c : codes) {
0328:                    try {
0329:                        result.add(new WbLocale(new Locale(c)));
0330:                    } catch (Exception e) {
0331:                        LogMgr.logError("Settings.getLanguages()",
0332:                                "Invalid locale specified: " + c, e);
0333:                    }
0334:                }
0335:                return result;
0336:            }
0337:
0338:            public Locale getLanguage() {
0339:                String lanCode = getProperty("workbench.gui.language", "en");
0340:                Locale l = null;
0341:                try {
0342:                    l = new Locale(lanCode);
0343:                } catch (Exception e) {
0344:                    LogMgr.logError("Settings.getLanguage()",
0345:                            "Error creating Locale for language=" + lanCode, e);
0346:                    l = new Locale("en");
0347:                }
0348:                return l;
0349:            }
0350:
0351:            // </editor-fold>
0352:
0353:            public ShortcutManager getShortcutManager() {
0354:                if (this .keyManager == null) {
0355:                    this .keyManager = new ShortcutManager(this 
0356:                            .getShortcutFilename());
0357:                }
0358:                return this .keyManager;
0359:            }
0360:
0361:            // <editor-fold defaultstate="collapsed" desc="Settings Configuration">
0362:            public String getDriverConfigFilename() {
0363:                return new WbFile(getConfigDir(), "WbDrivers.xml")
0364:                        .getFullPath();
0365:            }
0366:
0367:            public File getConfigDir() {
0368:                return this .configfile.getParentFile();
0369:            }
0370:
0371:            public String replaceLibDirKey(String aPathname) {
0372:                if (aPathname == null)
0373:                    return null;
0374:                WbFile libDir = getLibDir();
0375:                return StringUtil.replace(aPathname, LIB_DIR_KEY, libDir
0376:                        .getFullPath());
0377:            }
0378:
0379:            public WbFile getLibDir() {
0380:                String dir = System.getProperty("workbench.libdir",
0381:                        getProperty("workbench.libdir", null));
0382:                if (dir == null)
0383:                    return new WbFile(getConfigDir());
0384:                return new WbFile(dir);
0385:            }
0386:
0387:            private String getShortcutFilename() {
0388:                return new File(getConfigDir(), "WbShortcuts.xml")
0389:                        .getAbsolutePath();
0390:            }
0391:
0392:            public void setProfileStorage(String file) {
0393:                if (StringUtil.isEmptyString(file)) {
0394:                    this .props.remove(PROPERTY_PROFILE_STORAGE);
0395:                } else {
0396:                    this .props.setProperty(PROPERTY_PROFILE_STORAGE, file);
0397:                }
0398:            }
0399:
0400:            // </editor-fold>
0401:
0402:            // <editor-fold defaultstate="collapsed" desc="Blob Stuff">
0403:
0404:            public void setLastUsedBlobTool(String name) {
0405:                setProperty("workbench.tools.last.blob", name);
0406:            }
0407:
0408:            public String getLastUsedBlobTool() {
0409:                return getProperty("workbench.tools.last.blob", null);
0410:            }
0411:
0412:            // </editor-fold>
0413:
0414:            // <editor-fold defaultstate="collapsed" desc="External Tools">
0415:
0416:            public List<ToolDefinition> getExternalTools() {
0417:                return getExternalTools(true);
0418:            }
0419:
0420:            public List<ToolDefinition> getAllExternalTools() {
0421:                return getExternalTools(false);
0422:            }
0423:
0424:            private List<ToolDefinition> getExternalTools(boolean check) {
0425:                int numTools = getIntProperty("workbench.tools.count", 0);
0426:                List<ToolDefinition> result = new ArrayList<ToolDefinition>(
0427:                        numTools);
0428:                int count = 0;
0429:                for (int i = 0; i < numTools; i++) {
0430:                    String path = getProperty("workbench.tools." + i
0431:                            + ".executable", "");
0432:                    String name = getProperty("workbench.tools." + i + ".name",
0433:                            path);
0434:
0435:                    ToolDefinition tool = new ToolDefinition(path, name);
0436:
0437:                    if (check && tool.executableExists()) {
0438:                        result.add(tool);
0439:                        count++;
0440:                    } else {
0441:                        result.add(tool);
0442:                        count++;
0443:                    }
0444:                }
0445:                return result;
0446:            }
0447:
0448:            private void clearTools() {
0449:                int numTools = getIntProperty("workbench.tools.count", 0);
0450:                for (int i = 0; i < numTools; i++) {
0451:                    removeProperty("workbench.tools." + i + ".executable");
0452:                    removeProperty("workbench.tools." + i + ".name");
0453:                }
0454:            }
0455:
0456:            public void setExternalTools(Collection<ToolDefinition> tools) {
0457:                clearTools();
0458:                int count = 0;
0459:                for (ToolDefinition tool : tools) {
0460:                    setProperty("workbench.tools." + count + ".executable",
0461:                            tool.getApplicationPath());
0462:                    setProperty("workbench.tools." + count + ".name", tool
0463:                            .getName());
0464:                    count++;
0465:                }
0466:                setProperty("workbench.tools.count", count);
0467:            }
0468:
0469:            // </editor-fold>
0470:
0471:            // <editor-fold defaultstate="collapsed" desc="Update Check">
0472:            public Date getLastUpdateCheck() {
0473:                String dt = getProperty("workbench.gui.updatecheck.lastcheck",
0474:                        null);
0475:                if (dt == null)
0476:                    return null;
0477:                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
0478:                Date last = null;
0479:                try {
0480:                    last = sdf.parse(dt);
0481:                    return last;
0482:                } catch (Exception e) {
0483:                    return null;
0484:                }
0485:            }
0486:
0487:            public void setLastUpdateCheck() {
0488:                Date now = new Date();
0489:                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
0490:                this .props.setProperty("workbench.gui.updatecheck.lastcheck",
0491:                        sdf.format(now), false);
0492:            }
0493:
0494:            public int getUpdateCheckInterval() {
0495:                return getIntProperty("workbench.gui.updatecheck.interval", 7);
0496:            }
0497:
0498:            public void setUpdateCheckInterval(int days) {
0499:                setProperty("workbench.gui.updatecheck.interval", days);
0500:            }
0501:
0502:            // </editor-fold>
0503:
0504:            /**
0505:             * Return a list of popular encodings to be used for the code-completion
0506:             * of the -encoding parameter.
0507:             * @see workbench.sql.wbcommands.CommonArgs#addEncodingParameter(workbench.util.ArgumentParser)
0508:             */
0509:            public String getPopularEncodings() {
0510:                return getProperty("workbench.export.defaultencodings",
0511:                        "UTF-8,ISO-8859-1,ISO-8859-15,<name>");
0512:            }
0513:
0514:            /**
0515:             * Return true if the application should be terminated if the first connect
0516:             * dialog is cancelled.
0517:             */
0518:            public boolean getExitOnFirstConnectCancel() {
0519:                return getBoolProperty(
0520:                        "workbench.gui.cancel.firstconnect.exit", false);
0521:            }
0522:
0523:            public void setExitOnFirstConnectCancel(boolean flag) {
0524:                setProperty("workbench.gui.cancel.firstconnect.exit", flag);
0525:            }
0526:
0527:            public String getPDFReaderPath() {
0528:                return getProperty(PROPERTY_PDF_READER_PATH, null);
0529:            }
0530:
0531:            public void setPDFReaderPath(String path) {
0532:                setProperty(PROPERTY_PDF_READER_PATH, path);
0533:            }
0534:
0535:            // <editor-fold defaultstate="collapsed" desc="Formatting options">
0536:
0537:            public int getFormatterMaxColumnsInSelect() {
0538:                return getIntProperty(
0539:                        "workbench.sql.formatter.select.columnsperline", 1);
0540:            }
0541:
0542:            public void setFormatterMaxColumnsInSelect(int value) {
0543:                setProperty("workbench.sql.formatter.select.columnsperline",
0544:                        value);
0545:            }
0546:
0547:            public boolean getFormatterLowercaseFunctions() {
0548:                return getBoolProperty(
0549:                        "workbench.sql.formatter.functions.lowercase", false);
0550:            }
0551:
0552:            public void setFormatterLowercaseFunctions(boolean flag) {
0553:                setProperty("workbench.sql.formatter.functions.lowercase", flag);
0554:            }
0555:
0556:            public int getFormatterMaxSubselectLength() {
0557:                return getIntProperty(
0558:                        "workbench.sql.formatter.subselect.maxlength", 60);
0559:            }
0560:
0561:            public void setFormatterMaxSubselectLength(int value) {
0562:                setProperty("workbench.sql.formatter.subselect.maxlength",
0563:                        value);
0564:            }
0565:
0566:            public int getMaxCharInListElements() {
0567:                return getIntProperty(
0568:                        "workbench.editor.format.list.maxelements.quoted", 2);
0569:            }
0570:
0571:            public void setMaxCharInListElements(int value) {
0572:                setProperty("workbench.editor.format.list.maxelements.quoted",
0573:                        (value <= 0 ? 2 : value));
0574:            }
0575:
0576:            public int getMaxNumInListElements() {
0577:                return getIntProperty(
0578:                        "workbench.editor.format.list.maxelements.nonquoted",
0579:                        10);
0580:            }
0581:
0582:            public void setMaxNumInListElements(int value) {
0583:                setProperty(
0584:                        "workbench.editor.format.list.maxelements.nonquoted",
0585:                        (value <= 0 ? 10 : value));
0586:            }
0587:
0588:            public int getFormatUpdateColumnThreshold() {
0589:                return getIntProperty(
0590:                        "workbench.sql.generate.update.newlinethreshold", 5);
0591:            }
0592:
0593:            public void setFormatUpdateColumnThreshold(int value) {
0594:                setProperty("workbench.sql.generate.update.newlinethreshold",
0595:                        value);
0596:            }
0597:
0598:            public int getFormatInsertColsPerLine() {
0599:                return getIntProperty(
0600:                        "workbench.sql.generate.insert.colsperline", 1);
0601:            }
0602:
0603:            public void setFormatInsertColsPerLine(int value) {
0604:                setProperty("workbench.sql.generate.insert.colsperline", 1);
0605:            }
0606:
0607:            public boolean getFormatInsertIgnoreIdentity() {
0608:                return getBoolProperty(
0609:                        "workbench.sql.generate.insert.ignoreidentity", true);
0610:            }
0611:
0612:            public void setFormatInsertIgnoreIdentity(boolean flag) {
0613:                setProperty("workbench.sql.generate.insert.ignoreidentity",
0614:                        flag);
0615:            }
0616:
0617:            public int getFormatInsertColumnThreshold() {
0618:                return getIntProperty(
0619:                        "workbench.sql.generate.insert.newlinethreshold", 5);
0620:            }
0621:
0622:            public void setFormatInsertColumnThreshold(int value) {
0623:                setProperty("workbench.sql.generate.insert.newlinethreshold",
0624:                        value);
0625:            }
0626:
0627:            public boolean getDoFormatUpdates() {
0628:                return getBoolProperty(
0629:                        "workbench.sql.generate.update.doformat", true);
0630:            }
0631:
0632:            public void setDoFormatUpdates(boolean flag) {
0633:                setProperty("workbench.sql.generate.update.doformat", flag);
0634:            }
0635:
0636:            public boolean getDoFormatInserts() {
0637:                return getBoolProperty(
0638:                        "workbench.sql.generate.insert.doformat", true);
0639:            }
0640:
0641:            public void setDoFormatInserts(boolean flag) {
0642:                setProperty("workbench.sql.generate.insert.doformat", flag);
0643:            }
0644:
0645:            public void setIncludeEmptyComments(boolean flag) {
0646:                setProperty("workbench.sql.generate.comment.includeempty", flag);
0647:            }
0648:
0649:            public boolean getIncludeEmptyComments() {
0650:                return getBoolProperty(
0651:                        "workbench.sql.generate.comment.includeempty", false);
0652:            }
0653:
0654:            // </editor-fold>
0655:
0656:            // <editor-fold defaultstate="collapsed" desc="DbExplorer">
0657:
0658:            public boolean getRetrieveDbExplorer() {
0659:                return getBoolProperty("workbench.dbexplorer.retrieveonopen",
0660:                        true);
0661:            }
0662:
0663:            public void setRetrieveDbExplorer(boolean aFlag) {
0664:                this .setProperty("workbench.dbexplorer.retrieveonopen", aFlag);
0665:            }
0666:
0667:            public void setShowDbExplorerInMainWindow(boolean showWindow) {
0668:                this .setProperty("workbench.dbexplorer.mainwindow", showWindow);
0669:            }
0670:
0671:            public boolean getShowDbExplorerInMainWindow() {
0672:                return this .getBoolProperty("workbench.dbexplorer.mainwindow",
0673:                        true);
0674:            }
0675:
0676:            public boolean getAutoGeneratePKName() {
0677:                return getBoolProperty("workbench.db.createpkname", true);
0678:            }
0679:
0680:            public void setAutoGeneratePKName(boolean flag) {
0681:                setProperty("workbench.db.createpkname", flag);
0682:            }
0683:
0684:            /**
0685:             * Returns true if the DbExplorer should show an additional 
0686:             * panel with all triggers
0687:             */
0688:            public boolean getShowTriggerPanel() {
0689:                return getBoolProperty(
0690:                        "workbench.dbexplorer.triggerpanel.show", true);
0691:            }
0692:
0693:            public void setShowTriggerPanel(boolean flag) {
0694:                setProperty("workbench.dbexplorer.triggerpanel.show", flag);
0695:            }
0696:
0697:            public void setShowFocusInDbExplorer(boolean flag) {
0698:                setProperty("workbench.gui.dbobjects.showfocus", flag);
0699:            }
0700:
0701:            public boolean showFocusInDbExplorer() {
0702:                return getBoolProperty("workbench.gui.dbobjects.showfocus",
0703:                        false);
0704:            }
0705:
0706:            public void setRememberSortInDbExplorer(boolean flag) {
0707:                setProperty(PROPERTY_DBEXP_REMEMBER_SORT, flag);
0708:            }
0709:
0710:            public boolean getRememberSortInDbExplorer() {
0711:                return getBoolProperty(PROPERTY_DBEXP_REMEMBER_SORT, false);
0712:            }
0713:
0714:            public void setStoreExplorerObjectType(boolean flag) {
0715:                setProperty("workbench.dbexplorer.rememberObjectType", flag);
0716:            }
0717:
0718:            public boolean getStoreExplorerObjectType() {
0719:                return getBoolProperty(
0720:                        "workbench.dbexplorer.rememberObjectType", false);
0721:            }
0722:
0723:            public boolean getSwitchCatalogInExplorer() {
0724:                return getBoolProperty("workbench.dbexplorer.switchcatalog",
0725:                        true);
0726:            }
0727:
0728:            public String getProfileStorage() {
0729:                String profiles = this .props
0730:                        .getProperty(PROPERTY_PROFILE_STORAGE);
0731:                if (profiles == null) {
0732:                    return new File(getConfigDir(), "WbProfiles.xml")
0733:                            .getAbsolutePath();
0734:                }
0735:                String realFilename = FileDialogUtil.replaceConfigDir(profiles);
0736:
0737:                WbFile f = new WbFile(realFilename);
0738:                if (!f.isAbsolute()) {
0739:                    // no directory in filename -> use config directory
0740:                    f = new WbFile(getConfigDir(), realFilename);
0741:                }
0742:                return f.getFullPath();
0743:            }
0744:
0745:            public boolean getSelectDataPanelAfterRetrieve() {
0746:                return getBoolProperty(
0747:                        "workbench.gui.dbobjects.autoselectdatapanel", true);
0748:            }
0749:
0750:            public void setSelectDataPanelAfterRetrieve(boolean flag) {
0751:                setProperty("workbench.gui.dbobjects.autoselectdatapanel", flag);
0752:            }
0753:
0754:            // </editor-fold>
0755:
0756:            public void addFontChangedListener(FontChangedListener aListener) {
0757:                this .fontChangeListeners.add(aListener);
0758:            }
0759:
0760:            public synchronized void removeFontChangedListener(
0761:                    FontChangedListener aListener) {
0762:                this .fontChangeListeners.remove(aListener);
0763:            }
0764:
0765:            public synchronized void addPropertyChangeListener(
0766:                    PropertyChangeListener l, String property,
0767:                    String... properties) {
0768:                this .props.addPropertyChangeListener(l, property);
0769:                if (properties.length > 0)
0770:                    this .props.addPropertyChangeListener(l, properties);
0771:            }
0772:
0773:            public void removePropertyChangeListener(PropertyChangeListener l) {
0774:                this .props.removePropertyChangeListener(l);
0775:            }
0776:
0777:            // <editor-fold defaultstate="collapsed" desc="Font Settings">
0778:            public void setFont(String aFontName, Font aFont) {
0779:                String baseKey = "workbench.font." + aFontName;
0780:                if (aFont == null) {
0781:                    this .props.remove(baseKey + ".name");
0782:                    this .props.remove(baseKey + ".size");
0783:                    this .props.remove(baseKey + ".style");
0784:                    return;
0785:                }
0786:
0787:                String name = aFont.getFamily();
0788:                String size = Integer.toString(aFont.getSize());
0789:                int style = aFont.getStyle();
0790:                this .props.setProperty(baseKey + ".name", name);
0791:                this .props.setProperty(baseKey + ".size", size);
0792:                String value = null;
0793:                if ((style & Font.BOLD) == Font.BOLD)
0794:                    value = "BOLD";
0795:                if ((style & Font.ITALIC) == Font.ITALIC) {
0796:                    if (value == null)
0797:                        value = "ITALIC";
0798:                    else
0799:                        value = value + ",ITALIC";
0800:                }
0801:                if (value == null)
0802:                    value = "PLAIN";
0803:                this .props.setProperty(baseKey + ".style", value);
0804:                this .fireFontChangedEvent(aFontName, aFont);
0805:            }
0806:
0807:            public void fireFontChangedEvent(String aKey, Font aFont) {
0808:                for (FontChangedListener listener : fontChangeListeners) {
0809:                    if (listener != null)
0810:                        listener.fontChanged(aKey, aFont);
0811:                }
0812:            }
0813:
0814:            public void setPrintFont(Font aFont) {
0815:                this .setFont(PROPERTY_PRINTER_FONT, aFont);
0816:            }
0817:
0818:            public void setEditorFont(Font f) {
0819:                this .setFont(PROPERTY_EDITOR_FONT, f);
0820:            }
0821:
0822:            public Font getEditorFont() {
0823:                return this .getFont(PROPERTY_EDITOR_FONT, true);
0824:            }
0825:
0826:            public void setMsgLogFont(Font f) {
0827:                this .setFont(PROPERTY_MSGLOG_FONT, f);
0828:            }
0829:
0830:            public Font getMsgLogFont() {
0831:                return this .getFont(PROPERTY_MSGLOG_FONT, true);
0832:            }
0833:
0834:            public void setDataFont(Font f) {
0835:                this .setFont(PROPERTY_DATA_FONT, f);
0836:            }
0837:
0838:            public Font getDataFont(boolean returnDefault) {
0839:                Font f = this .getFont(PROPERTY_DATA_FONT, false);
0840:                if (f == null && returnDefault) {
0841:                    UIDefaults def = UIManager.getLookAndFeelDefaults();
0842:                    f = def.getFont("Table.font");
0843:                }
0844:                return f;
0845:            }
0846:
0847:            public Font getPrinterFont() {
0848:                Font f = this .getFont(PROPERTY_PRINTER_FONT, false);
0849:                if (f == null) {
0850:                    f = this .getDataFont(true);
0851:                }
0852:                return f;
0853:            }
0854:
0855:            public Font getStandardFont() {
0856:                return this .getFont(PROPERTY_STANDARD_FONT, false);
0857:            }
0858:
0859:            public void setStandardFont(Font f) {
0860:                this .setFont(PROPERTY_STANDARD_FONT, f);
0861:            }
0862:
0863:            /**
0864:             *	Returns the font configured for this keyword
0865:             */
0866:            public Font getFont(String aFontName, boolean returnDefault) {
0867:                Font result = null;
0868:
0869:                String baseKey = "workbench.font." + aFontName;
0870:                String name = this .props.getProperty(baseKey + ".name", null);
0871:                if (name == null && returnDefault)
0872:                    name = "Dialog";
0873:
0874:                if (name == null)
0875:                    return null;
0876:
0877:                String sizeS = this .props.getProperty(baseKey + ".size", "11");
0878:                String type = this .props.getProperty(baseKey + ".style",
0879:                        "Plain");
0880:                int style = Font.PLAIN;
0881:                int size = 12;
0882:                StringTokenizer tok = new StringTokenizer(type);
0883:                while (tok.hasMoreTokens()) {
0884:                    String t = tok.nextToken();
0885:                    if ("bold".equalsIgnoreCase(t))
0886:                        style = style | Font.BOLD;
0887:                    if ("italic".equalsIgnoreCase(type))
0888:                        style = style | Font.ITALIC;
0889:                }
0890:
0891:                try {
0892:                    size = Integer.parseInt(sizeS);
0893:                } catch (NumberFormatException e) {
0894:                    size = 11;
0895:                }
0896:                result = new Font(name, style, size);
0897:                return result;
0898:            }
0899:
0900:            // </editor-fold>
0901:
0902:            // <editor-fold defaultstate="collapsed" desc="Date Formats">
0903:            public void setCopyDefault(String value) {
0904:                if (value == null)
0905:                    return;
0906:                if (value.equalsIgnoreCase("all")
0907:                        || value.equalsIgnoreCase("selected")) {
0908:                    setProperty("workbench.gui.table.copydefault", value
0909:                            .toLowerCase());
0910:                }
0911:            }
0912:
0913:            public String getLiteralTypes() {
0914:                return getProperty("workbench.sql.literals.types",
0915:                        "jdbc,ansi,dbms,default");
0916:            }
0917:
0918:            public List<String> getLiteralTypeList() {
0919:                String types = getLiteralTypes();
0920:                List<String> result = StringUtil.stringToList(types, ",", true,
0921:                        true, false);
0922:                if (!result.contains("dbms")) {
0923:                    result.add("dbms");
0924:                }
0925:                return result;
0926:            }
0927:
0928:            public void setDefaultCopyDateLiteralType(String type) {
0929:                setProperty("workbench.export.copy.sql.dateliterals", type);
0930:            }
0931:
0932:            public String getDefaultCopyDateLiteralType() {
0933:                return getProperty("workbench.export.copy.sql.dateliterals",
0934:                        "dbms");
0935:            }
0936:
0937:            public void setDefaultExportDateLiteralType(String type) {
0938:                setProperty("workbench.export.sql.default.dateliterals", type);
0939:            }
0940:
0941:            public String getDefaultExportDateLiteralType() {
0942:                return getProperty("workbench.export.sql.default.dateliterals",
0943:                        "dbms");
0944:            }
0945:
0946:            // </editor-fold>
0947:
0948:            // <editor-fold defaultstate="collapsed" desc="Data display">
0949:
0950:            public boolean getAllowRowHeightResizing() {
0951:                return getBoolProperty("workbench.gui.display.rowheightresize",
0952:                        false);
0953:            }
0954:
0955:            public void setAllowRowHeightResizing(boolean flag) {
0956:                setProperty("workbench.gui.display.rowheightresize", flag);
0957:            }
0958:
0959:            public boolean getUseAlternateRowColor() {
0960:                return getBoolProperty("workbench.gui.table.alternate.use",
0961:                        false);
0962:            }
0963:
0964:            public void setUseAlternateRowColor(boolean flag) {
0965:                setProperty("workbench.gui.table.alternate.use", flag);
0966:            }
0967:
0968:            public void setNullColor(Color c) {
0969:                setColor("workbench.gui.table.null.color", c);
0970:            }
0971:
0972:            public Color getNullColor() {
0973:                return getColor("workbench.gui.table.null.color", null);
0974:            }
0975:
0976:            public Color getExpressionHighlightColor() {
0977:                return getColor("workbench.gui.table.searchhighlite.color",
0978:                        Color.YELLOW);
0979:            }
0980:
0981:            public void setExpressionHighlightColor(Color c) {
0982:                setColor("workbench.gui.table.searchhighlite.color", c);
0983:            }
0984:
0985:            public Color getAlternateRowColor() {
0986:                return getColor("workbench.gui.table.alternate.color",
0987:                        new Color(252, 252, 252));
0988:            }
0989:
0990:            public void setAlternateRowColor(Color c) {
0991:                setColor("workbench.gui.table.alternate.color", c);
0992:            }
0993:
0994:            public void setRequiredFieldColor(Color c) {
0995:                setColor("workbench.gui.edit.requiredfield.color", c);
0996:            }
0997:
0998:            public Color getRequiredFieldColor() {
0999:                return getColor("workbench.gui.edit.requiredfield.color",
1000:                        new Color(255, 100, 100));
1001:            }
1002:
1003:            public void setHighlightRequiredFields(boolean flag) {
1004:                setProperty("workbench.gui.edit.requiredfield.dohighlight",
1005:                        flag);
1006:            }
1007:
1008:            public boolean getHighlightRequiredFields() {
1009:                return getBoolProperty(
1010:                        "workbench.gui.edit.requiredfield.dohighlight", true);
1011:            }
1012:
1013:            // </editor-fold>
1014:
1015:            // <editor-fold defaultstate="collapsed" desc="Color Handling">
1016:            public Color getColor(String aColorKey) {
1017:                return getColor(aColorKey, null);
1018:            }
1019:
1020:            public Color getColor(String aColorKey, Color defaultColor) {
1021:                String value = this .getProperty(aColorKey, null);
1022:                if (value == null)
1023:                    return defaultColor;
1024:                String[] colors = value.split(",");
1025:                if (colors.length != 3)
1026:                    return defaultColor;
1027:                try {
1028:                    int r = StringUtil.getIntValue(colors[0]);
1029:                    int g = StringUtil.getIntValue(colors[1]);
1030:                    int b = StringUtil.getIntValue(colors[2]);
1031:                    return new Color(r, g, b);
1032:                } catch (Exception e) {
1033:                    return defaultColor;
1034:                }
1035:            }
1036:
1037:            // </editor-fold>
1038:
1039:            // <editor-fold defaultstate="collapsed" desc="Printing">
1040:            public PageFormat getPageFormat() {
1041:                PageFormat page = new PageFormat();
1042:                double iw = getDoubleProperty("workbench.print.paper.iwidth",
1043:                        538.5826771653543);
1044:                double ih = getDoubleProperty("workbench.print.paper.iheight",
1045:                        785.1968503937007);
1046:                double top = getDoubleProperty("workbench.print.paper.top",
1047:                        28.346456692913385);
1048:                double left = getDoubleProperty("workbench.print.paper.left",
1049:                        28.346456692913385);
1050:                double width = getDoubleProperty("workbench.print.paper.width",
1051:                        595.275590551181);
1052:                double height = getDoubleProperty(
1053:                        "workbench.print.paper.height", 841.8897637795276);
1054:
1055:                Paper paper = new Paper();
1056:                paper.setSize(width, height);
1057:                paper.setImageableArea(left, top, iw, ih);
1058:                page.setPaper(paper);
1059:                page.setOrientation(this .getPrintOrientation());
1060:                return page;
1061:            }
1062:
1063:            private double getDoubleProperty(String prop, double defValue) {
1064:                String v = getProperty(prop, null);
1065:                return StringUtil.getDoubleValue(v, defValue);
1066:            }
1067:
1068:            public boolean getShowNativePageDialog() {
1069:                return getBoolProperty("workbench.print.nativepagedialog", true);
1070:            }
1071:
1072:            private int getPrintOrientation() {
1073:                return getIntProperty("workbench.print.orientation",
1074:                        PageFormat.PORTRAIT);
1075:            }
1076:
1077:            public void setPageFormat(PageFormat aFormat) {
1078:                Paper p = aFormat.getPaper();
1079:
1080:                double width = aFormat.getWidth();
1081:                double height = aFormat.getHeight();
1082:
1083:                double iw = aFormat.getImageableWidth();
1084:                double ih = aFormat.getImageableHeight();
1085:
1086:                double left = aFormat.getImageableX();
1087:                double top = aFormat.getImageableY();
1088:
1089:                this .props.setProperty("workbench.print.paper.iwidth", Double
1090:                        .toString(iw));
1091:                this .props.setProperty("workbench.print.paper.iheight", Double
1092:                        .toString(ih));
1093:                this .props.setProperty("workbench.print.paper.top", Double
1094:                        .toString(top));
1095:                this .props.setProperty("workbench.print.paper.left", Double
1096:                        .toString(left));
1097:                this .props.setProperty("workbench.print.paper.width", Double
1098:                        .toString(width));
1099:                this .props.setProperty("workbench.print.paper.height", Double
1100:                        .toString(height));
1101:                this .props.setProperty("workbench.print.orientation", Integer
1102:                        .toString(aFormat.getOrientation()));
1103:            }
1104:
1105:            // </editor-fold>
1106:
1107:            // <editor-fold defaultstate="collapsed" desc="GUI Stuff">
1108:            public boolean getIncludeHeaderInOptimalWidth() {
1109:                return getBoolProperty(
1110:                        "workbench.gui.optimalwidth.includeheader", true);
1111:            }
1112:
1113:            public void setIncludeHeaderInOptimalWidth(boolean flag) {
1114:                setProperty("workbench.gui.optimalwidth.includeheader", flag);
1115:            }
1116:
1117:            public boolean getAutomaticOptimalWidth() {
1118:                return getBoolProperty("workbench.gui.optimalwidth.automatic",
1119:                        true);
1120:            }
1121:
1122:            public void setAutomaticOptimalWidth(boolean flag) {
1123:                setProperty("workbench.gui.optimalwidth.automatic", flag);
1124:            }
1125:
1126:            public boolean getUseAnimatedIcon() {
1127:                return getBoolProperty(PROPERTY_ANIMATED_ICONS, false);
1128:            }
1129:
1130:            public void setUseAnimatedIcon(boolean flag) {
1131:                this .setProperty(PROPERTY_ANIMATED_ICONS, flag);
1132:            }
1133:
1134:            public boolean getUseDynamicLayout() {
1135:                return getBoolProperty("workbench.gui.dynamiclayout", true);
1136:            }
1137:
1138:            public void setUseDynamicLayout(boolean flag) {
1139:                this .setProperty("workbench.gui.dynamiclayout", flag);
1140:            }
1141:
1142:            public boolean getShowMnemonics() {
1143:                return getBoolProperty("workbench.gui.showmnemonics", true);
1144:            }
1145:
1146:            public boolean getShowSplash() {
1147:                return getBoolProperty("workbench.gui.showsplash", false);
1148:            }
1149:
1150:            public int getProfileDividerLocation() {
1151:                return getIntProperty("workbench.gui.profiles.divider", -1);
1152:            }
1153:
1154:            public void setProfileDividerLocation(int aValue) {
1155:                this .props.setProperty("workbench.gui.profiles.divider",
1156:                        Integer.toString(aValue));
1157:            }
1158:
1159:            public void setMinColumnWidth(int width) {
1160:                setProperty("workbench.gui.optimalwidth.minsize", width);
1161:            }
1162:
1163:            public int getMinColumnWidth() {
1164:                return this .getIntProperty(
1165:                        "workbench.gui.optimalwidth.minsize", 50);
1166:            }
1167:
1168:            public int getMaxColumnWidth() {
1169:                return getIntProperty("workbench.gui.optimalwidth.maxsize", 850);
1170:            }
1171:
1172:            public void setMaxColumnWidth(int width) {
1173:                this .setProperty("workbench.gui.optimalwidth.maxsize", width);
1174:            }
1175:
1176:            public void setLookAndFeelClass(String aClassname) {
1177:                this .props.setProperty("workbench.gui.lookandfeelclass",
1178:                        aClassname);
1179:            }
1180:
1181:            public String getLookAndFeelClass() {
1182:                return getProperty("workbench.gui.lookandfeelclass", "");
1183:            }
1184:
1185:            public int getMaxMacrosInMenu() {
1186:                return getIntProperty("workbench.gui.macro.maxmenuitems", 9);
1187:            }
1188:
1189:            public static final int SHOW_NO_FILENAME = 0;
1190:            public static final int SHOW_FILENAME = 1;
1191:            public static final int SHOW_FULL_PATH = 2;
1192:
1193:            public void setShowFilenameInWindowTitle(int type) {
1194:                switch (type) {
1195:                case SHOW_NO_FILENAME:
1196:                    this .setProperty("workbench.gui.display.showfilename",
1197:                            "none");
1198:                    break;
1199:                case SHOW_FILENAME:
1200:                    this .setProperty("workbench.gui.display.showfilename",
1201:                            "name");
1202:                    break;
1203:                case SHOW_FULL_PATH:
1204:                    this .setProperty("workbench.gui.display.showfilename",
1205:                            "path");
1206:                    break;
1207:                }
1208:            }
1209:
1210:            public int getShowFilenameInWindowTitle() {
1211:                String type = this .getProperty(
1212:                        "workbench.gui.display.showfilename", "none");
1213:                if ("name".equalsIgnoreCase(type))
1214:                    return SHOW_FILENAME;
1215:                if ("path".equalsIgnoreCase(type))
1216:                    return SHOW_FULL_PATH;
1217:                return SHOW_NO_FILENAME;
1218:            }
1219:
1220:            public String getTitleGroupSeparator() {
1221:                String sep = getProperty("workbench.gui.display.titlegroupsep",
1222:                        "/");
1223:                if ("XXX".equals(sep))
1224:                    return "";
1225:                return sep;
1226:            }
1227:
1228:            public void setTitleGroupSeparator(String sep) {
1229:                if (StringUtil.isEmptyString(sep) || sep.trim().length() == 0)
1230:                    sep = "XXX";
1231:                setProperty("workbench.gui.display.titlegroupsep", sep);
1232:            }
1233:
1234:            public String getTitleGroupBracket() {
1235:                return getProperty("workbench.gui.display.titlegroupbracket",
1236:                        null);
1237:            }
1238:
1239:            public void setTitleGroupBracket(String bracket) {
1240:                setProperty("workbench.gui.display.titlegroupbracket", bracket);
1241:            }
1242:
1243:            public void setShowWorkspaceInWindowTitle(boolean flag) {
1244:                setProperty("workbench.gui.display.showpworkspace", flag);
1245:            }
1246:
1247:            public boolean getShowWorkspaceInWindowTitle() {
1248:                return getBoolProperty("workbench.gui.display.showpworkspace",
1249:                        true);
1250:            }
1251:
1252:            public void setShowProfileGroupInWindowTitle(boolean flag) {
1253:                setProperty("workbench.gui.display.showprofilegroup", flag);
1254:            }
1255:
1256:            public boolean getShowProfileGroupInWindowTitle() {
1257:                return getBoolProperty(
1258:                        "workbench.gui.display.showprofilegroup", false);
1259:            }
1260:
1261:            public void setShowProductNameAtEnd(boolean flag) {
1262:                setProperty("workbench.gui.display.name_at_end", flag);
1263:            }
1264:
1265:            public boolean getShowProductNameAtEnd() {
1266:                return getBoolProperty("workbench.gui.display.name_at_end",
1267:                        false);
1268:            }
1269:
1270:            public boolean getShowToolbar() {
1271:                return getBoolProperty(PROPERTY_SHOW_TOOLBAR, true);
1272:            }
1273:
1274:            public void setShowToolbar(final boolean show) {
1275:                setProperty(PROPERTY_SHOW_TOOLBAR, show);
1276:            }
1277:
1278:            // </editor-fold>
1279:
1280:            // <editor-fold defaultstate="collapsed" desc="Editor">
1281:            public boolean getConsolidateLogMsg() {
1282:                return getBoolProperty("workbench.gui.log.consolidate", false);
1283:            }
1284:
1285:            public void setConsolidateLogMsg(boolean aFlag) {
1286:                this .setProperty("workbench.gui.log.consolidate", aFlag);
1287:            }
1288:
1289:            public boolean getPlainEditorWordWrap() {
1290:                return getBoolProperty("workbench.editor.plain.wordwrap", true);
1291:            }
1292:
1293:            public void setPlainEditorWordWrap(boolean flag) {
1294:                setProperty("workbench.editor.plain.wordwrap", flag);
1295:            }
1296:
1297:            public boolean getUsePlainEditorForData() {
1298:                return getBoolProperty("workbench.gui.editor.data.plain", true);
1299:            }
1300:
1301:            /**
1302:             *  Returns the modifier key for rectangular selections in the editor
1303:             */
1304:            public int getRectSelectionModifier() {
1305:                String mod = getProperty(
1306:                        "workbench.editor.rectselection.modifier", "alt");
1307:                if (mod.equalsIgnoreCase("ctrl")) {
1308:                    return InputEvent.CTRL_MASK;
1309:                }
1310:                return InputEvent.ALT_MASK;
1311:            }
1312:
1313:            public void setRectSelectionModifier(String mod) {
1314:                if (mod == null)
1315:                    return;
1316:                if (mod.equalsIgnoreCase("alt")) {
1317:                    setProperty("workbench.editor.rectselection.modifier",
1318:                            "alt");
1319:                } else if (mod.equalsIgnoreCase("ctrl")) {
1320:                    setProperty("workbench.editor.rectselection.modifier",
1321:                            "ctrl");
1322:                }
1323:            }
1324:
1325:            public String getExternalEditorLineEnding() {
1326:                return getLineEndingProperty(
1327:                        "workbench.editor.lineending.external",
1328:                        DEFAULT_LINE_TERMINATOR_PROP_VALUE);
1329:            }
1330:
1331:            public void setExternalEditorLineEnding(String value) {
1332:                setLineEndingProperty("workbench.editor.lineending.external",
1333:                        value);
1334:            }
1335:
1336:            public String getInternalEditorLineEnding() {
1337:                return getLineEndingProperty(
1338:                        "workbench.editor.lineending.internal",
1339:                        UNIX_LINE_TERMINATOR_PROP_VALUE);
1340:            }
1341:
1342:            public void setInternalEditorLineEnding(String value) {
1343:                setLineEndingProperty("workbench.editor.lineending.internal",
1344:                        value);
1345:            }
1346:
1347:            /**
1348:             * The real setting for the external line ending property
1349:             * to be used by the options dialog
1350:             */
1351:            public String getExternalLineEndingValue() {
1352:                return getProperty("workbench.editor.lineending.external",
1353:                        DEFAULT_LINE_TERMINATOR_PROP_VALUE);
1354:            }
1355:
1356:            /**
1357:             * The real setting for the internal line ending property
1358:             * to be used by the options dialog
1359:             */
1360:            public String getInteralLineEndingValue() {
1361:                return getProperty("workbench.editor.lineending.internal",
1362:                        UNIX_LINE_TERMINATOR_PROP_VALUE);
1363:            }
1364:
1365:            private String getLineEndingProperty(String key, String def) {
1366:                String value = getProperty(key, def);
1367:                if (DEFAULT_LINE_TERMINATOR_PROP_VALUE.equalsIgnoreCase(value)) {
1368:                    return StringUtil.LINE_TERMINATOR;
1369:                }
1370:                if (UNIX_LINE_TERMINATOR_PROP_VALUE.equalsIgnoreCase(value)) {
1371:                    return "\n";
1372:                } else if (DOS_LINE_TERMINATOR_PROP_VALUE
1373:                        .equalsIgnoreCase(value)) {
1374:                    return "\r\n";
1375:                } else {
1376:                    return "\n";
1377:                }
1378:            }
1379:
1380:            private void setLineEndingProperty(String key, String value) {
1381:                if (value == null)
1382:                    return;
1383:                setProperty(key, value.toLowerCase());
1384:            }
1385:
1386:            public boolean getStoreFilesInHistory() {
1387:                return getBoolProperty("workbench.sql.history.includefiles",
1388:                        true);
1389:            }
1390:
1391:            public void getStoreFilesInHistory(boolean flag) {
1392:                setProperty("workbench.sql.history.includefiles", flag);
1393:            }
1394:
1395:            public int getMaxHistorySize() {
1396:                return getIntProperty("workbench.sql.historysize", 15);
1397:            }
1398:
1399:            public void setMaxHistorySize(int aValue) {
1400:                this .setProperty("workbench.sql.historysize", aValue);
1401:            }
1402:
1403:            public DelimiterDefinition getAlternateDelimiter(WbConnection con) {
1404:                DelimiterDefinition delim = null;
1405:                if (con != null && con.getProfile() != null) {
1406:                    delim = con.getProfile().getAlternateDelimiter();
1407:                }
1408:                return (delim == null ? getAlternateDelimiter() : delim);
1409:            }
1410:
1411:            public DelimiterDefinition getAlternateDelimiter() {
1412:                String delim = getProperty("workbench.sql.alternatedelimiter",
1413:                        "/");
1414:                boolean sld = getBoolProperty(
1415:                        "workbench.sql.alternatedelimiter.singleline", true);
1416:                if (StringUtil.isEmptyString(delim))
1417:                    return null;
1418:                DelimiterDefinition def = new DelimiterDefinition(delim, sld);
1419:                if (def.isStandard())
1420:                    return null;
1421:                return def;
1422:            }
1423:
1424:            public void setAlternateDelimiter(DelimiterDefinition aDelimit) {
1425:                this .setProperty("workbench.sql.alternatedelimiter", aDelimit
1426:                        .getDelimiter());
1427:                this .setProperty("workbench.sql.alternatedelimiter.singleline",
1428:                        aDelimit.isSingleLine());
1429:            }
1430:
1431:            public boolean getRightClickMovesCursor() {
1432:                return this .getBoolProperty(
1433:                        "workbench.editor.rightclickmovescursor", false);
1434:            }
1435:
1436:            public void setRightClickMovesCursor(boolean flag) {
1437:                setProperty("workbench.editor.rightclickmovescursor", flag);
1438:            }
1439:
1440:            public boolean getShowLineNumbers() {
1441:                return getBoolProperty(PROPERTY_SHOW_LINE_NUMBERS, true);
1442:            }
1443:
1444:            public void setShowLineNumbers(boolean show) {
1445:                setProperty(PROPERTY_SHOW_LINE_NUMBERS, show);
1446:            }
1447:
1448:            public boolean getAutoJumpNextStatement() {
1449:                return getBoolProperty(PROPERTY_AUTO_JUMP_STATEMENT, false);
1450:            }
1451:
1452:            public void setAutoJumpNextStatement(boolean flag) {
1453:                this .setProperty(PROPERTY_AUTO_JUMP_STATEMENT, flag);
1454:            }
1455:
1456:            public boolean getIgnoreErrors() {
1457:                return StringUtil.stringToBool(this .props.getProperty(
1458:                        "workbench.sql.ignoreerror", "false"));
1459:            }
1460:
1461:            public void setIgnoreErrors(boolean ignore) {
1462:                this .setProperty("workbench.sql.ignoreerror", ignore);
1463:            }
1464:
1465:            public boolean getHighlightCurrentStatement() {
1466:                return getBoolProperty(PROPERTY_HIGHLIGHT_CURRENT_STATEMENT,
1467:                        false);
1468:            }
1469:
1470:            public void setEditorSelectionColor(Color c) {
1471:                setColor("workbench.editor.color.selection", c);
1472:            }
1473:
1474:            public Color getEditorSelectionColor() {
1475:                return getColor("workbench.editor.color.selection", new Color(
1476:                        0xccccff));
1477:            }
1478:
1479:            public void setEditorErrorColor(Color c) {
1480:                setColor("workbench.editor.color.error", c);
1481:            }
1482:
1483:            public Color getEditorErrorColor() {
1484:                return getColor("workbench.editor.color.error", Color.RED
1485:                        .brighter());
1486:            }
1487:
1488:            public Color getEditorCurrentLineColor() {
1489:                return getColor(PROPERTY_EDITOR_CURRENT_LINE_COLOR, null);
1490:            }
1491:
1492:            public void setEditorCurrentLineColor(Color c) {
1493:                setColor(PROPERTY_EDITOR_CURRENT_LINE_COLOR, c);
1494:            }
1495:
1496:            public int getElectricScroll() {
1497:                return this .getIntProperty(PROPERTY_EDITOR_ELECTRIC_SCROLL, 0);
1498:            }
1499:
1500:            public void setElectricScroll(int value) {
1501:                setProperty(PROPERTY_EDITOR_ELECTRIC_SCROLL, (value < 0 ? 0
1502:                        : value));
1503:            }
1504:
1505:            public int getEditorTabWidth() {
1506:                return getIntProperty(PROPERTY_EDITOR_TAB_WIDTH, 2);
1507:            }
1508:
1509:            public void setEditorTabWidth(int aWidth) {
1510:                this .setProperty(PROPERTY_EDITOR_TAB_WIDTH, aWidth);
1511:            }
1512:
1513:            public String getEditorNoWordSep() {
1514:                return getProperty("workbench.editor.nowordsep", "");
1515:            }
1516:
1517:            public void setEditorNoWordSep(String noSep) {
1518:                setProperty("workbench.editor.nowordsep", noSep);
1519:            }
1520:
1521:            public void setAutoCompletionPasteCase(String value) {
1522:                if (value != null) {
1523:                    if (value.toLowerCase().startsWith("lower"))
1524:                        setProperty(
1525:                                "workbench.editor.autocompletion.paste.case",
1526:                                "lower");
1527:                    else if (value.toLowerCase().startsWith("upper"))
1528:                        setProperty(
1529:                                "workbench.editor.autocompletion.paste.case",
1530:                                "upper");
1531:                    else
1532:                        setProperty(
1533:                                "workbench.editor.autocompletion.paste.case",
1534:                                null);
1535:                } else {
1536:                    setProperty("workbench.editor.autocompletion.paste.case",
1537:                            null);
1538:                }
1539:            }
1540:
1541:            public ColumnSortType getAutoCompletionColumnSortType() {
1542:                String sort = getProperty(
1543:                        "workbench.editor.autocompletion.paste.sort", "name");
1544:                try {
1545:                    return ColumnSortType.valueOf(sort);
1546:                } catch (Exception e) {
1547:                    return ColumnSortType.name;
1548:                }
1549:            }
1550:
1551:            public void setAutoCompletionColumnSort(String sort) {
1552:
1553:                try {
1554:                    setAutoCompletionColumnSort(ColumnSortType.valueOf(sort));
1555:                } catch (Exception e) {
1556:                    setAutoCompletionColumnSort(ColumnSortType.name);
1557:                }
1558:            }
1559:
1560:            public void setAutoCompletionColumnSort(ColumnSortType sort) {
1561:                setProperty("workbench.editor.autocompletion.paste.sort",
1562:                        (sort == ColumnSortType.position ? "position" : "name"));
1563:            }
1564:
1565:            public String getAutoCompletionPasteCase() {
1566:                return getProperty(
1567:                        "workbench.editor.autocompletion.paste.case", null);
1568:            }
1569:
1570:            public boolean getCloseAutoCompletionWithSearch() {
1571:                return getBoolProperty(
1572:                        "workbench.editor.autocompletion.closewithsearch",
1573:                        false);
1574:            }
1575:
1576:            public void setCloseAutoCompletionWithSearch(boolean flag) {
1577:                setProperty("workbench.editor.autocompletion.closewithsearch",
1578:                        flag);
1579:            }
1580:
1581:            public boolean getAutoCompletionEmptyLineIsSeparator() {
1582:                return getBoolProperty(
1583:                        "workbench.editor.autocompletion.sql.emptylineseparator",
1584:                        false);
1585:            }
1586:
1587:            public boolean getAutoSaveWorkspace() {
1588:                return getBoolProperty("workbench.workspace.autosave", false);
1589:            }
1590:
1591:            public void setAutoSaveWorkspace(boolean flag) {
1592:                this .setProperty("workbench.workspace.autosave", flag);
1593:            }
1594:
1595:            public boolean getCreateWorkspaceBackup() {
1596:                return getBoolProperty("workbench.workspace.createbackup",
1597:                        false);
1598:            }
1599:
1600:            // </editor-fold>
1601:
1602:            // <editor-fold defaultstate="collapsed" desc="Database">
1603:            public String getPKMappingFilename() {
1604:                String fName = System.getProperty(PK_MAPPING_FILENAME_PROPERTY,
1605:                        getProperty(PK_MAPPING_FILENAME_PROPERTY, null));
1606:                if (StringUtil.isEmptyString(fName))
1607:                    return null;
1608:                return StringUtil.replace(fName, FileDialogUtil.CONFIG_DIR_KEY,
1609:                        getConfigDir().getAbsolutePath());
1610:            }
1611:
1612:            public void setPKMappingFilename(String file) {
1613:                setProperty(PK_MAPPING_FILENAME_PROPERTY, file);
1614:            }
1615:
1616:            public boolean getPreviewDml() {
1617:                return getBoolProperty("workbench.db.previewsql", true);
1618:            }
1619:
1620:            public void setPreviewDml(boolean aFlag) {
1621:                this .props.setProperty("workbench.db.previewsql", Boolean
1622:                        .toString(aFlag));
1623:            }
1624:
1625:            public boolean getDebugMetadataSql() {
1626:                return getBoolProperty("workbench.dbmetadata.debugmetasql",
1627:                        false);
1628:            }
1629:
1630:            public List<String> getServersWhereDDLNeedsCommit() {
1631:                String list = getProperty("workbench.db.ddlneedscommit", "");
1632:                return StringUtil.stringToList(list, ",");
1633:            }
1634:
1635:            public void removeDDLCommitServer(String product) {
1636:                removeListEntry("workbench.db.ddlneedscommit", product);
1637:            }
1638:
1639:            public List<String> getServersWithInlineConstraints() {
1640:                String list = getProperty("workbench.db.inlineconstraints", "");
1641:                return StringUtil.stringToList(list, ",");
1642:            }
1643:
1644:            public List<String> getServersWhichNeedJdbcCommit() {
1645:                String list = getProperty("workbench.db.usejdbccommit", "");
1646:                return StringUtil.stringToList(list, ",");
1647:            }
1648:
1649:            public void removeJdbcCommitServer(String product) {
1650:                removeListEntry("workbench.db.usejdbccommit", product);
1651:            }
1652:
1653:            public List<String> getServersWithNoNullKeywords() {
1654:                String list = getProperty("workbench.db.nonullkeyword", "");
1655:                return StringUtil.stringToList(list, ",");
1656:            }
1657:
1658:            public List<String> getCaseSensitivServers() {
1659:                String list = getProperty("workbench.db.casesensitive", "");
1660:                return StringUtil.stringToList(list, ",");
1661:            }
1662:
1663:            public void removeCaseSensitivServer(String product) {
1664:                removeListEntry("workbench.db.casesensitive", product);
1665:            }
1666:
1667:            private void removeListEntry(String listProperty, String value) {
1668:                String list = getProperty(listProperty, "");
1669:                if (!StringUtil.isEmptyString(list)) {
1670:                    List<String> servers = StringUtil.stringToList(list, ",");
1671:                    servers.remove(value);
1672:                    setProperty(listProperty, StringUtil.listToString(servers,
1673:                            ',', false));
1674:                }
1675:            }
1676:
1677:            public boolean useOracleNVarcharFix() {
1678:                return getBoolProperty("workbench.db.oracle.fixnvarchartype",
1679:                        true);
1680:            }
1681:
1682:            public boolean useOracleCharSemanticsFix() {
1683:                return getBoolProperty("workbench.db.oracle.fixcharsemantics",
1684:                        true);
1685:            }
1686:
1687:            public boolean getCheckPreparedStatements() {
1688:                return getBoolProperty("workbench.sql.checkprepared", false);
1689:            }
1690:
1691:            public void setCheckPreparedStatements(boolean flag) {
1692:                this .setProperty("workbench.sql.checkprepared", flag);
1693:            }
1694:
1695:            // </editor-fold>
1696:
1697:            // <editor-fold defaultstate="collapsed" desc="Export">
1698:            public boolean getIncludeOwnerInSqlExport() {
1699:                return this .getBoolProperty(
1700:                        "workbench.export.sql.includeowner", true);
1701:            }
1702:
1703:            public void setIncludeOwnerInSqlExport(boolean flag) {
1704:                setProperty("workbench.export.sql.includeowner", flag);
1705:            }
1706:
1707:            public String getDefaultTextDelimiter() {
1708:                return this .getDefaultTextDelimiter(false);
1709:            }
1710:
1711:            public String getQuoteChar() {
1712:                return getProperty("workbench.export.text.quotechar", "");
1713:            }
1714:
1715:            public void setQuoteChar(String aQuoteChar) {
1716:                this .props.setProperty("workbench.export.text.quotechar",
1717:                        aQuoteChar);
1718:            }
1719:
1720:            public String getDefaultBlobTextEncoding() {
1721:                return getProperty("workbench.blob.text.encoding",
1722:                        getDefaultDataEncoding());
1723:            }
1724:
1725:            public void setDefaultBlobTextEncoding(String enc) {
1726:                setProperty("workbench.blob.text.encoding", enc);
1727:            }
1728:
1729:            public String getDefaultDataEncoding() {
1730:                String def = System.getProperty("file.encoding");
1731:                if ("Cp1252".equals(def))
1732:                    def = "ISO-8859-15";
1733:                return getProperty("workbench.file.data.encoding", def);
1734:            }
1735:
1736:            public String getDefaultFileEncoding() {
1737:                String def = System.getProperty("file.encoding");
1738:                return getProperty("workbench.file.encoding", def);
1739:            }
1740:
1741:            public void setDefaultFileEncoding(String enc) {
1742:                this .props.setProperty("workbench.file.encoding", enc);
1743:            }
1744:
1745:            public String getDefaultTextDelimiter(boolean readable) {
1746:                return getDelimiter("workbench.export.text.fielddelimiter",
1747:                        "\\t", readable);
1748:            }
1749:
1750:            public void setClipboardDelimiter(String delim) {
1751:                setDelimiter("workbench.import.clipboard.fielddelimiter", delim);
1752:            }
1753:
1754:            public String getClipboardDelimiter(boolean readable) {
1755:                return getDelimiter(
1756:                        "workbench.import.clipboard.fielddelimiter", "\\t",
1757:                        readable);
1758:            }
1759:
1760:            public void setDelimiter(String prop, String delim) {
1761:                if (delim.equals("\t"))
1762:                    delim = "\\t";
1763:                setProperty("workbench.import.clipboard.fielddelimiter", delim);
1764:            }
1765:
1766:            public String getDelimiter(String prop, String def, boolean readable) {
1767:                String del = getProperty(prop, def);
1768:                if (readable) {
1769:                    if (del.equals("\t")) {
1770:                        del = "\\t";
1771:                    }
1772:                } else {
1773:                    if (del.equals("\\t"))
1774:                        del = "\t";
1775:                }
1776:
1777:                return del;
1778:
1779:            }
1780:
1781:            public void setDefaultTextDelimiter(String aDelimit) {
1782:                if (aDelimit.equals("\t"))
1783:                    aDelimit = "\\t";
1784:
1785:                this .props.setProperty("workbench.export.text.fielddelimiter",
1786:                        aDelimit);
1787:            }
1788:
1789:            public String getLastImportDelimiter(boolean readable) {
1790:                return getDelimiter("workbench.import.text.fielddelimiter",
1791:                        "\\t", readable);
1792:            }
1793:
1794:            // </editor-fold>
1795:
1796:            // <editor-fold defaultstate="collapsed" desc="Import">
1797:            public void setLastImportDelimiter(String aDelimit) {
1798:                if (aDelimit.equals("\t"))
1799:                    aDelimit = "\\t";
1800:
1801:                this .props.setProperty("workbench.import.text.fielddelimiter",
1802:                        aDelimit);
1803:            }
1804:
1805:            public boolean getLastImportWithHeaders() {
1806:                return getBoolProperty("workbench.import.text.containsheader",
1807:                        true);
1808:            }
1809:
1810:            public void setLastImportWithHeaders(boolean aFlag) {
1811:                this .props.setProperty("workbench.import.text.containsheader",
1812:                        Boolean.toString(aFlag));
1813:            }
1814:
1815:            public String getLastImportDateFormat() {
1816:                return getProperty("workbench.import.dateformat", this 
1817:                        .getDefaultDateFormat());
1818:            }
1819:
1820:            public void setLastImportDateFormat(String aFormat) {
1821:                this .props.setProperty("workbench.import.dateformat", aFormat);
1822:            }
1823:
1824:            public void setLastImportNumberFormat(String aFormat) {
1825:                this .props
1826:                        .setProperty("workbench.import.numberformat", aFormat);
1827:            }
1828:
1829:            public String getLastImportNumberFormat() {
1830:                String result = getProperty("workbench.import.numberformat",
1831:                        null);
1832:                if (result == null) {
1833:                    result = "#" + this .getDecimalSymbol() + "#";
1834:                }
1835:                return result;
1836:            }
1837:
1838:            public boolean getLastImportDecode() {
1839:                return this .getBoolProperty("workbench.import.decode");
1840:            }
1841:
1842:            public void setLastImportDecode(boolean flag) {
1843:                this .setProperty("workbench.import.decode", flag);
1844:            }
1845:
1846:            public String getLastImportQuoteChar() {
1847:                return getProperty("workbench.import.quotechar", "\"");
1848:            }
1849:
1850:            public void setLastImportQuoteChar(String aChar) {
1851:                this .props.setProperty("workbench.import.quotechar", aChar);
1852:            }
1853:
1854:            public String getLastImportDir() {
1855:                return getProperty("workbench.import.lastdir", this 
1856:                        .getLastExportDir());
1857:            }
1858:
1859:            public void setLastImportDir(String aDir) {
1860:                this .props.setProperty("workbench.import.lastdir", aDir);
1861:            }
1862:
1863:            // </editor-fold>
1864:
1865:            // <editor-fold defaultstate="collapsed" desc="Directories">
1866:            public String getLastLibraryDir() {
1867:                return getProperty("workbench.drivers.lastlibdir", "");
1868:            }
1869:
1870:            public void setLastLibraryDir(String aDir) {
1871:                this .props.setProperty("workbench.drivers.lastlibdir", aDir);
1872:            }
1873:
1874:            public String getLastBlobDir() {
1875:                return getProperty("workbench.data.blob.save.lastdir", null);
1876:            }
1877:
1878:            public void setLastBlobDir(String aDir) {
1879:                this .setProperty("workbench.data.blob.save.lastdir", aDir);
1880:            }
1881:
1882:            public String getLastWorkspaceDir() {
1883:                return getProperty("workbench.workspace.lastdir", this 
1884:                        .getConfigDir().getAbsolutePath());
1885:            }
1886:
1887:            public void setLastWorkspaceDir(String aDir) {
1888:                this .props.setProperty("workbench.workspace.lastdir", aDir);
1889:            }
1890:
1891:            public String getLastExportDir() {
1892:                return getProperty("workbench.export.lastdir", "");
1893:            }
1894:
1895:            public void setLastExportDir(String aDir) {
1896:                this .props.setProperty("workbench.export.lastdir", aDir);
1897:            }
1898:
1899:            public String getLastSqlDir() {
1900:                return getProperty("workbench.sql.lastscriptdir", "");
1901:            }
1902:
1903:            public void setLastSqlDir(String aDir) {
1904:                this .props.setProperty("workbench.sql.lastscriptdir", aDir);
1905:            }
1906:
1907:            public String getLastEditorDir() {
1908:                return getProperty("workbench.editor.lastdir", "");
1909:            }
1910:
1911:            public void setLastEditorDir(String aDir) {
1912:                this .props.setProperty("workbench.editor.lastdir", aDir);
1913:            }
1914:
1915:            public String getLastFilterDir() {
1916:                return getProperty("workbench.filter.lastdir", "");
1917:            }
1918:
1919:            public void setLastFilterDir(String dir) {
1920:                this .props.setProperty("workbench.filter.lastdir", dir);
1921:            }
1922:
1923:            // </editor-fold>
1924:
1925:            // <editor-fold defaultstate="collapsed" desc="Date and Time Formatting">
1926:            private SimpleDateFormat defaultDateFormatter = null;
1927:            private SimpleDateFormat defaultTimestampFormatter = null;
1928:
1929:            public SimpleDateFormat getDefaultDateFormatter() {
1930:                if (this .defaultDateFormatter == null) {
1931:                    this .defaultDateFormatter = new SimpleDateFormat(this 
1932:                            .getDefaultDateFormat());
1933:                }
1934:                return this .defaultDateFormatter;
1935:            }
1936:
1937:            public void setDefaultDateFormat(String aFormat) {
1938:                this .defaultDateFormatter = null;
1939:                this .props.setProperty(PROPERTY_DATE_FORMAT, aFormat);
1940:            }
1941:
1942:            public void registerDateFormatChangeListener(
1943:                    PropertyChangeListener l) {
1944:                this .addPropertyChangeListener(l, PROPERTY_DATE_FORMAT,
1945:                        PROPERTY_DATETIME_FORMAT, PROPERTY_TIME_FORMAT);
1946:            }
1947:
1948:            public boolean isDateFormatProperty(String prop) {
1949:                if (prop == null)
1950:                    return false;
1951:                return (PROPERTY_DATE_FORMAT.equals(prop)
1952:                        || PROPERTY_DATETIME_FORMAT.equals(prop) || PROPERTY_TIME_FORMAT
1953:                        .equals(prop));
1954:            }
1955:
1956:            public String getDefaultDateFormat() {
1957:                return getProperty(PROPERTY_DATE_FORMAT,
1958:                        StringUtil.ISO_DATE_FORMAT);
1959:            }
1960:
1961:            public String getDefaultTimestampFormat() {
1962:                return getProperty(PROPERTY_DATETIME_FORMAT,
1963:                        StringUtil.ISO_TIMESTAMP_FORMAT);
1964:            }
1965:
1966:            public void setDefaultTimestampFormat(String aFormat) {
1967:                this .defaultDateFormatter = null;
1968:                this .props.setProperty(PROPERTY_DATETIME_FORMAT, aFormat);
1969:            }
1970:
1971:            public void setDefaultTimeFormat(String format) {
1972:                this .props.setProperty(PROPERTY_TIME_FORMAT, format);
1973:            }
1974:
1975:            public String getDefaultTimeFormat() {
1976:                return getProperty(PROPERTY_TIME_FORMAT, "HH:mm:ss");
1977:            }
1978:
1979:            public SimpleDateFormat getDefaultTimestampFormatter() {
1980:                if (this .defaultTimestampFormatter == null) {
1981:                    this .defaultTimestampFormatter = new SimpleDateFormat(this 
1982:                            .getDefaultTimestampFormat());
1983:                }
1984:                return this .defaultTimestampFormatter;
1985:            }
1986:
1987:            public int getMaxFractionDigits() {
1988:                return getIntProperty(
1989:                        "workbench.gui.display.maxfractiondigits", 2);
1990:            }
1991:
1992:            public void setMaxFractionDigits(int aValue) {
1993:                this .props.setProperty(
1994:                        "workbench.gui.display.maxfractiondigits", Integer
1995:                                .toString(aValue));
1996:                this .defaultDecimalFormatter = null;
1997:            }
1998:
1999:            private DecimalFormat defaultDecimalFormatter = null;
2000:            private DecimalFormatSymbols decSymbols = new DecimalFormatSymbols();
2001:
2002:            public DecimalFormat getDefaultDecimalFormatter() {
2003:                this .initFormatter();
2004:                return this .defaultDecimalFormatter;
2005:            }
2006:
2007:            private void initFormatter() {
2008:                if (this .defaultDecimalFormatter == null) {
2009:                    this .defaultDecimalFormatter = new DecimalFormat("0.#");
2010:                    String sep = this .getDecimalSymbol();
2011:                    int maxDigits = this .getMaxFractionDigits();
2012:                    this .decSymbols.setDecimalSeparator(sep.charAt(0));
2013:                    this .defaultDecimalFormatter
2014:                            .setDecimalFormatSymbols(this .decSymbols);
2015:                    this .defaultDecimalFormatter
2016:                            .setMaximumFractionDigits(maxDigits);
2017:                }
2018:            }
2019:
2020:            public String getDecimalSymbol() {
2021:                return getProperty("workbench.gui.display.decimal.separator",
2022:                        ".");
2023:            }
2024:
2025:            public void setDecimalSymbol(String aSep) {
2026:                this .props.setProperty(
2027:                        "workbench.gui.display.decimal.separator", aSep);
2028:                this .defaultDecimalFormatter = null;
2029:            }
2030:
2031:            // </editor-fold>
2032:
2033:            public String getSqlParameterPrefix() {
2034:                String value = getProperty("workbench.sql.parameter.prefix",
2035:                        "$[");
2036:                if (StringUtil.isEmptyString(value))
2037:                    value = "$[";
2038:                return value;
2039:            }
2040:
2041:            public String getSqlParameterSuffix() {
2042:                return getProperty("workbench.sql.parameter.suffix", "]");
2043:            }
2044:
2045:            public int getMaxLogfileSize() {
2046:                return this .getIntProperty("workbench.log.maxfilesize", 30000);
2047:            }
2048:
2049:            public boolean getCheckEscapedQuotes() {
2050:                return getBoolProperty("workbench.sql.checkescapedquotes",
2051:                        false);
2052:            }
2053:
2054:            public void setCheckEscapedQuotes(boolean flag) {
2055:                this .setProperty("workbench.sql.checkescapedquotes", flag);
2056:            }
2057:
2058:            // <editor-fold defaultstate="collapsed" desc="Connections">
2059:            public boolean getAutoConnectDataPumper() {
2060:                return getBoolProperty("workbench.datapumper.autoconnect", true);
2061:            }
2062:
2063:            public void setAutoConnectDataPumper(boolean flag) {
2064:                this .setProperty("workbench.datapumper.autoconnect", flag);
2065:            }
2066:
2067:            public ProfileKey getLastConnection(String key) {
2068:                if (key == null) {
2069:                    key = "workbench.connection.last";
2070:                }
2071:                String name = getProperty(key, null);
2072:                if (name == null)
2073:                    return null;
2074:                String group = getProperty(key + ".group", null);
2075:                return new ProfileKey(name, group);
2076:            }
2077:
2078:            public void setLastConnection(ConnectionProfile prof) {
2079:                setLastConnection("workbench.connection.last", prof);
2080:            }
2081:
2082:            public void setLastConnection(String key, ConnectionProfile prof) {
2083:                if (prof == null) {
2084:                    this .props.setProperty(key, "");
2085:                    this .props.setProperty(key + ".group", "");
2086:                }
2087:
2088:                // comparing with == is intended!!!!
2089:                if (prof.getName() == BatchRunner.CMD_LINE_PROFILE_NAME)
2090:                    return;
2091:
2092:                this .props.setProperty(key, prof.getName());
2093:                this .props.setProperty(key + ".group", prof.getGroup());
2094:            }
2095:
2096:            // </editor-fold>
2097:
2098:            public int getInMemoryScriptSizeThreshold() {
2099:                // Process scripts up to 1 MB in memory
2100:                // this is used by the ScriptParser
2101:                return getIntProperty("workbench.sql.script.inmemory.maxsize",
2102:                        1024 * 1024);
2103:            }
2104:
2105:            public void setInMemoryScriptSizeThreshold(int size) {
2106:                setProperty("workbench.sql.script.inmemory.maxsize", size);
2107:            }
2108:
2109:            public boolean getUseCollator() {
2110:                return getBoolProperty("workbench.sort.usecollator", false);
2111:            }
2112:
2113:            public String getSortLanguage() {
2114:                return getProperty("workbench.sort.language", System
2115:                        .getProperty("user.language"));
2116:            }
2117:
2118:            public String getSortCountry() {
2119:                return getProperty("workbench.sort.country", System
2120:                        .getProperty("user.country"));
2121:            }
2122:
2123:            public void setGeneratedSqlTableCase(String value) {
2124:                if (value != null) {
2125:                    if (value.toLowerCase().startsWith("lower"))
2126:                        setProperty("workbench.sql.generate.table.case",
2127:                                "lower");
2128:                    else if (value.toLowerCase().startsWith("upper"))
2129:                        setProperty("workbench.sql.generate.table.case",
2130:                                "upper");
2131:                    else
2132:                        setProperty("workbench.sql.generate.table.case",
2133:                                "original");
2134:                } else {
2135:                    setProperty("workbench.sql.generate.table.case", "original");
2136:                }
2137:            }
2138:
2139:            public String getGeneratedSqlTableCase() {
2140:                return getProperty("workbench.sql.generate.table.case",
2141:                        getAutoCompletionPasteCase());
2142:            }
2143:
2144:            public boolean getUseEncryption() {
2145:                return getBoolProperty(PROPERTY_ENCRYPT_PWD, false);
2146:            }
2147:
2148:            public void setUseEncryption(boolean useEncryption) {
2149:                this .setProperty(PROPERTY_ENCRYPT_PWD, useEncryption);
2150:            }
2151:
2152:            // <editor-fold defaultstate="collapsed" desc="Utility">
2153:            public void removeProperty(String property) {
2154:                this .props.remove(property);
2155:            }
2156:
2157:            public boolean getBoolProperty(String property) {
2158:                return getBoolProperty(property, false);
2159:            }
2160:
2161:            public boolean getBoolProperty(String property, boolean defaultValue) {
2162:                String sysValue = System.getProperty(property, null);
2163:                if (sysValue != null) {
2164:                    return StringUtil.stringToBool(sysValue);
2165:                }
2166:                return this .props.getBoolProperty(property, defaultValue);
2167:            }
2168:
2169:            public void setProperty(String property, boolean value) {
2170:                this .props.setProperty(property, value);
2171:            }
2172:
2173:            public Object setProperty(String aProperty, String aValue) {
2174:                return this .props.setProperty(aProperty, aValue);
2175:            }
2176:
2177:            public void setProperty(String aProperty, int aValue) {
2178:                this .props.setProperty(aProperty, Integer.toString(aValue));
2179:            }
2180:
2181:            public String getProperty(String aProperty, String aDefault) {
2182:                return System.getProperty(aProperty, this .props.getProperty(
2183:                        aProperty, aDefault));
2184:            }
2185:
2186:            public List<String> getListProperty(String aProperty,
2187:                    boolean makeLowerCase) {
2188:                String list = System.getProperty(aProperty, this .props
2189:                        .getProperty(aProperty, null));
2190:                if (makeLowerCase && list != null) {
2191:                    list = list.toLowerCase();
2192:                }
2193:                return StringUtil.stringToList(list, ",", true, true, false);
2194:            }
2195:
2196:            public int getIntProperty(String aProperty, int defaultValue) {
2197:                String sysValue = System.getProperty(aProperty, null);
2198:                if (sysValue != null) {
2199:                    return StringUtil.getIntValue(sysValue, defaultValue);
2200:                }
2201:                return this .props.getIntProperty(aProperty, defaultValue);
2202:            }
2203:
2204:            private void setColor(String key, Color c) {
2205:                String value = null;
2206:                if (c != null) {
2207:                    int r = c.getRed();
2208:                    int g = c.getGreen();
2209:                    int b = c.getBlue();
2210:                    value = Integer.toString(r) + "," + Integer.toString(g)
2211:                            + "," + Integer.toString(b);
2212:                }
2213:                this .setProperty(key, value);
2214:            }
2215:
2216:            public int getWindowPosX(String windowClass) {
2217:                return getIntProperty(windowClass + ".x", Integer.MIN_VALUE);
2218:            }
2219:
2220:            public int getWindowPosY(String windowClass) {
2221:                return getIntProperty(windowClass + ".y", Integer.MIN_VALUE);
2222:            }
2223:
2224:            public int getWindowWidth(String windowClass) {
2225:                return getIntProperty(windowClass + ".width", Integer.MIN_VALUE);
2226:            }
2227:
2228:            public int getWindowHeight(String windowClass) {
2229:                return getIntProperty(windowClass + ".height",
2230:                        Integer.MIN_VALUE);
2231:            }
2232:
2233:            public void storeWindowPosition(Component target) {
2234:                this .storeWindowPosition(target, target.getClass().getName());
2235:            }
2236:
2237:            public void storeWindowPosition(Component target, String id) {
2238:                Point p = target.getLocation();
2239:                this .setWindowPosition(id, p.x, p.y);
2240:            }
2241:
2242:            public void storeWindowSize(Component target) {
2243:                this .storeWindowSize(target, null);
2244:            }
2245:
2246:            public void storeWindowSize(Component target, String id) {
2247:                if (target == null)
2248:                    return;
2249:                Dimension d = target.getSize();
2250:                if (id == null)
2251:                    id = target.getClass().getName();
2252:                this .setWindowSize(id, d.width, d.height);
2253:            }
2254:
2255:            public void setWindowPosition(String windowClass, int x, int y) {
2256:                this .props.setProperty(windowClass + ".x", Integer.toString(x));
2257:                this .props.setProperty(windowClass + ".y", Integer.toString(y));
2258:            }
2259:
2260:            public void setWindowSize(String windowClass, int width, int height) {
2261:                this .props.setProperty(windowClass + ".width", Integer
2262:                        .toString(width));
2263:                this .props.setProperty(windowClass + ".height", Integer
2264:                        .toString(height));
2265:            }
2266:
2267:            public boolean restoreWindowSize(Component target) {
2268:                return this .restoreWindowSize(target, target.getClass()
2269:                        .getName());
2270:            }
2271:
2272:            public boolean restoreWindowSize(final Component target,
2273:                    final String id) {
2274:                boolean result = false;
2275:                final int w = this .getWindowWidth(id);
2276:                final int h = this .getWindowHeight(id);
2277:                Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
2278:
2279:                if (w > 0 && h > 0 && w <= screen.getWidth()
2280:                        && h <= screen.getHeight()) {
2281:                    result = true;
2282:                    WbSwingUtilities.invoke(new Runnable() {
2283:                        public void run() {
2284:                            target.setSize(new Dimension(w, h));
2285:                        }
2286:                    });
2287:                }
2288:                return result;
2289:            }
2290:
2291:            public boolean restoreWindowPosition(Component target) {
2292:                return this .restoreWindowPosition(target, target.getClass()
2293:                        .getName());
2294:            }
2295:
2296:            public boolean restoreWindowPosition(final Component target,
2297:                    final String id) {
2298:                boolean result = false;
2299:                final int x = this .getWindowPosX(id);
2300:                final int y = this .getWindowPosY(id);
2301:                Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
2302:
2303:                if (x != Integer.MIN_VALUE && y != Integer.MIN_VALUE
2304:                        && x <= screen.getWidth() - 20
2305:                        && y <= screen.getHeight() - 20) {
2306:                    result = true;
2307:                    WbSwingUtilities.invoke(new Runnable() {
2308:                        public void run() {
2309:                            target.setLocation(new Point(x, y));
2310:                        }
2311:                    });
2312:                }
2313:                return result;
2314:            }
2315:
2316:            private void migrateProps() {
2317:                // Fix incorrectly distributed defaults
2318:                String defaultSelectable = getProperty(
2319:                        "workbench.db.objecttype.selectable.default", null);
2320:                if (defaultSelectable != null) {
2321:                    List<String> types = StringUtil.stringToList(
2322:                            defaultSelectable.toLowerCase(), ",", true, true,
2323:                            false);
2324:                    if (!types.contains("synonym")) {
2325:                        types.add("synonym");
2326:                        setProperty(
2327:                                "workbench.db.objecttype.selectable.default",
2328:                                StringUtil.listToString(types, ','));
2329:                    }
2330:                }
2331:
2332:                String synRegex = getProperty(
2333:                        "workbench.db.oracle.exclude.synonyms", null);
2334:                if (synRegex != null && !synRegex.startsWith("^/.*")) {
2335:                    synRegex = "^/.*|" + synRegex;
2336:                    setProperty("workbench.db.oracle.exclude.synonyms",
2337:                            synRegex);
2338:                }
2339:
2340:                WbProperties def = getDefaultProperties();
2341:                upgradeListProp(def, "workbench.db.oracle.syntax.functions");
2342:
2343:                // Adjust the patterns for SELECT ... INTO
2344:                upgradeProp(def, "workbench.db.postgresql.selectinto.pattern",
2345:                        "(?s)^SELECT\\s+.*INTO\\s+\\p{Print}*\\s*FROM.*");
2346:                upgradeProp(
2347:                        def,
2348:                        "workbench.db.informix_dynamic_server.selectinto.pattern",
2349:                        "(?s)^SELECT.*FROM.*INTO\\s*\\p{Print}*");
2350:            }
2351:
2352:            private void upgradeProp(WbProperties defProps, String property,
2353:                    String originalvalue) {
2354:                String p = getProperty(property, "");
2355:
2356:                // Make sure it has not been modified
2357:                if (originalvalue.equals(p)) {
2358:                    String newprop = defProps.getProperty(
2359:                            "workbench.db.postgresql.selectinto.pattern", null);
2360:                    setProperty("workbench.db.postgresql.selectinto.pattern",
2361:                            newprop);
2362:                }
2363:            }
2364:
2365:            private void upgradeListProp(WbProperties defProps, String key) {
2366:                String currentValue = getProperty(key, "");
2367:                List<String> currentList = StringUtil.stringToList(
2368:                        currentValue, ",", true, true, false);
2369:
2370:                // Use a HashSet to ensure that no duplicates are contained in the list
2371:                Set<String> currentProps = new HashSet<String>();
2372:                currentProps.addAll(currentList);
2373:
2374:                String defValue = defProps.getProperty(key, "");
2375:                List<String> defList = StringUtil.stringToList(defValue, ",",
2376:                        true, true, false);
2377:                currentProps.addAll(defList);
2378:                this .setProperty(key, StringUtil
2379:                        .listToString(currentProps, ','));
2380:            }
2381:
2382:            private void renameOldProps() {
2383:                this .renameProperty("workbench.sql.maxcolwidth",
2384:                        "workbench.gui.optimalwidth.maxsize");
2385:                this .renameProperty("workbench.sql.mincolwidth",
2386:                        "workbench.gui.optimalwidth.minsize");
2387:                this .renameProperty("sort.language", "workbench.sort.language");
2388:                this .renameProperty("sort.country", "workbench.sort.country");
2389:                this .renameProperty("connection.last",
2390:                        "workbench.connection.last");
2391:                this .renameProperty("drivers.lastlibdir",
2392:                        "workbench.drivers.lastlibdir");
2393:                this .renameProperty("workbench.db.debugger",
2394:                        "workbench.db.previewsql");
2395:
2396:                // Fix typos from incorrect default.properties
2397:                this .renameProperty("workbench.db.objecttype.data.postgres",
2398:                        "workbench.db.objecttype.data.postgresql");
2399:                this .renameProperty(
2400:                        "workbench.db.objecttype.selectable.postgres",
2401:                        "workbench.db.objecttype.selectable.postgresql");
2402:                this .renameProperty("workbench.ignoretypes.postgres",
2403:                        "workbench.ignoretypes.postgresql");
2404:                String s = getProperty("workbench.db.truncatesupported", null);
2405:                if (s != null) {
2406:                    s = s.replaceAll(",postgres,", ",postgresql,");
2407:                    this .setProperty("workbench.db.truncatesupported", s);
2408:                }
2409:                this .renameProperty("workbench.history.tablelist",
2410:                        "workbench.quickfilter.tablelist.history");
2411:                this .renameProperty("workbench.history.columnlist",
2412:                        "workbench.quickfilter.columnlist.history");
2413:                this 
2414:                        .renameProperty(
2415:                                "workbench.gui.dbobjects.ProcedureListPanel.lastsearch",
2416:                                "workbench.quickfilter.procedurelist.history");
2417:                this .renameProperty("workbench.blob.text.encoding",
2418:                        "workbench.gui.blob.text.encoding");
2419:                this .renameProperty("workbench.javacode.includenewline",
2420:                        "workbench.clipcreate.includenewline");
2421:                this .renameProperty("workbench.javacode.codeprefix",
2422:                        "workbench.clipcreate.codeprefix");
2423:            }
2424:
2425:            private void renameProperty(String oldKey, String newKey) {
2426:                if (this .props.containsKey(oldKey)) {
2427:                    Object value = this .props.get(oldKey);
2428:                    this .props.remove(oldKey);
2429:                    this .props.put(newKey, value);
2430:                }
2431:            }
2432:
2433:            private void removeObsolete() {
2434:                try {
2435:                    this .props.remove("workbench.db.fetchsize");
2436:                    this .props.remove("workbench.editor.java.lastdir");
2437:                    this .props.remove("workbench.sql.replace.ignorecase");
2438:                    this .props.remove("workbench.sql.replace.selectedtext");
2439:                    this .props.remove("workbench.sql.replace.useregex");
2440:                    this .props.remove("workbench.sql.replace.wholeword");
2441:                    this .props.remove("workbench.sql.search.ignorecase");
2442:                    this .props.remove("workbench.sql.search.useregex");
2443:                    this .props.remove("workbench.sql.search.wholeword");
2444:                    this .props.remove("workbench.sql.search.lastvalue");
2445:                    this .props.remove("workbench.dbexplorer.rememberSchema");
2446:                    this .props
2447:                            .remove("workbench.db.postgres.select.startstransaction");
2448:                    this .props.remove("workbench.db.oracle.quotedigits");
2449:                    this .props.remove("workbench.gui.macros.replaceonrun");
2450:                    this .props.remove("workbench.db.cancelneedsreconnect");
2451:                    this .props.remove("workbench.db.trigger.replacenl");
2452:                    this .props.remove("workbench.sql.multipleresultsets");
2453:
2454:                    this .props.remove("workbench.db.keywordlist.oracle");
2455:                    this .props
2456:                            .remove("workbench.db.keywordlist.thinksql_relational_database_management_system");
2457:
2458:                    this .props
2459:                            .remove("workbench.gui.settings.ExternalToolsPanel.divider");
2460:                    this .props
2461:                            .remove("workbench.gui.settings.LnFOptionsPanel.divider");
2462:                    this .props
2463:                            .remove("workbench.gui.profiles.DriverlistEditorPanel.divider");
2464:
2465:                    this .props
2466:                            .remove("workbench.gui.dbobjects.TableListPanel.quickfilter.history");
2467:                    this .props
2468:                            .remove("workbench.gui.dbobjects.TableListPanel.quickfilter.lastvalue");
2469:
2470:                    boolean mySQLRemoved = getBoolProperty(
2471:                            "workbench.migrate.settings.mysql.cascade", false);
2472:                    if (!mySQLRemoved) {
2473:                        // Only remove them once!
2474:                        this .props
2475:                                .remove("workbench.db.drop.table.cascade.mysql");
2476:                        this .props
2477:                                .remove("workbench.db.drop.view.cascade.mysql");
2478:                        this .props
2479:                                .remove("workbench.db.drop.function.cascade.mysql");
2480:                        setProperty("workbench.migrate.settings.mysql.cascade",
2481:                                true);
2482:                    }
2483:
2484:                    // Starting with build 95 no default standard font should be used 
2485:                    // (to make sure the default font of the Look & Feel is used)
2486:                    // Only if the user sets one through the Options dialog
2487:                    // The "user-defined" standard font is then saved with 
2488:                    // the property key workbench.font.std.XXXX
2489:                    this .props.remove("workbench.font.standard.name");
2490:                    this .props.remove("workbench.font.standard.size");
2491:                    this .props.remove("workbench.font.standard.style");
2492:
2493:                    this .props
2494:                            .remove("workbench.db.sql_server.batchedstatements");
2495:                    this .props
2496:                            .remove("workbench.db.sql_server.currentcatalog.query");
2497:                    this .props
2498:                            .remove("workbench.db.sql_server.objectname.case");
2499:                    this .props
2500:                            .remove("workbench.db.sql_server.schemaname.case");
2501:
2502:                    this .props.remove("workbench.dbexplorer.visible");
2503:
2504:                    // DbMetadata now uses db2 as the dbid for all DB2 versions (stripping the _linux or _nt suffix)
2505:                    this .props
2506:                            .remove("workbench.db.db2_nt.currentschema.query");
2507:                    this .props
2508:                            .remove("workbench.db.objecttype.selectable.db2_nt");
2509:                    this .props.remove("workbench.db.db2_nt.synonymtypes");
2510:                    this .props
2511:                            .remove("workbench.db.db2_nt.additional.viewtypes");
2512:                    this .props.remove("workbench.db.db2_nt.retrieve_sequences");
2513:                    this .props
2514:                            .remove("workbench.db.db2_nt.additional.tabletypes");
2515:
2516:                    this .props
2517:                            .remove("workbench.sql.dbms_output.defaultbuffer");
2518:                    this .props.remove("workbench.sql.enable_dbms_output");
2519:
2520:                    this .props.remove("workbench.db.stripprocversion");
2521:                    this .props.remove("workbench.dbexplorer.cleardata");
2522:                    this .props.remove("workbench.db.verifydriverurl");
2523:                    this .props.remove("workbench.db.retrievepklist");
2524:                    this .props.remove("workbench.print.margin.bottom");
2525:                    this .props.remove("workbench.print.margin.left");
2526:                    this .props.remove("workbench.print.margin.right");
2527:                    this .props.remove("workbench.print.margin.top");
2528:                    this .props.remove("workbench.dbexplorer.defTableType");
2529:                    this .props.remove("workbench.dbexplorer.deftabletype");
2530:                } catch (Throwable e) {
2531:                    LogMgr.logWarning("Settings.removeObsolete()",
2532:                            "Error when removing obsolete properties", e);
2533:                }
2534:            }
2535:
2536:            private WbProperties getDefaultProperties() {
2537:                WbProperties defProps = new WbProperties(this );
2538:                InputStream in = ResourceMgr.getDefaultSettings();
2539:                try {
2540:                    defProps.load(in);
2541:                } catch (IOException e) {
2542:                    LogMgr.logError(this , "Could not read default settings", e);
2543:                } finally {
2544:                    try {
2545:                        in.close();
2546:                    } catch (Throwable th) {
2547:                    }
2548:                }
2549:                return defProps;
2550:            }
2551:
2552:            private void fillDefaults() {
2553:                InputStream in = ResourceMgr.getDefaultSettings();
2554:                try {
2555:                    this .props.load(in);
2556:                } catch (IOException e) {
2557:                    LogMgr.logError(this , "Could not read default settings", e);
2558:                } finally {
2559:                    try {
2560:                        in.close();
2561:                    } catch (Throwable th) {
2562:                    }
2563:                }
2564:            }
2565:
2566:            // </editor-fold>
2567:
2568:            public void saveSettings() {
2569:                if (this .props == null)
2570:                    return;
2571:                if (keyManager != null)
2572:                    this .keyManager.saveSettings();
2573:                try {
2574:                    this .props.saveToFile(this .configfile);
2575:                } catch (IOException e) {
2576:                    LogMgr.logError(this , "Error saving Settings file '"
2577:                            + configfile.getFullPath() + "'", e);
2578:                }
2579:                if (this .getPKMappingFilename() != null
2580:                        && PkMapping.isInitialized()) {
2581:                    PkMapping.getInstance().saveMapping(
2582:                            this .getPKMappingFilename());
2583:                }
2584:            }
2585:
2586:            public String toString() {
2587:                return "[Settings]";
2588:            }
2589:
2590:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.