0001: /*
0002: * UIConfig.java Copyright (c) 2006,07 Swaroop Belur
0003: *
0004: * This program is free software; you can redistribute it and/or
0005: * modify it under the terms of the GNU General Public License
0006: * as published by the Free Software Foundation; either version 2
0007: * of the License, or (at your option) any later version.
0008:
0009: * This program is distributed in the hope that it will be useful,
0010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0012: * GNU General Public License for more details.
0013:
0014: * You should have received a copy of the GNU General Public License
0015: * along with this program; if not, write to the Free Software
0016: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017: *
0018: */
0019: package net.sf.jdec.ui.config;
0020:
0021: import net.sf.jdec.main.ConsoleLauncher;
0022: import net.sf.jdec.ui.main.UILauncher;
0023: import net.sf.jdec.ui.util.UIUtil;
0024: import net.sf.jdec.ui.util.highlight.CategoryChooser;
0025: import net.sf.jdec.ui.util.highlight.ColorChooser;
0026:
0027: import java.awt.*;
0028: import java.io.*;
0029: import java.util.*;
0030:
0031: public class UIConfig {
0032:
0033: private static UIConfig config = null;
0034:
0035: java.lang.String showConsole = "true";
0036: java.lang.String showFileDetail = "true";
0037: java.lang.String showStatusWindow = "true";
0038: java.lang.String lookAndFeelType = "windows";
0039: java.lang.String showAuxToolBar = "true"; // Auxiliary
0040:
0041: private UIConfig() {
0042: loadDefaultPrefs();
0043: }
0044:
0045: public static UIConfig getUIConfig() {
0046: if (config == null) {
0047: config = new UIConfig();
0048: return config;
0049: } else
0050: return config;
0051:
0052: }
0053:
0054: public void registerUIConfigInfo() {
0055:
0056: ResourceBundle rb = ResourceBundle.getBundle("uiconfig");
0057: readAllParameters(rb);
0058: }
0059:
0060: private void readAllParameters(ResourceBundle rb) {
0061: showConsole = rb.getString("Show_Console_Window").trim();
0062: showFileDetail = rb.getString("Show_FileDetail_Window").trim();
0063: showStatusWindow = rb.getString("Show_Status_Window").trim();
0064: lookAndFeelType = rb.getString("Look_N_Feel_Type").trim();
0065: showAuxToolBar = rb.getString("Show_Aux_Toolbar").trim();
0066: }
0067:
0068: Hashtable uiprefs = new Hashtable();
0069:
0070: private void loadDefaultPrefs() {
0071: addPref("JdecVerSion", "1.2.1");
0072: addPref("ShowTip", "true");
0073: }
0074:
0075: public void addPref(String name, String value) {
0076:
0077: uiprefs.put(name, value);
0078:
0079: }
0080:
0081: public String getPref(String name) {
0082: Iterator it = uiprefs.keySet().iterator();
0083: while (it.hasNext()) {
0084: String k = (String) it.next();
0085: if (k.equalsIgnoreCase(name)) {
0086: return (String) uiprefs.get(name);
0087: }
0088: }
0089: return null;
0090:
0091: }
0092:
0093: public synchronized void persistToFile() throws IOException {
0094: checkForMissingPrefs(uiprefs);
0095:
0096: String path = System.getProperty("user.home") + File.separator
0097: + "JDecUserPreferences.txt";
0098: File file = new File(path);
0099: if (!file.exists()) {
0100: file.createNewFile();
0101: } else {
0102: file.delete();
0103: file.createNewFile();
0104: }
0105:
0106: // For Favorite List
0107: String fl = getFavoriteListAsString();
0108: if (fl.length() != 0) {
0109: uiprefs.put("user_favorite_folder_list", fl);
0110: }
0111: uiprefs.put("JdecVerSion", "1.2.1");
0112: Iterator it = uiprefs.entrySet().iterator();
0113: BufferedWriter br = new BufferedWriter(new OutputStreamWriter(
0114: new FileOutputStream(file)));
0115: while (it.hasNext()) {
0116: Map.Entry entry = (Map.Entry) it.next();
0117: String key = (String) entry.getKey();
0118: String val = (String) entry.getValue();
0119: br.write(key + "=" + val);
0120: br.write("\n");
0121: }
0122: br.flush();
0123: br.close();
0124:
0125: }
0126:
0127: private boolean showTip = false;
0128:
0129: /**
0130: * @return Returns the showTip.
0131: */
0132: public boolean showTip() {
0133: return showTip;
0134: }
0135:
0136: /**
0137: * @param showTip The showTip to set.
0138: */
0139: public void setShowTip(boolean showTip) {
0140: this .showTip = showTip;
0141: }
0142:
0143: public void readUserPrefs() throws IOException {
0144: boolean jdecVersionPresent = false;
0145:
0146: String level = UILauncher.getUIutil().getLogLevel();
0147: String m = "Reading user preferences...";
0148:
0149: String path = System.getProperty("user.home") + File.separator
0150: + "JDecUserPreferences.txt";
0151: File file = new File(path);
0152: if (!file.exists()) {
0153: showTip = true;
0154: } else {
0155: BufferedReader br = new BufferedReader(
0156: new InputStreamReader(new FileInputStream(path)));
0157: String l = br.readLine();
0158: if (l == null) {
0159: showTip = true;
0160: return;
0161: }
0162: String s = l.trim();
0163: while (s != null) {
0164: if (s.indexOf("=") != -1) {
0165: String key = s.substring(0, s.indexOf("=")).trim();
0166: String value = s.substring(s.indexOf("=") + 1)
0167: .trim();
0168: if (key.equalsIgnoreCase("all_classes_in_archive")) {
0169: setAll_classes_in_archive(value);
0170: }
0171: if (key
0172: .equalsIgnoreCase("only_default_classes_in_archive")) {
0173: setOnly_default_classes_in_archive(value);
0174: }
0175: if (key
0176: .equalsIgnoreCase("enclosed_archives_in_archive")) {
0177: setEnclosed_archives_in_archive(value);
0178: }
0179:
0180: if (key.equalsIgnoreCase("JdecVerSion")) {
0181: uiprefs.put(key, value);
0182: jdecVersionPresent = true;
0183:
0184: if (value != null
0185: && !value.trim().equals("1.2.1")) {
0186: showTip = true;
0187: }
0188: }
0189:
0190: if (key.equalsIgnoreCase("userprojectHome")) {
0191: UILauncher.getUIutil().setUserProjFol(value);
0192: uiprefs.put(key, value);
0193:
0194: }
0195: if (key.equalsIgnoreCase("browserPath")) {
0196: UILauncher.getUIutil().setBrowserPath(
0197: new File(value));
0198: uiprefs.put(key, value);
0199:
0200: }
0201: if (key.equalsIgnoreCase("JavaHome")) {
0202: UILauncher.getUIutil().setJavaFolderPath(
0203: new File(value));
0204: uiprefs.put(key, value);
0205:
0206: }
0207: if (key.equalsIgnoreCase("ShowTip")) {
0208: //UILauncher.getUIutil().setShowTip(value);
0209: uiprefs.put(key, value);
0210:
0211: }
0212: if (key.equalsIgnoreCase("DefaultLNKFeel")) {
0213: UILauncher.getUIutil().setDefaultLnkNFeelName(
0214: value);
0215: uiprefs.put(key, value);
0216:
0217: }
0218: if (key.equalsIgnoreCase("ShowWelcomeAtStartUp")) {
0219: UILauncher.getUIutil()
0220: .setShowWelcomeScreenAtStartUp(value);
0221: uiprefs.put(key, value);
0222:
0223: }
0224: if (key.equalsIgnoreCase("DONTDECPVTMET")) {
0225: uiprefs.put(key, value);
0226:
0227: try {
0228: boolean z = new Boolean(value)
0229: .booleanValue();
0230: ConsoleLauncher.setDontpvtmethods(z);
0231: } catch (Exception e) {
0232: ConsoleLauncher.setDontpvtmethods(false);
0233: }
0234:
0235: }
0236: if (key.equalsIgnoreCase("DONTSHOWABSMET")) {
0237: uiprefs.put(key, value);
0238:
0239: try {
0240: boolean z = new Boolean(value)
0241: .booleanValue();
0242: ConsoleLauncher.setDontshowabs(z);
0243: } catch (Exception e) {
0244: ConsoleLauncher.setDontshowabs(false);
0245: }
0246:
0247: }
0248: if (key.equalsIgnoreCase("DONTDECSYNMET")) {
0249: uiprefs.put(key, value);
0250:
0251: try {
0252: boolean z = new Boolean(value)
0253: .booleanValue();
0254: ConsoleLauncher.setDontsynth(z);
0255: } catch (Exception e) {
0256: ConsoleLauncher.setDontsynth(false);
0257: }
0258:
0259: }
0260: if (key.equalsIgnoreCase("DONTDECSTATICINIT")) {
0261: uiprefs.put(key, value);
0262:
0263: try {
0264: boolean z = new Boolean(value)
0265: .booleanValue();
0266: ConsoleLauncher.setDontstaticinit(z);
0267: } catch (Exception e) {
0268: ConsoleLauncher.setDontstaticinit(false);
0269: }
0270: }
0271: if (key.equalsIgnoreCase("DONTSHOWEMPCONS")) {
0272: uiprefs.put(key, value);
0273:
0274: try {
0275: boolean z = new Boolean(value)
0276: .booleanValue();
0277: ConsoleLauncher.setDontshowemptyconst(z);
0278: } catch (Exception e) {
0279: ConsoleLauncher
0280: .setDontshowemptyconst(false);
0281: }
0282: }
0283: if (key.equalsIgnoreCase("DONTSHOWNAT")) {
0284: uiprefs.put(key, value);
0285:
0286: try {
0287: boolean z = new Boolean(value)
0288: .booleanValue();
0289: ConsoleLauncher.setDontshownative(z);
0290: } catch (Exception e) {
0291: ConsoleLauncher.setDontshownative(false);
0292: }
0293: }
0294:
0295: if (key.equalsIgnoreCase("SHOWFIELDSFIRST")) {
0296: uiprefs.put(key, value);
0297: try {
0298: boolean z = new Boolean(value)
0299: .booleanValue();
0300: ConsoleLauncher.setShowfieldsfirst(z);
0301: } catch (Exception e) {
0302: ConsoleLauncher.setShowfieldsfirst(true);
0303: }
0304: }
0305: if (key.equalsIgnoreCase("SHOWEXTENDSOBJECT")) {
0306: uiprefs.put(key, value);
0307:
0308: try {
0309: boolean z = new Boolean(value)
0310: .booleanValue();
0311: ConsoleLauncher.setShowObjectSuperClass(z);
0312: } catch (Exception e) {
0313: ConsoleLauncher
0314: .setShowObjectSuperClass(true);
0315: }
0316: }
0317: if (key.equalsIgnoreCase("SHOWCONSTFIRST")) {
0318: uiprefs.put(key, value);
0319:
0320: try {
0321: boolean z = new Boolean(value)
0322: .booleanValue();
0323: ConsoleLauncher.setShowconstfirst(z);
0324: } catch (Exception e) {
0325: ConsoleLauncher.setShowconstfirst(false);
0326: }
0327:
0328: }
0329: if (key.equalsIgnoreCase("INCLUDEDPKGS")) {
0330: if (value != null
0331: && value.equals("[]") == false) {
0332: uiprefs.put(key, value);
0333:
0334: StringTokenizer tokens = new StringTokenizer(
0335: value, ",");
0336: ArrayList includedList = new ArrayList();
0337: while (tokens.hasMoreTokens()) {
0338: java.lang.String str = (java.lang.String) tokens
0339: .nextToken();
0340: includedList.add(str);
0341: }
0342: ConsoleLauncher
0343: .setInclListInJar(includedList);
0344: }
0345: }
0346:
0347: if (key.equalsIgnoreCase("EXCLUDEDPKGSINIMPORT")) {
0348: if (value != null
0349: && value.equals("[]") == false) {
0350: uiprefs.put(key, value);
0351:
0352: StringTokenizer tokens = new StringTokenizer(
0353: value, ",");
0354: ArrayList exclList = new ArrayList();
0355: while (tokens.hasMoreTokens()) {
0356: java.lang.String str = (java.lang.String) tokens
0357: .nextToken();
0358: exclList.add(str);
0359: }
0360: ConsoleLauncher.setExclImpList(exclList);
0361: }
0362: }
0363: if (key.equalsIgnoreCase("keyword_backg_color")) {
0364: Color c = getColor(value);
0365: UILauncher.getUIConfigRef()
0366: .setCurrentBackGrndColor_KEYWORD(c);
0367: }
0368: if (key.equalsIgnoreCase("keyword_foreg_color")) {
0369: Color c = getColor(value);
0370: UILauncher.getUIConfigRef()
0371: .setCurrentForeGrndColor_KEYWORD(c);
0372: }
0373: if (key.equalsIgnoreCase("keyword_effect")) {
0374: UILauncher.getUIConfigRef().setEffectKEYWORD(
0375: value);
0376: }
0377:
0378: if (key.equalsIgnoreCase("number_backg_color")) {
0379: Color c = getColor(value);
0380: UILauncher.getUIConfigRef()
0381: .setCurrentBackGrndColor_NUMBER(c);
0382: }
0383: if (key.equalsIgnoreCase("number_foreg_color")) {
0384: Color c = getColor(value);
0385: UILauncher.getUIConfigRef()
0386: .setCurrentForeGrndColor_NUMBER(c);
0387: }
0388: if (key.equalsIgnoreCase("number_effect")) {
0389: UILauncher.getUIConfigRef().setEffectNUMBER(
0390: value);
0391: }
0392:
0393: if (key.equalsIgnoreCase("operator_backg_color")) {
0394: Color c = getColor(value);
0395: UILauncher.getUIConfigRef()
0396: .setCurrentBackGrndColor_OPERATOR(c);
0397: }
0398: if (key.equalsIgnoreCase("operator_foreg_color")) {
0399: Color c = getColor(value);
0400: UILauncher.getUIConfigRef()
0401: .setCurrentForeGrndColor_OPERATOR(c);
0402: }
0403: if (key.equalsIgnoreCase("operator_effect")) {
0404: UILauncher.getUIConfigRef().setEffectOP(value);
0405: }
0406: if (key.equalsIgnoreCase("string_backg_color")) {
0407: Color c = getColor(value);
0408: UILauncher.getUIConfigRef()
0409: .setCurrentBackGrndColor_STRING(c);
0410: }
0411: if (key.equalsIgnoreCase("string_foreg_color")) {
0412: Color c = getColor(value);
0413: UILauncher.getUIConfigRef()
0414: .setCurrentForeGrndColor_STRING(c);
0415: }
0416: if (key.equalsIgnoreCase("string_effect")) {
0417: UILauncher.getUIConfigRef().setEffectSTRING(
0418: value);
0419: }
0420: if (key.equalsIgnoreCase("enableSyntax")) {
0421: UILauncher.getUIConfigRef().setSyntaxEnabled(
0422: value);
0423: }
0424:
0425: if (key.equalsIgnoreCase("FavoriteEditor")) {
0426: UILauncher.getUIConfigRef()
0427: .setCustomeEditorPath(value);
0428: }
0429:
0430: if (key.equalsIgnoreCase("font_family_kwd")) {
0431: UILauncher.getUIConfigRef().setFontFamilykwd(
0432: value);
0433: }
0434: if (key.equalsIgnoreCase("font_family_num")) {
0435: UILauncher.getUIConfigRef().setFontFamilynum(
0436: value);
0437: }
0438: if (key.equalsIgnoreCase("font_family_op")) {
0439: UILauncher.getUIConfigRef().setFontFamilyop(
0440: value);
0441: }
0442: if (key.equalsIgnoreCase("font_family_str")) {
0443: UILauncher.getUIConfigRef().setFontFamilystr(
0444: value);
0445: }
0446:
0447: if (key.equalsIgnoreCase("font_size_kwd")) {
0448: UILauncher.getUIConfigRef().setFontSizekwd(
0449: value);
0450: }
0451: if (key.equalsIgnoreCase("font_size_num")) {
0452: UILauncher.getUIConfigRef().setFontSizenum(
0453: value);
0454: }
0455: if (key.equalsIgnoreCase("font_size_op")) {
0456: UILauncher.getUIConfigRef()
0457: .setFontSizeop(value);
0458: }
0459: if (key.equalsIgnoreCase("font_size_str")) {
0460: UILauncher.getUIConfigRef().setFontSizestr(
0461: value);
0462: }
0463: if (key
0464: .equalsIgnoreCase("registered_archive_types")) {
0465: /*ArrayList list=new ArrayList();
0466: String v=value;
0467: if(v!=null)
0468: {
0469: StringTokenizer all=new StringTokenizer(v,",");
0470: while(all.hasMoreTokens())
0471: {
0472: String t=(String)all.nextToken();
0473: list.add(t);
0474: }
0475: }
0476: else
0477: {
0478: list.add("jar");
0479: list.add("zip");
0480: }
0481: ArchiveSettings.currentlist=list;*/
0482: setArchiveTypes(value);
0483:
0484: }
0485: if (key
0486: .equalsIgnoreCase("user_favorite_folder_list")) {
0487: formFavListFromFavString(value);
0488: }
0489:
0490: }
0491:
0492: // note: Add here Other entries
0493: String tmp = br.readLine();
0494: if (tmp == null)
0495: break;
0496: s = tmp.trim();
0497:
0498: }
0499:
0500: if (jdecVersionPresent == false) {
0501: showTip = true;
0502: }
0503:
0504: }
0505:
0506: }
0507:
0508: private String all_classes_in_archive = "true";
0509: private String only_default_classes_in_archive = "false";
0510: private String enclosed_archives_in_archive = "false";
0511:
0512: private String archiveTypes = "jar,zip";
0513:
0514: public void setArchiveTypes(String list) {
0515: archiveTypes = list;
0516: }
0517:
0518: public String getArchiveTypes() {
0519: return archiveTypes;
0520: }
0521:
0522: public Object removePref(java.lang.String key) {
0523: Object o = uiprefs.remove(key);
0524: return o;
0525: }
0526:
0527: /***
0528: * belurs:
0529: * Methods Used by Syntax module
0530: *
0531: **/
0532:
0533: public Color getCurrentForeGrndColor_KEYWORD_PREVW() {
0534: return currentForeGrndColor_KEYWORD_PREVW;
0535: }
0536:
0537: public void setCurrentForeGrndColor_KEYWORD_PREVW(
0538: Color currentForeGrndColor_KEYWORD_PREVW) {
0539: this .currentForeGrndColor_KEYWORD_PREVW = currentForeGrndColor_KEYWORD_PREVW;
0540: }
0541:
0542: public Color getCurrentBackGrndColor_KEYWORD_PREVW() {
0543: return currentBackGrndColor_KEYWORD_PREVW;
0544: }
0545:
0546: public void setCurrentBackGrndColor_KEYWORD_PREVW(
0547: Color currentBackGrndColor_KEYWORD_PREVW) {
0548: this .currentBackGrndColor_KEYWORD_PREVW = currentBackGrndColor_KEYWORD_PREVW;
0549: }
0550:
0551: private Color currentForeGrndColor_KEYWORD_PREVW = null;
0552: private Color currentBackGrndColor_KEYWORD_PREVW = null;
0553:
0554: private Color currentForeGrndColor_KEYWORD = null;
0555: private Color currentBackGrndColor_KEYWORD = null;
0556:
0557: public Color getCurrentBackGrndColor_KEYWORD() {
0558: return currentBackGrndColor_KEYWORD;
0559: }
0560:
0561: public void setCurrentBackGrndColor_KEYWORD(
0562: Color currentBackGrndColor_KEYWORD) {
0563: this .currentBackGrndColor_KEYWORD = currentBackGrndColor_KEYWORD;
0564: }
0565:
0566: public Color getCurrentForeGrndColor_KEYWORD() {
0567: return currentForeGrndColor_KEYWORD;
0568: }
0569:
0570: public void setCurrentForeGrndColor_KEYWORD(
0571: Color currentForeGrndColor_KEYWORD) {
0572: this .currentForeGrndColor_KEYWORD = currentForeGrndColor_KEYWORD;
0573: }
0574:
0575: public Color getCurrentForeGrndColor_STRING_PREVW() {
0576: return currentForeGrndColor_STRING_PREVW;
0577: }
0578:
0579: public void setCurrentForeGrndColor_STRING_PREVW(
0580: Color currentForeGrndColor_STRING_PREVW) {
0581: this .currentForeGrndColor_STRING_PREVW = currentForeGrndColor_STRING_PREVW;
0582: }
0583:
0584: public Color getCurrentBackGrndColor_STRING_PREVW() {
0585: return currentBackGrndColor_STRING_PREVW;
0586: }
0587:
0588: public void setCurrentBackGrndColor_STRING_PREVW(
0589: Color currentBackGrndColor_STRING_PREVW) {
0590: this .currentBackGrndColor_STRING_PREVW = currentBackGrndColor_STRING_PREVW;
0591: }
0592:
0593: private Color currentForeGrndColor_STRING_PREVW = null;
0594: private Color currentBackGrndColor_STRING_PREVW = null;
0595:
0596: private Color currentForeGrndColor_STRING = null;
0597: private Color currentBackGrndColor_STRING = null;
0598:
0599: public Color getCurrentBackGrndColor_STRING() {
0600: return currentBackGrndColor_STRING;
0601: }
0602:
0603: public void setCurrentBackGrndColor_STRING(
0604: Color currentBackGrndColor_STRING) {
0605: this .currentBackGrndColor_STRING = currentBackGrndColor_STRING;
0606: }
0607:
0608: public Color getCurrentForeGrndColor_STRING() {
0609: return currentForeGrndColor_STRING;
0610: }
0611:
0612: public void setCurrentForeGrndColor_STRING(
0613: Color currentForeGrndColor_STRING) {
0614: this .currentForeGrndColor_STRING = currentForeGrndColor_STRING;
0615: }
0616:
0617: public Color getCurrentForeGrndColor_NUMBER_PREVW() {
0618: return currentForeGrndColor_NUMBER_PREVW;
0619: }
0620:
0621: public void setCurrentForeGrndColor_NUMBER_PREVW(
0622: Color currentForeGrndColor_NUMBER_PREVW) {
0623: this .currentForeGrndColor_NUMBER_PREVW = currentForeGrndColor_NUMBER_PREVW;
0624: }
0625:
0626: public Color getCurrentBackGrndColor_NUMBER_PREVW() {
0627: return currentBackGrndColor_NUMBER_PREVW;
0628: }
0629:
0630: public void setCurrentBackGrndColor_NUMBER_PREVW(
0631: Color currentBackGrndColor_NUMBER_PREVW) {
0632: this .currentBackGrndColor_NUMBER_PREVW = currentBackGrndColor_NUMBER_PREVW;
0633: }
0634:
0635: private Color currentForeGrndColor_NUMBER_PREVW = null;
0636: private Color currentBackGrndColor_NUMBER_PREVW = null;
0637:
0638: private Color currentForeGrndColor_NUMBER = null;
0639: private Color currentBackGrndColor_NUMBER = null;
0640:
0641: public Color getCurrentBackGrndColor_NUMBER() {
0642: return currentBackGrndColor_NUMBER;
0643: }
0644:
0645: public void setCurrentBackGrndColor_NUMBER(
0646: Color currentBackGrndColor_NUMBER) {
0647: this .currentBackGrndColor_NUMBER = currentBackGrndColor_NUMBER;
0648: }
0649:
0650: public Color getCurrentForeGrndColor_NUMBER() {
0651: return currentForeGrndColor_NUMBER;
0652: }
0653:
0654: public void setCurrentForeGrndColor_NUMBER(
0655: Color currentForeGrndColor_NUMBER) {
0656: this .currentForeGrndColor_NUMBER = currentForeGrndColor_NUMBER;
0657: }
0658:
0659: public Color getCurrentForeGrndColor_OPERATOR_PREVW() {
0660: return currentForeGrndColor_OPERATOR_PREVW;
0661: }
0662:
0663: public void setCurrentForeGrndColor_OPERATOR_PREVW(
0664: Color currentForeGrndColor_OPERATOR_PREVW) {
0665: this .currentForeGrndColor_OPERATOR_PREVW = currentForeGrndColor_OPERATOR_PREVW;
0666: }
0667:
0668: public Color getCurrentBackGrndColor_OPERATOR_PREVW() {
0669: return currentBackGrndColor_OPERATOR_PREVW;
0670: }
0671:
0672: public void setCurrentBackGrndColor_OPERATOR_PREVW(
0673: Color currentBackGrndColor_OPERATOR_PREVW) {
0674: this .currentBackGrndColor_OPERATOR_PREVW = currentBackGrndColor_OPERATOR_PREVW;
0675: }
0676:
0677: private Color currentForeGrndColor_OPERATOR_PREVW = null;
0678: private Color currentBackGrndColor_OPERATOR_PREVW = null;
0679:
0680: private Color currentForeGrndColor_OPERATOR = null;
0681: private Color currentBackGrndColor_OPERATOR = null;
0682:
0683: public Color getCurrentBackGrndColor_OPERATOR() {
0684: return currentBackGrndColor_OPERATOR;
0685: }
0686:
0687: public void setCurrentBackGrndColor_OPERATOR(
0688: Color currentBackGrndColor_OPERATOR) {
0689: this .currentBackGrndColor_OPERATOR = currentBackGrndColor_OPERATOR;
0690: }
0691:
0692: public Color getCurrentForeGrndColor_OPERATOR() {
0693: return currentForeGrndColor_OPERATOR;
0694: }
0695:
0696: public void setCurrentForeGrndColor_OPERATOR(
0697: Color currentForeGrndColor_OPERATOR) {
0698: this .currentForeGrndColor_OPERATOR = currentForeGrndColor_OPERATOR;
0699: }
0700:
0701: private String effectKEYWORD = null;
0702:
0703: public String getEffectKEYWORD_PREVW() {
0704: return effectKEYWORD_PREVW;
0705: }
0706:
0707: public void setEffectKEYWORD_PREVW(String effectKEYWORD_PREVW) {
0708: this .effectKEYWORD_PREVW = effectKEYWORD_PREVW;
0709: }
0710:
0711: private String effectKEYWORD_PREVW = null;
0712:
0713: private String effectSTRING = null;
0714: private String effectNUMBER = null;
0715: private String effectOP = null;
0716:
0717: public String getEffectSTRING_PREVW() {
0718: return effectSTRING_PREVW;
0719: }
0720:
0721: public void setEffectSTRING_PREVW(String effectSTRING_PREVW) {
0722: this .effectSTRING_PREVW = effectSTRING_PREVW;
0723: }
0724:
0725: public String getEffectNUMBER_PREVW() {
0726: return effectNUMBER_PREVW;
0727: }
0728:
0729: public void setEffectNUMBER_PREVW(String effectNUMBER_PREVW) {
0730: this .effectNUMBER_PREVW = effectNUMBER_PREVW;
0731: }
0732:
0733: public String getEffectOP_PREVW() {
0734: return effectOP_PREVW;
0735: }
0736:
0737: public void setEffectOP_PREVW(String effectOP_PREVW) {
0738: this .effectOP_PREVW = effectOP_PREVW;
0739: }
0740:
0741: private String effectSTRING_PREVW = null;
0742: private String effectNUMBER_PREVW = null;
0743: private String effectOP_PREVW = null;
0744:
0745: public String getSyntaxEnabled() {
0746: return syntaxEnabled;
0747: }
0748:
0749: private String syntaxEnabled = null;
0750:
0751: public String getEffectKEYWORD() {
0752: return effectKEYWORD;
0753: }
0754:
0755: public void setEffectKEYWORD(String effectKEYWORD) {
0756: this .effectKEYWORD = effectKEYWORD;
0757: }
0758:
0759: public String getEffectNUMBER() {
0760: return effectNUMBER;
0761: }
0762:
0763: public void setEffectNUMBER(String effectNUMBER) {
0764: this .effectNUMBER = effectNUMBER;
0765: }
0766:
0767: public String getEffectOP() {
0768: return effectOP;
0769: }
0770:
0771: public void setEffectOP(String effectOP) {
0772: this .effectOP = effectOP;
0773: }
0774:
0775: public String getEffectSTRING() {
0776: return effectSTRING;
0777: }
0778:
0779: public void setEffectSTRING(String effectSTRING) {
0780: this .effectSTRING = effectSTRING;
0781: }
0782:
0783: public void setSyntaxEnabled(String enabled) {
0784: this .syntaxEnabled = enabled;
0785: }
0786:
0787: private Color getColor(String s) {
0788: int s1 = s.indexOf("[");
0789: if (s1 == -1)
0790: return null;
0791: int s2 = s.indexOf("]");
0792: String s3 = s.substring(s1 + 1, s2);
0793: StringTokenizer sk = new StringTokenizer(s3, ",");
0794: int cls[] = new int[3];
0795: int r = -1;
0796: int g = -1;
0797: int b = -1;
0798: int i = 0;
0799: while (sk.hasMoreTokens()) {
0800: String t = (String) sk.nextToken();
0801: t = t.trim();
0802: cls[i] = Integer.parseInt(t);
0803: i++;
0804: }
0805:
0806: r = cls[0];
0807: g = cls[1];
0808: b = cls[2];
0809: return new Color(r, g, b);
0810: }
0811:
0812: public CategoryChooser cc = null;
0813:
0814: private ColorChooser currentColorChooser = null;
0815:
0816: public void setColorChooserRef(ColorChooser c) {
0817: currentColorChooser = c;
0818: }
0819:
0820: public ColorChooser getCurrentColorChooser() {
0821: return currentColorChooser;
0822: }
0823:
0824: private String fontFamilykwd;
0825: private String fontFamilystr;
0826: private String fontFamilyop;
0827: private String fontFamilynum;
0828:
0829: private String fontSizekwd;
0830: private String fontSizestr;
0831: private String fontSizeop;
0832: private String fontSizenum;
0833:
0834: private void checkForMissingPrefs(Hashtable prefs) {
0835: checkForMissingColorsAndFonts(prefs);
0836: checkForOtherMissingPrefs(uiprefs);
0837: }
0838:
0839: private void checkForOtherMissingPrefs(Hashtable uiprefs) {
0840: Object key = uiprefs.get("JavaHome");
0841: if (key == null) {
0842: String java = UILauncher.getUIutil().getJavaHomePath();
0843: if (java != null) {
0844: uiprefs.put("JavaHome", java);
0845: }
0846: }
0847: key = uiprefs.get("ShowWelcomeAtStartUp");
0848: if (key == null) {
0849: String show = UILauncher.getUIutil().getShowWelcome();
0850: uiprefs.put("ShowWelcomeAtStartUp", show);
0851: }
0852: key = uiprefs.get("browserPath");
0853: if (key == null) {
0854: File bpath = UILauncher.getUIutil().getBrowserPath();
0855: if (bpath != null) {
0856: String browser = bpath.getAbsolutePath();
0857: uiprefs.put("browserPath", browser);
0858: }
0859: }
0860: key = uiprefs.get("FavoriteEditor");
0861: if (key == null) {
0862: String ced = UILauncher.getUIConfigRef()
0863: .getCustomeEditorPath();
0864: if (ced != null) {
0865: uiprefs.put("FavoriteEditor", ced);
0866: }
0867:
0868: }
0869: key = uiprefs.get("enableSyntax");
0870: if (key == null) {
0871: String syn = UILauncher.getUIConfigRef().getSyntaxEnabled();
0872: if (syn != null) {
0873: uiprefs.put("enableSyntax", syn);
0874: }
0875: }
0876: key = uiprefs.get("DefaultLNKFeel");
0877: if (key == null) {
0878: String look = UILauncher.getUIutil()
0879: .getDefaultLnkNFeelName();
0880: if (look != null) {
0881: uiprefs.put("DefaultLNKFeel", look);
0882: }
0883: }
0884: key = uiprefs.get("userprojectHome");
0885: if (key == null) {
0886: String projfol = UILauncher.getUIutil().getUserProjFol();
0887: if (projfol != null) {
0888: uiprefs.put("userprojectHome", projfol);
0889: }
0890: }
0891:
0892: key = uiprefs.get("DONTDECPVTMET");
0893: if (key == null) {
0894: String pvt = "" + ConsoleLauncher.isDontpvtmethods();
0895: if (pvt != null) {
0896: uiprefs.put("DONTDECPVTMET", pvt);
0897: }
0898: }
0899:
0900: key = uiprefs.get("DONTSHOWABSMET");
0901: if (key == null) {
0902: String abs = "" + ConsoleLauncher.isDontshowabs();
0903: if (abs != null) {
0904: uiprefs.put("DONTSHOWABSMET", abs);
0905: }
0906: }
0907: key = uiprefs.get("DONTDECSYNMET");
0908: if (key == null) {
0909: String syn = "" + ConsoleLauncher.isDontsynth();
0910: if (syn != null) {
0911: uiprefs.put("DONTDECSYNMET", syn);
0912: }
0913: }
0914: key = uiprefs.get("DONTDECSTATICINIT");
0915: if (key == null) {
0916: String sta = "" + ConsoleLauncher.isDontstaticinit();
0917: if (sta != null) {
0918: uiprefs.put("DONTDECSTATICINIT", sta);
0919: }
0920: }
0921: key = uiprefs.get("DONTSHOWEMPCONS");
0922: if (key == null) {
0923: String con = "" + ConsoleLauncher.isDontshowemptyconst();
0924: if (con != null) {
0925: uiprefs.put("DONTSHOWEMPCONS", con);
0926: }
0927: }
0928: key = uiprefs.get("DONTSHOWNAT");
0929: if (key == null) {
0930: String nat = "" + ConsoleLauncher.isDontshownative();
0931: if (nat != null) {
0932: uiprefs.put("DONTSHOWNAT", nat);
0933: }
0934: }
0935: key = uiprefs.get("INCLUDEDPKGS");
0936: if (key == null) {
0937: String incl = "" + ConsoleLauncher.getInclList();
0938: if (incl != null) {
0939: uiprefs.put("INCLUDEDPKGS", incl);
0940: }
0941: }
0942: key = uiprefs.get("EXCLUDEDPKGSINIMPORT");
0943: if (key == null) {
0944: String excl = "" + ConsoleLauncher.getExclList();
0945: if (excl != null) {
0946: uiprefs.put("EXCLUDEDPKGSINIMPORT", excl);
0947: }
0948: }
0949:
0950: key = uiprefs.get("all_classes_in_archive");
0951: if (key == null) {
0952: String excl = getAll_classes_in_archive();
0953: if (excl != null) {
0954: uiprefs.put("all_classes_in_archive", excl);
0955: }
0956: }
0957: key = uiprefs.get("only_default_classes_in_archive");
0958: if (key == null) {
0959: String excl = getOnly_default_classes_in_archive();
0960: if (excl != null) {
0961: uiprefs.put("only_default_classes_in_archive", excl);
0962: }
0963: }
0964:
0965: key = uiprefs.get("enclosed_archives_in_archive");
0966: if (key == null) {
0967: String excl = getEnclosed_archives_in_archive();
0968: if (excl != null) {
0969: uiprefs.put("enclosed_archives_in_archive", excl);
0970: }
0971: }
0972:
0973: key = uiprefs.get("registered_archive_types");
0974: if (key == null) {
0975: String excl = getArchiveTypes();
0976: if (excl != null) {
0977: uiprefs.put("registered_archive_types", excl);
0978: } else {
0979: excl = "jar,zip";
0980: uiprefs.put("registered_archive_types", excl);
0981: }
0982: }
0983:
0984: }
0985:
0986: private void checkForMissingColorsAndFonts(Hashtable uiprefs) {
0987:
0988: Object val = uiprefs.get("keyword_backg_color");
0989: if (val == null) {
0990: Color c = getCurrentBackGrndColor_KEYWORD();
0991: if (c != null) {
0992: String t = "[" + c.getRed() + "," + c.getGreen() + ","
0993: + c.getBlue() + "]";
0994: uiprefs.put("keyword_backg_color", t);
0995: }
0996: }
0997: val = uiprefs.get("keyword_foreg_color");
0998: if (val == null) {
0999: Color c = getCurrentForeGrndColor_KEYWORD();
1000: if (c != null) {
1001: String t = "[" + c.getRed() + "," + c.getGreen() + ","
1002: + c.getBlue() + "]";
1003: uiprefs.put("keyword_foreg_color", t);
1004: }
1005: }
1006: val = uiprefs.get("keyword_effect");
1007: if (val == null) {
1008: String c = getEffectKEYWORD();
1009: if (c != null) {
1010: uiprefs.put("keyword_effect", c);
1011: }
1012: }
1013:
1014: val = uiprefs.get("number_backg_color");
1015: if (val == null) {
1016: Color c = getCurrentBackGrndColor_NUMBER();
1017: if (c != null) {
1018: String t = "[" + c.getRed() + "," + c.getGreen() + ","
1019: + c.getBlue() + "]";
1020: uiprefs.put("number_backg_color", t);
1021: }
1022: }
1023: val = uiprefs.get("number_foreg_color");
1024: if (val == null) {
1025: Color c = getCurrentForeGrndColor_NUMBER();
1026: if (c != null) {
1027: String t = "[" + c.getRed() + "," + c.getGreen() + ","
1028: + c.getBlue() + "]";
1029: uiprefs.put("number_foreg_color", t);
1030: }
1031: }
1032: val = uiprefs.get("number_effect");
1033: if (val == null) {
1034: String c = getEffectNUMBER();
1035: if (c != null) {
1036: uiprefs.put("number_effect", c);
1037: }
1038: }
1039:
1040: val = uiprefs.get("operator_backg_color");
1041: if (val == null) {
1042: Color c = getCurrentBackGrndColor_OPERATOR();
1043: if (c != null) {
1044: String t = "[" + c.getRed() + "," + c.getGreen() + ","
1045: + c.getBlue() + "]";
1046: uiprefs.put("operator_backg_color", t);
1047: }
1048: }
1049: val = uiprefs.get("operator_foreg_color");
1050: if (val == null) {
1051: Color c = getCurrentForeGrndColor_OPERATOR();
1052: if (c != null) {
1053: String t = "[" + c.getRed() + "," + c.getGreen() + ","
1054: + c.getBlue() + "]";
1055: uiprefs.put("operator_foreg_color", t);
1056: }
1057: }
1058: val = uiprefs.get("operator_effect");
1059: if (val == null) {
1060: String c = getEffectOP();
1061: if (c != null) {
1062: uiprefs.put("operator_effect", c);
1063: }
1064: }
1065:
1066: val = uiprefs.get("string_backg_color");
1067: if (val == null) {
1068: Color c = getCurrentBackGrndColor_STRING();
1069: if (c != null) {
1070: String t = "[" + c.getRed() + "," + c.getGreen() + ","
1071: + c.getBlue() + "]";
1072: uiprefs.put("string_backg_color", t);
1073: }
1074: }
1075: val = uiprefs.get("string_foreg_color");
1076: if (val == null) {
1077: Color c = getCurrentForeGrndColor_STRING();
1078: if (c != null) {
1079: String t = "[" + c.getRed() + "," + c.getGreen() + ","
1080: + c.getBlue() + "]";
1081: uiprefs.put("string_foreg_color", t);
1082: }
1083: }
1084: val = uiprefs.get("string_effect");
1085: if (val == null) {
1086: String c = getEffectSTRING();
1087: if (c != null) {
1088: uiprefs.put("string_effect", c);
1089: }
1090: }
1091:
1092: val = uiprefs.get("font_family_kwd");
1093: if (val == null) {
1094: String c = getFontFamilykwd();
1095: if (c != null) {
1096: uiprefs.put("font_family_kwd", c);
1097: }
1098: }
1099:
1100: val = uiprefs.get("font_family_num");
1101: if (val == null) {
1102: String c = getFontFamilynum();
1103: if (c != null) {
1104: uiprefs.put("font_family_num", c);
1105: }
1106: }
1107:
1108: val = uiprefs.get("font_family_op");
1109: if (val == null) {
1110: String c = getFontFamilyop();
1111: if (c != null) {
1112: uiprefs.put("font_family_op", c);
1113: }
1114: }
1115:
1116: val = uiprefs.get("font_family_str");
1117: if (val == null) {
1118: String c = getFontFamilystr();
1119: if (c != null) {
1120: uiprefs.put("font_family_str", c);
1121: }
1122: }
1123:
1124: val = uiprefs.get("font_size_kwd");
1125: if (val == null) {
1126: String c = getFontSizekwd();
1127: if (c != null) {
1128: uiprefs.put("font_size_kwd", c);
1129: }
1130: }
1131:
1132: val = uiprefs.get("font_size_op");
1133: if (val == null) {
1134: String c = getFontSizeop();
1135: if (c != null) {
1136: uiprefs.put("font_size_op", c);
1137: }
1138: }
1139:
1140: val = uiprefs.get("font_size_num");
1141: if (val == null) {
1142: String c = getFontSizenum();
1143: if (c != null) {
1144: uiprefs.put("font_size_num", c);
1145: }
1146: }
1147:
1148: val = uiprefs.get("font_size_str");
1149: if (val == null) {
1150: String c = getFontSizestr();
1151: if (c != null) {
1152: uiprefs.put("font_size_str", c);
1153: }
1154: }
1155:
1156: }
1157:
1158: public String getFontFamilykwd() {
1159: return fontFamilykwd;
1160: }
1161:
1162: public void setFontFamilykwd(String fontFamilykwd) {
1163: this .fontFamilykwd = fontFamilykwd;
1164: }
1165:
1166: public String getFontFamilynum() {
1167: return fontFamilynum;
1168: }
1169:
1170: public void setFontFamilynum(String fontFamilynum) {
1171: this .fontFamilynum = fontFamilynum;
1172: }
1173:
1174: public String getFontFamilyop() {
1175: return fontFamilyop;
1176: }
1177:
1178: public void setFontFamilyop(String fontFamilyop) {
1179: this .fontFamilyop = fontFamilyop;
1180: }
1181:
1182: public String getFontFamilystr() {
1183: return fontFamilystr;
1184: }
1185:
1186: public void setFontFamilystr(String fontFamilystr) {
1187: this .fontFamilystr = fontFamilystr;
1188: }
1189:
1190: public String getFontSizekwd() {
1191: return fontSizekwd;
1192: }
1193:
1194: public void setFontSizekwd(String fontSizekwd) {
1195: this .fontSizekwd = fontSizekwd;
1196: }
1197:
1198: public String getFontSizenum() {
1199: return fontSizenum;
1200: }
1201:
1202: public void setFontSizenum(String fontSizenum) {
1203: this .fontSizenum = fontSizenum;
1204: }
1205:
1206: public String getFontSizeop() {
1207: return fontSizeop;
1208: }
1209:
1210: public void setFontSizeop(String fontSizeop) {
1211: this .fontSizeop = fontSizeop;
1212: }
1213:
1214: public String getFontSizestr() {
1215: return fontSizestr;
1216: }
1217:
1218: public void setFontSizestr(String fontSizestr) {
1219: this .fontSizestr = fontSizestr;
1220: }
1221:
1222: public static Color defaultBackgColor = Color.WHITE;
1223:
1224: public String getCustomeEditorPath() {
1225: return customeEditorPath;
1226: }
1227:
1228: public void setCustomeEditorPath(String customeEditorPath) {
1229: this .customeEditorPath = customeEditorPath;
1230: }
1231:
1232: private String customeEditorPath = null;
1233:
1234: public File getCurrentOpFile() {
1235: return currentOpFile;
1236: }
1237:
1238: private File currentOpFile = null;
1239:
1240: public void setCurrentResultFile(File d) {
1241: currentOpFile = d;
1242:
1243: }
1244:
1245: public String getAll_classes_in_archive() {
1246: return all_classes_in_archive;
1247: }
1248:
1249: public void setAll_classes_in_archive(String all_classes_in_archive) {
1250: this .all_classes_in_archive = all_classes_in_archive;
1251: }
1252:
1253: public String getEnclosed_archives_in_archive() {
1254: return enclosed_archives_in_archive;
1255: }
1256:
1257: public void setEnclosed_archives_in_archive(
1258: String enclosed_archives_in_archive) {
1259: this .enclosed_archives_in_archive = enclosed_archives_in_archive;
1260: }
1261:
1262: public String getOnly_default_classes_in_archive() {
1263: return only_default_classes_in_archive;
1264: }
1265:
1266: public void setOnly_default_classes_in_archive(String s) {
1267: this .only_default_classes_in_archive = s;
1268: }
1269:
1270: private ArrayList favoriteList = new ArrayList();
1271:
1272: public ArrayList currentFavoriteList() {
1273: return favoriteList;
1274: }
1275:
1276: public void setFavoriteList(ArrayList list) {
1277: favoriteList = list;
1278: }
1279:
1280: public String getFavoriteListAsString() {
1281: String s = "[";
1282: if (favoriteList.size() > 0) {
1283: for (int z = 0; z < favoriteList.size(); z++) {
1284: s += favoriteList.get(z).toString();
1285: if (z < (favoriteList.size() - 1)) {
1286: s += ",";
1287: }
1288: }
1289: s += "]";
1290: return s;
1291: } else
1292: return "";
1293: }
1294:
1295: public String[] getFavoriteListAsArray() {
1296:
1297: if (favoriteList.size() > 0) {
1298: String s[] = new String[favoriteList.size()];
1299: for (int z = 0; z < favoriteList.size(); z++) {
1300: s[z] = favoriteList.get(z).toString();
1301:
1302: }
1303:
1304: return s;
1305: } else
1306: return null;
1307: }
1308:
1309: public void formFavListFromFavString(String s) {
1310: if (s != null && s.length() > 0) {
1311: ArrayList list = new ArrayList();
1312: int index1 = s.indexOf("[");
1313: int index2 = s.indexOf("]");
1314: if (index1 != -1 && index2 != -1) {
1315: s = s.substring(index1 + 1, index2);
1316: StringTokenizer st = new StringTokenizer(s, ",");
1317: while (st.hasMoreTokens()) {
1318: String t = (String) st.nextToken();
1319: list.add(t);
1320: }
1321: if (list.size() > 0) {
1322: setFavoriteList(list);
1323: UIUtil.getUIUtil().setFavList(list);
1324: }
1325: }
1326: }
1327:
1328: }
1329:
1330: }
|