public void dialogWillCloseOK() { String text = getTestRigText(); if (text.length() > Preferences.MAX_VALUE_LENGTH) { XJAlert.display( getJavaComponent(), "Error", "The test template text is too large: " + text.length() + " bytes but preferences can only hold " + Preferences.MAX_VALUE_LENGTH + " bytes. It will be truncated."); text = text.substring(0, Preferences.MAX_VALUE_LENGTH - 1); } setTestRigTemplateToFile(testRigFullPath, text); AWPrefs.setTestRigTemplateMode(grammarIdentifier, getTestRigMode()); AWPrefs.setTestRigTemplateClass(grammarIdentifier, getTestRigClass()); }
protected synchronized Map<Integer, Integer> getEvents() { if (events == null) { try { events = (Map<Integer, Integer>) AWPrefs.getPreferences().getObject(PREF_KEY, null); } catch (Exception e) { events = null; System.err.println("Statistics: " + e); } if (events == null) { events = new HashMap<Integer, Integer>(); initDate(); } } return events; }
public DialogTestTemplate(DebuggerTab debuggerTab, Container parent) { super(parent, true); this.debuggerTab = debuggerTab; qualifiedFileName = this.debuggerTab.getDelegate().getDocument().getDocumentPath(); if (qualifiedFileName != null) { testRigFullPath = XJUtils.getPathByDeletingPathExtension(qualifiedFileName) + DBLocal.testRigTemplateSuffix + ".st"; grammarIdentifier = qualifiedFileName.toUpperCase(); } if (this.debuggerTab.getDelegate().getGrammarEngine() != null) grammarLanguage = this.debuggerTab.getDelegate().getGrammarEngine().getGrammarLanguage(); initComponents(); if (XJSystem.isMacOS()) { buttonBar.remove(okButton); buttonBar.remove(cancelButton); CellConstraints cc = new CellConstraints(); buttonBar.add(cancelButton, cc.xy(2, 1)); buttonBar.add(okButton, cc.xy(4, 1)); } setDefaultButton(okButton); setOKButton(okButton); setCancelButton(cancelButton); TextUtils.createTabs(testTextArea); TextUtils.setDefaultTextPaneProperties(testTextArea); testTextArea.setFont( new Font(AWPrefs.getEditorFont(), Font.PLAIN, AWPrefs.getEditorFontSize())); testTextArea.setFocusable(true); testTextArea.requestFocusInWindow(); testTextArea.setText(getTestRigTemplateFromFile(testRigFullPath)); if ("".equals(testTextArea.getText())) { if (AWPrefs.TEST_RIG_MODE_DEFAULT.equals( AWPrefs.getTestRigTemplateModeByLanguage(grammarLanguage.toUpperCase()))) { testTextArea.setText(getDefaultTestRigByLanguage(grammarLanguage)); } else { testTextArea.setText( AWPrefs.getTestRigTemplateTextByLanguage(grammarLanguage.toUpperCase())); } } testClassHiddenField.setText(AWPrefs.getTestRigTemplateClass(grammarIdentifier)); testClassField.setText(testClassHiddenField.getText()); if ("".equals(testClassField.getText())) { testClassField.setForeground(Color.LIGHT_GRAY); testClassField.setText(TEXT_FULLY_QUALIFIED_CLASS_NAME); } textTestRadio.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (textTestRadio.isSelected()) { testTextArea.setEnabled(true); testClassField.setEnabled(false); } else { testTextArea.setEnabled(false); testClassField.setEnabled(true); } } }); classTestRadio.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (classTestRadio.isSelected()) { testTextArea.setEnabled(false); testClassField.setEnabled(true); } else { testTextArea.setEnabled(true); testClassField.setEnabled(false); } } }); if (AWPrefs.TEST_RIG_MODE_TEXT.equals(AWPrefs.getTestRigTemplateMode(grammarIdentifier))) { textTestRadio.setSelected(true); testTextArea.setEnabled(true); testClassField.setEnabled(false); } else { classTestRadio.setSelected(true); testTextArea.setEnabled(false); testClassField.setEnabled(true); } }
public void close() { AWPrefs.getPreferences().setObject(PREF_KEY, events); }
public String getFromDate() { return AWPrefs.getPreferences().getString(PREF_KEY_FROM_DATE, null); }
public void setFromDate(String date) { AWPrefs.getPreferences().setString(PREF_KEY_FROM_DATE, date); }