summaryrefslogtreecommitdiff
path: root/javax
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2005-05-20 18:20:46 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2005-05-20 18:20:46 +0000
commitc521023082fc793b1236b9964f0efaffc0aec767 (patch)
treefc3c9b5ec9734e75db6d555a2624ea11b1467868 /javax
parentce52995bef1e166d56cbfe68770c19e43ce50765 (diff)
downloadclasspath-c521023082fc793b1236b9964f0efaffc0aec767.tar.gz
2005-05-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Merge of HEAD to generics-branch for 2005/04/28 - 2005/05/19 Changelog: 2005-05-19 Andrew John Hughes <gnu_andrew@member.fsf.org> * java/net/URI.java: Added more documentation. (RFC2396_MARK): Removed. (RFC2396_UNRESERVED): Changed to RFC3986_UNRESERVED and updated. (RFC2396_REG_NAME): Changed to RFC3986_REG_NAME and updated. (RFC2396_PCHAR): Changed to RFC3986_PCHAR and updated. (RFC2396_SEGMENT): Changed to RFC3986_SEGMENT and updated. (RFC2396_PATH_SEGMENTS): Changed to RFC3986_PATH_SEGMENTS. (RFC3986_UNRESERVED): New field. (RFC3986_SSP): New field. (RFC3986_HOST): New field. (RFC3986_USERINFO): New field. (static): New initializer to initialize patterns with class. (parseURI()): Moved authority parsing to parseServerAuthority(). (unquote(String)): Removed invalid exception for non-ASCII chars. (quote(String)): Implemented. (quoteAuthority(String)): Adapted to use new fields. (quote(String,String)): Moved escaping of characters to another method. (quoteHost(String)): Implemented. (quotePath(String)): Adapted to use new fields. (quoteUserInfo(String)): Implemented. (parseServerAuthority()): Implemented. (normalize()): Implemented. (normalizePath(String)): Implemented as part of normalize(). (removeLastSegment(StringBuffer)): Likewise. (relativize(java.net.URI)): Implemented. (equals(Object)): Implemented. (hashCode()): Implemented. (compareTo(Object)): Implemented. (compareFragments(java.net.URI)): Implemented. (toString()): Use fields directly. (toASCIIString()): Implemented. (escapeCharacters(String)): Implemented to escape non-ASCII characters. 2005-05-19 Roman Kennke <roman@kennke.org> * javax/swing/SizeRequirements.java (constructors): Implemented. (getTiledSizeRequirements): Implemented. (calculateTiledPositions): Implemented. 2005-05-19 Roman Kennke <roman@kennke.org> * javax/swing/SizeRequirements.java: Added API documentation for this class. 2005-05-19 Roman Kennke <roman@kennke.org> * javax/swing/SizeRequirements.java: Reformatted file to meet our coding standards. 2005-05-19 Roman Kennke <roman@kennke.org> * javax/swing/SwingUtilities.java (getUIInputMap): Return the InputMap that has been set by the UI of the component, not the component's own InputMap. (getUIActionMap): Return the ActionMap that has been set by the UI of the component, not the component's own ActionMap. 2005-05-19 Roman Kennke <roman@kennke.org> * javax/swing/FocusManager.java: Reformatted this file to match our coding standard. 2005-05-19 Roman Kennke <roman@kennke.org> * javax/swing/plaf/metal/BasicFileChooserUI.java: (installComponents): Include parents ComboBox. This has been commented out because ComboBox was broken (see previous entry). 2005-05-19 Roman Kennke <roman@kennke.org> * javax/swing/plaf/metal/MetalComboBoxUI.java (createUI): Do not share instances of this UI class between different JComboBoxes. 2005-05-19 Kim Ho <kho@luxsci.net> * javax/swing/DefaultComboBoxModel.java: (addElement): Set index to be the element of the added item. (removeAllElements): Clear before retrieving new size. Use correct size. * javax/swing/JFileChooser.java: Implemented. * javax/swing/filechooser/FileSystemView.java: Implemented. * javax/swing/filechooser/UnixFileSystemView.java: New file. Implemented. * javax/swing/plaf/basic/BasicComboBoxUI.java: (intervalAdded): Set initial index to start. * javax/swing/plaf/basic/BasicDirectoryModel.java: New file. Implemented. * javax/swing/plaf/basic/BasicFileChooserUI.java: New file. Implemented. * javax/swing/plaf/basic/BasicLookAndFeel.java: Add FileChooserUI. Commented out GIF properties for FileChooser stuff. 2005-05-19 Michael Koch <konqueror@gmx.de> * lib/Makefile.am: Remove accidentally commited -nowarn option for jikes. 2005-05-19 Michael Koch <konqueror@gmx.de> * java/text/DateFormatSymbols.java (getStringArray): New method. (getZoneStrings): Likewise. (DateFormatSymbols): Load symbols from properties files. * java/util/Locale.java (getDisplayLanguage): Handle new way to load language names. (getDisplayCountry): Handle new way to load territory names. (getDisplayVariant): Handle new way to load variant names. * lib/Makefile.am, lib/gen-classlist.sh.in: No need to special case classes from gnu.java.locale anymore. * scripts/generate-locale-list.sh: Generate list from the new properties files. * LICENSE: Added license of locale data properties files. 2005-05-19 Michael Koch <konqueror@gmx.de> * resource/gnu/java/locale/LocaleInformation_aa_DJ.properties, resource/gnu/java/locale/LocaleInformation_aa_ER.properties, resource/gnu/java/locale/LocaleInformation_aa_ER_SAAHO.properties, resource/gnu/java/locale/LocaleInformation_aa_ET.properties, resource/gnu/java/locale/LocaleInformation_aa.properties, resource/gnu/java/locale/LocaleInformation_af.properties, resource/gnu/java/locale/LocaleInformation_af_ZA.properties, resource/gnu/java/locale/LocaleInformation_am_ET.properties, resource/gnu/java/locale/LocaleInformation_am.properties, resource/gnu/java/locale/LocaleInformation_ar_DZ.properties, resource/gnu/java/locale/LocaleInformation_ar_IN.properties, resource/gnu/java/locale/LocaleInformation_ar_IQ.properties, resource/gnu/java/locale/LocaleInformation_ar_JO.properties, resource/gnu/java/locale/LocaleInformation_ar_KW.properties, resource/gnu/java/locale/LocaleInformation_ar_LB.properties, resource/gnu/java/locale/LocaleInformation_ar_LY.properties, resource/gnu/java/locale/LocaleInformation_ar_MA.properties, resource/gnu/java/locale/LocaleInformation_ar.properties, resource/gnu/java/locale/LocaleInformation_ar_QA.properties, resource/gnu/java/locale/LocaleInformation_ar_SA.properties, resource/gnu/java/locale/LocaleInformation_ar_SY.properties, resource/gnu/java/locale/LocaleInformation_ar_TN.properties, resource/gnu/java/locale/LocaleInformation_ar_YE.properties, resource/gnu/java/locale/LocaleInformation_as_IN.properties, resource/gnu/java/locale/LocaleInformation_as.properties, resource/gnu/java/locale/LocaleInformation_az_Cyrl.properties, resource/gnu/java/locale/LocaleInformation_be_BY.properties, resource/gnu/java/locale/LocaleInformation_be.properties, resource/gnu/java/locale/LocaleInformation_bg_BG.properties, resource/gnu/java/locale/LocaleInformation_bg.properties, resource/gnu/java/locale/LocaleInformation_bn_IN.properties, resource/gnu/java/locale/LocaleInformation_bn.properties, resource/gnu/java/locale/LocaleInformation_ca_ES.properties, resource/gnu/java/locale/LocaleInformation_ca.properties, resource/gnu/java/locale/LocaleInformation_cs_CZ.properties, resource/gnu/java/locale/LocaleInformation_cs.properties, resource/gnu/java/locale/LocaleInformation_cy_GB.properties, resource/gnu/java/locale/LocaleInformation_cy.properties, resource/gnu/java/locale/LocaleInformation_da_DK.properties, resource/gnu/java/locale/LocaleInformation_da.properties, resource/gnu/java/locale/LocaleInformation_de_AT.properties, resource/gnu/java/locale/LocaleInformation_de_BE.properties, resource/gnu/java/locale/LocaleInformation_de_CH.properties, resource/gnu/java/locale/LocaleInformation_de_DE.properties, resource/gnu/java/locale/LocaleInformation_de_LI.properties, resource/gnu/java/locale/LocaleInformation_de_LU.properties, resource/gnu/java/locale/LocaleInformation_de.properties, resource/gnu/java/locale/LocaleInformation_dv_MV.properties, resource/gnu/java/locale/LocaleInformation_dv.properties, resource/gnu/java/locale/LocaleInformation_dz_BT.properties, resource/gnu/java/locale/LocaleInformation_dz.properties, resource/gnu/java/locale/LocaleInformation_el_GR.properties, resource/gnu/java/locale/LocaleInformation_el.properties, resource/gnu/java/locale/LocaleInformation_en_AS.properties, resource/gnu/java/locale/LocaleInformation_en_AU.properties, resource/gnu/java/locale/LocaleInformation_en_BE.properties, resource/gnu/java/locale/LocaleInformation_en_BW.properties, resource/gnu/java/locale/LocaleInformation_en_BZ.properties, resource/gnu/java/locale/LocaleInformation_en_CA.properties, resource/gnu/java/locale/LocaleInformation_en_GB.properties, resource/gnu/java/locale/LocaleInformation_en_GU.properties, resource/gnu/java/locale/LocaleInformation_en_HK.properties, resource/gnu/java/locale/LocaleInformation_en_IE.properties, resource/gnu/java/locale/LocaleInformation_en_IN.properties, resource/gnu/java/locale/LocaleInformation_en_MH.properties, resource/gnu/java/locale/LocaleInformation_en_MP.properties, resource/gnu/java/locale/LocaleInformation_en_MT.properties, resource/gnu/java/locale/LocaleInformation_en_NZ.properties, resource/gnu/java/locale/LocaleInformation_en_PH.properties, resource/gnu/java/locale/LocaleInformation_en_PK.properties, resource/gnu/java/locale/LocaleInformation_en.properties, resource/gnu/java/locale/LocaleInformation_en_SG.properties, resource/gnu/java/locale/LocaleInformation_en_UM.properties, resource/gnu/java/locale/LocaleInformation_en_US_POSIX.properties, resource/gnu/java/locale/LocaleInformation_en_US.properties, resource/gnu/java/locale/LocaleInformation_en_VI.properties, resource/gnu/java/locale/LocaleInformation_en_ZA.properties, resource/gnu/java/locale/LocaleInformation_en_ZW.properties, resource/gnu/java/locale/LocaleInformation_eo.properties, resource/gnu/java/locale/LocaleInformation_es_AR.properties, resource/gnu/java/locale/LocaleInformation_es_BO.properties, resource/gnu/java/locale/LocaleInformation_es_CL.properties, resource/gnu/java/locale/LocaleInformation_es_CO.properties, resource/gnu/java/locale/LocaleInformation_es_CR.properties, resource/gnu/java/locale/LocaleInformation_es_DO.properties, resource/gnu/java/locale/LocaleInformation_es_EC.properties, resource/gnu/java/locale/LocaleInformation_es_ES.properties, resource/gnu/java/locale/LocaleInformation_es_GT.properties, resource/gnu/java/locale/LocaleInformation_es_HN.properties, resource/gnu/java/locale/LocaleInformation_es_MX.properties, resource/gnu/java/locale/LocaleInformation_es_NI.properties, resource/gnu/java/locale/LocaleInformation_es_PA.properties, resource/gnu/java/locale/LocaleInformation_es_PE.properties, resource/gnu/java/locale/LocaleInformation_es.properties, resource/gnu/java/locale/LocaleInformation_es_PR.properties, resource/gnu/java/locale/LocaleInformation_es_PY.properties, resource/gnu/java/locale/LocaleInformation_es_SV.properties, resource/gnu/java/locale/LocaleInformation_es_US.properties, resource/gnu/java/locale/LocaleInformation_es_UY.properties, resource/gnu/java/locale/LocaleInformation_es_VE.properties, resource/gnu/java/locale/LocaleInformation_et_EE.properties, resource/gnu/java/locale/LocaleInformation_et.properties, resource/gnu/java/locale/LocaleInformation_eu_ES.properties, resource/gnu/java/locale/LocaleInformation_eu.properties, resource/gnu/java/locale/LocaleInformation_fa_AF.properties, resource/gnu/java/locale/LocaleInformation_fa_IR.properties, resource/gnu/java/locale/LocaleInformation_fa.properties, resource/gnu/java/locale/LocaleInformation_fi_FI.properties, resource/gnu/java/locale/LocaleInformation_fi.properties, resource/gnu/java/locale/LocaleInformation_fo_FO.properties, resource/gnu/java/locale/LocaleInformation_fo.properties, resource/gnu/java/locale/LocaleInformation_fr_BE.properties, resource/gnu/java/locale/LocaleInformation_fr_CA.properties, resource/gnu/java/locale/LocaleInformation_fr_CH.properties, resource/gnu/java/locale/LocaleInformation_fr_LU.properties, resource/gnu/java/locale/LocaleInformation_fr.properties, resource/gnu/java/locale/LocaleInformation_ga_IE.properties, resource/gnu/java/locale/LocaleInformation_ga.properties, resource/gnu/java/locale/LocaleInformation_gl_ES.properties, resource/gnu/java/locale/LocaleInformation_gl.properties, resource/gnu/java/locale/LocaleInformation_gu_IN.properties, resource/gnu/java/locale/LocaleInformation_gu.properties, resource/gnu/java/locale/LocaleInformation_gv_GB.properties, resource/gnu/java/locale/LocaleInformation_gv.properties, resource/gnu/java/locale/LocaleInformation_he_IL.properties, resource/gnu/java/locale/LocaleInformation_he.properties, resource/gnu/java/locale/LocaleInformation_hi_IN.properties, resource/gnu/java/locale/LocaleInformation_hi.properties, resource/gnu/java/locale/LocaleInformation_hr.properties, resource/gnu/java/locale/LocaleInformation_hu_HU.properties, resource/gnu/java/locale/LocaleInformation_hu.properties, resource/gnu/java/locale/LocaleInformation_hy_AM.properties, resource/gnu/java/locale/LocaleInformation_hy_AM_REVISED.properties, resource/gnu/java/locale/LocaleInformation_hy.properties, resource/gnu/java/locale/LocaleInformation_id_ID.properties, resource/gnu/java/locale/LocaleInformation_id.properties, resource/gnu/java/locale/LocaleInformation_is_IS.properties, resource/gnu/java/locale/LocaleInformation_is.properties, resource/gnu/java/locale/LocaleInformation_it_CH.properties, resource/gnu/java/locale/LocaleInformation_it_IT.properties, resource/gnu/java/locale/LocaleInformation_it.properties, resource/gnu/java/locale/LocaleInformation_iu.properties, resource/gnu/java/locale/LocaleInformation_ja_JP.properties, resource/gnu/java/locale/LocaleInformation_ja.properties, resource/gnu/java/locale/LocaleInformation_ka.properties, resource/gnu/java/locale/LocaleInformation_kk_KZ.properties, resource/gnu/java/locale/LocaleInformation_kk.properties, resource/gnu/java/locale/LocaleInformation_kl_GL.properties, resource/gnu/java/locale/LocaleInformation_kl.properties, resource/gnu/java/locale/LocaleInformation_km_KH.properties, resource/gnu/java/locale/LocaleInformation_km.properties, resource/gnu/java/locale/LocaleInformation_kn_IN.properties, resource/gnu/java/locale/LocaleInformation_kn.properties, resource/gnu/java/locale/LocaleInformation_ko_KR.properties, resource/gnu/java/locale/LocaleInformation_ko.properties, resource/gnu/java/locale/LocaleInformation_kw_GB.properties, resource/gnu/java/locale/LocaleInformation_kw.properties, resource/gnu/java/locale/LocaleInformation_ky.properties, resource/gnu/java/locale/LocaleInformation_lo_LA.properties, resource/gnu/java/locale/LocaleInformation_lo.properties, resource/gnu/java/locale/LocaleInformation_lt_LT.properties, resource/gnu/java/locale/LocaleInformation_lt.properties, resource/gnu/java/locale/LocaleInformation_lv_LV.properties, resource/gnu/java/locale/LocaleInformation_lv.properties, resource/gnu/java/locale/LocaleInformation_mk.properties, resource/gnu/java/locale/LocaleInformation_ml_IN.properties, resource/gnu/java/locale/LocaleInformation_ml.properties, resource/gnu/java/locale/LocaleInformation_mn_MN.properties, resource/gnu/java/locale/LocaleInformation_mn.properties, resource/gnu/java/locale/LocaleInformation_mr_IN.properties, resource/gnu/java/locale/LocaleInformation_mr.properties, resource/gnu/java/locale/LocaleInformation_ms_BN.properties, resource/gnu/java/locale/LocaleInformation_ms_MY.properties, resource/gnu/java/locale/LocaleInformation_ms.properties, resource/gnu/java/locale/LocaleInformation_mt_MT.properties, resource/gnu/java/locale/LocaleInformation_mt.properties, resource/gnu/java/locale/LocaleInformation_nb_NO.properties, resource/gnu/java/locale/LocaleInformation_nb.properties, resource/gnu/java/locale/LocaleInformation_nl_BE.properties, resource/gnu/java/locale/LocaleInformation_nl_NL.properties, resource/gnu/java/locale/LocaleInformation_nl.properties, resource/gnu/java/locale/LocaleInformation_nn_NO.properties, resource/gnu/java/locale/LocaleInformation_nn.properties, resource/gnu/java/locale/LocaleInformation_om_ET.properties, resource/gnu/java/locale/LocaleInformation_om_KE.properties, resource/gnu/java/locale/LocaleInformation_om.properties, resource/gnu/java/locale/LocaleInformation_or_IN.properties, resource/gnu/java/locale/LocaleInformation_or.properties, resource/gnu/java/locale/LocaleInformation_pa_IN.properties, resource/gnu/java/locale/LocaleInformation_pa.properties, resource/gnu/java/locale/LocaleInformation_pl_PL.properties, resource/gnu/java/locale/LocaleInformation_pl.properties, resource/gnu/java/locale/LocaleInformation.properties, resource/gnu/java/locale/LocaleInformation_ps_AF.properties, resource/gnu/java/locale/LocaleInformation_ps.properties, resource/gnu/java/locale/LocaleInformation_pt_BR.properties, resource/gnu/java/locale/LocaleInformation_pt.properties, resource/gnu/java/locale/LocaleInformation_pt_PT.properties, resource/gnu/java/locale/LocaleInformation_ro.properties, resource/gnu/java/locale/LocaleInformation_ro_RO.properties, resource/gnu/java/locale/LocaleInformation_ru.properties, resource/gnu/java/locale/LocaleInformation_ru_RU.properties, resource/gnu/java/locale/LocaleInformation_ru_UA.properties, resource/gnu/java/locale/LocaleInformation_sa_IN.properties, resource/gnu/java/locale/LocaleInformation_sa.properties, resource/gnu/java/locale/LocaleInformation_sk.properties, resource/gnu/java/locale/LocaleInformation_sk_SK.properties, resource/gnu/java/locale/LocaleInformation_sl.properties, resource/gnu/java/locale/LocaleInformation_so_DJ.properties, resource/gnu/java/locale/LocaleInformation_so_ET.properties, resource/gnu/java/locale/LocaleInformation_so_KE.properties, resource/gnu/java/locale/LocaleInformation_so.properties, resource/gnu/java/locale/LocaleInformation_so_SO.properties, resource/gnu/java/locale/LocaleInformation_sq_AL.properties, resource/gnu/java/locale/LocaleInformation_sq.properties, resource/gnu/java/locale/LocaleInformation_sr_Latn.properties, resource/gnu/java/locale/LocaleInformation_sr.properties, resource/gnu/java/locale/LocaleInformation_sv_FI.properties, resource/gnu/java/locale/LocaleInformation_sv.properties, resource/gnu/java/locale/LocaleInformation_sv_SE.properties, resource/gnu/java/locale/LocaleInformation_sw_KE.properties, resource/gnu/java/locale/LocaleInformation_sw.properties, resource/gnu/java/locale/LocaleInformation_sw_TZ.properties, resource/gnu/java/locale/LocaleInformation_ta_IN.properties, resource/gnu/java/locale/LocaleInformation_ta.properties, resource/gnu/java/locale/LocaleInformation_te_IN.properties, resource/gnu/java/locale/LocaleInformation_te.properties, resource/gnu/java/locale/LocaleInformation_th.properties, resource/gnu/java/locale/LocaleInformation_th_TH.properties, resource/gnu/java/locale/LocaleInformation_ti_ER.properties, resource/gnu/java/locale/LocaleInformation_ti_ET.properties, resource/gnu/java/locale/LocaleInformation_ti.properties, resource/gnu/java/locale/LocaleInformation_tr.properties, resource/gnu/java/locale/LocaleInformation_tr_TR.properties, resource/gnu/java/locale/LocaleInformation_tt.properties, resource/gnu/java/locale/LocaleInformation_tt_RU.properties, resource/gnu/java/locale/LocaleInformation_uk.properties, resource/gnu/java/locale/LocaleInformation_uk_UA.properties, resource/gnu/java/locale/LocaleInformation_ur.properties, resource/gnu/java/locale/LocaleInformation_uz_AF.properties, resource/gnu/java/locale/LocaleInformation_uz.properties, resource/gnu/java/locale/LocaleInformation_vi.properties, resource/gnu/java/locale/LocaleInformation_zh_CN_Hans.properties, resource/gnu/java/locale/LocaleInformation_zh_Hant.properties, resource/gnu/java/locale/LocaleInformation_zh_HK_Hant.properties, resource/gnu/java/locale/LocaleInformation_zh_MO_Hant.properties, resource/gnu/java/locale/LocaleInformation_zh.properties, resource/gnu/java/locale/LocaleInformation_zh_SG_Hans.properties, resource/gnu/java/locale/LocaleInformation_zh_TW_Hant.properties: New files. * gnu/java/locale/LocaleInformation_aa_DJ.java, gnu/java/locale/LocaleInformation_aa_ER.java, gnu/java/locale/LocaleInformation_aa_ER_SAAHO.java, gnu/java/locale/LocaleInformation_aa_ET.java, gnu/java/locale/LocaleInformation_aa.java, gnu/java/locale/LocaleInformation_af.java, gnu/java/locale/LocaleInformation_af_ZA.java, gnu/java/locale/LocaleInformation_am_ET.java, gnu/java/locale/LocaleInformation_am.java, gnu/java/locale/LocaleInformation_ar_DZ.java, gnu/java/locale/LocaleInformation_ar_IN.java, gnu/java/locale/LocaleInformation_ar_IQ.java, gnu/java/locale/LocaleInformation_ar.java, gnu/java/locale/LocaleInformation_ar_JO.java, gnu/java/locale/LocaleInformation_ar_KW.java, gnu/java/locale/LocaleInformation_ar_LB.java, gnu/java/locale/LocaleInformation_ar_LY.java, gnu/java/locale/LocaleInformation_ar_MA.java, gnu/java/locale/LocaleInformation_ar_QA.java, gnu/java/locale/LocaleInformation_ar_SA.java, gnu/java/locale/LocaleInformation_ar_SY.java, gnu/java/locale/LocaleInformation_ar_TN.java, gnu/java/locale/LocaleInformation_ar_YE.java, gnu/java/locale/LocaleInformation_as_IN.java, gnu/java/locale/LocaleInformation_as.java, gnu/java/locale/LocaleInformation_az_Cyrl.java, gnu/java/locale/LocaleInformation_az.java, gnu/java/locale/LocaleInformation_be_BY.java, gnu/java/locale/LocaleInformation_be.java, gnu/java/locale/LocaleInformation_bg_BG.java, gnu/java/locale/LocaleInformation_bg.java, gnu/java/locale/LocaleInformation_bn_IN.java, gnu/java/locale/LocaleInformation_bn.java, gnu/java/locale/LocaleInformation_br_FR.java, gnu/java/locale/LocaleInformation_bs_BA.java, gnu/java/locale/LocaleInformation_byn_ER.java, gnu/java/locale/LocaleInformation_byn.java, gnu/java/locale/LocaleInformation_ca_ES.java, gnu/java/locale/LocaleInformation_ca.java, gnu/java/locale/LocaleInformation_cs_CZ.java, gnu/java/locale/LocaleInformation_cs.java, gnu/java/locale/LocaleInformation_cy_GB.java, gnu/java/locale/LocaleInformation_cy.java, gnu/java/locale/LocaleInformation_da_DK.java, gnu/java/locale/LocaleInformation_da.java, gnu/java/locale/LocaleInformation_de_AT.java, gnu/java/locale/LocaleInformation_de_BE.java, gnu/java/locale/LocaleInformation_de_CH.java, gnu/java/locale/LocaleInformation_de_DE.java, gnu/java/locale/LocaleInformation_de.java, gnu/java/locale/LocaleInformation_de_LI.java, gnu/java/locale/LocaleInformation_de_LU.java, gnu/java/locale/LocaleInformation_dv.java, gnu/java/locale/LocaleInformation_dv_MV.java, gnu/java/locale/LocaleInformation_dz_BT.java, gnu/java/locale/LocaleInformation_dz.java, gnu/java/locale/LocaleInformation_el_GR.java, gnu/java/locale/LocaleInformation_el.java, gnu/java/locale/LocaleInformation_en_AS.java, gnu/java/locale/LocaleInformation_en_AU.java, gnu/java/locale/LocaleInformation_en_BE.java, gnu/java/locale/LocaleInformation_en_BW.java, gnu/java/locale/LocaleInformation_en_BZ.java, gnu/java/locale/LocaleInformation_en_CA.java, gnu/java/locale/LocaleInformation_en_DK.java, gnu/java/locale/LocaleInformation_en_GB.java, gnu/java/locale/LocaleInformation_en_GU.java, gnu/java/locale/LocaleInformation_en_HK.java, gnu/java/locale/LocaleInformation_en_IE.java, gnu/java/locale/LocaleInformation_en_IN.java, gnu/java/locale/LocaleInformation_en.java, gnu/java/locale/LocaleInformation_en_MH.java, gnu/java/locale/LocaleInformation_en_MP.java, gnu/java/locale/LocaleInformation_en_MT.java, gnu/java/locale/LocaleInformation_en_NZ.java, gnu/java/locale/LocaleInformation_en_PH.java, gnu/java/locale/LocaleInformation_en_PK.java, gnu/java/locale/LocaleInformation_en_SG.java, gnu/java/locale/LocaleInformation_en_UM.java, gnu/java/locale/LocaleInformation_en_US.java, gnu/java/locale/LocaleInformation_en_US_POSIX.java, gnu/java/locale/LocaleInformation_en_VI.java, gnu/java/locale/LocaleInformation_en_ZA.java, gnu/java/locale/LocaleInformation_en_ZW.java, gnu/java/locale/LocaleInformation_eo.java, gnu/java/locale/LocaleInformation_es_AR.java, gnu/java/locale/LocaleInformation_es_BO.java, gnu/java/locale/LocaleInformation_es_CL.java, gnu/java/locale/LocaleInformation_es_CO.java, gnu/java/locale/LocaleInformation_es_CR.java, gnu/java/locale/LocaleInformation_es_DO.java, gnu/java/locale/LocaleInformation_es_EC.java, gnu/java/locale/LocaleInformation_es_ES.java, gnu/java/locale/LocaleInformation_es_GT.java, gnu/java/locale/LocaleInformation_es_HN.java, gnu/java/locale/LocaleInformation_es.java, gnu/java/locale/LocaleInformation_es_MX.java, gnu/java/locale/LocaleInformation_es_NI.java, gnu/java/locale/LocaleInformation_es_PA.java, gnu/java/locale/LocaleInformation_es_PE.java, gnu/java/locale/LocaleInformation_es_PR.java, gnu/java/locale/LocaleInformation_es_PY.java, gnu/java/locale/LocaleInformation_es_SV.java, gnu/java/locale/LocaleInformation_es_US.java, gnu/java/locale/LocaleInformation_es_UY.java, gnu/java/locale/LocaleInformation_es_VE.java, gnu/java/locale/LocaleInformation_et_EE.java, gnu/java/locale/LocaleInformation_et.java, gnu/java/locale/LocaleInformation_eu_ES.java, gnu/java/locale/LocaleInformation_eu.java, gnu/java/locale/LocaleInformation_fa_AF.java, gnu/java/locale/LocaleInformation_fa_IR.java, gnu/java/locale/LocaleInformation_fa.java, gnu/java/locale/LocaleInformation_fi_FI.java, gnu/java/locale/LocaleInformation_fi.java, gnu/java/locale/LocaleInformation_fo_FO.java, gnu/java/locale/LocaleInformation_fo.java, gnu/java/locale/LocaleInformation_fr_BE.java, gnu/java/locale/LocaleInformation_fr_CA.java, gnu/java/locale/LocaleInformation_fr_CH.java, gnu/java/locale/LocaleInformation_fr.java, gnu/java/locale/LocaleInformation_fr_LU.java, gnu/java/locale/LocaleInformation_ga_IE.java, gnu/java/locale/LocaleInformation_ga.java, gnu/java/locale/LocaleInformation_gez_ER.java, gnu/java/locale/LocaleInformation_gez_ET.java, gnu/java/locale/LocaleInformation_gez.java, gnu/java/locale/LocaleInformation_gl_ES.java, gnu/java/locale/LocaleInformation_gl.java, gnu/java/locale/LocaleInformation_gu_IN.java, gnu/java/locale/LocaleInformation_gu.java, gnu/java/locale/LocaleInformation_gv_GB.java, gnu/java/locale/LocaleInformation_gv.java, gnu/java/locale/LocaleInformation_haw.java, gnu/java/locale/LocaleInformation_haw_US.java, gnu/java/locale/LocaleInformation_he_IL.java, gnu/java/locale/LocaleInformation_he.java, gnu/java/locale/LocaleInformation_hi_IN.java, gnu/java/locale/LocaleInformation_hi.java, gnu/java/locale/LocaleInformation_hr.java, gnu/java/locale/LocaleInformation_hu_HU.java, gnu/java/locale/LocaleInformation_hu.java, gnu/java/locale/LocaleInformation_hy_AM.java, gnu/java/locale/LocaleInformation_hy_AM_REVISED.java, gnu/java/locale/LocaleInformation_hy.java, gnu/java/locale/LocaleInformation_id_ID.java, gnu/java/locale/LocaleInformation_id.java, gnu/java/locale/LocaleInformation_is_IS.java, gnu/java/locale/LocaleInformation_is.java, gnu/java/locale/LocaleInformation_it_CH.java, gnu/java/locale/LocaleInformation_it_IT.java, gnu/java/locale/LocaleInformation_it.java, gnu/java/locale/LocaleInformation_iu.java, gnu/java/locale/LocaleInformation_iw_IL.java, gnu/java/locale/LocaleInformation_ja.java, gnu/java/locale/LocaleInformation_ja_JP.java, gnu/java/locale/LocaleInformation.java, gnu/java/locale/LocaleInformation_ka.java, gnu/java/locale/LocaleInformation_kk.java, gnu/java/locale/LocaleInformation_kk_KZ.java, gnu/java/locale/LocaleInformation_kl_GL.java, gnu/java/locale/LocaleInformation_kl.java, gnu/java/locale/LocaleInformation_km.java, gnu/java/locale/LocaleInformation_km_KH.java, gnu/java/locale/LocaleInformation_kn_IN.java, gnu/java/locale/LocaleInformation_kn.java, gnu/java/locale/LocaleInformation_ko.java, gnu/java/locale/LocaleInformation_kok_IN.java, gnu/java/locale/LocaleInformation_kok.java, gnu/java/locale/LocaleInformation_ko_KR.java, gnu/java/locale/LocaleInformation_kw_GB.java, gnu/java/locale/LocaleInformation_kw.java, gnu/java/locale/LocaleInformation_ky.java, gnu/java/locale/LocaleInformation_lo.java, gnu/java/locale/LocaleInformation_lo_LA.java, gnu/java/locale/LocaleInformation_lt.java, gnu/java/locale/LocaleInformation_lt_LT.java, gnu/java/locale/LocaleInformation_lv.java, gnu/java/locale/LocaleInformation_lv_LV.java, gnu/java/locale/LocaleInformation_mk.java, gnu/java/locale/LocaleInformation_ml_IN.java, gnu/java/locale/LocaleInformation_ml.java, gnu/java/locale/LocaleInformation_mn.java, gnu/java/locale/LocaleInformation_mn_MN.java, gnu/java/locale/LocaleInformation_mr_IN.java, gnu/java/locale/LocaleInformation_mr.java, gnu/java/locale/LocaleInformation_ms_BN.java, gnu/java/locale/LocaleInformation_ms.java, gnu/java/locale/LocaleInformation_ms_MY.java, gnu/java/locale/LocaleInformation_mt.java, gnu/java/locale/LocaleInformation_mt_MT.java, gnu/java/locale/LocaleInformation_nb.java, gnu/java/locale/LocaleInformation_nb_NO.java, gnu/java/locale/LocaleInformation_nl_BE.java, gnu/java/locale/LocaleInformation_nl.java, gnu/java/locale/LocaleInformation_nl_NL.java, gnu/java/locale/LocaleInformation_nn.java, gnu/java/locale/LocaleInformation_nn_NO.java, gnu/java/locale/LocaleInformation_no_NO.java, gnu/java/locale/LocaleInformation_oc_FR.java, gnu/java/locale/LocaleInformation_om_ET.java, gnu/java/locale/LocaleInformation_om.java, gnu/java/locale/LocaleInformation_om_KE.java, gnu/java/locale/LocaleInformation_or_IN.java, gnu/java/locale/LocaleInformation_or.java, gnu/java/locale/LocaleInformation_pa_IN.java, gnu/java/locale/LocaleInformation_pa.java, gnu/java/locale/LocaleInformation_pl.java, gnu/java/locale/LocaleInformation_pl_PL.java, gnu/java/locale/LocaleInformation_ps_AF.java, gnu/java/locale/LocaleInformation_ps.java, gnu/java/locale/LocaleInformation_pt_BR.java, gnu/java/locale/LocaleInformation_pt.java, gnu/java/locale/LocaleInformation_pt_PT.java, gnu/java/locale/LocaleInformation_ro.java, gnu/java/locale/LocaleInformation_ro_RO.java, gnu/java/locale/LocaleInformation_ru.java, gnu/java/locale/LocaleInformation_ru_RU.java, gnu/java/locale/LocaleInformation_ru_UA.java, gnu/java/locale/LocaleInformation_sa_IN.java, gnu/java/locale/LocaleInformation_sa.java, gnu/java/locale/LocaleInformation_se_NO.java, gnu/java/locale/LocaleInformation_sid_ET.java, gnu/java/locale/LocaleInformation_sid.java, gnu/java/locale/LocaleInformation_sk.java, gnu/java/locale/LocaleInformation_sk_SK.java, gnu/java/locale/LocaleInformation_sl.java, gnu/java/locale/LocaleInformation_so_DJ.java, gnu/java/locale/LocaleInformation_so_ET.java, gnu/java/locale/LocaleInformation_so.java, gnu/java/locale/LocaleInformation_so_KE.java, gnu/java/locale/LocaleInformation_so_SO.java, gnu/java/locale/LocaleInformation_sq_AL.java, gnu/java/locale/LocaleInformation_sq.java, gnu/java/locale/LocaleInformation_sr.java, gnu/java/locale/LocaleInformation_sr_Latn.java, gnu/java/locale/LocaleInformation_sv_FI.java, gnu/java/locale/LocaleInformation_sv.java, gnu/java/locale/LocaleInformation_sv_SE.java, gnu/java/locale/LocaleInformation_sw.java, gnu/java/locale/LocaleInformation_sw_KE.java, gnu/java/locale/LocaleInformation_sw_TZ.java, gnu/java/locale/LocaleInformation_syr.java, gnu/java/locale/LocaleInformation_syr_SY.java, gnu/java/locale/LocaleInformation_ta_IN.java, gnu/java/locale/LocaleInformation_ta.java, gnu/java/locale/LocaleInformation_te_IN.java, gnu/java/locale/LocaleInformation_te.java, gnu/java/locale/LocaleInformation_tg_TJ.java, gnu/java/locale/LocaleInformation_th.java, gnu/java/locale/LocaleInformation_th_TH.java, gnu/java/locale/LocaleInformation_ti_ER.java, gnu/java/locale/LocaleInformation_ti_ET.java, gnu/java/locale/LocaleInformation_tig_ER.java, gnu/java/locale/LocaleInformation_tig.java, gnu/java/locale/LocaleInformation_ti.java, gnu/java/locale/LocaleInformation_tr.java, gnu/java/locale/LocaleInformation_tr_TR.java, gnu/java/locale/LocaleInformation_tt.java, gnu/java/locale/LocaleInformation_tt_RU.java, gnu/java/locale/LocaleInformation_uk.java, gnu/java/locale/LocaleInformation_uk_UA.java, gnu/java/locale/LocaleInformation_ur.java, gnu/java/locale/LocaleInformation_uz_AF.java, gnu/java/locale/LocaleInformation_uz.java, gnu/java/locale/LocaleInformation_vi.java, gnu/java/locale/LocaleInformation_wal_ET.java, gnu/java/locale/LocaleInformation_wal.java, gnu/java/locale/LocaleInformation_zh_CN_Hans.java, gnu/java/locale/LocaleInformation_zh_Hant.java, gnu/java/locale/LocaleInformation_zh_HK_Hant.java, gnu/java/locale/LocaleInformation_zh.java, gnu/java/locale/LocaleInformation_zh_MO_Hant.java, gnu/java/locale/LocaleInformation_zh_SG_Hans.java, gnu/java/locale/LocaleInformation_zh_TW_Hant.java: Removed. 2005-05-18 Thomas Fitzsimmons <fitzsim@redhat.com> * java/awt/Window.java (createBufferStrategy): Remove unnecessary try-catch blocks. * java/awt/Canvas.java (createBufferStrategy): Likewise. * gnu
Diffstat (limited to 'javax')
-rw-r--r--javax/swing/AbstractButton.java31
-rw-r--r--javax/swing/AbstractCellEditor.java130
-rw-r--r--javax/swing/DefaultButtonModel.java1
-rw-r--r--javax/swing/DefaultComboBoxModel.java6
-rw-r--r--javax/swing/FocusManager.java253
-rw-r--r--javax/swing/ImageIcon.java163
-rw-r--r--javax/swing/JComponent.java420
-rw-r--r--javax/swing/JDialog.java4
-rw-r--r--javax/swing/JEditorPane.java6
-rw-r--r--javax/swing/JFileChooser.java2003
-rw-r--r--javax/swing/JSeparator.java11
-rw-r--r--javax/swing/JTable.java260
-rw-r--r--javax/swing/JTextField.java12
-rw-r--r--javax/swing/JTree.java317
-rw-r--r--javax/swing/MenuSelectionManager.java7
-rw-r--r--javax/swing/RepaintManager.java25
-rw-r--r--javax/swing/ScrollPaneLayout.java9
-rw-r--r--javax/swing/SizeRequirements.java408
-rw-r--r--javax/swing/SwingUtilities.java41
-rw-r--r--javax/swing/UIManager.java17
-rw-r--r--javax/swing/filechooser/FileSystemView.java425
-rw-r--r--javax/swing/filechooser/UnixFileSystemView.java144
-rw-r--r--javax/swing/plaf/basic/BasicComboBoxUI.java2
-rw-r--r--javax/swing/plaf/basic/BasicDirectoryModel.java313
-rw-r--r--javax/swing/plaf/basic/BasicFileChooserUI.java1929
-rw-r--r--javax/swing/plaf/basic/BasicLookAndFeel.java56
-rw-r--r--javax/swing/plaf/basic/BasicOptionPaneUI.java16
-rw-r--r--javax/swing/plaf/basic/BasicPopupMenuUI.java299
-rw-r--r--javax/swing/plaf/basic/BasicProgressBarUI.java19
-rw-r--r--javax/swing/plaf/basic/BasicTextUI.java103
-rw-r--r--javax/swing/plaf/basic/DefaultMenuLayout.java78
-rw-r--r--javax/swing/plaf/metal/MetalComboBoxUI.java22
-rw-r--r--javax/swing/table/DefaultTableCellRenderer.java6
-rw-r--r--javax/swing/text/AbstractDocument.java4
-rw-r--r--javax/swing/text/FieldView.java79
-rw-r--r--javax/swing/text/GapContent.java227
-rw-r--r--javax/swing/text/JTextComponent.java27
-rw-r--r--javax/swing/text/PlainDocument.java42
-rw-r--r--javax/swing/text/PlainView.java39
-rw-r--r--javax/swing/text/Utilities.java2
-rw-r--r--javax/swing/text/View.java199
41 files changed, 6628 insertions, 1527 deletions
diff --git a/javax/swing/AbstractButton.java b/javax/swing/AbstractButton.java
index 1232a4ab4..b5daf1c25 100644
--- a/javax/swing/AbstractButton.java
+++ b/javax/swing/AbstractButton.java
@@ -47,6 +47,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.io.Serializable;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -152,7 +153,23 @@ public abstract class AbstractButton extends JComponent
implements ItemSelectable, SwingConstants
{
private static final long serialVersionUID = -937921345538462020L;
-
+
+ /**
+ * An extension of ChangeListener to be serializable.
+ */
+ protected class ButtonChangeListener
+ implements ChangeListener, Serializable
+ {
+ /**
+ * Notified when the target of the listener changes its state.
+ *
+ * @param ev the ChangeEvent describing the change
+ */
+ public void stateChanged(ChangeEvent ev)
+ {
+ }
+ }
+
/** The icon displayed by default. */
Icon default_icon;
@@ -1329,18 +1346,6 @@ public abstract class AbstractButton extends JComponent
}
/**
- * Return the button's "focusTraversable" property. This property controls
- * whether or not the button can receive focus when the user attempts to
- * traverse the focus hierarchy.
- *
- * @return The current "focusTraversable" property
- */
- public boolean isFocusTraversable()
- {
- return true;
- }
-
- /**
* Verifies that a particular key is one of the valid constants used for
* describing horizontal alignment and positioning. The valid constants
* are the following members of {@link SwingConstants}:
diff --git a/javax/swing/AbstractCellEditor.java b/javax/swing/AbstractCellEditor.java
index 7cc57516a..18f78e319 100644
--- a/javax/swing/AbstractCellEditor.java
+++ b/javax/swing/AbstractCellEditor.java
@@ -1,5 +1,5 @@
/* AbstractCellEditor.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,9 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.EventListenerList;
/**
- * AbstractCellEditor
+ * The abstract superclass for table and tree cells. This provides some
+ * common shared functionality.
+ *
* @author Andrew Selkirk
* @version 1.0
*/
@@ -56,59 +58,77 @@ public abstract class AbstractCellEditor
private static final long serialVersionUID = -1048006551406220959L;
/**
- * listenerList
+ * Our Swing event listeners.
*/
protected EventListenerList listenerList;
/**
- * changeEvent
+ * The cached ChangeEvent.
*/
protected transient ChangeEvent changeEvent;
- /**
- * Constructor AbstractCellEditor
- */
- public AbstractCellEditor() {
- // TODO
- } // AbstractCellEditor()
-
- /**
- * isCellEditable
- * @param event TODO
- * @returns boolean
- */
- public boolean isCellEditable(EventObject event) {
- return false; // TODO
- } // isCellEditable()
-
- /**
- * shouldSelectCell
- * @param event TODO
- * @returns boolean
- */
- public boolean shouldSelectCell(EventObject event) {
- return false; // TODO
- } // shouldSelectCell()
-
- /**
- * stopCellEditing
- * @returns boolean
- */
- public boolean stopCellEditing() {
- return false; // TODO
- } // stopCellEditing()
-
- /**
- * cancelCellEditing
- */
- public void cancelCellEditing() {
- // TODO
- } // cancelCellEditing()
+ /**
+ * Creates a new instance of AbstractCellEditor.
+ */
+ public AbstractCellEditor() {
+ listenerList = new EventListenerList();
+ changeEvent = new ChangeEvent(this);
+ } // AbstractCellEditor()
+
+ /**
+ * Returns <code>true</code> if the cell is editable using
+ * <code>event</code>, <code>false</code>
+ * if it's not. The default behaviour is to return <code>true</code>.
+ *
+ * @param event an event
+ *
+ * @return <code>true</code> if the cell is editable using
+ * <code>event</code>, <code>false</code> if it's not
+ */
+ public boolean isCellEditable(EventObject event) {
+ return true;
+ } // isCellEditable()
+
+ /**
+ * Returns <code>true</code> if the editing cell should be selected,
+ * <code>false</code> otherwise. This is usually returning <code>true</code>,
+ * but in some special cases it might be useful not to switch cell selection
+ * when editing one cell.
+ *
+ * @param event an event
+ *
+ * @return <code>true</code> if the editing cell should be selected,
+ * <code>false</code> otherwise
+ */
+ public boolean shouldSelectCell(EventObject event) {
+ return true;
+ } // shouldSelectCell()
+
+ /**
+ * Stop editing the cell and accept any partial value that has been entered
+ * into the cell.
+ *
+ * @returns <code>true</code> if editing has been stopped successfully,
+ * <code>false</code>otherwise
+ */
+ public boolean stopCellEditing() {
+ fireEditingStopped();
+ return true;
+ } // stopCellEditing()
/**
- * addCellEditorListener
+ * Stop editing the cell and do not accept any partial value that has
+ * been entered into the cell.
+ */
+ public void cancelCellEditing() {
+ fireEditingCanceled();
+ } // cancelCellEditing()
+
+ /**
+ * Adds a CellEditorListener to the list of CellEditorListeners of this
+ * CellEditor.
*
- * @param listener The listener to add
+ * @param listener the CellEditorListener to add
*/
public void addCellEditorListener (CellEditorListener listener)
{
@@ -116,9 +136,10 @@ public abstract class AbstractCellEditor
}
/**
- * removeCellEditorListener
+ * Removes the specified CellEditorListener from the list of the
+ * CellEditorListeners of this CellEditor.
*
- * @param listener The listener to remove
+ * @param listener the CellEditorListener to remove
*/
public void removeCellEditorListener (CellEditorListener listener)
{
@@ -126,17 +147,23 @@ public abstract class AbstractCellEditor
}
/**
- * getCellEditorListeners
+ * Returns the list of CellEditorListeners that have been registered
+ * in this CellEditor.
+ *
+ * @return the list of CellEditorListeners that have been registered
+ * in this CellEditor
*
* @since 1.4
*/
public CellEditorListener[] getCellEditorListeners()
{
- return (CellEditorListener[]) listenerList.getListeners (CellEditorListener.class);
+ return (CellEditorListener[]) listenerList.getListeners
+ (CellEditorListener.class);
}
/**
- * fireEditingStopped
+ * Notifies all registered listeners that the editing of the cell has
+ * has been stopped.
*/
protected void fireEditingStopped()
{
@@ -149,7 +176,8 @@ public abstract class AbstractCellEditor
}
/**
- * fireEditingCanceled
+ * Notifies all registered listeners that the editing of the cell has
+ * has been canceled.
*/
protected void fireEditingCanceled()
{
diff --git a/javax/swing/DefaultButtonModel.java b/javax/swing/DefaultButtonModel.java
index 0473f53bc..021f02ced 100644
--- a/javax/swing/DefaultButtonModel.java
+++ b/javax/swing/DefaultButtonModel.java
@@ -116,7 +116,6 @@ public class DefaultButtonModel implements ButtonModel, Serializable
* this model.
*/
protected EventListenerList listenerList = new EventListenerList();
- ;
/** The single ChangeEvent this model (re)uses to call its ChangeListeners. */
protected ChangeEvent changeEvent = new ChangeEvent(this);
diff --git a/javax/swing/DefaultComboBoxModel.java b/javax/swing/DefaultComboBoxModel.java
index c2ece6435..496551e00 100644
--- a/javax/swing/DefaultComboBoxModel.java
+++ b/javax/swing/DefaultComboBoxModel.java
@@ -108,7 +108,7 @@ public class DefaultComboBoxModel extends AbstractListModel
public void addElement(Object object)
{
list.add(object);
- fireIntervalAdded(this, list.size(), list.size());
+ fireIntervalAdded(this, list.size() - 1, list.size());
}
/**
@@ -163,9 +163,9 @@ public class DefaultComboBoxModel extends AbstractListModel
*/
public void removeAllElements()
{
- int listSize = getSize();
list.clear();
- fireIntervalAdded(this, 0, listSize - 1);
+ int listSize = getSize();
+ fireIntervalAdded(this, 0, listSize);
}
/**
diff --git a/javax/swing/FocusManager.java b/javax/swing/FocusManager.java
index 8e404e948..419c4d4e0 100644
--- a/javax/swing/FocusManager.java
+++ b/javax/swing/FocusManager.java
@@ -47,140 +47,123 @@ import java.awt.event.KeyEvent;
* @author Andrew Selkirk
* @version 1.0
*/
-public abstract class FocusManager extends DefaultKeyboardFocusManager
+public abstract class FocusManager
+ extends DefaultKeyboardFocusManager
{
- //-------------------------------------------------------------
- // Classes ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * DisabledFocusManager
- */
- static class DisabledFocusManager extends FocusManager {
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor DisabledFocusManager
- */
- DisabledFocusManager() {
- // TODO
- } // DisabledFocusManager()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * processKeyEvent
- * @param component TODO
- * @param event TODO
- */
- public void processKeyEvent(Component component, KeyEvent event) {
- // TODO
- } // processKeyEvent()
-
- /**
- * focusNextComponent
- * @param component TODO
- */
- public void focusNextComponent(Component component) {
- // TODO
- } // focusNextComponent()
-
- /**
- * focusPreviousComponent
- * @param value0 TODO
- */
- public void focusPreviousComponent(Component value0) {
- // TODO
- } // focusPreviousComponent()
-
-
- } // DisabledFocusManager
-
-
- //-------------------------------------------------------------
- // Variables --------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * FOCUS_MANAGER_CLASS_PROPERTY
- */
- public static final String FOCUS_MANAGER_CLASS_PROPERTY = "FocusManagerClassName";
-
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor FocusManager
- */
- public FocusManager() {
- // TODO
- } // FocusManager()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * getCurrentManager
- * @returns FocusManager
- */
- public static FocusManager getCurrentManager() {
- return null; // TODO
- } // getCurrentManager()
-
- /**
- * setCurrentManager
- * @param manager TODO
- */
- public static void setCurrentManager(FocusManager manager) {
- // TODO
- } // setCurrentManager()
-
- /**
- * disableSwingFocusManager
- * @deprecated 1.4
- */
- public static void disableSwingFocusManager() {
- // TODO
- } // disableSwingFocusManager()
-
- /**
- * isFocusManagerEnabled
- * @return boolean
- * @deprecated 1.4
- */
- public static boolean isFocusManagerEnabled() {
- return false; // TODO
- } // isFocusManagerEnabled()
-
- /**
- * processKeyEvent
- * @param component TODO
- * @param event TODO
- */
- public abstract void processKeyEvent(Component component, KeyEvent event);
-
- /**
- * focusNextComponent
- * @param component TODO
- */
- public abstract void focusNextComponent(Component component);
-
- /**
- * focusPreviousComponent
- * @param component TODO
- */
- public abstract void focusPreviousComponent(Component component);
-
-
-} // FocusManager
+ /**
+ * DisabledFocusManager
+ */
+ static class DisabledFocusManager
+ extends FocusManager
+ {
+
+ /**
+ * Constructor DisabledFocusManager
+ */
+ DisabledFocusManager()
+ {
+ // TODO
+ }
+
+ /**
+ * processKeyEvent
+ * @param component TODO
+ * @param event TODO
+ */
+ public void processKeyEvent(Component component, KeyEvent event)
+ {
+ // TODO
+ }
+
+ /**
+ * focusNextComponent
+ * @param component TODO
+ */
+ public void focusNextComponent(Component component)
+ {
+ // TODO
+ }
+
+ /**
+ * focusPreviousComponent
+ * @param value0 TODO
+ */
+ public void focusPreviousComponent(Component value0)
+ {
+ // TODO
+ }
+ }
+
+
+ /**
+ * FOCUS_MANAGER_CLASS_PROPERTY
+ */
+ public static final String FOCUS_MANAGER_CLASS_PROPERTY =
+ "FocusManagerClassName";
+
+ /**
+ * Constructor FocusManager
+ */
+ public FocusManager()
+ {
+ // TODO
+ }
+
+ /**
+ * getCurrentManager
+ * @returns FocusManager
+ */
+ public static FocusManager getCurrentManager()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * setCurrentManager
+ * @param manager TODO
+ */
+ public static void setCurrentManager(FocusManager manager)
+ {
+ // TODO
+ }
+
+ /**
+ * disableSwingFocusManager
+ * @deprecated 1.4
+ */
+ public static void disableSwingFocusManager()
+ {
+ // TODO
+ }
+
+ /**
+ * isFocusManagerEnabled
+ * @return boolean
+ * @deprecated 1.4
+ */
+ public static boolean isFocusManagerEnabled()
+ {
+ return false; // TODO
+ }
+
+ /**
+ * processKeyEvent
+ * @param component TODO
+ * @param event TODO
+ */
+ public abstract void processKeyEvent(Component component, KeyEvent event);
+
+ /**
+ * focusNextComponent
+ * @param component TODO
+ */
+ public abstract void focusNextComponent(Component component);
+
+ /**
+ * focusPreviousComponent
+ * @param component TODO
+ */
+ public abstract void focusPreviousComponent(Component component);
+
+}
diff --git a/javax/swing/ImageIcon.java b/javax/swing/ImageIcon.java
index abdc39131..8c2401c8e 100644
--- a/javax/swing/ImageIcon.java
+++ b/javax/swing/ImageIcon.java
@@ -45,11 +45,157 @@ import java.awt.Toolkit;
import java.awt.image.ImageObserver;
import java.io.Serializable;
import java.net.URL;
+import java.util.Locale;
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleIcon;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleStateSet;
public class ImageIcon
- implements Icon, Serializable
+ implements Icon, Serializable, Accessible
{
+ /**
+ * Accessibility support for ImageIcon.
+ */
+ protected class AccessibleImageIcon
+ extends AccessibleContext
+ implements AccessibleIcon, Serializable
+ {
+ /**
+ * Creates a new instance of AccessibleImageIcon.
+ */
+ protected AccessibleImageIcon()
+ {
+ }
+
+ /**
+ * Returns the AccessibleRole of ImageIcon, which is
+ * {@link AccessibleRole#ICON}.
+ *
+ * @return {@link AccessibleRole#ICON}
+ */
+ public AccessibleRole getAccessibleRole()
+ {
+ return AccessibleRole.ICON;
+ }
+
+ /**
+ * Returns the accessible state of this ImageIcon.
+ *
+ * @return the accessible state of this ImageIcon
+ */
+ public AccessibleStateSet getAccessibleStateSet()
+ {
+ // TODO: which state information from ImageIcon is returned here??
+ return new AccessibleStateSet();
+ }
+
+ /**
+ * Returns the accessible parent of this object, which is <code>null</code>
+ * in this case, because ImageIcons have no parent.
+ *
+ * @return <code>null</code>, because ImageIcons have no parent
+ */
+ public Accessible getAccessibleParent()
+ {
+ // TODO: ImageIcons have no parent, have they ??
+ return null;
+ }
+
+ /**
+ * Returns the index of this object in its accessible parent, which is
+ * -1 here, because ImageIcons have no accessible parent.
+ *
+ * @return -1 because ImageIcons have no parent
+ */
+ public int getAccessibleIndexInParent()
+ {
+ // TODO: do ImageIcons have parents??
+ return -1;
+ }
+
+ /**
+ * Returns the number of accessible children of this component,
+ * which is 0, because ImageIcons have no children.
+ *
+ * @return 0 because ImageIcons have no children
+ */
+ public int getAccessibleChildrenCount()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns the accessible child at index <code>i</code>, which is
+ * <code>null</code> in this case because ImageIcons have no children.
+ *
+ * @param i the index of the child to be fetched
+ *
+ * @return <code>null</code> because ImageIcons have no children
+ */
+ public Accessible getAccessibleChild(int i)
+ {
+ return null;
+ }
+
+ /**
+ * Returns the locale of this object. This returns the default locale
+ * that is set for the current VM.
+ *
+ * @return the locale of this object
+ */
+ public Locale getLocale()
+ {
+ return Locale.getDefault();
+ }
+
+ /**
+ * Returns the accessible Icon description. This returns the
+ * actual 'description' property of the ImageIcon.
+ *
+ * @return the accessible Icon description
+ */
+ public String getAccessibleIconDescription()
+ {
+ return getDescription();
+ }
+
+ /**
+ * Sets the accessible Icon description. This sets the
+ * actual 'description' property of the ImageIcon.
+ *
+ * @param newDescr the description to be set
+ */
+ public void setAccessibleIconDescription(String newDescr)
+ {
+ setDescription(newDescr);
+ }
+
+ /**
+ * Returns the icon height. This returns the iconHeight property of
+ * the underlying Icon.
+ *
+ * @return the icon height
+ */
+ public int getAccessibleIconHeight()
+ {
+ return getIconHeight();
+ }
+
+ /**
+ * Returns the icon width. This returns the iconWidth property of
+ * the underlying Icon.
+ *
+ * @return the icon width
+ */
+ public int getAccessibleIconWidth()
+ {
+ return getIconWidth();
+ }
+ } // AccessibleIcon
+
private static final long serialVersionUID = 532615968316031794L;
/** A dummy Component that is used in the MediaTracker. */
@@ -68,6 +214,9 @@ public class ImageIcon
/** The image loading status. */
private int loadStatus;
+ /** The AccessibleContext of this ImageIcon. */
+ private AccessibleContext accessibleContext;
+
public ImageIcon()
{
}
@@ -195,4 +344,16 @@ public class ImageIcon
{
return loadStatus;
}
+
+ /**
+ * Returns the AccessibleContext for this ImageIcon.
+ *
+ * @return the AccessibleContext for this ImageIcon
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ if (accessibleContext == null)
+ accessibleContext = new AccessibleImageIcon();
+ return accessibleContext;
+ }
}
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index 5924511a3..3bc8b71af 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -77,6 +77,7 @@ import javax.accessibility.AccessibleKeyBinding;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleStateSet;
import javax.swing.border.Border;
+import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.event.EventListenerList;
import javax.swing.event.SwingPropertyChangeSupport;
@@ -399,6 +400,7 @@ public abstract class JComponent extends Container implements Serializable
setDropTarget(new DropTarget());
defaultLocale = Locale.getDefault();
debugGraphicsOptions = DebugGraphics.NONE_OPTION;
+ setRequestFocusEnabled(true);
}
/**
@@ -2276,4 +2278,422 @@ public abstract class JComponent extends Container implements Serializable
! verifyInputWhenFocusTarget,
verifyInputWhenFocusTarget);
}
+
+ /**
+ * Requests that this component gets the input focus if the
+ * requestFocusEnabled property is set to <code>true</code>.
+ * This also means that this component's top-level window becomes
+ * the focused window, if that is not already the case.
+ *
+ * The preconditions that have to be met to become a focus owner is that
+ * the component must be displayable, visible and focusable.
+ *
+ * Note that this signals only a request for becoming focused. There are
+ * situations in which it is not possible to get the focus. So developers
+ * should not assume that the component has the focus until it receives
+ * a {@link java.awt.event.FocusEvent} with a value of
+ * {@link java.awt.event.FocusEvent.FOCUS_GAINED}.
+ *
+ * @see {@link Component#requestFocus()}
+ */
+ public void requestFocus()
+ {
+ if (isRequestFocusEnabled())
+ super.requestFocus();
+ }
+
+ /**
+ * This method is overridden to make it public so that it can be used
+ * by look and feel implementations.
+ *
+ * You should not use this method directly. Instead you are strongly
+ * encouraged to call {@link #requestFocus} or {@link #requestFocusInWindow}
+ * instead.
+ *
+ * @param temporary if the focus change is temporary
+ *
+ * @return <code>false</code> if the focus change request will definitly
+ * fail, <code>true</code> if it will likely succeed
+ *
+ * @see {@link Component#requestFocus(boolean)}
+ *
+ * @since 1.4
+ */
+ public boolean requestFocus(boolean temporary)
+ {
+ return super.requestFocus(temporary);
+ }
+
+ /**
+ * Requests that this component gets the input focus if the top level
+ * window that contains this component has the focus and the
+ * requestFocusEnabled property is set to <code>true</code>.
+ *
+ * The preconditions that have to be met to become a focus owner is that
+ * the component must be displayable, visible and focusable.
+ *
+ * Note that this signals only a request for becoming focused. There are
+ * situations in which it is not possible to get the focus. So developers
+ * should not assume that the component has the focus until it receives
+ * a {@link java.awt.event.FocusEvent} with a value of
+ * {@link java.awt.event.FocusEvent.FOCUS_GAINED}.
+ *
+ * @return <code>false</code> if the focus change request will definitly
+ * fail, <code>true</code> if it will likely succeed
+ *
+ * @see {@link Component#requestFocusInWindow()}
+ */
+ public boolean requestFocusInWindow()
+ {
+ if (isRequestFocusEnabled())
+ return super.requestFocusInWindow();
+ else
+ return false;
+ }
+
+ /**
+ * This method is overridden to make it public so that it can be used
+ * by look and feel implementations.
+ *
+ * You should not use this method directly. Instead you are strongly
+ * encouraged to call {@link #requestFocus} or {@link #requestFocusInWindow}
+ * instead.
+ *
+ * @param temporary if the focus change is temporary
+ *
+ * @return <code>false</code> if the focus change request will definitly
+ * fail, <code>true</code> if it will likely succeed
+ *
+ * @see {@link Component#requestFocus(boolean)}
+ *
+ * @since 1.4
+ */
+ public boolean requestFocusInWindow(boolean temporary)
+ {
+ return super.requestFocusInWindow(temporary);
+ }
+
+ /**
+ * Receives notification if this component is added to a parent component.
+ *
+ * Notification is sent to all registered AncestorListeners about the
+ * new parent.
+ *
+ * This method sets up ActionListeners for all registered KeyStrokes of
+ * this component in the chain of parent components.
+ *
+ * A PropertyChange event is fired to indicate that the ancestor property
+ * has changed.
+ *
+ * This method is used internally and should not be used in applications.
+ */
+ public void addNotify()
+ {
+ super.addNotify();
+
+ // let parents inherit the keybord mapping
+ InputMap input = getInputMap();
+ ActionMap actions = getActionMap();
+
+ Container parent = getParent();
+ while ((parent != null) && (parent instanceof JComponent))
+ {
+ JComponent jParent = (JComponent) parent;
+ InputMap parentInput = jParent.getInputMap();
+ ActionMap parentAction = jParent.getActionMap();
+
+ KeyStroke[] ikeys = input.keys();
+ for (int i = 0; i < ikeys.length; i++)
+ {
+ Object o = input.get(ikeys[i]);
+ parentInput.put(ikeys[i], o);
+ }
+
+ Object[] akeys = actions.keys();
+ for (int i = 0; i < akeys.length; i++)
+ {
+ Action a = actions.get(akeys[i]);
+ parentAction.put(akeys[i], a);
+ }
+
+ parent = jParent.getParent();
+ }
+
+ // notify ancestor listeners
+ AncestorListener[] ls = getAncestorListeners();
+ AncestorEvent ev = new AncestorEvent(this, AncestorEvent.ANCESTOR_ADDED,
+ this, parent);
+ for (int i = 0; i < ls.length; i++)
+ {
+ ls[i].ancestorAdded(ev);
+ }
+
+ // fire property change event for 'ancestor'
+ firePropertyChange("ancestor", null, parent);
+ }
+
+ /**
+ * Receives notification that this component no longer has a parent.
+ *
+ * This method sends an AncestorEvent to all registered AncestorListeners,
+ * notifying them that the parent is gone.
+ *
+ * The keybord actions of this component are removed from the parent and
+ * its ancestors.
+ *
+ * A PropertyChangeEvent is fired to indicate that the 'ancestor' property
+ * has changed.
+ *
+ * This method is called before the component is actually removed from
+ * its parent, so the parent is still visible through {@link #getParent}.
+ */
+ public void removeNotify()
+ {
+ super.removeNotify();
+
+ // let parents inherit the keybord mapping
+ InputMap input = getInputMap();
+ ActionMap actions = getActionMap();
+
+ Container parent = getParent();
+ while ((parent != null) && (parent instanceof JComponent))
+ {
+ JComponent jParent = (JComponent) parent;
+ InputMap parentInput = jParent.getInputMap();
+ ActionMap parentAction = jParent.getActionMap();
+
+ KeyStroke[] ikeys = input.allKeys();
+ for (int i = 0; i < ikeys.length; i++)
+ {
+ parentInput.remove(ikeys[i]);
+ }
+
+ Object[] akeys = actions.allKeys();
+ for (int i = 0; i < akeys.length; i++)
+ {
+ parentAction.remove(akeys[i]);
+ }
+
+ parent = jParent.getParent();
+ }
+
+ // notify ancestor listeners
+ AncestorListener[] ls = getAncestorListeners();
+ AncestorEvent ev = new AncestorEvent(this, AncestorEvent.ANCESTOR_ADDED,
+ this, parent);
+ for (int i = 0; i < ls.length; i++)
+ {
+ ls[i].ancestorAdded(ev);
+ }
+
+ // fire property change event for 'ancestor'
+ firePropertyChange("ancestor", parent, null);
+ }
+
+ /**
+ * Returns <code>true</code> if the coordinates (x, y) lie within
+ * the bounds of this component and <code>false</code> otherwise.
+ * x and y are relative to the coordinate space of the component.
+ *
+ * @param x the X coordinate of the point to check
+ * @param y the Y coordinate of the point to check
+ *
+ * @return <code>true</code> if the specified point lies within the bounds
+ * of this component, <code>false</code> otherwise
+ */
+ public boolean contains(int x, int y)
+ {
+ if (ui == null)
+ return super.contains(x, y);
+ else
+ return ui.contains(this, x, y);
+ }
+
+ /**
+ * Disables this component.
+ *
+ * @deprecated replaced by {@link #setEnabled(boolean)}
+ */
+ public void disable()
+ {
+ super.disable();
+ }
+
+ /**
+ * Enables this component.
+ *
+ * @deprecated replaced by {@link #setEnabled(boolean)}
+ */
+ public void enable()
+ {
+ super.enable();
+ }
+
+ /**
+ * Returns the Graphics context for this component. This can be used
+ * to draw on a component.
+ *
+ * @return the Graphics context for this component
+ */
+ public Graphics getGraphics()
+ {
+ return super.getGraphics();
+ }
+
+ /**
+ * Returns the X coordinate of the upper left corner of this component.
+ * Prefer this method over {@link #getBounds} or {@link #getLocation}
+ * because it does not cause any heap allocation.
+ *
+ * @return the X coordinate of the upper left corner of the component
+ */
+ public int getX()
+ {
+ return super.getX();
+ }
+
+ /**
+ * Returns the Y coordinate of the upper left corner of this component.
+ * Prefer this method over {@link #getBounds} or {@link #getLocation}
+ * because it does not cause any heap allocation.
+ *
+ * @return the Y coordinate of the upper left corner of the component
+ */
+ public int getY()
+ {
+ return super.getY();
+ }
+
+ /**
+ * Returns the height of this component. Prefer this method over
+ * {@link #getBounds} or {@link #getSize} because it does not cause
+ * any heap allocation.
+ *
+ * @return the height of the component
+ */
+ public int getHeight()
+ {
+ return super.getHeight();
+ }
+
+ /**
+ * Returns the width of this component. Prefer this method over
+ * {@link #getBounds} or {@link #getSize} because it does not cause
+ * any heap allocation.
+ *
+ * @return the width of the component
+ */
+ public int getWidth()
+ {
+ return super.getWidth();
+ }
+
+ /**
+ * Return all <code>PropertyChangeListener</code> objects registered.
+ *
+ * @return The set of <code>PropertyChangeListener</code> objects
+ */
+ public PropertyChangeListener[] getPropertyChangeListeners()
+ {
+ if (changeSupport == null)
+ return new PropertyChangeListener[0];
+ else
+ return changeSupport.getPropertyChangeListeners();
+ }
+
+ /**
+ * Prints this component to the given Graphics context. A call to this
+ * method results in calls to the methods {@link #printComponent},
+ * {@link #printBorder} and {@link printChildren} in this order.
+ *
+ * Double buffering is temporarily turned off so the painting goes directly
+ * to the supplied Graphics context.
+ *
+ * @param g the Graphics context to print onto
+ */
+ public void print(Graphics g)
+ {
+ boolean doubleBufferState = isDoubleBuffered();
+ setDoubleBuffered(false);
+ printComponent(g);
+ printBorder(g);
+ printChildren(g);
+ setDoubleBuffered(doubleBufferState);
+ }
+
+ /**
+ * Prints this component to the given Graphics context. This invokes
+ * {@link #print}.
+ *
+ * @param g the Graphics context to print onto
+ */
+ public void printAll(Graphics g)
+ {
+ print(g);
+ }
+
+ /**
+ * Prints this component to the specified Graphics context. The default
+ * behaviour is to invoke {@link #paintComponent}. Override this
+ * if you want special behaviour for printing.
+ *
+ * @param g the Graphics context to print onto
+ *
+ * @since 1.3
+ */
+ public void printComponent(Graphics g)
+ {
+ paintComponent(g);
+ }
+
+ /**
+ * Print this component's children to the specified Graphics context.
+ * The default behaviour is to invoke {@link #paintChildren}. Override this
+ * if you want special behaviour for printing.
+ *
+ * @param g the Graphics context to print onto
+ *
+ * @since 1.3
+ */
+ public void printChildren(Graphics g)
+ {
+ paintChildren(g);
+ }
+
+ /**
+ * Print this component's border to the specified Graphics context.
+ * The default behaviour is to invoke {@link #paintBorder}. Override this
+ * if you want special behaviour for printing.
+ *
+ * @param g the Graphics context to print onto
+ *
+ * @since 1.3
+ */
+ public void printBorder(Graphics g)
+ {
+ paintBorder(g);
+ }
+
+ /**
+ * Processes mouse motion event, like dragging and moving.
+ *
+ * @param ev the MouseEvent describing the mouse motion
+ */
+ protected void processMouseMotionEvent(MouseEvent ev)
+ {
+ super.processMouseMotionEvent(ev);
+ }
+
+ /**
+ * Moves and resizes the component.
+ *
+ * @param x the new horizontal location
+ * @param y the new vertial location
+ * @param w the new width
+ * @param h the new height
+ */
+ public void reshape(int x, int y, int w, int h)
+ {
+ super.reshape(x, y, w, h);
+ }
}
diff --git a/javax/swing/JDialog.java b/javax/swing/JDialog.java
index ace284bd5..db9976ed3 100644
--- a/javax/swing/JDialog.java
+++ b/javax/swing/JDialog.java
@@ -525,7 +525,9 @@ public class JDialog extends Dialog implements Accessible, WindowConstants,
operation == DISPOSE_ON_CLOSE)
close_action = operation;
else
- throw new IllegalArgumentException("Default close operation must be one of DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE");
+ // accept illegal value and set the property to the default value,
+ // that's what the reference implementation does
+ close_action = DO_NOTHING_ON_CLOSE;
}
/**
diff --git a/javax/swing/JEditorPane.java b/javax/swing/JEditorPane.java
index 8361b2037..6b77406d3 100644
--- a/javax/swing/JEditorPane.java
+++ b/javax/swing/JEditorPane.java
@@ -61,7 +61,6 @@ public class JEditorPane extends JTextComponent
private EditorKit editorKit;
boolean focus_root;
- boolean manages_focus;
public JEditorPane()
{
@@ -177,11 +176,6 @@ public class JEditorPane extends JTextComponent
return focus_root;
}
- public boolean isManagingFocus()
- {
- return manages_focus;
- }
-
protected String paramString()
{
return "JEditorPane";
diff --git a/javax/swing/JFileChooser.java b/javax/swing/JFileChooser.java
index 9b9371789..f369cc492 100644
--- a/javax/swing/JFileChooser.java
+++ b/javax/swing/JFileChooser.java
@@ -1,5 +1,5 @@
/* JFileChooser.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,925 +35,1120 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package javax.swing;
import java.awt.Component;
+import java.awt.Frame;
+import java.awt.HeadlessException;
+import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.util.Vector;
-
+import java.util.ArrayList;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
-import javax.accessibility.AccessibleRole;
+import javax.swing.JDialog;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileSystemView;
import javax.swing.filechooser.FileView;
import javax.swing.plaf.FileChooserUI;
+
/**
- * JFileChooser
- * @author Andrew Selkirk
- * @version 1.0
+ * DOCUMENT ME!
*/
-public class JFileChooser extends JComponent implements Accessible {
-
- private static final long serialVersionUID = 3162921138695327837L;
-
- /**
- * AccessibleJFileChooser
- */
- protected class AccessibleJFileChooser extends AccessibleJComponent
- {
- private static final long serialVersionUID = 8205148454060169244L;
-
- /**
- * Constructor AccessibleJFileChooser
- * @param component TODO
- */
- protected AccessibleJFileChooser()
- {
- }
-
- /**
- * getAccessibleRole
- * @return AccessibleRole
- */
- public AccessibleRole getAccessibleRole()
- {
- return AccessibleRole.FILE_CHOOSER;
- }
- }
-
- /**
- * uiClassID
- */
- private static final String uiClassID = "FileChooserUI";
-
- /**
- * OPEN_DIALOG
- */
- public static final int OPEN_DIALOG = 0;
-
- /**
- * SAVE_DIALOG
- */
- public static final int SAVE_DIALOG = 1;
-
- /**
- * CUSTOM_DIALOG
- */
- public static final int CUSTOM_DIALOG = 2;
-
- /**
- * CANCEL_OPTION
- */
- public static final int CANCEL_OPTION = 1;
-
- /**
- * APPROVE_OPTION
- */
- public static final int APPROVE_OPTION = 0;
-
- /**
- * ERROR_OPTION
- */
- public static final int ERROR_OPTION = -1;
-
- /**
- * FILES_ONLY
- */
- public static final int FILES_ONLY = 0;
-
- /**
- * DIRECTORIES_ONLY
- */
- public static final int DIRECTORIES_ONLY = 1;
-
- /**
- * FILES_AND_DIRECTORIES
- */
- public static final int FILES_AND_DIRECTORIES = 2;
-
- /**
- * CANCEL_SELECTION
- */
- public static final String CANCEL_SELECTION = "CancelSelection";
-
- /**
- * APPROVE_SELECTION
- */
- public static final String APPROVE_SELECTION = "ApproveSelection";
-
- /**
- * APPROVE_BUTTON_TEXT_CHANGED_PROPERTY
- */
- public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY = "ApproveButtonTextChangedProperty";
-
- /**
- * APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY
- */
- public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY = "ApproveButtonToolTipTextChangedProperty";
-
- /**
- * APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY
- */
- public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY = "ApproveButtonMnemonicChangedProperty";
-
- /**
- * CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY
- */
- public static final String CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY = "ControlButtonsAreShownChangedProperty";
-
- /**
- * DIRECTORY_CHANGED_PROPERTY
- */
- public static final String DIRECTORY_CHANGED_PROPERTY = "directoryChanged";
-
- /**
- * SELECTED_FILE_CHANGED_PROPERTY
- */
- public static final String SELECTED_FILE_CHANGED_PROPERTY = "SelectedFileChangedProperty";
-
- /**
- * SELECTED_FILES_CHANGED_PROPERTY
- */
- public static final String SELECTED_FILES_CHANGED_PROPERTY = "SelectedFilesChangedProperty";
-
- /**
- * MULTI_SELECTION_ENABLED_CHANGED_PROPERTY
- */
- public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY = "MultiSelectionEnabledChangedProperty";
-
- /**
- * FILE_SYSTEM_VIEW_CHANGED_PROPERTY
- */
- public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY = "FileSystemViewChanged";
-
- /**
- * FILE_VIEW_CHANGED_PROPERTY
- */
- public static final String FILE_VIEW_CHANGED_PROPERTY = "fileViewChanged";
-
- /**
- * FILE_HIDING_CHANGED_PROPERTY
- */
- public static final String FILE_HIDING_CHANGED_PROPERTY = "FileHidingChanged";
-
- /**
- * FILE_FILTER_CHANGED_PROPERTY
- */
- public static final String FILE_FILTER_CHANGED_PROPERTY = "fileFilterChanged";
-
- /**
- * FILE_SELECTION_MODE_CHANGED_PROPERTY
- */
- public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY = "fileSelectionChanged";
-
- /**
- * ACCESSORY_CHANGED_PROPERTY
- */
- public static final String ACCESSORY_CHANGED_PROPERTY = "AccessoryChangedProperty";
-
- /**
- * ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY
- */
- public static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY = "acceptAllFileFilterUsedChanged";
-
- /**
- * DIALOG_TITLE_CHANGED_PROPERTY
- */
- public static final String DIALOG_TITLE_CHANGED_PROPERTY = "DialogTitleChangedProperty";
-
- /**
- * DIALOG_TYPE_CHANGED_PROPERTY
- */
- public static final String DIALOG_TYPE_CHANGED_PROPERTY = "DialogTypeChangedProperty";
-
- /**
- * CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY
- */
- public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY = "ChoosableFileFilterChangedProperty";
-
- /**
- * dialogTitle
- */
- private String dialogTitle;
-
- /**
- * approveButtonText
- */
- private String approveButtonText;
-
- /**
- * approveButtonToolTipText
- */
- private String approveButtonToolTipText;
-
- /**
- * approveButtonMnemonic
- */
- private int approveButtonMnemonic;
-
- /**
- * actionListener
- */
- private ActionListener actionListener;
-
- /**
- * filters
- */
- private Vector filters;
-
- /**
- * dialog
- */
- private JDialog dialog;
-
- /**
- * dialogType
- */
- private int dialogType;
-
- /**
- * returnValue
- */
- private int returnValue;
-
- /**
- * accessory
- */
- private JComponent accessory;
-
- /**
- * fileView
- */
- private FileView fileView;
-
- /**
- * uiFileView
- */
- private FileView uiFileView;
-
- /**
- * controlsShown
- */
- private boolean controlsShown;
-
- /**
- * useFileHiding
- */
- private boolean useFileHiding;
-
- /**
- * fileSelectionMode
- */
- private int fileSelectionMode;
-
- /**
- * multiSelectionEnabled
- */
- private boolean multiSelectionEnabled;
-
- /**
- * useAcceptAllFileFilter
- */
- private boolean useAcceptAllFileFilter;
-
- /**
- * fileFilter
- */
- private FileFilter fileFilter;
-
- /**
- * fileSystemView
- */
- private FileSystemView fileSystemView;
-
- /**
- * currentDirectory
- */
- private File currentDirectory;
-
- /**
- * selectedFile
- */
- private File selectedFile;
-
- /**
- * selectedFiles
- */
- private File[] selectedFiles;
-
- /**
- * accessibleContext
- */
- protected AccessibleContext accessibleContext;
-
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor JFileChooser
- */
- public JFileChooser() {
- // TODO
- } // JFileChooser()
-
- /**
- * Constructor JFileChooser
- * @param currentDirectoryPath TODO
- */
- public JFileChooser(String currentDirectoryPath) {
- // TODO
- } // JFileChooser()
-
- /**
- * Constructor JFileChooser
- * @param currentDirectory TODO
- */
- public JFileChooser(File currentDirectory) {
- // TODO
- } // JFileChooser()
-
- /**
- * Constructor JFileChooser
- * @param value0 TODO
- */
- public JFileChooser(FileSystemView fsv) {
- // TODO
- } // JFileChooser()
-
- /**
- * Constructor JFileChooser
- * @param currentDirectory TODO
- * @param fsv TODO
- */
- public JFileChooser(File currentDirectory, FileSystemView fsv) {
- // TODO
- } // JFileChooser()
-
- /**
- * Constructor JFileChooser
- * @param currentDirectoryPath TODO
- * @param fsv TODO
- */
- public JFileChooser(String currentDirectoryPath, FileSystemView fsv) {
- // TODO
- } // JFileChooser()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * writeObject
- * @param stream TODO
- * @exception IOException TODO
- */
- private void writeObject(ObjectOutputStream stream) throws IOException {
- // TODO
- } // writeObject()
-
- /**
- * getName
- * @param file TODO
- * @returns String
- */
- public String getName(File file) {
- return null; // TODO
- } // getName()
-
- /**
- * setup
- * @param view TODO
- */
- protected void setup(FileSystemView view) {
- // TODO
- } // setup()
-
- /**
- * accept
- * @param file TODO
- * @returns boolean
- */
- public boolean accept(File file) {
- return false; // TODO
- } // accept()
-
- /**
- * getSelectedFile
- * @returns File
- */
- public File getSelectedFile() {
- return null; // TODO
- } // getSelectedFile()
-
- /**
- * setSelectedFile
- * @param file TODO
- */
- public void setSelectedFile(File file) {
- // TODO
- } // setSelectedFile()
-
- /**
- * getSelectedFiles
- * @returns File[]
- */
- public File[] getSelectedFiles() {
- return null; // TODO
- } // getSelectedFiles()
-
- /**
- * setSelectedFiles
- * @param files TODO
- */
- public void setSelectedFiles(File[] files) {
- // TODO
- } // setSelectedFiles()
-
- /**
- * getCurrentDirectory
- * @returns File
- */
- public File getCurrentDirectory() {
- return null; // TODO
- } // getCurrentDirectory()
-
- /**
- * setCurrentDirectory
- * @param directory TODO
- */
- public void setCurrentDirectory(File directory) {
- // TODO
- } // setCurrentDirectory()
-
- /**
- * changeToParentDirectory
- */
- public void changeToParentDirectory() {
- // TODO
- } // changeToParentDirectory()
-
- /**
- * rescanCurrentDirectory
- */
- public void rescanCurrentDirectory() {
- // TODO
- } // rescanCurrentDirectory()
-
- /**
- * ensureFileIsVisible
- * @param file TODO
- */
- public void ensureFileIsVisible(File file) {
- // TODO
- } // ensureFileIsVisible()
-
- /**
- * showOpenDialog
- * @param parent TODO
- * @returns int
- */
- public int showOpenDialog(Component parent) {
- return CANCEL_OPTION; // TODO
- } // showOpenDialog()
-
- /**
- * showSaveDialog
- * @param parent TODO
- * @returns int
- */
- public int showSaveDialog(Component parent) {
- return CANCEL_OPTION; // TODO
- } // showSaveDialog()
-
- /**
- * showDialog
- * @param parent TODO
- * @param approveButtonText TODO
- * @returns int
- */
- public int showDialog(Component parent, String approveButtonText) {
- return CANCEL_OPTION; // TODO
- } // showDialog()
-
- /**
- * getControlButtonsAreShown
- * @returns boolean
- */
- public boolean getControlButtonsAreShown() {
- return false; // TODO
- } // getControlButtonsAreShown()
-
- /**
- * setControlButtonsAreShown
- * @param value TODO
- */
- public void setControlButtonsAreShown(boolean value) {
- // TODO
- } // setControlButtonsAreShown()
-
- /**
- * getDialogType
- * @returns int
- */
- public int getDialogType() {
- return 0; // TODO
- } // getDialogType()
-
- /**
- * setDialogType
- * @param type TODO
- */
- public void setDialogType(int type) {
- // TODO
- } // setDialogType()
-
- /**
- * setDialogTitle
- * @param title TODO
- */
- public void setDialogTitle(String title) {
- // TODO
- } // setDialogTitle()
-
- /**
- * getDialogTitle
- * @returns String
- */
- public String getDialogTitle() {
- return null; // TODO
- } // getDialogTitle()
-
- /**
- * setApproveButtonToolTipText
- * @param text TODO
- */
- public void setApproveButtonToolTipText(String text) {
- // TODO
- } // setApproveButtonToolTipText()
-
- /**
- * getApproveButtonToolTipText
- * @returns String
- */
- public String getApproveButtonToolTipText() {
- return null; // TODO
- } // getApproveButtonToolTipText()
-
- /**
- * getApproveButtonMnemonic
- * @returns int
- */
- public int getApproveButtonMnemonic() {
- return 0; // TODO
- } // getApproveButtonMnemonic()
-
- /**
- * setApproveButtonMnemonic
- * @param mnemonic TODO
- */
- public void setApproveButtonMnemonic(int mnemonic) {
- // TODO
- } // setApproveButtonMnemonic()
-
- /**
- * setApproveButtonMnemonic
- * @param mnemonic TODO
- */
- public void setApproveButtonMnemonic(char mnemonic) {
- // TODO
- } // setApproveButtonMnemonic()
-
- /**
- * setApproveButtonText
- * @param text TODO
- */
- public void setApproveButtonText(String text) {
- // TODO
- } // setApproveButtonText()
-
- /**
- * getApproveButtonText
- * @returns String
- */
- public String getApproveButtonText() {
- return null; // TODO
- } // getApproveButtonText()
-
- /**
- * getChoosableFileFilters
- * @returns FileFilter[]
- */
- public FileFilter[] getChoosableFileFilters() {
- return null; // TODO
- } // getChoosableFileFilters()
-
- /**
- * addChoosableFileFilter
- * @param filter TODO
- */
- public void addChoosableFileFilter(FileFilter filter) {
- // TODO
- } // addChoosableFileFilter()
-
- /**
- * removeChoosableFileFilter
- * @param filter TODO
- * @returns boolean
- */
- public boolean removeChoosableFileFilter(FileFilter filter) {
- return false; // TODO
- } // removeChoosableFileFilter()
-
- /**
- * resetChoosableFileFilters
- */
- public void resetChoosableFileFilters() {
- // TODO
- } // resetChoosableFileFilters()
-
- /**
- * getAcceptAllFileFilter
- * @returns FileFilter
- */
- public FileFilter getAcceptAllFileFilter() {
- return null; // TODO
- } // getAcceptAllFileFilter()
-
- /**
- * isAcceptAllFileFilterUsed
- * @returns boolean
- */
- public boolean isAcceptAllFileFilterUsed() {
- return false; // TODO
- } // isAcceptAllFileFilterUsed()
-
- /**
- * setAcceptAllFileFilterUsed
- * @param value TODO
- */
- public void setAcceptAllFileFilterUsed(boolean value) {
- // TODO
- } // setAcceptAllFileFilterUsed()
-
- /**
- * getAccessory
- * @returns JComponent
- */
- public JComponent getAccessory() {
- return null; // TODO
- } // getAccessory()
-
- /**
- * setAccessory
- * @param accessory TODO
- */
- public void setAccessory(JComponent accessory) {
- // TODO
- } // setAccessory()
-
- /**
- * setFileSelectionMode
- * @param mode TODO
- */
- public void setFileSelectionMode(int mode) {
- // TODO
- } // setFileSelectionMode()
-
- /**
- * getFileSelectionMode
- * @returns int
- */
- public int getFileSelectionMode() {
- return 0; // TODO
- } // getFileSelectionMode()
-
- /**
- * isFileSelectionEnabled
- * @returns boolean
- */
- public boolean isFileSelectionEnabled() {
- return false; // TODO
- } // isFileSelectionEnabled()
-
- /**
- * isDirectorySelectionEnabled
- * @returns boolean
- */
- public boolean isDirectorySelectionEnabled() {
- return false; // TODO
- } // isDirectorySelectionEnabled()
-
- /**
- * isMultiSelectionEnabled
- * @returns boolean
- */
- public boolean isMultiSelectionEnabled() {
- return false; // TODO
- } // isMultiSelectionEnabled()
-
- /**
- * setMultiSelectionEnabled
- * @param enabled TODO
- */
- public void setMultiSelectionEnabled(boolean enabled) {
- // TODO
- } // setMultiSelectionEnabled()
-
- /**
- * isFileHidingEnabled
- * @returns boolean
- */
- public boolean isFileHidingEnabled() {
- return false; // TODO
- } // isFileHidingEnabled()
-
- /**
- * setFileHidingEnabled
- * @param enabled TODO
- */
- public void setFileHidingEnabled(boolean enabled) {
- // TODO
- } // setFileHidingEnabled()
-
- /**
- * getFileFilter
- * @returns FileFilter
- */
- public FileFilter getFileFilter() {
- return null; // TODO
- } // getFileFilter()
-
- /**
- * setFileFilter
- * @param filter TODO
- */
- public void setFileFilter(FileFilter filter) {
- // TODO
- } // setFileFilter()
-
- /**
- * getFileView
- * @returns FileView
- */
- public FileView getFileView() {
- return null; // TODO
- } // getFileView()
-
- /**
- * setFileView
- * @param view TODO
- */
- public void setFileView(FileView view) {
- // TODO
- } // setFileView()
-
- /**
- * getDescription
- * @param file TODO
- * @returns String
- */
- public String getDescription(File file) {
- return null; // TODO
- } // getDescription()
-
- /**
- * getTypeDescription
- * @param file TODO
- * @returns String
- */
- public String getTypeDescription(File file) {
- return null; // TODO
- } // getTypeDescription()
-
- /**
- * getIcon
- * @param file TODO
- * @returns Icon
- */
- public Icon getIcon(File file) {
- return null; // TODO
- } // getIcon()
-
- /**
- * isTraversable
- * @param file TODO
- * @returns boolean
- */
- public boolean isTraversable(File file) {
- return false; // TODO
- } // isTraversable()
-
- /**
- * getFileSystemView
- * @returns FileSystemView
- */
- public FileSystemView getFileSystemView() {
- return null; // TODO
- } // getFileSystemView()
-
- /**
- * setFileSystemView
- * @param fsv TODO
- */
- public void setFileSystemView(FileSystemView fsv) {
- // TODO
- } // setFileSystemView()
-
- /**
- * approveSelection
- */
- public void approveSelection() {
- // TODO
- } // approveSelection()
-
- /**
- * cancelSelection
- */
- public void cancelSelection() {
- // TODO
- } // cancelSelection()
-
- /**
- * addActionListener
- * @param listener TODO
- */
- public void addActionListener(ActionListener listener)
- {
- listenerList.add (ActionListener.class, listener);
- }
-
- /**
- * removeActionListener
- * @param listener TODO
- */
- public void removeActionListener(ActionListener listener)
- {
- listenerList.remove (ActionListener.class, listener);
- }
-
- public ActionListener[] getActionListeners()
- {
- return (ActionListener[]) listenerList.getListeners (ActionListener.class);
- }
-
- /**
- * fireActionPerformed
- * @param command TODO
- */
- protected void fireActionPerformed(String command) {
- // TODO
- } // fireActionPerformed()
-
- /**
- * updateUI
- */
- public void updateUI() {
- setUI((FileChooserUI) UIManager.get(this));
- invalidate();
- } // updateUI()
-
- /**
- * getUIClassID
- * @returns String
- */
- public String getUIClassID() {
- return uiClassID;
- } // getUIClassID()
-
- /**
- * getUI
- * @returns FileChooserUI
- */
- public FileChooserUI getUI() {
- return (FileChooserUI) ui;
- } // getUI()
-
- /**
- * paramString
- * @returns String
- */
- protected String paramString() {
- return null; // TODO
- } // paramString()
-
- /**
- * getAccessibleContext
- * @returns AccessibleContext
+public class JFileChooser extends JComponent implements Accessible
+{
+ /** DOCUMENT ME! */
+ public static final int OPEN_DIALOG = 0;
+
+ /** DOCUMENT ME! */
+ public static final int SAVE_DIALOG = 1;
+
+ /** DOCUMENT ME! */
+ public static final int CUSTOM_DIALOG = 2;
+
+ /** DOCUMENT ME! */
+ public static final int CANCEL_OPTION = 1;
+
+ /** DOCUMENT ME! */
+ public static final int APPROVE_OPTION = 0;
+
+ /** DOCUMENT ME! */
+ public static final int ERROR_OPTION = -1;
+
+ /** DOCUMENT ME! */
+ public static final int FILES_ONLY = 0;
+
+ /** DOCUMENT ME! */
+ public static final int DIRECTORIES_ONLY = 1;
+
+ /** DOCUMENT ME! */
+ public static final int FILES_AND_DIRECTORIES = 2;
+
+ /** DOCUMENT ME! */
+ public static final String CANCEL_SELECTION = "CancelSelection";
+
+ /** DOCUMENT ME! */
+ public static final String APPROVE_SELECTION = "ApproveSelection";
+
+ /** DOCUMENT ME! */
+ public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY = "approvebuttonText";
+
+ /** DOCUMENT ME! */
+ public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY = "approveButtonToolTipText";
+
+ /** DOCUMENT ME! */
+ public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY = "approveButtonMnemonic";
+
+ /** DOCUMENT ME! */
+ public static final String CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY = "controlButtonsAreShown";
+
+ /** DOCUMENT ME! */
+ public static final String DIRECTORY_CHANGED_PROPERTY = "directory";
+
+ /** DOCUMENT ME! */
+ public static final String SELECTED_FILE_CHANGED_PROPERTY = "SelectedFileChangedProperty";
+
+ /** DOCUMENT ME! */
+ public static final String SELECTED_FILES_CHANGED_PROPERTY = "selectedFiles";
+
+ /** DOCUMENT ME! */
+ public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY = "multiSelectionEnabled";
+
+ /** DOCUMENT ME! */
+ public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY = "fileSystemView";
+
+ /** DOCUMENT ME! */
+ public static final String FILE_VIEW_CHANGED_PROPERTY = "fileView";
+
+ /** DOCUMENT ME! */
+ public static final String FILE_HIDING_CHANGED_PROPERTY = "fileHidingEnabled";
+
+ /** DOCUMENT ME! */
+ public static final String FILE_FILTER_CHANGED_PROPERTY = "fileFilter";
+
+ /** DOCUMENT ME! */
+ public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY = "fileSelectionMode";
+
+ /** DOCUMENT ME! */
+ public static final String ACCESSORY_CHANGED_PROPERTY = "accessory";
+
+ /** DOCUMENT ME! */
+ public static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY = "acceptAllFileFilter";
+
+ /** DOCUMENT ME! */
+ public static final String DIALOG_TITLE_CHANGED_PROPERTY = "dialogTitle";
+
+ /** DOCUMENT ME! */
+ public static final String DIALOG_TYPE_CHANGED_PROPERTY = "dialogType";
+
+ /** DOCUMENT ME! */
+ public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY = "choosableFileFilter";
+
+ /** DOCUMENT ME! */
+ protected AccessibleContext accessibleContext;
+
+ /** DOCUMENT ME! */
+ private FileSystemView fsv;
+
+ /** DOCUMENT ME! */
+ private JComponent accessory;
+
+ /** DOCUMENT ME! */
+ private int approveButtonMnemonic = 0;
+
+ /** DOCUMENT ME! */
+ private String approveButtonText;
+
+ /** DOCUMENT ME! */
+ private String approveButtonToolTipText;
+
+ /** DOCUMENT ME! */
+ private ArrayList choosableFilters = new ArrayList();
+
+ /** DOCUMENT ME! */
+ private boolean isAcceptAll = true;
+
+ /** DOCUMENT ME! */
+ private String dialogTitle;
+
+ /** DOCUMENT ME! */
+ private int dialogType = OPEN_DIALOG;
+
+ /** DOCUMENT ME! */
+ private int retval = ERROR_OPTION;
+
+ /** DOCUMENT ME! */
+ private boolean multiSelection = false;
+
+ /** DOCUMENT ME! */
+ private boolean fileHiding = true;
+
+ /** DOCUMENT ME! */
+ private int fileSelectionMode = FILES_AND_DIRECTORIES;
+
+ /** DOCUMENT ME! */
+ private FileView fv = null;
+
+ /** DOCUMENT ME! */
+ private boolean controlButtonsShown = true;
+
+ /** DOCUMENT ME! */
+ private File currentDir = null;
+
+ /** DOCUMENT ME! */
+ private FileFilter currentFilter = null;
+
+ /** DOCUMENT ME! */
+ private File[] selectedFiles;
+
+ /** DOCUMENT ME! */
+ private File selectedFile;
+
+ /**
+ * Creates a new JFileChooser object.
*/
- public AccessibleContext getAccessibleContext()
+ public JFileChooser()
+ {
+ setup(null);
+ setCurrentDirectory(null);
+ }
+
+ /**
+ * Creates a new JFileChooser object.
+ *
+ * @param currentDirectoryPath DOCUMENT ME!
+ */
+ public JFileChooser(String currentDirectoryPath)
+ {
+ setup(null);
+ setCurrentDirectory(fsv.createFileObject(currentDirectoryPath));
+ }
+
+ /**
+ * Creates a new JFileChooser object.
+ *
+ * @param currentDirectory DOCUMENT ME!
+ */
+ public JFileChooser(File currentDirectory)
+ {
+ setup(null);
+ setCurrentDirectory(currentDirectory);
+ }
+
+ /**
+ * Creates a new JFileChooser object.
+ *
+ * @param fsv DOCUMENT ME!
+ */
+ public JFileChooser(FileSystemView fsv)
+ {
+ setup(fsv);
+ setCurrentDirectory(null);
+ }
+
+ /**
+ * Creates a new JFileChooser object.
+ *
+ * @param currentDirectory DOCUMENT ME!
+ * @param fsv DOCUMENT ME!
+ */
+ public JFileChooser(File currentDirectory, FileSystemView fsv)
+ {
+ setup(fsv);
+ setCurrentDirectory(currentDirectory);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param view DOCUMENT ME!
+ */
+ protected void setup(FileSystemView view)
+ {
+ if (view == null)
+ view = FileSystemView.getFileSystemView();
+ setFileSystemView(view);
+ updateUI();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param b DOCUMENT ME!
+ */
+ public void setDragEnabled(boolean b)
+ {
+ // FIXME: Implement
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean getDragEnabled()
+ {
+ // FIXME: Implement
+ return false;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File getSelectedFile()
+ {
+ return selectedFile;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param file DOCUMENT ME!
+ */
+ public void setSelectedFile(File file)
+ {
+ if (selectedFile != file)
+ {
+ File old = selectedFile;
+ selectedFile = file;
+ firePropertyChange(SELECTED_FILE_CHANGED_PROPERTY, old, selectedFile);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File[] getSelectedFiles()
+ {
+ return selectedFiles;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param selectedFiles DOCUMENT ME!
+ */
+ public void setSelectedFiles(File[] selectedFiles)
+ {
+ if (this.selectedFiles != selectedFiles)
+ {
+ File[] old = this.selectedFiles;
+ this.selectedFiles = selectedFiles;
+ firePropertyChange(SELECTED_FILES_CHANGED_PROPERTY, old, selectedFiles);
+ }
+
+ if (selectedFiles != null)
+ setSelectedFile(selectedFiles[0]);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File getCurrentDirectory()
+ {
+ return currentDir;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dir DOCUMENT ME!
+ */
+ public void setCurrentDirectory(File dir)
+ {
+ if (currentDir != dir || dir == null)
+ {
+ if (dir == null)
+ dir = fsv.getDefaultDirectory();
+
+ File old = currentDir;
+ currentDir = dir;
+ firePropertyChange(DIRECTORY_CHANGED_PROPERTY, old, currentDir);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void changeToParentDirectory()
+ {
+ setCurrentDirectory(fsv.getParentDirectory(currentDir));
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void rescanCurrentDirectory()
+ {
+ getUI().rescanCurrentDirectory(this);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ */
+ public void ensureFileIsVisible(File f)
+ {
+ getUI().ensureFileIsVisible(this, f);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param parent DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ *
+ * @throws HeadlessException DOCUMENT ME!
+ */
+ public int showOpenDialog(Component parent) throws HeadlessException
+ {
+ JDialog d = createDialog(parent);
+
+ // FIXME: Remove when we get ancestor property
+ d.setTitle("Open");
+ setDialogType(OPEN_DIALOG);
+
+ retval = ERROR_OPTION;
+
+ d.pack();
+ d.show();
+ return retval;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param parent DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ *
+ * @throws HeadlessException DOCUMENT ME!
+ */
+ public int showSaveDialog(Component parent) throws HeadlessException
+ {
+ JDialog d = createDialog(parent);
+ setDialogType(SAVE_DIALOG);
+
+ retval = ERROR_OPTION;
+
+ d.pack();
+ d.show();
+ return retval;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param parent DOCUMENT ME!
+ * @param approveButtonText DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ *
+ * @throws HeadlessException DOCUMENT ME!
+ */
+ public int showDialog(Component parent, String approveButtonText)
+ throws HeadlessException
+ {
+ JDialog d = createDialog(parent);
+ setApproveButtonText(approveButtonText);
+ setDialogType(CUSTOM_DIALOG);
+
+ retval = ERROR_OPTION;
+
+ d.pack();
+ d.show();
+ return retval;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param parent DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ *
+ * @throws HeadlessException DOCUMENT ME!
+ */
+ protected JDialog createDialog(Component parent) throws HeadlessException
+ {
+ Frame toUse = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
+ if (toUse == null)
+ toUse = SwingUtilities.getOwnerFrame();
+
+ JDialog dialog = new JDialog(toUse);
+ setSelectedFile(null);
+ dialog.getContentPane().add(this);
+ dialog.setModal(true);
+ dialog.invalidate();
+ dialog.repaint();
+
+ return dialog;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean getControlButtonsAreShown()
+ {
+ return controlButtonsShown;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param b DOCUMENT ME!
+ */
+ public void setControlButtonsAreShown(boolean b)
+ {
+ if (controlButtonsShown != b)
+ {
+ controlButtonsShown = b;
+ firePropertyChange(CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY,
+ ! controlButtonsShown, controlButtonsShown);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public int getDialogType()
+ {
+ return dialogType;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dialogType DOCUMENT ME!
+ */
+ public void setDialogType(int dialogType)
+ {
+ if (dialogType != OPEN_DIALOG && dialogType != SAVE_DIALOG
+ && dialogType != CUSTOM_DIALOG)
+ throw new IllegalArgumentException("Choose allowable dialogType.");
+
+ if (this.dialogType != dialogType)
+ {
+ int old = this.dialogType;
+ this.dialogType = dialogType;
+ firePropertyChange(DIALOG_TYPE_CHANGED_PROPERTY, old, this.dialogType);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dialogTitle DOCUMENT ME!
+ */
+ public void setDialogTitle(String dialogTitle)
+ {
+ if (this.dialogTitle != dialogTitle)
+ {
+ String old = this.dialogTitle;
+ this.dialogTitle = dialogTitle;
+ firePropertyChange(DIALOG_TITLE_CHANGED_PROPERTY, old, this.dialogTitle);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getDialogTitle()
+ {
+ return dialogTitle;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param toolTipText DOCUMENT ME!
+ */
+ public void setApproveButtonToolTipText(String toolTipText)
+ {
+ if (approveButtonToolTipText != toolTipText)
+ {
+ String oldText = approveButtonToolTipText;
+ approveButtonToolTipText = toolTipText;
+ firePropertyChange(APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY,
+ oldText, approveButtonToolTipText);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getApproveButtonToolTipText()
+ {
+ return approveButtonToolTipText;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public int getApproveButtonMnemonic()
+ {
+ return approveButtonMnemonic;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param mnemonic DOCUMENT ME!
+ */
+ public void setApproveButtonMnemonic(int mnemonic)
+ {
+ if (approveButtonMnemonic != mnemonic)
+ {
+ int oldMnemonic = approveButtonMnemonic;
+ approveButtonMnemonic = mnemonic;
+ firePropertyChange(APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY,
+ oldMnemonic, approveButtonMnemonic);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param mnemonic DOCUMENT ME!
+ */
+ public void setApproveButtonMnemonic(char mnemonic)
{
- if (accessibleContext == null)
- accessibleContext = new AccessibleJFileChooser();
+ setApproveButtonMnemonic((int) Character.toUpperCase(mnemonic));
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param approveButtonText DOCUMENT ME!
+ */
+ public void setApproveButtonText(String approveButtonText)
+ {
+ if (this.approveButtonText != approveButtonText)
+ {
+ String oldText = this.approveButtonText;
+ this.approveButtonText = approveButtonText;
+ firePropertyChange(APPROVE_BUTTON_TEXT_CHANGED_PROPERTY, oldText,
+ this.approveButtonText);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getApproveButtonText()
+ {
+ return approveButtonText;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public FileFilter[] getChoosableFileFilters()
+ {
+ return (FileFilter[]) choosableFilters.toArray(new FileFilter[0]);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param filter DOCUMENT ME!
+ */
+ public void addChoosableFileFilter(FileFilter filter)
+ {
+ FileFilter[] old = getChoosableFileFilters();
+ choosableFilters.add(filter);
+ FileFilter[] newFilters = getChoosableFileFilters();
+ firePropertyChange(CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY, old, newFilters);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean removeChoosableFileFilter(FileFilter f)
+ {
+ FileFilter[] old = getChoosableFileFilters();
+ if (! choosableFilters.remove(f))
+ return false;
+ FileFilter[] newFilters = getChoosableFileFilters();
+ firePropertyChange(CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY, old, newFilters);
+ return true;
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void resetChoosableFileFilters()
+ {
+ choosableFilters.clear();
+ choosableFilters.add(getUI().getAcceptAllFileFilter(this));
+ setFileFilter((FileFilter) choosableFilters.get(0));
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public FileFilter getAcceptAllFileFilter()
+ {
+ return getUI().getAcceptAllFileFilter(this);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isAcceptAllFileFilterUsed()
+ {
+ return isAcceptAll;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param b DOCUMENT ME!
+ */
+ public void setAcceptAllFileFilterUsed(boolean b)
+ {
+ if (isAcceptAll != b)
+ {
+ isAcceptAll = b;
+ firePropertyChange(ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY,
+ ! isAcceptAll, isAcceptAll);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public JComponent getAccessory()
+ {
+ return accessory;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param newAccessory DOCUMENT ME!
+ */
+ public void setAccessory(JComponent newAccessory)
+ {
+ if (accessory != newAccessory)
+ {
+ JComponent old = accessory;
+ accessory = newAccessory;
+ firePropertyChange(ACCESSORY_CHANGED_PROPERTY, old, accessory);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param mode DOCUMENT ME!
+ */
+ public void setFileSelectionMode(int mode)
+ {
+ if (mode != FILES_ONLY && mode != DIRECTORIES_ONLY
+ && mode != FILES_AND_DIRECTORIES)
+ throw new IllegalArgumentException("Choose a correct file selection mode.");
+ if (fileSelectionMode != mode)
+ {
+ int old = fileSelectionMode;
+ fileSelectionMode = mode;
+ firePropertyChange(FILE_SELECTION_MODE_CHANGED_PROPERTY, old,
+ fileSelectionMode);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public int getFileSelectionMode()
+ {
+ return fileSelectionMode;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isFileSelectionEnabled()
+ {
+ return (fileSelectionMode == FILES_ONLY
+ || fileSelectionMode == FILES_AND_DIRECTORIES);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isDirectorySelectionEnabled()
+ {
+ return (fileSelectionMode == DIRECTORIES_ONLY
+ || fileSelectionMode == FILES_AND_DIRECTORIES);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param b DOCUMENT ME!
+ */
+ public void setMultiSelectionEnabled(boolean b)
+ {
+ if (multiSelection != b)
+ {
+ multiSelection = b;
+ firePropertyChange(MULTI_SELECTION_ENABLED_CHANGED_PROPERTY,
+ ! multiSelection, multiSelection);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isMultiSelectionEnabled()
+ {
+ return multiSelection;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isFileHidingEnabled()
+ {
+ return fileHiding;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param b DOCUMENT ME!
+ */
+ public void setFileHidingEnabled(boolean b)
+ {
+ if (fileHiding != b)
+ {
+ fileHiding = b;
+ firePropertyChange(FILE_HIDING_CHANGED_PROPERTY, ! fileHiding,
+ fileHiding);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param filter DOCUMENT ME!
+ */
+ public void setFileFilter(FileFilter filter)
+ {
+ if (currentFilter != filter)
+ {
+ FileFilter old = currentFilter;
+ currentFilter = filter;
+ firePropertyChange(FILE_FILTER_CHANGED_PROPERTY, old, currentFilter);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public FileFilter getFileFilter()
+ {
+ return currentFilter;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fileView DOCUMENT ME!
+ */
+ public void setFileView(FileView fileView)
+ {
+ if (fv != fileView)
+ {
+ FileView old = fv;
+ fv = fileView;
+ firePropertyChange(FILE_VIEW_CHANGED_PROPERTY, old, fv);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public FileView getFileView()
+ {
+ return fv;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ private FileView getInternalFileView()
+ {
+ if (fv == null)
+ return getUI().getFileView(this);
+ return fv;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getName(File f)
+ {
+ return getInternalFileView().getName(f);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getDescription(File f)
+ {
+ return getInternalFileView().getDescription(f);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getTypeDescription(File f)
+ {
+ return getInternalFileView().getTypeDescription(f);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Icon getIcon(File f)
+ {
+ return getInternalFileView().getIcon(f);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isTraversable(File f)
+ {
+ return getFileSystemView().isTraversable(f).booleanValue();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean accept(File f)
+ {
+ if (f == null)
+ return false;
+ return getFileFilter().accept(f);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fsv DOCUMENT ME!
+ */
+ public void setFileSystemView(FileSystemView fsv)
+ {
+ if (this.fsv != fsv)
+ {
+ FileSystemView old = this.fsv;
+ this.fsv = fsv;
+ firePropertyChange(FILE_SYSTEM_VIEW_CHANGED_PROPERTY, old, this.fsv);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public FileSystemView getFileSystemView()
+ {
+ return fsv;
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void approveSelection()
+ {
+ retval = APPROVE_OPTION;
+ fireActionPerformed(APPROVE_SELECTION);
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void cancelSelection()
+ {
+ retval = CANCEL_OPTION;
+ fireActionPerformed(CANCEL_SELECTION);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param l DOCUMENT ME!
+ */
+ public void addActionListener(ActionListener l)
+ {
+ listenerList.add(ActionListener.class, l);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param l DOCUMENT ME!
+ */
+ public void removeActionListener(ActionListener l)
+ {
+ try
+ {
+ listenerList.remove(ActionListener.class, l);
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public ActionListener[] getActionListeners()
+ {
+ return (ActionListener[]) getListeners(ActionListener.class);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param command DOCUMENT ME!
+ */
+ protected void fireActionPerformed(String command)
+ {
+ ActionListener[] list = getActionListeners();
+ ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
+ command);
+
+ for (int i = 0; i < list.length; i++)
+ list[i].actionPerformed(event);
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void updateUI()
+ {
+ setUI((FileChooserUI) UIManager.getUI(this));
+ revalidate();
+ }
- return accessibleContext;
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getUIClassID()
+ {
+ return "FileChooserUI";
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public FileChooserUI getUI()
+ {
+ return (FileChooserUI) ui;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected String paramString()
+ {
+ return "JFileChooser";
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public AccessibleContext getAccessibleContext()
+ {
+ return null;
}
}
diff --git a/javax/swing/JSeparator.java b/javax/swing/JSeparator.java
index 5b99795a5..d3edb737d 100644
--- a/javax/swing/JSeparator.java
+++ b/javax/swing/JSeparator.java
@@ -183,17 +183,6 @@ public class JSeparator extends JComponent implements SwingConstants,
}
/**
- * This method overrides the isFocusTraversable method from
- * Component to false. JSeparator cannot be focused on.
- *
- * @return boolean False.
- */
- public boolean isFocusTraversable()
- {
- return false;
- }
-
- /**
* getAccessibleContext
*
* @return AccessibleContext
diff --git a/javax/swing/JTable.java b/javax/swing/JTable.java
index ca38aa0ba..e609e61ed 100644
--- a/javax/swing/JTable.java
+++ b/javax/swing/JTable.java
@@ -43,6 +43,9 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
+import java.text.DateFormat;
+import java.text.NumberFormat;
+import java.util.Date;
import java.util.Hashtable;
import java.util.Vector;
@@ -71,6 +74,212 @@ public class JTable extends JComponent
implements TableModelListener, Scrollable, TableColumnModelListener,
ListSelectionListener, CellEditorListener, Accessible
{
+
+ /**
+ * A cell renderer for boolean values.
+ */
+ private class BooleanCellRenderer
+ extends DefaultTableCellRenderer
+ {
+
+ /**
+ * The CheckBox that is used for rendering.
+ */
+ private JCheckBox checkBox = new JCheckBox();
+
+ /**
+ * Returns the component that is used for rendering the value.
+ *
+ * @param table the JTable
+ * @param value the value of the object
+ * @param isSelected is the cell selected?
+ * @param hasFocus has the cell the focus?
+ * @param row the row to render
+ * @param column the cell to render
+ *
+ * @return this component (the default table cell renderer)
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus, int row,
+ int column)
+ {
+ Boolean boolValue = (Boolean) value;
+ checkBox.setSelected(boolValue.booleanValue());
+ return checkBox;
+ }
+ }
+
+ /**
+ * A cell renderer for Date values.
+ */
+ private class DateCellRenderer
+ extends DefaultTableCellRenderer
+ {
+ /**
+ * Returns the component that is used for rendering the value.
+ *
+ * @param table the JTable
+ * @param value the value of the object
+ * @param isSelected is the cell selected?
+ * @param hasFocus has the cell the focus?
+ * @param row the row to render
+ * @param column the cell to render
+ *
+ * @return this component (the default table cell renderer)
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus, int row,
+ int column)
+ {
+ super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
+ row, column);
+ if (value instanceof Date)
+ {
+ Date dateValue = (Date) value;
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
+ setText(df.format(dateValue));
+ }
+ return this;
+ }
+ }
+
+ /**
+ * A cell renderer for Double values.
+ */
+ private class DoubleCellRenderer
+ extends DefaultTableCellRenderer
+ {
+ /**
+ * Creates a new instance of NumberCellRenderer.
+ */
+ public DoubleCellRenderer()
+ {
+ setHorizontalAlignment(JLabel.RIGHT);
+ }
+
+ /**
+ * Returns the component that is used for rendering the value.
+ *
+ * @param table the JTable
+ * @param value the value of the object
+ * @param isSelected is the cell selected?
+ * @param hasFocus has the cell the focus?
+ * @param row the row to render
+ * @param column the cell to render
+ *
+ * @return this component (the default table cell renderer)
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus, int row,
+ int column)
+ {
+ super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
+ row, column);
+ if (value instanceof Double)
+ {
+ Double doubleValue = (Double) value;
+ NumberFormat nf = NumberFormat.getInstance();
+ setText(nf.format(doubleValue.doubleValue()));
+ }
+ return this;
+ }
+ }
+
+ /**
+ * A cell renderer for Float values.
+ */
+ private class FloatCellRenderer
+ extends DefaultTableCellRenderer
+ {
+ /**
+ * Creates a new instance of NumberCellRenderer.
+ */
+ public FloatCellRenderer()
+ {
+ setHorizontalAlignment(JLabel.RIGHT);
+ }
+
+ /**
+ * Returns the component that is used for rendering the value.
+ *
+ * @param table the JTable
+ * @param value the value of the object
+ * @param isSelected is the cell selected?
+ * @param hasFocus has the cell the focus?
+ * @param row the row to render
+ * @param column the cell to render
+ *
+ * @return this component (the default table cell renderer)
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus, int row,
+ int column)
+ {
+ super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
+ row, column);
+ if (value instanceof Float)
+ {
+ Float floatValue = (Float) value;
+ NumberFormat nf = NumberFormat.getInstance();
+ setText(nf.format(floatValue.floatValue()));
+ }
+ return this;
+ }
+ }
+
+ /**
+ * A cell renderer for Number values.
+ */
+ private class NumberCellRenderer
+ extends DefaultTableCellRenderer
+ {
+ /**
+ * Creates a new instance of NumberCellRenderer.
+ */
+ public NumberCellRenderer()
+ {
+ setHorizontalAlignment(JLabel.RIGHT);
+ }
+ }
+
+ /**
+ * A cell renderer for Icon values.
+ */
+ private class IconCellRenderer
+ extends DefaultTableCellRenderer
+ {
+ /**
+ * Returns the component that is used for rendering the value.
+ *
+ * @param table the JTable
+ * @param value the value of the object
+ * @param isSelected is the cell selected?
+ * @param hasFocus has the cell the focus?
+ * @param row the row to render
+ * @param column the cell to render
+ *
+ * @return this component (the default table cell renderer)
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus, int row,
+ int column)
+ {
+ super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
+ row, column);
+ if (value instanceof Icon)
+ {
+ Icon iconValue = (Icon) value;
+ setIcon(iconValue);
+ }
+ return this;
+ }
+ }
+
private static final long serialVersionUID = 3876025080382781659L;
@@ -476,7 +685,12 @@ public class JTable extends JComponent
protected void createDefaultRenderers()
{
- //FIXME: Create the renderer object.
+ setDefaultRenderer(Boolean.class, new BooleanCellRenderer());
+ setDefaultRenderer(Number.class, new NumberCellRenderer());
+ setDefaultRenderer(Double.class, new DoubleCellRenderer());
+ setDefaultRenderer(Double.class, new FloatCellRenderer());
+ setDefaultRenderer(Date.class, new DateCellRenderer());
+ setDefaultRenderer(Icon.class, new IconCellRenderer());
}
/**
@@ -1580,44 +1794,22 @@ public class JTable extends JComponent
/**
- * Sun javadocs describe an unusual implementation of
- * <code>doLayout</code> which involves some private interfaces. We try
- * to implement the same algorithm as is documented, but using the
- * columnModel directly. We still use a private helper method, but it has
- * a simpler signature.
+ * This distributes the superfluous width in a table evenly on its columns.
+ *
+ * The implementation used here is different to that one described in
+ * the JavaDocs. It is much simpler, and seems to work very well.
+ *
+ * TODO: correctly implement the algorithm described in the JavaDoc
*/
-
private void distributeSpill(TableColumn[] cols, int spill)
{
- int MIN = 0;
- int MAX = 0;
- int PREF = 0;
-
- int[] min = new int[cols.length];
- int[] max = new int[cols.length];
- int[] pref = new int[cols.length];
-
- for (int i = 0; i < cols.length; ++i)
+ int average = spill / cols.length;
+ for (int i = 0; i < cols.length; i++)
{
- pref[i] = cols[i].getPreferredWidth();
- min[i] = cols[i].getMinWidth();
- max[i] = cols[i].getMaxWidth();
- PREF += pref[i];
- MIN += min[i];
- MAX += max[i];
+ cols[i].setWidth(cols[i].getWidth() + average);
}
-
- for (int i = 0; i < cols.length; ++i)
- {
- int adj = 0;
- if (spill > 0)
- adj = (spill * (pref[i] - min[i])) / (PREF - MIN);
- else
- adj = (spill * (max[i] - pref[i])) / (MAX - PREF);
- cols[i].setWidth(pref[i] + adj);
- }
}
-
+
public void doLayout()
{
TableColumn resizingColumn = null;
@@ -1643,7 +1835,7 @@ public class JTable extends JComponent
rCol = i;
}
- int spill = prefSum - getWidth();
+ int spill = getWidth() - prefSum;
if (resizingColumn != null)
{
diff --git a/javax/swing/JTextField.java b/javax/swing/JTextField.java
index 409e2a597..19651445c 100644
--- a/javax/swing/JTextField.java
+++ b/javax/swing/JTextField.java
@@ -47,6 +47,8 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.accessibility.AccessibleStateSet;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import javax.swing.text.PlainDocument;
@@ -187,7 +189,15 @@ public class JTextField extends JTextComponent
*/
protected Document createDefaultModel()
{
- return new PlainDocument();
+ // subclassed to swallow newlines
+ return new PlainDocument() {
+ public void insertString(int offset, String str, AttributeSet a)
+ throws BadLocationException
+ {
+ if (str.indexOf('\n') == -1)
+ super.insertString(offset, str, a);
+ }
+ };
}
/**
diff --git a/javax/swing/JTree.java b/javax/swing/JTree.java
index 170fd3014..5a0e78abe 100644
--- a/javax/swing/JTree.java
+++ b/javax/swing/JTree.java
@@ -40,6 +40,7 @@ package javax.swing;
import java.awt.Dimension;
import java.awt.Rectangle;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
@@ -49,6 +50,8 @@ import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeExpansionListener;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeWillExpandListener;
@@ -56,6 +59,7 @@ import javax.swing.plaf.TreeUI;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.ExpandVetoException;
import javax.swing.tree.TreeCellEditor;
import javax.swing.tree.TreeCellRenderer;
@@ -68,6 +72,172 @@ import javax.swing.tree.TreeSelectionModel;
public class JTree extends JComponent
implements Scrollable, Accessible
{
+ /**
+ * Listens to the model of the JTree and updates the property
+ * <code>expandedState</code> if nodes are removed or changed.
+ */
+ protected class TreeModelHandler
+ implements TreeModelListener
+ {
+
+ /**
+ * Creates a new instance of TreeModelHandler.
+ */
+ protected TreeModelHandler()
+ {
+ }
+
+ /**
+ * Notifies when a node has changed in some ways. This does not include
+ * that a node has changed its location or changed it's children. It
+ * only means that some attributes of the node have changed that might
+ * affect its presentation.
+ *
+ * This method is called after the actual change occured.
+ *
+ * @param ev the TreeModelEvent describing the change
+ */
+ public void treeNodesChanged(TreeModelEvent ev)
+ {
+ // nothing to do here
+ }
+
+ /**
+ * Notifies when a node is inserted into the tree.
+ *
+ * This method is called after the actual change occured.
+ *
+ * @param ev the TreeModelEvent describing the change
+ */
+ public void treeNodesInserted(TreeModelEvent ev)
+ {
+ // nothing to do here
+ }
+
+ /**
+ * Notifies when a node is removed from the tree.
+ *
+ * This method is called after the actual change occured.
+ *
+ * @param ev the TreeModelEvent describing the change
+ */
+ public void treeNodesRemoved(TreeModelEvent ev)
+ {
+ // TODO: The API docs suggest that this method should do something
+ // but I cannot really see what has to be done here ...
+ }
+
+ /**
+ * Notifies when the structure of the tree is changed.
+ *
+ * This method is called after the actual change occured.
+ *
+ * @param ev the TreeModelEvent describing the change
+ */
+ public void treeStructureChanged(TreeModelEvent ev)
+ {
+ // set state of new path
+ TreePath path = ev.getTreePath();
+ setExpandedState(path, isExpanded(path));
+ }
+ } // TreeModelHandler
+
+ /**
+ * This redirects TreeSelectionEvents and rewrites the source of it
+ * to be this JTree. This is typically done when the tree model
+ * generates an event, but the JTree object associated with that model
+ * should be listed as the actual source of the event.
+ */
+ protected class TreeSelectionRedirector
+ implements TreeSelectionListener, Serializable
+ {
+ /** The serial version UID. */
+ private static final long serialVersionUID = -3505069663646241664L;
+
+ /**
+ * Creates a new instance of TreeSelectionRedirector
+ */
+ protected TreeSelectionRedirector()
+ {
+ }
+
+ /**
+ * Notifies when the tree selection changes.
+ *
+ * @param ev the TreeSelectionEvent that describes the change
+ */
+ public void valueChanged(TreeSelectionEvent ev)
+ {
+ TreeSelectionEvent rewritten =
+ (TreeSelectionEvent) ev.cloneWithSource(JTree.this);
+ fireValueChanged(rewritten);
+ }
+ } // TreeSelectionRedirector
+
+ /**
+ * A TreeModel that does not allow anything to be selected.
+ */
+ protected static class EmptySelectionModel
+ extends DefaultTreeSelectionModel
+ {
+ /** The serial version UID. */
+ private static final long serialVersionUID = -5815023306225701477L;
+
+ /**
+ * The shared instance of this model.
+ */
+ protected static final EmptySelectionModel sharedInstance =
+ new EmptySelectionModel();
+
+ /**
+ * Creates a new instance of EmptySelectionModel.
+ */
+ protected EmptySelectionModel()
+ {
+ }
+
+ /**
+ * Returns the shared instance of EmptySelectionModel.
+ *
+ * @return the shared instance of EmptySelectionModel
+ */
+ public static EmptySelectionModel sharedInstance()
+ {
+ return sharedInstance;
+ }
+
+ /**
+ * This catches attempts to set a selection and sets nothing
+ * instead.
+ *
+ * @param paths not used here
+ */
+ public void setSelectionPaths(TreePath[] paths)
+ {
+ // we don't allow selections in this class
+ }
+
+ /**
+ * This catches attempts to add something to the selection.
+ *
+ * @param paths not used here
+ */
+ public void addSelectionPaths(TreePath[] paths)
+ {
+ // we don't allow selections in this class
+ }
+
+ /**
+ * This catches attempts to remove something from the selection.
+ *
+ * @param paths not used here
+ */
+ public void removeSelectionPaths(TreePath[] paths)
+ {
+ // we don't allow selections in this class
+ }
+ }// EmptySelectionModel
+
private static final long serialVersionUID = 7559816092864483649L;
public static final String CELL_EDITOR_PROPERTY = "cellEditor";
@@ -121,6 +291,17 @@ public class JTree extends JComponent
protected int visibleRowCount;
/**
+ * Handles TreeModelEvents to update the expandedState.
+ */
+ protected transient TreeModelListener treeModelListener;
+
+ /**
+ * Redirects TreeSelectionEvents so that the source is this JTree.
+ */
+ protected TreeSelectionRedirector selectionRedirector =
+ new TreeSelectionRedirector();
+
+ /**
* Creates a new <code>JTree</code> object.
*/
public JTree()
@@ -155,7 +336,9 @@ public class JTree extends JComponent
*/
public JTree(TreeModel model)
{
- treeModel = model;
+ setModel(model);
+ setSelectionModel(EmptySelectionModel.sharedInstance());
+ selectionModel.addTreeSelectionListener(selectionRedirector);
setCellRenderer(new DefaultTreeCellRenderer());
updateUI();
}
@@ -233,6 +416,20 @@ public class JTree extends JComponent
return super.children();
}
+ /**
+ * Returns the child node at position <code>pos</code>. Subclassed here
+ * to load the children if necessary.
+ *
+ * @param pos the position of the child node to fetch
+ *
+ * @return the childnode at the specified position
+ */
+ public TreeNode getChildAt(int pos)
+ {
+ loadChildren();
+ return super.getChildAt(pos);
+ }
+
public boolean isLeaf()
{
return (childValue == null ||
@@ -582,6 +779,11 @@ public class JTree extends JComponent
TreeModel oldValue = treeModel;
treeModel = model;
firePropertyChange(TREE_MODEL_PROPERTY, oldValue, model);
+
+ // add treeModelListener to the new model
+ if (treeModelListener == null)
+ treeModelListener = createTreeModelListener();
+ model.addTreeModelListener(treeModelListener);
}
/**
@@ -1389,4 +1591,117 @@ public class JTree extends JComponent
{
return isEditable();
}
+
+ /**
+ * Creates and returns an instance of {@link TreeModelHandler}.
+ *
+ * @returns an instance of {@link TreeModelHandler}
+ */
+ protected TreeModelListener createTreeModelListener()
+ {
+ return new TreeModelHandler();
+ }
+
+ /**
+ * Returns a sample TreeModel that can be used in a JTree. This can
+ * be used in Bean- or GUI-Builders to show something interesting.
+ *
+ * @return a sample TreeModel that can be used in a JTree
+ */
+ protected static TreeModel getDefaultTreeModel()
+ {
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root node");
+ DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("Child node 1");
+ DefaultMutableTreeNode child11 =
+ new DefaultMutableTreeNode("Child node 1.1");
+ DefaultMutableTreeNode child12 =
+ new DefaultMutableTreeNode("Child node 1.2");
+ DefaultMutableTreeNode child13 =
+ new DefaultMutableTreeNode("Child node 1.3");
+ DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("Child node 2");
+ DefaultMutableTreeNode child21 =
+ new DefaultMutableTreeNode("Child node 2.1");
+ DefaultMutableTreeNode child22 =
+ new DefaultMutableTreeNode("Child node 2.2");
+ DefaultMutableTreeNode child23 =
+ new DefaultMutableTreeNode("Child node 2.3");
+ DefaultMutableTreeNode child24 =
+ new DefaultMutableTreeNode("Child node 2.4");
+
+ DefaultMutableTreeNode child3 = new DefaultMutableTreeNode("Child node 3");
+ root.add(child1);
+ root.add(child2);
+ root.add(child3);
+ child1.add(child11);
+ child1.add(child12);
+ child1.add(child13);
+ child2.add(child21);
+ child2.add(child22);
+ child2.add(child23);
+ child2.add(child24);
+ return new DefaultTreeModel(root);
+ }
+
+ /**
+ * Converts the specified value to a String. This is used by the
+ * renderers of this JTree and its nodes.
+ *
+ * This implementation simply returns <code>value.toString()</code> and
+ * ignores all other parameters.
+ * Subclass this method to control the conversion.
+ *
+ * @param value the value that is converted to a String
+ * @param selected indicates if that value is selected or not
+ * @param expanded indicates if that value is expanded or not
+ * @param leaf indicates if that value is a leaf node or not
+ * @param row the row of the node
+ * @param hasFocus indicates if that node has focus or not
+ */
+ public String convertValueToText(Object value, boolean selected,
+ boolean expanded, boolean leaf, int row,
+ boolean hasFocus)
+ {
+ return value.toString();
+ }
+
+ /**
+ * A String representation of this JTree. This is intended to be used
+ * for debugging. The returned string may be empty but may not be
+ * <code>null</code>.
+ *
+ * @return a String representation of this JTree
+ */
+ public String paramString()
+ {
+ // TODO: this is completely legal, but it would possibly be nice
+ // to return some more content, like the tree structure, some properties
+ // etc ...
+ return "";
+ }
+
+ /**
+ * Returns all TreePath objects which are a descendants of
+ * the given path and are exapanded at the moment of the
+ * execution of this method. If the state of any node
+ * is beeing toggled while this method is executing this
+ * change may be left unaccounted.
+ *
+ * @param path The parent of this request
+ * @return An Enumeration containing TreePath objects
+ */
+ public Enumeration getExpandedDescendants(TreePath path)
+ {
+ Enumeration paths = nodeStates.keys();
+ Vector relevantPaths = new Vector();
+ while(paths.hasMoreElements())
+ {
+ TreePath nextPath = (TreePath) paths.nextElement();
+ if(nodeStates.get(nextPath) == EXPANDED &&
+ path.isDescendant(nextPath))
+ {
+ relevantPaths.add(nextPath);
+ }
+ }
+ return relevantPaths.elements();
+ }
}
diff --git a/javax/swing/MenuSelectionManager.java b/javax/swing/MenuSelectionManager.java
index f78e21467..f01d8b837 100644
--- a/javax/swing/MenuSelectionManager.java
+++ b/javax/swing/MenuSelectionManager.java
@@ -157,7 +157,7 @@ public class MenuSelectionManager
for (int i = 0; i < selectedPath.size(); i++)
{
Component comp = ((Component) selectedPath.get(i));
- Dimension size = comp.getSize();
+ Dimension size = comp.getSize();
// convert location of this menu item to screen coordinates
compPointOnScreen = comp.getLocationOnScreen();
@@ -277,6 +277,11 @@ public class MenuSelectionManager
}
*/
}
+ else
+ {
+ if (event.getID() == MouseEvent.MOUSE_RELEASED)
+ clearSelectedPath();
+ }
}
/**
diff --git a/javax/swing/RepaintManager.java b/javax/swing/RepaintManager.java
index 8a9d4c8e8..b6611bfdb 100644
--- a/javax/swing/RepaintManager.java
+++ b/javax/swing/RepaintManager.java
@@ -489,6 +489,31 @@ public class RepaintManager
}
/**
+ * Creates and returns a volatile offscreen buffer for the specified
+ * component that can be used as a double buffer. The returned image
+ * is a {@link VolatileImage}. Its size will be <code>(proposedWidth,
+ * proposedHeight)</code> except when the maximum double buffer size
+ * has been set in this RepaintManager.
+ *
+ * @param comp the Component for which to create a volatile buffer
+ * @param proposedWidth the proposed width of the buffer
+ * @param proposedHeight the proposed height of the buffer
+ *
+ * @since 1.4
+ *
+ * @see {@link VolatileImage}
+ */
+ public Image getVolatileOffscreenBuffer(Component comp, int proposedWidth,
+ int proposedHeight)
+ {
+ int maxWidth = doubleBufferMaximumSize.width;
+ int maxHeight = doubleBufferMaximumSize.height;
+ return comp.createVolatileImage(Math.min(maxWidth, proposedWidth),
+ Math.min(maxHeight, proposedHeight));
+ }
+
+
+ /**
* Get the value of the {@link #doubleBufferMaximumSize} property.
*
* @return The current value of the property
diff --git a/javax/swing/ScrollPaneLayout.java b/javax/swing/ScrollPaneLayout.java
index a0461b4d0..6fbb3048a 100644
--- a/javax/swing/ScrollPaneLayout.java
+++ b/javax/swing/ScrollPaneLayout.java
@@ -467,6 +467,15 @@ public class ScrollPaneLayout
}
}
+ /**
+ * Returns the bounds of the border around a ScrollPane's viewport.
+ *
+ * @param scrollPane the ScrollPane for which's viewport the border
+ * is requested
+ *
+ * @deprecated As of Swing 1.1 replaced by
+ * {@link javax.swing.JScrollPane#getViewportBorderBounds}.
+ */
public Rectangle getViewportBorderBounds(JScrollPane scrollPane) {
return null;
}
diff --git a/javax/swing/SizeRequirements.java b/javax/swing/SizeRequirements.java
index dd34d9cd9..414a5f011 100644
--- a/javax/swing/SizeRequirements.java
+++ b/javax/swing/SizeRequirements.java
@@ -1,5 +1,5 @@
/* SizeRequirements.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,137 +35,295 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package javax.swing;
import java.io.Serializable;
/**
- * SizeRequirements
- * @author Andrew Selkirk
- * @version 1.0
+ * This class calculates information about the size and position requirements
+ * of components.
+ *
+ * Two types of layout are supported:
+ * <ul>
+ * <li>Tiled: the components are placed at position top-left or bottom-right
+ * position within their allocated space</li>
+ * <li>Aligned: the components are placed aligned in their allocated space
+ * according to their alignment value</li>
+ * </ul>
+ *
+ * @author Andrew Selkirk
+ * @author Roman Kennke (roman@kennke.org)
*/
public class SizeRequirements implements Serializable
{
+ /**
+ * The serialVersionUID.
+ */
private static final long serialVersionUID = 9217749429906736553L;
- //-------------------------------------------------------------
- // Variables --------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * minimum
- */
- public int minimum;
-
- /**
- * preferred
- */
- public int preferred;
-
- /**
- * maximum
- */
- public int maximum;
-
- /**
- * alignment
- */
- public float alignment;
-
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor SizeRequirements
- */
- public SizeRequirements() {
- // TODO
- } // SizeRequirements()
-
- /**
- * Constructor SizeRequirements
- * @param min TODO
- * @param pref TODO
- * @param max TODO
- * @param align TODO
- */
- public SizeRequirements(int min, int pref, int max, float align) {
- // TODO
- } // SizeRequirements()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * toString
- * @returns String
- */
- public String toString() {
- return null; // TODO
- } // toString()
-
- /**
- * getTiledSizeRequirements
- * @param children TODO
- * @returns SizeRequirements
- */
- public static SizeRequirements getTiledSizeRequirements(
- SizeRequirements[] children) {
- return null; // TODO
- } // getTiledSizeRequirements()
-
- /**
- * getAlignedSizeRequirements
- * @param children TODO
- * @returns SizeRequirements
- */
- public static SizeRequirements getAlignedSizeRequirements(
- SizeRequirements[] children) {
- return null; // TODO
- } // getAlignedSizeRequirements()
-
- /**
- * calculateTiledPositions
- * @param allocated TODO
- * @param total TODO
- * @param children TODO
- * @param offset TODO
- * @param spans TODO
- */
- public static void calculateTiledPositions(int allocated,
- SizeRequirements total, SizeRequirements[] children,
- int[] offset, int[] spans) {
- // TODO
- } // calculateTiledPositions()
-
- /**
- * calculateAlignedPositions
- * @param allocated TODO
- * @param total TODO
- * @param children TODO
- * @param offset TODO
- * @param spans TODO
- */
- public static void calculateAlignedPositions(int allocated,
- SizeRequirements total, SizeRequirements[] children,
- int[] offset, int[] spans) {
- // TODO
- } // calculateAlignedPositions()
-
- /**
- * adjustSizes
- * @param delta TODO
- * @param children TODO
- * @returns int[]
- */
- public static int[] adjustSizes(int delta, SizeRequirements[] children) {
- return null; // TODO
- } // adjustSizes()
-
-
-} // SizeRequirements
+ /**
+ * The minimum reasonable width or height of a component.
+ */
+ public int minimum;
+
+ /**
+ * The preferred width or height of a component.
+ */
+ public int preferred;
+
+ /**
+ * The maximum reasonable width or height of a component.
+ */
+ public int maximum;
+
+ /**
+ * The horizontal or vertical alignment of a component.
+ */
+ public float alignment;
+
+ /**
+ * Creates a SizeRequirements object with minimum, preferred and
+ * maximum size set to zero, and an alignment value of 0.5.
+ */
+ public SizeRequirements()
+ {
+ this (0, 0, 0, 0.5F);
+ }
+
+ /**
+ * Creates a SizeRequirements object with the specified minimum,
+ * preferred, maximum and alignment values.
+ *
+ * @param min the minimum reasonable size of the component
+ * @param pref the preferred size of the component
+ * @param max the maximum size of the component
+ * @param align the alignment of the component
+ */
+ public SizeRequirements(int min, int pref, int max, float align)
+ {
+ minimum = min;
+ preferred = pref;
+ maximum = max;
+ alignment = align;
+ }
+
+ /**
+ * Returns a String representation of this SizeRequirements object,
+ * containing information about the minimum, preferred, maximum and
+ * alignment value.
+ *
+ * @return a String representation of this SizeRequirements object
+ */
+ public String toString()
+ {
+ return null; // TODO
+ }
+
+ /**
+ * Calculates how much space is nessecary to place a set of components
+ * end-to-end. The size requirements of the components is specified
+ * in <code>children</code>.
+ *
+ * @param children the SizeRequirements of each of the components
+ *
+ * @return the SizeRequirements that describe how much space is needed
+ * to place the components end-to-end
+ */
+ public static SizeRequirements
+ getTiledSizeRequirements(SizeRequirements[] children)
+ {
+ SizeRequirements result = new SizeRequirements();
+ for (int i = 0; i < children.length; i++)
+ {
+ result.minimum += children[i].minimum;
+ result.preferred += children[i].preferred;
+ result.maximum += children[i].maximum;
+ }
+ return result;
+ }
+
+ /**
+ * Calculates how much space is nessecary to place a set of components
+ * aligned according to their alignment value.
+ * The size requirements of the components is specified in
+ * <code>children</code>.
+ *
+ * @param children the SizeRequirements of each of the components
+ *
+ * @return the SizeRequirements that describe how much space is needed
+ * to place the components aligned
+ */
+ public static SizeRequirements
+ getAlignedSizeRequirements(SizeRequirements[] children)
+ {
+ return null; // TODO
+ }
+
+ /**
+ * Calculate the offsets and spans of the components, when they should
+ * be placed end-to-end.
+ *
+ * You must specify the amount of allocated space in
+ * <code>allocated</code>, the total size requirements of the set of
+ * components in <code>total</code> (this can be calculated using
+ * {@link #getTiledSizeRequirements} and the size requirements of the
+ * components in <code>children</code>.
+ *
+ * The calculated offset and span values for each component are then
+ * stored in the arrays <code>offsets</code> and <code>spans</code>.
+ *
+ * The components are placed in the forward direction, beginning with
+ * an offset of 0.
+ *
+ * @param allocated the amount of allocated space
+ * @param total the total size requirements of the components
+ * @param children the size requirement of each component
+ * @param offsets will hold the offset values for each component
+ * @param spans will hold the span values for each component
+ */
+ public static void calculateTiledPositions(int allocated,
+ SizeRequirements total,
+ SizeRequirements[] children,
+ int[] offsets, int[] spans)
+ {
+ calculateTiledPositions(allocated, total, children, offsets, spans, true);
+ }
+
+ /**
+ * Calculate the offsets and spans of the components, when they should
+ * be placed end-to-end.
+ *
+ * You must specify the amount of allocated space in
+ * <code>allocated</code>, the total size requirements of the set of
+ * components in <code>total</code> (this can be calculated using
+ * {@link #getTiledSizeRequirements} and the size requirements of the
+ * components in <code>children</code>.
+ *
+ * The calculated offset and span values for each component are then
+ * stored in the arrays <code>offsets</code> and <code>spans</code>.
+ *
+ * Depending on the value of <code>forward</code> the components are
+ * placed in the forward direction (left-right or top-bottom), where
+ * the offsets begin with 0, or in the reverse direction
+ * (right-left or bottom-top).
+ *
+ * @param allocated the amount of allocated space
+ * @param total the total size requirements of the components
+ * @param children the size requirement of each component
+ * @param offsets will hold the offset values for each component
+ * @param spans will hold the span values for each component
+ * @param forward whether the components should be placed in the forward
+ * direction (left-right or top-bottom) or reverse direction
+ * (right-left or bottom-top)
+ */
+ public static void calculateTiledPositions(int allocated,
+ SizeRequirements total,
+ SizeRequirements[] children,
+ int[] offsets, int[] spans,
+ boolean forward)
+ {
+ if (forward)
+ {
+ int offset = 0;
+ for (int i = 0; i < children.length; i++)
+ {
+ offsets[i] = offset;
+ spans[i] = children[i].preferred;
+ offset += children[i].preferred;
+ }
+ }
+ else
+ {
+ int offset = allocated;
+ for (int i = 0; i < children.length; i++)
+ {
+ offset -= children[i].preferred;
+ offsets[i] = offset;
+ spans[i] = children[i].preferred;
+ }
+ }
+ }
+
+ /**
+ * Calculate the offsets and spans of the components, when they should
+ * be placed end-to-end.
+ *
+ * You must specify the amount of allocated space in
+ * <code>allocated</code>, the total size requirements of the set of
+ * components in <code>total</code> (this can be calculated using
+ * {@link #getTiledSizeRequirements} and the size requirements of the
+ * components in <code>children</code>.
+ *
+ * The calculated offset and span values for each component are then
+ * stored in the arrays <code>offsets</code> and <code>spans</code>.
+ *
+ * The components are tiled in the forward direction, beginning with
+ * an offset of 0.
+ *
+ * @param allocated the amount of allocated space
+ * @param total the total size requirements of the components
+ * @param children the size requirement of each component
+ * @param offsets will hold the offset values for each component
+ * @param spans will hold the span values for each component
+ */
+ public static void calculateAlignedPositions(int allocated,
+ SizeRequirements total,
+ SizeRequirements[] children,
+ int[] offsets, int[] spans)
+ {
+ calculateTiledPositions(allocated, total, children, offsets, spans, true);
+ }
+
+ /**
+ * Calculate the offsets and spans of the components, when they should
+ * be placed end-to-end.
+ *
+ * You must specify the amount of allocated space in
+ * <code>allocated</code>, the total size requirements of the set of
+ * components in <code>total</code> (this can be calculated using
+ * {@link #getTiledSizeRequirements} and the size requirements of the
+ * components in <code>children</code>.
+ *
+ * The calculated offset and span values for each component are then
+ * stored in the arrays <code>offsets</code> and <code>spans</code>.
+ *
+ * Depending on the value of <code>forward</code> the components are
+ * placed in the forward direction (left-right or top-bottom), where
+ * the offsets begin with 0, or in the reverse direction
+ * (right-left or bottom-top).
+ *
+ * @param allocated the amount of allocated space
+ * @param total the total size requirements of the components
+ * @param children the size requirement of each component
+ * @param offsets will hold the offset values for each component
+ * @param spans will hold the span values for each component
+ * @param forward whether the components should be placed in the forward
+ * direction (left-right or top-bottom) or reverse direction
+ * (right-left or bottom-top)
+ */
+ public static void calculateAlignedPositions(int allocated,
+ SizeRequirements total,
+ SizeRequirements[] children,
+ int[] offset, int[] spans,
+ boolean forward)
+ {
+ // TODO
+ }
+
+ /**
+ * Returns an array of new preferred sizes for the children based on
+ * <code>delta</code>. <code>delta</code> specifies a change in the
+ * allocated space. The sizes of the children will be shortened or
+ * lengthened to accomodate the new allocation.
+ *
+ * @param delta the change of the size of the total allocation for
+ * the components
+ * @param children the size requirements of each component
+ *
+ * @return the new preferred sizes for each component
+ */
+ public static int[] adjustSizes(int delta, SizeRequirements[] children)
+ {
+ return null; // TODO
+ }
+}
diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java
index 8e987425f..2507c9111 100644
--- a/javax/swing/SwingUtilities.java
+++ b/javax/swing/SwingUtilities.java
@@ -1319,4 +1319,45 @@ public class SwingUtilities
&& b.x >= a.x && b.x + b.width <= a.x + a.width && b.y >= a.y
&& b.y + b.height <= a.y + a.height;
}
+
+ /**
+ * Returns the InputMap that is provided by the ComponentUI of
+ * <code>component</code> for the specified condition.
+ *
+ * @param component the component for which the InputMap is returned
+ * @param cond the condition that specifies which of the three input
+ * maps should be returned, may be
+ * {@link JComponent#WHEN_IN_FOCUSED_WINDOW},
+ * {@link JComponent#WHEN_FOCUSED} or
+ * {@link JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
+ *
+ * @return
+ */
+ public static InputMap getUIInputMap(JComponent component, int cond)
+ {
+ if (UIManager.getUI(component) != null)
+ // we assume here that the UI class sets the parent of the component's
+ // InputMap, which is the correct behaviour. If it's not, then
+ // this can be considered a bug
+ return component.getInputMap(cond).getParent();
+ else
+ return null;
+ }
+
+ /**
+ * Returns the ActionMap that is provided by the ComponentUI of
+ * <code>component</code>.
+ *
+ * @param component the component for which the ActionMap is returned
+ */
+ public static ActionMap getUIActionMap(JComponent component)
+ {
+ if (UIManager.getUI(component) != null)
+ // we assume here that the UI class sets the parent of the component's
+ // ActionMap, which is the correct behaviour. If it's not, then
+ // this can be considered a bug
+ return component.getActionMap().getParent();
+ else
+ return null;
+ }
}
diff --git a/javax/swing/UIManager.java b/javax/swing/UIManager.java
index 26fe4790a..056e944be 100644
--- a/javax/swing/UIManager.java
+++ b/javax/swing/UIManager.java
@@ -72,6 +72,23 @@ public class UIManager implements Serializable
{
return clazz;
}
+
+ /**
+ * Returns a String representation of the LookAndFeelInfo object.
+ *
+ * @return a String representation of the LookAndFeelInfo object
+ */
+ public String toString()
+ {
+ StringBuffer s = new StringBuffer();
+ s.append(getClass().getName());
+ s.append('[');
+ s.append(getName());
+ s.append(' ');
+ s.append(getClassName());
+ s.append(']');
+ return s.toString();
+ }
}
private static final long serialVersionUID = -5547433830339189365L;
diff --git a/javax/swing/filechooser/FileSystemView.java b/javax/swing/filechooser/FileSystemView.java
index f224349a5..6be4773aa 100644
--- a/javax/swing/filechooser/FileSystemView.java
+++ b/javax/swing/filechooser/FileSystemView.java
@@ -1,5 +1,5 @@
/* FileSystemView.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,116 +35,327 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
package javax.swing.filechooser;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import javax.swing.Icon;
+
/**
- * FileSystemView
- * @author Andrew Selkirk
- * @version 1.0
+ * DOCUMENT ME!
*/
-public abstract class FileSystemView {
-
- //-------------------------------------------------------------
- // Initialization ---------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * Constructor FileSystemView
- */
- public FileSystemView() {
- // TODO
- } // FileSystemView()
-
-
- //-------------------------------------------------------------
- // Methods ----------------------------------------------------
- //-------------------------------------------------------------
-
- /**
- * getFileSystemView
- * @returns FileSystemView
- */
- public static FileSystemView getFileSystemView() {
- return null; // TODO
- } // getFileSystemView()
-
- /**
- * isRoot
- * @param file TODO
- * @returns boolean
- */
- public abstract boolean isRoot(File file);
-
- /**
- * createNewFolder
- * @param file TODO
- * @exception IOException TODO
- * @returns File
- */
- public abstract File createNewFolder(File file) throws IOException;
-
- /**
- * isHiddenFile
- * @param file TODO
- * @returns boolean
- */
- public abstract boolean isHiddenFile(File file);
-
- /**
- * getRoots
- * @returns File[]
- */
- public abstract File[] getRoots();
-
- /**
- * getHomeDirectory
- * @returns File
- */
- public File getHomeDirectory() {
- return null; // TODO
- } // getHomeDirectory()
-
- /**
- * createFileObject
- * @param directory TODO
- * @param filename TODO
- * @returns File
- */
- public File createFileObject(File directory, String filename) {
- return null; // TODO
- } // createFileObject()
-
- /**
- * createFileObject
- * @param path TODO
- * @returns File
- */
- public File createFileObject(String path) {
- return null; // TODO
- } // createFileObject()
-
- /**
- * getFiles
- * @param directory TODO
- * @param fileHiding TODO
- * @returns File[]
- */
- public File[] getFiles(File directory, boolean fileHiding) {
- return null; // TODO
- } // getFiles()
-
- /**
- * getParentDirectory
- * @param directory TODO
- * @returns File
- */
- public File getParentDirectory(File directory) {
- return null; // TODO
- } // getParentDirectory()
-
-
-} // FileSystemView
+public abstract class FileSystemView
+{
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dir DOCUMENT ME!
+ * @param filename DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File createFileObject(File dir, String filename)
+ {
+ return new File(dir, filename);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param path DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File createFileObject(String path)
+ {
+ return new File(path);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected File createFileSystemRoot(File f)
+ {
+ File[] roots = File.listRoots();
+ if (roots == null)
+ return null;
+ return roots[0];
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param containingDir DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ *
+ * @throws IOException DOCUMENT ME!
+ */
+ public abstract File createNewFolder(File containingDir)
+ throws IOException;
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param parent DOCUMENT ME!
+ * @param fileName DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File getChild(File parent, String fileName)
+ {
+ // FIXME: Handle the case when parent and child are special folders.
+ return new File(parent, fileName);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File getDefaultDirectory()
+ {
+ return getHomeDirectory();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dir DOCUMENT ME!
+ * @param useFileHiding DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File[] getFiles(File dir, boolean useFileHiding)
+ {
+ if (dir == null)
+ return null;
+ File[] files = dir.listFiles();
+ if (! useFileHiding)
+ return files;
+ ArrayList trim = new ArrayList();
+ for (int i = 0; i < files.length; i++)
+ if (! files[i].isHidden())
+ trim.add(files[i]);
+ File[] value = (File[]) trim.toArray(new File[0]);
+ return value;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public static FileSystemView getFileSystemView()
+ {
+ if (File.separator.equals("/"))
+ return new UnixFileSystemView();
+
+ // else if (File.Separator.equals("\"))
+ // return new Win32FileSystemView();
+ // else
+ // return new GenericFileSystemView();
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File getHomeDirectory()
+ {
+ return createFileObject(System.getProperty("user.home"));
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File getParentDirectory(File f)
+ {
+ if (f == null)
+ return null;
+ return f.getParentFile();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File[] getRoots()
+ {
+ // subclass
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getSystemDisplayName(File f)
+ {
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Icon getSystemIcon(File f)
+ {
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getSystemTypeDescription(File f)
+ {
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dir DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isComputerNode(File dir)
+ {
+ return false;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dir DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isDrive(File dir)
+ {
+ return false;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isFileSystem(File f)
+ {
+ return (f.isFile() || f.isDirectory());
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dir DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isFileSystemRoot(File dir)
+ {
+ File[] roots = File.listRoots();
+ if (roots == null || dir == null)
+ return false;
+ String filename = dir.getAbsolutePath();
+ for (int i = 0; i < roots.length; i++)
+ if (roots[i].getAbsolutePath().equals(filename))
+ return true;
+ return false;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dir DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isFloppyDrive(File dir)
+ {
+ return false;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isHiddenFile(File f)
+ {
+ return f.isHidden();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param folder DOCUMENT ME!
+ * @param file DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isParent(File folder, File file)
+ {
+ File parent = file.getParentFile();
+ if (parent == null)
+ return false;
+ return folder.equals(parent);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isRoot(File f)
+ {
+ // These are not file system roots.
+ return false;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Boolean isTraversable(File f)
+ {
+ // Tested. A directory where the user has no permission to rwx is still
+ // traversable. (No files are listed when you traverse the directory)
+ // My best guess is that as long as it's a directory, the file is
+ // traversable.
+ return new Boolean(f.isDirectory());
+ }
+}
diff --git a/javax/swing/filechooser/UnixFileSystemView.java b/javax/swing/filechooser/UnixFileSystemView.java
new file mode 100644
index 000000000..ccf054305
--- /dev/null
+++ b/javax/swing/filechooser/UnixFileSystemView.java
@@ -0,0 +1,144 @@
+/* UnixFileSystemView.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.filechooser;
+
+import java.io.File;
+import java.io.IOException;
+import javax.swing.Icon;
+
+
+/**
+ * DOCUMENT ME!
+ */
+class UnixFileSystemView extends FileSystemView
+{
+ /** DOCUMENT ME! */
+ private static final String NEW_FOLDER_NAME = "NewFolder";
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param containingDir DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ *
+ * @throws IOException DOCUMENT ME!
+ */
+ public File createNewFolder(File containingDir) throws IOException
+ {
+ int count = 0;
+ File f = null;
+ String filename = containingDir.getAbsolutePath() + File.separator
+ + NEW_FOLDER_NAME;
+ while (f == null)
+ {
+ String full = filename;
+ if (count > 0)
+ full += "." + (count++);
+ f = new File(full);
+ if (f.isDirectory() || f.isFile())
+ {
+ count++;
+ f = null;
+ }
+ }
+ f.mkdir();
+ return f;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public File[] getRoots()
+ {
+ return File.listRoots();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getSystemDisplayName(File f)
+ {
+ // FIXME: Implement;
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Icon getSystemIcon(File f)
+ {
+ // FIXME: Implement;
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getSystemTypeDescription(File f)
+ {
+ // FIXME: Implement.
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean isRoot(File f)
+ {
+ return isFileSystemRoot(f);
+ }
+}
diff --git a/javax/swing/plaf/basic/BasicComboBoxUI.java b/javax/swing/plaf/basic/BasicComboBoxUI.java
index 21998868b..572902ec3 100644
--- a/javax/swing/plaf/basic/BasicComboBoxUI.java
+++ b/javax/swing/plaf/basic/BasicComboBoxUI.java
@@ -1111,7 +1111,7 @@ public class BasicComboBoxUI extends ComboBoxUI
if (largestItemSize == null)
largestItemSize = new Dimension(0, 0);
- for (int i = start - 1; i < end; i++)
+ for (int i = start; i < end; i++)
{
Object item = model.getElementAt(i);
Component comp = renderer.getListCellRendererComponent(new JList(),
diff --git a/javax/swing/plaf/basic/BasicDirectoryModel.java b/javax/swing/plaf/basic/BasicDirectoryModel.java
new file mode 100644
index 000000000..f83887e69
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicDirectoryModel.java
@@ -0,0 +1,313 @@
+/* BasicDirectoryModel.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.basic;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.Vector;
+import javax.swing.AbstractListModel;
+import javax.swing.JFileChooser;
+import javax.swing.event.ListDataEvent;
+import javax.swing.filechooser.FileSystemView;
+
+
+/**
+ * DOCUMENT ME!
+ */
+public class BasicDirectoryModel extends AbstractListModel
+ implements PropertyChangeListener
+{
+ /** DOCUMENT ME! */
+ private Vector contents;
+
+ /** DOCUMENT ME! */
+ private int directories;
+
+ /** DOCUMENT ME! */
+ private int listingMode;
+
+ /** DOCUMENT ME! */
+ private JFileChooser filechooser;
+
+ /** DOCUMENT ME! */
+ private Comparator comparator = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ if (lt((File) o1, (File) o2))
+ return -1;
+ else
+ return 1;
+ }
+ };
+
+ /**
+ * Creates a new BasicDirectoryModel object.
+ *
+ * @param filechooser DOCUMENT ME!
+ */
+ public BasicDirectoryModel(JFileChooser filechooser)
+ {
+ this.filechooser = filechooser;
+ filechooser.addPropertyChangeListener(this);
+ listingMode = filechooser.getFileSelectionMode();
+ contents = new Vector();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param o DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean contains(Object o)
+ {
+ return contents.contains(o);
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void fireContentsChanged()
+ {
+ fireContentsChanged(this, 0, getSize() - 1);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Vector getDirectories()
+ {
+ Vector tmp = new Vector();
+ for (int i = 0; i < directories; i++)
+ tmp.add(contents.get(i));
+ return tmp;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param index DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Object getElementAt(int index)
+ {
+ if (index > getSize() - 1)
+ return null;
+ if (listingMode == JFileChooser.FILES_ONLY)
+ return contents.get(directories + index);
+ else
+ return contents.elementAt(index);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Vector getFiles()
+ {
+ Vector tmp = new Vector();
+ for (int i = directories; i < getSize(); i++)
+ tmp.add(contents.get(i));
+ return tmp;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public int getSize()
+ {
+ if (listingMode == JFileChooser.DIRECTORIES_ONLY)
+ return directories;
+ else if (listingMode == JFileChooser.FILES_ONLY)
+ return contents.size() - directories;
+ return contents.size();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param o DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public int indexOf(Object o)
+ {
+ if (listingMode == JFileChooser.FILES_ONLY)
+ return contents.indexOf(o) - directories;
+ return contents.indexOf(o);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void intervalAdded(ListDataEvent e)
+ {
+ // obsoleted
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void intervalRemoved(ListDataEvent e)
+ {
+ // obsoleted
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void invalidateFileCache()
+ {
+ // obsoleted
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param a DOCUMENT ME!
+ * @param b DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected boolean lt(File a, File b)
+ {
+ boolean aTrav = filechooser.isTraversable(a);
+ boolean bTrav = filechooser.isTraversable(b);
+
+ if (aTrav == bTrav)
+ {
+ String aname = a.getName().toLowerCase();
+ String bname = b.getName().toLowerCase();
+ return ((aname.compareTo(bname) < 0) ? true : false);
+ }
+ else
+ {
+ if (aTrav)
+ return true;
+ else
+ return false;
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ if (e.getPropertyName().equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY))
+ listingMode = filechooser.getFileSelectionMode();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param oldFile DOCUMENT ME!
+ * @param newFile DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean renameFile(File oldFile, File newFile)
+ {
+ // FIXME: implement
+ return false;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param v DOCUMENT ME!
+ */
+ protected void sort(Vector v)
+ {
+ Collections.sort(v, comparator);
+ Enumeration e = Collections.enumeration(v);
+ Vector tmp = new Vector();
+ for (; e.hasMoreElements();)
+ tmp.add(e.nextElement());
+
+ contents = tmp;
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void validateFileCache()
+ {
+ contents.clear();
+ directories = 0;
+ FileSystemView fsv = filechooser.getFileSystemView();
+ File[] list = fsv.getFiles(filechooser.getCurrentDirectory(),
+ filechooser.isFileHidingEnabled());
+
+ if (list == null)
+ return;
+
+ for (int i = 0; i < list.length; i++)
+ {
+ if (list[i] == null)
+ continue;
+ if (filechooser.accept(list[i]))
+ {
+ contents.add(list[i]);
+ if (filechooser.isTraversable(list[i]))
+ directories++;
+ }
+ }
+ sort(contents);
+ filechooser.revalidate();
+ filechooser.repaint();
+ }
+}
diff --git a/javax/swing/plaf/basic/BasicFileChooserUI.java b/javax/swing/plaf/basic/BasicFileChooserUI.java
new file mode 100644
index 000000000..517d4ecec
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -0,0 +1,1929 @@
+/* BasicFileChooserUI.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.basic;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Point;
+import java.awt.Polygon;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.BoxLayout;
+import javax.swing.ButtonGroup;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.JToggleButton;
+import javax.swing.ListCellRenderer;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileSystemView;
+import javax.swing.filechooser.FileView;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.FileChooserUI;
+
+
+/**
+ * DOCUMENT ME!
+ */
+public class BasicFileChooserUI extends FileChooserUI
+{
+ /**
+ * DOCUMENT ME!
+ */
+ protected class AcceptAllFileFilter extends FileFilter
+ {
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public boolean accept(File f)
+ {
+ return true;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getDescription()
+ {
+ return acceptAllFileFilterText;
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected class ApproveSelectionAction extends AbstractAction
+ {
+ /**
+ * Creates a new ApproveSelectionAction object.
+ */
+ protected ApproveSelectionAction()
+ {
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ Object obj = filelist.getSelectedValue();
+ if (obj != null)
+ {
+ File f = filechooser.getFileSystemView().createFileObject(obj
+ .toString());
+ if (filechooser.isTraversable(f))
+ filechooser.setCurrentDirectory(f);
+ else
+ {
+ filechooser.setSelectedFile(f);
+ filechooser.approveSelection();
+ closeDialog();
+ }
+ }
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected class BasicFileView extends FileView
+ {
+ /** DOCUMENT ME! */
+ protected Hashtable iconCache = new Hashtable();
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ * @param i DOCUMENT ME!
+ */
+ public void cacheIcon(File f, Icon i)
+ {
+ iconCache.put(f, i);
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void clearIconCache()
+ {
+ iconCache.clear();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Icon getCachedIcon(File f)
+ {
+ return (Icon) iconCache.get(f);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getDescription(File f)
+ {
+ return getName(f);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Icon getIcon(File f)
+ {
+ Icon val = getCachedIcon(f);
+ if (val != null)
+ return val;
+ if (filechooser.isTraversable(f))
+ val = directoryIcon;
+ else
+ val = fileIcon;
+ cacheIcon(f, val);
+ return val;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getName(File f)
+ {
+ return f.getName();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getTypeDescription(File f)
+ {
+ if (filechooser.isTraversable(f))
+ return dirDescText;
+ else
+ return fileDescText;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Boolean isHidden(File f)
+ {
+ return new Boolean(filechooser.getFileSystemView().isHiddenFile(f));
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected class CancelSelectionAction extends AbstractAction
+ {
+ /**
+ * Creates a new CancelSelectionAction object.
+ */
+ protected CancelSelectionAction()
+ {
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ filechooser.cancelSelection();
+ closeDialog();
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected class ChangeToParentDirectoryAction extends AbstractAction
+ {
+ /**
+ * Creates a new ChangeToParentDirectoryAction object.
+ */
+ protected ChangeToParentDirectoryAction()
+ {
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ filechooser.changeToParentDirectory();
+ filechooser.revalidate();
+ filechooser.repaint();
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected class DoubleClickListener extends MouseAdapter
+ {
+ /** DOCUMENT ME! */
+ private Timer timer = null;
+
+ /** DOCUMENT ME! */
+ private Object lastSelected = null;
+
+ /** DOCUMENT ME! */
+ private JList list = null;
+
+ /**
+ * Creates a new DoubleClickListener object.
+ *
+ * @param list DOCUMENT ME!
+ */
+ public DoubleClickListener(JList list)
+ {
+ this.list = list;
+ timer = new Timer(1000, null);
+ timer.setRepeats(false);
+ lastSelected = list.getSelectedValue();
+ setDirectorySelected(false);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void mouseClicked(MouseEvent e)
+ {
+ if (list.getSelectedValue() == null)
+ return;
+ FileSystemView fsv = filechooser.getFileSystemView();
+ if (timer.isRunning()
+ && list.getSelectedValue().toString().equals(lastSelected.toString()))
+ {
+ File f = fsv.createFileObject(lastSelected.toString());
+ timer.stop();
+ if (filechooser.isTraversable(f))
+ {
+ filechooser.setCurrentDirectory(f);
+ filechooser.rescanCurrentDirectory();
+ }
+ else
+ {
+ filechooser.setSelectedFile(f);
+ filechooser.approveSelection();
+ closeDialog();
+ }
+ }
+ else
+ {
+ File f = fsv.createFileObject(list.getSelectedValue().toString());
+ if (filechooser.isTraversable(f))
+ {
+ setDirectorySelected(true);
+ setDirectory(f);
+ }
+ else
+ {
+ setDirectorySelected(false);
+ setDirectory(null);
+ }
+ lastSelected = list.getSelectedValue().toString();
+ timer.restart();
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void mouseEntered(MouseEvent e)
+ {
+ // FIXME: Implement
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected class GoHomeAction extends AbstractAction
+ {
+ /**
+ * Creates a new GoHomeAction object.
+ */
+ protected GoHomeAction()
+ {
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ filechooser.setCurrentDirectory(filechooser.getFileSystemView()
+ .getHomeDirectory());
+ filechooser.revalidate();
+ filechooser.repaint();
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected class NewFolderAction extends AbstractAction
+ {
+ /**
+ * Creates a new NewFolderAction object.
+ */
+ protected NewFolderAction()
+ {
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ filechooser.getFileSystemView().createNewFolder(filechooser
+ .getCurrentDirectory());
+ }
+ catch (IOException ioe)
+ {
+ return;
+ }
+ filechooser.rescanCurrentDirectory();
+ filechooser.repaint();
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected class SelectionListener implements ListSelectionListener
+ {
+ /**
+ * Creates a new SelectionListener object.
+ */
+ protected SelectionListener()
+ {
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void valueChanged(ListSelectionEvent e)
+ {
+ Object f = filelist.getSelectedValue();
+ if (f == null)
+ return;
+ File file = filechooser.getFileSystemView().createFileObject(f.toString());
+ if (! filechooser.isTraversable(file))
+ filechooser.setSelectedFile(file);
+ else
+ filechooser.setSelectedFile(null);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected class UpdateAction extends AbstractAction
+ {
+ /**
+ * Creates a new UpdateAction object.
+ */
+ protected UpdateAction()
+ {
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param e DOCUMENT ME!
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ }
+ }
+
+ /** DOCUMENT ME! */
+ protected int cancelButtonMnemonic;
+
+ /** DOCUMENT ME! */
+ protected String cancelButtonText;
+
+ /** DOCUMENT ME! */
+ protected String cancelButtonToolTipText;
+
+ /** DOCUMENT ME! */
+ protected Icon computerIcon = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ }
+ };
+
+ /** DOCUMENT ME! */
+ protected Icon detailsViewIcon = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.translate(x, y);
+
+ g.setColor(Color.GRAY);
+ g.drawRect(1, 1, 15, 20);
+ g.drawLine(17, 6, 23, 6);
+ g.drawLine(17, 12, 23, 12);
+ g.drawLine(17, 18, 23, 18);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ };
+
+ /** DOCUMENT ME! */
+ protected Icon directoryIcon = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.translate(x, y);
+
+ Point ap = new Point(3, 7);
+ Point bp = new Point(3, 21);
+ Point cp = new Point(21, 21);
+ Point dp = new Point(21, 12);
+ Point ep = new Point(16, 12);
+ Point fp = new Point(13, 7);
+
+ Polygon dir = new Polygon(new int[] { ap.x, bp.x, cp.x, dp.x, ep.x, fp.x },
+ new int[] { ap.y, bp.y, cp.y, dp.y, ep.y, fp.y },
+ 6);
+
+ g.setColor(new Color(153, 204, 255));
+ g.fillPolygon(dir);
+ g.setColor(Color.BLACK);
+ g.drawPolygon(dir);
+
+ g.translate(-x, -y);
+ g.setColor(saved);
+ }
+ };
+
+ /** DOCUMENT ME! */
+ protected int directoryOpenButtonMnemonic;
+
+ /** DOCUMENT ME! */
+ protected String directoryOpenButtonText;
+
+ /** DOCUMENT ME! */
+ protected String directoryOpenButtonToolTipText;
+
+ /** DOCUMENT ME! */
+ protected Icon fileIcon = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.translate(x, y);
+
+ Point a = new Point(5, 4);
+ Point b = new Point(5, 20);
+ Point d = new Point(19, 20);
+ Point e = new Point(19, 7);
+ Point f = new Point(16, 4);
+
+ Polygon p = new Polygon(new int[] { a.x, b.x, d.x, e.x, f.x, },
+ new int[] { a.y, b.y, d.y, e.y, f.y }, 5);
+
+ g.setColor(Color.WHITE);
+ g.fillPolygon(p);
+ g.setColor(Color.BLACK);
+ g.drawPolygon(p);
+
+ g.drawLine(16, 4, 14, 6);
+ g.drawLine(14, 6, 19, 7);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ };
+
+ /** DOCUMENT ME! */
+ protected Icon floppyDriveIcon = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ }
+ };
+
+ /** DOCUMENT ME! */
+ protected Icon hardDriveIcon = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ }
+ };
+
+ /** DOCUMENT ME! */
+ protected int helpButtonMnemonic;
+
+ /** DOCUMENT ME! */
+ protected String helpButtonText;
+
+ /** DOCUMENT ME! */
+ protected String helpButtonToolTipText;
+
+ /** DOCUMENT ME! */
+ protected Icon homeFolderIcon = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.translate(x, y);
+
+ Point a = new Point(12, 3);
+ Point b = new Point(4, 10);
+ Point d = new Point(20, 10);
+
+ Polygon p = new Polygon(new int[] { a.x, b.x, d.x },
+ new int[] { a.y, b.y, d.y }, 3);
+
+ g.setColor(new Color(104, 51, 0));
+ g.fillPolygon(p);
+ g.setColor(Color.BLACK);
+ g.drawPolygon(p);
+
+ g.setColor(Color.WHITE);
+ g.fillRect(8, 10, 8, 10);
+ g.setColor(Color.BLACK);
+ g.drawRect(8, 10, 8, 10);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ };
+
+ /** DOCUMENT ME! */
+ protected Icon listViewIcon = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ // Not needed. Only simplifies things until we get real icons.
+ private void paintPartial(Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.translate(x, y);
+
+ g.setColor(Color.GRAY);
+ g.drawRect(1, 1, 7, 10);
+ g.drawLine(8, 6, 11, 6);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.translate(x, y);
+
+ paintPartial(g, 0, 0);
+ paintPartial(g, 12, 0);
+ paintPartial(g, 0, 12);
+ paintPartial(g, 12, 12);
+
+ g.setColor(saved);
+ g.translate(-x, -y);
+ }
+ };
+
+ /** DOCUMENT ME! */
+ protected Icon newFolderIcon = directoryIcon;
+
+ /** DOCUMENT ME! */
+ protected int openButtonMnemonic;
+
+ /** DOCUMENT ME! */
+ protected String openButtonText;
+
+ /** DOCUMENT ME! */
+ protected String openButtonToolTipText;
+
+ /** DOCUMENT ME! */
+ protected int saveButtonMnemonic;
+
+ /** DOCUMENT ME! */
+ protected String saveButtonText;
+
+ /** DOCUMENT ME! */
+ protected String saveButtonToolTipText;
+
+ /** DOCUMENT ME! */
+ protected int updateButtonMnemonic;
+
+ /** DOCUMENT ME! */
+ protected String updateButtonText;
+
+ /** DOCUMENT ME! */
+ protected String updateButtonToolTipText;
+
+ /** DOCUMENT ME! */
+ protected Icon upFolderIcon = new Icon()
+ {
+ public int getIconHeight()
+ {
+ return ICON_SIZE;
+ }
+
+ public int getIconWidth()
+ {
+ return ICON_SIZE;
+ }
+
+ public void paintIcon(Component comp, Graphics g, int x, int y)
+ {
+ Color saved = g.getColor();
+ g.translate(x, y);
+
+ Point a = new Point(3, 7);
+ Point b = new Point(3, 21);
+ Point c = new Point(21, 21);
+ Point d = new Point(21, 12);
+ Point e = new Point(16, 12);
+ Point f = new Point(13, 7);
+
+ Polygon dir = new Polygon(new int[] { a.x, b.x, c.x, d.x, e.x, f.x },
+ new int[] { a.y, b.y, c.y, d.y, e.y, f.y }, 6);
+
+ g.setColor(new Color(153, 204, 255));
+ g.fillPolygon(dir);
+ g.setColor(Color.BLACK);
+ g.drawPolygon(dir);
+
+ a = new Point(12, 15);
+ b = new Point(9, 18);
+ c = new Point(15, 18);
+
+ Polygon arrow = new Polygon(new int[] { a.x, b.x, c.x },
+ new int[] { a.y, b.y, c.y }, 3);
+
+ g.fillPolygon(arrow);
+
+ g.drawLine(12, 15, 12, 22);
+
+ g.translate(-x, -y);
+ g.setColor(saved);
+ }
+ };
+
+ // -- begin private --
+
+ /** DOCUMENT ME! */
+ private JFileChooser filechooser;
+
+ /** DOCUMENT ME! */
+ private JList filelist;
+
+ /** DOCUMENT ME! */
+ private JComboBox filters;
+
+ /** DOCUMENT ME! */
+ private BasicDirectoryModel model;
+
+ /** DOCUMENT ME! */
+ private FileFilter acceptAll = new AcceptAllFileFilter();
+
+ /** DOCUMENT ME! */
+ private FileView fv = new BasicFileView();
+
+ /** DOCUMENT ME! */
+ private static final int ICON_SIZE = 24;
+
+ /** DOCUMENT ME! */
+ private JComboBox parents;
+
+ /** DOCUMENT ME! */
+ private String filename;
+
+ /** DOCUMENT ME! */
+ private JButton accept;
+
+ /** DOCUMENT ME! */
+ private JButton cancel;
+
+ /** DOCUMENT ME! */
+ private JButton upFolderButton;
+
+ /** DOCUMENT ME! */
+ private JButton newFolderButton;
+
+ /** DOCUMENT ME! */
+ private JButton homeFolderButton;
+
+ /** DOCUMENT ME! */
+ private JPanel accessoryPanel;
+
+ /** DOCUMENT ME! */
+ private PropertyChangeListener propertyChangeListener;
+
+ /** DOCUMENT ME! */
+ private String acceptAllFileFilterText;
+
+ /** DOCUMENT ME! */
+ private String dirDescText;
+
+ /** DOCUMENT ME! */
+ private String fileDescText;
+
+ /** DOCUMENT ME! */
+ private boolean dirSelected = false;
+
+ /** DOCUMENT ME! */
+ private File currDir = null;
+
+ /** DOCUMENT ME! */
+ private JPanel bottomPanel;
+
+ /** DOCUMENT ME! */
+ private JPanel closePanel;
+
+ // -- end private --
+ private class ListLabelRenderer
+ extends JLabel
+ implements ListCellRenderer
+ {
+ /** DOCUMENT ME! */
+ final Color selected = new Color(153, 204, 255);
+
+ /**
+ * Creates a new ListLabelRenderer object.
+ */
+ public ListLabelRenderer()
+ {
+ super();
+ setOpaque(true);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param list DOCUMENT ME!
+ * @param value DOCUMENT ME!
+ * @param index DOCUMENT ME!
+ * @param isSelected DOCUMENT ME!
+ * @param cellHasFocus DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Component getListCellRendererComponent(JList list, Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
+ {
+ setHorizontalAlignment(SwingConstants.LEFT);
+ File file = (File) value;
+ setText(filechooser.getName(file));
+ setIcon(filechooser.getIcon(file));
+ setBackground(isSelected ? selected : Color.WHITE);
+ setForeground(Color.BLACK);
+
+ return this;
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public class CBLabelRenderer extends JLabel implements ListCellRenderer
+ {
+ /**
+ * Creates a new CBLabelRenderer object.
+ */
+ public CBLabelRenderer()
+ {
+ super();
+ setOpaque(true);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param list DOCUMENT ME!
+ * @param value DOCUMENT ME!
+ * @param index DOCUMENT ME!
+ * @param isSelected DOCUMENT ME!
+ * @param cellHasFocus DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Component getListCellRendererComponent(JList list, Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
+ {
+ setHorizontalAlignment(SwingConstants.LEFT);
+ setIcon(directoryIcon);
+ setText(value.toString());
+ setForeground(Color.BLACK);
+ setBackground(Color.WHITE);
+
+ return this;
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ private void closeDialog()
+ {
+ Window owner = SwingUtilities.windowForComponent(filechooser);
+ if (owner instanceof JDialog)
+ ((JDialog) owner).dispose();
+ }
+
+ /**
+ * Creates a new BasicFileChooserUI object.
+ *
+ * @param b DOCUMENT ME!
+ */
+ public BasicFileChooserUI(JFileChooser b)
+ {
+ this.filechooser = b;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param c DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new BasicFileChooserUI((JFileChooser) c);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param c DOCUMENT ME!
+ */
+ public void installUI(JComponent c)
+ {
+ if (c instanceof JFileChooser)
+ {
+ JFileChooser fc = (JFileChooser) c;
+ fc.resetChoosableFileFilters();
+ createModel();
+ clearIconCache();
+ installDefaults(fc);
+ installComponents(fc);
+ installListeners(fc);
+ }
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param c DOCUMENT ME!
+ */
+ public void uninstallUI(JComponent c)
+ {
+ model = null;
+ uninstallListeners(filechooser);
+ uninstallComponents(filechooser);
+ uninstallDefaults(filechooser);
+ filechooser = null;
+ }
+
+ // FIXME: Indent the entries in the combobox
+ private void boxEntries()
+ {
+ ArrayList parentFiles = new ArrayList();
+ File parent = filechooser.getCurrentDirectory();
+ if (parent == null)
+ parent = filechooser.getFileSystemView().getDefaultDirectory();
+ while (parent != null)
+ {
+ String name = parent.getName();
+ if (name.equals(""))
+ name = parent.getAbsolutePath();
+
+ parentFiles.add(parentFiles.size(), name);
+ parent = parent.getParentFile();
+ }
+
+ if (parentFiles.size() == 0)
+ return;
+
+ if (parents.getItemCount() > 0)
+ parents.removeAllItems();
+ for (int i = parentFiles.size() - 1; i >= 0; i--)
+ parents.addItem(parentFiles.get(i));
+ parents.setSelectedIndex(parentFiles.size() - 1);
+ parents.revalidate();
+ parents.repaint();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ private ItemListener createBoxListener()
+ {
+ return new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent e)
+ {
+ if (parents.getItemCount() - 1 == parents.getSelectedIndex())
+ return;
+ StringBuffer dir = new StringBuffer();
+ for (int i = 0; i <= parents.getSelectedIndex(); i++)
+ {
+ dir.append(parents.getItemAt(i));
+ dir.append(File.separatorChar);
+ }
+ filechooser.setCurrentDirectory(filechooser.getFileSystemView()
+ .createFileObject(dir
+ .toString()));
+ }
+ };
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ private ItemListener createFilterListener()
+ {
+ return new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent e)
+ {
+ int index = filters.getSelectedIndex();
+ if (index == -1)
+ return;
+ filechooser.setFileFilter(filechooser.getChoosableFileFilters()[index]);
+ }
+ };
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ private void filterEntries()
+ {
+ FileFilter[] list = filechooser.getChoosableFileFilters();
+ if (filters.getItemCount() > 0)
+ filters.removeAllItems();
+
+ int index = -1;
+ String selected = filechooser.getFileFilter().getDescription();
+ for (int i = 0; i < list.length; i++)
+ {
+ if (selected.equals(list[i].getDescription()))
+ index = i;
+ filters.addItem(list[i].getDescription());
+ }
+ filters.setSelectedIndex(index);
+ filters.revalidate();
+ filters.repaint();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ public void installComponents(JFileChooser fc)
+ {
+ JLabel look = new JLabel("Look In:");
+
+ parents = new JComboBox();
+ parents.setRenderer(new CBLabelRenderer());
+ boxEntries();
+ look.setLabelFor(parents);
+ JPanel parentsPanel = new JPanel();
+ parentsPanel.add(look);
+ parentsPanel.add(parents);
+ JPanel buttonPanel = new JPanel();
+
+ upFolderButton = new JButton();
+ upFolderButton.setIcon(upFolderIcon);
+ buttonPanel.add(upFolderButton);
+
+ homeFolderButton = new JButton();
+ homeFolderButton = new JButton(homeFolderIcon);
+ buttonPanel.add(homeFolderButton);
+
+ newFolderButton = new JButton();
+ newFolderButton.setIcon(newFolderIcon);
+ buttonPanel.add(newFolderButton);
+
+ ButtonGroup toggles = new ButtonGroup();
+ JToggleButton listViewButton = new JToggleButton();
+ listViewButton.setIcon(listViewIcon);
+ toggles.add(listViewButton);
+ buttonPanel.add(listViewButton);
+
+ JToggleButton detailsViewButton = new JToggleButton();
+ detailsViewButton.setIcon(detailsViewIcon);
+ toggles.add(detailsViewButton);
+ buttonPanel.add(detailsViewButton);
+
+ JPanel topPanel = new JPanel();
+ topPanel.setLayout(new java.awt.FlowLayout());
+ topPanel.add(parentsPanel);
+ topPanel.add(buttonPanel);
+
+ accessoryPanel = new JPanel();
+ if (filechooser.getAccessory() != null)
+ accessoryPanel.add(filechooser.getAccessory(), BorderLayout.CENTER);
+
+ filelist = new JList(model);
+ filelist.setVisibleRowCount(6);
+ JScrollPane scrollp = new JScrollPane(filelist);
+ scrollp.setPreferredSize(new Dimension(400, 175));
+ filelist.setBackground(Color.WHITE);
+
+ filelist.setLayoutOrientation(JList.VERTICAL_WRAP);
+ filelist.setCellRenderer(new ListLabelRenderer());
+
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridx = 0;
+ c.gridy = 0;
+ c.fill = GridBagConstraints.BOTH;
+ c.weightx = 1;
+ c.weighty = 1;
+
+ JPanel centrePanel = new JPanel();
+ centrePanel.setLayout(new GridBagLayout());
+ centrePanel.add(scrollp, c);
+
+ c.gridx = 1;
+ centrePanel.add(accessoryPanel, c);
+
+ JLabel fileNameLabel = new JLabel("File Name:");
+ JLabel fileTypesLabel = new JLabel("Files of Type:");
+
+ JTextField entry = new JTextField();
+ filters = new JComboBox();
+ filterEntries();
+
+ fileNameLabel.setLabelFor(entry);
+ fileNameLabel.setHorizontalTextPosition(SwingConstants.LEFT);
+ fileTypesLabel.setLabelFor(filters);
+ fileTypesLabel.setHorizontalTextPosition(SwingConstants.LEFT);
+
+ closePanel = new JPanel();
+ accept = getApproveButton(filechooser);
+ cancel = new JButton(cancelButtonText);
+ cancel.setMnemonic(cancelButtonMnemonic);
+ cancel.setToolTipText(cancelButtonToolTipText);
+ closePanel.add(accept);
+ closePanel.add(cancel);
+
+ c.anchor = GridBagConstraints.WEST;
+ c.weighty = 0;
+ c.weightx = 0;
+ c.gridx = 0;
+
+ bottomPanel = new JPanel();
+ bottomPanel.setLayout(new GridBagLayout());
+ bottomPanel.add(fileNameLabel, c);
+
+ c.gridy = 1;
+ bottomPanel.add(fileTypesLabel, c);
+ c.gridx = 1;
+ c.gridy = 0;
+ c.weightx = 1;
+ c.weighty = 1;
+ bottomPanel.add(entry, c);
+
+ c.gridy = 1;
+ bottomPanel.add(filters, c);
+
+ c.fill = GridBagConstraints.NONE;
+ c.gridy = 2;
+ c.anchor = GridBagConstraints.EAST;
+ bottomPanel.add(closePanel, c);
+
+ filechooser.setLayout(new GridBagLayout());
+
+ c.anchor = GridBagConstraints.WEST;
+ c.gridx = 0;
+ c.gridy = 0;
+ filechooser.add(topPanel, c);
+
+ c.gridy = 1;
+ filechooser.add(centrePanel, c);
+
+ c.gridy = 2;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ filechooser.add(bottomPanel, c);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ public void uninstallComponents(JFileChooser fc)
+ {
+ parents = null;
+
+ accept = null;
+ cancel = null;
+ upFolderButton = null;
+ homeFolderButton = null;
+ newFolderButton = null;
+
+ filelist = null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ protected void installListeners(JFileChooser fc)
+ {
+ propertyChangeListener = createPropertyChangeListener(filechooser);
+ filechooser.addPropertyChangeListener(propertyChangeListener);
+
+ //parents.addItemListener(createBoxListener());
+ accept.addActionListener(getApproveSelectionAction());
+ cancel.addActionListener(getCancelSelectionAction());
+ upFolderButton.addActionListener(getChangeToParentDirectoryAction());
+ homeFolderButton.addActionListener(getGoHomeAction());
+ newFolderButton.addActionListener(getNewFolderAction());
+ filters.addItemListener(createFilterListener());
+
+ filelist.addMouseListener(createDoubleClickListener(filechooser, filelist));
+ filelist.addListSelectionListener(createListSelectionListener(filechooser));
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ protected void uninstallListeners(JFileChooser fc)
+ {
+ filechooser.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ protected void installDefaults(JFileChooser fc)
+ {
+ installIcons(fc);
+ installStrings(fc);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ protected void uninstallDefaults(JFileChooser fc)
+ {
+ uninstallStrings(fc);
+ uninstallIcons(fc);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ protected void installIcons(JFileChooser fc)
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ protected void uninstallIcons(JFileChooser fc)
+ {
+ // FIXME: Implement.
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ protected void installStrings(JFileChooser fc)
+ {
+ UIDefaults defaults = UIManager.getLookAndFeelDefaults();
+
+ acceptAllFileFilterText = defaults.getString("FileChooser.acceptAllFileFilterText");
+ cancelButtonMnemonic = defaults.getInt("FileChooser.cancelButtonMnemonic");
+ cancelButtonText = defaults.getString("FileChooser.cancelButtonText");
+ cancelButtonToolTipText = defaults.getString("FileChooser.cancelButtonToolTipText");
+
+ dirDescText = defaults.getString("FileChooser.directoryDescriptionText");
+ fileDescText = defaults.getString("FileChooser.fileDescriptionText");
+
+ helpButtonMnemonic = defaults.getInt("FileChooser.helpButtonMnemonic");
+ helpButtonText = defaults.getString("FileChooser.helpButtonText");
+ helpButtonToolTipText = defaults.getString("FileChooser.helpButtonToolTipText");
+
+ openButtonMnemonic = defaults.getInt("FileChooser.openButtonMnemonic");
+ openButtonText = defaults.getString("FileChooser.openButtonText");
+ openButtonToolTipText = defaults.getString("FileChooser.openButtonToolTipText");
+
+ saveButtonMnemonic = defaults.getInt("FileChooser.saveButtonMnemonic");
+ saveButtonText = defaults.getString("FileChooser.saveButtonText");
+ saveButtonToolTipText = defaults.getString("FileChooser.saveButtonToolTipText");
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ protected void uninstallStrings(JFileChooser fc)
+ {
+ acceptAllFileFilterText = null;
+ cancelButtonMnemonic = 0;
+ cancelButtonText = null;
+ cancelButtonToolTipText = null;
+
+ dirDescText = null;
+ fileDescText = null;
+
+ helpButtonMnemonic = 0;
+ helpButtonText = null;
+ helpButtonToolTipText = null;
+
+ openButtonMnemonic = 0;
+ openButtonText = null;
+ openButtonToolTipText = null;
+
+ saveButtonMnemonic = 0;
+ saveButtonText = null;
+ saveButtonToolTipText = null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ protected void createModel()
+ {
+ model = new BasicDirectoryModel(filechooser);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public BasicDirectoryModel getModel()
+ {
+ return model;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public PropertyChangeListener createPropertyChangeListener(JFileChooser fc)
+ {
+ return new PropertyChangeListener()
+ {
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ // FIXME: Multiple file selection waiting on JList multiple selection bug.
+ if (e.getPropertyName().equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY))
+ {
+ if (filechooser.getSelectedFile() == null)
+ setFileName(null);
+ else
+ setFileName(filechooser.getSelectedFile().toString());
+ int index = -1;
+ File file = filechooser.getSelectedFile();
+ for (index = 0; index < model.getSize(); index++)
+ if (((File) model.getElementAt(index)).equals(file))
+ break;
+ if (index == -1)
+ return;
+ filelist.setSelectedIndex(index);
+ filelist.ensureIndexIsVisible(index);
+ filelist.revalidate();
+ filelist.repaint();
+ }
+ else if (e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY))
+ {
+ //boxEntries();
+ filelist.clearSelection();
+ filelist.revalidate();
+ filelist.repaint();
+ setDirectorySelected(false);
+ setDirectory(filechooser.getCurrentDirectory());
+ }
+ else if (e.getPropertyName().equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)
+ || e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY))
+ filterEntries();
+ else if (e.getPropertyName().equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)
+ || e.getPropertyName().equals(JFileChooser.DIALOG_TITLE_CHANGED_PROPERTY))
+ {
+ Window owner = SwingUtilities.windowForComponent(filechooser);
+ if (owner instanceof JDialog)
+ ((JDialog) owner).setTitle(getDialogTitle(filechooser));
+ accept.setText(getApproveButtonText(filechooser));
+ accept.setToolTipText(getApproveButtonToolTipText(filechooser));
+ accept.setMnemonic(getApproveButtonMnemonic(filechooser));
+ }
+ else if (e.getPropertyName().equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY))
+ accept.setText(getApproveButtonText(filechooser));
+ else if (e.getPropertyName().equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY))
+ accept.setToolTipText(getApproveButtonToolTipText(filechooser));
+ else if (e.getPropertyName().equals(JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY))
+ accept.setMnemonic(getApproveButtonMnemonic(filechooser));
+ else if (e.getPropertyName().equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY))
+ {
+ if (filechooser.getControlButtonsAreShown())
+ {
+ GridBagConstraints c = new GridBagConstraints();
+ c.gridy = 1;
+ bottomPanel.add(filters, c);
+
+ c.fill = GridBagConstraints.BOTH;
+ c.gridy = 2;
+ c.anchor = GridBagConstraints.EAST;
+ bottomPanel.add(closePanel, c);
+ bottomPanel.revalidate();
+ bottomPanel.repaint();
+ bottomPanel.doLayout();
+ }
+ else
+ bottomPanel.remove(closePanel);
+ }
+ else if (e.getPropertyName().equals(JFileChooser.ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY))
+ {
+ if (filechooser.isAcceptAllFileFilterUsed())
+ filechooser.addChoosableFileFilter(getAcceptAllFileFilter(filechooser));
+ else
+ filechooser.removeChoosableFileFilter(getAcceptAllFileFilter(filechooser));
+ }
+ else if (e.getPropertyName().equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY))
+ {
+ JComponent old = (JComponent) e.getOldValue();
+ if (old != null)
+ getAccessoryPanel().remove(old);
+ JComponent newval = (JComponent) e.getNewValue();
+ if (newval != null)
+ getAccessoryPanel().add(newval);
+ }
+ if (e.getPropertyName().equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)
+ || e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)
+ || e.getPropertyName().equals(JFileChooser.FILE_HIDING_CHANGED_PROPERTY))
+ rescanCurrentDirectory(filechooser);
+
+ filechooser.revalidate();
+ filechooser.repaint();
+ }
+ };
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getFileName()
+ {
+ return filename;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getDirectoryName()
+ {
+ // XXX: I don't see a case where the thing returns something non-null..
+ return null;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param filename DOCUMENT ME!
+ */
+ public void setFileName(String filename)
+ {
+ this.filename = filename;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param dirname DOCUMENT ME!
+ */
+ public void setDirectoryName(String dirname)
+ {
+ // FIXME: Implement
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ */
+ public void rescanCurrentDirectory(JFileChooser fc)
+ {
+ getModel().validateFileCache();
+ filelist.revalidate();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ * @param f DOCUMENT ME!
+ */
+ public void ensureFileIsVisible(JFileChooser fc, File f)
+ {
+ // XXX: Not sure what this does.
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public JFileChooser getFileChooser()
+ {
+ return filechooser;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public JPanel getAccessoryPanel()
+ {
+ return accessoryPanel;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public JButton getApproveButton(JFileChooser fc)
+ {
+ accept = new JButton(getApproveButtonText(fc));
+ accept.setMnemonic(getApproveButtonMnemonic(fc));
+ accept.setToolTipText(getApproveButtonToolTipText(fc));
+ return accept;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getApproveButtonToolTipText(JFileChooser fc)
+ {
+ if (fc.getApproveButtonToolTipText() != null)
+ return fc.getApproveButtonToolTipText();
+ else if (fc.getDialogType() == JFileChooser.SAVE_DIALOG)
+ return saveButtonToolTipText;
+ else
+ return openButtonToolTipText;
+ }
+
+ /**
+ * DOCUMENT ME!
+ */
+ public void clearIconCache()
+ {
+ if (fv instanceof BasicFileView)
+ ((BasicFileView) fv).clearIconCache();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public ListSelectionListener createListSelectionListener(JFileChooser fc)
+ {
+ return new SelectionListener();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ * @param list DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected MouseListener createDoubleClickListener(JFileChooser fc, JList list)
+ {
+ return new DoubleClickListener(list);
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected boolean isDirectorySelected()
+ {
+ return dirSelected;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param selected DOCUMENT ME!
+ */
+ protected void setDirectorySelected(boolean selected)
+ {
+ dirSelected = selected;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ protected File getDirectory()
+ {
+ return currDir;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param f DOCUMENT ME!
+ */
+ protected void setDirectory(File f)
+ {
+ currDir = f;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public FileFilter getAcceptAllFileFilter(JFileChooser fc)
+ {
+ return acceptAll;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public FileView getFileView(JFileChooser fc)
+ {
+ if (fc.getFileView() != null)
+ return fc.getFileView();
+ return fv;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getDialogTitle(JFileChooser fc)
+ {
+ String ret = fc.getDialogTitle();
+ if (ret != null)
+ return ret;
+ switch (fc.getDialogType())
+ {
+ case JFileChooser.OPEN_DIALOG:
+ ret = openButtonText;
+ break;
+ case JFileChooser.SAVE_DIALOG:
+ ret = saveButtonText;
+ break;
+ default:
+ ret = fc.getApproveButtonText();
+ break;
+ }
+ if (ret == null)
+ ret = openButtonText;
+ return ret;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public int getApproveButtonMnemonic(JFileChooser fc)
+ {
+ if (fc.getApproveButtonMnemonic() != 0)
+ return fc.getApproveButtonMnemonic();
+ else if (fc.getDialogType() == JFileChooser.SAVE_DIALOG)
+ return saveButtonMnemonic;
+ else
+ return openButtonMnemonic;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param fc DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public String getApproveButtonText(JFileChooser fc)
+ {
+ if (fc.getApproveButtonText() != null)
+ return fc.getApproveButtonText();
+ else if (fc.getDialogType() == JFileChooser.SAVE_DIALOG)
+ return saveButtonText;
+ else
+ return openButtonText;
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Action getNewFolderAction()
+ {
+ return new NewFolderAction();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Action getGoHomeAction()
+ {
+ return new GoHomeAction();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Action getChangeToParentDirectoryAction()
+ {
+ return new ChangeToParentDirectoryAction();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Action getApproveSelectionAction()
+ {
+ return new ApproveSelectionAction();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Action getCancelSelectionAction()
+ {
+ return new CancelSelectionAction();
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public Action getUpdateAction()
+ {
+ return new UpdateAction();
+ }
+}
diff --git a/javax/swing/plaf/basic/BasicLookAndFeel.java b/javax/swing/plaf/basic/BasicLookAndFeel.java
index ee9f64b6f..d543505e6 100644
--- a/javax/swing/plaf/basic/BasicLookAndFeel.java
+++ b/javax/swing/plaf/basic/BasicLookAndFeel.java
@@ -112,6 +112,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"DesktopIconUI", "javax.swing.plaf.basic.BasicDesktopIconUI",
"DesktopPaneUI", "javax.swing.plaf.basic.BasicDesktopPaneUI",
"EditorPaneUI", "javax.swing.plaf.basic.BasicEditorPaneUI",
+ "FileChooserUI", "javax.swing.plaf.basic.BasicFileChooserUI",
"FormattedTextFieldUI", "javax.swing.plaf.basic.BasicFormattedTextFieldUI",
"InternalFrameUI", "javax.swing.plaf.basic.BasicInternalFrameUI",
"LabelUI", "javax.swing.plaf.basic.BasicLabelUI",
@@ -398,20 +399,20 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"FileChooser.cancelButtonText", "Cancel",
"FileChooser.cancelButtonToolTipText", "Abort file chooser dialog",
// XXX Don't use gif
- "FileChooser.detailsViewIcon", new IconUIResource(new ImageIcon("icons/DetailsView.gif")),
+// "FileChooser.detailsViewIcon", new IconUIResource(new ImageIcon("icons/DetailsView.gif")),
"FileChooser.directoryDescriptionText", "Directory",
"FileChooser.fileDescriptionText", "Generic File",
"FileChooser.helpButtonMnemonic", new Integer(72),
"FileChooser.helpButtonText", "Help",
"FileChooser.helpButtonToolTipText", "FileChooser help",
// XXX Don't use gif
- "FileChooser.homeFolderIcon", new IconUIResource(new ImageIcon("icons/HomeFolder.gif")),
+// "FileChooser.homeFolderIcon", new IconUIResource(new ImageIcon("icons/HomeFolder.gif")),
// XXX Don't use gif
- "FileChooser.listViewIcon", new IconUIResource(new ImageIcon("icons/ListView.gif")),
+// "FileChooser.listViewIcon", new IconUIResource(new ImageIcon("icons/ListView.gif")),
"FileChooser.newFolderErrorSeparator", ":",
"FileChooser.newFolderErrorText", "Error creating new folder",
// XXX Don't use gif
- "FileChooser.newFolderIcon", new IconUIResource(new ImageIcon("icons/NewFolder.gif")),
+// "FileChooser.newFolderIcon", new IconUIResource(new ImageIcon("icons/NewFolder.gif")),
"FileChooser.openButtonMnemonic", new Integer(79),
"FileChooser.openButtonText", "Open",
"FileChooser.openButtonToolTipText", "Open selected file",
@@ -419,20 +420,20 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"FileChooser.saveButtonText", "Save",
"FileChooser.saveButtonToolTipText", "Save selected file",
// XXX Don't use gif
- "FileChooser.upFolderIcon", new IconUIResource(new ImageIcon("icons/UpFolder.gif")),
+// "FileChooser.upFolderIcon", new IconUIResource(new ImageIcon("icons/UpFolder.gif")),
"FileChooser.updateButtonMnemonic", new Integer(85),
"FileChooser.updateButtonText", "Update",
"FileChooser.updateButtonToolTipText", "Update directory listing",
// XXX Don't use gif
- "FileView.computerIcon", new IconUIResource(new ImageIcon("icons/Computer.gif")),
+// "FileView.computerIcon", new IconUIResource(new ImageIcon("icons/Computer.gif")),
// XXX Don't use gif
- "FileView.directoryIcon", new IconUIResource(new ImageIcon("icons/Directory.gif")),
+// "FileView.directoryIcon", new IconUIResource(new ImageIcon("icons/Directory.gif")),
// XXX Don't use gif
- "FileView.fileIcon", new IconUIResource(new ImageIcon("icons/File.gif")),
+// "FileView.fileIcon", new IconUIResource(new ImageIcon("icons/File.gif")),
// XXX Don't use gif
- "FileView.floppyDriveIcon", new IconUIResource(new ImageIcon("icons/Floppy.gif")),
+// "FileView.floppyDriveIcon", new IconUIResource(new ImageIcon("icons/Floppy.gif")),
// XXX Don't use gif
- "FileView.hardDriveIcon", new IconUIResource(new ImageIcon("icons/HardDrive.gif")),
+// "FileView.hardDriveIcon", new IconUIResource(new ImageIcon("icons/HardDrive.gif")),
"FocusManagerClassName", "TODO",
"FormattedTextField.background", new ColorUIResource(light),
"FormattedTextField.caretForeground", new ColorUIResource(Color.black),
@@ -456,7 +457,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"InternalFrame.borderShadow", new ColorUIResource(shadow),
"InternalFrame.closeIcon", BasicIconFactory.createEmptyFrameIcon(),
// XXX Don't use gif
- "InternalFrame.icon", new IconUIResource(new ImageIcon("icons/JavaCup.gif")),
+// "InternalFrame.icon", new IconUIResource(new ImageIcon("icons/JavaCup.gif")),
"InternalFrame.iconifyIcon", BasicIconFactory.createEmptyFrameIcon(),
"InternalFrame.inactiveTitleBackground", new ColorUIResource(Color.gray),
"InternalFrame.inactiveTitleForeground",
@@ -557,13 +558,13 @@ public abstract class BasicLookAndFeel extends LookAndFeel
new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0),
"OptionPane.cancelButtonText", "Cancel",
// XXX Don't use gif
- "OptionPane.errorIcon",
- new IconUIResource(new ImageIcon("icons/Error.gif")),
+// "OptionPane.errorIcon",
+// new IconUIResource(new ImageIcon("icons/Error.gif")),
"OptionPane.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"OptionPane.foreground", new ColorUIResource(darkShadow),
// XXX Don't use gif
- "OptionPane.informationIcon",
- new IconUIResource(new ImageIcon("icons/Inform.gif")),
+// "OptionPane.informationIcon",
+// new IconUIResource(new ImageIcon("icons/Inform.gif")),
"OptionPane.messageAreaBorder",
new BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0),
"OptionPane.messageForeground", new ColorUIResource(darkShadow),
@@ -571,11 +572,11 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"OptionPane.noButtonText", "No",
"OptionPane.okButtonText", "OK",
// XXX Don't use gif
- "OptionPane.questionIcon",
- new IconUIResource(new ImageIcon("icons/Question.gif")),
+// "OptionPane.questionIcon",
+// new IconUIResource(new ImageIcon("icons/Question.gif")),
// XXX Don't use gif
- "OptionPane.warningIcon",
- new IconUIResource(new ImageIcon("icons/Warn.gif")),
+// "OptionPane.warningIcon",
+// new IconUIResource(new ImageIcon("icons/Warn.gif")),
"OptionPane.windowBindings", new Object[] {
"ESCAPE", "close"
},
@@ -836,7 +837,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"TableHeader.cellBorder", new BorderUIResource.BevelBorderUIResource(0),
"TableHeader.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"TableHeader.foreground", new ColorUIResource(darkShadow),
- "TextArea.background", new ColorUIResource(light),
+
+ "TextArea.background", new ColorUIResource(light),
"TextArea.border", new BasicBorders.MarginBorder(),
"TextArea.caretBlinkRate", new Integer(500),
"TextArea.caretForeground", new ColorUIResource(Color.black),
@@ -909,7 +911,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
},
"TextPane.margin", new InsetsUIResource(3, 3, 3, 3),
"TextPane.selectionBackground", new ColorUIResource(Color.black),
- "TextPane.selectionForeground", new ColorUIResource(Color.white),
+ "TextPane.selectionForeground", new ColorUIResource(Color.white)/*,
"TitledBorder.border", new BorderUIResource.EtchedBorderUIResource(),
"TitledBorder.font", new FontUIResource("Dialog", Font.PLAIN, 12),
"TitledBorder.titleColor", new ColorUIResource(darkShadow),
@@ -961,8 +963,8 @@ public abstract class BasicLookAndFeel extends LookAndFeel
}),
"Tree.background", new ColorUIResource(light),
"Tree.changeSelectionWithFocus", Boolean.TRUE,
- "Tree.closedIcon", new IconUIResource(new ImageIcon("icons/TreeClosed.png")),
- "Tree.collapsedIcon", new IconUIResource(new ImageIcon("icons/TreeCollapsed.png")),
+// "Tree.closedIcon", new IconUIResource(new ImageIcon("icons/TreeClosed.png")),
+// "Tree.collapsedIcon", new IconUIResource(new ImageIcon("icons/TreeCollapsed.png")),
"Tree.drawsFocusBorderAroundIcon", Boolean.FALSE,
"Tree.editorBorder", new BorderUIResource.LineBorderUIResource(Color.lightGray),
"Tree.focusInputMap", new UIDefaults.LazyInputMap(new Object[] {
@@ -1010,12 +1012,12 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"ctrl PAGE_DOWN", "scrollDownChangeLead"
}),
"Tree.font", new FontUIResource("Dialog", Font.PLAIN, 12),
- "Tree.expandedIcon", new IconUIResource(new ImageIcon("icons/TreeExpanded.png")),
+// "Tree.expandedIcon", new IconUIResource(new ImageIcon("icons/TreeExpanded.png")),
"Tree.foreground", new ColorUIResource(Color.black),
"Tree.hash", new ColorUIResource(Color.gray),
- "Tree.leafIcon", new IconUIResource(new ImageIcon("icons/TreeLeaf.png")),
+// "Tree.leafIcon", new IconUIResource(new ImageIcon("icons/TreeLeaf.png")),
"Tree.leftChildIndent", new Integer(7),
- "Tree.openIcon", new IconUIResource(new ImageIcon("icons/TreeOpen.png")),
+// "Tree.openIcon", new IconUIResource(new ImageIcon("icons/TreeOpen.png")),
"Tree.rightChildIndent", new Integer(13),
"Tree.rowHeight", new Integer(16),
"Tree.scrollsOnExpand", Boolean.TRUE,
@@ -1026,7 +1028,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel
"Tree.textForeground", new ColorUIResource(Color.black),
"Viewport.background", new ColorUIResource(light),
"Viewport.foreground", new ColorUIResource(Color.black),
- "Viewport.font", new FontUIResource("Dialog", Font.PLAIN, 12)
+ "Viewport.font", new FontUIResource("Dialog", Font.PLAIN, 12)*/
};
defaults.putDefaults(uiDefaults);
}
diff --git a/javax/swing/plaf/basic/BasicOptionPaneUI.java b/javax/swing/plaf/basic/BasicOptionPaneUI.java
index f86dd75e6..e0cabce0d 100644
--- a/javax/swing/plaf/basic/BasicOptionPaneUI.java
+++ b/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -56,6 +56,7 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
+import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.Icon;
@@ -854,6 +855,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
addIcon(messageArea);
JPanel rightSide = new JPanel();
+ rightSide.setBorder(BorderFactory.createEmptyBorder(0, 11, 17, 0));
rightSide.setLayout(new GridBagLayout());
GridBagConstraints con = createConstraints();
@@ -864,19 +866,16 @@ public class BasicOptionPaneUI extends OptionPaneUI
{
Object[] selection = optionPane.getSelectionValues();
-// if (selection == null)
-// inputComponent = new JTextField();
-// else if (selection.length < 20)
-// inputComponent = new JComboBox(selection);
- // FIXME: Uncomment when the widgets are done.
if (selection == null)
- inputComponent = null;
+ inputComponent = new JTextField(15);
+ else if (selection.length < 20)
+ inputComponent = new JComboBox(selection);
else
inputComponent = new JList(selection);
if (inputComponent != null)
{
addMessageComponents(rightSide, con, inputComponent,
- getMaxCharactersPerLineCount(), true);
+ getMaxCharactersPerLineCount(), false);
resetSelectedValue();
selectInitialValue(optionPane);
}
@@ -906,7 +905,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
*/
protected Container createSeparator()
{
- return null;
+ return (Container) Box.createVerticalStrut(17);
}
/**
@@ -1123,6 +1122,7 @@ public class BasicOptionPaneUI extends OptionPaneUI
optionPane.add(button);
}
+ optionPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11));
optionPane.invalidate();
}
diff --git a/javax/swing/plaf/basic/BasicPopupMenuUI.java b/javax/swing/plaf/basic/BasicPopupMenuUI.java
index c131c86b1..b7cbb3284 100644
--- a/javax/swing/plaf/basic/BasicPopupMenuUI.java
+++ b/javax/swing/plaf/basic/BasicPopupMenuUI.java
@@ -37,18 +37,24 @@ exception statement from your version. */
package javax.swing.plaf.basic;
+import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Container;
+import java.awt.Cursor;
import java.awt.Dimension;
-import java.awt.GridBagLayout;
+import java.awt.Point;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.MouseEvent;
+import javax.swing.BoxLayout;
import javax.swing.JComponent;
+import javax.swing.JLayeredPane;
+import javax.swing.JMenu;
import javax.swing.JPopupMenu;
import javax.swing.MenuElement;
import javax.swing.MenuSelectionManager;
+import javax.swing.RootPaneContainer;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
@@ -83,7 +89,6 @@ public class BasicPopupMenuUI extends PopupMenuUI
public BasicPopupMenuUI()
{
popupMenuListener = new PopupMenuHandler();
- mouseInputListener = new MouseInputHandler();
topWindowListener = new TopWindowListener();
}
@@ -111,7 +116,7 @@ public class BasicPopupMenuUI extends PopupMenuUI
{
super.installUI(c);
popupMenu = (JPopupMenu) c;
- popupMenu.setLayout(new GridBagLayout());
+ popupMenu.setLayout(new DefaultMenuLayout(popupMenu, BoxLayout.Y_AXIS));
popupMenu.setBorderPainted(true);
JPopupMenu.setDefaultLightWeightPopupEnabled(true);
@@ -120,8 +125,8 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
- * This method installs the defaults that are defined in the Basic look and
- * feel for this {@link JPopupMenu}.
+ * This method installs the defaults that are defined in the Basic look
+ * and feel for this {@link JPopupMenu}.
*/
public void installDefaults()
{
@@ -139,8 +144,6 @@ public class BasicPopupMenuUI extends PopupMenuUI
*/
protected void installListeners()
{
- popupMenu.addMouseListener(mouseInputListener);
- popupMenu.addMouseMotionListener(mouseInputListener);
popupMenu.addPopupMenuListener(popupMenuListener);
}
@@ -183,8 +186,6 @@ public class BasicPopupMenuUI extends PopupMenuUI
*/
protected void uninstallListeners()
{
- popupMenu.removeMouseListener(mouseInputListener);
- popupMenu.removeMouseMotionListener(mouseInputListener);
popupMenu.removePopupMenuListener(popupMenuListener);
}
@@ -273,8 +274,26 @@ public class BasicPopupMenuUI extends PopupMenuUI
// by the top - level window that this popup belongs to.
Component invoker = popupMenu.getInvoker();
- Container rootContainer = (Container) SwingUtilities.getRoot(invoker);
- rootContainer.removeComponentListener(topWindowListener);
+ RootPaneContainer rootContainer = (RootPaneContainer) SwingUtilities
+ .getRoot(invoker);
+ ((Container) rootContainer).removeComponentListener(topWindowListener);
+
+ // If this popup menu is the last popup menu visible on the screen, then
+ // stop interrupting mouse events in the glass pane before hiding this
+ // last popup menu.
+ boolean topLevelMenu = (popupMenu.getInvoker() instanceof JMenu)
+ && ((JMenu) popupMenu.getInvoker())
+ .isTopLevelMenu();
+
+ if (topLevelMenu || ! (popupMenu.getInvoker() instanceof MenuElement))
+ {
+ // set glass pane not to interrupt mouse events and remove
+ // mouseInputListener
+ Container glassPane = (Container) rootContainer.getGlassPane();
+ glassPane.setVisible(false);
+ glassPane.removeMouseListener(mouseInputListener);
+ mouseInputListener = null;
+ }
}
/**
@@ -288,8 +307,20 @@ public class BasicPopupMenuUI extends PopupMenuUI
// ComponentEvents fired by it. We need to cancel this popup menu
// if topWindow to which this popup belongs was resized or moved.
Component invoker = popupMenu.getInvoker();
- Container rootContainer = (Container) SwingUtilities.getRoot(invoker);
- rootContainer.addComponentListener(topWindowListener);
+ RootPaneContainer rootContainer = (RootPaneContainer) SwingUtilities
+ .getRoot(invoker);
+ ((Container) rootContainer).addComponentListener(topWindowListener);
+
+ // Set the glass pane to interrupt all mouse events originating in root
+ // container
+ if (mouseInputListener == null)
+ {
+ Container glassPane = (Container) rootContainer.getGlassPane();
+ glassPane.setVisible(true);
+ mouseInputListener = new MouseInputHandler(rootContainer);
+ glassPane.addMouseListener(mouseInputListener);
+ glassPane.addMouseMotionListener(mouseInputListener);
+ }
// if this popup menu is a free floating popup menu,
// then by default its first element should be always selected when
@@ -344,8 +375,8 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
/**
- * This method is invoked when top-level window is shown This method does
- * nothing by default.
+ * This method is invoked when top-level window is shown This method
+ * does nothing by default.
*
* @param e The ComponentEvent
*/
@@ -368,34 +399,272 @@ public class BasicPopupMenuUI extends PopupMenuUI
}
}
+ /**
+ * MouseInputHandler listens to all mouse events originated in the root
+ * container. This class is responsible for closing menu hierarchy when the
+ * user presses mouse over any component that do not belong to the current
+ * menu hierarchy. This is acomplished by interrupting all mouse event in
+ * the glass pane and checking if other component was pressed while menu
+ * was open, before redestributing events further to intended components
+ */
private class MouseInputHandler implements MouseInputListener
{
+ private JLayeredPane layeredPane;
+ private Container glassPane;
+ private Cursor nativeCursor;
+ private transient Component mouseEventTarget;
+ private transient Component pressedComponent;
+ private transient Component lastComponentEntered;
+ private transient int pressCount;
+
+ /**
+ * Creates a new MouseInputHandler object.
+ *
+ * @param c the top most root container
+ */
+ public MouseInputHandler(RootPaneContainer c)
+ {
+ layeredPane = c.getLayeredPane();
+ glassPane = (Container) c.getGlassPane();
+ }
+
+ /**
+ * Handles mouse clicked event
+ *
+ * @param e Mouse event
+ */
public void mouseClicked(MouseEvent e)
{
+ handleEvent(e);
}
+ /**
+ * Handles mouseDragged event
+ *
+ * @param e MouseEvent
+ */
public void mouseDragged(MouseEvent e)
{
+ handleEvent(e);
}
+ /**
+ * Handles mouseEntered event
+ *
+ * @param e MouseEvent
+ */
public void mouseEntered(MouseEvent e)
{
+ handleEvent(e);
}
+ /**
+ * Handles mouseExited event
+ *
+ * @param e MouseEvent
+ */
public void mouseExited(MouseEvent e)
{
+ handleEvent(e);
}
+ /**
+ * Handles mouse moved event
+ *
+ * @param e MouseEvent
+ */
public void mouseMoved(MouseEvent e)
{
+ handleEvent(e);
}
+ /**
+ * Handles mouse pressed event
+ *
+ * @param e MouseEvent
+ */
public void mousePressed(MouseEvent e)
{
+ handleEvent(e);
}
+ /**
+ * Handles mouse released event
+ *
+ * @param e MouseEvent
+ */
public void mouseReleased(MouseEvent e)
{
+ handleEvent(e);
+ }
+
+ /*
+ * This method determines component that was intended to received mouse
+ * event, before it was interrupted within the glass pane. This method
+ * also redispatches mouse entered and mouse exited events to the
+ * appropriate components. This code is slightly modified code from
+ * Container.LightweightDispatcher class, which is private inside
+ * Container class and cannot be used here.
+ */
+ public void acquireComponentForMouseEvent(MouseEvent me)
+ {
+ int x = me.getX();
+ int y = me.getY();
+
+ // Find the candidate which should receive this event.
+ Component parent = layeredPane;
+ Component candidate = null;
+ Point p = me.getPoint();
+ while ((candidate == null) && (parent != null))
+ {
+ p = SwingUtilities.convertPoint(glassPane, p.x, p.y, parent);
+ candidate = SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
+
+ if (candidate == null)
+ {
+ p = SwingUtilities.convertPoint(parent, p.x, p.y,
+ parent.getParent());
+ parent = parent.getParent();
+ }
+ }
+
+ // If the only candidate we found was the native container itself,
+ // don't dispatch any event at all. We only care about the lightweight
+ // children here.
+ if (candidate == layeredPane)
+ candidate = null;
+
+ // If our candidate is new, inform the old target we're leaving.
+ if ((lastComponentEntered != null) && lastComponentEntered.isShowing()
+ && (lastComponentEntered != candidate))
+ {
+ // Old candidate could have been removed from
+ // the layeredPane so we check first.
+ if (SwingUtilities.isDescendingFrom(lastComponentEntered, layeredPane))
+ {
+ Point tp = SwingUtilities.convertPoint(layeredPane, x, y,
+ lastComponentEntered);
+ MouseEvent exited = new MouseEvent(lastComponentEntered,
+ MouseEvent.MOUSE_EXITED,
+ me.getWhen(),
+ me.getModifiersEx(), tp.x,
+ tp.y, me.getClickCount(),
+ me.isPopupTrigger(),
+ me.getButton());
+
+ lastComponentEntered.dispatchEvent(exited);
+ }
+
+ lastComponentEntered = null;
+ }
+
+ // If we have a candidate, maybe enter it.
+ if (candidate != null)
+ {
+ mouseEventTarget = candidate;
+
+ if (candidate.isLightweight() && candidate.isShowing()
+ && (candidate != layeredPane)
+ && (candidate != lastComponentEntered))
+ {
+ lastComponentEntered = mouseEventTarget;
+
+ Point cp = SwingUtilities.convertPoint(layeredPane, x, y,
+ lastComponentEntered);
+ MouseEvent entered = new MouseEvent(lastComponentEntered,
+ MouseEvent.MOUSE_ENTERED,
+ me.getWhen(),
+ me.getModifiersEx(), cp.x,
+ cp.y, me.getClickCount(),
+ me.isPopupTrigger(),
+ me.getButton());
+ lastComponentEntered.dispatchEvent(entered);
+ }
+ }
+
+ if ((me.getID() == MouseEvent.MOUSE_RELEASED)
+ || ((me.getID() == MouseEvent.MOUSE_PRESSED) && (pressCount > 0))
+ || (me.getID() == MouseEvent.MOUSE_DRAGGED))
+ {
+ // If any of the following events occur while a button is held down,
+ // they should be dispatched to the same component to which the
+ // original MOUSE_PRESSED event was dispatched:
+ // - MOUSE_RELEASED
+ // - MOUSE_PRESSED: another button pressed while the first is held down
+ // - MOUSE_DRAGGED
+ if (SwingUtilities.isDescendingFrom(pressedComponent, layeredPane))
+ mouseEventTarget = pressedComponent;
+ else if (me.getID() == MouseEvent.MOUSE_CLICKED)
+ {
+ // Don't dispatch CLICKED events whose target is not the same as the
+ // target for the original PRESSED event.
+ if (candidate != pressedComponent)
+ mouseEventTarget = null;
+ else if (pressCount == 0)
+ pressedComponent = null;
+ }
+ }
+ }
+
+ /*
+ * This method handles mouse events interrupted by glassPane. It
+ * redispatches the mouse events appropriately to the intended components.
+ * The code in this method is also taken from
+ * Container.LightweightDispatcher class. The code is slightly modified
+ * to handle the case when mouse is released over non-menu component. In
+ * this case this method closes current menu hierarchy before
+ * redispatching the event further.
+ */
+ public void handleEvent(AWTEvent e)
+ {
+ if (e instanceof MouseEvent)
+ {
+ MouseEvent me = (MouseEvent) e;
+
+ acquireComponentForMouseEvent(me);
+
+ // Avoid dispatching ENTERED and EXITED events twice.
+ if (mouseEventTarget != null && mouseEventTarget.isShowing()
+ && (e.getID() != MouseEvent.MOUSE_ENTERED)
+ && (e.getID() != MouseEvent.MOUSE_EXITED))
+ {
+ MouseEvent newEvt = SwingUtilities.convertMouseEvent(glassPane,
+ me,
+ mouseEventTarget);
+
+ mouseEventTarget.dispatchEvent(newEvt);
+
+ // If mouse was clicked over the component that is not part
+ // of menu hierarchy,then must close the menu hierarchy */
+ if (e.getID() == MouseEvent.MOUSE_RELEASED)
+ {
+ boolean partOfMenuHierarchy = false;
+ MenuSelectionManager manager = MenuSelectionManager
+ .defaultManager();
+
+ partOfMenuHierarchy = manager.isComponentPartOfCurrentMenu(mouseEventTarget);
+
+ if (! partOfMenuHierarchy)
+ manager.clearSelectedPath();
+ }
+
+ switch (e.getID())
+ {
+ case MouseEvent.MOUSE_PRESSED:
+ if (pressCount++ == 0)
+ pressedComponent = mouseEventTarget;
+ break;
+ case MouseEvent.MOUSE_RELEASED:
+ // Clear our memory of the original PRESSED event, only if
+ // we're not expecting a CLICKED event after this. If
+ // there is a CLICKED event after this, it will do clean up.
+ if ((--pressCount == 0)
+ && (mouseEventTarget != pressedComponent))
+ pressedComponent = null;
+ break;
+ }
+ }
+ }
}
}
}
diff --git a/javax/swing/plaf/basic/BasicProgressBarUI.java b/javax/swing/plaf/basic/BasicProgressBarUI.java
index 1feb2c4ce..8cf473993 100644
--- a/javax/swing/plaf/basic/BasicProgressBarUI.java
+++ b/javax/swing/plaf/basic/BasicProgressBarUI.java
@@ -48,6 +48,9 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.font.FontRenderContext;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -381,16 +384,16 @@ public class BasicProgressBarUI extends ProgressBarUI
{
// The only thing we need to worry about is
// the text size.
- Graphics g = progressBar.getGraphics();
-
Insets insets = c.getInsets();
- FontMetrics fm = g.getFontMetrics(c.getFont());
-
- int textW = fm.stringWidth(progressBar.getString());
- int textH = fm.getHeight();
-
- g.dispose();
+ // make a fontrenderer context so that we can make assumptions about
+ // the string bounds
+ FontRenderContext ctx = new FontRenderContext(new AffineTransform(),
+ false, false);
+ Rectangle2D bounds = c.getFont().getStringBounds(progressBar.getString(),
+ ctx);
+ int textW = (int) bounds.getWidth();
+ int textH = (int) bounds.getHeight();
if (progressBar.getOrientation() == JProgressBar.HORIZONTAL)
{
diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java
index a94ca2bb4..25e640429 100644
--- a/javax/swing/plaf/basic/BasicTextUI.java
+++ b/javax/swing/plaf/basic/BasicTextUI.java
@@ -57,6 +57,8 @@ import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
import javax.swing.plaf.TextUI;
import javax.swing.plaf.UIResource;
import javax.swing.text.BadLocationException;
@@ -150,6 +152,45 @@ public abstract class BasicTextUI extends TextUI
return ((PlainView) view).modelToView(position, a, bias).getBounds();
}
+
+ /**
+ * Notification about text insertions. These are forwarded to the
+ * real root view.
+ *
+ * @param ev the DocumentEvent describing the change
+ * @param shape the current allocation of the view's display
+ * @param vf the ViewFactory to use for creating new Views
+ */
+ public void insertUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ view.insertUpdate(ev, shape, vf);
+ }
+
+ /**
+ * Notification about text removals. These are forwarded to the
+ * real root view.
+ *
+ * @param ev the DocumentEvent describing the change
+ * @param shape the current allocation of the view's display
+ * @param vf the ViewFactory to use for creating new Views
+ */
+ public void removeUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ view.removeUpdate(ev, shape, vf);
+ }
+
+ /**
+ * Notification about text changes. These are forwarded to the
+ * real root view.
+ *
+ * @param ev the DocumentEvent describing the change
+ * @param shape the current allocation of the view's display
+ * @param vf the ViewFactory to use for creating new Views
+ */
+ public void changedUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ view.changedUpdate(ev, shape, vf);
+ }
}
class UpdateHandler implements PropertyChangeListener
@@ -163,13 +204,61 @@ public abstract class BasicTextUI extends TextUI
}
}
}
-
+
+ /**
+ * Listens for changes on the underlying model and forwards notifications
+ * to the View.
+ *
+ * TODO: Maybe this should somehow be handled through EditorKits
+ */
+ class DocumentHandler implements DocumentListener
+ {
+ /**
+ * Notification about a document change event.
+ *
+ * @param ev the DocumentEvent describing the change
+ */
+ public void changedUpdate(DocumentEvent ev)
+ {
+ Dimension size = textComponent.getSize();
+ rootView.changedUpdate(ev, new Rectangle(0, 0, size.width, size.height),
+ BasicTextUI.this);
+ }
+
+ /**
+ * Notification about a document insert event.
+ *
+ * @param ev the DocumentEvent describing the insertion
+ */
+ public void insertUpdate(DocumentEvent ev)
+ {
+ Dimension size = textComponent.getSize();
+ rootView.insertUpdate(ev, new Rectangle(0, 0, size.width, size.height),
+ BasicTextUI.this);
+ }
+
+ /**
+ * Notification about a document removal event.
+ *
+ * @param ev the DocumentEvent describing the removal
+ */
+ public void removeUpdate(DocumentEvent ev)
+ {
+ Dimension size = textComponent.getSize();
+ rootView.removeUpdate(ev, new Rectangle(0, 0, size.width, size.height),
+ BasicTextUI.this);
+ }
+ }
+
static EditorKit kit = new DefaultEditorKit();
RootView rootView = new RootView();
JTextComponent textComponent;
UpdateHandler updateHandler = new UpdateHandler();
+ /** The DocumentEvent handler. */
+ DocumentHandler documentHandler = new DocumentHandler();
+
public BasicTextUI()
{
}
@@ -249,6 +338,17 @@ public abstract class BasicTextUI extends TextUI
protected void installListeners()
{
textComponent.addFocusListener(focuslistener);
+ installDocumentListeners();
+ }
+
+ /**
+ * Installs the document listeners on the textComponent's model.
+ */
+ private void installDocumentListeners()
+ {
+ Document doc = textComponent.getDocument();
+ if (doc != null)
+ doc.addDocumentListener(documentHandler);
}
protected String getKeymapName()
@@ -488,6 +588,7 @@ public abstract class BasicTextUI extends TextUI
Document doc = textComponent.getDocument();
if (doc == null)
return;
+ installDocumentListeners();
Element elem = doc.getDefaultRootElement();
if (elem == null)
return;
diff --git a/javax/swing/plaf/basic/DefaultMenuLayout.java b/javax/swing/plaf/basic/DefaultMenuLayout.java
new file mode 100644
index 000000000..d6ad950f0
--- /dev/null
+++ b/javax/swing/plaf/basic/DefaultMenuLayout.java
@@ -0,0 +1,78 @@
+/* DefaultMenuLayout.java
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package javax.swing.plaf.basic;
+
+import java.awt.Container;
+import java.awt.Dimension;
+
+import javax.swing.BoxLayout;
+import javax.swing.plaf.UIResource;
+
+/**
+ * The LayoutManager that is used in PopupMenus. This is a derived from
+ * {@link BoxLayout}.
+ *
+ * @author Roman Kennke (roman@kennke.org)
+ */
+public class DefaultMenuLayout
+ extends BoxLayout
+ implements UIResource
+{
+
+ /**
+ * Creates a new instance of DefaultMenuLayout.
+ *
+ * @param target the component that is laid out
+ * @param axis the axis along which the component is laid out
+ */
+ public DefaultMenuLayout(Container target, int axis)
+ {
+ super(target, axis);
+ }
+
+ /**
+ * Returns the preferred size for the layout of the menu.
+ *
+ * @param target the Container which's preferred size we calculate
+ */
+ public Dimension preferredLayoutSize(Container target)
+ {
+ return super.preferredLayoutSize(target);
+ }
+
+}
diff --git a/javax/swing/plaf/metal/MetalComboBoxUI.java b/javax/swing/plaf/metal/MetalComboBoxUI.java
index 3ba25b6c5..2e4ca5149 100644
--- a/javax/swing/plaf/metal/MetalComboBoxUI.java
+++ b/javax/swing/plaf/metal/MetalComboBoxUI.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.util.HashMap;
+
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicComboBoxUI;
@@ -46,9 +48,8 @@ public class MetalComboBoxUI
extends BasicComboBoxUI
{
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for JComboBoxes. */
- private static MetalComboBoxUI instance = null;
+ /** The UI instances for JComboBoxes. */
+ private static HashMap instances = null;
/**
* Constructs a new instance of MetalComboBoxUI.
@@ -67,8 +68,19 @@ public class MetalComboBoxUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalComboBoxUI();
+ if (instances == null)
+ instances = new HashMap();
+
+ Object o = instances.get(component);
+ MetalComboBoxUI instance;
+ if (o == null)
+ {
+ instance = new MetalComboBoxUI();
+ instances.put(component, instance);
+ }
+ else
+ instance = (MetalComboBoxUI) o;
+
return instance;
}
}
diff --git a/javax/swing/table/DefaultTableCellRenderer.java b/javax/swing/table/DefaultTableCellRenderer.java
index 790d0450f..1dadf81b5 100644
--- a/javax/swing/table/DefaultTableCellRenderer.java
+++ b/javax/swing/table/DefaultTableCellRenderer.java
@@ -122,10 +122,14 @@ public class DefaultTableCellRenderer extends JLabel
boolean hasFocus,
int row, int column)
{
- if (value!=null)
+ if (value != null)
super.setText(value.toString());
setOpaque(true);
+
+ if (table == null)
+ return this;
+
if (isSelected)
{
setBackground(table.getSelectionBackground());
diff --git a/javax/swing/text/AbstractDocument.java b/javax/swing/text/AbstractDocument.java
index 29be0ad06..efeb85db6 100644
--- a/javax/swing/text/AbstractDocument.java
+++ b/javax/swing/text/AbstractDocument.java
@@ -847,8 +847,8 @@ public abstract class AbstractDocument
public class LeafElement extends AbstractElement
{
private static final long serialVersionUID = 5115368706941283802L;
- private int start;
- private int end;
+ int start;
+ int end;
public LeafElement(Element parent, AttributeSet attributes, int start,
int end)
diff --git a/javax/swing/text/FieldView.java b/javax/swing/text/FieldView.java
index 3f1de3772..e81a19fe5 100644
--- a/javax/swing/text/FieldView.java
+++ b/javax/swing/text/FieldView.java
@@ -39,10 +39,15 @@ exception statement from your version. */
package javax.swing.text;
import java.awt.Component;
+import java.awt.ComponentOrientation;
import java.awt.FontMetrics;
import java.awt.Graphics;
+import java.awt.Rectangle;
import java.awt.Shape;
+import javax.swing.JTextField;
+import javax.swing.event.DocumentEvent;
+
public class FieldView extends PlainView
{
public FieldView(Element elem)
@@ -56,6 +61,55 @@ public class FieldView extends PlainView
return container.getFontMetrics(container.getFont());
}
+ /**
+ * Vertically centers the single line of text within the
+ * bounds of the input shape. The returned Rectangle is centered
+ * vertically within <code>shape</code> and has a height of the
+ * preferred span along the Y axis. Horizontal adjustment is done according
+ * to the horizontalAligment property of the component that is rendered.
+ *
+ * @param shape the shape within which the line is beeing centered
+ */
+ protected Shape adjustAllocation(Shape shape)
+ {
+ Rectangle rectIn = shape.getBounds();
+ // vertical adjustment
+ int height = (int) getPreferredSpan(Y_AXIS);
+ int y = rectIn.y + (rectIn.height - height) / 2;
+ // horizontal adjustment
+ JTextField textField = (JTextField) getContainer();
+ int halign = textField.getHorizontalAlignment();
+ int width = (int) getPreferredSpan(X_AXIS);
+ int x;
+ ComponentOrientation orientation = textField.getComponentOrientation();
+ switch (halign)
+ {
+ case JTextField.CENTER:
+ x = rectIn.x + (rectIn.width - width) / 2;
+ break;
+ case JTextField.RIGHT:
+ x = rectIn.x + (rectIn.width - width);
+ break;
+ case JTextField.TRAILING:
+ if (orientation.isLeftToRight())
+ x = rectIn.x + (rectIn.width - width);
+ else
+ x = rectIn.x;
+ break;
+ case JTextField.LEADING:
+ if (orientation.isLeftToRight())
+ x = rectIn.x;
+ else
+ x = rectIn.x + (rectIn.width - width);
+ break;
+ case JTextField.LEFT:
+ default:
+ x = rectIn.x;
+ break;
+ }
+ return new Rectangle(x, y, width, height);
+ }
+
public float getPreferredSpan(int axis)
{
if (axis != X_AXIS && axis != Y_AXIS)
@@ -91,11 +145,32 @@ public class FieldView extends PlainView
public Shape modelToView(int pos, Shape a, Position.Bias bias)
throws BadLocationException
{
- return super.modelToView(pos, a, bias);
+ Shape newAlloc = adjustAllocation(a);
+ return super.modelToView(pos, newAlloc, bias);
}
public void paint(Graphics g, Shape s)
{
- super.paint(g, s);
+ Shape newAlloc = adjustAllocation(s);
+ super.paint(g, newAlloc);
+ }
+
+ public void insertUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ Shape newAlloc = adjustAllocation(shape);
+ super.insertUpdate(ev, newAlloc, vf);
+ }
+
+ public void removeUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ Shape newAlloc = adjustAllocation(shape);
+ super.removeUpdate(ev, newAlloc, vf);
}
+
+ public void changedUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ Shape newAlloc = adjustAllocation(shape);
+ super.removeUpdate(ev, newAlloc, vf);
+ }
+
}
diff --git a/javax/swing/text/GapContent.java b/javax/swing/text/GapContent.java
index a22aeed51..111617e94 100644
--- a/javax/swing/text/GapContent.java
+++ b/javax/swing/text/GapContent.java
@@ -40,8 +40,6 @@ package javax.swing.text;
import java.io.Serializable;
-// too lazy to make a real gapcontent.
-// lets just use a stringbuffer instead.
import javax.swing.undo.UndoableEdit;
/**
@@ -53,20 +51,41 @@ import javax.swing.undo.UndoableEdit;
* has to be shifted around when the insertion point moves (then the gap also
* moves and one array copy is necessary) or when the gap is filled up and
* the buffer has to be enlarged.
+ *
+ * TODO: Implement UndoableEdit support stuff
*/
public class GapContent
implements AbstractDocument.Content, Serializable
{
private static final long serialVersionUID = 8374645204155842629L;
-
- StringBuffer buf = new StringBuffer();
+
+ /**
+ * This is the default buffer size and the amount of bytes that
+ * a buffer is extended if it is full.
+ */
+ static final int DEFAULT_BUFSIZE = 64;
+
+ /**
+ * The text buffer.
+ */
+ char[] buffer;
+
+ /**
+ * The index of the first character of the gap.
+ */
+ int gapStart;
+
+ /**
+ * The index of the character after the last character of the gap.
+ */
+ int gapEnd;
/**
* Creates a new GapContent object.
*/
public GapContent()
{
- this(10);
+ this(DEFAULT_BUFSIZE);
}
/**
@@ -76,30 +95,33 @@ public class GapContent
*/
public GapContent(int size)
{
- buf.append("\n");
+ buffer = (char[]) allocateArray(size);
+ gapStart = 0;
+ gapEnd = size - 1;
+ buffer[size - 1] = '\n';
}
/**
- * Creates and returns a mark at the specified position.
- *
- * @param offset the position at which to create the mark
+ * Allocates an array of the specified length that can then be used as
+ * buffer.
*
- * @return the create Position object for the mark
+ * @param size the size of the array to be allocated
*
- * @throws BadLocationException if the offset is not a valid position in
- * the buffer
+ * @return the allocated array
*/
- public Position createPosition(final int offset) throws BadLocationException
+ protected Object allocateArray(int size)
{
- return new Position()
- {
- int off = offset;
+ return new char[size];
+ }
- public int getOffset()
- {
- return off;
- }
- };
+ /**
+ * Returns the length of the allocated buffer array.
+ *
+ * @return the length of the allocated buffer array
+ */
+ protected int getArrayLength()
+ {
+ return buffer.length;
}
/**
@@ -109,7 +131,7 @@ public class GapContent
*/
public int length()
{
- return buf.length();
+ return buffer.length - (gapEnd - gapStart);
}
/**
@@ -127,7 +149,27 @@ public class GapContent
public UndoableEdit insertString(int where, String str)
throws BadLocationException
{
- buf.insert(where, str);
+ // check arguments
+ int length = length();
+ int strLen = str.length();
+
+ if (where >= length)
+ throw new BadLocationException("the where argument cannot be greater"
+ + " than the content length", where);
+
+ // check if the gap is big enough to hold the string
+ if ((gapEnd - gapStart) < strLen)
+ // make room for this string and some more
+ shiftEnd(strLen + DEFAULT_BUFSIZE);
+
+ // are we at the gap boundary?
+ if (where != gapStart)
+ shiftGap(where);
+
+ // now we can simple copy the string into the gap and adjust the
+ // gap boundaries
+ System.arraycopy(str.toCharArray(), 0, buffer, gapStart, strLen);
+ gapStart += strLen;
return null;
}
@@ -146,7 +188,23 @@ public class GapContent
public UndoableEdit remove(int where, int nitems)
throws BadLocationException
{
- buf.delete(where, where + nitems);
+ // check arguments
+ int length = length();
+
+ if (where >= length)
+ throw new BadLocationException("the where argument cannot be greater"
+ + " than the content length", where);
+ if ((where + nitems) > length)
+ throw new BadLocationException("where + nitems cannot be greater"
+ + " than the content length",
+ where + nitems);
+
+ // check if we are at the gap boundary
+ if (where != gapStart)
+ shiftGap(where);
+
+ // now we simply have to enlarge the gap
+ gapEnd += nitems;
return null;
}
@@ -161,12 +219,18 @@ public class GapContent
*/
public String getString(int where, int len) throws BadLocationException
{
- return buf.substring(where, where+len);
+ Segment seg = new Segment();
+ getChars(where, len, seg);
+ return new String(seg.array, seg.offset, seg.count);
}
/**
* Fetches a piece of content and stores it in a {@link Segment} object.
*
+ * If the requested piece of text spans the gap, the content is copied
+ * into a new array. If it doesn't then it is contiguous and the
+ * actual content store is returned.
+ *
* @param where the start location of the fragment
* @param len the length of the fragment
* @param txt the Segment object to store the fragment in
@@ -177,11 +241,116 @@ public class GapContent
public void getChars(int where, int len, Segment txt)
throws BadLocationException
{
- txt.array = new char[len];
+ // check arguments
+ int length = length();
+ if (where >= length)
+ throw new BadLocationException("the where argument cannot be greater"
+ + " than the content length", where);
+ if ((where + len) > length)
+ throw new BadLocationException("len plus where cannot be greater"
+ + " than the content length",
+ len + where);
- System.arraycopy(buf.toString().toCharArray(), where, txt.array, 0, len);
+ // check if requested segment is contiguous
+ if ((where < gapStart) && ((gapStart - where) < len))
+ {
+ // requested segment is not contiguous -> copy the pieces together
+ char[] copy = new char[len];
+ int lenFirst = gapStart - where; // the length of the first segment
+ System.arraycopy(buffer, where, copy, 0, lenFirst);
+ System.arraycopy(buffer, gapEnd, copy, lenFirst, len - lenFirst);
+ txt.array = copy;
+ txt.offset = 0;
+ txt.count = len;
+ }
+ else
+ {
+ // requested segment is contiguous -> we can simply return the
+ // actual content
+ txt.array = buffer;
+ if (where < gapStart)
+ txt.offset = where;
+ else
+ txt.offset = where + (gapEnd - gapStart);
+ txt.count = len;
+ }
+ }
- txt.count = len;
- txt.offset = 0;
+ /**
+ * Creates and returns a mark at the specified position.
+ *
+ * @param offset the position at which to create the mark
+ *
+ * @return the create Position object for the mark
+ *
+ * @throws BadLocationException if the offset is not a valid position in
+ * the buffer
+ */
+ public Position createPosition(final int offset) throws BadLocationException
+ {
+ return new Position()
+ {
+ int off = offset;
+
+ public int getOffset()
+ {
+ return off;
+ }
+ };
+ }
+
+ /**
+ * Enlarges the gap. This allocates a new bigger buffer array, copy the
+ * segment before the gap as it is and the segment after the gap at
+ * the end of the new buffer array. This does change the gapEnd mark
+ * but not the gapStart mark.
+ *
+ * @param newSize the new size of the gap
+ */
+ protected void shiftEnd(int newSize)
+ {
+ char[] newBuf = (char[]) allocateArray(length() + newSize);
+ System.arraycopy(buffer, 0, newBuf, 0, gapStart);
+ System.arraycopy(buffer, gapEnd, newBuf, gapStart + newSize,
+ buffer.length - gapEnd);
+ gapEnd = gapStart + newSize;
+ buffer = newBuf;
+ }
+
+ /**
+ * Shifts the gap to the specified position.
+ *
+ * @param newGapStart the new start position of the gap
+ */
+ protected void shiftGap(int newGapStart)
+ {
+ int newGapEnd = newGapStart + (gapEnd - gapStart);
+
+ if (newGapStart == gapStart)
+ return;
+ else if (newGapStart < gapStart)
+ {
+ System.arraycopy(buffer, newGapStart, buffer, newGapEnd,
+ gapStart - newGapStart);
+ gapStart = newGapStart;
+ gapEnd = newGapEnd;
+ }
+ else
+ {
+ System.arraycopy(buffer, gapEnd, buffer, gapStart,
+ newGapStart - gapStart);
+ gapStart = newGapStart;
+ gapEnd = newGapEnd;
+ }
+ }
+
+ /**
+ * Returns the allocated buffer array.
+ *
+ * @return the allocated buffer array
+ */
+ protected Object getArray()
+ {
+ return buffer;
}
}
diff --git a/javax/swing/text/JTextComponent.java b/javax/swing/text/JTextComponent.java
index 6b464b5de..68b2161d1 100644
--- a/javax/swing/text/JTextComponent.java
+++ b/javax/swing/text/JTextComponent.java
@@ -895,30 +895,11 @@ public abstract class JTextComponent extends JComponent
private Insets margin;
private boolean dragEnabled;
- /** Issues repaint request on document changes. */
- private DocumentListener repaintListener;
-
/**
* Creates a new <code>JTextComponent</code> instance.
*/
public JTextComponent()
{
- repaintListener = new DocumentListener()
- {
- public void changedUpdate(DocumentEvent ev)
- {
- repaint();
- }
- public void insertUpdate(DocumentEvent ev)
- {
- repaint();
- }
- public void removeUpdate(DocumentEvent ev)
- {
- repaint();
- }
- };
-
Keymap defkeymap = getKeymap(DEFAULT_KEYMAP);
boolean creatingKeymap = false;
if (defkeymap == null)
@@ -929,6 +910,7 @@ public abstract class JTextComponent extends JComponent
}
setFocusable(true);
+ setEditable(true);
enableEvents(AWTEvent.KEY_EVENT_MASK);
updateUI();
@@ -952,13 +934,6 @@ public abstract class JTextComponent extends JComponent
{
Document oldDoc = doc;
doc = newDoc;
-
- // setup document listener
- if (oldDoc != null)
- oldDoc.removeDocumentListener(repaintListener);
- if (newDoc != null)
- newDoc.addDocumentListener(repaintListener);
-
firePropertyChange("document", oldDoc, newDoc);
revalidate();
repaint();
diff --git a/javax/swing/text/PlainDocument.java b/javax/swing/text/PlainDocument.java
index 64e9c8ab3..3a44725fc 100644
--- a/javax/swing/text/PlainDocument.java
+++ b/javax/swing/text/PlainDocument.java
@@ -47,7 +47,7 @@ public class PlainDocument extends AbstractDocument
public static final String lineLimitAttribute = "lineLimit";
public static final String tabSizeAttribute = "tabSize";
- private Element rootElement;
+ private BranchElement rootElement;
private int tabSize;
public PlainDocument()
@@ -59,7 +59,7 @@ public class PlainDocument extends AbstractDocument
{
super(content);
tabSize = 8;
- rootElement = createDefaultRoot();
+ rootElement = (BranchElement) createDefaultRoot();
}
private void reindex()
@@ -114,9 +114,43 @@ public class PlainDocument extends AbstractDocument
protected void removeUpdate(DefaultDocumentEvent event)
{
- reindex();
-
super.removeUpdate(event);
+
+ int p0 = event.getOffset();
+ int p1 = event.getLength() + p0;
+ int len = event.getLength();
+
+ // check if we must collapse some elements
+ int i1 = rootElement.getElementIndex(p0);
+ int i2 = rootElement.getElementIndex(p1);
+ if (i1 != i2)
+ {
+ Element el1 = rootElement.getElement(i1);
+ Element el2 = rootElement.getElement(i2);
+ int start = el1.getStartOffset();
+ int end = el2.getEndOffset();
+ // collapse elements if the removal spans more than 1 line
+ Element newEl = createLeafElement(rootElement,
+ SimpleAttributeSet.EMPTY,
+ start, end - len);
+ rootElement.replace(start, end - start, new Element[]{ newEl });
+ }
+ else
+ {
+ // otherwise only adjust indices of the element
+ LeafElement el1 = (LeafElement) rootElement.getElement(i1);
+ el1.end -= len;
+ }
+
+ // reindex remaining elements
+ for (int i = rootElement.getElementIndex(p0) + 1;
+ i < rootElement.getElementCount(); i++)
+ {
+ LeafElement el = (LeafElement) rootElement.getElement(i);
+ el.start -= len;
+ el.end -= len;
+ }
+
}
public Element getDefaultRootElement()
diff --git a/javax/swing/text/PlainView.java b/javax/swing/text/PlainView.java
index c852c1d69..cc58dd065 100644
--- a/javax/swing/text/PlainView.java
+++ b/javax/swing/text/PlainView.java
@@ -148,7 +148,7 @@ public class PlainView extends View
g.setColor(unselectedColor);
Segment segment = new Segment();
getDocument().getText(p0, p1 - p0, segment);
- return Utilities.drawTabbedText(segment, x, y, g, this, 0);
+ return Utilities.drawTabbedText(segment, x, y, g, this, segment.offset);
}
public void paint(Graphics g, Shape s)
@@ -200,7 +200,42 @@ public class PlainView extends View
if (axis != X_AXIS && axis != Y_AXIS)
throw new IllegalArgumentException();
- return 10;
+ // make sure we have the metrics
+ updateMetrics();
+
+ float span = 0;
+ Element el = getElement();
+ Document doc = el.getDocument();
+ Segment seg = new Segment();
+
+ switch (axis)
+ {
+ case X_AXIS:
+ // calculate the maximum of the line's widths
+ for (int i = 0; i < el.getElementCount(); i++)
+ {
+ Element child = el.getElement(i);
+ int start = child.getStartOffset();
+ int end = child.getEndOffset();
+ try {
+ doc.getText(start, start + end, seg);
+ }
+ catch (BadLocationException ex)
+ {
+ // throw new ClasspathAssertionError
+ // ("no BadLocationException should be thrown here");
+ }
+ int width = metrics.charsWidth(seg.array, seg.offset, seg.count);
+ span = Math.max(span, width);
+ }
+ break;
+ case Y_AXIS:
+ default:
+ span = metrics.getHeight() * el.getElementCount();
+ break;
+ }
+
+ return span;
}
}
diff --git a/javax/swing/text/Utilities.java b/javax/swing/text/Utilities.java
index c55f48e0a..79047014d 100644
--- a/javax/swing/text/Utilities.java
+++ b/javax/swing/text/Utilities.java
@@ -92,7 +92,7 @@ public class Utilities
int ascent = metrics.getAscent();
int pixelWidth = 0;
- int pos = 0;
+ int pos = s.offset;
int len = 0;
for (int offset = s.offset; offset < (s.offset + s.count); ++offset)
diff --git a/javax/swing/text/View.java b/javax/swing/text/View.java
index 46f42b503..760e3b0ae 100644
--- a/javax/swing/text/View.java
+++ b/javax/swing/text/View.java
@@ -40,9 +40,12 @@ package javax.swing.text;
import java.awt.Container;
import java.awt.Graphics;
+import java.awt.Rectangle;
import java.awt.Shape;
+import javax.swing.JComponent;
import javax.swing.SwingConstants;
+import javax.swing.event.DocumentEvent;
public abstract class View implements SwingConstants
{
@@ -59,6 +62,11 @@ public abstract class View implements SwingConstants
private View parent;
/**
+ * The child views.
+ */
+ View[] children;
+
+ /**
* Creates a new <code>View</code> instance.
*
* @param elem an <code>Element</code> value
@@ -66,6 +74,7 @@ public abstract class View implements SwingConstants
public View(Element elem)
{
elt = elem;
+ children = new View[0];
}
public abstract void paint(Graphics g, Shape s);
@@ -241,6 +250,8 @@ public abstract class View implements SwingConstants
{
if (parent != null)
parent.preferenceChanged(this, width, height);
+ else
+ ((JComponent) getContainer()).revalidate();
}
public int getBreakWeight(int axis, float pos, float len)
@@ -260,5 +271,193 @@ public abstract class View implements SwingConstants
{
return -1;
}
+
+ /**
+ * Receive notification about an insert update to the text model.
+ *
+ * The default implementation of this method does the following:
+ * <ul>
+ * <li>Call {@link #updateChildren} if the element that this view is
+ * responsible for has changed. This makes sure that the children can
+ * correctly represent the model.<li>
+ * <li>Call {@link #forwardUpdate}. This forwards the DocumentEvent to
+ * the child views.<li>
+ * <li>Call {@link #updateLayout}. Gives the view a chance to either
+ * repair its layout, reschedule layout or do nothing at all.</li>
+ * </ul>
+ *
+ * @param ev the DocumentEvent that describes the change
+ * @param shape the shape of the view
+ * @param vf the ViewFactory for creating child views
+ */
+ public void insertUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ Element el = getElement();
+ DocumentEvent.ElementChange ec = ev.getChange(el);
+ if (ec != null)
+ updateChildren(ec, ev, vf);
+ forwardUpdate(ec, ev, shape, vf);
+ updateLayout(ec, ev, shape);
+ }
+
+ /**
+ * Receive notification about a remove update to the text model.
+ *
+ * The default implementation of this method does the following:
+ * <ul>
+ * <li>Call {@link #updateChildren} if the element that this view is
+ * responsible for has changed. This makes sure that the children can
+ * correctly represent the model.<li>
+ * <li>Call {@link #forwardUpdate}. This forwards the DocumentEvent to
+ * the child views.<li>
+ * <li>Call {@link #updateLayout}. Gives the view a chance to either
+ * repair its layout, reschedule layout or do nothing at all.</li>
+ * </ul>
+ *
+ * @param ev the DocumentEvent that describes the change
+ * @param shape the shape of the view
+ * @param vf the ViewFactory for creating child views
+ */
+ public void removeUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ Element el = getElement();
+ DocumentEvent.ElementChange ec = ev.getChange(el);
+ if (ec != null)
+ updateChildren(ec, ev, vf);
+ forwardUpdate(ec, ev, shape, vf);
+ updateLayout(ec, ev, shape);
+ }
+
+ /**
+ * Receive notification about a change update to the text model.
+ *
+ * The default implementation of this method does the following:
+ * <ul>
+ * <li>Call {@link #updateChildren} if the element that this view is
+ * responsible for has changed. This makes sure that the children can
+ * correctly represent the model.<li>
+ * <li>Call {@link #forwardUpdate}. This forwards the DocumentEvent to
+ * the child views.<li>
+ * <li>Call {@link #updateLayout}. Gives the view a chance to either
+ * repair its layout, reschedule layout or do nothing at all.</li>
+ * </ul>
+ *
+ * @param ev the DocumentEvent that describes the change
+ * @param shape the shape of the view
+ * @param vf the ViewFactory for creating child views
+ */
+ public void changedUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ Element el = getElement();
+ DocumentEvent.ElementChange ec = ev.getChange(el);
+ if (ec != null)
+ updateChildren(ec, ev, vf);
+ forwardUpdate(ec, ev, shape, vf);
+ updateLayout(ec, ev, shape);
+ }
+
+ /**
+ * Updates the list of children that is returned by {@link #getView}
+ * and {@link #getViewCount}.
+ *
+ * Element that are specified as beeing added in the ElementChange record are
+ * assigned a view for using the ViewFactory. Views of Elements that
+ * are specified as beeing removed are removed from the list.
+ *
+ * @param ec the ElementChange record that describes the change of the
+ * element
+ * @param ev the DocumentEvent describing the change of the document model
+ * @param vf the ViewFactory to use for creating new views
+ *
+ * @return whether or not the child views represent the child elements of
+ * the element that this view is responsible for. Some views may
+ * create views that are responsible only for parts of the element
+ * that they are responsible for and should then return false.
+ *
+ * @since 1.3
+ */
+ protected boolean updateChildren(DocumentEvent.ElementChange ec,
+ DocumentEvent ev,
+ ViewFactory vf)
+ {
+ Element[] added = ec.getChildrenAdded();
+ Element[] removed = ec.getChildrenRemoved();
+ View[] newChildren = new View[children.length + added.length
+ - removed.length];
+ int index = ec.getIndex();
+ System.arraycopy(children, 0, newChildren, 0, index);
+ System.arraycopy(children, index, added, 0, added.length);
+ int index2 = index + removed.length;
+ int len2 = children.length - index2;
+ System.arraycopy(children, index2, newChildren, index + added.length,
+ len2);
+ children = newChildren;
+
+ return true;
+ }
+
+ /**
+ * Forwards the DocumentEvent to child views that need to get notified
+ * of the change to the model. This calles {@link #forwardUpdateToView}
+ * for each View that must be forwarded to.
+ *
+ * @param ec the ElementChange describing the element changes (may be
+ * <code>null</code> if there were no changes)
+ * @param ev the DocumentEvent describing the changes to the model
+ * @param shape the current allocation of the view
+ * @param vf the ViewFactory used to create new Views
+ *
+ * @since 1.3
+ */
+ protected void forwardUpdate(DocumentEvent.ElementChange ec,
+ DocumentEvent ev, Shape shape, ViewFactory vf)
+ {
+ for (int i = 0; i < children.length; i++)
+ {
+ View child = children[i];
+ forwardUpdateToView(child, ev, shape, vf);
+ }
+ }
+
+ /**
+ * Forwards an update event to the given child view. This calls
+ * {@link #insertUpdate}, {@link #removeUpdate} or {@link #changedUpdate},
+ * depending on the type of document event.
+ *
+ * @param view the View to forward the event to
+ * @param ev the DocumentEvent to forward
+ * @param shape the current allocation of the View
+ * @param vf the ViewFactory used to create new Views
+ *
+ * @since 1.3
+ */
+ protected void forwardUpdateToView(View view, DocumentEvent ev, Shape shape,
+ ViewFactory vf)
+ {
+ DocumentEvent.EventType type = ev.getType();
+ if (type == DocumentEvent.EventType.INSERT)
+ view.insertUpdate(ev, shape, vf);
+ else if (type == DocumentEvent.EventType.REMOVE)
+ view.removeUpdate(ev, shape, vf);
+ else if (type == DocumentEvent.EventType.CHANGE)
+ view.changedUpdate(ev, shape, vf);
+ }
+
+ /**
+ * Updates the layout.
+ *
+ * @param ec the ElementChange that describes the changes to the element
+ * @param ev the DocumentEvent that describes the changes to the model
+ * @param shape the current allocation for this view
+ *
+ * @since 1.3
+ */
+ protected void updateLayout(DocumentEvent.ElementChange ec,
+ DocumentEvent ev, Shape shape)
+ {
+ Rectangle b = shape.getBounds();
+ if (ec != null)
+ preferenceChanged(this, true, true);
+ }
}