jsxe-cvs Mailing List for jsXe (Page 8)
Status: Inactive
Brought to you by:
ian_lewis
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(29) |
Dec
(63) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(4) |
Feb
(23) |
Mar
(19) |
Apr
(102) |
May
(88) |
Jun
(30) |
Jul
(42) |
Aug
(43) |
Sep
(17) |
Oct
(19) |
Nov
(41) |
Dec
(46) |
2005 |
Jan
(32) |
Feb
(8) |
Mar
(110) |
Apr
(102) |
May
(139) |
Jun
(45) |
Jul
(5) |
Aug
(1) |
Sep
(9) |
Oct
(30) |
Nov
(18) |
Dec
|
2006 |
Jan
(10) |
Feb
(85) |
Mar
(9) |
Apr
(64) |
May
(24) |
Jun
(95) |
Jul
(107) |
Aug
(123) |
Sep
(37) |
Oct
(15) |
Nov
(1) |
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ian...@us...> - 2006-08-03 14:57:54
|
Revision: 1097 Author: ian_lewis Date: 2006-08-03 07:57:41 -0700 (Thu, 03 Aug 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1097&view=rev Log Message: ----------- Added russian translation Modified Paths: -------------- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java Added Paths: ----------- trunk/jsxe/messages/messages.ru Added: trunk/jsxe/messages/messages.ru =================================================================== --- trunk/jsxe/messages/messages.ru (rev 0) +++ trunk/jsxe/messages/messages.ru 2006-08-03 14:57:41 UTC (rev 1097) @@ -0,0 +1,287 @@ +# JSXE English properties file +# $Id: +# Maintained by Sagrer[GG] (sa...@ya...) +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1: + +#{{{ common properties + +common.ok=Принять +common.cancel=Отменить +common.open=Открыть +common.save=Сохранить +common.save.as=Сохранить как +common.close=Закрыть +common.apply=Применить +common.more=Еще +common.insert=Вставить +common.add=Добавить +common.remove=Удалить +common.moveUp=Поднять +common.moveDown=Опустить +common.cut=Вырезать +common.copy=Копировать +common.paste=Вставить +common.find=Искать... +common.findnext=Искать следующий + +common.ctrl=Ctrl +common.alt=Alt +common.shift=Shift +common.meta=Meta + +#}}} + +#{{{ XML Terminology + +#{{{ XML Node Types +xml.element=Элемент +xml.processing.instruction=Правило обработки +xml.cdata=Секция CDATA +xml.text=Текст +xml.entity.reference=Ссылка на сущность +xml.declaration=Объявление элемента +xml.notation=Замечание +xml.entity=Объявление сущности +xml.comment=Комментарий +xml.attribute=Свойство +xml.doctype=Тип документа +#}}} + +xml.attribute.value.short=Значение +xml.attribute.value=Значение свойства +xml.document=документ XML +xml.namespace=Пространство имен +xml.namespace.prefix=Префикс пространства имен +xml.namespace.prefix.short=Префикс +xml.namespace.decl=Объявление пространства имен +xml.doctypedef=Определение типа документа (DTD) +xml.doctype.name=Имя +xml.doctype.public=Публичный Id +xml.doctype.system=Системный Id +xml.schema=Схема XML +#}}} + +#{{{ Global Options +Global.Options.Dialog.Title=Глобальные опции +Global.Options.Title=Главное +Global.Options.Max.Recent.Files=Помнить ранее открытых файлов: +Global.Options.Max.Recent.Files.ToolTip=Максимальное количество ранее открытых файлов, про которые jsXe помнит и отображает в меню Файл->Ранее открытые файлы +Global.Options.network-off=Кешировать всегда, без спросу +Global.Options.network-cache=Кешировать удаленные файлы только спросив разрешения +Global.Options.network-always=Скачивать всегда, без спросу +Global.Options.network=Скачивание DTD и схемы: +Global.Options.Menu.Spill.Over=Меню выпадают после: + +Shortcuts.Options.Title=Горячие клавиши +Shortcuts.Options.Select.Label=Редактировать горячие клавиши: +Shortcuts.Options.Shortcut=Горячая клавиша +Shortcuts.Options.Command=Команда + +Grab.Key.title=Нажмите клавишу +Grab.Key.caption=Нажмите клавишу для команды "{0}", а котом нажмите Принять. +Grab.Key.keyboard-test=Input the key strokes that are causing problems. +Grab.Key.assigned-to=Уже назначено для: {0} +Grab.Key.assigned-to.none=<ничего> +Grab.Key.clear=Очистить +Grab.Key.remove=Удалить текущее + +Grab.Key.remove-ask.title=Удалить клавишу? +Grab.Key.remove-ask.message=\ + Вы не назначили новую клавишу.\n\ + Вы что, всеръез решили лишить команду клавиши, правда? + +Grab.Key.duplicate-alt-shortcut.title=Две команды на клавишу +Grab.Key.duplicate-alt-shortcut.message=\ + Клавиша которую вы назначили уже занята за другой командой\n\ + Просьба выбрать другую, ато они подерутся. + +Grab.Key.duplicate-shortcut.title=Две команды на клавишу +Grab.Key.duplicate-shortcut.message=\ + Эта клавиша уже занята за\n\ + "{0}".\n\ + \n\ + Вы хотите отвергнуть это назначение? +#}}} + +#{{{ Document Options +Document.Options.Title=Опции документа XML +Document.Options.Message=Этот диалог управляет настройками только\n текущего документа. Чтобы изменить\n базовые настройки лезте в\n Инструменты->Глобальные опции. +Document.Options.Line.Separator=Разделитель строк: +Document.Options.Line.Separator.ToolTip=Разделитель строк. По умолчанию выбирается традиционный для вашей операционной системы. +Document.Options.Encoding=Кодировка: +Document.Options.Encoding.ToolTip=Кодировка, которую jsXe использует для записи текстовой инфы в файл. +Document.Options.Indent.Width=Ширина отступа: +Document.Options.Indent.Width.ToolTip=Ширина используемая при форматировании и отображении символов табуляции. +Document.Options.Format.XML=Форматировать выводимый XML +Document.Options.Format.XML.ToolTip=Если это выбрано, XML будет форматироваться автоматически. +Document.Options.Validate=Подтв. если доступны DTD или Схема +Document.Options.Validate.ToolTip=Если это выбрано, jsXe будет подтверждать (проверять?) документ XML. +Document.Options.Soft.Tabs=Мягкие табуляции (эмуляция пробелами) +Document.Options.Soft.Tabs.ToolTip=Если это выбрано, символы табуляции будут заменены пробелами. +#}}} + +#{{{ Plugin Manager +Plugin.Manager.Title=Менеджер плагинов +Plugin.Manager.Name.Column.Header=Имя +Plugin.Manager.Version.Column.Header=Версия +Plugin.Manager.Status.Column.Header=Статус +Plugin.Manager.Loaded.Status=Загружен +Plugin.Manager.Not.Loaded.Status=Не загружен +Plugin.Manager.Broken.Status=Ошибка +#}}} + +#{{{ Menu Items + +File.Menu=Файл +Edit.Menu=Правка +View.Menu=Вид +Tools.Menu=Инструменты +Help.Menu=Справка + +#{{{ File Menu Items +new-file.label=Новый +open-file.label=Открыть... +File.Recent=Ранее открытые файлы +File.Recent.None=Нэма нифигга +save-file.label=Сохранить +save-as.label=Сохранить как... +reload-file.label=Открыть еще раз +close-file.label=Закрыть +close-all.label=Закрыть все +exit.label=Выход +#}}} + +general-options.label=Глобальные опции... +document-options.label=Опции документа... +plugin-manager.label=Менеджер плагинов... +validation-errors.label=Ошибки подтверждения... +about-jsxe.label=О программе jsXe... +#}}} + +#{{{ Messages + +DocumentView.Open.Message="Не могу открыть буффер в каком-либо из установленных document view-ов" + +#{0} file name +DocumentBuffer.Reload.Message={0} не сохранен!\n Вы потеряете все несохраненные изменения если продолжите!\n\n Продолжить? Вам не нужны эти несохраненные данные, в самом деле? +DocumentBuffer.Reload.Message.Title=Документ был изменен +DocumentBuffer.SaveAs.Message=Файл {0} уже существует. Записать новый файл поверх, зверски убив старый? +DocumentBuffer.SaveAs.Message.Title=Файл уже существует +DocumentBuffer.Close.Message={0} Не сохранен! Сохранить его прямо сейчас? +DocumentBuffer.Close.Message.Title=Несохраненные изменения + +#{0} file name +DocumentBuffer.Saved.Message={0} Сохранен +DocumentBuffer.Closed.Message={0} Закрыт +DocumentBuffer.Loaded.Message={0} Загружен +DocumentBuffer.Reloaded.Message={0} Загружен заново + +#{0} plugin name +DocumentView.Not.Found=Нету такого плагина со странным именем "{0}". + +#{{{ Plugin Load Messages + +# {0} plugin name +Plugin.Error.title=Ошибка плагина +Plugin.Error.List.message=Следующие плагины не могут быть загружены: +Plugin.Load.Already.Loaded=Плагин {0} уже загружен. +Plugin.Load.Wrong.Main.Class=Главный класс не является классом плагина. +Plugin.Load.No.Plugin.Class=Класс плагина не был определен. +Plugin.Load.No.Plugin.Name=Имя плагина не было определено. +Plugin.Load.No.Plugin.HR.Name=Для плагина не было определено такого имени,/n чтоб его мог прочитать нормальный человек (human-readable name). +Plugin.Load.No.Plugin.Version=Версия плагина не была определена. + +# {0} plugin name +# {1} requirement name +# {2} required version +# {3} found version +Plugin.Dependency.Message={0} требует {1} версии {2}, но обнаружена только версия {3}. +# {0} plugin name +# {1} requirement name +# {2} required version +Plugin.Dependency.Not.Found={0} требует {1} версии {2}, но {1} не удалось найти. +# {0} plugin name +# {1} requirement name +Plugin.Dependency.Not.Found2={0} требует {1} но {1} нигде не видать. +# {0} plugin name +# {1} invalid dependency +Plugin.Dependency.Invalid=У {0} есть неправильная зависимость: {1} +# {0} invalid version +Plugin.Dependency.Invalid.jsXe.Version=Неправильный номер версии jsXe: {0} +# {0} plugin name +# {1} requirement name +Plugin.Dependency.No.Version=Не могу загрузить плагин {0}, потому что у {1} не подписана версия. +# {0} plugin name +# {1} requirement name +Plugin.Dependency.Failed.Load={0} Требует плагин {1}, но этот самый {1} так и не удалось загрузить. + +#}}} + +#{{{ Error Messages +No.Xerces.Error.message={0} не обнаружен. jsXe требует Apache {0}. +No.Xerces.Error.title={0} не обнаружен. +IO.Error.title=ошибка ввода/вывода (I/O Error) +IO.Error.message=Произошла ошибка ввода/вывода +#}}} + +#}}} + +#{{{ Dialogs + +#{{{ Download resource dialog +xml.download-resource.title=Выкачиваем ресурсы с удаленного сервера... + +#{0} URL +xml.download-resource.message=Этот XML-файл зависит от ресурсов, которые расколожены\n\ + по следующему адресу в интернете:\n\ + \n\ + {0}\n\ + \n\ + Хотите ли вы чтобы плагин XML скачал ресурсы и закешировал их\n\ + для последующего использования?\n\ + \n\ + Если вы хотите соизволить разрешить мне скачивать ресурсы без спросу,\n\ + то отключите кеширование ресурсов в глобальных опциях jsXe. +#}}} + +#{{{ Dirty Files Dialog +DirtyFilesDialog.Dialog.Title=Несохраненные изменения +DirtyFilesDialog.Dialog.Message=В следующих файлах есть несохраненные изменения: +DirtyFilesDialog.Button.SelectAll.Title=Выбрать все +#DirtyFilesDialog.Button.SelectAll.ToolTip=Взять их фсехх! +DirtyFilesDialog.Button.SaveSelected.Title=Сохранить выбранные +#DirtyFilesDialog.Button.SaveSelected.ToolTip=Сохраняет, что тут еще можно сказать... те что выбраны, да... +DirtyFilesDialog.Button.DiscardSelected.Title=Убрать выделение +#DirtyFilesDialog.Button.DiscardSelected.ToolTip=Убирает выделение ;) +#}}} + +#{{{ Activity Log Dialog +activity-log.label = Лог активности +ActivityLogDialog.Dialog.Title = Лог активности +ActivityLogDialog.Dialog.Message = Содержимое лога активности: +#}}} + +#{{{ About dialag +about.title=О программе jsXe +about.message=Распространяется на условиях GNU General Public License\n\n\ + Активные разработчики:\n\ + \ \ \ \ Ian Lewis <Ian...@me...>\n\ + \ \ \ \ Trish Hartnett <tri...@us...>\n\n\ + Переводчики:\n\ + \ \ \ \ German (de) - Bianca Sh\u00f6en\n\ + \ \ \ \ Swedish (sv) - Patrik Johansson <pa...@it...>\n\n\ + В прошлом учавствовали в разработке:\n\ + \ \ \ \ Aaron Flatten <afl...@us...>\n\ + \ \ \ \ Bilel Remmache <rb...@us...>\n\ + \ \ \ \ SVM <svm...@us...>\n\n\ + Страница проекта: http://jsxe.sourceforge.net/ +#}}} + +#{{{ Validation Errors Dialog +ValidationErrors.title=Ошибки подтверждения +ValidationErrors.message=Ошибки подтверждения +#}}} + +#}}} Property changes on: trunk/jsxe/messages/messages.ru ___________________________________________________________________ Name: svn:executable + * Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-08-03 14:53:19 UTC (rev 1096) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-08-03 14:57:41 UTC (rev 1097) @@ -3,10 +3,6 @@ :tabSize=4:indentSize=4:noTabs=true: :folding=explicit:collapseFolds=1: -jsXe is the Java Simple XML Editor -jsXe is a gui application that creates a tree view of an XML document. -The user can then edit this tree and the content in the tree. - Copyright (C) 2006 Ian Lewis (Ian...@me...) This program is free software; you can redistribute it and/or Modified: trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java 2006-08-03 14:53:19 UTC (rev 1096) +++ trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java 2006-08-03 14:57:41 UTC (rev 1097) @@ -3,9 +3,9 @@ :tabSize=4:indentSize=4:noTabs=true: :folding=explicit:collapseFolds=1: - * Copyright (C) 2001, 2003 Slava Pestov - * Portions Copyright (C) 2002 Chris Stevenson - * Portions Copyright (C) 2005 Ian Lewis (Ian...@me...) +Copyright (C) 2001, 2003 Slava Pestov +Portions Copyright (C) 2002 Chris Stevenson +Portions Copyright (C) 2005 Ian Lewis (Ian...@me...) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-08-03 14:53:28
|
Revision: 1096 Author: ian_lewis Date: 2006-08-03 07:53:19 -0700 (Thu, 03 Aug 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1096&view=rev Log Message: ----------- removed code for persistant markers Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-08-01 05:12:24 UTC (rev 1095) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-08-03 14:53:19 UTC (rev 1096) @@ -121,10 +121,6 @@ this.session = session; this.vfs = vfs; this.path = path; - - markersPath = vfs.getParentOfPath(path) - + '.' + vfs.getFileName(path) - + ".marks"; } //}}} //{{{ run() method @@ -179,7 +175,6 @@ private Object session; private VFS vfs; private String path; - private String markersPath; //}}} //{{{ load() method @@ -247,21 +242,6 @@ buffer.setBooleanProperty(ERROR_OCCURRED,true); } - - // if (jEdit.getBooleanProperty("persistentMarkers")) { - // try { - // String[] args = { vfs.getFileName(path) }; - // if (!buffer.isTemporary()) { - // setStatus(jEdit.getProperty("vfs.status.load-markers",args)); - // } - // setAbortable(true); - // in = vfs._createInputStream(session,markersPath,true,view); - // if(in != null) - // readMarkers(buffer,in); - // } catch(IOException io) { - // // ignore - // } - // } } catch(WorkThread.Abort a) { if (in != null) { try { @@ -274,13 +254,13 @@ } finally { try { vfs._endVFSSession(session,view); - } catch(IOException io) { + } catch (IOException io) { Log.log(Log.ERROR,this,io); String[] pp = { io.toString() }; VFSManager.error(view,path,"IO.Error.Read.Error",pp); buffer.setBooleanProperty(ERROR_OCCURRED,true); - } catch(WorkThread.Abort a) { + } catch (WorkThread.Abort a) { buffer.setBooleanProperty(ERROR_OCCURRED,true); } } @@ -397,8 +377,7 @@ // only true if the file size is known boolean trackProgress = (!buffer.isTemporary() && length != 0); - if(trackProgress) - { + if (trackProgress) { setProgressValue(0); setProgressMaximum((int)length); } @@ -538,20 +517,23 @@ setAbortable(false); String lineSeparator; - if(seg.count == 0) - { - // fix for "[ 865589 ] 0-byte files should open using + if(seg.count == 0) { + // 0-byte files should open using // the default line seperator" - lineSeparator = jEdit.getProperty( - "buffer.lineSeparator", + lineSeparator = jsXe.getProperty( + "xml.document."+XMLDocumen.LINE_SEPARATOR, System.getProperty("line.separator")); + } else { + if (CRLF) { + lineSeparator = "\r\n"; + } else { + if(CROnly) { + lineSeparator = "\r"; + } else { + lineSeparator = "\n"; + } + } } - else if(CRLF) - lineSeparator = "\r\n"; - else if(CROnly) - lineSeparator = "\r"; - else - lineSeparator = "\n"; in.close(); @@ -596,37 +578,6 @@ return seg; } //}}} - //{{{ readMarkers() method - private void readMarkers(Buffer buffer, InputStream _in) - throws IOException - { - // For `reload' command - buffer.removeAllMarkers(); - - BufferedReader in = new BufferedReader(new InputStreamReader(_in)); - - try - { - String line; - while((line = in.readLine()) != null) - { - // compatibility kludge for jEdit 3.1 and earlier - if(!line.startsWith("!")) - continue; - - char shortcut = line.charAt(1); - int start = line.indexOf(';'); - int end = line.indexOf(';',start + 1); - int position = Integer.parseInt(line.substring(start + 1,end)); - buffer.addMarker(shortcut,position); - } - } - finally - { - in.close(); - } - } //}}} - //{{{ save() method private void save() { @@ -694,23 +645,6 @@ if(!vfs._rename(session,savePath,path,view)) throw new IOException("Rename failed: " + savePath); } - - // We only save markers to VFS's that support deletion. - // Otherwise, we will accumilate stale marks files. - if((vfs.getCapabilities() & VFS.DELETE_CAP) != 0) - { - if(jEdit.getBooleanProperty("persistentMarkers") - && buffer.getMarkers().size() != 0) - { - setStatus(jEdit.getProperty("vfs.status.save-markers",args)); - setProgressValue(0); - out = vfs._createOutputStream(session,markersPath,view); - if(out != null) - writeMarkers(buffer,out); - } - else - vfs._delete(session,markersPath,view); - } } else buffer.setBooleanProperty(ERROR_OCCURRED,true); @@ -883,34 +817,6 @@ } } //}}} - //{{{ writeMarkers() method - private void writeMarkers(Buffer buffer, OutputStream out) - throws IOException - { - Writer o = new BufferedWriter(new OutputStreamWriter(out)); - try - { - Vector markers = buffer.getMarkers(); - for(int i = 0; i < markers.size(); i++) - { - Marker marker = (Marker)markers.elementAt(i); - o.write('!'); - o.write(marker.getShortcut()); - o.write(';'); - - String pos = String.valueOf(marker.getPosition()); - o.write(pos); - o.write(';'); - o.write(pos); - o.write('\n'); - } - } - finally - { - o.close(); - } - } //}}} - //{{{ insert() method private void insert() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-08-01 05:12:36
|
Revision: 1095 Author: ian_lewis Date: 2006-07-31 22:12:24 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1095&view=rev Log Message: ----------- Added planned feature for the help system Modified Paths: -------------- trunk/web/htdocs/features.php Modified: trunk/web/htdocs/features.php =================================================================== --- trunk/web/htdocs/features.php 2006-08-01 05:09:16 UTC (rev 1094) +++ trunk/web/htdocs/features.php 2006-08-01 05:12:24 UTC (rev 1095) @@ -72,6 +72,7 @@ <li>Support for Unlimited Undo (version 0.5 beta)</li> <li>Tag completion using DTD/Schema introspection (version 0.5 beta)</li> <li>Automatic insertion of closing tags (version 0.5 beta)</li> + <li>A help system using <a href="http://aurigadoc.sourceforge.net/">AurigaDoc</a></li> </ul> <?php include("footer.php") ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-08-01 05:09:30
|
Revision: 1094 Author: ian_lewis Date: 2006-07-31 22:09:16 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1094&view=rev Log Message: ----------- Fixed some typos Modified Paths: -------------- trunk/web/htdocs/get-involved.php Modified: trunk/web/htdocs/get-involved.php =================================================================== --- trunk/web/htdocs/get-involved.php 2006-07-29 15:52:20 UTC (rev 1093) +++ trunk/web/htdocs/get-involved.php 2006-08-01 05:09:16 UTC (rev 1094) @@ -28,7 +28,7 @@ <p>If you are interested in working on jsXe, please <a href="http://lists.sourceforge.net/mailman/listinfo/jsxe-devel">subscribe</a> and send a mail to the jsxe-devel mailing list. The developers can help - get you started. Developers should be know how to use SVN and have some + get you started. Developers should know how to use SVN and have some experience with Java swing or XML.</p> <h3>Translators</h3> @@ -39,7 +39,7 @@ knowlegeable of SVN, you can check out the messages files from jsXe's <a href="http://svn.sourceforge.net/viewcvs.cgi/jsxe/trunk/jsxe/">SVN repository</a>. But even if you are not versed in SVN, the developers on the - mailing list can help get you.</p> + mailing list can help get you started.</p> <h3>Web Developers</h3> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-29 15:52:34
|
Revision: 1093 Author: ian_lewis Date: 2006-07-29 08:52:20 -0700 (Sat, 29 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1093&view=rev Log Message: ----------- Added some more code for multi-threaded io Modified Paths: -------------- branches/jsxe2/Changelog branches/jsxe2/messages/messages branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java branches/jsxe2/src/net/sourceforge/jsxe/gui/ErrorListDialog.java branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java branches/jsxe2/src/net/sourceforge/jsxe/properties Added Paths: ----------- branches/jsxe2/src/net/sourceforge/jsxe/gui/ErrorListCellRenderer.java Modified: branches/jsxe2/Changelog =================================================================== --- branches/jsxe2/Changelog 2006-07-29 06:24:45 UTC (rev 1092) +++ branches/jsxe2/Changelog 2006-07-29 15:52:20 UTC (rev 1093) @@ -1,3 +1,7 @@ +07/29/2006 Ian Lewis <Ian...@me...> + + * Added some more code for multi-threaded IO support. + 07/28/2006 Ian Lewis <Ian...@me...> * Added some multi-threaded support. Modified: branches/jsxe2/messages/messages =================================================================== --- branches/jsxe2/messages/messages 2006-07-29 06:24:45 UTC (rev 1092) +++ branches/jsxe2/messages/messages 2006-07-29 15:52:20 UTC (rev 1093) @@ -185,6 +185,8 @@ DocumentBuffer.Loaded.Message={0} Loaded DocumentBuffer.Reloaded.Message={0} Reloaded +DocumentBuffer.Loading.Message=Loading {0} + #{0} plugin name DocumentView.Not.Found=No plugin a with name of {0} exists. @@ -229,8 +231,21 @@ #{{{ Error Messages No.Xerces.Error.message={0} not found. jsXe requires Apache {0}. No.Xerces.Error.title={0} not found. + +IO.Error.caption=The following {0} I/O operations could not be completed: +IO.Error.caption-1=The following {0} I/O operation could not be completed: + +IO.Error.Encoding.Error=Cannot load with "{0}" encoding.\n\ + ({1})\n\ + Try selecting a different encoding. +IO.Error.Read.Error=Cannot load: {0} +IO.Error.Write.Error=Cannot save: {0} + IO.Error.title=I/O Error IO.Error.message=An I/O error has occurred + +Out.Of.Memory.Error=There was insufficent Java heap memory to complete\n\ + this request. Try increasing the maximum heap size. #}}} #}}} Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 06:24:45 UTC (rev 1092) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 15:52:20 UTC (rev 1093) @@ -69,6 +69,7 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id: XMLDocument.java 999 2006-07-07 20:59:23Z ian_lewis $ * @see XMLNode + * @since jsXe 0.5 pre3 */ public class XMLDocument { Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-07-29 06:24:45 UTC (rev 1092) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-07-29 15:52:20 UTC (rev 1093) @@ -38,7 +38,9 @@ /** * A document I/O request. * @author Slava Pestov + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ + * @since jsXe 0.5 pre3 */ public class XMLDocumentIORequest extends WorkRequest { @@ -192,14 +194,14 @@ setAbortable(true); if (!buffer.isTemporary()) { - setStatus(jEdit.getProperty("vfs.status.load",args)); + setStatus(Messages.getMessage("DocumentBuffer.Loading.Message",args)); setProgressValue(0); } path = vfs._canonPath(session,path,view); - VFS.DirectoryEntry entry = vfs._getDirectoryEntry( - session,path,view); + VFS.DirectoryEntry entry = vfs._getDirectoryEntry(session,path,view); + long length; if (entry != null) { length = entry.length; @@ -214,11 +216,13 @@ read(autodetect(in),length,false); buffer.setNewFile(false); + } catch(CharConversionException ch) { Log.log(Log.ERROR,this,ch); - Object[] pp = { buffer.getProperty(Buffer.ENCODING), - ch.toString() }; - VFSManager.error(view,path,"ioerror.encoding-error",pp); + + Object[] pp = { buffer.getProperty(Buffer.ENCODING), ch.toString() }; + + VFSManager.error(view,path,"IO.Error.Encoding.Error",pp); buffer.setBooleanProperty(ERROR_OCCURRED,true); @@ -226,39 +230,38 @@ Log.log(Log.ERROR,this,uu); Object[] pp = { buffer.getProperty(Buffer.ENCODING), uu.toString() }; - VFSManager.error(view,path,"ioerror.encoding-error",pp); + VFSManager.error(view,path,"IO.Error.Encoding.Error",pp); buffer.setBooleanProperty(ERROR_OCCURRED,true); } catch(IOException io) { Log.log(Log.ERROR,this,io); Object[] pp = { io.toString() }; - VFSManager.error(view,path,"ioerror.read-error",pp); + VFSManager.error(view,path,"IO.Error.Read.Error",pp); buffer.setBooleanProperty(ERROR_OCCURRED,true); } catch(OutOfMemoryError oom) { Log.log(Log.ERROR,this,oom); - VFSManager.error(view,path,"out-of-memory-error",null); + VFSManager.error(view,path,"Out.Of.Memory.Error",null); buffer.setBooleanProperty(ERROR_OCCURRED,true); } - if (jEdit.getBooleanProperty("persistentMarkers")) { - try { - String[] args = { vfs.getFileName(path) }; - if (!buffer.isTemporary()) { - setStatus(jEdit.getProperty("vfs.status.load-markers",args)); - } - setAbortable(true); - - in = vfs._createInputStream(session,markersPath,true,view); - if(in != null) - readMarkers(buffer,in); - } catch(IOException io) { - // ignore - } - } + // if (jEdit.getBooleanProperty("persistentMarkers")) { + // try { + // String[] args = { vfs.getFileName(path) }; + // if (!buffer.isTemporary()) { + // setStatus(jEdit.getProperty("vfs.status.load-markers",args)); + // } + // setAbortable(true); + // in = vfs._createInputStream(session,markersPath,true,view); + // if(in != null) + // readMarkers(buffer,in); + // } catch(IOException io) { + // // ignore + // } + // } } catch(WorkThread.Abort a) { if (in != null) { try { @@ -274,7 +277,7 @@ } catch(IOException io) { Log.log(Log.ERROR,this,io); String[] pp = { io.toString() }; - VFSManager.error(view,path,"ioerror.read-error",pp); + VFSManager.error(view,path,"IO.Error.Read.Error",pp); buffer.setBooleanProperty(ERROR_OCCURRED,true); } catch(WorkThread.Abort a) { @@ -338,8 +341,7 @@ { // do not reset the stream and just treat it // like a normal UTF-8 file. - buffer.setProperty(Buffer.ENCODING, - MiscUtilities.UTF_8_Y); + buffer.setProperty(XMLDocument.ENCODING, MiscUtilities.UTF_8_Y); encoding = "UTF-8"; } else { @@ -356,8 +358,8 @@ break; } - String xmlPI = new String(_xmlPI,0,offset, - "ASCII"); + String xmlPI = new String(_xmlPI,0,offset, "ASCII"); + if (xmlPI.startsWith("<?xml")) { int index = xmlPI.indexOf("encoding="); if (index != -1 && index + 9 != xmlPI.length()) { @@ -366,7 +368,7 @@ encoding = xmlPI.substring(index + 10,endIndex); if (MiscUtilities.isSupportedEncoding(encoding)) { - buffer.setProperty(Buffer.ENCODING,encoding); + buffer.setProperty(XMLDocument.ENCODING, encoding); } else { Log.log(Log.WARNING,this,"XML PI specifies unsupported encoding: " + encoding); } Added: branches/jsxe2/src/net/sourceforge/jsxe/gui/ErrorListCellRenderer.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/gui/ErrorListCellRenderer.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/gui/ErrorListCellRenderer.java 2006-07-29 15:52:20 UTC (rev 1093) @@ -0,0 +1,117 @@ +/* +ErrorListCellRenderer.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2001 Slava Pestov +Portions Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.gui; + +//{{{ Imports +import javax.swing.*; +import javax.swing.border.*; +import java.awt.*; +//}}} + +/** + * @author Slava Pestov + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @since jsXe 0.5 pre3 + */ +public class ErrorListCellRenderer extends JComponent implements ListCellRenderer { + + //{{{ ErrorListCellRenderer constructor + ErrorListCellRenderer() { + // GTK look and feel issues + plainFont = new JLabel().getFont(); + //UIManager.getFont("Label.font"); + boldFont = new Font(plainFont.getName(),Font.BOLD,plainFont.getSize()); + plainFM = getFontMetrics(plainFont); + boldFM = getFontMetrics(boldFont); + + setBorder(new EmptyBorder(2,2,2,2)); + } //}}} + + //{{{ getListCellRendererComponent() method + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) + { + if (value instanceof ErrorListDialog.ErrorEntry) { + ErrorListDialog.ErrorEntry entry = (ErrorListDialog.ErrorEntry)value; + this.path = entry.path + ":"; + this.messages = entry.messages; + } else { + this.path = null; + this.messages = new String[] { value.toString() }; + } + + + return this; + } //}}} + + //{{{ getPreferredSize() method + public Dimension getPreferredSize() { + + int width = 0; + if (path != null) { + width = boldFM.stringWidth(path); + } + int height = boldFM.getHeight(); + for (int i = 0; i < messages.length; i++) { + width = Math.max(plainFM.stringWidth(messages[i]),width); + height += plainFM.getHeight(); + } + + Insets insets = getBorder().getBorderInsets(this); + width += insets.left + insets.right; + height += insets.top + insets.bottom; + + return new Dimension(width,height); + } //}}} + + //{{{ paintComponent() method + public void paintComponent(Graphics g) { + + Insets insets = getBorder().getBorderInsets(this); + int y = insets.top; + if (path != null) { + g.setFont(boldFont); + g.drawString(path,insets.left,insets.top + boldFM.getAscent()); + y = insets.top + boldFM.getHeight() + 2; + } + + g.setFont(plainFont); + for (int i = 0; i < messages.length; i++) { + g.drawString(messages[i],insets.left,y + plainFM.getAscent()); + y += plainFM.getHeight(); + } + } //}}} + + //{{{ Instance variables + private String path; + private String[] messages; + private Font plainFont; + private Font boldFont; + private FontMetrics plainFM; + private FontMetrics boldFM; + //}}} +} Modified: branches/jsxe2/src/net/sourceforge/jsxe/gui/ErrorListDialog.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/gui/ErrorListDialog.java 2006-07-29 06:24:45 UTC (rev 1092) +++ branches/jsxe2/src/net/sourceforge/jsxe/gui/ErrorListDialog.java 2006-07-29 15:52:20 UTC (rev 1093) @@ -44,79 +44,126 @@ */ public class ErrorListDialog extends EnhancedDialog { - //{{{ ErrorListDialog constructor - /** - * Creates a new ErrorListDialog. - * @param frame the parent component of this dialog - * @param title the title of the dialog - * @param caption the caption displayed on the dialog. - * @param messages a Vector containing objects used as error messages - * @param modal whether the dialog is modal - */ - public ErrorListDialog(Frame frame, String title, String caption, Vector messages, boolean modal) { - super(frame,title,modal); + //{{{ ErrorEntry class + public static class ErrorEntry { + + String path; + String[] messages; - JPanel content = new JPanel(new BorderLayout(12,12)); - content.setBorder(new EmptyBorder(12,12,12,12)); - setContentPane(content); + public ErrorEntry(String path, String messageProp, Object[] args) { + + this.path = path; - Box iconBox = new Box(BoxLayout.Y_AXIS); - iconBox.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon"))); - iconBox.add(Box.createGlue()); - content.add(BorderLayout.WEST,iconBox); + String message = Messages.getMessage(messageProp,args); + if (message == null) { + message = "Undefined property: " + messageProp; + } - JPanel centerPanel = new JPanel(new BorderLayout()); + Log.log(Log.ERROR,this,path + ":"); + Log.log(Log.ERROR,this,message); - JLabel label = new JLabel(caption); - label.setBorder(new EmptyBorder(0,0,6,0)); - centerPanel.add(BorderLayout.NORTH,label); + Vector tokenizedMessage = new Vector(); + int lastIndex = -1; + for (int i = 0; i < message.length(); i++) { + + if (message.charAt(i) == '\n') { + tokenizedMessage.addElement(message.substring(lastIndex + 1,i)); + lastIndex = i; + } + } - JList errors = new JList(messages); - // errors.setCellRenderer(new ErrorListCellRenderer()); - errors.setVisibleRowCount(Math.min(Math.max(messages.size(),4),10)); + if (lastIndex != message.length()) { + tokenizedMessage.addElement(message.substring( + lastIndex + 1)); + } - // need this bullshit scroll bar policy for the preferred size - // hack to work - JScrollPane scrollPane = new JScrollPane(errors, - JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - Dimension size = scrollPane.getPreferredSize(); - size.width = Math.max(size.width,400); - scrollPane.setPreferredSize(size); + messages = new String[tokenizedMessage.size()]; + tokenizedMessage.copyInto(messages); + } - centerPanel.add(BorderLayout.CENTER,scrollPane); + public boolean equals(Object o) { + if (o instanceof ErrorEntry) { + ErrorEntry e = (ErrorEntry)o; + return e.path.equals(path); + } else { + return false; + } + } + } //}}} + + //{{{ ErrorListDialog constructor + /** + * Creates a new ErrorListDialog. + * @param frame the parent component of this dialog + * @param title the title of the dialog + * @param caption the caption displayed on the dialog. + * @param messages a Vector containing ErrorEntry objects used as error messages + * @param modal whether the dialog is modal + */ + public ErrorListDialog(Frame frame, String title, String caption, Vector messages, boolean modal) { + super(frame,title,modal); - content.add(BorderLayout.CENTER,centerPanel); + JPanel content = new JPanel(new BorderLayout(12,12)); + content.setBorder(new EmptyBorder(12,12,12,12)); + setContentPane(content); - Box buttons = new Box(BoxLayout.X_AXIS); - buttons.add(Box.createGlue()); + Box iconBox = new Box(BoxLayout.Y_AXIS); + iconBox.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon"))); + iconBox.add(Box.createGlue()); + content.add(BorderLayout.WEST,iconBox); - ok = new JButton("OK"); - ok.addActionListener(new ActionHandler()); + JPanel centerPanel = new JPanel(new BorderLayout()); - buttons.add(ok); + JLabel label = new JLabel(caption); + label.setBorder(new EmptyBorder(0,0,6,0)); + centerPanel.add(BorderLayout.NORTH,label); - buttons.add(Box.createGlue()); - content.add(BorderLayout.SOUTH,buttons); + JList errors = new JList(messages); + errors.setCellRenderer(new ErrorListCellRenderer()); + errors.setVisibleRowCount(Math.min(Math.max(messages.size(),4),10)); - getRootPane().setDefaultButton(ok); + // need this bullshit scroll bar policy for the preferred size + // hack to work + JScrollPane scrollPane = new JScrollPane(errors, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + Dimension size = scrollPane.getPreferredSize(); + size.width = Math.max(size.width,400); + scrollPane.setPreferredSize(size); - pack(); - setLocationRelativeTo(frame); - setVisible(true); - } //}}} + centerPanel.add(BorderLayout.CENTER,scrollPane); - //{{{ ok() method - public void ok() { - dispose(); - } //}}} + content.add(BorderLayout.CENTER,centerPanel); - //{{{ cancel() method - public void cancel(){ - dispose(); - } //}}} + Box buttons = new Box(BoxLayout.X_AXIS); + buttons.add(Box.createGlue()); - //{{{ Private members + ok = new JButton("OK"); + ok.addActionListener(new ActionHandler()); + + buttons.add(ok); + + buttons.add(Box.createGlue()); + content.add(BorderLayout.SOUTH,buttons); + + getRootPane().setDefaultButton(ok); + + pack(); + setLocationRelativeTo(frame); + setVisible(true); + } //}}} + + //{{{ ok() method + public void ok() { + dispose(); + } //}}} + + //{{{ cancel() method + public void cancel(){ + dispose(); + } //}}} + + //{{{ Private members private JButton ok; //{{{ ActionHandler class Modified: branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-07-29 06:24:45 UTC (rev 1092) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-07-29 15:52:20 UTC (rev 1093) @@ -4,7 +4,7 @@ :folding=explicit:collapseFolds=1: Copyright (C) 2000, 2003 Slava Pestov -Portions Copyright (C) 2004 Ian Lewis (Ian...@me...) +Portions Copyright (C) 2006 Ian Lewis (Ian...@me...) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -58,6 +58,7 @@ * @author Slava Pestov * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ + * @since jsXe 0.5 pre3 */ public class VFSManager { /** @@ -69,13 +70,11 @@ /** * Do not call. */ - public static void init() - { - int count = jEdit.getIntegerProperty("ioThreadCount",4); - ioThreadPool = new WorkThreadPool("jEdit I/O",count); + public static void init() { + int count = jsXe.getIntegerProperty("ioThreadCount", 4); + ioThreadPool = new WorkThreadPool("jsXe I/O",count); JARClassLoader classLoader = new JARClassLoader(); - for(int i = 0; i < ioThreadPool.getThreadCount(); i++) - { + for (int i = 0; i < ioThreadPool.getThreadCount(); i++) { ioThreadPool.getThread(i).setContextClassLoader( classLoader); } @@ -85,8 +84,7 @@ /** * Do not call. */ - public static void start() - { + public static void start() { ioThreadPool.start(); } //}}} @@ -96,8 +94,7 @@ /** * Returns the local filesystem VFS. */ - public static VFS getFileVFS() - { + public static VFS getFileVFS() { return fileVFS; } //}}} @@ -105,8 +102,7 @@ /** * Returns the URL VFS. */ - public static VFS getUrlVFS() - { + public static VFS getUrlVFS() { return urlVFS; } //}}} @@ -269,41 +265,6 @@ //{{{ error() method /** - * @deprecated Call the other <code>error()</code> method instead. - */ - public static void error(final Component comp, final String error, final Object[] args) - { - // if we are already in the AWT thread, take a shortcut - if(SwingUtilities.isEventDispatchThread()) - { - GUIUtilities.error(comp,error,args); - return; - } - - // the 'error' chicanery ensures that stuff like: - // VFSManager.waitForRequests() - // if(VFSManager.errorOccurred()) - // ... - // will work (because the below runnable will only be - // executed in the next event) - VFSManager.error = true; - - runInAWTThread(new Runnable() - { - public void run() - { - VFSManager.error = false; - - if(comp == null || !comp.isShowing()) - GUIUtilities.error(null,error,args); - else - GUIUtilities.error(comp,error,args); - } - }); - } //}}} - - //{{{ error() method - /** * Reports an I/O error. * * @param comp The component @@ -318,31 +279,27 @@ { final Frame frame = JOptionPane.getFrameForComponent(comp); - synchronized(errorLock) - { + synchronized(errorLock) { + error = true; - errors.addElement(new ErrorListDialog.ErrorEntry( - path,messageProp,args)); + errors.addElement(new ErrorListDialog.ErrorEntry(path, messageProp, args)); - if(errors.size() == 1) - { + if (errors.size() == 1) { - VFSManager.runInAWTThread(new Runnable() - { - public void run() - { - String caption = jEdit.getProperty( - "ioerror.caption" + (errors.size() == 1 - ? "-1" : ""),new Integer[] { - new Integer(errors.size()) }); + VFSManager.runInAWTThread(new Runnable() { + public void run() { + String caption = Messages.getMessage("IO.Error.caption" + (errors.size() == 1 ? "-1" : ""), + new Integer[] { new Integer(errors.size()) }); + new ErrorListDialog( frame.isShowing() ? frame - : jEdit.getFirstView(), - jEdit.getProperty("ioerror.title"), + : jsXe.getActiveView(), + Messages.getMessage("IO.Error.title"), caption,errors,false); + errors.removeAllElements(); error = false; } Modified: branches/jsxe2/src/net/sourceforge/jsxe/properties =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/properties 2006-07-29 06:24:45 UTC (rev 1092) +++ branches/jsxe2/src/net/sourceforge/jsxe/properties 2006-07-29 15:52:20 UTC (rev 1093) @@ -13,6 +13,8 @@ # Resource Cache xml.cache=true +ioThreadCount=4 + #{{{ Plugin Manager Default Dimensions #pluginmgr.x=100 #pluginmgr.y=100 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-29 06:24:50
|
Revision: 1092 Author: ian_lewis Date: 2006-07-28 23:24:45 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1092&view=rev Log Message: ----------- Updated how attributes are retrieved from element nodes so they don't use the AttributeSet anymore Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 06:15:19 UTC (rev 1091) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 06:24:45 UTC (rev 1092) @@ -29,6 +29,7 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; import net.sourceforge.jsxe.dom2.ls.*; +import net.sourceforge.jsxe.dom2.event.*; import net.sourceforge.jsxe.util.Log; import net.sourceforge.jsxe.util.MiscUtilities; //}}} @@ -170,7 +171,7 @@ * Registers a change listener with the XMLDocument * @param listener the listener to register with this document */ - public void addDocumentListener(DocumentListener listener) { + public void addDocumentListener(XMLDocumentListener listener) { //TODO: Create XMLDocumentListeners if (listener != null) { m_docListeners.add(listener); @@ -179,7 +180,7 @@ //{{{ removeDocumentListener() - public void removeDocumentListener(DocumentListener listener) { + public void removeDocumentListener(XMLDocumentListener listener) { if (listener != null) { m_docListeners.remove(listener); } Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java 2006-07-29 06:15:19 UTC (rev 1091) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java 2006-07-29 06:24:45 UTC (rev 1092) @@ -55,7 +55,7 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ * @see XMLDocument - * @since jsXe 0.5 pre2 + * @since jsXe 0.5 pre3 */ public class XMLElement extends XMLNode { @@ -70,21 +70,21 @@ //{{{ getAttributes() /** - * Returns a read only set of attributes in this node. The AttributeSet + * Returns a read only set of attributes in this node. The Map * maps the attribute name to the attribute's value. */ - public AttributeSet getAttributes() { + public Map getAttributes() { //TODO: create resolving parent for the attributes for default node // values from a DTD or schema? - SimpleAttributeSet attrSet = new SimpleAttributeSet(); + HashMap attrSet = new HashMap(); NamedNodeMap attributes = getNode().getAttributes(); int len = attributes.getLength(); for (int i=0; i<len; i++) { Node attr = attributes.item(i); XMLAttribute xmlAttr = (XMLAttribute)attr.getUserData(USER_DATA_KEY); - attrSet.addAttribute(xmlAttr.getName(), xmlAttr.getValue()); + attrSet.put(xmlAttr.getName(), xmlAttr.getValue()); } return attrSet; }//}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-29 06:15:30
|
Revision: 1091 Author: ian_lewis Date: 2006-07-28 23:15:19 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1091&view=rev Log Message: ----------- Updated method structure Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentEvent.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 05:48:54 UTC (rev 1090) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 06:15:19 UTC (rev 1091) @@ -177,6 +177,16 @@ } }//}}} + //{{{ removeDocumentListener() + + public void removeDocumentListener(DocumentListener listener) { + if (listener != null) { + m_docListeners.remove(listener); + } + }//}}} + + //{{{ Structure methods + //{{{ getDefaultRootElement() /** * Gets the root document element. @@ -186,6 +196,17 @@ return null; }//}}} + //{{{ getRootNodes() + + public XMLNode[] getRootNodes() { + //TODO: return root nodes + return null; + }//}}} + + //}}} + + //{{{ Text methods + //{{{ getLength() /** * Gets the total number of characters in the document. This method is @@ -197,13 +218,6 @@ return m_content.getLength(); }//}}} - //{{{ getRootNodes() - - public XMLNode[] getRootNodes() { - //TODO: return root nodes - return null; - }//}}} - //{{{ getText() public String getText(int offset, int length) { try { @@ -281,30 +295,8 @@ } }//}}} - //{{{ removeDocumentListener() + //}}} - public void removeDocumentListener(DocumentListener listener) { - if (listener != null) { - m_docListeners.remove(listener); - } - }//}}} - - //{{{ render() - public void render(Runnable r) { - VFSManager.runInWorkThread(new Runnable() { - public void run() { - try { - readLock(); - - r.run(); - - } finally { - readUnlock(); - } - } - }); - }//}}} - //{{{ Thread safety //{{{ readLock() method @@ -345,17 +337,8 @@ //}}} - //{{{ getDocumentType() + //{{{ Properties methods - public XMLDocumentType getDocumentType() { - DocumentType docType = m_document.getDoctype(); - if (docType != null) { - return (XMLDocumentType)docType.getUserData(XMLNode.USER_DATA_KEY); - } else { - return null; - } - }//}}} - //{{{ getProperties() public Enumeration getProperties() { return m_properties.propertyNames(); @@ -465,6 +448,21 @@ setProperty(name, Integer.toString(value)); } //}}} + //}}} + + //{{{ XMLDocument attributes + + //{{{ getDocumentType() + + public XMLDocumentType getDocumentType() { + DocumentType docType = m_document.getDoctype(); + if (docType != null) { + return (XMLDocumentType)docType.getUserData(XMLNode.USER_DATA_KEY); + } else { + return null; + } + }//}}} + //{{{ setURI() /** * Sets the URI for the location of this document. @@ -534,6 +532,8 @@ m_readOnly = readOnly; }//}}} + //}}} + //{{{ Node Factory methods //{{{ newElementNode() Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-07-29 05:48:54 UTC (rev 1090) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-07-29 06:15:19 UTC (rev 1091) @@ -63,7 +63,7 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ * @see XMLDocument - * @since jsXe 0.5 pre2 + * @since jsXe 0.5 pre3 */ public abstract class XMLNode { Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentEvent.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentEvent.java 2006-07-29 05:48:54 UTC (rev 1090) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentEvent.java 2006-07-29 06:15:19 UTC (rev 1091) @@ -26,12 +26,67 @@ import net.sourceforge.jsxe.dom2.*; +/** + * XMLDocumentEvents are modifications to the structure of the XMLDocument. + * As the XMLDocument represents structured text the XMLDocumentEvent represents + * a structured change to the XMLDocument. + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @see XMLDocument + * @since jsXe 0.5 pre3 + */ public interface XMLDocumentEvent extends EventListener { - public void propertyChanged(PropertyChangeEvent event); + private XMLDocument m_document; + private int m_offset; + private int m_length; + private short m_type; - public void insertUpdate(XMLDocumentEvent event); + public static short INSERT = 0; + public static short REMOVE = 1; - public void removeUpdate(XMLDocumentEvent event); + //{{{ XMLDocumentEvent constructor + /** + * Creates a new document event signifying an edit to the document. + * + */ + public XMLDocumentEvent(XMLDocument doc, int offset, String text, short type) { + m_document = doc; + m_type = type; + m_length = text.length(); + m_offset = offset; + }//}}} + //{{{ getDocument() + /** + * Gets the document that was updated. + */ + public XMLDocument getDocument() { + return m_document; + }//}}} + + //{{{ getOffset() + /** + * Gets the offset into the document where the update occurred. + */ + public int getOffset() { + return m_offset; + }//}}} + + //{{{ getLength() + /** + * Gets the length of the update. + */ + public int getLength() { + return m_length; + }//}}} + + //{{{ getType() + /** + * Gets the type of edit done to the document. + */ + public short getType() { + return m_type; + }//}}} + } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-29 05:49:10
|
Revision: 1090 Author: ian_lewis Date: 2006-07-28 22:48:54 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1090&view=rev Log Message: ----------- Updated multi-threaded support. Added new constructor methods for document nodes Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/ActionManager.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/ActionManager.java 2006-07-29 04:42:42 UTC (rev 1089) +++ branches/jsxe2/src/net/sourceforge/jsxe/ActionManager.java 2006-07-29 05:48:54 UTC (rev 1090) @@ -254,9 +254,9 @@ */ public static void handleKey(KeyEvent event) { KeyEventTranslator.Key key = KeyEventTranslator.translateKeyEvent(event); - Log.log(Log.DEBUG, ActionManager.class, "Key: "+key.toString()); - Log.log(Log.DEBUG, ActionManager.class, "key.key: "+key.key); - Log.log(Log.DEBUG, ActionManager.class, "key.input: "+key.input); + // Log.log(Log.DEBUG, ActionManager.class, "Key: "+key.toString()); + // Log.log(Log.DEBUG, ActionManager.class, "key.key: "+key.key); + // Log.log(Log.DEBUG, ActionManager.class, "key.input: "+key.input); //Gets the action for the Key. Action action = (Action)m_keyBindingMap.get(key); Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 04:42:42 UTC (rev 1089) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 05:48:54 UTC (rev 1090) @@ -206,71 +206,79 @@ //{{{ getText() public String getText(int offset, int length) { - if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { - throw new ArrayIndexOutOfBoundsException(offset); + try { + + readLock(); + + if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { + throw new ArrayIndexOutOfBoundsException(offset); + } + + return m_content.getText(offset,length); + } finally { + readUnlock(); } - - return m_content.getText(offset,length); }//}}} //{{{ getText() public void getText(int offset, int length, Segment txt) { - if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { - throw new ArrayIndexOutOfBoundsException(offset); + try { + + readLock(); + + if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { + throw new ArrayIndexOutOfBoundsException(offset); + } + + m_content.getText(offset, length, txt); + + } finally { + readUnlock(); } - - m_content.getText(offset, length, txt); }//}}} //{{{ insertString() - /** - * <p>Inserts a string of content. This will cause a DocumentEvent of type - * DocumentEvent.EventType.INSERT to be sent to the registered - * DocumentListers, unless an exception is thrown. The DocumentEvent will - * be delivered by calling the insertUpdate method on the - * DocumentListener. The offset and length of the generated DocumentEvent - * will indicate what change was actually made to the Document.</p> - * - * <p>If the Document structure changed as result of the insertion, the - * details of what Elements were inserted and removed in response to the - * change will also be contained in the generated DocumentEvent. It is up - * to the implementation of a Document to decide how the structure should - * change in response to an insertion.</p> - * - * <p>If the Document supports undo/redo, an UndoableEditEvent will also be - * generated.</p> - * @param offset the offset into the document to insert the content >= 0. - * All positions that track change at or after the given - * location will move. - * @param str the string to insert - * @param a the attributes to associate with the inserted content. - * This attribute is ignored by XMLDocuments. - */ public void insertString(int offset, String str) { - if (offset < 0 || str.length() < 0 || offset + str.length() > m_content.getLength()) { - throw new ArrayIndexOutOfBoundsException(offset); - } - m_content.insert(offset, str); + try { + + writeLock(); - //TODO: document structure must change - //TODO: notify listeners - //TODO: implement undo + if (offset < 0 || str.length() < 0 || offset + str.length() > m_content.getLength()) { + throw new ArrayIndexOutOfBoundsException(offset); + } + + m_content.insert(offset, str); + + //TODO: document structure must change + //TODO: notify listeners + //TODO: implement undo + } finally { + writeUnlock(); + } }//}}} //{{{ remove() public void remove(int offs, int len) { - if (offs < 0 || len < 0 || offs + len > m_content.getLength()) { - throw new ArrayIndexOutOfBoundsException(offs); + + try { + + writeLock(); + + if (offs < 0 || len < 0 || offs + len > m_content.getLength()) { + throw new ArrayIndexOutOfBoundsException(offs); + } + + m_content.remove(offs, len); + + //TODO: document structure must change + //TODO: notify listeners + //TODO: implement undo + } finally { + writeUnlock(); } - - m_content.remove(offs, len); - - //TODO: document structure must change - //TODO: notify listeners - //TODO: implement undo }//}}} //{{{ removeDocumentListener() @@ -349,9 +357,8 @@ }//}}} //{{{ getProperties() - - public Map getProperties() { - return m_properties; + public Enumeration getProperties() { + return m_properties.propertyNames(); }//}}} //{{{ getProperty() @@ -363,7 +370,7 @@ if (o == null) { // Now try xml.document.<property> o = jsXe.getProperty("xml.document." + name); - } + } return o; } }//}}} @@ -409,16 +416,12 @@ * @param name The property name */ public boolean getBooleanProperty(String name) { - Object obj = getProperty(name); + String obj = getProperty(name); if (obj == null) { return null; } - if (obj instanceof Boolean) { - return ((Boolean)obj).booleanValue(); - } else { - return Boolean.valueOf(obj.toString()).booleanValue(); - } + return Boolean.valueOf(obj).booleanValue(); } //}}} //{{{ setBooleanProperty() method @@ -428,7 +431,7 @@ * @param value The value */ public void setBooleanProperty(String name, boolean value) { - setProperty(name, Boolean.valueOf(value)); + setProperty(name, Boolean.toString(value)); } //}}} //{{{ getIntegerProperty() method @@ -439,14 +442,14 @@ public int getIntegerProperty(String name, int defaultValue) { boolean defaultValueFlag; - Object obj = getProperty(); + String obj = getProperty(); if (obj == null) { return defaultValue; } else { - if (obj instanceof Number) { - return ((Number)obj).intValue(); - } else { + try { + return Integer.parseInt(obj); + } catch (NumberFormatException e) { return defaultValue; } } @@ -459,7 +462,7 @@ * @param value The value */ public void setIntegerProperty(String name, int value) { - setProperty(name, new Integer(value)); + setProperty(name, Integer.toString(value)); } //}}} //{{{ setURI() @@ -486,7 +489,14 @@ * document is standalone. This is false when unspecified. */ public void setStandalone(boolean standalone) throws DOMException { - m_document.setXmlStandalone(standalone); + try { + writeLock(); + + m_document.setXmlStandalone(standalone); + //TODO: update text + } finally { + writeUnlock(); + } }//}}} //{{{ isStandalone() @@ -495,7 +505,13 @@ * document is standalone. This is false when unspecified. */ public boolean isStandalone() { - return m_document.getXmlStandalone(); + try { + readLock(); + + return m_document.getXmlStandalone(); + } finally { + readUnlock(); + } }//}}} //{{{ isReadOnly() @@ -523,7 +539,23 @@ //{{{ newElementNode() /** * Create a new XMLElement node with the given name. + * * @param name the qualified name of the new node. + * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified + * qualifiedName is not an XML name according to the + * XML version in use specified in the xml version + * attribute. + * @throws DOMException NAMESPACE_ERR: Raised if the qualifiedName is a + * malformed qualified name, if the qualifiedName has + * a prefix and the namespaceURI is null, or if the + * qualifiedName has a prefix that is "xml" and the + * namespaceURI is different from " + * http://www.w3.org/XML/1998/namespace" + * [XML Namespaces] , or if the qualifiedName or its + * prefix is "xmlns" and the namespaceURI is different + * from "http://www.w3.org/2000/xmlns/", or if the + * namespaceURI is "http://www.w3.org/2000/xmlns/" and + * neither the qualifiedName nor its prefix is "xmlns". */ public XMLElement newElementNode(String name) throws DOMException { return new XMLElement(m_document.createElementNS("", name)); @@ -538,6 +570,48 @@ return new XMLAttribute(m_document.createAttributeNS("", name)); }//}}} + //{{{ newCDATASection() + /** + * Creates a CDATASection node whose value is the specified string. + * @param data The data for the CDATASection contents. + */ + public XMLCDATASection newCDATASection(String data) { + return new XMLCDATASection(m_document.createCDATASection(data)); + }//}}} + + //{{{ newCommentNode() + /** + * Creates a Comment node given the specified string. + * @param data the text contents of the comment + */ + public XMLComment newCommentNode(String data) { + return new XMLComment(m_document.createCommentNode(data)); + }//}}} + + //{{{ newProcessingInstruction() + /** + * Creates a ProcessingInstruction node given the specified name and data strings. + * @param target The target part of the processing instruction. + * @param data The data for the node. + * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified + * target is not an XML name according to the XML + * version in use specified in the xml version + * attribute. + */ + public XMLProcessingInstruction newProcessingInstruction(String target, String data) throws DOMException { + //TODO: make sure the target is namespace-well-formed + return new XMLProcessingInstruction(m_document.createProcessingInstruction(target, data)); + }//}}} + + //{{{ newTextNode() + /** + * Creates a Text node given the specified string. + * @param data the text contents of this node + */ + public XMLText newTextNode(String data) { + return new XMLText(m_document.createTextNode(data)); + }//}}} + //{{{ newErrorNode() /** * Creates a new error node. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-29 04:43:06
|
Revision: 1089 Author: ian_lewis Date: 2006-07-28 21:42:42 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1089&view=rev Log Message: ----------- Merge from trunk/sourceview of revision 1086 ViewCVS Links: ------------- http://svn.sourceforge.net/jsxe/?rev=1086&view=rev Modified Paths: -------------- branches/sourceview2/Changelog branches/sourceview2/build.xml branches/sourceview2/dependency.props branches/sourceview2/messages/messages.de branches/sourceview2/src/org/syntax/jedit/DefaultInputHandler.java branches/sourceview2/src/org/syntax/jedit/InputHandler.java branches/sourceview2/src/org/syntax/jedit/JEditTextArea.java branches/sourceview2/src/org/syntax/jedit/TextAreaPainter.java branches/sourceview2/src/sourceview/SourceView.java branches/sourceview2/src/sourceview/SourceViewDocument.java branches/sourceview2/src/sourceview/SourceViewPlugin.java branches/sourceview2/src/sourceview/SourceViewSearchDialog.java branches/sourceview2/src/sourceview/action/EditCopyAction.java branches/sourceview2/src/sourceview/action/EditCutAction.java branches/sourceview2/src/sourceview/action/EditFindAction.java branches/sourceview2/src/sourceview/action/EditPasteAction.java branches/sourceview2/src/sourceview/sourceview.props Added Paths: ----------- branches/sourceview2/messages/messages branches/sourceview2/messages/messages.en_GB branches/sourceview2/messages/messages.ja branches/sourceview2/src/sourceview/SourceViewOptionPane.java branches/sourceview2/src/sourceview/SourceViewSearch.java branches/sourceview2/src/sourceview/action/EditFindNextAction.java Removed Paths: ------------- branches/sourceview2/messages/messages.en branches/sourceview2/src/sourceview/SourceViewOptionsPanel.java Modified: branches/sourceview2/Changelog =================================================================== --- branches/sourceview2/Changelog 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/Changelog 2006-07-29 04:42:42 UTC (rev 1089) @@ -1,3 +1,40 @@ +07/26/2006 Ian Lewis <Ian...@me...> + + * Addded support for the findnext action + +07/21/2006 Ian Lewis <Ian...@me...> + + * Added better horizontal scrolling support. It isn't perfect because + it's hard to know the true width of the line because parts of it + can have bold text while other parts don't. + +07/20/2006 Ian Lewis <Ian...@me...> + + * Added Japanese translation + * Fixed syntax highlighting colors when you first load jsXe + +07/06/2006 Ian Lewis <Ian...@me...> + + * Updated to support the new Messages format. + +06/23/2006 Ian Lewis <Ian...@me...> + + * Added back rudimentary key bindings using Swing Actions so they get + dispached by Swing and are displayed in menus. But infrastructure is + in place to allow jsXe to catch key bindings itself. + +06/20/2006 Ian Lewis <Ian...@me...> + + * Updated the sourceview's actions to extend the new LocalizedAction class. + +06/13/2006 Ian Lewis <Ian...@me...> + + * Updated the source view options panel to extend AbstractOptionPane + +06/09/2006 Ian Lewis <Ian...@me...> + + * Updated version and dependency info + 06/03/2006 Ian Lewis <Ian...@me...> * Updated the SourceView to use the new XMLDocumentListener interface Modified: branches/sourceview2/build.xml =================================================================== --- branches/sourceview2/build.xml 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/build.xml 2006-07-29 04:42:42 UTC (rev 1089) @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - This is a build.xml file for building the Source View for jsXe. - Version: $Id$ + :tabSize=2:indentSize=2:noTabs=true: + :folding=explicit:collapseFolds=1: + + This is a build.xml file for building the Source View for jsXe. + Version: $Id$ --> <project basedir="." default="usage" name="sourceview"> @@ -26,6 +29,7 @@ <property name="build.help" value="${build.docs}/help"/> <property name="jsxe.dir" value="${root.dir}/../.."/> <property name="jsxe.jar" value="${jsxe.dir}/jsXe.jar"/> + <property name="jsxe.lib.dir" value="${jsxe.dir}/../lib"/> <property name="javac.debug" value="on"/> <property name="javac.optimize" value="off"/> <property name="javac.deprecation" value="on"/> @@ -34,7 +38,7 @@ <property name="javadoc.link" value="http://java.sun.com/j2se/1.3/docs/api/"/> <property name="main.class" value="sourceview.SourceViewPlugin"/> <property name="major.version" value="0"/> - <property name="minor.version" value="4"/> + <property name="minor.version" value="5"/> <property name="build.version" value="3"/> <property name="app.version" value="${major.version}.${minor.version}.${build.version}"/> <property name="app_version" value="${major.version}_${minor.version}_${build.version}"/> @@ -47,6 +51,9 @@ <pathelement location="${build.src}"/> <pathelement location="${src.dir}"/> <pathelement location="${jsxe.jar}"/> + <fileset dir="${jsxe.lib.dir}"> + <include name="**/*.jar"/> + </fileset> </path> <echo message="${readable.name} ${app.version}"/> <echo message="----------------------------------------------------------"/> @@ -67,11 +74,15 @@ <target depends="init" name="prepare"> <mkdir dir="${build.dir}"/> <mkdir dir="${build.messages}"/> - <copy todir="${build.messages}"> + + <!--<copy todir="${build.messages}"> <fileset dir="${messages.dir}"> <include name="**/messages.*"/> </fileset> - </copy> + </copy>--> + + <!-- run native2ascii on these files --> + <native2ascii encoding="UTF-8" src="${messages.dir}" dest="${build.messages}" includes="messages*"/> </target> <!-- }}} --> <!-- {{{ ============ Prepares the documentation ======================= --> @@ -133,7 +144,7 @@ <jar jarfile="${root.dir}/../${app.name}.jar" manifest="${app.name}.manifest"> <fileset dir="${build.dir}"> - <include name="messages/messages.*"/> + <include name="messages/messages*"/> </fileset> <fileset dir="${build.dest}"> <include name="**/*.class"/> Modified: branches/sourceview2/dependency.props =================================================================== --- branches/sourceview2/dependency.props 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/dependency.props 2006-07-29 04:42:42 UTC (rev 1089) @@ -1 +1 @@ -dependency.0=jsxe 00.04.03.00 +dependency.0=jsxe 00.05.03.00 Copied: branches/sourceview2/messages/messages (from rev 1084, trunk/sourceview/messages/messages) =================================================================== --- branches/sourceview2/messages/messages (rev 0) +++ branches/sourceview2/messages/messages 2006-07-29 04:42:42 UTC (rev 1089) @@ -0,0 +1,33 @@ +# JSXE source view English properties file +# $Id$ +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1 + +#{{{ Source View Options +SourceView.Options.Title=Source View +SourceView.Options.EndOfLineMarker=End of line markers +SourceView.Syntax.Object=Node Type +SourceView.Syntax.Style=Text Style +SourceView.ColorChooser.Title=Color Chooser +SourceView.Markup=Markup +SourceView.Invalid=Invalid +#}}} + +#{{{ Style Editor +SourceView.StyleEditor.Title=Style Editor +SourceView.StyleEditor.Color=Text Color +SourceView.StyleEditor.Bold=Bold +SourceView.StyleEditor.Italics=Italics +#}}} + +#{{{ Find Dialog +SourceView.Find.title and Replace +SourceView.Ignore.Case=Ignore Case +SourceView.Search.For=Search for: +SourceView.Replace.With=Replace With: +SourceView.Replace.And.Find=Replace&Find +SourceView.No.More.Matches.title=No More Matches +SourceView.No.More.Matches.message="No more matches were found. Continue search from the beginning?" +SourceView.Search.Error.title=Search Error +#}}} \ No newline at end of file Modified: branches/sourceview2/messages/messages.de =================================================================== --- branches/sourceview2/messages/messages.de 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/messages/messages.de 2006-07-29 04:42:42 UTC (rev 1089) @@ -5,22 +5,22 @@ #:tabSize=4:indentSize=4:noTabs=true: #:folding=explicit:collapseFolds=1: -#{{{ Source View +# ä Ä é ö Ö ü Ü ß #{{{ Source View Options SourceView.Options.Title=Source View Optionen SourceView.Syntax.Object=Knoten Typ SourceView.Syntax.Style=Text Stil -SourceView.Syntax.ToolTip=Dieses Tool erm�glicht es, den Font f�r verschiedene Knoten zu setzen. -SourceView.ColorChooser.Title=Farbw�hler +SourceView.Syntax.ToolTip=Dieses Tool ermöglicht es, den Font für verschiedene Knoten zu setzen. +SourceView.ColorChooser.Title=Farbwähler SourceView.Markup=Markup -SourceView.Invalid=Ung�ltig +SourceView.Invalid=Ungültig #}}} #{{{ Style Editor SourceView.StyleEditor.Title=Stil Editor SourceView.StyleEditor.Color=Textfarbe -SourceView.StyleEditor.Color.ToolTip=<HTML>Die Farbe dieses Knoten Typs kann hier ge�ndert werden. <BR>H�ckchen dieser Box entfernen setzten die Farbe zu schwarz zur�ck. <BR>Die rechteckige Box neben diesr Auswahl, kann<BR> benutzt werden um verschiedene Farben auszuw�hlen.</HTML> +SourceView.StyleEditor.Color.ToolTip=<HTML>Die Farbe dieses Knoten Typs kann hier geändert werden. <BR>H�ckchen dieser Box entfernen setzten die Farbe zu schwarz zurück. <BR>Die rechteckige Box neben diesr Auswahl, kann<BR> benutzt werden um verschiedene Farben auszuwählen.</HTML> SourceView.StyleEditor.Bold=Fett SourceView.StyleEditor.Bold.ToolTip=schaltet Fettdruck an/aus SourceView.StyleEditor.Italics=Kursiv @@ -28,5 +28,3 @@ #}}} -#}}} - Deleted: branches/sourceview2/messages/messages.en =================================================================== --- branches/sourceview2/messages/messages.en 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/messages/messages.en 2006-07-29 04:42:42 UTC (rev 1089) @@ -1,27 +0,0 @@ -# JSXE source view English properties file -# $Id$ -#:mode=properties: -#:tabSize=4:indentSize=4:noTabs=true: -#:folding=explicit:collapseFolds=1 - -#{{{ Source View - -#{{{ Source View Options -SourceView.Options.Title=Source View Options -SourceView.Options.EndOfLineMarker=End of line markers -SourceView.Syntax.Object=Node Type -SourceView.Syntax.Style=Text Style -SourceView.ColorChooser.Title=Color Chooser -SourceView.Markup=Markup -SourceView.Invalid=Invalid -#}}} - -#{{{ Style Editor -SourceView.StyleEditor.Title=Style Editor -SourceView.StyleEditor.Color=Text Color -SourceView.StyleEditor.Bold=Bold -SourceView.StyleEditor.Italics=Italics -#}}} - -#}}} - Copied: branches/sourceview2/messages/messages.en_GB (from rev 1084, trunk/sourceview/messages/messages.en_GB) =================================================================== --- branches/sourceview2/messages/messages.en_GB (rev 0) +++ branches/sourceview2/messages/messages.en_GB 2006-07-29 04:42:42 UTC (rev 1089) @@ -0,0 +1,13 @@ +# JSXE source view British English properties file +# $Id: messages 996 2006-07-07 03:46:52Z ian_lewis $ +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1 + +#{{{ Source View Options +SourceView.ColorChooser.Title=Colour Chooser +#}}} + +#{{{ Style Editor +SourceView.StyleEditor.Color=Text Colour +#}}} Copied: branches/sourceview2/messages/messages.ja (from rev 1084, trunk/sourceview/messages/messages.ja) =================================================================== --- branches/sourceview2/messages/messages.ja (rev 0) +++ branches/sourceview2/messages/messages.ja 2006-07-29 04:42:42 UTC (rev 1089) @@ -0,0 +1,13 @@ +# JSXE source view Japanese properties file +# $Id$ +# Maintained by Ian Lewis +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1: + +#{{{ Source View Options +SourceView.Options.Title=ソース表示 +SourceView.Syntax.Object=ノードタイプ +SourceView.Markup=マーク付け +SourceView.Invalid=無効 +#}}} Modified: branches/sourceview2/src/org/syntax/jedit/DefaultInputHandler.java =================================================================== --- branches/sourceview2/src/org/syntax/jedit/DefaultInputHandler.java 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/src/org/syntax/jedit/DefaultInputHandler.java 2006-07-29 04:42:42 UTC (rev 1089) @@ -78,9 +78,9 @@ addKeyBinding("C+ENTER",REPEAT); // Clipboard - addKeyBinding("C+C", CLIP_COPY); - addKeyBinding("C+V", CLIP_PASTE); - addKeyBinding("C+X", CLIP_CUT); + // addKeyBinding("C+C", CLIP_COPY); + // addKeyBinding("C+V", CLIP_PASTE); + // addKeyBinding("C+X", CLIP_CUT); } /** Modified: branches/sourceview2/src/org/syntax/jedit/InputHandler.java =================================================================== --- branches/sourceview2/src/org/syntax/jedit/InputHandler.java 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/src/org/syntax/jedit/InputHandler.java 2006-07-29 04:42:42 UTC (rev 1089) @@ -142,10 +142,10 @@ */ public static String getActionName(ActionListener listener) { - Enumeration enum = getActions(); - while(enum.hasMoreElements()) + Enumeration actions = getActions(); + while(actions.hasMoreElements()) { - String name = (String)enum.nextElement(); + String name = (String)actions.nextElement(); ActionListener _listener = getAction(name); if(_listener == listener) return name; Modified: branches/sourceview2/src/org/syntax/jedit/JEditTextArea.java =================================================================== --- branches/sourceview2/src/org/syntax/jedit/JEditTextArea.java 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/src/org/syntax/jedit/JEditTextArea.java 2006-07-29 04:42:42 UTC (rev 1089) @@ -6,7 +6,6 @@ Copyright (C) 1999 Slava Pestov Copyright (C) 2002 Ian Lewis (Ian...@me...) - You may use and modify this package for any purpose. Redistribution is permitted, in both source and binary form, provided that this notice remains intact in all source distributions of this package. @@ -252,21 +251,18 @@ * if the number of lines in the document changes, or when the * size of the text are changes. */ - public void updateScrollBars() - { - if(vertical != null && visibleLines != 0) - { + public void updateScrollBars() { + if (vertical != null && visibleLines != 0) { vertical.setValues(firstLine,visibleLines,0,getLineCount()); vertical.setUnitIncrement(2); vertical.setBlockIncrement(visibleLines); } - int width = painter.getWidth(); - if(horizontal != null && width != 0) - { - horizontal.setValues(-horizontalOffset,width,0,width * 5); - horizontal.setUnitIncrement(painter.getFontMetrics() - .charWidth('w')); + if (horizontal != null && width != 0) { + // Log.log(Log.DEBUG, this, "value: "+ (-horizontalOffset)); + + horizontal.setValue(-horizontalOffset); + horizontal.setUnitIncrement(painter.getFontMetrics().charWidth('w')); horizontal.setBlockIncrement(width / 2); } } @@ -330,13 +326,14 @@ * implement horizontal scrolling. * @param horizontalOffset offset The new horizontal offset */ - public void setHorizontalOffset(int horizontalOffset) - { - if(horizontalOffset == this.horizontalOffset) + public void setHorizontalOffset(int horizontalOffset) { + if (horizontalOffset == this.horizontalOffset) { return; + } this.horizontalOffset = horizontalOffset; - if(horizontalOffset != horizontal.getValue()) + if (horizontalOffset != horizontal.getValue()) { updateScrollBars(); + } painter.repaint(); } @@ -1604,6 +1601,8 @@ protected int magicCaret; protected boolean overwrite; protected boolean rectSelect; + + private int maxHorizontalScrollWidth; protected void fireCaretEvent() { @@ -2132,6 +2131,51 @@ return false; } } + + //{{{ updateMaxHorizontalScrollWidth() method + void updateMaxHorizontalScrollWidth() { + + int max = 0; + + for (int i = firstLine; i < firstLine + visibleLines && i < getLineCount(); i++) { + /* + TODO: This is broken since some parts of the line can be bold and + thus be wider than other parts of the line. Need to implement + a chunk cache like jEdit has. + */ + int width = (int)Math.round( + painter.getFont().deriveFont(Font.BOLD).getStringBounds(getLineText(i), + new java.awt.font.FontRenderContext(null,false,false)).getWidth()); + if (width > max) { + max = width; + } + } + + int _tabSize = ((Integer)getDocument().getProperty(PlainDocument.tabSizeAttribute)).intValue(); + char[] foo = new char[] { ' ' }; + + int charWidth = (int)Math.round( + painter.getFont().getStringBounds(foo,0,1, + new java.awt.font.FontRenderContext(null,false,false)).getWidth()); + + // Log.log(Log.DEBUG, this, "value: "+ Math.max(0, + // Math.min(maxHorizontalScrollWidth /*+ charWidth*/ + // - painter.getWidth(), + // -horizontalOffset)) + // +" extent: "+painter.getWidth() + // +" min: "+0 + // +" max: "+max); + if (max != maxHorizontalScrollWidth) { + maxHorizontalScrollWidth = max; + horizontal.setValues(Math.max(0, + Math.min(maxHorizontalScrollWidth + charWidth + - painter.getWidth(), + -horizontalOffset)), + painter.getWidth(), + 0,maxHorizontalScrollWidth + + charWidth); + } + } //}}} //{{{ WheelScrollListener class static class MouseWheelHandler implements MouseWheelListener { Modified: branches/sourceview2/src/org/syntax/jedit/TextAreaPainter.java =================================================================== --- branches/sourceview2/src/org/syntax/jedit/TextAreaPainter.java 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/src/org/syntax/jedit/TextAreaPainter.java 2006-07-29 04:42:42 UTC (rev 1089) @@ -1,14 +1,32 @@ /* - * TextAreaPainter.java - Paints the text area - * Copyright (C) 1999 Slava Pestov - * - * 08/05/2002 Cursor (caret) rendering fixed for JDK 1.4 (Anonymous) - * - * You may use and modify this package for any purpose. Redistribution is - * permitted, in both source and binary form, provided that this notice - * remains intact in all source distributions of this package. - */ +TextAreaPainter.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: +Copyright (C) 1999 Slava Pestov +Copyright (C) 2002 Ian Lewis (Ian...@me...) + +You may use and modify this package for any purpose. Redistribution is +permitted, in both source and binary form, provided that this notice +remains intact in all source distributions of this package. + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + package org.syntax.jedit; import org.syntax.jedit.tokenmarker.*; @@ -25,6 +43,8 @@ * The text area repaint manager. It performs double buffering and paints * lines of text. * @author Slava Pestov + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * * @version $Id$ */ public class TextAreaPainter extends JComponent implements TabExpander @@ -47,7 +67,7 @@ currentLineIndex = -1; setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); - + setFont(new Font("Monospaced",Font.PLAIN,14)); setForeground(Color.black); setBackground(Color.white); @@ -66,7 +86,28 @@ eolMarkerColor = defaults.eolMarkerColor; eolMarkers = defaults.eolMarkers; } + + //{{{ setBounds() method + /** + * It is a bad idea to override this, but we need to get the component + * event before the first repaint. + */ + public void setBounds(int x, int y, int width, int height) { + if (x == getX() && y == getY() && width == getWidth() && height == getHeight()) { + return; + } + super.setBounds(x,y,width,height); + + textArea.recalculateVisibleLines(); + // if (textArea.getBuffer().isLoaded()) { + // textArea.recalculateLastPhysicalLine(); + // } + // textArea.propertiesChanged(); + textArea.updateMaxHorizontalScrollWidth(); + textArea.scrollBarsInitialized = true; + } //}}} + /** * Returns if this component can be traversed by pressing the * Tab key. This returns false. @@ -352,8 +393,7 @@ * cached font metrics and to recalculate which lines are visible. * @param font The font */ - public void setFont(Font font) - { + public void setFont(Font font) { super.setFont(font); //TODO: this is deprecated, figure out how to do it the right way. fm = Toolkit.getDefaultToolkit().getFontMetrics(font); @@ -364,10 +404,8 @@ * Repaints the text. * @param g The graphics context */ - public void paint(Graphics gfx) - { - tabSize = fm.charWidth(' ') * ((Integer)textArea - .getDocument().getProperty( + public void paint(Graphics gfx) { + tabSize = fm.charWidth(' ') * ((Integer)textArea.getDocument().getProperty( PlainDocument.tabSizeAttribute)).intValue(); Rectangle clipRect = gfx.getClipBounds(); @@ -385,25 +423,22 @@ // too many lines will always be painted. int lastInvalid = firstLine + (clipRect.y + clipRect.height - 1) / height; - try - { - TokenMarker tokenMarker = textArea.getDocument() - .getTokenMarker(); + try { + TokenMarker tokenMarker = textArea.getDocument().getTokenMarker(); int x = textArea.getHorizontalOffset(); - for(int line = firstInvalid; line <= lastInvalid; line++) - { + for(int line = firstInvalid; line <= lastInvalid; line++) { paintLine(gfx,tokenMarker,line,x); } - if(tokenMarker != null && tokenMarker.isNextLineRequested()) - { + if (tokenMarker != null && tokenMarker.isNextLineRequested()) { int h = clipRect.y + clipRect.height; repaint(0,h,getWidth(),getHeight() - h); } - } - catch(Exception e) - { + + textArea.updateMaxHorizontalScrollWidth(); + + } catch(Exception e) { System.err.println("Error repainting line" + " range {" + firstInvalid + "," + lastInvalid + "}:"); @@ -502,7 +537,7 @@ protected FontMetrics fm; protected Highlight highlights; - + protected void paintLine(Graphics gfx, TokenMarker tokenMarker, int line, int x) { @@ -696,7 +731,7 @@ fm.getHeight() - 1); } -protected void paintCaret(Graphics gfx, int line, int y) + protected void paintCaret(Graphics gfx, int line, int y) { if(textArea.isCaretVisible()) { Modified: branches/sourceview2/src/sourceview/SourceView.java =================================================================== --- branches/sourceview2/src/sourceview/SourceView.java 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/src/sourceview/SourceView.java 2006-07-29 04:42:42 UTC (rev 1089) @@ -34,12 +34,11 @@ //{{{ jsXe classes import net.sourceforge.jsxe.*; import net.sourceforge.jsxe.gui.Messages; -import net.sourceforge.jsxe.gui.OptionsPanel; import net.sourceforge.jsxe.gui.DocumentView; import net.sourceforge.jsxe.dom.AdapterNode; import net.sourceforge.jsxe.dom.XMLDocument; import net.sourceforge.jsxe.dom.XMLDocumentListener; -import net.sourceforge.jsxe.dom.XMLDocumentEvent; +import net.sourceforge.jsxe.msg.PropertyChanged; import net.sourceforge.jsxe.util.Log; import net.sourceforge.jsxe.util.MiscUtilities; //}}} @@ -82,19 +81,11 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class SourceView extends JPanel implements DocumentView { +public class SourceView extends JPanel implements DocumentView, EBListener { - // Temporary Hack - protected static ArrayList m_sourceviews = new ArrayList(); - - //{{{ Private static members - private static final String _VIEWNAME = "source"; - //}}} - //{{{ Public static members - public static final String SOFT_TABS = _VIEWNAME+".soft.tabs"; - public static final String LAST_FIND_STRING = _VIEWNAME+".last.find.string"; - public static final String END_OF_LINE_MARKS = _VIEWNAME+".end-of-line-markers"; + public static final String SOFT_TABS = SourceViewPlugin.PLUGIN_NAME+".soft.tabs"; + public static final String END_OF_LINE_MARKS = SourceViewPlugin.PLUGIN_NAME+".end-of-line-markers"; //}}} //{{{ SourceView constructor @@ -118,19 +109,19 @@ TextAreaPainter painter = m_textarea.getPainter(); painter.setEOLMarkersPainted(jsXe.getBooleanProperty(SourceView.END_OF_LINE_MARKS, true)); painter.setStyles( - new SyntaxStyle[] { SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.text.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.comment.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.doctype.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.attribute.value.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.attribute.value.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.cdata.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.entity.reference.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.element.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.attribute.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.processing.instruction.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.namespace.prefix.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.markup.color")), - SourceViewOptionsPanel.parseStyle(jsXe.getProperty("source.invalid.color")), + new SyntaxStyle[] { SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.text.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.comment.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.doctype.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.attribute.value.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.attribute.value.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.cdata.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.entity.reference.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.element.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.attribute.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.processing.instruction.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.namespace.prefix.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.markup.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("sourceview.invalid.color")), }); // textarea.setFont(new Font("Monospaced", 0, 12)); m_textarea.setCaretPosition(0); @@ -142,15 +133,17 @@ //{{{ create popup menu JPopupMenu popup = new JPopupMenu(); - JMenuItem menuItem = new JMenuItem(jsXe.getAction("sourceview.cut")); + JMenuItem menuItem = new JMenuItem(ActionManager.getAction("cut")); popup.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("sourceview.copy")); + menuItem = new JMenuItem(ActionManager.getAction("copy")); popup.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("sourceview.paste")); + menuItem = new JMenuItem(ActionManager.getAction("paste")); popup.add(menuItem); popup.addSeparator(); - menuItem = new JMenuItem(jsXe.getAction("sourceview.find")); + menuItem = new JMenuItem(ActionManager.getAction("find")); popup.add(menuItem); + menuItem = new JMenuItem(ActionManager.getAction("findnext")); + popup.add(menuItem); m_textarea.setRightClickPopup(popup); //}}} @@ -169,21 +162,19 @@ // menuItem.addActionListener( new EditRedoAction() ); // menu.add(menuItem); // menu.addSeparator(); - menuItem = new JMenuItem(jsXe.getAction("sourceview.cut")); + menuItem = new JMenuItem(ActionManager.getAction("cut")); m_editMenu.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("sourceview.copy")); + menuItem = new JMenuItem(ActionManager.getAction("copy")); m_editMenu.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("sourceview.paste")); + menuItem = new JMenuItem(ActionManager.getAction("paste")); m_editMenu.add(menuItem); m_editMenu.addSeparator(); - menuItem = new JMenuItem(jsXe.getAction("sourceview.find")); + menuItem = new JMenuItem(ActionManager.getAction("find")); m_editMenu.add(menuItem); - // menuItem = new JMenuItem(new EditFindNextAction()); - // menu.add(menuItem); + menuItem = new JMenuItem(ActionManager.getAction("findnext")); + m_editMenu.add(menuItem); //}}} - m_sourceviews.add(this); - setDocumentBuffer(document); //focus on the text area the first time the view is shown @@ -202,8 +193,39 @@ });//}}} + EditBus.addToBus(this); }//}}} + //{{{ handleMessage() + public void handleMessage(EBMessage message) { + if (message instanceof PropertyChanged) { + String key = ((PropertyChanged)message).getKey(); + TextAreaPainter painter = getTextArea().getPainter(); + if (key.equals("source.end-of-line-markers")) { + painter.setEOLMarkersPainted(jsXe.getBooleanProperty("source.end-of-line-markers", false)); + } + + if (key.startsWith("source.") && key.endsWith(".color")) { + painter.setStyles( + new SyntaxStyle[] { + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.text.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.comment.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.doctype.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.attribute.value.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.attribute.value.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.cdata.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.entity.reference.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.element.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.attribute.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.processing.instruction.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.namespace.prefix.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.markup.color")), + SourceViewOptionPane.parseStyle(jsXe.getProperty("source.invalid.color")), + }); + } + } + }//}}} + //{{{ getTextArea() public JEditTextArea getTextArea() { @@ -226,7 +248,6 @@ dialog.dispose(); } m_document.removeXMLDocumentListener(docListener); - m_sourceviews.remove(this); return true; }//}}} @@ -285,52 +306,6 @@ //{{{ Private members - //{{{ EditUndoAction class - - private class EditUndoAction implements ActionListener { - - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { - //undo does nothing for now - }//}}} - - }//}}} - - //{{{ EditRedoAction class - - private class EditRedoAction implements ActionListener { - - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { - //redo action does nothing for now. - }//}}} - - }//}}} - - //{{{ EditFindNextAction class - - private class EditFindNextAction extends AbstractAction { - - //{{{ EditFindNextAction constructor - - public EditFindNextAction() { - //putValue(Action.NAME, "Find Next"); - putValue(Action.NAME, Messages.getMessage("SourceView.FindNext")); - putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke("ctrl G")); - putValue(Action.MNEMONIC_KEY, new Integer(KeyStroke.getKeyStroke("N").getKeyCode())); - }//}}} - - //{{{ actionPerformed() - - public void actionPerformed(ActionEvent e) { - //use previous find string - - }//}}} - - }//}}} - //{{{ SourceViewXMLDocumentListener class private class SourceViewXMLDocumentListener implements XMLDocumentListener { @@ -350,14 +325,6 @@ //{{{ structureChanged() public void structureChanged(XMLDocument source, AdapterNode location) {}//}}} - //{{{ insertUpdate() - public void insertUpdate(XMLDocumentEvent event) {}//}}} - - //{{{ removeUpdate() - public void removeUpdate(XMLDocumentEvent event) {}//}}} - - //{{{ changeUpdate() - public void changeUpdate(XMLDocumentEvent event) {}//}}} }//}}} //{{{ SourceViewEnter Modified: branches/sourceview2/src/sourceview/SourceViewDocument.java =================================================================== --- branches/sourceview2/src/sourceview/SourceViewDocument.java 2006-07-29 04:41:34 UTC (rev 1088) +++ branches/sourceview2/src/sourceview/SourceViewDocument.java 2006-07-29 04:42:42 UTC (rev 1089) @@ -138,29 +138,6 @@ //}}} - // private class SourceViewDocumentXMLDocumentListener implements XMLDocumentListener {//{{{ - // - // public void propertiesChanged(XMLDocument source, String propertyKey) { - // if (propertyKey.equals("encoding")) { - // try { - // String text = getText(0, getLength()); - // SourceViewDocument.super.remove(0, getLength()); - // SourceViewDocument.super.insertString(0, document.getSource(), new SimpleAttributeSet()); - // } catch (BadLocationException ble) { - // //This should never happen. If it does however jsXe will - // //act abnormally so... crash. - // jsXe.exiterror(view, ble.toString(), 1); - // } catch (IOException ioe) { - // //This might happen. If it does jsXe will - // //act abnormally so... crash. - // jsXe.exiterror(view, ioe.toString(), 1); - // } - // } - // } - // - // public void fileChanged(XMLDocument source) {} - // }//}}} - //{{{ Private members private XMLDocument m_document; //}}} Copied: branches/sourceview2/src/sourceview/SourceViewOptionPane.java (from rev 1084, trunk/sourceview/src/sourceview/SourceViewOptionPane.java) =================================================================== --- branches/sourceview2/src/sourceview/SourceViewOptionPane.java (rev 0) +++ branches/sourceview2/src/sourceview/SourceViewOptionPane.java 2006-07-29 04:42:42 UTC (rev 1089) @@ -0,0 +1,696 @@ +/* +SourceViewOptionPane.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2002, 2006 Ian Lewis (Ian...@me...) +Portions Copyright (C) 1999, 2000, 2001, 2002 Slava Pestov + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package sourceview; + +//{{{ Imports + +import org.syntax.jedit.*; + +//{{{ jsXe classes +import net.sourceforge.jsxe.*; +import net.sourceforge.jsxe.gui.*; +import net.sourceforge.jsxe.options.*; +import net.sourceforge.jsxe.msg.PropertyChanged; +import net.sourceforge.jsxe.util.MiscUtilities; +//}}} + +//{{{ Java Classes +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.table.*; +import javax.swing.border.EmptyBorder; +import java.util.Vector; +import java.util.StringTokenizer; +import java.util.Iterator; +//}}} + +//}}} + +public class SourceViewOptionPane extends AbstractOptionPane { + + //{{{ SourceViewOptionPane constructor + public SourceViewOptionPane(DocumentBuffer buffer) { + super("sourceview"); + }//}}} + + //{{{ _init() + protected void _init() { + setLayout(new BorderLayout(6,6)); + + // {{{ styles + + add(BorderLayout.CENTER,createStyleTableScroller()); + + //}}} + + //{{{ end of line markers + m_endOfLineMarkCheckBox = new JCheckBox(Messages.getMessage("SourceView.Options.EndOfLineMarker"),jsXe.getBooleanProperty("source.end-of-line-markers",true)); + m_endOfLineMarkCheckBox.setToolTipText(Messages.getMessage("SourceView.Options.EndOfLineMarker.Tooltip")); + add(BorderLayout.SOUTH, m_endOfLineMarkCheckBox); + + //}}} + + }//}}} + + //{{{ _save() + protected void _save() { + styleModel.save(); + jsXe.setBooleanProperty("source.end-of-line-markers",m_endOfLineMarkCheckBox.isSelected()); + }//}}} + + //{{{ getTitle() + + public String getTitle() { + return Messages.getMessage("SourceView.Options.Title"); + }//}}} + + //{{{ parseStyle() method + /** + * Converts a style string to a style object. + * @param str The style string + * @param family Style strings only specify font style, not font family + * @param size Style strings only specify font style, not font family + * @param color If false, the styles will be monochrome + * @exception IllegalArgumentException if the style is invalid + */ + public static SyntaxStyle parseStyle(String str) throws IllegalArgumentException { + Color fgColor = Color.black; + Color bgColor = null; + boolean italic = false; + boolean bold = false; + StringTokenizer st = new StringTokenizer(str); + while(st.hasMoreTokens()) { + String s = st.nextToken(); + if (s.startsWith("color:")) { + fgColor = parseColor(s.substring(6), Color.black); + } + else if (s.startsWith("style:")) { + for (int i = 6; i < s.length(); i++) { + if (s.charAt(i) == 'i') + italic = true; + else if(s.charAt(i) == 'b') + bold = true; + else + throw new IllegalArgumentException("Invalid style: " + s); + } + } + else + throw new IllegalArgumentException("Invalid directive: " + s); + } + return new SyntaxStyle(fgColor, italic, bold); + } //}}} + + //{{{ parseColor() method + public static Color parseColor(String name, Color defaultColor) { + if (name == null) + return defaultColor; + else if(name.startsWith("#")) { + try + { + return Color.decode(name); + } + catch(NumberFormatException nf) + { + return defaultColor; + } + } + else if("red".equals(name)) + return Color.red; + else if("green".equals(name)) + return Color.green; + else if("blue".equals(name)) + return Color.blue; + else if("yellow".equals(name)) + return Color.yellow; + else if("orange".equals(name)) + return Color.orange; + else if("white".equals(name)) + return Color.white; + else if("lightGray".equals(name)) + return Color.lightGray; + else if("gray".equals(name)) + return Color.gray; + else if("darkGray".equals(name)) + return Color.darkGray; + else if("black".equals(name)) + return Color.black; + else if("cyan".equals(name)) + return Color.cyan; + else if("magenta".equals(name)) + return Color.magenta; + else if("pink".equals(name)) + return Color.pink; + else + return defaultColor; + } //}}} + + //{{{ Private Members + + //{{{ getParentDialog() method + /** + * Traverses the given component's parent tree looking for an + * instance of JDialog, and return it. If not found, return null. + * @param c The component + */ + private static JDialog getParentDialog(Component c) { + Component p = c.getParent(); + while (p != null && !(p instanceof JDialog)) { + p = p.getParent(); + } + + return (p instanceof JDialog) ? (JDialog) p : null; + } //}}} + + //{{{ getStyleString() method + /** + * Converts a style into it's string representation. + * @param style The style + */ + private static String getStyleString(SyntaxStyle style) { + StringBuffer buf = new StringBuffer(); + + if (style.getColor() != null) { + buf.append("color:" + getColorHexString(style.getColor())); + } + + if (!style.isPlain()) { + buf.append(" style:" + (style.isItalic() ? "i" : "") + + (style.isBold() ? "b" : "")); + } + + return buf.toString(); + }//}}} + + //{{{ createStyleTableScroller() method + + private JScrollPane createStyleTableScroller() { + styleModel = createStyleTableModel(); + styleTable = new JTable(styleModel); + styleTable.setRowSelectionAllowed(false); + styleTable.setColumnSelectionAllowed(false); + styleTable.setCellSelectionEnabled(false); + styleTable.getTableHeader().setReorderingAllowed(false); + styleTable.addMouseListener(new MouseHandler()); + TableColumnModel tcm = styleTable.getColumnModel(); + TableColumn styleColumn = tcm.getColumn(1); + styleColumn.setCellRenderer(new StyleTableModel.StyleRenderer()); + Dimension d = styleTable.getPreferredSize(); + d.height = Math.min(d.height,100); + JScrollPane scroller = new JScrollPane(styleTable); + scroller.setPreferredSize(d); + return scroller; + } //}}} + + //{{{ createStyleTableModel() method + + private StyleTableModel createStyleTableModel() { + return new StyleTableModel(); + } //}}} + + //{{{ getColorHexString() method + /** + * Converts a color object to its hex value. The hex value + * prefixed is with `#', for example `#ff0088'. + * @param c The color object + */ + private static String getColorHexString(Color c) { + String colString = Integer.toHexString(c.getRGB() & 0xffffff); + return "#000000".substring(0,7 - colString.length()).concat(colString); + } //}}} + + //{{{ MouseHandler class + + private class MouseHandler extends MouseAdapter { + public void mouseClicked(MouseEvent evt) { + int row = styleTable.rowAtPoint(evt.getPoint()); + if(row == -1) + return; + + SyntaxStyle style = new StyleEditor( + SourceViewOptionPane.this, + (SyntaxStyle)styleModel.getValueAt( + row,1)).getStyle(); + if(style != null) + styleModel.setValueAt(style,row,1); + } + } //}}} + + //{{{ StyleEditor class + private static class StyleEditor extends EnhancedDialog implements ActionListener { + //{{{ StyleEditor constructor + public StyleEditor(Component comp, SyntaxStyle style) { + super(getParentDialog(comp), + Messages.getMessage("SourceView.StyleEditor.Title"),true); + + JPanel content = new JPanel(new BorderLayout(12,12)); + content.setBorder(new EmptyBorder(12,12,12,12)); + setContentPane(content); + + GridBagLayout layout = new GridBagLayout(); + JPanel panel = new JPanel(layout); + + GridBagConstraints cons = new GridBagConstraints(); + cons.gridx = cons.gridy = 0; + cons.gridwidth = 2; + cons.gridheight = 1; + cons.fill = GridBagConstraints.BOTH; + cons.weightx = 0.0f; + + italics = new JCheckBox(Messages.getMessage("SourceView.StyleEditor.Italics")); + italics.setSelected(style.isItalic()); + italics.setToolTipText(Messages.getMessage("SourceView.StyleEditor.Italics.ToolTip")); + layout.setConstraints(italics,cons); + panel.add(italics); + + cons.gridy++; + bold = new JCheckBox(Messages.getMessage("SourceView.StyleEditor.Bold")); + bold.setSelected(style.isBold()); + bold.setToolTipText(Messages.getMessage("SourceView.StyleEditor.Bold.ToolTip")); + layout.setConstraints(bold,cons); + panel.add(bold); + + cons.gridy++; + cons.gridwidth = 1; + Color fg = style.getColor(); + + fgColorCheckBox = new JCheckBox(Messages.getMessage("SourceView.StyleEditor.Color")); + fgColorCheckBox.setSelected(fg != null); + fgColorCheckBox.addActionListener(this); + fgColorCheckBox.setBorder(new EmptyBorder(0,0,0,12)); + fgColorCheckBox.setToolTipText(Messages.getMessage("SourceView.StyleEditor.Color.ToolTip")); + layout.setConstraints(fgColorCheckBox,cons); + panel.add(fgColorCheckBox); + + cons.gridx++; + fgColor = new ColorWellButton(fg); + fgColor.setEnabled(fg != null); + layout.setConstraints(fgColor,cons); + panel.add(fgColor); + + content.add(BorderLayout.CENTER,panel); + + Box box = new Box(BoxLayout.X_AXIS); + box.add(Box.createGlue()); + box.add(ok = new JButton(Messages.getMessage("common.ok"))); + getRootPane().setDefaultButton(ok); + ok.addActionListener(this); + box.add(Box.createHorizontalStrut(6)); + box.add(cancel = new JButton(Messages.getMessage("common.cancel"))); + cancel.addActionListener(this); + box.add(Box.createGlue()); + + content.add(BorderLayout.SOUTH,box); + + pack(); + setLocationRelativeTo(getParentDialog(comp)); + + setResizable(false); + show(); + } //}}} + + //{{{ actionPerformed() method + public void actionPerformed(ActionEvent evt) { + Object source = evt.getSource(); + if(source == ok) + ok(); + else if(source == cancel) + cancel(); + else if(source == fgColorCheckBox) + fgColor.setEnabled(fgColorCheckBox.isSelected()); + } //}}} + + //{{{ ok() method + public void ok() { + okClicked = true; + dispose(); + } //}}} + + //{{{ cancel() method + public void cancel() { + dispose(); + } //}}} + + //{{{ getStyle() method + public SyntaxStyle getStyle() { + if(!okClicked) + return null; + + Color foreground = (fgColorCheckBox.isSelected() + ? fgColor.getSelectedColor() + : null); + + return new SyntaxStyle(foreground, italics.isSelected(), bold.isSelected()); + } //}}} + + //{{{ Private members + private JCheckBox italics; + private JCheckBox bold; + private JCheckBox fgColorCheckBox; + private ColorWellButton fgColor; + private JButton ok; + private JButton cancel; + private boolean okClicked; + //}}} + } //}}} + + //{{{ StyleTableModel class + private static class StyleTableModel extends AbstractTableModel { + private Vector styleChoices; + + //{{{ StyleTableModel constructor + public StyleTableModel() { + styleChoices = new Vector(9); + addStyleChoice("SourceView.Markup", "sourceview.markup.color"); + addStyleChoice("xml.namespace.prefix", "sourceview.namespace.prefix.color"); + addStyleChoice("xml.text", "sourceview.text.color"); + addStyleChoice("xml.element", "sourceview.element.color"); + addStyleChoice("xml.attribute", "sourceview.attribute.color"); + addStyleChoice("xml.attribute.value", "sourceview.attribute.value.color"); + addStyleChoice("xml.cdata", "sourceview.cdata.color"); + addStyleChoice("xml.processing.instruction", "sourceview.processing.instruction.color"); + addStyleChoice("xml.entity.reference", "sourceview.entity.reference.color"); + addStyleChoice("xml.comment", "sourceview.comment.color"); + addStyleChoice("xml.doctype", "sourceview.doctype.color"); + addStyleChoice("SourceView.Invalid", "sourceview.invalid.color"); + MiscUtilities.quicksort(styleChoices, new MiscUtilities.StringCompare()); + } //}}} + + //{{{ getColumnCount() method + public int getColumnCount() + { + return 2; + } //}}} + + //{{{ getRowCount() method + public int getRowCount() + { + return styleChoices.size(); + } //}}} + + //{{{ getValueAt() method + public Object getValueAt(int row, int col) + { + StyleChoice ch = (StyleChoice)styleChoices.elementAt(row); + switch(col) + { + case 0: + return ch.label; + case 1: + return ch.style; + default: + return null; + } + } //}}} + + //{{{ setValueAt() method + public void setValueAt(Object value, int row, int col) + { + StyleChoice ch = (StyleChoice)styleChoices.elementAt(row); + if(col == 1) + ch.style = (SyntaxStyle)value; + fireTableRowsUpdated(row,row); + } //}}} + + //{{{ getColumnName() method + public String getColumnName(int index) + { + switch(index) + { + case 0: + return Messages.getMessage("SourceView.Syntax.Object"); + case 1: + return Messages.getMessage("SourceView.Syntax.Style"); + default: + return null; + } + } //}}} + + //{{{ save() method + public void save() { + for (int i = 0; i < styleChoices.size(); i++) { + StyleChoice ch = (StyleChoice)styleChoices.elementAt(i); + jsXe.setProperty(ch.property, getStyleString(ch.style)); + } + } //}}} + + //{{{ addStyleChoice() method + private void addStyleChoice(String label, String property) { + styleChoices.addElement(new StyleChoice(Messages.getMessage(label), property, parseStyle(jsXe.getProperty(property, "color:#000000")))); + } //}}} + + //{{{ StyleChoice class + private class StyleChoice { + String label; + String property; + SyntaxStyle style; + + StyleChoice(String label, String property, SyntaxStyle style) { + this.label = label; + this.property = property; + this.style = style; + } + + // for sorting + public String toString() { + return label; + } + } //}}} + + //{{{ StyleRenderer class + static class StyleRenderer extends JLabel implements TableCellRenderer { + //{{{ StyleRenderer constructor + public StyleRenderer() { + setOpaque(true); + // setBorder(); + setText("Hello World"); + setToolTipText(Messages.getMessage("SourceView.Syntax.ToolTip")); + } //}}} + + //{{{ getTableCellRendererComponent() method + public Component getTableCellRendererComponent( + JTable table, + Object value, + boolean isSelected, + boolean cellHasFocus, + int row, + int col) + { + if (value != null) { + SyntaxStyle style = (SyntaxStyle)value; + setForeground(style.getColor()); + setBackground(Color.WHITE); + setFont(new Font("Monospaced", (style.isItalic() ? Font.ITALIC : 0) | (style.isBold() ? Font.BOLD : 0), 12)); + } + + //Set a border if focused? + // setBorder(); + return this; + } //}}} + } //}}} + } //}}} + + //{{{ ColorWellButton class + + /** + * A button that, when clicked, shows a color chooser. + * + * You can get and set the currently selected color using + * {@link #getSelectedColor()} and {@link #setSelectedColor(Color)}. + * @author Slava Pestov + * @version $Id$ + */ + public static class ColorWellButton extends JButton { + + //{{{ ColorWellButton constructor + public ColorWellButton(Color color) + { + setIcon(new ColorWell(color)); + setMargin(new Insets(2,2,2,2)); + addActionListener(new ActionHandler()); + + // according to krisk this looks better on OS X... + if(OperatingSystem.isMacOSLF()) + putClientProperty("JButton.buttonType","toolbar"); + } //}}} + + //{{{ getSelectedColor() method + public Color getSelectedColor() + { + return ((ColorWell)getIcon()).color; + } //}}} + + //{{{ setSelectedColor() method + public void setSelectedColor(Color color) + { + ((ColorWell)getIcon()).color = color; + repaint(); + } //}}} + + //{{{ ColorWell class + private class ColorWell implements Icon { + + Color color; + + ColorWell(Color color) + { + this.color = color; + } + + public int getIconWidth() + { + return 35; + } + + public int getIconHeight() + { + return 10; + } + + public void paintIcon(Component c, Graphics g, int x, int y) + { + if(color == null) + return; + + g.setColor(color); + g.fillRect(x,y,getIconWidth(),getIconHeight()); + g.setColor(color.darker()); + g.drawRect(x,y,getIconWidth()-1,getIconHeight()-1); + } + } //}}} + + //{{{ ActionHandler class + class ActionHandler implements ActionListener + { + public void actionPerformed(ActionEvent evt) + { + JDialog parent = getParentDialog(ColorWellButton.this); + JDialog dialog; + if (parent != null) + { + dialog = new ColorPickerDialog(parent, + Messages.getMessage("SourceView.ColorChooser.Title"), + true); + } + else + { + dialog = new ColorPickerDialog( + JOptionPane.getFrameForComponent( + ColorWellButton.this), + Messages.getMessage("SourceView.ColorChooser.Title"), + true); + } + dialog.pack(); + dialog.show(); + } + } //}}} + + //{{{ ColorPickerDialog class + /** + * Replacement for the color picker dialog provided with Swing. This version + * supports dialog as well as frame parents. + */ + private class ColorPickerDialog extends EnhancedDialog implements ActionListener + { + public ColorPickerDialog(Frame parent, String title, boolean modal) + { + super(parent,title,modal); + + init(); + } + + public ColorPickerDialog(Dialog parent, String title, boolean modal) + { + super(parent,title,modal); + + getContent... [truncated message content] |
From: <ian...@us...> - 2006-07-29 04:41:54
|
Revision: 1088 Author: ian_lewis Date: 2006-07-28 21:41:34 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1088&view=rev Log Message: ----------- Merge from trunk/treeview of revision 1086 ViewCVS Links: ------------- http://svn.sourceforge.net/jsxe/?rev=1086&view=rev Modified Paths: -------------- branches/treeview2/Changelog branches/treeview2/build.xml branches/treeview2/dependency.props branches/treeview2/messages/messages.de branches/treeview2/src/treeview/DefaultView.java branches/treeview2/src/treeview/DefaultViewTreeModel.java branches/treeview2/src/treeview/NodeTransferHandler.java branches/treeview2/src/treeview/TransferableNode.java branches/treeview2/src/treeview/TreeViewPlugin.java branches/treeview2/src/treeview/action/AddAttributeAction.java branches/treeview2/src/treeview/action/AddDocTypeAction.java branches/treeview2/src/treeview/action/AddNodeAction.java branches/treeview2/src/treeview/action/CopyNodeAction.java branches/treeview2/src/treeview/action/CutNodeAction.java branches/treeview2/src/treeview/action/EditNodeAction.java branches/treeview2/src/treeview/action/PasteNodeAction.java branches/treeview2/src/treeview/action/RemoveAttributeAction.java branches/treeview2/src/treeview/action/RemoveNodeAction.java branches/treeview2/src/treeview/action/RenameNodeAction.java branches/treeview2/src/treeview/treeview.props Added Paths: ----------- branches/treeview2/messages/messages branches/treeview2/messages/messages.ja branches/treeview2/src/treeview/TreeViewOptionPane.java branches/treeview2/src/treeview/TreeViewTree.java Removed Paths: ------------- branches/treeview2/messages/messages.en branches/treeview2/src/treeview/DefaultViewOptionsPanel.java branches/treeview2/src/treeview/DefaultViewTree.java Modified: branches/treeview2/Changelog =================================================================== --- branches/treeview2/Changelog 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/Changelog 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,3 +1,58 @@ +07/20/2006 Ian Lewis <Ian...@me...> + + * Updated actions and messages for options. + * Added Japanese translation. + +07/13/2006 Ian Lewis <Ian...@me...> + + * Fixed problem where the shortcut for Adding an element node wasn't + showing in the popup menu. + * Fixed problem where the shortcut for Adding and removing an attribute + wasn't showing in the popup menu. + +07/12/2006 Ian Lewis <Ian...@me...> + + * Updated TreeViewTree to use the WrappingMenu instead of EnhancedMenu + since it was renamed. + +07/06/2006 Ian Lewis <Ian...@me...> + + * Updated to support the new Messages format. + +06/25/2006 Ian Lewis <Ian...@me...> + + * Feature Request 1494444: Updated the tree view so that if no attributes + are defined in the Schema/DTD for the element then the Edit Node dialog + will not be displayed. + +06/23/2006 Ian Lewis <Ian...@me...> + + * Added back rudimentary key bindings using Swing Actions so they get + dispached by Swing and are displayed in menus. But infrastructure is + in place to allow jsXe to catch key bindings itself. + +06/21/2006 Ian Lewis <Ian...@me...> + + * Updated TreeViewTree to use the new package for EnhancedMenu so it + compiles properly. + +06/20/2006 Ian Lewis <Ian...@me...> + + * Updated the treeview's actions to extend the new LocalizedAction class. + +06/15/2006 Ian Lewis <Ian...@me...> + + * Updated how properties are loaded for the tree view + +06/13/2006 Ian Lewis <Ian...@me...> + + * Updated the options pane extend AbstractOptionPane + * Renamed the DefaultViewTree to TreeViewTree + +06/09/2006 Ian Lewis <Ian...@me...> + + * Updated version and dependency info + 06/03/2006 Ian Lewis <Ian...@me...> * Updated the Tree View to use the new XMLDocumentListener interface Modified: branches/treeview2/build.xml =================================================================== --- branches/treeview2/build.xml 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/build.xml 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - This is a build.xml file for building the Tree View for jsXe. - Version: $Id$ + :tabSize=2:indentSize=2:noTabs=true: + :folding=explicit:collapseFolds=1: + + This is a build.xml file for building the Tree View for jsXe. + Version: $Id$ --> <project basedir="." default="usage" name="treeview"> @@ -26,7 +29,7 @@ <property name="build.help" value="${build.docs}/help"/> <property name="jsxe.dir" value="${root.dir}/../.."/> <property name="jsxe.jar" value="${jsxe.dir}/jsXe.jar"/> - <property name="jsxe.lib.dir" value="${jsxe.dir}/lib"/> + <property name="jsxe.lib.dir" value="${jsxe.dir}/../lib"/> <property name="javac.debug" value="on"/> <property name="javac.optimize" value="off"/> <property name="javac.deprecation" value="on"/> @@ -35,7 +38,7 @@ <property name="javadoc.link" value="http://java.sun.com/j2se/1.3/docs/api/"/> <property name="main.class" value="treeview.TreeViewPlugin"/> <property name="major.version" value="0"/> - <property name="minor.version" value="4"/> + <property name="minor.version" value="5"/> <property name="build.version" value="3"/> <property name="app.version" value="${major.version}.${minor.version}.${build.version}"/> <property name="app_version" value="${major.version}_${minor.version}_${build.version}"/> @@ -73,11 +76,14 @@ <mkdir dir="${build.dir}"/> <mkdir dir="${build.messages}"/> - <copy todir="${build.messages}"> + <!--<copy todir="${build.messages}"> <fileset dir="${messages.dir}"> <include name="**/messages.*"/> </fileset> - </copy> + </copy>--> + + <!-- run native2ascii on these files --> + <native2ascii encoding="UTF-8" src="${messages.dir}" dest="${build.messages}" includes="messages*"/> </target> <!-- }}} --> <!-- {{{ ============ Prepares the documentation ======================= --> @@ -131,6 +137,8 @@ <attribute name="jsxe-plugin-name" value="${app.name}"/> <attribute name="jsxe-plugin-human-readable-name" value="${readable.name}"/> <attribute name="jsxe-plugin-version" value="${implementation.version}"/> + <attribute name="jsxe-plugin-author" value="Ian Lewis"/> + <!--<attribute name="jsxe-plugin-release-date" value=""/>--> <attribute name="jsxe-plugin-url" value="http://jsxe.sourceforge.net/"/> <attribute name="jsxe-plugin-class" value="${main.class}"/> <attribute name="jsxe-plugin-description" value="${description}"/> @@ -139,7 +147,7 @@ <jar jarfile="${root.dir}/../${app.name}.jar" manifest="${app.name}.manifest"> <fileset dir="${build.dir}"> - <include name="messages/messages.*"/> + <include name="messages/messages*"/> </fileset> <fileset dir="${build.dest}"> <include name="**/*.class"/> Modified: branches/treeview2/dependency.props =================================================================== --- branches/treeview2/dependency.props 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/dependency.props 2006-07-29 04:41:34 UTC (rev 1088) @@ -1 +1 @@ -dependency.0=jsxe 00.04.03.00 +dependency.0=jsxe 00.05.03.00 Copied: branches/treeview2/messages/messages (from rev 1084, trunk/treeview/messages/messages) =================================================================== --- branches/treeview2/messages/messages (rev 0) +++ branches/treeview2/messages/messages 2006-07-29 04:41:34 UTC (rev 1088) @@ -0,0 +1,30 @@ +# JSXE tree view English properties file +# $Id$ +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1: + +TreeView.Options.Title=Tree View + +TreeView.Options.Show.Comments=Show comment nodes +TreeView.Options.Continuous.Layout=Continuous layout for split-panes +TreeView.Options.Show.Attributes=Show element attributes in tree: +Show.Attributes.None=None +Show.Attributes.ID.Only=ID only +Show.Attributes.All=All + + +treeview.rename.node.label=Rename Node +treeview.remove.node.label=Remove Node +treeview.add.attribute.label=Add Attribute +treeview.remove.attribute.label=Remove Attribute +treeview.edit.node.label=Edit Node +TreeView.EditDocType.Title=Edit Document Type Definition +Edit.Node.Dialog.Title=Edit Node + +treeview.add.doctype.node.label=Add Document Type Definition +treeview.add.element.node.label=Add Element Node +treeview.add.text.node.label=Add Text Node +treeview.add.cdata.node.label=Add CDATA Node +treeview.add.pi.node.label=Add Processing Instruction +treeview.add.comment.node.label=Add Comment Modified: branches/treeview2/messages/messages.de =================================================================== --- branches/treeview2/messages/messages.de 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/messages/messages.de 2006-07-29 04:41:34 UTC (rev 1088) @@ -5,19 +5,18 @@ #:tabSize=4:indentSize=4:noTabs=true: #:folding=explicit:collapseFolds=1: +# ä Ä é ö Ö ü Ü ß -#{{{ TreeView TreeView.Options.Title=Tree View Optionen TreeView.Options.Show.Comments=Kommentar Knoten anzeigen -TreeView.Options.Show.Comments.ToolTip =Beim Deaktivieren werden s�mtliche Kommentare in der momentan ge�ffneten XML Datei ausgeblendet. -TreeView.Options.Continuous.Layout=Durchg�ngiges Layout f�r split-panes -TreeView.Options.Continuous.Layout.ToolTip =<HTML>Dies beeinflusst das Aussehen des vertikalen Balkens in der Mitte des jsXE Screens.<BR>Ist dieses Auswahlk�stchen nicht ausgew�hlt w�hrend der vertikale Balken vor und zur�ck �ber den Screen <BR>gezogen wird, bewegt er sich ohne Umst�nde.<BR>Ist dieses Auswahlk�stchen nicht aktiviert w�hrend der vertikale Balken verschoben wird, ver�ndert er sich in <BR>eine dicke schwarze Linie.</HTML> +TreeView.Options.Show.Comments.ToolTip=Beim Deaktivieren werden sämtliche Kommentare in der momentan geöffneten XML Datei ausgeblendet. +TreeView.Options.Continuous.Layout=Durchgängiges Layout für split-panes +TreeView.Options.Continuous.Layout.ToolTip=<HTML>Dies beeinflusst das Aussehen des vertikalen Balkens in der Mitte des jsXE Screens.<BR>Ist dieses Auswahlkästchen nicht ausgewählt während der vertikale Balken vor und zurück über den Screen <BR>gezogen wird, bewegt er sich ohne Umstände.<BR>Ist dieses Auswahlkästchen nicht aktiviert während der vertikale Balken verschoben wird, verändert er sich in <BR>eine dicke schwarze Linie.</HTML> TreeView.Options.Show.Attributes=Show element attributes in tree: -TreeView.Options.Show.Attributes.ToolTip =<HTML>Diese Option verlaubt es, die XML Datei auf verschiedene Arten anzuzeigen. <BR><ul><li><strong>Keine</strong> - blendet alle Attribut-Informationen der Datei aus. </li><li><strong>Nur ID</strong> - nur Attribut-Informationen, die zu einem XML Element mit ID geh�ren, werden angezeigt.</li><li><strong>Alle</strong> - alle Attribut-Informationen werden angezeigt.</li></ul><HTML> +TreeView.Options.Show.Attributes.ToolTip=<HTML>Diese Option verlaubt es, die XML Datei auf verschiedene Arten anzuzeigen. <ul><li><strong>Keine</strong> - blendet alle Attribut-Informationen der Datei aus. </li><li><strong>Nur ID</strong> - nur Attribut-Informationen, die zu einem XML Element mit ID gehören, werden angezeigt.</li><li><strong>Alle</strong> - alle Attribut-Informationen werden angezeigt.</li></ul><HTML> TreeView.RenameNode=Knoten umbenennen TreeView.RemoveNode=Knoten entfernen -TreeView.AddAttribute=Attribut hinzuf�gen +TreeView.AddAttribute=Attribut hinzufügen TreeView.RemoveAttribute=Attribut entfernen TreeView.EditNode=Knoten bearbeiten Edit.Node.Dialog.Title=Knoten bearbeitenn -#}}} Deleted: branches/treeview2/messages/messages.en =================================================================== --- branches/treeview2/messages/messages.en 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/messages/messages.en 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,19 +0,0 @@ -# JSXE tree view English properties file -# $Id$ -#:mode=properties: -#:tabSize=4:indentSize=4:noTabs=true: -#:folding=explicit:collapseFolds=1: - -#{{{ TreeView -TreeView.Options.Title=Tree View Options -TreeView.Options.Show.Comments=Show comment nodes -TreeView.Options.Continuous.Layout=Continuous layout for split-panes -TreeView.Options.Show.Attributes=Show element attributes in tree: -TreeView.RenameNode=Rename Node -TreeView.RemoveNode=Remove Node -TreeView.AddAttribute=Add Attribute -TreeView.RemoveAttribute=Remove Attribute -TreeView.EditNode=Edit Node -TreeView.EditDocType.Title=Edit Document Type Definition -Edit.Node.Dialog.Title=Edit Node -#}}} Copied: branches/treeview2/messages/messages.ja (from rev 1084, trunk/treeview/messages/messages.ja) =================================================================== --- branches/treeview2/messages/messages.ja (rev 0) +++ branches/treeview2/messages/messages.ja 2006-07-29 04:41:34 UTC (rev 1088) @@ -0,0 +1,29 @@ +# JSXE tree view Japanese properties file +# $Id$ +# Maintained by Ian Lewis +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1: + +TreeView.Options.Title=ツリー表示 + +TreeView.Options.Show.Comments=コメントノードを表示する +TreeView.Options.Show.Attributes=要素の属性を表示する: +Show.Attributes.None=なし +Show.Attributes.ID.Only=IDだけ +Show.Attributes.All=全て + +treeview.rename.node.label=ノードをリネーム +treeview.remove.node.label=ノードを削除 +treeview.add.attribute.label=属性を追加 +treeview.remove.attribute.label=属性を削除 +treeview.add.doctype.node.label=DTDを追加 +treeview.edit.node.label=ノードを編集 +TreeView.EditDocType.Title=DTDを編集 +Edit.Node.Dialog.Title=ノードを編集 + +treeview.add.element.node.label=要素を追加 +treeview.add.text.node.label=テキストを追加 +treeview.add.cdata.node.label=CDATA セクションを追加 +treeview.add.pi.node.label=処理命令を追加 +treeview.add.comment.node.label=コメントを追加 Modified: branches/treeview2/src/treeview/DefaultView.java =================================================================== --- branches/treeview2/src/treeview/DefaultView.java 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/src/treeview/DefaultView.java 2006-07-29 04:41:34 UTC (rev 1088) @@ -31,13 +31,11 @@ //{{{ jsXe classes import net.sourceforge.jsxe.dom.*; import net.sourceforge.jsxe.dom.completion.ElementDecl; -import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.DocumentBuffer; -import net.sourceforge.jsxe.ViewPlugin; -import net.sourceforge.jsxe.gui.OptionsPanel; +import net.sourceforge.jsxe.*; import net.sourceforge.jsxe.gui.DocumentView; import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.msg.PropertyChanged; //}}} //{{{ Swing components @@ -75,7 +73,7 @@ * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ */ -public class DefaultView extends JPanel implements DocumentView { +public class DefaultView extends JPanel implements DocumentView, EBListener { //{{{ Private static members private static final Properties m_defaultProperties; @@ -108,6 +106,8 @@ m_plugin = plugin; + enableEvents(java.awt.AWTEvent.KEY_EVENT_MASK); + setLayout(new BorderLayout()); //{{{ init html editor pane @@ -168,11 +168,11 @@ //TODO: get cut/copy/paste to work in the right hand text window m_editMenu = new JMenu(Messages.getMessage("Edit.Menu")); m_editMenu.setMnemonic('E'); - JMenuItem menuItem = new JMenuItem(jsXe.getAction("treeview.cut.node")); + JMenuItem menuItem = new JMenuItem(ActionManager.getAction("cut")); m_editMenu.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("treeview.copy.node")); + menuItem = new JMenuItem(ActionManager.getAction("copy")); m_editMenu.add(menuItem); - menuItem = new JMenuItem(jsXe.getAction("treeview.paste.node")); + menuItem = new JMenuItem(ActionManager.getAction("paste")); m_editMenu.add(menuItem); //}}} @@ -203,8 +203,8 @@ Container parent = getParent(); if (parent != null) { Dimension size = parent.getSize(); - float vertPercent = Integer.valueOf(m_document.getProperty(VERT_SPLIT_LOCATION)).floatValue(); - float horizPercent = Integer.valueOf(m_document.getProperty(HORIZ_SPLIT_LOCATION)).floatValue(); + float vertPercent = Integer.valueOf(jsXe.getProperty(VERT_SPLIT_LOCATION)).floatValue(); + float horizPercent = Integer.valueOf(jsXe.getProperty(HORIZ_SPLIT_LOCATION)).floatValue(); int vertLoc = (int)((vertPercent/100.0)*size.getHeight()); int horizLoc = (int)((horizPercent/100.0)*size.getWidth()); @@ -219,12 +219,13 @@ });//}}} setDocumentBuffer(document); + + EditBus.addToBus(this); }//}}} //{{{ DocumentView methods //{{{ close() - public boolean close() { //m_document should only be null if setDocumentBuffer was never called. @@ -236,13 +237,15 @@ String vert = Integer.toString((int)(vertSplitPane.getDividerLocation()/size.getHeight()*100)); String horiz = Integer.toString((int)(horizSplitPane.getDividerLocation()/size.getWidth()*100)); - m_document.setProperty(VERT_SPLIT_LOCATION,vert); - m_document.setProperty(HORIZ_SPLIT_LOCATION,horiz); + jsXe.setProperty(VERT_SPLIT_LOCATION,vert); + jsXe.setProperty(HORIZ_SPLIT_LOCATION,horiz); m_document.removeXMLDocumentListener(m_documentListener); } } + EditBus.removeFromBus(this); + return true; }//}}} @@ -271,7 +274,6 @@ }//}}} //{{{ setDocumentBuffer() - public void setDocumentBuffer(DocumentBuffer document) throws IOException { try { @@ -284,8 +286,6 @@ throw new IOException(e.toString()); } - ensureDefaultProps(document); - AdapterNode adapter = document.getAdapterNode(); DefaultViewTreeModel treeModel = new DefaultViewTreeModel(this, document); @@ -304,7 +304,7 @@ styledDoc.addDocumentListener(docListener); //get the splitpane layout options - boolean layout = Boolean.valueOf(document.getProperty(CONTINUOUS_LAYOUT)).booleanValue(); + boolean layout = Boolean.valueOf(jsXe.getProperty(CONTINUOUS_LAYOUT)).booleanValue(); vertSplitPane.setContinuousLayout(layout); horizSplitPane.setContinuousLayout(layout); @@ -330,12 +330,27 @@ //}}} - //{{{ getDefaultViewTree() + //{{{ handleMessage() + public void handleMessage(EBMessage message) { + if (message instanceof PropertyChanged) { + String key = ((PropertyChanged)message).getKey(); + if (CONTINUOUS_LAYOUT.equals(key)) { + boolean layout = Boolean.valueOf(jsXe.getProperty(CONTINUOUS_LAYOUT)).booleanValue(); + vertSplitPane.setContinuousLayout(layout); + horizSplitPane.setContinuousLayout(layout); + } + if (CONTINUOUS_LAYOUT.equals(key) || SHOW_COMMENTS.equals(key) || SHOW_ATTRIBUTES.equals(key)) { + tree.updateUI(); + } + } + }//}}} + + //{{{ getTree() /** * Gets the tree component for this DefaultView. * @return the tree component */ - public DefaultViewTree getDefaultViewTree() { + public TreeViewTree getTree() { return tree; }//}}} @@ -366,18 +381,6 @@ return (node.getNodeValue() != null); }//}}} - //{{{ ensureDefaultProps() - - private void ensureDefaultProps(XMLDocument document) { - //get default properties from jsXe - document.setProperty(CONTINUOUS_LAYOUT, document.getProperty(CONTINUOUS_LAYOUT, m_defaultProperties.getProperty(CONTINUOUS_LAYOUT))); - document.setProperty(HORIZ_SPLIT_LOCATION, document.getProperty(HORIZ_SPLIT_LOCATION, m_defaultProperties.getProperty(HORIZ_SPLIT_LOCATION))); - document.setProperty(VERT_SPLIT_LOCATION, document.getProperty(VERT_SPLIT_LOCATION, m_defaultProperties.getProperty(VERT_SPLIT_LOCATION))); - document.setProperty(SHOW_COMMENTS, document.getProperty(SHOW_COMMENTS, m_defaultProperties.getProperty(SHOW_COMMENTS))); - document.setProperty(SHOW_ATTRIBUTES, document.getProperty(SHOW_ATTRIBUTES, m_defaultProperties.getProperty(SHOW_ATTRIBUTES))); - // document.setProperty(SHOW_EMPTY_NODES, document.getProperty(SHOW_EMPTY_NODES, m_defaultProperties.getProperty(SHOW_EMPTY_NODES))); - }//}}} - //{{{ TablePopupListener class private class TablePopupListener extends MouseAdapter { @@ -410,14 +413,10 @@ JPopupMenu popup = new JPopupMenu(); JMenuItem popupMenuItem; - popupMenuItem = new JMenuItem("Add Attribute"); - popupMenuItem.addActionListener(jsXe.getAction("treeview.add.attribute")); - popup.add(popupMenuItem); + popup.add(ActionManager.getAction("treeview.add.attribute")); if (row != attributesTable.getRowCount()-1) { - popupMenuItem = new JMenuItem("Remove Attribute"); - popupMenuItem.addActionListener(jsXe.getAction("treeview.remove.attribute")); - popup.add(popupMenuItem); + popup.add(ActionManager.getAction("treeview.remove.attribute")); } popup.show(e.getComponent(), e.getX(), e.getY()); } @@ -524,7 +523,7 @@ }//}}} - private DefaultViewTree tree = new DefaultViewTree(); + private TreeViewTree tree = new TreeViewTree(); private JTextArea m_valueTextArea = new JTextArea(""); private DefaultViewTable attributesTable = new DefaultViewTable(); private JSplitPane vertSplitPane; @@ -577,17 +576,8 @@ };//}}} private XMLDocumentListener m_documentListener = new XMLDocumentListener() {///{{{ - //{{{ propertiesChanged - public void propertyChanged(XMLDocument source, String key, String oldValue) { - if (CONTINUOUS_LAYOUT.equals(key)) { - boolean layout = Boolean.valueOf(source.getProperty(CONTINUOUS_LAYOUT)).booleanValue(); - vertSplitPane.setContinuousLayout(layout); - horizSplitPane.setContinuousLayout(layout); - } - if (CONTINUOUS_LAYOUT.equals(key) || SHOW_COMMENTS.equals(key) || SHOW_ATTRIBUTES.equals(key)) { - tree.updateUI(); - } - }//}}} + //{{{ propertiesChanged() + public void propertyChanged(XMLDocument source, String key, String oldValue) {}//}}} //{{{ structureChanged() public void structureChanged(XMLDocument source, AdapterNode location) { @@ -601,21 +591,6 @@ attributesTable.updateUI(); }//}}} - //{{{ insertUpdate() - public void insertUpdate(XMLDocumentEvent event) { - structureChanged(event.getXMLDocument(), null); - }//}}} - - //{{{ removeUpdate() - public void removeUpdate(XMLDocumentEvent event) { - structureChanged(event.getXMLDocument(), null); - }//}}} - - //{{{ changeUpdate() - public void changeUpdate(XMLDocumentEvent event) { - structureChanged(event.getXMLDocument(), null); - }//}}} - };//}}} //}}} Deleted: branches/treeview2/src/treeview/DefaultViewOptionsPanel.java =================================================================== --- branches/treeview2/src/treeview/DefaultViewOptionsPanel.java 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/src/treeview/DefaultViewOptionsPanel.java 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,179 +0,0 @@ -/* -DefaultViewOptionsPanel.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2002 Ian Lewis (Ian...@me...) - -This program 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 -of the License, or (at your option) any later version. - -This program 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 this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package treeview; - -//{{{ imports - -//{{{ jsXe classes -import net.sourceforge.jsxe.dom.*; -import net.sourceforge.jsxe.DocumentBuffer; -import net.sourceforge.jsxe.gui.OptionsPanel; -import net.sourceforge.jsxe.gui.DocumentView; -import net.sourceforge.jsxe.gui.Messages; -//}}} - -//{{{ Swing components -import javax.swing.*; -import javax.swing.text.PlainDocument; -import javax.swing.event.*; -import javax.swing.tree.*; -//}}} - -//{{{ AWT components -import java.awt.*; -import java.awt.event.*; -//}}} - -//{{{ Java base classes -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.Properties; -//}}} - -//}}} - - -public class DefaultViewOptionsPanel extends OptionsPanel { - - //{{{ DefaultViewOptionsPanel constructor - - public DefaultViewOptionsPanel(DocumentBuffer buffer) { - - m_document = buffer; - - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - - setLayout(layout); - - int gridY = 0; - - boolean showCommentNodes = Boolean.valueOf(m_document.getProperty(DefaultView.SHOW_COMMENTS, "false")).booleanValue(); - // boolean showEmptyNodes = Boolean.valueOf(m_document.getProperty(SHOW_EMPTY_NODES, "false")).booleanValue(); - boolean continuousLayout = Boolean.valueOf(m_document.getProperty(DefaultView.CONTINUOUS_LAYOUT, "false")).booleanValue(); - String showAttrs = m_document.getProperty(DefaultView.SHOW_ATTRIBUTES, "ID only"); - - showCommentsCheckBox = new JCheckBox(Messages.getMessage("TreeView.Options.Show.Comments"),showCommentNodes); - showCommentsCheckBox.setToolTipText(Messages.getMessage("TreeView.Options.Show.Comments.ToolTip")); - // showEmptyNodesCheckBox = new JCheckBox("Show whitespace-only nodes",showEmptyNodes); - ContinuousLayoutCheckBox = new JCheckBox(Messages.getMessage("TreeView.Options.Continuous.Layout"),continuousLayout); - ContinuousLayoutCheckBox.setToolTipText(Messages.getMessage("TreeView.Options.Continuous.Layout.ToolTip")); - - JLabel showAttrsLabel = new JLabel(Messages.getMessage("TreeView.Options.Show.Attributes")); - m_showAttrsComboBox = new JComboBox(new String [] {"None", "ID only", "All"}); - - m_showAttrsComboBox.setSelectedItem(showAttrs); - m_showAttrsComboBox.setToolTipText(Messages.getMessage("TreeView.Options.Show.Attributes.ToolTip")); - - constraints.gridy = gridY; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(showAttrsLabel, constraints); - add(showAttrsLabel); - - constraints.gridy = gridY++; - constraints.gridx = 2; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(m_showAttrsComboBox, constraints); - add(m_showAttrsComboBox); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 2; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(showCommentsCheckBox, constraints); - add(showCommentsCheckBox); - - // constraints.gridy = gridY++; - // constraints.gridx = 1; - // constraints.gridheight = 1; - // constraints.gridwidth = 1; - // constraints.weightx = 1.0f; - // constraints.fill = GridBagConstraints.BOTH; - // constraints.insets = new Insets(1,0,1,0); - - // layout.setConstraints(showEmptyNodesCheckBox, constraints); - // add(showEmptyNodesCheckBox); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 2; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(ContinuousLayoutCheckBox, constraints); - add(ContinuousLayoutCheckBox); - }//}}} - - //{{{ save() - - public void save() { - m_document.setProperty(DefaultView.SHOW_COMMENTS,String.valueOf(showCommentsCheckBox.isSelected())); - // m_document.setProperty(SHOW_EMPTY_NODES,(new Boolean(showEmptyNodesCheckBox.isSelected())).toString()); - m_document.setProperty(DefaultView.CONTINUOUS_LAYOUT,String.valueOf(ContinuousLayoutCheckBox.isSelected())); - m_document.setProperty(DefaultView.SHOW_ATTRIBUTES, m_showAttrsComboBox.getSelectedItem().toString()); - }//}}} - - //{{{ getName() - - public String getName() { - return "defaultview"; - }//}}} - - //{{{ getTitle() - - public String getTitle() { - return Messages.getMessage("TreeView.Options.Title"); - }//}}} - - //{{{ Private Members - - private JCheckBox showCommentsCheckBox; - // private JCheckBox showEmptyNodesCheckBox; - private JCheckBox ContinuousLayoutCheckBox; - private JComboBox m_showAttrsComboBox; - - private DocumentBuffer m_document; - - //}}} - -}//}}} Deleted: branches/treeview2/src/treeview/DefaultViewTree.java =================================================================== --- branches/treeview2/src/treeview/DefaultViewTree.java 2006-07-29 04:40:06 UTC (rev 1087) +++ branches/treeview2/src/treeview/DefaultViewTree.java 2006-07-29 04:41:34 UTC (rev 1088) @@ -1,1121 +0,0 @@ -/* -DefaultViewTree.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -jsXe is the Java Simple XML Editorh -jsXe is a gui application that can edit an XML document and create a tree view. -The user can then edit this tree and the content in the tree and save the -document. - -This file contains the tree class that is used in the default view. - -This file written by Ian Lewis (Ian...@me...) -Copyright (C) 2002 Ian Lewis - -This program 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 -of the License, or (at your option) any later version. - -This program 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 this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package treeview; - -//{{{ imports - -import treeview.action.AddNodeAction; - -//{{{ jsXe classes -import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.gui.Messages; -import net.sourceforge.jsxe.gui.EnhancedMenu; -import net.sourceforge.jsxe.dom.*; -import net.sourceforge.jsxe.dom.completion.*; -import net.sourceforge.jsxe.util.Log; -//}}} - -//{{{ Swing components -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.tree.*; -//}}} - -//{{{ AWT components -import java.awt.*; -import java.awt.datatransfer.*; -import java.awt.dnd.*; -import java.awt.event.*; -//}}} - -//{{{ DOM classes -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.DOMException; -import org.w3c.dom.Node; -//}}} - -//{{{ Java base classes -import java.io.IOException; -import java.util.*; -//}}} - -//}}} - -/** - * The DefaultViewTree is the tree that is displayed in the upper-left of - * the DefaultView in jsXe. This class defines methods specific to the tree - * display. - * - * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id$ - * @see DefaultView - */ -public class DefaultViewTree extends JTree implements Autoscroll, ClipboardOwner { - - //{{{ Properties - private final String NODE_EXPANDED = "tree.expandedstate"; - //}}} - - //{{{ DefaultViewTree constructor - /** - * Creates a new DefaultViewTree with the default TreeModel - */ - public DefaultViewTree() { - - //{{{ intitalize Drag n Drop - m_dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, m_treeDGListener); - m_dropTarget = new DropTarget(this, m_acceptableActions, m_treeDTListener, true); - //}}} - - addMouseListener(new TreePopupListener()); - setEditable(false); - addTreeExpansionListener(new TreeExpansionListener() {//{{{ - - //{{{ treeExpanded() - - public void treeExpanded(TreeExpansionEvent event) { - try { - AdapterNode node = (AdapterNode)event.getPath().getLastPathComponent(); - node.setProperty(NODE_EXPANDED, "true"); - } catch (ClassCastException e) {} - }//}}} - - //{{{ treeCollapsed() - - public void treeCollapsed(TreeExpansionEvent event) { - try { - AdapterNode node = (AdapterNode)event.getPath().getLastPathComponent(); - node.setProperty(NODE_EXPANDED, "false"); - } catch (ClassCastException e) {} - }//}}} - - });//}}} - - getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); - - DefaultViewTreeCellRenderer renderer = new DefaultViewTreeCellRenderer(); - setCellRenderer(renderer); - - //Since elements are the only editable nodes... - renderer = new DefaultViewTreeCellRenderer(); - setCellEditor(new DefaultTreeCellEditor(this, renderer, new ElementCellEditor(this, renderer))); - - - ToolTipManager.sharedInstance().registerComponent(this); - - }//}}} - - //{{{ isEditable() - /** - * Indicates if a node is capable of being edited in - * this tree. - * @param node the node to check - * @return true if the node can be edited in this tree - */ - public boolean isEditable(AdapterNode node) { - if (node != null) { - int nodeType = node.getNodeType(); - return (nodeType == Node.ELEMENT_NODE || nodeType == Node.PROCESSING_INSTRUCTION_NODE); - } else { - return false; - } - }//}}} - - //{{{ isExpanded() - - public boolean isExpanded(AdapterNode node) { - return Boolean.valueOf(node.getProperty(NODE_EXPANDED)).booleanValue(); - }//}}} - - //{{{ startEditingAtPath() - - public void startEditingAtPath(TreePath path) { - if (path != null && isEditable((AdapterNode)path.getLastPathComponent())) { - //When editing is finished go back to uneditable - getCellEditor().addCellEditorListener(new CellEditorListener() {//{{{ - public void editingCanceled(ChangeEvent e) { - setEditable(false); - getCellEditor().removeCellEditorListener(this); - } - public void editingStopped(ChangeEvent e) { - setEditable(false); - getCellEditor().removeCellEditorListener(this); - } - });//}}} - setEditable(true); - super.startEditingAtPath(path); - } - }//}}} - - //{{{ getSelectedNode() - /** - * Gets the current node that is selected for editing. - * @return the current selected node or null if no node is selected. - */ - public AdapterNode getSelectedNode() { - TreePath selPath = getLeadSelectionPath(); - AdapterNode selectedNode = null; - if (selPath != null) { - selectedNode = (AdapterNode)selPath.getLastPathComponent(); - } - return selectedNode; - }//}}} - - //{{{ cut() - /** - * Cuts the currently selected node out of the tree and places it in the - * clipboard. - * @return true if the node was successfully cut - * @throws DOMException if the node cannot be removed from the tree. - */ - public boolean cut() throws DOMException { - AdapterNode selectedNode = getSelectedNode(); - Clipboard clipBoard = getToolkit().getSystemClipboard(); - if (selectedNode != null) { - try { - clipBoard.setContents(new TransferableNode(selectedNode), this); - selectedNode.getParentNode().remove(selectedNode); - updateUI(); - return true; - } catch (IllegalStateException e) { - Log.log(Log.ERROR, this, e); - } catch (HeadlessException e) { - Log.log(Log.ERROR, this, e); - } catch (DOMException e) { - clipBoard.setContents(null, this); - throw e; - } - } - return false; - }//}}} - - //{{{ copy() - /** - * Copies the currently selected node to the clipboard. - * @return true if the node was copied successfully - */ - public boolean copy() { - AdapterNode selectedNode = getSelectedNode(); - if (selectedNode != null) { - try { - Clipboard clipBoard = getToolkit().getSystemClipboard(); - AdapterNode newNode = selectedNode.copy(true); - clipBoard.setContents(new TransferableNode(newNode), this); - return true; - } catch (IllegalStateException e) { - Log.log(Log.ERROR, this, e); - } catch (HeadlessException e) { - Log.log(Log.ERROR, this, e); - } - } - return false; - }//}}} - - //{{{ paste() - /** - * Pastes the contents of the clipboard into the currently selected node - * in the document tree. - * @return true if the node was pasted successfully - * @throws DOMException if the node cannot be inserted in the current - * location. - */ - public boolean paste() throws DOMException { - AdapterNode selectedNode = getSelectedNode(); - if (selectedNode != null) { - try { - Clipboard clipBoard = getToolkit().getSystemClipboard(); - Transferable contents = clipBoard.getContents(this); - if (contents != null) { - if (contents.isDataFlavorSupported(TransferableNode.nodeFlavor)) { - AdapterNode node = (AdapterNode)contents.getTransferData(TransferableNode.nodeFlavor); - TreePath pastePath = getLeadSelectionPath(); - selectedNode.addAdapterNode(node); - - //reset the clipboard - StringSelection sel = new StringSelection(""); - clipBoard.setContents(sel, sel); - - refreshExpandedStates(pastePath); - addSelectionPath(pastePath.pathByAddingChild(node)); - updateUI(); - return true; - } - } - } catch (IllegalStateException e) { - Log.log(Log.ERROR, this, e); - } catch (HeadlessException e) { - Log.log(Log.ERROR, this, e); - } catch (UnsupportedFlavorException e) { - Log.log(Log.ERROR, this, e); - } catch (IOException e) { - Log.log(Log.ERROR, this, e); - } - } - return false; - }//}}} - - //{{{ Autoscroll methods - - //{{{ autoscroll() - - public void autoscroll(Point cursorLocn) { - int row = getClosestRowForLocation(cursorLocn.x, cursorLocn.y); - - if (row < 0) { - return; - } - - Rectangle bounds = getBounds(); - - if (cursorLocn.y + bounds.y <= m_AUTOSCROLL_MARGIN) { - if (row <= 0) { - row = 0; - } else { - row -=1; - } - } else { - if (row < getRowCount() - 1) { - row += 1; - } - } - scrollRowToVisible(row); - }//}}} - - //{{{ getAutoscrollInsets() - - public Insets getAutoscrollInsets() { - - Rectangle outerBounds = getBounds(); - Rectangle innerBounds = getParent().getBounds(); - int top = innerBounds.y - outerBounds.y + m_AUTOSCROLL_MARGIN; - int left = innerBounds.x - outerBounds.x + m_AUTOSCROLL_MARGIN; - int bottom = outerBounds.height - innerBounds.height - innerBounds.y + outerBounds.y + m_AUTOSCROLL_MARGIN; - int right = outerBounds.width - innerBounds.width - innerBounds.x + outerBounds.y + m_AUTOSCROLL_MARGIN; - return new Insets(top, left, bottom, right); - }//}}} - - //}}} - - //{{{ ClipboardOwner methods - - //{{{ lostOwnership() - - public void lostOwnership(Clipboard clipboard, Transferable contents) { - // Nothing right now. - }//}}} - - //}}} - - //{{{ Private static members - private static final ImageIcon m_elementIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/Element.png"), "Element"); - private static final ImageIcon m_textIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/Text.png"), "Text"); - private static final ImageIcon m_CDATAIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/CDATA.png"), "CDATA"); - private static final ImageIcon m_commentIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/Comment.png"), "Comment"); - // private static final ImageIcon m_externalEntityIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/ExternalEntity.png"), "External Entity"); - private static final ImageIcon m_internalEntityIcon = new ImageIcon(DefaultView.class.getResource("/net/sourceforge/jsxe/icons/InternalEntity.png"), "Internal Entity"); - - private static final int m_AUTOSCROLL_MARGIN = 12; - //}}} - - //{{{ Private members - - //{{{ refreshExpandedStates() - /** - * Refreshes the expanded states of all the node pointed to by - * the treepath and all nodes below it. Used after a drag and - * drop is done because the JTree uses TreePaths to keep track - * of expanded states. When a drag and drop is done the - * path is broken and the expanded states are lost. - */ - private void refreshExpandedStates(TreePath path) { - AdapterNode node = (AdapterNode)path.getLastPathComponent(); - boolean expandedState = isExpanded(node); - if (node.childCount() > 0) { - expandPath(path); //expand all nodes out - //still have to set expanded states - int children = node.childCount(); - for (int i=0;i < children; i++) { - TreePath newPath = path.pathByAddingChild(node.child(i)); - refreshExpandedStates(newPath); - } - if (expandedState) { //close non-expanded nodes - expandPath(path); - } else { - collapsePath(path); - } - } - }//}}} - - //{{{ toString() - /** - * Creates the string that will be displayed in the tree node - * @param showattrs "ID only", "All" or "None" - */ - private static String toString(AdapterNode node) { - StringBuffer s = new StringBuffer(); - if (node.getNodeType() == Node.DOCUMENT_NODE) - return "Document Root"; - String nodeName = node.getNodeName(); - if (! nodeName.startsWith("#")) { - s.append(nodeName); - if (node.getNodeType() == AdapterNode.ELEMENT_NODE) { - NamedNodeMap attributes = node.getAttributes(); - ElementDecl decl = node.getElementDecl(); - XMLDocument document = node.getOwnerDocument(); - String showAttrs = document.getProperty(DefaultView.SHOW_ATTRIBUTES); - for (int i=0; i<attributes.getLength(); i++) { - Node attr = attributes.item(i); - ElementDecl.AttributeDecl attrDecl = (decl != null) ? decl.getAttribute(attr.getNodeName()) : null; - if (showAttrs.equals("All") || - (showAttrs.equals("ID only") && - ((attr.getNodeName().equalsIgnoreCase("id") || - (attrDecl != null && attrDecl.type.equals("ID")))))) - { - s.append(' '+attr.getNodeName() + "=\"" + attr.getNodeValue() + '"'); - } - } - } - } - if (s.length()==0) { - if (node.getNodeValue() != null) { - String t = node.getNodeValue().trim(); - int x = t.indexOf("\n"); - if (x >= 0) { - t = t.substring(0, x); - } - if (t.length() > 50) { - t = t.substring(0, 50) + "..."; - } - s.append(t); - } - } - return s.toString(); - }//}}} - - //{{{ TreePopupListener class - //TODO: rework this class - private class TreePopupListener extends MouseAdapter { - - //{{{ mousePressed() - - public void mousePressed(MouseEvent e) { - maybeShowPopup(e); - }//}}} - - //{{{ mouseReleased() - - public void mouseReleased(MouseEvent e) { - maybeShowPopup(e); - }//}}} - - //{{{ maybeShowPopup() - - private void maybeShowPopup(MouseEvent e) { - TreePath selPath = getPathForLocation(e.getX(), e.getY()); - if (e.isPopupTrigger() && selPath != null) { - setSelectionPath(selPath); - - //Don't want to interact with AdapterNodes too much. Maybe change this. - AdapterNode selectedNode = ((AdapterNode)selPath.getLastPathComponent()); - XMLDocument ownerDocument = selectedNode.getOwnerDocument(); - - JMenuItem popupMenuItem; - JMenu addNodeItem = new JMenu(Messages.getMessage("common.add")); - JPopupMenu popup = new JPopupMenu(); - boolean showpopup = false; - boolean addNodeShown = false; - - if (selectedNode.getNodeType() == Node.ELEMENT_NODE) { - - JMenu addElement = new EnhancedMenu(Messages.getMessage("xml.element"), 20); - addNodeItem.add(addElement); - - addElement.add(jsXe.getAction("treeview.add.element.node")); - Iterator allowedElements = selectedNode.getAllowedElements().iterator(); - while (allowedElements.hasNext()) { - ElementDecl decl = (ElementDecl)allowedElements.next(); - addElement.add(new AddNodeAction(decl, decl.name)); - } - - //Add the allowed entities even if no matter what - - JMenu addEntity = new EnhancedMenu(Messages.getMessage("xml.entity.reference"), 20); - addNodeItem.add(addEntity); - - Iterator allowedEntities = ownerDocument.getAllowedEntities().iterator(); - while (allowedEntities.hasNext()) { - EntityDecl decl = (EntityDecl)allowedEntities.next(); - popupMenuItem = new JMenuItem(new AddNodeAction(decl.name, decl.name, decl.value, AdapterNode.ENTITY_REFERENCE_NODE)); - addEntity.add(popupMenuItem); - } - - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.text.node")); - popupMenuItem.setText(Messages.getMessage("xml.text")); - addNodeItem.add(popupMenuItem); - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.cdata.node")); - popupMenuItem.setText(Messages.getMessage("xml.cdata")); - addNodeItem.add(popupMenuItem); - - // popupMenuItem = new JMenuItem(new AddNodeAction("New_Entity", "", Node.ENTITY_REFERENCE_NODE)); - // addNodeItem.add(popupMenuItem); - addNodeShown = true; - showpopup = true; - } - - if (selectedNode.getNodeType() == Node.DOCUMENT_NODE) { - if (ownerDocument.getDocType() == null) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.doctype.node")); - popupMenuItem.setText(Messages.getMessage("xml.doctypedef")); - addNodeItem.add(popupMenuItem); - showpopup = true; - } - } - - if (selectedNode.getNodeType() == Node.DOCUMENT_NODE || selectedNode.getNodeType() == Node.ELEMENT_NODE) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.processing.instruction.node")); - popupMenuItem.setText(Messages.getMessage("xml.processing.instruction")); - addNodeItem.add(popupMenuItem); - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.add.comment.node")); - popupMenuItem.setText(Messages.getMessage("xml.comment")); - addNodeItem.add(popupMenuItem); - addNodeShown = true; - showpopup = true; - } - - if (addNodeShown) { - popup.add(addNodeItem); - } - - //Add the edit node action - if (selectedNode.getNodeType() == Node.ELEMENT_NODE && ownerDocument.getElementDecl(selectedNode.getNodeName()) != null) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.edit.node")); - popup.add(popupMenuItem); - showpopup = true; - } - - if (selectedNode.getNodeType() == Node.ELEMENT_NODE || selectedNode.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.rename.node")); - popup.add(popupMenuItem); - showpopup = true; - } - //if the node is not the document, document type, or the document root. - if (selectedNode.getNodeType() != Node.DOCUMENT_NODE && - selectedNode.getNodeType() != Node.DOCUMENT_TYPE_NODE && - !(selectedNode.getNodeType() == Node.ELEMENT_NODE && - selectedNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE)) - { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.remove.node")); - popup.add(popupMenuItem); - showpopup = true; - } - - if (selectedNode.getNodeType() != Node.DOCUMENT_NODE && - selectedNode.getNodeType() != Node.DOCUMENT_TYPE_NODE) - { - popup.addSeparator(); - if(!(selectedNode.getNodeType() == Node.ELEMENT_NODE && - selectedNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE)) - { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.cut.node")); - popup.add(popupMenuItem); - } - - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.copy.node")); - popup.add(popupMenuItem); - - if (selectedNode.getNodeType() == Node.ELEMENT_NODE) { - popupMenuItem = new JMenuItem(jsXe.getAction("treeview.paste.node")); - popup.add(popupMenuItem); - } - showpopup = true; - } - - if (showpopup) { - popup.show(e.getComponent(), e.getX(), e.getY()); - } - } - }//}}} - - }//}}} - - //{{{ DefaultViewTreeCellRenderer class - - private class DefaultViewTreeCellRenderer extends DefaultTreeCellRenderer { - - //{{{ DefaultViewTreeCellRenderer constructor - - DefaultViewTreeCellRenderer() { - m_defaultLeafIcon = getLeafIcon(); - m_defaultOpenIcon = getOpenIcon(); - m_defaultClosedIcon = getClosedIcon(); - m_defaultBackgroundSelectionColor = this.backgroundSelectionColor; - }//}}} - - //{{{ getTreeCellRendererComponent() - - public Component getTreeCellRendererComponent(JTree tree, - Object value, boolean selected, boolean expanded, - boolean leaf, int row, boolean hasFocus) - { - - int type = -1; - try { - AdapterNode node = (AdapterNode)value; - type = node.getNodeType(); - setText(DefaultViewTree.toString(node)); - } catch (ClassCastException e) {} - - this.selected = selected; - if (value != null && m_dragOverTarget == value) { - this.selected = true; - backgroundSelectionColor = m_dragSelectionColor; - } else { - backgroundSelectionColor = m_defaultBackgroundSelectionColor; - } - - switch (type) { - case Node.ELEMENT_NODE: - setIcon(m_elementIcon); - setLeafIcon(m_elementIcon); - setOpenIcon(m_elementIcon); - setClosedIcon(m_elementIcon); - setToolTipText(Messages.getMessage("xml.element")); - break; - case Node.TEXT_NODE: - setIcon(m_textIcon); - setLeafIcon(m_textIcon); - setOpenIcon(m_textIcon); - setClosedIcon(m_textIcon); - setToolTipText(Messages.getMessage("xml.text")); - break; - case Node.CDATA_SECTION_NODE: - setIcon(m_CDATAIcon); - setLeafIcon(m_CDATAIcon); - setOpenIcon(m_CDATAIcon); - setClosedIcon(m_CDATAIcon); - setToolTipText(Messages.getMessage("xml.cdata")); - break; - case Node.COMMENT_NODE: - setIcon(m_commentIcon); - setLeafIcon(m_commentIcon); - setOpenIcon(m_commentIcon); - setClosedIcon(m_commentIcon); - setToolTipText(Messages.getMessage("xml.comment")); - break; - case Node.ENTITY_REFERENCE_NODE: - setIcon(m_internalEntityIcon); - setLeafIcon(m_internalEntityIcon); - setOpenIcon(m_internalEntityIcon); - setClosedIcon(m_internalEntityIcon); - setToolTipText(Messages.getMessage("xml.entity.reference")); - break; - case Node.DOCUMENT_NODE: - setIcon(m_defaultClosedIcon); - setLeafIcon(m_defaultLeafIcon); - setOpenIcon(m_defaultOpenIcon); - setClosedIcon(m_defaultClosedIcon); - setToolTipText(Messages.getMessage("xml.document")); - break; - case Node.PROCESSING_INSTRUCTION_NODE: - setIcon(m_defaultLeafIcon); - setLeafIcon(m_defaultLeafIcon); - setOpenIcon(m_defaultLeafIcon); - setClosedIcon(m_defaultLeafIcon); - setToolTipText(Messages.getMessage("xml.processing.instruction")); - break; - case Node.DOCUMENT_TYPE_NODE: - setIcon(m_defaultLeafIcon); - setLeafIcon(m_defaultLeafIcon); - setOpenIcon(m_defaultLeafIcon); - setClosedIcon(m_defaultLeafIcon); - setToolTipText(Messages.getMessage("xml.doctypedef")); - break; - default: - if (leaf) { - setIcon(m_defaultLeafIcon); - } else { - if (expanded) { - setIcon(m_defaultOpenIcon); - } else { - setIcon(m_defaultClosedIcon); - } - } - - setLeafIcon(m_defaultLeafIcon); - setOpenIcon(m_defaultOpenIcon); - setClosedIcon(m_defaultClosedIcon); - setToolTipText("Unknown node"); - break; - } - - return this; - }//}}} - - //{{{ Private members - - private Icon m_defaultLeafIcon; - private Icon m_defaultOpenIcon; - private Icon m_defaultClosedIcon; - private Color m_defaultBackgroundSelectionColor; - //}}} - - }//}}} - - //{{{ ElementTreeCellRenderer class - - private class ElementTreeCellRenderer extends DefaultTreeCellRenderer { - - //{{{ ElementTreeCellRenderer constructor - - public ElementTreeCellRenderer() { - m_defaultLe... [truncated message content] |
From: <ian...@us...> - 2006-07-29 04:41:20
|
Revision: 1087 Author: ian_lewis Date: 2006-07-28 21:40:06 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1087&view=rev Log Message: ----------- Merge from trunk/jsxe of revision 1086 ViewCVS Links: ------------- http://svn.sourceforge.net/jsxe/?rev=1086&view=rev Modified Paths: -------------- branches/jsxe2/Changelog branches/jsxe2/INSTALL branches/jsxe2/NEWS branches/jsxe2/RELEASE.CHECKLIST branches/jsxe2/build.xml branches/jsxe2/messages/messages.de branches/jsxe2/messages/messages.sv branches/jsxe2/src/net/sourceforge/jsxe/ActionPlugin.java branches/jsxe2/src/net/sourceforge/jsxe/ActionSet.java branches/jsxe2/src/net/sourceforge/jsxe/CatalogManager.java branches/jsxe2/src/net/sourceforge/jsxe/CustomFileFilter.java branches/jsxe2/src/net/sourceforge/jsxe/DocumentBuffer.java branches/jsxe2/src/net/sourceforge/jsxe/DocumentBufferListener.java branches/jsxe2/src/net/sourceforge/jsxe/JARClassLoader.java branches/jsxe2/src/net/sourceforge/jsxe/OperatingSystem.java branches/jsxe2/src/net/sourceforge/jsxe/PluginDependencyException.java branches/jsxe2/src/net/sourceforge/jsxe/PluginLoadException.java branches/jsxe2/src/net/sourceforge/jsxe/UnrecognizedPluginException.java branches/jsxe2/src/net/sourceforge/jsxe/action/ActivityLogAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FileCloseAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FileCloseAllAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FileExitAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FileNewAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FileOpenAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FileReloadAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FileSaveAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FileSaveAsAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/OpenRecentFileAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/ToolsOptionsAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/ToolsPluginManagerAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/ValidationErrorsAction.java branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocumentListener.java branches/jsxe2/src/net/sourceforge/jsxe/gui/ActivityLogDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/DirtyFilesDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/EnhancedDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/ErrorListDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/GlobalOptionsDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/Messages.java branches/jsxe2/src/net/sourceforge/jsxe/gui/OptionsDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/OptionsPanel.java branches/jsxe2/src/net/sourceforge/jsxe/gui/PluginManagerDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/StatusBar.java branches/jsxe2/src/net/sourceforge/jsxe/gui/TabbedView.java branches/jsxe2/src/net/sourceforge/jsxe/gui/jsxeAboutDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/jsxeFileDialog.java branches/jsxe2/src/net/sourceforge/jsxe/jsXe.java branches/jsxe2/src/net/sourceforge/jsxe/options/OptionPane.java branches/jsxe2/src/net/sourceforge/jsxe/properties branches/jsxe2/src/net/sourceforge/jsxe/util/Log.java branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java Added Paths: ----------- branches/jsxe2/buildlib/ branches/jsxe2/buildlib/jsmoothgen-ant.jar branches/jsxe2/buildlib/skeletons/ branches/jsxe2/buildlib/skeletons/windowed-wrapper/ branches/jsxe2/buildlib/skeletons/windowed-wrapper/description.skel branches/jsxe2/buildlib/skeletons/windowed-wrapper/jwrap.exe branches/jsxe2/jsXe.jsmooth branches/jsxe2/messages/messages branches/jsxe2/messages/messages.ja branches/jsxe2/src/net/sourceforge/jsxe/ActionManager.java branches/jsxe2/src/net/sourceforge/jsxe/EBListener.java branches/jsxe2/src/net/sourceforge/jsxe/EBMessage.java branches/jsxe2/src/net/sourceforge/jsxe/EditBus.java branches/jsxe2/src/net/sourceforge/jsxe/LocalizedAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/CopyAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/CutAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/DocumentOptionsAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FindAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/FindNextAction.java branches/jsxe2/src/net/sourceforge/jsxe/action/PasteAction.java branches/jsxe2/src/net/sourceforge/jsxe/gui/DocumentOptionsDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/GUIUtilities.java branches/jsxe2/src/net/sourceforge/jsxe/gui/GrabKeyDialog.java branches/jsxe2/src/net/sourceforge/jsxe/gui/GridPanel.java branches/jsxe2/src/net/sourceforge/jsxe/gui/KeyEventTranslator.java branches/jsxe2/src/net/sourceforge/jsxe/gui/KeyEventWorkaround.java branches/jsxe2/src/net/sourceforge/jsxe/gui/VariableGridLayout.java branches/jsxe2/src/net/sourceforge/jsxe/gui/menu/ branches/jsxe2/src/net/sourceforge/jsxe/gui/menu/WrappingMenu.java branches/jsxe2/src/net/sourceforge/jsxe/msg/ branches/jsxe2/src/net/sourceforge/jsxe/msg/DocumentBufferUpdate.java branches/jsxe2/src/net/sourceforge/jsxe/msg/PropertyChanged.java branches/jsxe2/src/net/sourceforge/jsxe/options/AbstractOptionPane.java branches/jsxe2/src/net/sourceforge/jsxe/options/GeneralOptionPane.java branches/jsxe2/src/net/sourceforge/jsxe/options/ShortcutsOptionPane.java Removed Paths: ------------- branches/jsxe2/buildlib/jsmoothgen-ant.jar branches/jsxe2/buildlib/skeletons/ branches/jsxe2/buildlib/skeletons/windowed-wrapper/ branches/jsxe2/buildlib/skeletons/windowed-wrapper/description.skel branches/jsxe2/buildlib/skeletons/windowed-wrapper/jwrap.exe branches/jsxe2/messages/messages.en branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocumentEvent.java branches/jsxe2/src/net/sourceforge/jsxe/dom/event/ branches/jsxe2/src/net/sourceforge/jsxe/gui/EnhancedMenu.java branches/jsxe2/src/net/sourceforge/jsxe/gui/menu/WrappingMenu.java branches/jsxe2/src/net/sourceforge/jsxe/msg/DocumentBufferUpdate.java branches/jsxe2/src/net/sourceforge/jsxe/msg/PropertyChanged.java Modified: branches/jsxe2/Changelog =================================================================== --- branches/jsxe2/Changelog 2006-07-29 01:44:34 UTC (rev 1086) +++ branches/jsxe2/Changelog 2006-07-29 04:40:06 UTC (rev 1087) @@ -1,6 +1,14 @@ +07/28/2006 Ian Lewis <Ian...@me...> + + * Added some multi-threaded support. + 07/26/2006 Ian Lewis <Ian...@me...> * Added support for error nodes in the new data model + * Updated the find and findnext actions to use proper messages + labels. + * Fixed a bug where the shortcuts for Built-In commands were not being + honored. 07/25/2006 Ian Lewis <Ian...@me...> @@ -12,12 +20,90 @@ types. * Added some support for the URIs and standalone properties in XMLDocument. + * Fixed a bug with the source view for new users that caused a + NullPointerException to be thrown when opening the source view. + * Added a wrapper exe for windows users using jSmooth +07/21/2006 Ian Lewis <Ian...@me...> + + * Fixed bug 1509575. Files that are reloaded should always be loaded in a + view that can accep the reloaded file. + 07/20/2006 Ian Lewis <Ian...@me...> * Xerces needs to be installed in the java endorsed directory now to make use of DOM3 classes. + * Released 0.5pre1 + * Keyboard shortcuts are now fully supported. + * Added Japanese translation +07/12/2006 Ian Lewis <Ian...@me...> + + * Added functionality to save keyboard shortcuts. The shortcuts themselves + work but the shortcut labels for menu items are not updated when the + action is updated. This is a bug that is fixed in the beta for Java 6 + but obviously it can't wait that long. + * Renamed EnhancedMenu to WrappingMenu. I think it's more descriptive. + * Updated messages to load the messages files in UTF-8 + +07/10/2006 Ian Lewis <Ian...@me...> + + * Added the Shortcuts option pane. However, it currently it doesn't work. + It only displays the built in options and the combo box. + * Updated the shortcuts option pane so that it shows the select shortcut + dialog. + +07/06/2006 Ian Lewis <Ian...@me...> + + * Rewrote the Messages class. Now it loads messages on demand and only + loads the messages that it needs but allows the Locale to be changed at + any time. It also now supports different countries and variants. + +06/27/2006 Ian Lewis <Ian...@me...> + + * Added the GUIUtilities class for handling utility functions in jsXe. + * Added the GrabKeyDialog which will be used to assign shortcuts. + * Updated many classes for supporting shortcuts. + +06/23/2006 Ian Lewis <Ian...@me...> + + * Added back rudimentary key bindings using Swing Actions so they get + dispached by Swing and are displayed in menus. But infrastructure is + in place to allow jsXe to catch key bindings itself. + +06/21/2006 Ian Lewis <Ian...@me...> + + * Moved EnhancedMenu to it's own package. I will be creating a new menu + class that is specially designed for jsXe's LocalizedActions + * Created a new option for how many items can be in menus before they spill + over. + +06/20/2006 Ian Lewis <Ian...@me...> + + * Updated actions in jsXe so that actions can be easily localized and + so that they can be assigned shortcuts. Future actions that are registered + with jsXe will extend this class. The ActionManager now manages ActionSets + and key bindings within jsXe. + +06/15/2006 Ian Lewis <Ian...@me...> + + * Added a new Status column to the Plugin Manager dialog + * Added new plugin properties for the plugin author and release date + +06/14/2006 Ian Lewis <Ian...@me...> + + * Added the EditAction class for future actions in jsXe. + The messages, menu mnemonics, and tooltips will be able to be + localized and the shortcuts will be able to be set via the + InputManager. + +06/13/2006 Ian Lewis <Ian...@me...> + + * Added the InputManager for maintaining the key bindings for actions in + jsXe. + * Updated the param string for PropertyChanged messages. + * Moved the general options pane to it's own file. + 06/08/2006 Ian Lewis <Ian...@me...> * XMLAttribute was added to the new data model. @@ -28,7 +114,28 @@ * Added a new XMLDocumentType class * Added factory methods for XMLElements and XMLAttributes to the XMLDocument class. + * Added a PropertyChanged event for when one of jsXe's properties changes. + * Updated lots of javadoc + * jsXe's global options now implements AbstractOptionPane +06/07/2006 Ian Lewis <Ian...@me...> + + * Updated the document options to use abstract classes to lay out the + dialog. OptionsPanel is now deprecated in favor of using the OptionPane + and AbstractOptionPane classes. + * Updated dialogs to use setVisible() instead of show() + +06/06/2006 Ian Lewis <Ian...@me...> + + * Added a new Document Options Dialog which handles settings on a per + document basis. + * Updated the Global Options so that they don't include the per document + options anymore. + * Updated the DirtyFilesDialog so that it selects the first entry by + default. + * Updated EnhancedDialogs to be resizable by default. + * Updated the file dialog to use localized messages in the title + 06/04/2006 Ian Lewis <Ian...@me...> * XMLElement was added to model element nodes @@ -43,6 +150,11 @@ * Added insertUpdate and removeUpdate methods to the XMLDocumentListener * Updated XMLDocument to notify listeners on insert and remove events. +05/31/2006 Ian Lewis <Ian...@me...> + + * All plugins now implement EBListener and are added to the EditBus + * Updated the use of EditBus messages + 05/24/2006 Ian Lewis <Ian...@me...> * Updated the minimum version of xerces needed to run jsXe to 2.8. Modified: branches/jsxe2/INSTALL =================================================================== --- branches/jsxe2/INSTALL 2006-07-29 01:44:34 UTC (rev 1086) +++ branches/jsxe2/INSTALL 2006-07-29 04:40:06 UTC (rev 1087) @@ -25,10 +25,12 @@ BUILDING jsXe FROM SOURCE This is pretty simple. You will need jakarta ANT and a Sun's javac compiler -(others might work, I just haven't tested them). Also, in order for jsXe to -compile properly you will need Apache Xerces installed. +(others might work, I just haven't tested them). You will need the optional +ant tasks installed as well. On some Linux distributions this may be a separate +package. Also, in order for jsXe to compile properly you will need Apache +Xerces installed. -You should have 1.4.2 or better of java and you will need version 2.8.0 of +You will need version 1.4.2 or better of java and you will need version 2.8.0 of Xerces (A Xerces 2.8.0 binary distribution is not included in the CVS source tree. You can aquire it at at http://xml.apache.org/) The jar files xercesImpl.jar, xml-apis.jar, and resolver.jar from the 2.8.0 distribution are @@ -36,7 +38,7 @@ (where you installed jsXe's source) or in the jre/lib/ext or lib/ext in your JVM. These jar files will be included with jsXe distributions for convenience. -Simply typing 'ant' or 'ant -p' in jsXe's root directory will give you the +Simply typing 'ant' in jsXe's root directory will give you the available targets to use with ant. To just simply compile jsXe and the default views to a jar file you can type 'ant compile'. To build a binary distribution you will need to run the 'bin' target in the build.xml file. I do this by simply @@ -51,23 +53,19 @@ RUNNING jsXe You should have 1.4.2 or better of java and you need 2.6.2 of Xerces. -To run jsXe you should just run the java interpreter on the jsXe.jar file. There -is a shell script or batch file included in the source tree for this purpose. - ./bin/jsXe.sh +*Windows* -or +Just run jsXe using the jsXe.exe in the install directory. The exe will +detect your version of Java and run jsXe using that version. - ./bin/jsXe.bat +*Unix* -The batch program should be run in with the jsXe root directory of as the -working directory. So you can create a shortcut to run jsXe by specifying the -batch file as the program to run and jsXe's root directory as the working -directory. +To run jsXe you should just run the java interpreter on the jsXe.jar file. There +is a shell script or batch file included in the source tree for this purpose. -Ex. -Target: "C:\Program Files\jsXe\bin\jsXe.bat" -Start in: "C:\Program Files\jsXe\" +./bin/jsXe.sh -You can also edit the JSXEDIR variable in the batch program to be the directory -where you installed jsXe and then the 'Start in' directory can be anywhere. +The shell script should be run in with the jsXe root directory of as the +working directory. You can also edit the JSXEDIR variable in the shell script +to be the directory where you installed jsXe. Modified: branches/jsxe2/NEWS =================================================================== --- branches/jsxe2/NEWS 2006-07-29 01:44:34 UTC (rev 1086) +++ branches/jsxe2/NEWS 2006-07-29 04:40:06 UTC (rev 1087) @@ -1,3 +1,24 @@ +07/24/2006 version 0.5 pre2 + + * Fixed a bug with the source view for new users that caused a + NullPointerException to be thrown when opening the source view. + * Added a wrapper exe for windows users using jSmooth + * Fixed bug 1509575. Files that are reloaded should always be loaded in a + view that can accep the reloaded file. + +07/20/2006 version 0.5 pre1 + + * Added support for keyboard shortcuts that can be set by the user via + the Global Options Dialog. + * Split the options into two dialogs. The Global Options, which are + editor-wide options, and the Document Options, which are set for each + document. + * Added a Japanese translation. + * Added a British-English translation. + * Fixed translation files so that non-ASCII characters will be displayed + properly. + * Added a status bar to display messages to the user. + 04/25/2006 version 0.4 beta * Updated to work with xerces 2.8.0 (jsXe now requires xerces 2.8.0) Modified: branches/jsxe2/RELEASE.CHECKLIST =================================================================== --- branches/jsxe2/RELEASE.CHECKLIST 2006-07-29 01:44:34 UTC (rev 1086) +++ branches/jsxe2/RELEASE.CHECKLIST 2006-07-29 04:40:06 UTC (rev 1087) @@ -1,48 +1,17 @@ RELEASE CHECKLIST -*********Minor release********* +* Make sure all bugs that are priority 5 or higher are resolved. -* Update the Changelog file -* Update the NEWS file -* Update the README if needed -* Update the AUTHORS if needed -* Update the INSTALL file if needed -* Update the README if needed - -* Make a new tag in SVN for the release. - -* Update the jsXe website in SVN to reference the new versions -* Update the jsXe website in SVN to have the correct help and documentation. - * Run 'ant deploy-web-doc' - -Build the project - * Make sure the major.version, minor.version, beta.version, bugfix.version, - app.version, and app_version are correct in build.xml - * Build the release files using 'ant bin src' - -* Create new release on sourceforge - * Upload binary and source distribution to Sourceforge - * Add the NEWS and Changelog entries to the release. -* Update the News on the sourceforge project page. -* Update the freshmeat project with the new version and URLs. - -*********Major release********* - * Get translations finalized * Build the Java Doc and check it for omissions and errors. -* Make sure all bugs that have a priority above 5 are resolved. * Update the Changelog file * Update the NEWS file * Update the README if needed * Update the AUTHORS if needed * Update the INSTALL file if needed -* Update the README if needed - -* Make a new tag in SVN for the release. - -* Update the jsXe website in SVN to reference the new versions -* Update the jsXe website in SVN to have the correct help and documentation. +* Update the jsXe website in CVS to reference the new versions +* Update the jsXe website in CVS to have the correct help and documentation. * Run 'ant deploy-web-doc' Build the project Modified: branches/jsxe2/build.xml =================================================================== --- branches/jsxe2/build.xml 2006-07-29 01:44:34 UTC (rev 1086) +++ branches/jsxe2/build.xml 2006-07-29 04:40:06 UTC (rev 1087) @@ -9,161 +9,196 @@ You should check out jsxe to make a structure like this. This ensures that when compiling jsXe the other views will be compiled as well. - jsxe module => jsxe/ - treeview module => jsxe/jars/treeview - sourceview module => jsxe/jars/sourceview - jsxe web module => web/ + jsxe module => jsxe/ + treeview module (optional) => jsxe/jars/treeview + sourceview module (optional) => jsxe/jars/sourceview + jsxe web module (optional) => web/ + jsmooth ant task (optional) => buildlib/ + --> <project basedir="." default="usage" name="jsXe"> - + <description>jsXe - Java Simple XML Editor</description> <!-- {{{ ============ Initializes properties and variables ============= --> - <target name="init"> - <tstamp/> - <property name="app.name" value="jsXe"/> - <property name="root.dir" value="."/> + <target name="init"> + <tstamp/> + <property name="app.name" value="jsXe"/> + <property name="root.dir" value="."/> <property name="build.dir" value="${root.dir}/build"/> - <property name="src.dir" value="${root.dir}/src"/> - <property name="lib.dir" value="${root.dir}/lib"/> - <property name="bin.dir" value="${root.dir}/bin"/> - <property name="messages.dir" value="${root.dir}/messages"/> + <property name="src.dir" value="${root.dir}/src"/> + <property name="lib.dir" value="${root.dir}/lib"/> + <property name="bin.dir" value="${root.dir}/bin"/> + <property name="messages.dir" value="${root.dir}/messages"/> <property name="build.messages" value="${build.dir}/messages"/> <property name="docs.dir" value="${src.dir}/doc"/> <property name="plugin.dir" value="${root.dir}/jars"/> - <property name="build.src" value="${build.dir}/src"/> - <property name="build.dest" value="${build.dir}/classes"/> - <property name="build.docs" value="${build.dir}/doc"/> - <property name="build.lib" value="${build.dir}/lib"/> - <property name="build.bin" value="${build.dir}/bin"/> - <property name="build.bin" value="${build.dir}/bin"/> + <property name="build.plugin" value="${build.dir}/jars"/> + <property name="build.src" value="${build.dir}/src"/> + <property name="build.dest" value="${build.dir}/classes"/> + <property name="build.docs" value="${build.dir}/doc"/> + <property name="build.lib" value="${build.dir}/lib"/> + <property name="build.bin" value="${build.dir}/bin"/> <property name="date.format" value="MM.dd.yyyy HH:mm:ss z"/> - <property name="build.javadocs" value="${build.docs}/api"/> - <property name="build.help" value="${build.docs}/help"/> + <property name="build.javadocs" value="${build.docs}/api"/> + <property name="build.help" value="${build.docs}/help"/> <property name="javac.debug" value="on"/> - <property name="javac.optimize" value="off"/> - <property name="javac.deprecation" value="on"/> + <property name="javac.optimize" value="off"/> + <property name="javac.deprecation" value="on"/> <property name="javac.include.runtime" value="no"/> <property name="javac.source" value="1.3"/> - <property name="javadoc.link" value="http://java.sun.com/j2se/1.3/docs/api/"/> + <property name="java.javadoc.link" value="http://java.sun.com/j2se/1.3/docs/api/"/> + <property name="xerces.javadoc.link" value="http://xerces.apache.org/xerces2-j/javadocs/api/"/> <property name="main.class" value="net.sourceforge.jsxe.jsXe"/> - <property name="major.version" value="0"/> - <property name="minor.version" value="5"/> - <property name="beta.version" value="1"/> + <property name="major.version" value="0"/> + <property name="minor.version" value="5"/> + <property name="beta.version" value="3"/> <property name="bugfix.version" value="0"/> <!-- Human Readable --> - <property name="app.version" value="0.5 pre1"/> + <property name="app.version" value="0.5 pre3"/> <!-- Used in filenames --> - <property name="app_version" value="05_pre1"/> - <!--<property name="app.version" value="${major.version}.${minor.version} beta"/>--> - <!--<property name="app_version" value="${major.version}_${minor.version}beta"/>--> - <property name="distbin.dir" value="${build.dir}/${app.name}-${app_version}-bin"/> - <property name="distsrc.dir" value="${build.dir}/${app.name}-${app_version}-src"/> + <property name="app_version" value="05_pre3"/> + <property name="buildlib.dir" value="${root.dir}/buildlib"/> + <property name="jsmooth.project" value="${root.dir}/jsXe.jsmooth"/> + <property name="jsmooth.jar" value="${buildlib.dir}/jsmoothgen-ant.jar"/> + + <condition property="windows.build"> + <and> + <os family="windows"/> + <available file="${jsmooth.jar}" property="jsmooth.avail"/> + </and> + </condition> + + <property name="distbin.dir" value="${build.dir}/${app.name}-${app_version}-bin"/> + <property name="distsrc.dir" value="${build.dir}/${app.name}-${app_version}-src"/> <path id="classpath"> - <pathelement location="."/> - <pathelement location="${build.dest}"/> - <pathelement location="${build.src}"/> - <pathelement location="${src.dir}"/> - <fileset dir="${lib.dir}"> - <include name="**/*.jar"/> - </fileset> - </path> + <pathelement location="."/> + <pathelement location="${build.dest}"/> + <pathelement location="${build.src}"/> + <pathelement location="${src.dir}"/> + <fileset dir="${lib.dir}"> + <include name="**/*.jar"/> + </fileset> + </path> + <path id="run-classpath"> + <pathelement location="${build.dir}/${app.name}.jar"/> + <fileset dir="${lib.dir}"> + <include name="**/*.jar"/> + </fileset> + </path> + <!-- set whether we have the source for the default views --> <available file="${plugin.dir}/treeview/build.xml" property="treeview.avail"/> <available file="${plugin.dir}/sourceview/build.xml" property="sourceview.avail"/> <available file="${root.dir}/../web" property="web.avail"/> + <available file="${plugin.dir}" property="plugin.avail"/> - <echo message="${app.name} ${app.version}"/> - <echo message="----------------------------------------------------------"/> - </target> - <!-- }}} --> - <!-- {{{ ============ Prints the available targets ===================== --> - <target depends="init" name="usage" description="Prints available targets"> - <echo message=" available targets are:"/> - <echo message=""/> - <echo message=" compile --> generates the ${app.name}.jar file."/> + + <echo message="${app.name} ${app.version}"/> + <echo message="----------------------------------------------------------"/> + </target> + <!-- }}} --> + <!-- {{{ ============ Prints the available targets ===================== --> + <target depends="init" name="usage" description="Prints available targets"> + <echo message=" available targets are:"/> + <echo message=""/> + <echo message=" compile --> generates the ${app.name}.jar file."/> <echo message=" also generates the jars for the tree view"/> <echo message=" and source view plugins if available."/> - <echo message=" bin --> generates a binary distribution"/> - <echo message=" src --> generates a source distribution"/> - <echo message=" doc --> generates all documentation"/> + <echo message=" bin --> generates a binary distribution"/> + <echo message=" src --> generates a source distribution"/> + <echo message=" doc --> generates all documentation"/> <echo message=" also updates the web api if the web module"/> <echo message=" is available."/> - <echo message=" clean --> cleans everything up"/> - </target> - <!-- }}} --> - <!-- {{{ ============ Prepares for any type of build =================== --> - <target depends="init" name="prepare"> - <mkdir dir="${build.dir}"/> - </target> - <!-- }}} --> - <!-- {{{ ============ Prepares the documentation ======================= --> - <target depends="prepare" name="prepare-doc"> - <mkdir dir="${build.docs}"/> - </target> - <!-- }}} --> - <!-- {{{ ============ Prepares the source distribution ================= --> - <target depends="prepare" name="prepare-src"> - <mkdir dir="${build.src}"/> - <copy todir="${build.src}"> - <fileset dir="${src.dir}"> - <include name="**/*.java"/> - <include name="**/*.props"/> - <include name="**/*.properties"/> - <include name="**/properties"/> + <echo message=" clean --> cleans everything up"/> + </target> + <!-- }}} --> + <!-- {{{ ============ Prepares for any type of build =================== --> + <target depends="init" name="prepare"> + <mkdir dir="${build.dir}"/> + </target> + <!-- }}} --> + <!-- {{{ ============ Prepares the documentation ======================= --> + <target depends="prepare" name="prepare-doc"> + <mkdir dir="${build.docs}"/> + </target> + <!-- }}} --> + <!-- {{{ ============ Prepares the source distribution ================= --> + <target depends="prepare" name="prepare-src"> + <mkdir dir="${build.src}"/> + <copy todir="${build.src}"> + <fileset dir="${src.dir}"> + <include name="**/*.java"/> + <include name="**/*.props"/> + <include name="**/*.properties"/> + <include name="**/properties"/> <include name="**/*.xml"/> <!-- internal xml docs are not validated --> <!--<include name="**/*.dtd"/>--> - <include name="**/*.jpg"/> - <include name="**/*.png"/> + <include name="**/*.jpg"/> + <include name="**/*.png"/> <!-- files in the source directory to ignore --> - <exclude name="net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java"/> + <exclude name="net/sourceforge/jsxe/dom2/**/*"/> <exclude name="net/sourceforge/jsxe/io/**/*"/> - </fileset> - </copy> + </fileset> + </copy> + <mkdir dir="${build.plugin}"/> + + <antcall target="prepare-plugins"/> + <mkdir dir="${build.messages}"/> - <copy todir="${build.messages}"> + <!--<copy todir="${build.messages}"> <fileset dir="${messages.dir}"> <include name="**/messages.*"/> </fileset> + </copy>--> + + <!-- run native2ascii on these files --> + <native2ascii encoding="UTF-8" src="${messages.dir}" dest="${build.messages}" includes="messages*"/> + </target> + <target name="prepare-plugins" if="plugin.avail"> + <copy todir="${build.plugin}"> + <fileset dir="${plugin.dir}"> + <include name="**/*"/> + </fileset> </copy> - </target> - <!-- }}} --> - <!-- {{{ ============ Compiles the program ============================= --> - <target depends="prepare-src" name="compile" description="compile jsXe"> - <mkdir dir="${build.dest}"/> - <javac debug="${javac.debug}" deprecation="${javac.deprecation}" includeJavaRuntime="${javac.include.runtime}" optimize="${javac.optimize}" source="${javac.source}" destdir="${build.dest}" srcdir="${build.src}"> - <classpath refid="classpath"/> + </target> + <!-- }}} --> + <!-- {{{ ============ Compiles the program ============================= --> + <target depends="prepare-src" name="compile" description="compile jsXe"> + <mkdir dir="${build.dest}"/> + <javac debug="${javac.debug}" deprecation="${javac.deprecation}" includeJavaRuntime="${javac.include.runtime}" optimize="${javac.optimize}" source="${javac.source}" destdir="${build.dest}" srcdir="${build.src}"> + <classpath refid="classpath"/> <include name="**/*.java"/> - </javac> - <copy todir="${build.dest}"> - <fileset dir="${build.src}"> - <include name="**/*.props"/> - <include name="**/*.properties"/> - <include name="**/properties"/> + </javac> + <copy todir="${build.dest}"> + <fileset dir="${build.src}"> + <include name="**/*.props"/> + <include name="**/*.properties"/> + <include name="**/properties"/> <include name="**/*.xml"/> <!-- internal xml docs are not validated --> <!--<include name="**/*.dtd"/>--> - <include name="**/*.jpg"/> - <include name="**/*.png"/> - </fileset> - </copy> - + <include name="**/*.jpg"/> + <include name="**/*.png"/> + </fileset> + </copy> + <!-- set the build properties --> <propertyfile comment="${app.name}'s build properties" file="${build.dest}/net/sourceforge/jsxe/build.properties"> - <entry key="application.name" value="${app.name}"/> - <entry key="build.time" pattern="${date.format}" type="date" value="now"/> + <entry key="application.name" value="${app.name}"/> + <entry key="build.time" pattern="${date.format}" type="date" value="now"/> <entry key="major.version" value="${major.version}"/> - <entry key="minor.version" value="${minor.version}"/> - <entry key="beta.version" value="${beta.version}"/> + <entry key="minor.version" value="${minor.version}"/> + <entry key="beta.version" value="${beta.version}"/> <entry key="build.version" value="${bugfix.version}"/> - </propertyfile> + </propertyfile> <!-- create jar manifest --> - <manifest file="${root.dir}/${app.name}.manifest"> + <manifest file="${build.dir}/${app.name}.manifest"> <attribute name="Built-By" value="${user.name}"/> <attribute name="Main-Class" value="${main.class}"/> <section name="common"> @@ -172,161 +207,214 @@ </section> </manifest> - <jar jarfile="${root.dir}/${app.name}.jar" manifest="${app.name}.manifest"> - <fileset dir="${build.dest}"> - <include name="**/*.class"/> - <include name="**/properties"/> - <include name="**/*.props"/> - <include name="**/*.properties"/> + <jar jarfile="${build.dir}/${app.name}.jar" manifest="${build.dir}/${app.name}.manifest"> + <fileset dir="${build.dest}"> + <include name="**/*.class"/> + <include name="**/properties"/> + <include name="**/*.props"/> + <include name="**/*.properties"/> <include name="**/*.xml"/> <!-- internal xml docs are not validated --> <!--<include name="**/*.dtd"/>--> - <include name="**/*.jpg"/> - <include name="**/*.png"/> - </fileset> - </jar> + <include name="**/*.jpg"/> + <include name="**/*.png"/> + </fileset> + </jar> <!-- compile default views --> <antcall target="build-treeview"/> <antcall target="build-sourceview"/> - </target> + </target> <target name="build-treeview" if="treeview.avail"> - <ant inheritAll="false" dir="${plugin.dir}/treeview/" target="compile"/> + <ant inheritAll="false" dir="${build.plugin}/treeview/" target="compile"/> </target> <target name="build-sourceview" if="sourceview.avail"> - <ant inheritAll="false" dir="${plugin.dir}/sourceview/" target="compile"/> + <ant inheritAll="false" dir="${build.plugin}/sourceview/" target="compile"/> </target> - <!-- }}} --> - <!-- {{{ ============ Prepares for a build ============================= --> - <target depends="init" name="prepare-build"> - <!-- lib --> - <mkdir dir="${build.dir}/lib"/> - <copy todir="${build.dir}/lib"> - <fileset dir="${lib.dir}"> - <include name="**/*"/> - </fileset> - </copy> - <!-- bin --> - <mkdir dir="${build.dir}/bin"/> - <copy todir="${build.dir}/bin"> - <fileset dir="${bin.dir}"> - <include name="**/*"/> - </fileset> - </copy> - </target> - <!-- }}} --> - <!-- {{{ ============ Generates the documentation ====================== --> - <target depends="prepare-doc, prepare-src" name="doc" description="Build documentation"> - <copy file="COPYING" tofile="${build.docs}/COPYING"/> - <copy file="README" tofile="${build.docs}/README"/> - <copy file="AUTHORS" tofile="${build.docs}/AUTHORS"/> - <copy file="ISSUES" tofile="${build.docs}/ISSUES"/> - <copy file="Changelog" tofile="${build.docs}/Changelog"/> - <copy file="INSTALL" tofile="${build.docs}/INSTALL"/> - <copy file="THANKS" tofile="${build.docs}/THANKS"/> - <copy file="NEWS" tofile="${build.docs}/NEWS"/> - <javadoc author="true" destdir="${build.javadocs}" doctitle="${app.name} ${app.version} API" link="${javadoc.link}" locale="en_US" packagenames="*" sourcepath="${build.src}" version="true" windowtitle="${app.name} ${app.version} API"/> + <!-- }}} --> + <!-- {{{ ============ Run the program ================================== --> + <target depends="compile" name="run" description="run jsXe"> + <java fork="true" classname="${main.class}"> + <classpath refid="run-classpath"/> + </java> + </target> + <!-- }}} --> + <!-- {{{ ============ Run the program in debug mode ==================== --> + <target depends="compile" name="debug" description="run jsXe in debug mode"> + <java fork="true" classname="${main.class}"> + <classpath refid="run-classpath"/> + <arg value="--debug"/> + </java> + </target> + <!-- }}} --> + <!-- {{{ ============ Prepares for a build ============================= --> + <target depends="init" name="prepare-build"> + <!-- lib --> + <mkdir dir="${build.dir}/lib"/> + <copy todir="${build.dir}/lib"> + <fileset dir="${lib.dir}"> + <include name="**/*"/> + </fileset> + </copy> + <!-- bin --> + <mkdir dir="${build.dir}/bin"/> + <copy todir="${build.dir}/bin"> + <fileset dir="${bin.dir}"> + <include name="**/*"/> + </fileset> + </copy> + </target> + <!-- }}} --> + <!-- {{{ ============ Generates the documentation ====================== --> + <target depends="prepare-doc, prepare-src" name="doc" description="Build documentation"> + <copy file="${root.dir}/COPYING" tofile="${build.docs}/COPYING"/> + <copy file="${root.dir}/README" tofile="${build.docs}/README"/> + <copy file="${root.dir}/AUTHORS" tofile="${build.docs}/AUTHORS"/> + <copy file="${root.dir}/ISSUES" tofile="${build.docs}/ISSUES"/> + <copy file="${root.dir}/Changelog" tofile="${build.docs}/Changelog"/> + <copy file="${root.dir}/INSTALL" tofile="${build.docs}/INSTALL"/> + <copy file="${root.dir}/THANKS" tofile="${build.docs}/THANKS"/> + <copy file="${root.dir}/NEWS" tofile="${build.docs}/NEWS"/> + + <javadoc author="true" destdir="${build.javadocs}" doctitle="${app.name} ${app.version} API" locale="en_US" packagenames="*" sourcepath="${build.src}" version="true" windowtitle="${app.name} ${app.version} API"> + <link href="${java.javadoc.link}"/> + <link href="${xerces.javadoc.link}"/> + </javadoc> + <zip basedir="${build.docs}" includes="api/**" zipfile="${build.dir}/${app.name}-${app_version}-api.zip"/> + </target> - <!-- }}} --> - <!-- {{{ ============ Generates the binary distribution ================ --> - <target depends="compile, prepare-build, doc" name="bin" description="Build binary distribution"> - + <!-- }}} --> + <!-- {{{ ============ Generates the binary distribution ================ --> + <target depends="compile, prepare-build, doc" name="bin" description="Build binary distribution"> + <!-- plugins --> <mkdir dir="${distbin.dir}/jars"/> <copy todir="${distbin.dir}/jars"> - <fileset dir="${plugin.dir}"> + <fileset dir="${build.plugin}"> <include name="*.jar"/> </fileset> </copy> <!-- doc --> - <mkdir dir="${distbin.dir}/doc"/> - <copy todir="${distbin.dir}/doc"> - <fileset dir="${build.docs}"> - <include name="**/*"/> - </fileset> - </copy> - <!-- bin --> - <mkdir dir="${distbin.dir}/bin"/> - <copy todir="${distbin.dir}/bin"> - <fileset dir="${build.bin}"> - <include name="**/*"/> - </fileset> - </copy> + <mkdir dir="${distbin.dir}/doc"/> + <copy todir="${distbin.dir}/doc"> + <fileset dir="${build.docs}"> + <include name="**/*"/> + </fileset> + </copy> + <!-- bin --> + <mkdir dir="${distbin.dir}/bin"/> + <copy todir="${distbin.dir}/bin"> + <fileset dir="${build.bin}"> + <include name="**/*"/> + </fileset> + </copy> <!-- messages --> <mkdir dir="${distbin.dir}/messages"/> - <copy todir="${distbin.dir}/messages"> - <fileset dir="${build.messages}"> - <include name="**/messages.*"/> - </fileset> - </copy> + <copy todir="${distbin.dir}/messages"> + <fileset dir="${build.messages}"> + <include name="**/messages*"/> + </fileset> + </copy> - <copy file="${app.name}.jar" tofile="${distbin.dir}/${app.name}.jar"/> - <!-- lib --> - <mkdir dir="${distbin.dir}/lib"/> - <copy todir="${distbin.dir}/lib"> - <fileset dir="${build.lib}"> - <include name="**/*"/> - </fileset> - </copy> - <zip basedir="${build.dir}" excludes="*.class" includes="${app.name}-${app_version}-bin/**" zipfile="${build.dir}/${app.name}-${app_version}-bin.zip"/> - </target> - <!-- }}} --> - <!-- {{{ ============ Generates the source distribution ================ --> - <target depends="prepare-build, prepare-src, doc" name="src" description="Build source distribution"> - + <copy file="${build.dir}/${app.name}.jar" tofile="${distbin.dir}/${app.name}.jar"/> + <!-- lib --> + <mkdir dir="${distbin.dir}/lib"/> + <copy todir="${distbin.dir}/lib"> + <fileset dir="${build.lib}"> + <include name="**/*"/> + </fileset> + </copy> + + <!-- build the windows executable --> + <antcall target="build-exe"/> + + <zip basedir="${build.dir}" excludes="*.class" includes="${app.name}-${app_version}-bin/**" zipfile="${build.dir}/${app.name}-${app_version}-bin.zip"/> + </target> + <target name="build-exe" if="windows.build"> + <taskdef name="jsmoothgen" + classname="net.charabia.jsmoothgen.ant.JSmoothGen" + classpath="${jsmooth.jar}"/> + + <jsmoothgen project="${jsmooth.project}" skeletonroot="${buildlib.dir}/skeletons"/> + <copy todir="${distbin.dir}" file="${build.dir}/jsXe.exe"/> + </target> + <!-- }}} --> + <!-- {{{ ============ Generates the source distribution ================ --> + <target depends="prepare-build, prepare-src, doc" name="src" description="Build source distribution"> + <antcall target="copy-treeview-source"/> <antcall target="copy-sourceview-source"/> <!-- doc --> - <mkdir dir="${distsrc.dir}/doc"/> - <copy todir="${distsrc.dir}/doc"> - <fileset dir="${build.docs}"> - <include name="**/*"/> - </fileset> - </copy> + <mkdir dir="${distsrc.dir}/doc"/> + <copy todir="${distsrc.dir}/doc"> + <fileset dir="${build.docs}"> + <include name="**/*"/> + </fileset> + </copy> + + <!-- move these files to the root dir of the src distribution --> + <move file="${distsrc.dir}/doc/COPYING" tofile="${distsrc.dir}/COPYING"/> + <move file="${distsrc.dir}/doc/README" tofile="${distsrc.dir}/README"/> + <move file="${distsrc.dir}/doc/AUTHORS" tofile="${distsrc.dir}/AUTHORS"/> + <move file="${distsrc.dir}/doc/ISSUES" tofile="${distsrc.dir}/ISSUES"/> + <move file="${distsrc.dir}/doc/Changelog" tofile="${distsrc.dir}/Changelog"/> + <move file="${distsrc.dir}/doc/INSTALL" tofile="${distsrc.dir}/INSTALL"/> + <move file="${distsrc.dir}/doc/THANKS" tofile="${distsrc.dir}/THANKS"/> + <move file="${distsrc.dir}/doc/NEWS" tofile="${distsrc.dir}/NEWS"/> + <!-- build files --> <copy todir="${distsrc.dir}"> <fileset dir="${root.dir}"> <include name="build.xml"/> </fileset> </copy> - <!-- bin --> - <mkdir dir="${distsrc.dir}/bin"/> - <copy todir="${distsrc.dir}/bin"> - <fileset dir="${build.bin}"> - <include name="**/*"/> - </fileset> - </copy> - <!-- src --> - <mkdir dir="${distsrc.dir}/src"/> - <copy todir="${distsrc.dir}/src"> - <fileset dir="${build.src}"> - <include name="**/*"/> - </fileset> - </copy> - <!-- lib --> - <mkdir dir="${distsrc.dir}/lib"/> - <copy todir="${distsrc.dir}/lib"> - <fileset dir="${build.lib}"> - <include name="**/*"/> - </fileset> - </copy> - <!-- messages --> + <!-- bin --> + <mkdir dir="${distsrc.dir}/bin"/> + <copy todir="${distsrc.dir}/bin"> + <fileset dir="${build.bin}"> + <include name="**/*"/> + </fileset> + </copy> + <!-- src --> + <mkdir dir="${distsrc.dir}/src"/> + <copy todir="${distsrc.dir}/src"> + <fileset dir="${build.src}"> + <include name="**/*"/> + </fileset> + </copy> + <!-- lib --> + <mkdir dir="${distsrc.dir}/lib"/> + <copy todir="${distsrc.dir}/lib"> + <fileset dir="${build.lib}"> + <include name="**/*"/> + </fileset> + </copy> + <!-- buildlib --> + <mkdir dir="${distsrc.dir}/buildlib"/> + <copy todir="${distsrc.dir}/buildlib"> + <fileset dir="${buildlib.dir}"> + <include name="**/*"/> + </fileset> + </copy> + <copy todir="${distsrc.dir}" file="${jsmooth.project}"/> + + <!-- messages --> <mkdir dir="${distsrc.dir}/messages"/> - <copy todir="${distsrc.dir}/messages"> - <fileset dir="${build.messages}"> - <include name="**/messages.*"/> - </fileset> - </copy> + <copy todir="${distsrc.dir}/messages"> + <fileset dir="${build.messages}"> + <include name="**/messages*"/> + </fileset> + </copy> - <zip basedir="${build.dir}" excludes="*.class" includes="${app.name}-${app_version}-src/**" zipfile="${build.dir}/${app.name}-${app_version}-src.zip"/> - </target> + <zip basedir="${build.dir}" excludes="*.class" includes="${app.name}-${app_version}-src/**" zipfile="${build.dir}/${app.name}-${app_version}-src.zip"/> + </target> <target name="copy-treeview-source" if="treeview.avail"> <copy todir="${distsrc.dir}/jars"> - <fileset dir="${root.dir}/jars/"> + <fileset dir="${build.dir}/jars/"> <include name="treeview/**/*"/> <exclude name="treeview/build"/> <exclude name="treeview/build/**/*"/> @@ -336,7 +424,7 @@ </target> <target name="copy-sourceview-source" if="sourceview.avail"> <copy todir="${distsrc.dir}/jars"> - <fileset dir="${root.dir}/jars/"> + <fileset dir="${build.dir}/jars/"> <include name="sourceview/**/*"/> <exclude name="sourceview/build"/> <exclude name="sourceview/build/**/*"/> @@ -344,35 +432,33 @@ </fileset> </copy> </target> - <!-- }}} --> - <!-- {{{ ============ Deploys documentation to the web module ========== --> + <!-- }}} --> + <!-- {{{ ============ Deploys documentation to the web module ========== --> <target depends="doc" name="deploy-web-doc" if="web.avail" description="Deploy documentation to the web module"> <copy file="${build.dir}/${app.name}-${app_version}-api.zip" tofile="${root.dir}/../web/api.zip"/> </target> <!-- }}} --> <!-- {{{ ============ Cleans everything up ============================= --> - <target depends="init" name="clean" description="Clean up distribution tree"> - <delete dir="${build.dir}"/> - <delete> - <fileset dir="." includes="${app.name}.jar"/> - <fileset dir="." includes="${app.name}.manifest"/> - <fileset dir="." includes="**/*.class"/> - <fileset dir="." includes="**/*.rej"/> - <fileset dir="." includes="**/*.orig"/> - <fileset dir="." includes="**/.*.swp"/> - <fileset dir="." includes="**/.#*"/> - <fileset dir="." includes="**/.new*"/> - <fileset dir="." includes="**/.directory"/> - <fileset dir="." includes="**/.xvpics"/> - </delete> - <antcall target="clean-treeview"/> - <antcall target="clean-sourceview"/> - </target> - <target name="clean-treeview" if="treeview.avail"> + <target depends="init" name="clean" description="Clean up distribution tree"> + <delete dir="${build.dir}"/> + <delete> + <fileset dir="." includes="**/*.class"/> + <fileset dir="." includes="**/*.rej"/> + <fileset dir="." includes="**/*.orig"/> + <fileset dir="." includes="**/.*.swp"/> + <fileset dir="." includes="**/.#*"/> + <fileset dir="." includes="**/.new*"/> + <fileset dir="." includes="**/.directory"/> + <fileset dir="." includes="**/.xvpics"/> + </delete> + <!--<antcall target="clean-treeview"/>--> + <!--<antcall target="clean-sourceview"/>--> + </target> + <!--<target name="clean-treeview" if="treeview.avail"> <ant inheritAll="false" dir="${plugin.dir}/treeview/" target="clean"/> </target> <target name="clean-sourceview" if="sourceview.avail"> <ant inheritAll="false" dir="${plugin.dir}/sourceview/" target="clean"/> - </target> - <!-- }}} --> -</project> + </target>--> + <!-- }}} --> +</project> \ No newline at end of file Copied: branches/jsxe2/buildlib (from rev 1084, trunk/jsxe/buildlib) Deleted: branches/jsxe2/buildlib/jsmoothgen-ant.jar =================================================================== (Binary files differ) Copied: branches/jsxe2/buildlib/jsmoothgen-ant.jar (from rev 1084, trunk/jsxe/buildlib/jsmoothgen-ant.jar) =================================================================== (Binary files differ) Copied: branches/jsxe2/buildlib/skeletons (from rev 1084, trunk/jsxe/buildlib/skeletons) Copied: branches/jsxe2/buildlib/skeletons/windowed-wrapper (from rev 1084, trunk/jsxe/buildlib/skeletons/windowed-wrapper) Deleted: branches/jsxe2/buildlib/skeletons/windowed-wrapper/description.skel =================================================================== --- trunk/jsxe/buildlib/skeletons/windowed-wrapper/description.skel 2006-07-29 00:09:39 UTC (rev 1084) +++ branches/jsxe2/buildlib/skeletons/windowed-wrapper/description.skel 2006-07-29 04:40:06 UTC (rev 1087) @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<jsmoothskeleton> -<debug>false</debug> -<description><![CDATA[ -This skeleton wraps <b>GUI applications</b>.<ul> -<li>No console I/O is displayed -<li>If no Java VM is found, it is able to display a configurable URL (typically to a java download page). -</ul> -Arguments can be passed to the application (either use the JSmooth default argument mechanism, or create a shortcut with arguments).]]> -</description> -<executableName>jwrap.exe</executableName> -<resourceCategory>JAVA</resourceCategory> -<resourceJarId>102</resourceJarId> -<resourcePropsId>103</resourcePropsId> -<shortName>Windowed Wrapper</shortName> -<skeletonProperties> -<description>When no JVM is found in the target computer, the user is prompted with the message defined below. Then, the default browser is launched with the URL defined here.</description> -<idName>Message</idName> -<label>Message</label> -<type>textarea</type> -<value>Java has not been found on your computer. Do you want to download it?</value> -</skeletonProperties> -<skeletonProperties> -<description>If the user selects YES to the message prompted above, the default web browser is launched with this URL.</description> -<idName>URL</idName> -<label>URL</label> -<type>string</type> -<value>http://www.java.com</value> -</skeletonProperties> -<skeletonProperties> -<description>The default behaviour is to launch the java application in a different (detached) process. If you want to force the wrapper to launch the Java application in the same process than the exe, than select this option.</description> -<idName>SingleProcess</idName> -<label>Launch java app in the exe process</label> -<type>boolean</type> -<value>0</value> -</skeletonProperties> -<skeletonProperties> -<description>Enable the jsmooth debug console.</description> -<idName>Debug</idName> -<label>Debug console</label> -<type>boolean</type> -<value>0</value> -</skeletonProperties> -</jsmoothskeleton> Copied: branches/jsxe2/buildlib/skeletons/windowed-wrapper/description.skel (from rev 1084, trunk/jsxe/buildlib/skeletons/windowed-wrapper/description.skel) =================================================================== --- branches/jsxe2/buildlib/skeletons/windowed-wrapper/description.skel (rev 0) +++ branches/jsxe2/buildlib/skeletons/windowed-wrapper/description.skel 2006-07-29 04:40:06 UTC (rev 1087) @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<jsmoothskeleton> +<debug>false</debug> +<description><![CDATA[ +This skeleton wraps <b>GUI applications</b>.<ul> +<li>No console I/O is displayed +<li>If no Java VM is found, it is able to display a configurable URL (typically to a java download page). +</ul> +Arguments can be passed to the application (either use the JSmooth default argument mechanism, or create a shortcut with arguments).]]> +</description> +<executableName>jwrap.exe</executableName> +<resourceCategory>JAVA</resourceCategory> +<resourceJarId>102</resourceJarId> +<resourcePropsId>103</resourcePropsId> +<shortName>Windowed Wrapper</shortName> +<skeletonProperties> +<description>When no JVM is found in the target computer, the user is prompted with the message defined below. Then, the default browser is launched with the URL defined here.</description> +<idName>Message</idName> +<label>Message</label> +<type>textarea</type> +<value>Java has not been found on your computer. Do you want to download it?</value> +</skeletonProperties> +<skeletonProperties> +<description>If the user selects YES to the message prompted above, the default web browser is launched with this URL.</description> +<idName>URL</idName> +<label>URL</label> +<type>string</type> +<value>http://www.java.com</value> +</skeletonProperties> +<skeletonProperties> +<description>The default behaviour is to launch the java application in a different (detached) process. If you want to force the wrapper to launch the Java application in the same process than the exe, than select this option.</description> +<idName>SingleProcess</idName> +<label>Launch java app in the exe process</label> +<type>boolean</type> +<value>0</value> +</skeletonProperties> +<skeletonProperties> +<description>Enable the jsmooth debug console.</description> +<idName>Debug</idName> +<label>Debug console</label> +<type>boolean</type> +<value>0</value> +</skeletonProperties> +</jsmoothskeleton> Deleted: branches/jsxe2/buildlib/skeletons/windowed-wrapper/jwrap.exe =================================================================== (Binary files differ) Copied: branches/jsxe2/buildlib/skeletons/windowed-wrapper/jwrap.exe (from rev 1084, trunk/jsxe/buildlib/skeletons/windowed-wrapper/jwrap.exe) =================================================================== (Binary files differ) Copied: branches/jsxe2/jsXe.jsmooth (from rev 1084, trunk/jsxe/jsXe.jsmooth) =================================================================== --- branches/jsxe2/jsXe.jsmooth (rev 0) +++ branches/jsxe2/jsXe.jsmooth 2006-07-29 04:40:06 UTC (rev 1087) @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<jsmoothproject> +<JVMSearchPath>registry</JVMSearchPath> +<JVMSearchPath>javahome</JVMSearchPath> +<JVMSearchPath>jrepath</JVMSearchPath> +<JVMSearchPath>jdkpath</JVMSearchPath> +<JVMSearchPath>exepath</JVMSearchPath> +<JVMSearchPath>jview</JVMSearchPath> +<classPath>build\jsXe.jar</classPath> +<embeddedJar>false</embeddedJar> +<executableName>build\jsXe.exe</executableName> +<iconLocation>src\net\sourceforge\jsxe\icons\jsxe.jpg</iconLocation> +<initialMemoryHeap>16777216</initialMemoryHeap> +<javaProperties> +<name>java.endorsed.dirs</name> +<value>lib</value> +</javaProperties> +<mainClassName>net.sourceforge.jsxe.jsXe</mainClassName> +<maximumMemoryHeap>67108864</maximumMemoryHeap> +<maximumVersion></maximumVersion> +<minimumVersion>1.4.2</minimumVersion> +<skeletonName>Windowed Wrapper</skeletonName> +<skeletonProperties> +<key>Message</key> +<value>Java has not been found on your computer. Do you want to download it?</value> +</skeletonProperties> +<skeletonProperties> +<key>URL</key> +<value>http://www.java.com</value> +</skeletonProperties> +<skeletonProperties> +<key>SingleProcess</key> +<value>0</value> +</skeletonProperties> +<skeletonProperties> +<key>Debug</key> +<value>0</value> +</skeletonProperties> +</jsmoothproject> Copied: branches/jsxe2/messages/messages (from rev 1084, trunk/jsxe/messages/messages) =================================================================== --- branches/jsxe2/messages/messages (rev 0) +++ branches/jsxe2/messages/messages 2006-07-29 04:40:06 UTC (rev 1087) @@ -0,0 +1,294 @@ +# JSXE English properties file +# $Id$ +# Maintained by Ian Lewis +#:mode=properties: +#:tabSize=4:indentSize=4:noTabs=true: +#:folding=explicit:collapseFolds=1: + +#{{{ common properties + +common.ok=OK +common.cancel=Cancel +common.open=Open +common.save=Save +common.save.as=Save As +common.close=Close +common.apply=Apply +common.more=More +common.insert=Insert +common.add=Add +common.remove=Remove +common.moveUp=Move Up +common.moveDown=Move Down +common.cut=Cut +common.copy=Copy +common.paste=Paste +common.find=Find +common.findnext=Find Next + +common.ctrl=Ctrl +common.alt=Alt +common.shift=Shift +common.meta=Meta + +#}}} + +#{{{ XML Terminology + +#{{{ XML Node Types +xml.element=Element +xml.processing.instruction=Processing Instruction +xml.cdata=CDATA Section +xml.text=Text +xml.entity.reference=Entity Reference +xml.declaration=Element Declaration +xml.notation=Notation +xml.entity=Entity Declaration +xml.comment=Comment +xml.attribute=Attribute +xml.doctype=Document Type +#}}} + +xml.attribute.value.short=Value +xml.attribute.value=Attribute Value +xml.document=XML Document +xml.namespace=Namespace +xml.namespace.prefix=Namespace Prefix +xml.namespace.prefix.short=Prefix +xml.namespace.decl=Namespace Declaration +xml.doctypedef=Document Type Definition +xml.doctype.name=Name +xml.doctype.public=Public Id +xml.doctype.system=System Id +xml.schema=XML Schema +#}}} + +#{{{ Global Options +Global.Options.Dialog.Title=Global Options +Global.Options.Title=General +Global.Options.Max.Recent.Files=Recent files to remember: +Global.Options.Max.Recent.Files.ToolTip=The maximum number of files that jsXe remembers in the recent files menu. +Global.Options.network-off=Always cache without asking +Global.Options.network-cache=Ask first, then cache remote files +Global.Options.network-always=Always download without asking +Global.Options.network=DTD and schema downloading: +Global.Options.Menu.Spill.Over=Number of items before menus spill over + +Shortcuts.Options.Title=Shortcuts +Shortcuts.Options.Select.Label=Edit Shortcuts: +Shortcuts.Options.Shortcut=Shortcut +Shortcuts.Options.Command=Command + +Grab.Key.title=Specify Shortcut +Grab.Key.caption=Press the desired shortcut for "{0}", then click OK. +Grab.Key.keyboard-test=Input the key strokes that are causing problems. +Grab.Key.assigned-to=Currently assigned to: {0} +Grab.Key.assigned-to.none=<none> +Grab.Key.clear=Clear +Grab.Key.remove=Remove Current + +Grab.Key.remove-ask.title=Remove Shortcut? +Grab.Key.remove-ask.message=\ + You didn't specify a new shortcut.\n\ + Do you want to remove the current shortcut? + +Grab.Key.duplicate-alt-shortcut.title=Duplicate Shortcut +Grab.Key.duplicate-alt-shortcut.message=\ + The shortcut you selected duplicates the other\n\ + shortcut for this item. Please choose another. + +Grab.Key.duplicate-shortcut.title=Duplicate Shortcut +Grab.Key.duplicate-shortcut.message=\ + This shortcut is already assigned to\n\ + "{0}".\n\ + \n\ + Do you want to override this assignment? +#}}} + +#{{{ Document Options +Document.Options.Title=XML Document Options +Document.Options.Message=This dialog changes settings for the current\n document only. To change settings on an\n editor-wide basis, see the\n Tools->Global Options dialog box. +Document.Options.Line.Separator=Line Separator: +Document.Options.Line.Separator.ToolTip=The line separator. Usually you'll pick the line separator used by your operating system. +Document.Options.Encoding=Encoding: +Document.Options.Encoding.ToolTip=The encoding that jsXe uses to write the file. +Document.Options.Indent.Width=Indent width: +Document.Options.Indent.Width.ToolTip=The width used when formatting and displaying tab characters. +Document.Options.Format.XML=Format XML output +Document.Options.Format.XML.ToolTip=If this box is checked then XML will be formatted automatically. +Document.Options.Validate=Validate if DTD or Schema Available +Document.Options.Validate.ToolTip=If this box is checked jsXe will validate the XML document. +Document.Options.Soft.Tabs=Soft tabs (emulated with spaces) +Document.Options.Soft.Tabs.ToolTip=If this box is checked then tab characters are replaced by spaces. +#}}} + +#{{{ Plugin Manager +Plugin.Manager.Title=Plugin Manager +Plugin.Manager.Name.Column.Header=Name +Plugin.Manager.Version.Column.Header=Version +Plugin.Manager.Status.Column.Header=Status +Plugin.Manager.Loaded.Status=Loaded +Plugin.Manager.Not.Loaded.Status=Not Loaded +Plugin.Manager.Broken.Status=Error +#}}} + +#{{{ Menu Items + +File.Menu=File +Edit.Menu=Edit +View.Menu=View +Tools.Menu=Tools +Help.Menu=Help + + +#}}} + +#{{{ Action Labels +new-file.label=New +open-file.label=Open... +File.Recent=Recent Files +File.Recent.None=No Recent Files +save-file.label=Save +save-as.label=Save As... +reload-file.label=Reload +File.Recent=Recent Files +close-file.label=Close +close-all.label=Close All +exit.label=Exit + +find.label=Find... +findnext.lab... [truncated message content] |
From: <ian...@us...> - 2006-07-29 01:44:39
|
Revision: 1086 Author: ian_lewis Date: 2006-07-28 18:44:34 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1086&view=rev Log Message: ----------- Adding Find next action Added Paths: ----------- trunk/sourceview/src/sourceview/action/EditFindNextAction.java Added: trunk/sourceview/src/sourceview/action/EditFindNextAction.java =================================================================== --- trunk/sourceview/src/sourceview/action/EditFindNextAction.java (rev 0) +++ trunk/sourceview/src/sourceview/action/EditFindNextAction.java 2006-07-29 01:44:34 UTC (rev 1086) @@ -0,0 +1,74 @@ +/* +EditFindNextAction.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package sourceview.action; + +//{{{ imports + +import sourceview.*; + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.LocalizedAction; +import net.sourceforge.jsxe.gui.TabbedView; +import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.gui.DocumentView; +//}}} + +//{{{ AWT classes +import java.awt.event.ActionEvent; +//}}} + +//}}} + +/** + * This action that searches the file for the last value searched for using + * the find dialog. + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + */ + +public class EditFindNextAction extends LocalizedAction { + + //{{{ EditFindNextAction constructor + public EditFindNextAction() { + super(SourceViewPlugin.PLUGIN_NAME+".findnext"); + }//}}} + + //{{{ getLabel() + public String getLabel() { + return Messages.getMessage("common.findnext"); + }//}}} + + //{{{ invoke() + public void invoke(TabbedView view, ActionEvent evt) { + DocumentView docView = view.getDocumentView(); + if (docView instanceof SourceView) { + SourceView sourceView = (SourceView)docView; + SourceViewSearch search = new SourceViewSearch(sourceView); + search.findNext(); + } + }//}}} + +} Property changes on: trunk/sourceview/src/sourceview/action/EditFindNextAction.java ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-29 01:41:06
|
Revision: 1085 Author: ian_lewis Date: 2006-07-28 18:40:59 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1085&view=rev Log Message: ----------- Adding SourceViewSearch to encapsulate search capabilities Added Paths: ----------- trunk/sourceview/src/sourceview/SourceViewSearch.java Added: trunk/sourceview/src/sourceview/SourceViewSearch.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewSearch.java (rev 0) +++ trunk/sourceview/src/sourceview/SourceViewSearch.java 2006-07-29 01:40:59 UTC (rev 1085) @@ -0,0 +1,164 @@ +/* +SourceViewSearch.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2002 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package sourceview; + +//{{{ imports + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.DocumentBuffer; +import net.sourceforge.jsxe.gui.DocumentView; +import net.sourceforge.jsxe.gui.GUIUtilities; +import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.util.Log; +//}}} + +//{{{ jEdit syntax classes +import org.syntax.jedit.JEditTextArea; +//}}} + +//{{{ Swing classes +import javax.swing.JOptionPane; +import javax.swing.text.Segment; +//}}} + +//}}} + +/** + * The SourceViewSearch class abstracts functions used by the source + * view's searching mechanisms. + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + */ +public class SourceViewSearch { + + private SourceView m_view; + + public static final String IGNORE_CASE = SourceViewPlugin.PLUGIN_NAME+".ignore.case"; + public static final String LAST_FIND_STRING = SourceViewPlugin.PLUGIN_NAME+".last.find.string"; + + //{{{ SourceViewSearch constructor + /** + * Creates a new search on a specific SourceView + * @param view the SourceView to search + */ + public SourceViewSearch(SourceView view) { + m_view = view; + }//}}} + + //{{{ find() + /** + * Initiates a simple find on the text area where the document + * is searched from the current caret position without replacing + * any text. + * @param search the search string to search for + * @param ignoreCase true if you want to ignore the case of the characters + * in the string when matching. + */ + public void find(String search, boolean ignoreCase) { + find(false, m_view.getTextArea().getCaretPosition(), search, "", ignoreCase); + }//}}} + + //{{{ replaceAndFind() + /** + * Initiates a replace and find action on the text area where the current + * matched text is replaced by the replacement and then the document is + * is searched from the current caret position for the next instance of + * the search string. + * + * @param search the search string to search for + * @param replace the replacement string + * @param ignoreCase true if you want to ignore the case of the characters + * in the string when matching. + */ + public void replaceAndFind(String search, String replace, boolean ignoreCase) { + find(true, m_view.getTextArea().getCaretPosition(), search, replace, ignoreCase); + }//}}} + + //{{{ findNext() + /** + * Initiates a find using the last string that was entered in the search + * dialog and value of the ignore case property. Text is not replaced. + */ + public void findNext() { + DocumentBuffer buffer = m_view.getDocumentBuffer(); + String search = buffer.getProperty(LAST_FIND_STRING); + if (search != null) { + boolean ignoreCase = jsXe.getBooleanProperty(IGNORE_CASE, false); + find(false, m_view.getTextArea().getCaretPosition(), search, "", ignoreCase); + } + }//}}} + + //{{{ Private members + + //{{{ find() + + private void find(boolean doReplace, int startIndex, String search, String replace, boolean ignoreCase) { + try { + + RESearchMatcher matcher = new RESearchMatcher(search, replace, ignoreCase); + + JEditTextArea textArea = m_view.getTextArea(); + + //replace previous text + if (doReplace) { + String selText = textArea.getSelectedText(); + if (selText != null && !selText.equals("")) { + String replaceString = matcher.substitute(selText); + textArea.setSelectedText(replaceString); + } + } + + DocumentBuffer buffer = m_view.getDocumentBuffer(); + Segment seg = buffer.getSegment(0, buffer.getLength()); + int caretPosition = startIndex; + CharIndexedSegment charSeg = new CharIndexedSegment(seg, caretPosition); + + int[] match = matcher.nextMatch(charSeg, false, true, true, false); + + buffer.setProperty(LAST_FIND_STRING, search); + jsXe.setBooleanProperty(IGNORE_CASE, ignoreCase); + + if (match != null) { + Log.log(Log.DEBUG, this, match[0] + " "+ match[1]); + int start = match[0]+caretPosition; + int end = match[1]+caretPosition; + // textArea.requestFocus(); + textArea.select(start, end); + } else { + int again = GUIUtilities.confirm(m_view, "SourceView.No.More.Matches", null, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + if (again == 0) { + find(doReplace, 0, search, replace, ignoreCase); + } + } + + } catch (Exception ex) { + ex.printStackTrace(); + JOptionPane.showMessageDialog(m_view, ex, Messages.getMessage("SourceView.Search.Error.title"), JOptionPane.WARNING_MESSAGE); + } + }//}}} + + //}}} +} \ No newline at end of file Property changes on: trunk/sourceview/src/sourceview/SourceViewSearch.java ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-29 00:09:45
|
Revision: 1084 Author: ian_lewis Date: 2006-07-28 17:09:39 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1084&view=rev Log Message: ----------- added XMLDocument events Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java Added Paths: ----------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/ branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentEvent.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentListener.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-28 22:46:52 UTC (rev 1083) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 00:09:39 UTC (rev 1084) @@ -50,14 +50,8 @@ import java.net.URI; //}}} -//{{{ Swing classes -import javax.swing.text.*; -import javax.swing.event.DocumentListener; -import javax.swing.event.UndoableEditListener; //}}} -//}}} - /** * <p>The XMLDocument class represents an XML document as a tree structure * that has nodes, implemented as XMLNodes, as well as text. Methods are @@ -183,14 +177,6 @@ } }//}}} - //{{{ addUndoableEditListener() - - public void addUndoableEditListener(UndoableEditListener listener) { - if (listener != null) { - m_undoListeners.add(listener); - } - }//}}} - //{{{ getDefaultRootElement() /** * Gets the root document element. @@ -295,14 +281,6 @@ } }//}}} - //{{{ removeUndoableEditListener() - - public void removeUndoableEditListener(UndoableEditListener listener) { - if (listener != null) { - m_undoListeners.remove(listener); - } - }//}}} - //{{{ render() public void render(Runnable r) { VFSManager.runInWorkThread(new Runnable() { Added: branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentEvent.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentEvent.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentEvent.java 2006-07-29 00:09:39 UTC (rev 1084) @@ -0,0 +1,37 @@ +/* +XMLDocumentEvent.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version.e + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom2.event; + +import net.sourceforge.jsxe.dom2.*; + +public interface XMLDocumentEvent extends EventListener { + + public void propertyChanged(PropertyChangeEvent event); + + public void insertUpdate(XMLDocumentEvent event); + + public void removeUpdate(XMLDocumentEvent event); + +} \ No newline at end of file Added: branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentListener.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentListener.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/event/XMLDocumentListener.java 2006-07-29 00:09:39 UTC (rev 1084) @@ -0,0 +1,37 @@ +/* +XMLDocumentListener.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom2.event; + +import net.sourceforge.jsxe.dom2.*; + +public interface XMLDocumentListener extends EventListener { + + public void propertyChanged(PropertyChangeEvent event); + + public void insertUpdate(XMLDocumentEvent event); + + public void removeUpdate(XMLDocumentEvent event); + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-28 22:47:07
|
Revision: 1083 Author: ian_lewis Date: 2006-07-28 15:46:52 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1083&view=rev Log Message: ----------- Added the ReadWriteLock class Added Paths: ----------- branches/jsxe2/src/net/sourceforge/jsxe/util/ReadWriteLock.java Added: branches/jsxe2/src/net/sourceforge/jsxe/util/ReadWriteLock.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/util/ReadWriteLock.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/util/ReadWriteLock.java 2006-07-28 22:46:52 UTC (rev 1083) @@ -0,0 +1,207 @@ +/* +ReadWriteLock.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2001 Peter Graves + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.util; + +import java.util.Vector; + +/** + * Implements consumer/producer locking scemantics. + * @author Peter Graves + * @version $Id: ReadWriteLock.java,v 1.7 2004/02/14 19:02:49 spestov Exp $ + * The lock tries to be re-entrant when called from the same thread in some + * cases. + * + * The following is ok: + * read lock + * read lock + * read unlock + * read unlock + * + * write lock + * read lock + * read unlock + * write unlock + * + * The following is not ok: + * + * read lock + * write lock + * write unlock + * read unlock + * + * write lock + * write lock + * write unlock + * write unlock + */ +public class ReadWriteLock +{ + //{{{ readLock() method + public synchronized void readLock() + { + // this seems to make nested readLock() calls work okay. + // but I have no idea if it actually fixes things or not. + if (activeReaders != 0 || allowRead()) + { + ++activeReaders; + //readers.addElement(Thread.currentThread()); + return; + } + ++waitingReaders; + while (!allowRead()) + { + try + { + wait(); + } + catch (InterruptedException e) + { + --waitingReaders; // Roll back state. + Log.log(Log.ERROR,this,e); + return; + } + } + --waitingReaders; + ++activeReaders; + readers.addElement(Thread.currentThread()); + } //}}} + + //{{{ readUnlock() method + public synchronized void readUnlock() + { + if(activeReaders == 0) + throw new InternalError("Unbalanced readLock()/readUnlock() calls"); + + --activeReaders; + //readers.removeElement(Thread.currentThread()); + notifyAll(); + } //}}} + + //{{{ writeLock() method + public synchronized void writeLock() + { + if (writerThread != null) + { + // Write in progress. + if (Thread.currentThread() == writerThread) + { + // Same thread. + ++lockCount; + return; + } + } + if (allowWrite()) + { + claimWriteLock(); + return; + } + + ++waitingWriters; + while (!allowWrite()) + { + try + { + wait(); + } + catch (InterruptedException e) + { + --waitingWriters; + Log.log(Log.ERROR,this,e); + return; + } + } + --waitingWriters; + claimWriteLock(); + } //}}} + + //{{{ writeUnlock() method + public synchronized void writeUnlock() + { + if(activeWriters != 1 || lockCount <= 0) + throw new InternalError("Unbalanced writeLock()/writeUnlock() calls"); + + if(Thread.currentThread() != writerThread) + throw new InternalError("writeUnlock() from wrong thread"); + + if (--lockCount == 0) + { + --activeWriters; + writerThread = null; + notifyAll(); + } + } //}}} + + //{{{ isWriteLocked() method + public synchronized boolean isWriteLocked() + { + //Debug.assert(activeWriters == 0 || activeWriters == 1); + return activeWriters == 1; + } //}}} + + //{{{ Private members + + //{{{ Instance variables + private int activeReaders; + private int activeWriters; + private int waitingReaders; + private int waitingWriters; + private Vector readers = new Vector(); + + private Thread writerThread; + private int lockCount; + //}}} + + //{{{ allowRead() method + private final boolean allowRead() + { + return (Thread.currentThread() == writerThread) + || (waitingWriters == 0 && activeWriters == 0); + } //}}} + + //{{{ allowWrite() method + private final boolean allowWrite() + { + /*Thread current = Thread.currentThread(); + for(int i = 0; i < readers.size(); i++) + { + if(readers.elementAt(i) == current) + throw new InternalError("Cannot nest writeLock() inside readLock()"); + }*/ + + return activeReaders == 0 && activeWriters == 0; + } //}}} + + //{{{ claimWriteLock() method + private void claimWriteLock() + { + ++activeWriters; + //Debug.assert(writerThread == null); + writerThread = Thread.currentThread(); + //Debug.assert(lockCount == 0); + lockCount = 1; + } //}}} + + //}}} +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/util/ReadWriteLock.java ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-28 22:46:33
|
Revision: 1082 Author: ian_lewis Date: 2006-07-28 15:46:19 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1082&view=rev Log Message: ----------- Added new multi-threading support. XMLDocuments and XMLNodes no longer implement the Document and Element interfaces respectively. The source tree will not currently compile Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java branches/jsxe2/src/net/sourceforge/jsxe/properties Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-28 22:46:19 UTC (rev 1082) @@ -59,19 +59,23 @@ //}}} /** - * The XMLDocument class represents an XML document as a tree structure + * <p>The XMLDocument class represents an XML document as a tree structure * that has nodes, implemented as XMLNodes, as well as text. Methods are * provided to allow user objects to interact with the XML document as text - * or as a tree structure seamlessly. + * or as a tree structure seamlessly.</p> * - * Properties of XMLDocuments are saved by jsXe as string values. And are loaded - * later when if the document was loaded recently. + * <p>It is implemented in the spirit of the {@link javax.swing.text.Document} + * class in that it represents a piece of structured text that can be + * viewed and edited via the text or document structure</p> * + * <p>Properties of XMLDocuments are saved by jsXe as string values. And are loaded + * later when if the document was loaded recently.</p> + * * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id: XMLDocument.java 999 2006-07-07 20:59:23Z ian_lewis $ * @see XMLNode */ -public class XMLDocument implements javax.swing.text.Document { +public class XMLDocument { //{{{ XMLDocument defined properties /** @@ -152,7 +156,6 @@ */ public XMLDocument(String uri, InputStream reader, EntityResolver resolver, Map properties) throws IOException { m_entityResolver = resolver; - setDefaultProperties(); setURI(uri); //add properties one by one @@ -168,14 +171,13 @@ reader.close(); }//}}} - //{{{ swing.text.Document methods - //{{{ addDocumentListener /** * Registers a change listener with the XMLDocument * @param listener the listener to register with this document */ public void addDocumentListener(DocumentListener listener) { + //TODO: Create XMLDocumentListeners if (listener != null) { m_docListeners.add(listener); } @@ -189,90 +191,47 @@ } }//}}} - //{{{ createPosition() - - public Position createPosition(int offs) throws BadLocationException { - if (offs < 0 || offs > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("createPosition(): Bad offset", offs); - } - - final int offset = offs; - return new Position() { - public int getOffset() { - return offset; - } - }; - }//}}} - //{{{ getDefaultRootElement() - - public javax.swing.text.Element getDefaultRootElement() { + /** + * Gets the root document element. + */ + public XMLElement getRootElement() { //TODO: return root element return null; }//}}} - //{{{ getEndPosition() - - public Position getEndPosition() { - try { - return createPosition(getLength()-1); - } catch (BadLocationException e) { - //Guaranteed to be good. - return null; - } - }//}}} - //{{{ getLength() /** - * Gets the total number of characters in the document. + * Gets the total number of characters in the document. This method is + * thread-safe. * @return the length of the document */ public int getLength() { + // no need to lock since this just returns a value and that's it return m_content.getLength(); }//}}} - //{{{ getProperty() + //{{{ getRootNodes() - public Object getProperty(Object key) { - return m_properties.get(key); - }//}}} - - //{{{ getRootElements() - - public javax.swing.text.Element[] getRootElements() { + public XMLNode[] getRootNodes() { //TODO: return root nodes return null; }//}}} - //{{{ getStartPosition() - - public Position getStartPosition() { - try { - return createPosition(0); - } catch (BadLocationException e) { - //Guaranteed to be good. - return null; - } - }//}}} - //{{{ getText() - public String getText(int offset, int length) throws BadLocationException { + public String getText(int offset, int length) { if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("insertString(): Bad Offset", offset); + throw new ArrayIndexOutOfBoundsException(offset); } return m_content.getText(offset,length); }//}}} //{{{ getText() - - public void getText(int offset, int length, Segment txt) throws BadLocationException { + public void getText(int offset, int length, Segment txt) { if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("insertString(): Bad Offset", offset); + throw new ArrayIndexOutOfBoundsException(offset); } m_content.getText(offset, length, txt); @@ -302,10 +261,9 @@ * @param a the attributes to associate with the inserted content. * This attribute is ignored by XMLDocuments. */ - public void insertString(int offset, String str, AttributeSet a) throws BadLocationException { + public void insertString(int offset, String str) { if (offset < 0 || str.length() < 0 || offset + str.length() > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("insertString(): Bad Offset", offset); + throw new ArrayIndexOutOfBoundsException(offset); } m_content.insert(offset, str); @@ -315,24 +273,11 @@ //TODO: implement undo }//}}} - //{{{ putProperty() - /** - * Add a property to the XMLDocument. - * They are saved in memory as objects however, jsXe saves properties as - * Strings when saving the Document to the recent buffers file, and when - * the document is opened later the property will be loaded as a String. - * Generally String properties are stored here. - */ - public void putProperty(Object key, Object value) { - m_properties.put(key, value); - }//}}} - //{{{ remove() - public void remove(int offs, int len) throws BadLocationException { + public void remove(int offs, int len) { if (offs < 0 || len < 0 || offs + len > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("insertString(): Bad Offset", offs); + throw new ArrayIndexOutOfBoundsException(offs); } m_content.remove(offs, len); @@ -359,12 +304,60 @@ }//}}} //{{{ render() - public void render(Runnable r) { - //TODO: implement concurrency support. + VFSManager.runInWorkThread(new Runnable() { + public void run() { + try { + readLock(); + + r.run(); + + } finally { + readUnlock(); + } + } + }); }//}}} - //}}} + //{{{ Thread safety + + //{{{ readLock() method + /** + * The buffer is guaranteed not to change between calls to + * {@link #readLock()} and {@link #readUnlock()}. + */ + public void readLock() { + lock.readLock(); + } //}}} + + //{{{ readUnlock() method + /** + * The buffer is guaranteed not to change between calls to + * {@link #readLock()} and {@link #readUnlock()}. + */ + public void readUnlock() { + lock.readUnlock(); + } //}}} + + //{{{ writeLock() method + /** + * Attempting to obtain read lock will block between calls to + * {@link #writeLock()} and {@link #writeUnlock()}. + */ + public void writeLock() { + lock.writeLock(); + } //}}} + + //{{{ writeUnlock() method + /** + * Attempting to obtain read lock will block between calls to + * {@link #writeLock()} and {@link #writeUnlock()}. + */ + public void writeUnlock() { + lock.writeUnlock(); + } //}}} + + //}}} //{{{ getDocumentType() @@ -383,6 +376,114 @@ return m_properties; }//}}} + //{{{ getProperty() + + public String getProperty(String key) { + synchronized(propertyLock) { + // First try the buffer-local properties + String o = m_properties.getProperty(key); + if (o == null) { + // Now try xml.document.<property> + o = jsXe.getProperty("xml.document." + name); + } + return o; + } + }//}}} + + //{{{ setProperty() + public void settProperty(String key, String value) { + synchronized(propertyLock) { + if (value == null) { + m_properties.remove(key); + } else { + m_properties.setProperty(key, value); + } + } + }//}}} + + //{{{ getStringProperty() method + /** + * Returns the value of a string property. This method is thread-safe. + * @param name The property name + */ + public String getStringProperty(String name) { + Object obj = getProperty(name); + if (obj != null) { + return obj.toString(); + } else { + return null; + } + } //}}} + + //{{{ setStringProperty() method + /** + * Sets a string property. + * @param name The property name + * @param value The value + */ + public void setStringProperty(String name, String value) { + setProperty(name,value); + } //}}} + + //{{{ getBooleanProperty() method + /** + * Returns the value of a boolean property. This method is thread-safe. + * @param name The property name + */ + public boolean getBooleanProperty(String name) { + Object obj = getProperty(name); + if (obj == null) { + return null; + } + + if (obj instanceof Boolean) { + return ((Boolean)obj).booleanValue(); + } else { + return Boolean.valueOf(obj.toString()).booleanValue(); + } + } //}}} + + //{{{ setBooleanProperty() method + /** + * Sets a boolean property. + * @param name The property name + * @param value The value + */ + public void setBooleanProperty(String name, boolean value) { + setProperty(name, Boolean.valueOf(value)); + } //}}} + + //{{{ getIntegerProperty() method + /** + * Returns the value of an integer property. This method is thread-safe. + * @param name The property name + */ + public int getIntegerProperty(String name, int defaultValue) { + + boolean defaultValueFlag; + Object obj = getProperty(); + + if (obj == null) { + return defaultValue; + } else { + if (obj instanceof Number) { + return ((Number)obj).intValue(); + } else { + return defaultValue; + } + } + } //}}} + + //{{{ setIntegerProperty() method + /** + * Sets an integer property. + * @param name The property name + * @param value The value + */ + public void setIntegerProperty(String name, int value) { + setProperty(name, new Integer(value)); + } //}}} + //{{{ setURI() /** * Sets the URI for the location of this document. @@ -473,16 +574,6 @@ //{{{ Private members - //{{{ setDefaultProperties() - private void setDefaultProperties() { - putProperty(FORMAT_XML, "false"); - putProperty(IS_USING_SOFT_TABS, "false"); - putProperty(WS_IN_ELEMENT_CONTENT, "true"); - putProperty(ENCODING, "UTF-8"); - putProperty(INDENT, "4"); - putProperty(IS_VALIDATING, "false"); - }//}}} - //{{{ ContentManager class /** * Text content manager based off of jEdit's ContentManager class. @@ -712,11 +803,14 @@ private ContentManager m_content; - private HashMap m_properties = new HashMap(); + private Properties m_properties = new Properties(); private ArrayList m_docListeners = new ArrayList(); private ArrayList m_undoListeners = new ArrayList(); + private Object propertyLock = new Object(); + private ReadWriteLock lock = new ReadWriteLock(); + /** * The entity resolver to use when resolving external entities * in this document. Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-07-28 22:46:19 UTC (rev 1082) @@ -53,6 +53,10 @@ * will correspond to text modifications to the XMLDocument. Direct text * modifications are only allowed at the XMLDocument level.</p> * + * <p>It is implement in the spirit of the {@link javax.swing.text.Element} + * class as it represents a piece of text as well as a structural element + * in the document.</p> + * * <p>It implements a subset of the support offered by standard w3c DOM * interfaces.</p> * @@ -61,7 +65,7 @@ * @see XMLDocument * @since jsXe 0.5 pre2 */ -public abstract class XMLNode implements javax.swing.text.Element { +public abstract class XMLNode { protected static final String USER_DATA_KEY = "net.sourceforge.jsxe.dom.XMLNode"; Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-07-28 22:46:19 UTC (rev 1082) @@ -23,22 +23,22 @@ from http://www.fsf.org/copyleft/gpl.txt */ -package org.gjt.sp.jedit.buffer; +package net.sourceforge.jsxe.dom2.ls; //{{{ Imports import javax.swing.text.Segment; import java.io.*; import java.util.zip.*; import java.util.Vector; -import org.gjt.sp.jedit.io.*; -import org.gjt.sp.jedit.*; -import org.gjt.sp.util.*; +import net.sourceforge.jsxe.io.*; +import net.sourceforge.jsxe.*; +import net.sourceforge.jsxe.util.*; //}}} /** * A document I/O request. * @author Slava Pestov - * @version $Id: BufferIORequest.java,v 1.28 2004/08/29 02:58:43 spestov Exp $ + * @version $Id$ */ public class XMLDocumentIORequest extends WorkRequest { @@ -53,12 +53,12 @@ */ public static final int PROGRESS_INTERVAL = 300; - public static final String LOAD_DATA = "BufferIORequest__loadData"; - public static final String END_OFFSETS = "BufferIORequest__endOffsets"; - public static final String NEW_PATH = "BufferIORequest__newPath"; + public static final String LOAD_DATA = "XMLDocumentIORequest__loadData"; + public static final String END_OFFSETS = "XMLDocumentIORequest__endOffsets"; + public static final String NEW_PATH = "XMLDocumentIORequest__newPath"; /** - * Buffer boolean property set when an error occurs. + * Boolean property set when an error occurs. */ public static final String ERROR_OCCURRED = "XMLDocumentIORequest__error"; @@ -173,7 +173,7 @@ //{{{ Instance variables private int type; private View view; - private Buffer buffer; + private XMLDocument buffer; private Object session; private VFS vfs; private String path; @@ -288,110 +288,96 @@ * Tries to detect if the stream is gzipped, and if it has an encoding * specified with an XML PI. */ - private Reader autodetect(InputStream in) throws IOException - { + private Reader autodetect(InputStream in) throws IOException { in = new BufferedInputStream(in); String encoding = buffer.getStringProperty(Buffer.ENCODING); - if(!in.markSupported()) + if (!in.markSupported()) { Log.log(Log.WARNING,this,"Mark not supported: " + in); - else if(buffer.getBooleanProperty(Buffer.ENCODING_AUTODETECT)) - { - in.mark(XML_PI_LENGTH); - int b1 = in.read(); - int b2 = in.read(); - int b3 = in.read(); - - if(encoding.equals(MiscUtilities.UTF_8_Y)) - { - // Java does not support this encoding so - // we have to handle it manually. - if(b1 != UTF8_MAGIC_1 || b2 != UTF8_MAGIC_2 - || b3 != UTF8_MAGIC_3) - { - // file does not begin with UTF-8-Y - // signature. reset stream, read as - // UTF-8. - in.reset(); - } - else - { - // file begins with UTF-8-Y signature. - // discard the signature, and read - // the remainder as UTF-8. - } - - encoding = "UTF-8"; - } - else if(b1 == GZIP_MAGIC_1 && b2 == GZIP_MAGIC_2) - { - in.reset(); - in = new GZIPInputStream(in); - buffer.setBooleanProperty(Buffer.GZIPPED,true); - // auto-detect encoding within the gzip stream. - return autodetect(in); - } - else if((b1 == UNICODE_MAGIC_1 - && b2 == UNICODE_MAGIC_2) - || (b1 == UNICODE_MAGIC_2 - && b2 == UNICODE_MAGIC_1)) - { - in.reset(); - encoding = "UTF-16"; - buffer.setProperty(Buffer.ENCODING,encoding); - } - else if(b1 == UTF8_MAGIC_1 && b2 == UTF8_MAGIC_2 - && b3 == UTF8_MAGIC_3) - { - // do not reset the stream and just treat it - // like a normal UTF-8 file. - buffer.setProperty(Buffer.ENCODING, - MiscUtilities.UTF_8_Y); - - encoding = "UTF-8"; - } - else - { - in.reset(); - - byte[] _xmlPI = new byte[XML_PI_LENGTH]; - int offset = 0; - int count; - while((count = in.read(_xmlPI,offset, - XML_PI_LENGTH - offset)) != -1) - { - offset += count; - if(offset == XML_PI_LENGTH) - break; - } - - String xmlPI = new String(_xmlPI,0,offset, - "ASCII"); - if(xmlPI.startsWith("<?xml")) - { - int index = xmlPI.indexOf("encoding="); - if(index != -1 - && index + 9 != xmlPI.length()) - { - char ch = xmlPI.charAt(index - + 9); - int endIndex = xmlPI.indexOf(ch, - index + 10); - encoding = xmlPI.substring( - index + 10,endIndex); - - if(MiscUtilities.isSupportedEncoding(encoding)) + } else { + if(buffer.getBooleanProperty(Buffer.ENCODING_AUTODETECT)) { + in.mark(XML_PI_LENGTH); + int b1 = in.read(); + int b2 = in.read(); + int b3 = in.read(); + + if (encoding.equals(MiscUtilities.UTF_8_Y)) { + // Java does not support this encoding so + // we have to handle it manually. + if (b1 != UTF8_MAGIC_1 || b2 != UTF8_MAGIC_2 || b3 != UTF8_MAGIC_3) { + // file does not begin with UTF-8-Y + // signature. reset stream, read as + // UTF-8. + in.reset(); + } else { + // file begins with UTF-8-Y signature. + // discard the signature, and read + // the remainder as UTF-8. + } + + encoding = "UTF-8"; + } else { + if (b1 == GZIP_MAGIC_1 && b2 == GZIP_MAGIC_2) { + in.reset(); + in = new GZIPInputStream(in); + buffer.setBooleanProperty(Buffer.GZIPPED,true); + // auto-detect encoding within the gzip stream. + return autodetect(in); + } else { + if ((b1 == UNICODE_MAGIC_1 + && b2 == UNICODE_MAGIC_2) + || (b1 == UNICODE_MAGIC_2 + && b2 == UNICODE_MAGIC_1)) { + in.reset(); + encoding = "UTF-16"; buffer.setProperty(Buffer.ENCODING,encoding); + } else { + if (b1 == UTF8_MAGIC_1 && b2 == UTF8_MAGIC_2 + && b3 == UTF8_MAGIC_3) + { + // do not reset the stream and just treat it + // like a normal UTF-8 file. + buffer.setProperty(Buffer.ENCODING, + MiscUtilities.UTF_8_Y); + + encoding = "UTF-8"; + } else { + in.reset(); + + byte[] _xmlPI = new byte[XML_PI_LENGTH]; + int offset = 0; + int count; + while((count = in.read(_xmlPI,offset, + XML_PI_LENGTH - offset)) != -1) + { + offset += count; + if(offset == XML_PI_LENGTH) + break; + } + + String xmlPI = new String(_xmlPI,0,offset, + "ASCII"); + if (xmlPI.startsWith("<?xml")) { + int index = xmlPI.indexOf("encoding="); + if (index != -1 && index + 9 != xmlPI.length()) { + char ch = xmlPI.charAt(index + 9); + int endIndex = xmlPI.indexOf(ch, index + 10); + encoding = xmlPI.substring(index + 10,endIndex); + + if (MiscUtilities.isSupportedEncoding(encoding)) { + buffer.setProperty(Buffer.ENCODING,encoding); + } else { + Log.log(Log.WARNING,this,"XML PI specifies unsupported encoding: " + encoding); + } + } + } + + in.reset(); + } } - else - { - Log.log(Log.WARNING,this,"XML PI specifies unsupported encoding: " + encoding); - } } } - - in.reset(); } } Modified: branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-07-28 22:46:19 UTC (rev 1082) @@ -57,13 +57,13 @@ * * @author Slava Pestov * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id: VFSManager.java,v 1.15 2004/05/10 03:21:11 spestov Exp $ + * @version $Id$ */ public class VFSManager { /** * The service type. See {@link org.gjt.sp.jedit.ServiceManager}. */ - public static final String SERVICE = "org.gjt.sp.jedit.io.VFS"; + public static final String SERVICE = "net.sourceforge.jsxe.io.VFS"; //{{{ init() method /** @@ -95,7 +95,6 @@ //{{{ getFileVFS() method /** * Returns the local filesystem VFS. - * @since jEdit 2.5pre1 */ public static VFS getFileVFS() { @@ -105,7 +104,6 @@ //{{{ getUrlVFS() method /** * Returns the URL VFS. - * @since jEdit 2.5pre1 */ public static VFS getUrlVFS() { @@ -130,7 +128,6 @@ /** * Returns the VFS for the specified protocol. * @param protocol The protocol - * @since jEdit 2.5pre1 */ public static VFS getVFSForProtocol(String protocol) { @@ -153,7 +150,6 @@ /** * Returns the VFS for the specified path. * @param path The path - * @since jEdit 2.6pre4 */ public static VFS getVFSForPath(String path) { @@ -189,7 +185,6 @@ //{{{ getVFSs() method /** * Returns a list of all registered filesystems. - * @since jEdit 4.2pre1 */ public static String[] getVFSs() { @@ -227,7 +222,6 @@ //{{{ waitForRequests() method /** * Returns when all pending requests are complete. - * @since jEdit 2.5pre1 */ public static void waitForRequests() { @@ -256,7 +250,6 @@ /** * Executes the specified runnable in the AWT thread once all * pending I/O requests are complete. - * @since jEdit 2.5pre1 */ public static void runInAWTThread(Runnable run) { @@ -266,7 +259,6 @@ //{{{ runInWorkThread() method /** * Executes the specified runnable in one of the I/O threads. - * @since jEdit 2.6pre2 */ public static void runInWorkThread(Runnable run) { @@ -318,7 +310,6 @@ * @param path The path name that caused the error * @param messageProp The error message property name * @param args Positional parameters - * @since jEdit 4.0pre3 */ public static void error(Component comp, final String path, @@ -367,7 +358,6 @@ * @param path The path that changed * @param parent True if an update should be sent for the path's * parent too - * @since jEdit 2.6pre4 */ public static void sendVFSUpdate(VFS vfs, String path, boolean parent) { Modified: branches/jsxe2/src/net/sourceforge/jsxe/properties =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/properties 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/properties 2006-07-28 22:46:19 UTC (rev 1082) @@ -45,4 +45,11 @@ metal.secondary.fontstyle=0 #}}} - +#{{{ XMLDocument default properties +xml.document.encoding=UTF-8 +xml.document.element-content-whitespace=true +xml.document.format-pretty-print=false +xml.document.soft-tabs=false +xml.document.indent=4 +xml.document.validating=false +#}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-28 22:08:29
|
Revision: 1074 Author: ian_lewis Date: 2006-07-26 19:05:24 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1074&view=rev Log Message: ----------- Added serialization classes and error node Added Paths: ----------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMOutput.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializer.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializerConfiguration.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializerException.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DefaultDOMLocator.java Added: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java 2006-07-27 02:05:24 UTC (rev 1074) @@ -0,0 +1,172 @@ +/* +XMLError.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom2; + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.gui.Messages; +import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.dom.completion.*; +//}}} + +//{{{ DOM classes +import org.w3c.dom.*; +import org.w3c.dom.events.*; +//}}} + +public class XMLError extends XMLNode { + + private XMLDocument m_document; + private String m_error; + private XMLNode m_parent; + private boolean m_warning; + + //{{{ XMLError constructor + XMLError(XMLDocument document, XMLNode parent, String message, boolean warning) { + super(null); + m_document = document; + m_parent = parent; + m_error = message; + m_warning = warning; + }//}}} + + //{{{ getDocument() + public javax.swing.text.Document getDocument() { + return m_document; + }//}}} + + //{{{ getElement() + public javax.swing.text.Element getElement(int index) { + return null; + }//}}} + + //{{{ getElementCount() + public int getElementCount() { + return 0; + }//}}} + + //{{{ getName() + public String getName() { + //TODO + if (m_warning) { + return Messages.getMessage("common.warning"); + } else { + return Messages.getMessage("common.error"); + } + }//}}} + + //{{{ getParentElement() + public javax.swing.text.Element getParentElement() { + return m_parent; + }//}}} + + //{{{ isLeaf() + public boolean isLeaf() { + return true; + }//}}} + + //{{{ addEventListener() + public void addEventListener(java.lang.String type, EventListener listener, boolean useCapture) {}//}}} + + //{{{ removeEventListener() + public void removeEventListener(java.lang.String type, EventListener listener, boolean useCapture) {}//}}} + + //{{{ appendNode() + public XMLNode appendNode(XMLNode newChild) throws DOMException { + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); + }//}}} + + //{{{ getBaseURI() + public String getBaseURI() { + return m_parent.getBaseURI(); + }//}}} + + //{{{ getNamespaceURI() + public String getNamespaceURI() { + return m_parent.getNamespaceURI(); + }//}}} + + //{{{ getNodeType() + public short getNodeType() { + return ERROR_NODE; + }//}}} + + //{{{ getValue() + public String getValue() { + //TODO + return null; + }//}}} + + //{{{ getNSPrefix() + public String getNSPrefix() { + return null; + }//}}} + + //{{{ insertNode() + + public XMLNode insertNode(XMLNode node, int index) throws DOMException { + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); + }//}}} + + //{{{ lookupNamespaceURI() + public String lookupNamespaceURI(String prefix) { + return m_parent.lookupNamespaceURI(prefix); + }//}}} + + //{{{ removeNode() + public XMLNode removeNode(XMLNode child) throws DOMException { + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); + }//}}} + + //{{{ setValue() + public void setValue(String value) throws DOMException { + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); + }//}}} + + //{{{ setNSPrefix() + public void setNSPrefix(String prefix) throws DOMException { + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); + }//}}} + + //{{{ setName() + public void setName(String name) { + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); + }//}}} + + //{{{ isWarning() + /** + * Returns whether this node represents a warning message + * or an Error message. + * @return true if a warning message, false if an error message + */ + public boolean isWarning() { + return m_warning; + }//}}} + + //{{{ setParent() + protected void setParent(XMLNode node) { + m_parent = node; + }//}}} +} \ No newline at end of file Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java ___________________________________________________________________ Name: svn:executable + * Added: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMOutput.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMOutput.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMOutput.java 2006-07-27 02:05:24 UTC (rev 1074) @@ -0,0 +1,129 @@ +/* +DOMOutput.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2002 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom2.ls; + +//{{{ imports + +//{{{ DOM classes +import org.w3c.dom.ls.LSOutput; +//}}} + +//{{{ Java classes +import java.io.OutputStream; +import java.io.Writer; +//}}} + +//}}} + +/** + * An implementation of the LSOutput interface for use with the DOMSerializer + * class. This object is used when generating locations into a document. + * @author <a href="mailto:IanLewis at member dot fsf dot org">Ian Lewis</a> + * @version $Id: DOMOutput.java 610 2005-04-15 20:01:09Z ian_lewis $ + * @see DOMSerializer + */ +public class DOMOutput implements LSOutput { + + //{{{ DOMOutput constructor + + public DOMOutput(OutputStream byteStream, String encoding) { + m_byteStream = byteStream; + m_encoding = encoding; + }//}}} + + //{{{ DOMOutput constructor + + public DOMOutput(String systemId, String encoding) { + m_systemId = systemId; + m_encoding = encoding; + }//}}} + + //{{{ DOMOutput constructor + + public DOMOutput(Writer characterStream) { + m_characterStream = characterStream; + }//}}} + + //{{{ Implemented LSOutput methods + + //{{{ getByteStream() + + public OutputStream getByteStream() { + return m_byteStream; + }//}}} + + //{{{ getCharacterStream() + + public Writer getCharacterStream() { + return m_characterStream; + }//}}} + + //{{{ getEncoding() + + public String getEncoding() { + return m_encoding; + }//}}} + + //{{{ getSystemId() + + public String getSystemId() { + return m_systemId; + }//}}} + + //{{{ getByteStream() + + public void setByteStream(OutputStream byteStream) { + m_byteStream = byteStream; + }//}}} + + //{{{ setCharacterStream() + + public void setCharacterStream(Writer characterStream) { + m_characterStream = characterStream; + }//}}} + + //{{{ setEncoding() + + public void setEncoding(String encoding) { + m_encoding = encoding; + }//}}} + + //{{{ setSystemId() + + public void setSystemId(String systemId) { + m_systemId = systemId; + }//}}} + + //}}} + + //{{{ Private members + + private OutputStream m_byteStream; + private Writer m_characterStream; + private String m_systemId; + private String m_encoding; + + //}}} +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMOutput.java ___________________________________________________________________ Name: svn:executable + * Added: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializer.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializer.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializer.java 2006-07-27 02:05:24 UTC (rev 1074) @@ -0,0 +1,825 @@ +/* +DOMSerializer.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +This attempts to conform to the DOM3 implementation in Xerces. It tries to +conform to DOM3 as of Xerces 2.6.0. I'm not one to stay on the bleeding edge +but it is as close to a standard interface for load & save as you can get +and I didn't want to work around the fact that current serializers aren't +very good. + +Copyright (C) 2002 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom2.ls; + +//{{{ imports +/* +All classes are listed explicitly so +it is easy to see which package it +belongs to. +*/ + +//{{{ DOM classes +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.DOMException; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Notation; +import org.w3c.dom.ls.LSSerializer; +import org.w3c.dom.ls.LSSerializerFilter; +import org.w3c.dom.ls.LSOutput; +import org.w3c.dom.DOMConfiguration; +import org.w3c.dom.DOMLocator; +import org.w3c.dom.DOMError; +import org.w3c.dom.DOMErrorHandler; +//}}} + +//{{{ Java base classes +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; +import java.net.URL; +import java.net.URLConnection; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Vector; +//}}} + +//}}} + +/** + * An implementation of the DOM3 LSSerializer interface. This class supports + * everything that is supported by the DOMSerializerConfiguration class. Clients + * can check if a feature is supported by calling canSetParameter() on the + * appropriate DOMSerializerConfiguration object. + * + * @author <a href="mailto:IanLewis at member dot fsf dot org">Ian Lewis</a> + * @version $Id: DOMSerializer.java 849 2006-04-18 21:45:20Z ian_lewis $ + */ +public class DOMSerializer implements LSSerializer { + + //{{{ DOMSerializer constructor + /** + * Creates a default DOMSerializer using the default options. + */ + public DOMSerializer() { + config = new DOMSerializerConfiguration(); + m_newLine = System.getProperty("line.separator"); + }//}}} + + //{{{ DOMSerializer constructor + /** + * Creates a DOMSerializer that uses the configuration specified. + * @param config The configuration to be used by this DOMSerializer object + */ + public DOMSerializer(DOMSerializerConfiguration config) { + this.config = config; + m_newLine = System.getProperty("line.separator"); + }//}}} + + //{{{ Implemented LSSerializer methods + + //{{{ getConfig() + + public DOMConfiguration getDomConfig() { + return config; + }//}}} + + //{{{ getFilter() + + public LSSerializerFilter getFilter() { + return m_filter; + }//}}} + + //{{{ getNewLine() + + public String getNewLine() { + return m_newLine; + }//}}} + + //{{{ setFilter() + + public void setFilter(LSSerializerFilter filter) { + m_filter=filter; + }//}}} + + //{{{ setNewLine() + + public void setNewLine(String newLine) { + m_newLine=newLine; + }//}}} + + //{{{ write() + + public boolean write(Node nodeArg, LSOutput destination) { + if (m_filter == null || m_filter.acceptNode(nodeArg) == 1) { + + //{{{ try to get the Writer object for our destination + Writer writer = destination.getCharacterStream(); + String encoding = null; + + if (writer == null) { + //no character stream specified, try the byte stream. + OutputStream out = destination.getByteStream(); + if (out != null) { + + try { + writer = new OutputStreamWriter(out, destination.getEncoding()); + encoding = destination.getEncoding(); + } catch (UnsupportedEncodingException uee) { + DefaultDOMLocator loc = new DefaultDOMLocator(nodeArg, 1, 1, 0, null); + try { + throwError(loc, "unsupported-encoding", DOMError.SEVERITY_FATAL_ERROR, uee); + } catch (DOMSerializerException e) {/*we know this will happen*/} + //This is a fatal error, quit. + return false; + } + } else { + //no char stream or byte stream, try the uri + String id = destination.getSystemId(); + if (id != null) { + + try { + //We use URL since outputing to any other type of URI + //is not possible. + URL uri = new URL(id); + URLConnection con = uri.openConnection(); + + try { + //We want to try to output to the URI + con.setDoOutput(true); + //I don't see a problem with using caches + //do you? + con.setUseCaches(true); + } catch (IllegalStateException ise) { + //we are guaranteed to not be connected + } + + con.connect(); + + writer = new OutputStreamWriter(con.getOutputStream(), destination.getEncoding()); + + } catch (MalformedURLException mue) { + DefaultDOMLocator loc = new DefaultDOMLocator(nodeArg, 1, 1, 0, null); + try { + throwError(loc, "bad-uri", DOMError.SEVERITY_FATAL_ERROR, mue); + } catch (DOMSerializerException e) {/*we know this will happen*/} + //this is a fatal error + return false; + } catch (IOException ioe) { + DefaultDOMLocator loc = new DefaultDOMLocator(nodeArg, 1, 1, 0, null); + try { + throwError(loc, "io-error", DOMError.SEVERITY_FATAL_ERROR, ioe); + } catch (DOMSerializerException e) {/*we know this will happen*/} + //this is a fatal error + return false; + } + + } else { + DefaultDOMLocator loc = new DefaultDOMLocator(nodeArg, 1, 1, 0, null); + try { + throwError(loc, "no-output-specified", DOMError.SEVERITY_FATAL_ERROR, null); + } catch (DOMSerializerException e) {/*we know this will happen*/} + //this is a fatal error + return false; + } + } + }//}}} + + BufferedWriter bufWriter = new BufferedWriter(writer, IO_BUFFER_SIZE); + + try { + serializeNode(bufWriter, nodeArg, encoding); + bufWriter.close(); + return true; + } catch (IOException ioe) { + Object rawHandler = config.getParameter(DOMSerializerConfiguration.ERROR_HANDLER); + if (rawHandler != null) { + DOMErrorHandler handler = (DOMErrorHandler)rawHandler; + DefaultDOMLocator loc = new DefaultDOMLocator(nodeArg, 1, 1, 0, null); + DOMSerializerError error = new DOMSerializerError(loc, ioe, DOMError.SEVERITY_FATAL_ERROR, "io-error"); + handler.handleError(error); + } + } catch (DOMSerializerException dse) { + Object rawHandler = config.getParameter(DOMSerializerConfiguration.ERROR_HANDLER); + if (rawHandler != null) { + DOMErrorHandler handler = (DOMErrorHandler)rawHandler; + DOMError error = dse.getError(); + handler.handleError(error); + } + //This is a fatal error, quit. + } + } + return false; + }//}}} + + //{{{ writeToString() + + public String writeToString(Node nodeArg) throws DOMException { + StringWriter writer = new StringWriter(); + try { + serializeNode(writer, nodeArg); + //flush the output-stream. Without this + //files are sometimes not written at all. + writer.flush(); + } catch (DOMSerializerException dse) { + throw new DOMException(DOMException.INVALID_STATE_ERR, dse.getMessage()); + } + return writer.toString(); + }//}}} + + //{{{ writeToURI() + + public boolean writeToURI(Node nodeArg, java.lang.String uri) { + return write(nodeArg, new DOMOutput(uri, "UTF-8")); + }//}}} + + //}}} + + //{{{ Private static members + private static final int IO_BUFFER_SIZE = 32768; + //}}} + + //{{{ Private members + + //{{{ DOMSerializerError class + + private static class DOMSerializerError implements DOMError { + + //{{{ DOMSerializerError constructor + + public DOMSerializerError(DOMLocator locator, Exception e, short s, String type) { + m_exception = e; + m_location = locator; + m_severity = s; + m_type = type; + }//}}} + + //{{{ getLocation() + + public DOMLocator getLocation() { + return m_location; + }//}}} + + //{{{ getMessage() + + public String getMessage() { + return m_exception.getMessage(); + }//}}} + + //{{{ getRelatedData() + + public Object getRelatedData() { + return m_location.getRelatedNode(); + }//}}} + + //{{{ getRelatedException() + + public Object getRelatedException() { + return m_exception; + }//}}} + + //{{{ getSeverity() + + public short getSeverity() { + return m_severity; + }//}}} + + //{{{ getType() + + public String getType() { + return m_type; + }//}}} + + //{{{ Private members + + private Exception m_exception; + private DOMLocator m_location; + private short m_severity; + private String m_type; + //}}} + + }//}}} + + //{{{ serializeNode() + + private void serializeNode(Writer writer, Node node) throws DOMSerializerException { + serializeNode(writer, node, null); + }//}}} + + //{{{ serializeNode() + /** + * Serializes the node to the writer specified + */ + private void serializeNode(Writer writer, Node node, String encoding) throws DOMSerializerException { + rSerializeNode(writer, node, encoding, "", 1, 1, 0); + }//}}} + + //{{{ rSerializeNode() + /** + * Designed to be called recursively and maintain the state of the + * serialization. + */ + private void rSerializeNode(Writer writer, Node node, String encoding, String currentIndent, int line, int column, int offset) throws DOMSerializerException { + + boolean formatting = config.getFeature(DOMSerializerConfiguration.FORMAT_XML); + // boolean whitespace = config.getFeature(DOMSerializerConfiguration.WS_IN_ELEMENT_CONTENT); + + //This is used many times below as a temporary variable. + String str = ""; + + if (m_filter == null || m_filter.acceptNode(node) == 1) { + switch (node.getNodeType()) { + case Node.DOCUMENT_NODE://{{{ + if (config.getFeature(DOMSerializerConfiguration.XML_DECLARATION)) { + String header = "<?xml version=\"1.0\""; + String realEncoding = (String)config.getParameter(DOMSerializerConfiguration.XML_ENCODING); + if (realEncoding == null) { + realEncoding = encoding; + } + if (realEncoding != null) + header += " encoding=\""+realEncoding+"\""; + header +="?>"; + doWrite(writer, header, node, line, column, offset); + offset += header.length(); + column += header.length(); + + + //if not formatting write newLine here. + if (!formatting) { + column = 0; + line += 1; + doWrite(writer, m_newLine, node, line, column, offset); + offset += m_newLine.length(); + } + } + + NodeList nodes = node.getChildNodes(); + if (nodes != null) { + for (int i=0; i<nodes.getLength(); i++) { + rSerializeNode(writer, nodes.item(i), encoding, currentIndent, line, column, offset); + } + } + + break;//}}} + case Node.ELEMENT_NODE://{{{ + String nodeName = node.getLocalName(); + String nodePrefix = node.getPrefix(); + if (nodeName == null) { + nodeName = node.getNodeName(); + } + + if (formatting) { + //set to zero here for error handling (if doWrite throws exception). + column = 0; + str = m_newLine + currentIndent; + doWrite(writer, str, node, line, column, offset); + column += currentIndent.length(); + offset += str.length(); + } + + if (config.getFeature(DOMSerializerConfiguration.NAMESPACES) && nodePrefix != null) { + str = "<" + nodePrefix + ":" + nodeName; + } else { + str = "<" + nodeName; + } + + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + + NamedNodeMap attr = node.getAttributes(); + for (int i=0; i<attr.getLength(); i++) { + Attr currentAttr = (Attr)attr.item(i); + boolean writeAttr = false; + + /* + if we discard default content check if the attribute + was specified in the original document. + */ + if (config.getFeature(DOMSerializerConfiguration.DISCARD_DEFAULT_CONTENT)) { + if (currentAttr.getSpecified()) { + writeAttr = true; + } + } else { + writeAttr = true; + } + + if (writeAttr) { + str = " " + currentAttr.getNodeName() + "=\"" + normalizeCharacters(currentAttr.getNodeValue()) + "\""; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + } + } + + NodeList children = node.getChildNodes(); + if (children != null) { + + //check if element is empty or has + //only whitespace-only nodes + boolean elementEmpty = false; + if (children.getLength() <= 0) { + elementEmpty = true; + } else { + if (!config.getFeature(DOMSerializerConfiguration.WS_IN_ELEMENT_CONTENT)) { + boolean hasWSOnlyElements = true; + for(int i=0; i<children.getLength();i++) { + hasWSOnlyElements = hasWSOnlyElements && + children.item(i).getNodeType()==Node.TEXT_NODE && + children.item(i).getNodeValue().trim().equals(""); + } + elementEmpty = formatting && hasWSOnlyElements; + } + } + if (!elementEmpty) { + + str = ">"; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + + String indentUnit = ""; + + if (formatting) { + if (config.getFeature(DOMSerializerConfiguration.SOFT_TABS)) { + //get the indent size and use it when serializing the children nodes. + Integer indentSize = (Integer)config.getParameter("indent"); + if (indentSize != null) { + int size = indentSize.intValue(); + StringBuffer buf = new StringBuffer(); + for (int i=0; i < size; i++) { + buf.append(" "); + } + indentUnit = buf.toString(); + } + } else { + indentUnit = "\t"; + } + } + + + for(int i=0; i<children.getLength();i++) { + rSerializeNode(writer, children.item(i), encoding, currentIndent + indentUnit, line, column, offset); + } + + //don't add a new line if there is only text node children + if (formatting) { + + boolean allText = true; + for(int i=0; i<children.getLength();i++) { + if (!(children.item(i).getNodeType()==Node.TEXT_NODE) && + !(children.item(i).getNodeType()==Node.CDATA_SECTION_NODE)) + { + allText = false; + break; + } + } + + if (!allText) { + //set to zero here for error handling (if doWrite throws exception). + column = 0; + str = m_newLine + currentIndent; + doWrite(writer, str, node, line, column, offset); + column += currentIndent.length(); + offset += str.length(); + } + } + if (config.getFeature(DOMSerializerConfiguration.NAMESPACES) && nodePrefix != null) { + str = "</" + nodePrefix + ":" +nodeName + ">"; + } else { + str = "</" + nodeName + ">"; + } + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + + } else { + str = "/>"; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + } + } + break;//}}} + case Node.TEXT_NODE://{{{ + String text = node.getNodeValue(); + //formatting implies no whitespace + //but to be explicit... + // if (!whitespace || formatting) { + // text = text.trim(); + // } + if (!text.equals("")) { + if (formatting) { + if (text.trim().equals("")) { + //ignore this whitespace only text if formatting + return; + } + + /* + don't format text nodes + if (node.getNextSibling() != null || node.getPreviousSibling() != null) { + line++; + column=0; + doWrite(writer, m_newLine, node, line, column, offset); + offset += m_newLine.length(); + } + */ + } + + //TODO: This is a dumb quick fix and should probably be changed. + for (int i=0; i<text.length();i++) { + //this must be first or it picks up the other + //entities. + str = text.substring(i, i+1); + if (str.equals("&")) { + str = "&"; + } + if (str.equals(">")) { + str = ">"; + } + if (str.equals("<")) { + str = "<"; + } + if (str.equals("\'")) { + str = "'"; + } + if (str.equals("\"")) { + str = """; + } + if (str.equals(m_newLine)) { + line++; + column=0; + doWrite(writer, m_newLine, node, line, column, offset); + offset += m_newLine.length(); + } else { + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + } + } + } + break;//}}} + case Node.CDATA_SECTION_NODE://{{{ + if (config.getFeature(DOMSerializerConfiguration.CDATA_SECTIONS)) { + //shouldn't add newlines for + // if (formatting) { + // //set to zero here for error handling (if doWrite throws exception) + // column = 0; + // str = m_newLine + currentIndent; + // doWrite(writer, str, node, line, column, offset); + // column += currentIndent.length(); + // offset += str.length(); + // } + str = "<![CDATA["; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + + String cdata = node.getNodeValue(); + for (int i=0; i<cdata.length(); i++) { + + str = cdata.substring(i, i+1); + if (str.equals("]") && i+3 < cdata.length() && cdata.substring(i, i+3).equals("]]>")) { + //split the cdata + DefaultDOMLocator loc = new DefaultDOMLocator(node, line, column, offset, null); + if (config.getFeature(DOMSerializerConfiguration.SPLIT_CDATA)) { + i+=2; + str = "]]]]>"; + /* + if (formatting) { + str += (m_newLine + currentIndent); + column = currentIndent.length(); + offset += (m_newLine.length() + currentIndent.length()); + } + */ + str += "<![CDATA[>"; + throwError(loc, "cdata-sections-splitted", DOMError.SEVERITY_WARNING, null); + } else { + throwError(loc, "invalid-data-in-cdata-section", DOMError.SEVERITY_FATAL_ERROR, null); + } + } + if (str.equals(m_newLine)) { + line++; + column=0; + doWrite(writer, m_newLine, node, line, column, offset); + offset += m_newLine.length(); + } else { + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + } + + } + + str = "]]>"; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + } else { + //transform to text node. + Node textNode = node.getOwnerDocument().createTextNode(node.getNodeValue()); + rSerializeNode(writer, textNode, encoding, currentIndent, line, column, offset); + } + break;//}}} + case Node.COMMENT_NODE://{{{ + if (config.getFeature("comments")) { + if (formatting) { + //set to zero here for error handling (if doWrite throws exception) + column = 0; + str = m_newLine + currentIndent; + doWrite(writer, str, node, line, column, offset); + column += currentIndent.length(); + offset += str.length(); + } + str = "<!--"+node.getNodeValue()+"-->"; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + } + break;//}}} + case Node.PROCESSING_INSTRUCTION_NODE://{{{ + + if (formatting) { + //set to zero here for error handling (if doWrite throws exception) + column = 0; + str = m_newLine + currentIndent; + doWrite(writer, str, node, line, column, offset); + column += currentIndent.length(); + offset += str.length(); + } + + str = "<?" + node.getNodeName() + " " + node.getNodeValue() + "?>"; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + + break;//}}} + case Node.ENTITY_REFERENCE_NODE://{{{ + str = "&" + node.getNodeName() + ";"; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + break;//}}} + case Node.DOCUMENT_TYPE_NODE://{{{ + DocumentType docType = (DocumentType)node; + + if (formatting) { + //set to zero here for error handling (if doWrite throws exception). + column = 0; + str = m_newLine + currentIndent; + doWrite(writer, str, node, line, column, offset); + column += currentIndent.length(); + offset += str.length(); + } + + str = "<!DOCTYPE " + docType.getName(); + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + if (docType.getPublicId() != null) { + str = " PUBLIC \"" + docType.getPublicId() + "\" "; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + } + if (docType.getSystemId() != null) { + if (docType.getPublicId() == null) { + str = " SYSTEM "; + } else { + str = ""; + } + str += "\"" + docType.getSystemId() + "\""; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + } + + String internalSubset = docType.getInternalSubset(); + if (internalSubset != null && !internalSubset.equals("")) { + str = " [ "+internalSubset+" ]"; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + } + + str = ">"; + doWrite(writer, str, node, line, column, offset); + column += str.length(); + offset += str.length(); + + //need to add a newline so that the next item is on a new line + //since text nodes are not included outside of the root element + if (!formatting) { + column = 0; + str = m_newLine + currentIndent; + doWrite(writer, str, node, line, column, offset); + column += currentIndent.length(); + offset += str.length(); + } + + break;//}}} + } + } + }//}}} + + //{{{ doWrite() + /** + * Performs an actual write and implements error handling. + */ + private void doWrite(Writer writer, String str, Node wnode, int line, int column, int offset) throws DOMSerializerException { + try { + writer.write(str, 0, str.length()); + } catch (IOException ioe) { + + DefaultDOMLocator loc = new DefaultDOMLocator(wnode, line, column, offset, null); + + throwError(loc, "io-error", DOMError.SEVERITY_FATAL_ERROR, ioe); + } + }//}}} + + //{{{ throwError() + /** + * Throws an error, notifying the ErrorHandler object if necessary. + * @return the value returned by the error handler or false if the severity was SEVERITY_FATAL_ERROR + */ + private void throwError(DOMLocator loc, String type, short severity, Exception e) throws DOMSerializerException { + Object rawHandler = config.getParameter(DOMSerializerConfiguration.ERROR_HANDLER); + boolean handled = false; + if (severity == DOMError.SEVERITY_WARNING) { + handled = true; + } + DOMSerializerError error = new DOMSerializerError(loc, e, severity, type); + if (rawHandler != null) { + DOMErrorHandler handler = (DOMErrorHandler)rawHandler; + handled = handler.handleError(error); + } + + if ((severity == DOMError.SEVERITY_ERROR && !handled) || severity == DOMError.SEVERITY_FATAL_ERROR) { + throw new DOMSerializerException(error); + } + }//}}} + + //{{{ normalizeCharacters() + + private String normalizeCharacters(String text) { + StringBuffer newText = new StringBuffer(); + //This is a dumb quick fix and should be changed. + for (int i=0; i<text.length();i++) { + //this must be first or it picks up the other + //entities. + String str = text.substring(i, i+1); + if (str.equals("&")) { + str = "&"; + } + if (str.equals(">")) { + str = ">"; + } + if (str.equals("<")) { + str = "<"; + } + if (str.equals("\'")) { + str = "'"; + } + if (str.equals("\"")) { + str = """; + } + newText.append(str); + } + return newText.toString(); + }//}}} + + private DOMSerializerConfiguration config; + private LSSerializerFilter m_filter; + private String m_newLine; + + //}}} +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializer.java ___________________________________________________________________ Name: svn:executable + * Added: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializerConfiguration.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializerConfiguration.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/DOMSerializerConfiguration.java 2006-07-27 02:05:24 UTC (rev 1074) @@ -0,0 +1,478 @@ +/* +DOMSerializerConfiguration.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +This attempts to conform to the DOM3 implementation in Xerces. It conforms +to DOM3 as of Xerces 2.3.0. I'm not one to stay on the bleeding edge but +there is as close to a standard interface for load & save as you can get and I +didn't want to work around the fact that current serializers aren't very good. + +Copyright (C) 2002 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom2.ls; + +//{{{ imports + +//{{{ DOM classes +import org.w3c.dom.DOMException; +import org.w3c.dom.DOMConfiguration; +import org.w3c.dom.DOMError; +import org.w3c.dom.DOMErrorHandler; +import org.w3c.dom.DOMLocator; +import org.w3c.dom.DOMStringList; +//}}} + +//{{{ Java classes +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +//}}} + +import net.sourceforge.jsxe.util.Log; + +//}}} + +/** + * <p>DOMSerializerConfiguration is the default implementation of the DOMConfiguration + * interface to be used with the DOMSerializer class.</p> + * + * <p>Currently, this class only supports the required options with few exceptions. + * The <code>"format-pretty-print"</code> option is supported. + * A <code>"soft-tabs"</code> option is supported which specifies whether + * to emulate tabs with spaces. + * An <code>"indent"</code> option is supported to specify the indent/tab + * size when the <code>"soft-tabs"</code> feature is true. This has no effect + * if <code>"soft-tabs"</code> is false.</p> + * + * @author <a href="mailto:IanLewis at member dot fsf dot org">Ian Lewis</a> + * @version $Id: DOMSerializerConfiguration.java 833 2006-04-08 16:30:49Z ian_lewis $ + * @see DOMSerializer + */ +public class DOMSerializerConfiguration implements DOMConfiguration { + + //{{{ DOMConfiguration defined parameters + public static final String CANONICAL_FORM = "canonical-form"; + public static final String CDATA_SECTIONS = "cdata-sections"; + public static final String CHAR_NORMALIZATION = "check-character-normalization"; + public static final String COMMENTS = "comments"; + public static final String DATATYPE_NORMALIZATION = "datatype-normalization"; + public static final String ENTITIES = "entities"; + public static final String ERROR_HANDLER = "error-handler"; + public static final String INFOSET = "infoset"; + public static final String NAMESPACES = "namespaces"; + public static final String NAMESPACE_DECLARATIONS = "namespace-declarations"; + public static final String NORMALIZE_CHARS = "normalize-characters"; + public static final String SPLIT_CDATA = "split-cdata-sections"; + public static final String VALIDATE_XML = "validate"; + public static final String VALIDATE_IF_SCHEMA = "validate-if-schema"; + public static final String WELL_FORMED = "well-formed"; + public static final String WS_IN_ELEMENT_CONTENT = "element-content-whitespace"; + //}}} + + //{{{ LSSerializer defined parameters + public static final String DISCARD_DEFAULT_CONTENT = "discard-default-content"; + public static final String FORMAT_XML = "format-pretty-print"; + public static final String IGNORE_UNKNOWN_CHAR_DENORM = "ignore-unknown-character-denormalizations"; + public static final String XML_DECLARATION = "xml-declaration"; + //}}} + + //{{{ Additional parameters supported by DOMSerializerConfiguration + /** + * Use spaces instead of tabs if this is true. + */ + public static final String SOFT_TABS = "soft-tabs"; + /** + * The number of spaces to use as an tab when SOFT_TABS is true. + */ + public static final String INDENT = "indent"; + /** + * The encoding to use in the XML declaration. + */ + public static final String XML_ENCODING = "encoding"; + //}}} + + //{{{ DOMSerializerConfiguration constructor + + public DOMSerializerConfiguration() { + + //set the default boolean parameters for a DOMConfiguration + setFeature(CANONICAL_FORM, false); + setFeature(CDATA_SECTIONS, true); + setFeature(CHAR_NORMALIZATION, false); + setFeature(COMMENTS, true); + setFeature(DATATYPE_NORMALIZATION, false); + setFeature(ENTITIES, true); + //infoset is not present because it is determined + //by checking the values of other features. + setFeature(NAMESPACES, true); + setFeature(NAMESPACE_DECLARATIONS, true); + setFeature(NORMALIZE_CHARS, true); + setFeature(SPLIT_CDATA, true); + setFeature(VALIDATE_XML, false); + setFeature(VALIDATE_IF_SCHEMA, false); + setFeature(WELL_FORMED, true); + setFeature(WS_IN_ELEMENT_CONTENT, true); + + //LSSeraializer features + setFeature(DISCARD_DEFAULT_CONTENT, true); + setFeature(FORMAT_XML, false); + setFeature(IGNORE_UNKNOWN_CHAR_DENORM, true); + setFeature(XML_DECLARATION, true); + + //DOMSerializer parameters + setFeature(SOFT_TABS, false); + setParameter(INDENT, new Integer(4)); + setParameter(XML_ENCODING, null); + }//}}} + + //{{{ DOMSerializerConfiguration constructor + + public DOMSerializerConfiguration(DOMConfiguration config) throws DOMException { + this(); + Iterator iterator = m_supportedParameters.iterator(); + while (iterator.hasNext()) { + String param = iterator.next().toString(); + setParameter(param, config.getParameter(param)); + } + }//}}} + + //{{{ Implemented DOMConfiguration methods + + //{{{ canSetParameter() + + public boolean canSetParameter(String name, Object value) { + + if (value == null) { + return (m_supportedParameters.indexOf(name) != -1); + } + + if (value instanceof Boolean) { + boolean booleanValue = ((Boolean)value).booleanValue(); + + //couldn't think of a slicker way to do this + //that was worth the time to implement + //and extra processing. + if (name.equals(CANONICAL_FORM)) { + return !booleanValue; + } + if (name.equals(CDATA_SECTIONS)) { + return true; + } + if (name.equals(CHAR_NORMALIZATION)) { + return !booleanValue; + } + if (name.equals(COMMENTS)) { + return true; + } + if (name.equals(DATATYPE_NORMALIZATION)) { + return true; + } + if (name.equals(ENTITIES)) { + return true; + } + if (name.equals(WELL_FORMED)) { + return true; + } + if (name.equals(INFOSET)) { + return true; + } + if (name.equals(NAMESPACES)) { + return true; + } + if (name.equals(NAMESPACE_DECLARATIONS)) { + return true; + } + if (name.equals(NORMALIZE_CHARS)) { + return true; + } + if (name.equals(SPLIT_CDATA)) { + return true; + } + if (name.equals(VALIDATE_XML)) { + return !booleanValue; + } + if (name.equals(VALIDATE_IF_SCHEMA)) { + return !booleanValue; + } + if (name.equals(WS_IN_ELEMENT_CONTENT)) { + return true; + } + + if (name.equals(DISCARD_DEFAULT_CONTENT)) { + return true; + } + if (name.equals(FORMAT_XML)) { + return true; + } + if (name.equals(IGNORE_UNKNOWN_CHAR_DENORM)) { + return booleanValue; + } + if (name.equals(XML_DECLARATION)) { + return true; + } + if (name.equals(SOFT_TABS)) { + return true; + } + + return false; + } else { + if (name.equals(ERROR_HANDLER)) { + if (value instanceof DOMErrorHandler) { + return true; + } + } + if (name.equals(INDENT)) { + if (value instanceof Integer) { + return true; + } + } + if (name.equals(XML_ENCODING)) { + if (value instanceof String) { + return true; + } + } + } + return false; + }//}}} + + //{{{ getParameter() + + public Object getParameter(String name) throws DOMException { + + if (m_supportedParameters.indexOf(name) != -1) { + + if (name.equals("infoset")) { + boolean namespaceDeclarations = getFeature(NAMESPACE_DECLARATIONS); + boolean validateIfSchema = getFeature(VALIDATE_IF_SCHEMA); + boolean entities = getFeature(ENTITIES); + boolean datatypeNormalization = getFeature(DATATYPE_NORMALIZATION); + boolean cdataSections = getFeature(CDATA_SECTIONS); + + boolean whitespace = getFeature(WS_IN_ELEMENT_CONTENT); + boolean comments = getFeature(COMMENTS); + boolean namespaces = getFeature(NAMESPACES); + + return (Boolean.valueOf(!namespaceDeclarations && + !validateIfSchema && + !entities && + !datatypeNormalization && + !cdataSections && + whitespace && + comments && + namespaces)); + } else { + return m_parameters.get(name); + } + + } else { + + throw new DOMException(DOMException.NOT_FOUND_ERR ,"NOT_FOUND_ERR: Parameter "+name+" not recognized"); + + } + }//}}} + + //{{{ getParameterNames() + + public DOMStringList getParameterNames() { + return new DOMStringListImpl(m_supportedParameters); + }//}}} + + //{{{ setParameter() + + public void setParameter(String name, Object value) throws DOMException { + + if (value instanceof String && + (value.toString().equalsIgnoreCase("true") || + value.toString().equalsIgnoreCase("false"))) + { + Log.log(Log.WARNING,this, "Possibly setting XML serializer config boolean feature "+name+" with string value"); + } + + if (m_supportedParameters.indexOf(name) != -1) { + if ( value != null ) { + if (canSetParameter(name, value)) { + /* + if the parameter is infoset + then force the other parameters to + values that the infoset option + requires. + */ + if (name.equals(INFOSET)) { + setFeature(NAMESPACE_DECLARATIONS,false); + setFeature(VALIDATE_IF_SCHEMA, false); + setFeature(ENTITIES, false); + ... [truncated message content] |
From: <ian...@us...> - 2006-07-28 22:03:28
|
Revision: 1071 Author: ian_lewis Date: 2006-07-26 10:07:45 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1071&view=rev Log Message: ----------- Version bump Modified Paths: -------------- trunk/treeview/build.xml trunk/treeview/dependency.props Modified: trunk/treeview/build.xml =================================================================== --- trunk/treeview/build.xml 2006-07-26 17:07:26 UTC (rev 1070) +++ trunk/treeview/build.xml 2006-07-26 17:07:45 UTC (rev 1071) @@ -38,7 +38,7 @@ <property name="main.class" value="treeview.TreeViewPlugin"/> <property name="major.version" value="0"/> <property name="minor.version" value="5"/> - <property name="build.version" value="1"/> + <property name="build.version" value="3"/> <property name="app.version" value="${major.version}.${minor.version}.${build.version}"/> <property name="app_version" value="${major.version}_${minor.version}_${build.version}"/> <property name="implementation.version" value="${major.version}.${minor.version}.${build.version}"/> Modified: trunk/treeview/dependency.props =================================================================== --- trunk/treeview/dependency.props 2006-07-26 17:07:26 UTC (rev 1070) +++ trunk/treeview/dependency.props 2006-07-26 17:07:45 UTC (rev 1071) @@ -1 +1 @@ -dependency.0=jsxe 00.05.01.00 +dependency.0=jsxe 00.05.03.00 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-28 21:56:06
|
Revision: 1064 Author: ian_lewis Date: 2006-07-25 13:06:34 -0700 (Tue, 25 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1064&view=rev Log Message: ----------- added support for the read only attribute Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/INSTALL trunk/jsxe/NEWS trunk/jsxe/build.xml Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-24 21:24:27 UTC (rev 1063) +++ trunk/jsxe/Changelog 2006-07-25 20:06:34 UTC (rev 1064) @@ -1,3 +1,9 @@ +07/24/2006 Ian Lewis <Ian...@me...> + + * Fixed a bug with the source view for new users that caused a + NullPointerException to be thrown when opening the source view. + * Added a wrapper exe for windows users using jSmooth + 07/21/2006 Ian Lewis <Ian...@me...> * Fixed bug 1509575. Files that are reloaded should always be loaded in a Modified: trunk/jsxe/INSTALL =================================================================== --- trunk/jsxe/INSTALL 2006-07-24 21:24:27 UTC (rev 1063) +++ trunk/jsxe/INSTALL 2006-07-25 20:06:34 UTC (rev 1064) @@ -51,23 +51,19 @@ RUNNING jsXe You should have 1.4.2 or better of java and you need 2.6.2 of Xerces. -To run jsXe you should just run the java interpreter on the jsXe.jar file. There -is a shell script or batch file included in the source tree for this purpose. - ./bin/jsXe.sh +*Windows* -or +Just run jsXe using the jsXe.exe in the install directory. The exe will +detect your version of Java and run jsXe using that version. - ./bin/jsXe.bat +*Unix* -The batch program should be run in with the jsXe root directory of as the -working directory. So you can create a shortcut to run jsXe by specifying the -batch file as the program to run and jsXe's root directory as the working -directory. +To run jsXe you should just run the java interpreter on the jsXe.jar file. There +is a shell script or batch file included in the source tree for this purpose. -Ex. -Target: "C:\Program Files\jsXe\bin\jsXe.bat" -Start in: "C:\Program Files\jsXe\" +./bin/jsXe.sh -You can also edit the JSXEDIR variable in the batch program to be the directory -where you installed jsXe and then the 'Start in' directory can be anywhere. +The shell script should be run in with the jsXe root directory of as the +working directory. You can also edit the JSXEDIR variable in the shell script +to be the directory where you installed jsXe. Modified: trunk/jsxe/NEWS =================================================================== --- trunk/jsxe/NEWS 2006-07-24 21:24:27 UTC (rev 1063) +++ trunk/jsxe/NEWS 2006-07-25 20:06:34 UTC (rev 1064) @@ -1,5 +1,13 @@ -07/25/2006 version 0.5 pre1 +07/24/2006 version 0.5 pre2 + * Fixed a bug with the source view for new users that caused a + NullPointerException to be thrown when opening the source view. + * Added a wrapper exe for windows users using jSmooth + * Fixed bug 1509575. Files that are reloaded should always be loaded in a + view that can accep the reloaded file. + +07/20/2006 version 0.5 pre1 + * Added support for keyboard shortcuts that can be set by the user via the Global Options Dialog. * Split the options into two dialogs. The Global Options, which are Modified: trunk/jsxe/build.xml =================================================================== --- trunk/jsxe/build.xml 2006-07-24 21:24:27 UTC (rev 1063) +++ trunk/jsxe/build.xml 2006-07-25 20:06:34 UTC (rev 1064) @@ -52,7 +52,7 @@ <property name="main.class" value="net.sourceforge.jsxe.jsXe"/> <property name="major.version" value="0"/> <property name="minor.version" value="5"/> - <property name="beta.version" value="1"/> + <property name="beta.version" value="2"/> <property name="bugfix.version" value="0"/> <property name="buildlib.dir" value="${root.dir}/buildlib"/> @@ -67,9 +67,9 @@ </condition> <!-- Human Readable --> - <property name="app.version" value="0.5 pre1"/> + <property name="app.version" value="0.5 pre2"/> <!-- Used in filenames --> - <property name="app_version" value="05_pre1"/> + <property name="app_version" value="05_pre2"/> <!--<property name="app.version" value="${major.version}.${minor.version} beta"/>--> <!--<property name="app_version" value="${major.version}_${minor.version}beta"/>--> <property name="distbin.dir" value="${build.dir}/${app.name}-${app_version}-bin"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-28 20:23:09
|
Revision: 1067 Author: ian_lewis Date: 2006-07-26 09:56:28 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1067&view=rev Log Message: ----------- Fixed a bug where the shortcuts for Built-In commands were not being honored. Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-26 15:30:29 UTC (rev 1066) +++ trunk/jsxe/Changelog 2006-07-26 16:56:28 UTC (rev 1067) @@ -2,6 +2,8 @@ * Updated the find and findnext actions to use proper messages labels. + * Fixed a bug where the shortcuts for Built-In commands were not being + honored. 07/24/2006 Ian Lewis <Ian...@me...> Modified: trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-07-26 15:30:29 UTC (rev 1066) +++ trunk/jsxe/src/net/sourceforge/jsxe/ActionManager.java 2006-07-26 16:56:28 UTC (rev 1067) @@ -82,6 +82,7 @@ public static final String COPY_SUFFIX = ".copy"; public static final String PASTE_SUFFIX = ".paste"; public static final String FIND_SUFFIX = ".find"; + public static final String FIND_NEXT_SUFFIX = ".findnext"; //}}} @@ -173,27 +174,6 @@ Log.log(Log.NOTICE, ActionManager.class, "Loading key bindings."); if (!initialized) { - //Add EditBus Listener to update key bindings when properties are changed - EditBus.addToBus(new EBListener() { - - //{{{ handleMessage() - public void handleMessage(EBMessage message) { - if (message instanceof PropertyChanged) { - PropertyChanged msg = (PropertyChanged)message; - if (msg.getKey().endsWith(".shortcut")) { - String actionName = msg.getKey().substring(0, msg.getKey().lastIndexOf(".")); - String keyBinding = jsXe.getProperty(msg.getKey()); - if (keyBinding != null) { - addKeyBinding(keyBinding, actionName); - } else { - removeKeyBinding(msg.getOldValue()); - } - } - } - }//}}} - - }); - Iterator itr = m_actionSets.iterator(); while (itr.hasNext()) { ActionSet set = (ActionSet)itr.next(); @@ -233,9 +213,15 @@ if (action != null && keyBinding != null) { Action wrapper = getAction(action.getName()); + + KeyEventTranslator.Key key = KeyEventTranslator.parseKey(keyBinding); m_keyBindingMap.put(key, wrapper); + Log.log(Log.DEBUG, ActionManager.class, "Adding binding: "+key.toString()); + Log.log(Log.DEBUG, ActionManager.class, "key.key: "+key.key); + Log.log(Log.DEBUG, ActionManager.class, "key.input: "+key.input); + //need to do this so that the accelerator key is rendered on menu items wrapper.putValue(Action.ACCELERATOR_KEY, KeyEventTranslator.getKeyStroke(keyBinding)); } @@ -268,6 +254,9 @@ */ public static void handleKey(KeyEvent event) { KeyEventTranslator.Key key = KeyEventTranslator.translateKeyEvent(event); + Log.log(Log.DEBUG, ActionManager.class, "Key: "+key.toString()); + Log.log(Log.DEBUG, ActionManager.class, "key.key: "+key.key); + Log.log(Log.DEBUG, ActionManager.class, "key.input: "+key.input); //Gets the action for the Key. Action action = (Action)m_keyBindingMap.get(key); @@ -286,7 +275,8 @@ return (actionName.endsWith(CUT_SUFFIX) || actionName.endsWith(COPY_SUFFIX) || actionName.endsWith(PASTE_SUFFIX) || - actionName.endsWith(FIND_SUFFIX)); + actionName.endsWith(FIND_SUFFIX) || + actionName.endsWith(FIND_NEXT_SUFFIX)); }//}}} //{{{ Wrapper class Modified: trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-07-26 15:30:29 UTC (rev 1066) +++ trunk/jsxe/src/net/sourceforge/jsxe/jsXe.java 2006-07-26 16:56:28 UTC (rev 1067) @@ -321,15 +321,32 @@ initPLAF(); //}}} - //{{{ init key bindings + //{{{ Add EditBus Listener to update key bindings when properties are changed /* - key bindings are loaded before the TabbedView is created - so that the ActionManagers EBListener is added to the EditBus first - Hopefully this is a temporary problem. + This must be done before creating the TabbedView so that + the ActionManager's listener is notified of changes first. */ - ActionManager.initKeyBindings(); - //}}} + EditBus.addToBus(new EBListener() { + + //{{{ handleMessage() + public void handleMessage(EBMessage message) { + if (message instanceof PropertyChanged) { + PropertyChanged msg = (PropertyChanged)message; + if (msg.getKey().endsWith(".shortcut")) { + String actionName = msg.getKey().substring(0, msg.getKey().lastIndexOf(".")); + String keyBinding = jsXe.getProperty(msg.getKey()); + if (keyBinding != null) { + ActionManager.addKeyBinding(keyBinding, actionName); + } else { + ActionManager.removeKeyBinding(msg.getOldValue()); + } + } + } + }//}}} + + });//}}} + //{{{ create the TabbedView Log.log(Log.NOTICE, jsXe.class, "Starting the main window"); TabbedView tabbedview = null; @@ -366,6 +383,10 @@ progressScreen.updateSplashScreenDialog(85); //}}} + //{{{ init key bindings + ActionManager.initKeyBindings(); + //}}} + //{{{ Parse files to open on the command line Log.log(Log.NOTICE, jsXe.class, "Parsing files to open on command line"); if (files.size() > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-28 20:04:49
|
Revision: 1081 Author: ian_lewis Date: 2006-07-28 13:04:32 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1081&view=rev Log Message: ----------- Added WorkThread classes Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java Added Paths: ----------- branches/jsxe2/src/net/sourceforge/jsxe/util/WorkRequest.java branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThread.java branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadPool.java branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadProgressListener.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-07-28 20:03:36 UTC (rev 1080) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-07-28 20:04:32 UTC (rev 1081) @@ -60,7 +60,7 @@ /** * Buffer boolean property set when an error occurs. */ - public static final String ERROR_OCCURRED = "BufferIORequest__error"; + public static final String ERROR_OCCURRED = "XMLDocumentIORequest__error"; /** * A file load request. @@ -105,12 +105,12 @@ * Creates a new buffer I/O request. * @param type The request type * @param view The view - * @param buffer The buffer + * @param buffer The document * @param session The VFS session * @param vfs The VFS * @param path The path */ - public XMLDocumentIORequest(int type, View view, Buffer buffer, + public XMLDocumentIORequest(int type, TabbedView view, XMLDocument buffer, Object session, VFS vfs, String path) { this.type = type; @@ -126,44 +126,42 @@ } //}}} //{{{ run() method - public void run() - { - switch(type) - { - case LOAD: - load(); - break; - case SAVE: - save(); - break; - case AUTOSAVE: - autosave(); - break; - case INSERT: - insert(); - break; - default: - throw new InternalError(); + public void run() { + + switch(type) { + case LOAD: + load(); + break; + case SAVE: + save(); + break; + case AUTOSAVE: + autosave(); + break; + case INSERT: + insert(); + break; + default: + throw new InternalError(); } } //}}} //{{{ toString() method - public String toString() - { + public String toString() { + String typeString; - switch(type) - { - case LOAD: - typeString = "LOAD"; - break; - case SAVE: - typeString = "SAVE"; - break; - case AUTOSAVE: - typeString = "AUTOSAVE"; - break; - default: - typeString = "UNKNOWN!!!"; + switch(type) { + case LOAD: + typeString = "LOAD"; + break; + case SAVE: + typeString = "SAVE"; + break; + case AUTOSAVE: + typeString = "AUTOSAVE"; + break; + default: + typeString = "UNKNOWN!!!"; } return getClass().getName() + "[type=" + typeString @@ -183,18 +181,17 @@ //}}} //{{{ load() method - private void load() - { + private void load() { + InputStream in = null; - try - { - try - { + try { + try { + String[] args = { vfs.getFileName(path) }; setAbortable(true); - if(!buffer.isTemporary()) - { + + if (!buffer.isTemporary()) { setStatus(jEdit.getProperty("vfs.status.load",args)); setProgressValue(0); } @@ -204,103 +201,83 @@ VFS.DirectoryEntry entry = vfs._getDirectoryEntry( session,path,view); long length; - if(entry != null) + if (entry != null) { length = entry.length; - else + } else { length = 0L; + } - in = vfs._createInputStream(session,path, - false,view); - if(in == null) + in = vfs._createInputStream(session,path,false,view); + if (in == null) { return; + } read(autodetect(in),length,false); buffer.setNewFile(false); - } - catch(CharConversionException ch) - { + } catch(CharConversionException ch) { Log.log(Log.ERROR,this,ch); Object[] pp = { buffer.getProperty(Buffer.ENCODING), ch.toString() }; VFSManager.error(view,path,"ioerror.encoding-error",pp); buffer.setBooleanProperty(ERROR_OCCURRED,true); - } - catch(UnsupportedEncodingException uu) - { + + } catch(UnsupportedEncodingException uu) { Log.log(Log.ERROR,this,uu); Object[] pp = { buffer.getProperty(Buffer.ENCODING), uu.toString() }; VFSManager.error(view,path,"ioerror.encoding-error",pp); buffer.setBooleanProperty(ERROR_OCCURRED,true); - } - catch(IOException io) - { + + } catch(IOException io) { Log.log(Log.ERROR,this,io); Object[] pp = { io.toString() }; VFSManager.error(view,path,"ioerror.read-error",pp); buffer.setBooleanProperty(ERROR_OCCURRED,true); - } - catch(OutOfMemoryError oom) - { + + } catch(OutOfMemoryError oom) { Log.log(Log.ERROR,this,oom); VFSManager.error(view,path,"out-of-memory-error",null); buffer.setBooleanProperty(ERROR_OCCURRED,true); } - if(jEdit.getBooleanProperty("persistentMarkers")) - { - try - { + if (jEdit.getBooleanProperty("persistentMarkers")) { + try { String[] args = { vfs.getFileName(path) }; - if(!buffer.isTemporary()) + if (!buffer.isTemporary()) { setStatus(jEdit.getProperty("vfs.status.load-markers",args)); + } setAbortable(true); in = vfs._createInputStream(session,markersPath,true,view); if(in != null) readMarkers(buffer,in); - } - catch(IOException io) - { + } catch(IOException io) { // ignore } } - } - catch(WorkThread.Abort a) - { - if(in != null) - { - try - { + } catch(WorkThread.Abort a) { + if (in != null) { + try { in.close(); } - catch(IOException io) - { - } + catch(IOException io) {} } buffer.setBooleanProperty(ERROR_OCCURRED,true); - } - finally - { - try - { + } finally { + try { vfs._endVFSSession(session,view); - } - catch(IOException io) - { + } catch(IOException io) { Log.log(Log.ERROR,this,io); String[] pp = { io.toString() }; VFSManager.error(view,path,"ioerror.read-error",pp); buffer.setBooleanProperty(ERROR_OCCURRED,true); - } - catch(WorkThread.Abort a) - { + } catch(WorkThread.Abort a) { buffer.setBooleanProperty(ERROR_OCCURRED,true); } } Added: branches/jsxe2/src/net/sourceforge/jsxe/util/WorkRequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/util/WorkRequest.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/util/WorkRequest.java 2006-07-28 20:04:32 UTC (rev 1081) @@ -0,0 +1,77 @@ +/* +WorkRequest.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2000 Slava Pestov + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.util; + +/** + * A subclass of the Runnable interface. + * @author Slava Pestov + * @version $Id$ + * @since jsXe 0.5 pre3 + */ +public abstract class WorkRequest implements Runnable { + + /** + * Sets if the request can be aborted. + */ + public void setAbortable(boolean abortable) { + Thread thread = Thread.currentThread(); + if (thread instanceof WorkThread) { + ((WorkThread)thread).setAbortable(abortable); + } + } + + /** + * Sets the status text. + * @param status The status text + */ + public void setStatus(String status) { + Thread thread = Thread.currentThread(); + if (thread instanceof WorkThread) { + ((WorkThread)thread).setStatus(status); + } + } + + /** + * Sets the progress value. + * @param value The progress value. + */ + public void setProgressValue(int value) { + Thread thread = Thread.currentThread(); + if (thread instanceof WorkThread) { + ((WorkThread)thread).setProgressValue(value); + } + } + + /** + * Sets the maximum progress value. + * @param value The progress value. + */ + public void setProgressMaximum(int value) { + Thread thread = Thread.currentThread(); + if (thread instanceof WorkThread) { + ((WorkThread)thread).setProgressMaximum(value); + } + } +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/util/WorkRequest.java ___________________________________________________________________ Name: svn:executable + * Added: branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThread.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThread.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThread.java 2006-07-28 20:04:32 UTC (rev 1081) @@ -0,0 +1,196 @@ +/* +WorkThread.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2000 Slava Pestov + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.util; + +/** + * Services work requests in the background. + * @author Slava Pestov + * @version $Id$ + * @since jsXe 0.5 pre3 + */ +public class WorkThread extends Thread { + + public WorkThread(WorkThreadPool pool, ThreadGroup group, String name) { + super(group, name); + // so that jEdit doesn't exit with no views open automatically + //setDaemon(true); + setPriority(Thread.MIN_PRIORITY); + + this.pool = pool; + } + + /** + * Sets if the current request can be aborted. + */ + public void setAbortable(boolean abortable) { + synchronized(abortLock) { + this.abortable = abortable; + if (aborted) { + stop(new Abort()); + } + } + } + + /** + * Returns if the work thread is currently running a request. + */ + public boolean isRequestRunning() { + return requestRunning; + } + + /** + * Returns the status text. + */ + public String getStatus() { + return status; + } + + /** + * Sets the status text. + */ + public void setStatus(String status) { + this.status = status; + pool.fireProgressChanged(this); + } + + /** + * Returns the progress value. + */ + public int getProgressValue() { + return progressValue; + } + + /** + * Sets the progress value. + */ + public void setProgressValue(int progressValue) { + this.progressValue = progressValue; + pool.fireProgressChanged(this); + } + + /** + * Returns the progress maximum. + */ + public int getProgressMaximum() { + return progressMaximum; + } + + /** + * Sets the maximum progress value. + */ + public void setProgressMaximum(int progressMaximum) { + this.progressMaximum = progressMaximum; + pool.fireProgressChanged(this); + } + + /** + * Aborts the currently running request, if allowed. + */ + public void abortCurrentRequest() { + synchronized(abortLock) { + if (abortable && !aborted) { + stop(new Abort()); + } + aborted = true; + } + } + + public void run() { + Log.log(Log.DEBUG,this,"Work request thread starting [" + getName() + "]"); + + for(;;) { + doRequests(); + } + } + + // private members + private WorkThreadPool pool; + private Object abortLock = new Object(); + private boolean requestRunning; + private boolean abortable; + private boolean aborted; + private String status; + private int progressValue; + private int progressMaximum; + + private void doRequests() { + WorkThreadPool.Request request; + for(;;) { + request = pool.getNextRequest(); + if (request == null) { + break; + } else { + requestRunning = true; + pool.fireStatusChanged(this); + doRequest(request); + requestRunning = false; + } + } + + pool.fireStatusChanged(this); + + synchronized(pool.waitForAllLock) { + // notify a running waitForRequests() method + pool.waitForAllLock.notifyAll(); + } + + synchronized(pool.lock) { + // wait for more requests + try { + pool.lock.wait(); + } catch(InterruptedException ie) { + Log.log(Log.ERROR,this,ie); + } + } + } + + private void doRequest(WorkThreadPool.Request request) { + Log.log(Log.DEBUG,WorkThread.class, "Running in work thread: " + request); + + try { + request.run.run(); + } catch(Abort a) { + Log.log(Log.ERROR,WorkThread.class,"Unhandled abort"); + } catch(Throwable t) { + Log.log(Log.ERROR,WorkThread.class,"Exception " + + "in work thread:"); + Log.log(Log.ERROR,WorkThread.class,t); + } finally { + synchronized(abortLock) { + aborted = abortable = false; + } + status = null; + progressValue = progressMaximum = 0; + pool.requestDone(); + pool.fireStatusChanged(this); + } + } + + public static class Abort extends Error { + public Abort() { + super("Work request aborted"); + } + } +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThread.java ___________________________________________________________________ Name: svn:executable + * Added: branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadPool.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadPool.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadPool.java 2006-07-28 20:04:32 UTC (rev 1081) @@ -0,0 +1,473 @@ +/* +WorkThreadPool.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2000 Slava Pestov + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ +package net.sourceforge.jsxe.util; + +//{{{ Imports +import javax.swing.event.EventListenerList; +import javax.swing.SwingUtilities; +//}}} + +/** + * A pool of work threads. + * @author Slava Pestov + * @version $Id$ + * @see net.sourceforge.jsxe.util.WorkThread + * @since jsXe 0.5 pre3 + */ +public class WorkThreadPool { + + //{{{ WorkThreadPool constructor + /** + * Creates a new work thread pool with the specified number of + * work threads. + * @param name The thread name prefix + * @param count The number of work threads + */ + public WorkThreadPool(String name, int count) { + + listenerList = new EventListenerList(); + + if (count != 0) { + threadGroup = new ThreadGroup(name); + threads = new WorkThread[count]; + for (int i = 0; i < threads.length; i++) { + threads[i] = new WorkThread(this,threadGroup,name + " #" + (i+1)); + } + } else { + Log.log(Log.WARNING,this,"Async I/O disabled"); + } + } //}}} + + //{{{ start() method + /** + * Starts all the threads in this thread pool. + */ + public void start() { + /* not really needed since threads don't start until after */ + synchronized(lock) { + started = true; + + if (awtRequestCount != 0 && requestCount == 0) { + queueAWTRunner(); + } + } + + if (threads != null) { + for(int i = 0; i < threads.length; i++) { + threads[i].start(); + } + } + } //}}} + + //{{{ addWorkRequest() method + /** + * Adds a work request to the queue. + * @param run The runnable + * @param inAWT If true, will be executed in AWT thread. Otherwise, + * will be executed in work thread + */ + public void addWorkRequest(Runnable run, boolean inAWT) { + if (threads == null) { + run.run(); + return; + } + + synchronized(lock) { + //{{{ if there are no requests, execute AWT requests immediately + if (started && inAWT && requestCount == 0 && awtRequestCount == 0) { + // Log.log(Log.DEBUG,this,"AWT immediate: " + run); + + if (SwingUtilities.isEventDispatchThread()) { + run.run(); + } else { + SwingUtilities.invokeLater(run); + } + + return; + } //}}} + + Request request = new Request(run); + + + if (inAWT) { + //{{{ Add to AWT queue... + if (firstAWTRequest == null && lastAWTRequest == null) { + firstAWTRequest = lastAWTRequest = request; + } else { + lastAWTRequest.next = request; + lastAWTRequest = request; + } + + awtRequestCount++; + + // if no requests are running, requestDone() + // will not be called, so we must queue the + // AWT runner ourselves. + if (started && requestCount == 0) { + queueAWTRunner(); + } + //}}} + } else { + //{{{ Add to work thread queue... + if (firstRequest == null && lastRequest == null) { + firstRequest = lastRequest = request; + } else{ + lastRequest.next = request; + lastRequest = request; + } + + requestCount++; + //}}} + } + + lock.notifyAll(); + } + } //}}} + + //{{{ waitForRequests() method + /** + * Waits until all requests are complete. + */ + public void waitForRequests() + { + if(threads == null) + return; + + synchronized(waitForAllLock) + { + while(requestCount != 0) + { + try + { + waitForAllLock.wait(); + } + catch(InterruptedException ie) + { + Log.log(Log.ERROR,this,ie); + } + } + } + + if(SwingUtilities.isEventDispatchThread()) + { + // do any queued AWT runnables + doAWTRequests(); + } + else + { + try + { + SwingUtilities.invokeAndWait(new RunRequestsInAWTThread()); + } + catch(Exception e) + { + Log.log(Log.ERROR,this,e); + } + } + } //}}} + + //{{{ getRequestCount() method + /** + * Returns the number of pending requests. + */ + public int getRequestCount() + { + return requestCount; + } //}}} + + //{{{ getThreadCount() method + /** + * Returns the number of threads in this pool. + */ + public int getThreadCount() + { + if(threads == null) + return 0; + else + return threads.length; + } //}}} + + //{{{ getThread() method + /** + * Returns the specified thread. + * @param index The index of the thread + */ + public WorkThread getThread(int index) + { + return threads[index]; + } //}}} + + //{{{ addProgressListener() method + /** + * Adds a progress listener to this thread pool. + * @param listener The listener + */ + public void addProgressListener(WorkThreadProgressListener listener) + { + listenerList.add(WorkThreadProgressListener.class,listener); + } //}}} + + //{{{ removeProgressListener() method + /** + * Removes a progress listener from this thread pool. + * @param listener The listener + */ + public void removeProgressListener(WorkThreadProgressListener listener) + { + listenerList.remove(WorkThreadProgressListener.class,listener); + } //}}} + + //{{{ Package-private members + Object lock = new Object(); + Object waitForAllLock = new Object(); + + //{{{ fireStatusChanged() method + void fireStatusChanged(WorkThread thread) + { + final Object[] listeners = listenerList.getListenerList(); + if(listeners.length != 0) + { + int index = 0; + for(int i = 0; i < threads.length; i++) + { + if(threads[i] == thread) + { + index = i; + break; + } + } + + for(int i = listeners.length - 2; i >= 0; i--) + { + if(listeners[i] == WorkThreadProgressListener.class) + { + ((WorkThreadProgressListener)listeners[i+1]) + .statusUpdate(WorkThreadPool.this,index); + } + } + } + } //}}} + + //{{{ fireProgressChanged() method + void fireProgressChanged(WorkThread thread) + { + final Object[] listeners = listenerList.getListenerList(); + if(listeners.length != 0) + { + int index = 0; + for(int i = 0; i < threads.length; i++) + { + if(threads[i] == thread) + { + index = i; + break; + } + } + + for(int i = listeners.length - 2; i >= 0; i--) + { + if(listeners[i] == WorkThreadProgressListener.class) + { + ((WorkThreadProgressListener)listeners[i+1]) + .progressUpdate(WorkThreadPool.this,index); + } + } + } + } //}}} + + //{{{ requestDone() method + void requestDone() + { + synchronized(lock) + { + requestCount--; + + if(requestCount == 0 && firstAWTRequest != null) + queueAWTRunner(); + } + } //}}} + + //{{{ getNextRequest() method + Request getNextRequest() + { + synchronized(lock) + { + Request request = firstRequest; + if(request == null) + return null; + + firstRequest = firstRequest.next; + if(firstRequest == null) + lastRequest = null; + + if(request.alreadyRun) + throw new InternalError("AIEE!!! Request run twice!!! " + request.run); + request.alreadyRun = true; + + /* StringBuffer buf = new StringBuffer("request queue is now: "); + Request _request = request.next; + while(_request != null) + { + buf.append(_request.id); + if(_request.next != null) + buf.append(","); + _request = _request.next; + } + Log.log(Log.DEBUG,this,buf.toString()); */ + + return request; + } + } //}}} + + //}}} + + //{{{ Private members + + //{{{ Instance variables + private boolean started; + private ThreadGroup threadGroup; + private WorkThread[] threads; + + // Request queue + private Request firstRequest; + private Request lastRequest; + private int requestCount; + + // AWT thread magic + private boolean awtRunnerQueued; + private Request firstAWTRequest; + private Request lastAWTRequest; + private int awtRequestCount; + + private EventListenerList listenerList; + //}}} + + //{{{ doAWTRequests() method + /** Must always be called with the lock held. */ + private void doAWTRequests() + { + while(requestCount == 0 && firstAWTRequest != null) + { + doAWTRequest(getNextAWTRequest()); + } + } //}}} + + //{{{ doAWTRequest() method + /** Must always be called with the lock held. */ + private void doAWTRequest(Request request) + { +// Log.log(Log.DEBUG,this,"Running in AWT thread: " + request); + + try + { + request.run.run(); + } + catch(Throwable t) + { + Log.log(Log.ERROR,WorkThread.class,"Exception " + + "in AWT thread:"); + Log.log(Log.ERROR,WorkThread.class,t); + } + + awtRequestCount--; + } //}}} + + //{{{ queueAWTRunner() method + /** Must always be called with the lock held. */ + private void queueAWTRunner() + { + if(!awtRunnerQueued) + { + awtRunnerQueued = true; + SwingUtilities.invokeLater(new RunRequestsInAWTThread()); +// Log.log(Log.DEBUG,this,"AWT runner queued"); + } + } //}}} + + //{{{ getNextAWTRequest() method + private Request getNextAWTRequest() + { + Request request = firstAWTRequest; + firstAWTRequest = firstAWTRequest.next; + if(firstAWTRequest == null) + lastAWTRequest = null; + + if(request.alreadyRun) + throw new InternalError("AIEE!!! Request run twice!!! " + request.run); + request.alreadyRun = true; + + /* StringBuffer buf = new StringBuffer("AWT request queue is now: "); + Request _request = request.next; + while(_request != null) + { + buf.append(_request.id); + if(_request.next != null) + buf.append(","); + _request = _request.next; + } + Log.log(Log.DEBUG,this,buf.toString()); */ + + return request; + } //}}} + + //}}} + + static int ID; + + //{{{ Request class + static class Request + { + int id = ++ID; + + Runnable run; + + boolean alreadyRun; + + Request next; + + Request(Runnable run) + { + this.run = run; + } + + public String toString() + { + return "[id=" + id + ",run=" + run + "]"; + } + } //}}} + + //{{{ RunRequestsInAWTThread class + class RunRequestsInAWTThread implements Runnable + { + public void run() + { + synchronized(lock) + { + awtRunnerQueued = false; + if(requestCount == 0) + doAWTRequests(); + } + } + } //}}} +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadPool.java ___________________________________________________________________ Name: svn:executable + * Added: branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadProgressListener.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadProgressListener.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadProgressListener.java 2006-07-28 20:04:32 UTC (rev 1081) @@ -0,0 +1,40 @@ +/* +WorkThreadProgressListener.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2000 Slava Pestov + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.util; + +import java.util.EventListener; + +/** + * A work thread execution progress listener. + * @since jEdit 2.6pre1 + */ +public interface WorkThreadProgressListener extends EventListener { + + // status message changed, operation started, operation ends, ... + void statusUpdate(WorkThreadPool threadPool, int threadIndex); + + // progress bar value change + void progressUpdate(WorkThreadPool threadPool, int threadIndex); +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/util/WorkThreadProgressListener.java ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-28 20:03:54
|
Revision: 1080 Author: ian_lewis Date: 2006-07-28 13:03:36 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1080&view=rev Log Message: ----------- fixed reference to lib.dir to be jsxe.lib.dir Modified Paths: -------------- branches/treeview2/build.xml Modified: branches/treeview2/build.xml =================================================================== --- branches/treeview2/build.xml 2006-07-27 18:59:59 UTC (rev 1079) +++ branches/treeview2/build.xml 2006-07-28 20:03:36 UTC (rev 1080) @@ -26,6 +26,7 @@ <property name="build.help" value="${build.docs}/help"/> <property name="jsxe.dir" value="${root.dir}/../.."/> <property name="jsxe.jar" value="${jsxe.dir}/jsXe.jar"/> + <property name="jsxe.lib.dir" value="${jsxe.dir}/lib"/> <property name="javac.debug" value="on"/> <property name="javac.optimize" value="off"/> <property name="javac.deprecation" value="on"/> @@ -39,14 +40,18 @@ <property name="app.version" value="${major.version}.${minor.version}.${build.version}"/> <property name="app_version" value="${major.version}_${minor.version}_${build.version}"/> <property name="implementation.version" value="${major.version}.${minor.version}.${build.version}"/> - <property name="distbin.dir" value="${build.dir}/${app.name}-${app_version}-bin"/> + <property name="distbin.dir" value="${build.dir}/${app.name}-${app_version}-bin"/> <property name="distsrc.dir" value="${build.dir}/${app.name}-${app_version}-src"/> - <path id="classpath"> + + <path id="classpath"> <pathelement location="${root.dir}"/> <pathelement location="${build.dest}"/> <pathelement location="${build.src}"/> <pathelement location="${src.dir}"/> <pathelement location="${jsxe.jar}"/> + <fileset dir="${jsxe.lib.dir}"> + <include name="**/*.jar"/> + </fileset> </path> <echo message="${readable.name} ${app.version}"/> <echo message="----------------------------------------------------------"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-28 19:35:19
|
Revision: 1069 Author: ian_lewis Date: 2006-07-26 10:07:14 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1069&view=rev Log Message: ----------- Version bump Modified Paths: -------------- trunk/jsxe/build.xml Modified: trunk/jsxe/build.xml =================================================================== --- trunk/jsxe/build.xml 2006-07-26 16:57:45 UTC (rev 1068) +++ trunk/jsxe/build.xml 2006-07-26 17:07:14 UTC (rev 1069) @@ -52,8 +52,12 @@ <property name="main.class" value="net.sourceforge.jsxe.jsXe"/> <property name="major.version" value="0"/> <property name="minor.version" value="5"/> - <property name="beta.version" value="2"/> + <property name="beta.version" value="3"/> <property name="bugfix.version" value="0"/> + <!-- Human Readable --> + <property name="app.version" value="0.5 pre3"/> + <!-- Used in filenames --> + <property name="app_version" value="05_pre3"/> <property name="buildlib.dir" value="${root.dir}/buildlib"/> <property name="jsmooth.project" value="${root.dir}/jsXe.jsmooth"/> @@ -66,10 +70,6 @@ </and> </condition> - <!-- Human Readable --> - <property name="app.version" value="0.5 pre2"/> - <!-- Used in filenames --> - <property name="app_version" value="05_pre2"/> <!--<property name="app.version" value="${major.version}.${minor.version} beta"/>--> <!--<property name="app_version" value="${major.version}_${minor.version}beta"/>--> <property name="distbin.dir" value="${build.dir}/${app.name}-${app_version}-bin"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-27 21:12:47
|
Revision: 1068 Author: ian_lewis Date: 2006-07-26 09:57:45 -0700 (Wed, 26 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1068&view=rev Log Message: ----------- Added support for the findnext action Modified Paths: -------------- trunk/sourceview/Changelog trunk/sourceview/messages/messages trunk/sourceview/src/sourceview/SourceView.java trunk/sourceview/src/sourceview/SourceViewPlugin.java trunk/sourceview/src/sourceview/SourceViewSearchDialog.java Modified: trunk/sourceview/Changelog =================================================================== --- trunk/sourceview/Changelog 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/Changelog 2006-07-26 16:57:45 UTC (rev 1068) @@ -1,3 +1,7 @@ +07/26/2006 Ian Lewis <Ian...@me...> + + * Addded support for the findnext action + 07/21/2006 Ian Lewis <Ian...@me...> * Added better horizontal scrolling support. It isn't perfect because Modified: trunk/sourceview/messages/messages =================================================================== --- trunk/sourceview/messages/messages 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/messages/messages 2006-07-26 16:57:45 UTC (rev 1068) @@ -20,3 +20,14 @@ SourceView.StyleEditor.Bold=Bold SourceView.StyleEditor.Italics=Italics #}}} + +#{{{ Find Dialog +SourceView.Find.title and Replace +SourceView.Ignore.Case=Ignore Case +SourceView.Search.For=Search for: +SourceView.Replace.With=Replace With: +SourceView.Replace.And.Find=Replace&Find +SourceView.No.More.Matches.title=No More Matches +SourceView.No.More.Matches.message="No more matches were found. Continue search from the beginning?" +SourceView.Search.Error.title=Search Error +#}}} \ No newline at end of file Modified: trunk/sourceview/src/sourceview/SourceView.java =================================================================== --- trunk/sourceview/src/sourceview/SourceView.java 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/src/sourceview/SourceView.java 2006-07-26 16:57:45 UTC (rev 1068) @@ -85,7 +85,6 @@ //{{{ Public static members public static final String SOFT_TABS = SourceViewPlugin.PLUGIN_NAME+".soft.tabs"; - public static final String LAST_FIND_STRING = SourceViewPlugin.PLUGIN_NAME+".last.find.string"; public static final String END_OF_LINE_MARKS = SourceViewPlugin.PLUGIN_NAME+".end-of-line-markers"; //}}} Modified: trunk/sourceview/src/sourceview/SourceViewPlugin.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/src/sourceview/SourceViewPlugin.java 2006-07-26 16:57:45 UTC (rev 1068) @@ -64,6 +64,7 @@ addAction(new EditCopyAction()); addAction(new EditPasteAction()); addAction(new EditFindAction()); + addAction(new EditFindNextAction()); }//}}} //{{{ newDocumentView() Modified: trunk/sourceview/src/sourceview/SourceViewSearchDialog.java =================================================================== --- trunk/sourceview/src/sourceview/SourceViewSearchDialog.java 2006-07-26 16:56:28 UTC (rev 1067) +++ trunk/sourceview/src/sourceview/SourceViewSearchDialog.java 2006-07-26 16:57:45 UTC (rev 1068) @@ -70,13 +70,19 @@ //}}} +/** + * The Find dialog for the source view. This allows users to search + * for strings in the document and possibly replace the strings with + * another. + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + */ public class SourceViewSearchDialog extends EnhancedDialog { //{{{ Private static members private static int m_dialogHeight = 200; private static int m_dialogWidth = 350; private static SourceViewSearchDialog m_dialog = null; - private static final String IGNORE_CASE = "source.ignore.case"; //}}} //{{{ Public static members @@ -108,15 +114,15 @@ //{{{ SourceViewSearchDialog constructor public SourceViewSearchDialog(Frame parentFrame, SourceView view) { - super(parentFrame, "Search and Replace", false); + super(parentFrame, Messages.getMessage("SourceView.Search.And.Replace"), false); m_view = view; JPanel frame = new JPanel(); getContentPane().add(frame,BorderLayout.CENTER); - JButton findButton = new JButton("Find"); - JButton replaceButton = new JButton("Replace&Find"); + JButton findButton = new JButton(Messages.getMessage("common.find")); + JButton replaceButton = new JButton(Messages.getMessage("SourceView.Replace.And.Find")); // JButton replaceAllButton = new JButton("Replace All"); JButton cancelButton = new JButton(Messages.getMessage("common.cancel")); @@ -140,7 +146,9 @@ m_findComboBox.setName("FindComboBox"); m_findComboBox.setEditable(true); - String last = jsXe.getProperty("SourceView.Search.Last"); + DocumentBuffer buffer = m_view.getDocumentBuffer(); + + String last = buffer.getProperty(SourceViewSearch.LAST_FIND_STRING); if (last != null) { m_findComboBox.setSelectedItem(last); m_findComboBox.getEditor().selectAll(); @@ -150,9 +158,8 @@ m_replaceComboBox.setName("ReplaceComboBox"); m_replaceComboBox.setEditable(true); - DocumentBuffer buffer = m_view.getDocumentBuffer(); - boolean ignoreCase = Boolean.valueOf(jsXe.getProperty(IGNORE_CASE)).booleanValue(); - m_ignoreCaseCheckBox = new JCheckBox("Ignore Case", ignoreCase); + boolean ignoreCase = Boolean.valueOf(jsXe.getProperty(SourceViewSearch.IGNORE_CASE)).booleanValue(); + m_ignoreCaseCheckBox = new JCheckBox(Messages.getMessage("SourceView.Ignore.Case"), ignoreCase); constraints.gridy = 0; constraints.gridx = 0; @@ -164,7 +171,7 @@ constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(1,0,1,0); - JLabel searchLabel = new JLabel("Search for:"); + JLabel searchLabel = new JLabel(Messages.getMessage("SourceView.Search.For")); layout.setConstraints(searchLabel, constraints); frame.add(searchLabel); @@ -191,7 +198,7 @@ constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(1,0,1,0); - JLabel replaceLabel = new JLabel("Replace With:"); + JLabel replaceLabel = new JLabel(Messages.getMessage("SourceView.Replace.With")); layout.setConstraints(replaceLabel, constraints); frame.add(replaceLabel); @@ -247,7 +254,6 @@ //{{{ cancel() public void cancel() { - jsXe.setProperty(IGNORE_CASE, String.valueOf(m_ignoreCaseCheckBox.isSelected())); dispose(); }//}}} @@ -292,68 +298,28 @@ //{{{ find() private void find(boolean doReplace) { - find(doReplace, m_view.getTextArea().getCaretPosition()); - }//}}} - - //{{{ find() - - private void find(boolean doReplace, int startIndex) { - try { - Object searchItem = m_findComboBox.getSelectedItem(); - Object replaceItem = m_replaceComboBox.getSelectedItem(); - boolean ignoreCase = m_ignoreCaseCheckBox.isSelected(); - - String search = ""; - if (searchItem != null) { - search = searchItem.toString(); - } - - String replace = ""; - if (replaceItem != null) { - replace = replaceItem.toString(); - } - - RESearchMatcher matcher = new RESearchMatcher(search, replace, ignoreCase); - - JEditTextArea textArea = m_view.getTextArea(); - - //replace previous text - if (doReplace) { - String selText = textArea.getSelectedText(); - if (selText != null && !selText.equals("")) { - String replaceString = matcher.substitute(selText); - textArea.setSelectedText(replaceString); - } - } - - DocumentBuffer buffer = m_view.getDocumentBuffer(); - Segment seg = buffer.getSegment(0, buffer.getLength()); - int caretPosition = startIndex; - CharIndexedSegment charSeg = new CharIndexedSegment(seg, caretPosition); - - int[] match = matcher.nextMatch(charSeg, false, true, true, false); - - buffer.setProperty(SourceView.LAST_FIND_STRING, search); - - if (match != null) { - Log.log(Log.DEBUG, this, match[0] + " "+ match[1]); - int start = match[0]+caretPosition; - int end = match[1]+caretPosition; - // textArea.requestFocus(); - textArea.select(start, end); - } else { - int again = JOptionPane.showConfirmDialog(m_view, "No more matches were found. Continue search from the beginning?", "No More Matches Found", JOptionPane.YES_NO_OPTION); - if (again == 0) { - find(doReplace, 0); - } - } - - requestFocus(); - jsXe.setProperty("SourceView.Search.Last", search); - } catch (Exception ex) { - ex.printStackTrace(); - JOptionPane.showMessageDialog(m_view, ex, "Search Error", JOptionPane.WARNING_MESSAGE); + Object searchItem = m_findComboBox.getSelectedItem(); + Object replaceItem = m_replaceComboBox.getSelectedItem(); + boolean ignoreCase = m_ignoreCaseCheckBox.isSelected(); + + String search = ""; + if (searchItem != null) { + search = searchItem.toString(); } + + String replace = ""; + if (replaceItem != null) { + replace = replaceItem.toString(); + } + + SourceViewSearch searcher = new SourceViewSearch(m_view); + if (doReplace) { + searcher.replaceAndFind(search, replace, ignoreCase); + } else { + searcher.find(search, ignoreCase); + } + + requestFocus(); }//}}} private SourceView m_view; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-27 19:00:15
|
Revision: 1079 Author: ian_lewis Date: 2006-07-27 11:59:59 -0700 (Thu, 27 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1079&view=rev Log Message: ----------- Added classes for IO. Though they are ignored by the build atm Modified Paths: -------------- branches/jsxe2/build.xml Added Paths: ----------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java branches/jsxe2/src/net/sourceforge/jsxe/io/ branches/jsxe2/src/net/sourceforge/jsxe/io/FileRootsVFS.java branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java branches/jsxe2/src/net/sourceforge/jsxe/io/UrlVFS.java branches/jsxe2/src/net/sourceforge/jsxe/io/VFS.java branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java branches/jsxe2/src/net/sourceforge/jsxe/io/package.html Modified: branches/jsxe2/build.xml =================================================================== --- branches/jsxe2/build.xml 2006-07-27 18:02:07 UTC (rev 1078) +++ branches/jsxe2/build.xml 2006-07-27 18:59:59 UTC (rev 1079) @@ -118,6 +118,10 @@ <!--<include name="**/*.dtd"/>--> <include name="**/*.jpg"/> <include name="**/*.png"/> + + <!-- files in the source directory to ignore --> + <exclude name="net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java"/> + <exclude name="net/sourceforge/jsxe/io/**/*"/> </fileset> </copy> <mkdir dir="${build.messages}"/> Added: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-07-27 18:59:59 UTC (rev 1079) @@ -0,0 +1,1036 @@ +/* +XMLDocumentIORequest.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2000, 2003 Slava Pestov +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package org.gjt.sp.jedit.buffer; + +//{{{ Imports +import javax.swing.text.Segment; +import java.io.*; +import java.util.zip.*; +import java.util.Vector; +import org.gjt.sp.jedit.io.*; +import org.gjt.sp.jedit.*; +import org.gjt.sp.util.*; +//}}} + +/** + * A document I/O request. + * @author Slava Pestov + * @version $Id: BufferIORequest.java,v 1.28 2004/08/29 02:58:43 spestov Exp $ + */ +public class XMLDocumentIORequest extends WorkRequest { + + //{{{ Constants + /** + * Size of I/O buffers. + */ + public static final int IOBUFSIZE = 32768; + + /** + * Number of lines per progress increment. + */ + public static final int PROGRESS_INTERVAL = 300; + + public static final String LOAD_DATA = "BufferIORequest__loadData"; + public static final String END_OFFSETS = "BufferIORequest__endOffsets"; + public static final String NEW_PATH = "BufferIORequest__newPath"; + + /** + * Buffer boolean property set when an error occurs. + */ + public static final String ERROR_OCCURRED = "BufferIORequest__error"; + + /** + * A file load request. + */ + public static final int LOAD = 0; + + /** + * A file save request. + */ + public static final int SAVE = 1; + + /** + * An autosave request. Only supported for local files. + */ + public static final int AUTOSAVE = 2; + + /** + * An insert file request. + */ + public static final int INSERT = 3; + + /** + * Magic numbers used for auto-detecting Unicode and GZIP files. + */ + public static final int GZIP_MAGIC_1 = 0x1f; + public static final int GZIP_MAGIC_2 = 0x8b; + public static final int UNICODE_MAGIC_1 = 0xfe; + public static final int UNICODE_MAGIC_2 = 0xff; + public static final int UTF8_MAGIC_1 = 0xef; + public static final int UTF8_MAGIC_2 = 0xbb; + public static final int UTF8_MAGIC_3 = 0xbf; + + /** + * Length of longest XML PI used for encoding detection.<p> + * <?xml version="1.0" encoding="................"?> + */ + public static final int XML_PI_LENGTH = 50; + //}}} + + //{{{ XMLDocumentIORequest constructor + /** + * Creates a new buffer I/O request. + * @param type The request type + * @param view The view + * @param buffer The buffer + * @param session The VFS session + * @param vfs The VFS + * @param path The path + */ + public XMLDocumentIORequest(int type, View view, Buffer buffer, + Object session, VFS vfs, String path) + { + this.type = type; + this.view = view; + this.buffer = buffer; + this.session = session; + this.vfs = vfs; + this.path = path; + + markersPath = vfs.getParentOfPath(path) + + '.' + vfs.getFileName(path) + + ".marks"; + } //}}} + + //{{{ run() method + public void run() + { + switch(type) + { + case LOAD: + load(); + break; + case SAVE: + save(); + break; + case AUTOSAVE: + autosave(); + break; + case INSERT: + insert(); + break; + default: + throw new InternalError(); + } + } //}}} + + //{{{ toString() method + public String toString() + { + String typeString; + switch(type) + { + case LOAD: + typeString = "LOAD"; + break; + case SAVE: + typeString = "SAVE"; + break; + case AUTOSAVE: + typeString = "AUTOSAVE"; + break; + default: + typeString = "UNKNOWN!!!"; + } + + return getClass().getName() + "[type=" + typeString + + ",buffer=" + buffer + "]"; + } //}}} + + //{{{ Private members + + //{{{ Instance variables + private int type; + private View view; + private Buffer buffer; + private Object session; + private VFS vfs; + private String path; + private String markersPath; + //}}} + + //{{{ load() method + private void load() + { + InputStream in = null; + + try + { + try + { + String[] args = { vfs.getFileName(path) }; + setAbortable(true); + if(!buffer.isTemporary()) + { + setStatus(jEdit.getProperty("vfs.status.load",args)); + setProgressValue(0); + } + + path = vfs._canonPath(session,path,view); + + VFS.DirectoryEntry entry = vfs._getDirectoryEntry( + session,path,view); + long length; + if(entry != null) + length = entry.length; + else + length = 0L; + + in = vfs._createInputStream(session,path, + false,view); + if(in == null) + return; + + read(autodetect(in),length,false); + buffer.setNewFile(false); + } + catch(CharConversionException ch) + { + Log.log(Log.ERROR,this,ch); + Object[] pp = { buffer.getProperty(Buffer.ENCODING), + ch.toString() }; + VFSManager.error(view,path,"ioerror.encoding-error",pp); + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + catch(UnsupportedEncodingException uu) + { + Log.log(Log.ERROR,this,uu); + Object[] pp = { buffer.getProperty(Buffer.ENCODING), + uu.toString() }; + VFSManager.error(view,path,"ioerror.encoding-error",pp); + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + catch(IOException io) + { + Log.log(Log.ERROR,this,io); + Object[] pp = { io.toString() }; + VFSManager.error(view,path,"ioerror.read-error",pp); + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + catch(OutOfMemoryError oom) + { + Log.log(Log.ERROR,this,oom); + VFSManager.error(view,path,"out-of-memory-error",null); + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + + if(jEdit.getBooleanProperty("persistentMarkers")) + { + try + { + String[] args = { vfs.getFileName(path) }; + if(!buffer.isTemporary()) + setStatus(jEdit.getProperty("vfs.status.load-markers",args)); + setAbortable(true); + + in = vfs._createInputStream(session,markersPath,true,view); + if(in != null) + readMarkers(buffer,in); + } + catch(IOException io) + { + // ignore + } + } + } + catch(WorkThread.Abort a) + { + if(in != null) + { + try + { + in.close(); + } + catch(IOException io) + { + } + } + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + finally + { + try + { + vfs._endVFSSession(session,view); + } + catch(IOException io) + { + Log.log(Log.ERROR,this,io); + String[] pp = { io.toString() }; + VFSManager.error(view,path,"ioerror.read-error",pp); + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + catch(WorkThread.Abort a) + { + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + } + } //}}} + + //{{{ autodetect() method + /** + * Tries to detect if the stream is gzipped, and if it has an encoding + * specified with an XML PI. + */ + private Reader autodetect(InputStream in) throws IOException + { + in = new BufferedInputStream(in); + + String encoding = buffer.getStringProperty(Buffer.ENCODING); + if(!in.markSupported()) + Log.log(Log.WARNING,this,"Mark not supported: " + in); + else if(buffer.getBooleanProperty(Buffer.ENCODING_AUTODETECT)) + { + in.mark(XML_PI_LENGTH); + int b1 = in.read(); + int b2 = in.read(); + int b3 = in.read(); + + if(encoding.equals(MiscUtilities.UTF_8_Y)) + { + // Java does not support this encoding so + // we have to handle it manually. + if(b1 != UTF8_MAGIC_1 || b2 != UTF8_MAGIC_2 + || b3 != UTF8_MAGIC_3) + { + // file does not begin with UTF-8-Y + // signature. reset stream, read as + // UTF-8. + in.reset(); + } + else + { + // file begins with UTF-8-Y signature. + // discard the signature, and read + // the remainder as UTF-8. + } + + encoding = "UTF-8"; + } + else if(b1 == GZIP_MAGIC_1 && b2 == GZIP_MAGIC_2) + { + in.reset(); + in = new GZIPInputStream(in); + buffer.setBooleanProperty(Buffer.GZIPPED,true); + // auto-detect encoding within the gzip stream. + return autodetect(in); + } + else if((b1 == UNICODE_MAGIC_1 + && b2 == UNICODE_MAGIC_2) + || (b1 == UNICODE_MAGIC_2 + && b2 == UNICODE_MAGIC_1)) + { + in.reset(); + encoding = "UTF-16"; + buffer.setProperty(Buffer.ENCODING,encoding); + } + else if(b1 == UTF8_MAGIC_1 && b2 == UTF8_MAGIC_2 + && b3 == UTF8_MAGIC_3) + { + // do not reset the stream and just treat it + // like a normal UTF-8 file. + buffer.setProperty(Buffer.ENCODING, + MiscUtilities.UTF_8_Y); + + encoding = "UTF-8"; + } + else + { + in.reset(); + + byte[] _xmlPI = new byte[XML_PI_LENGTH]; + int offset = 0; + int count; + while((count = in.read(_xmlPI,offset, + XML_PI_LENGTH - offset)) != -1) + { + offset += count; + if(offset == XML_PI_LENGTH) + break; + } + + String xmlPI = new String(_xmlPI,0,offset, + "ASCII"); + if(xmlPI.startsWith("<?xml")) + { + int index = xmlPI.indexOf("encoding="); + if(index != -1 + && index + 9 != xmlPI.length()) + { + char ch = xmlPI.charAt(index + + 9); + int endIndex = xmlPI.indexOf(ch, + index + 10); + encoding = xmlPI.substring( + index + 10,endIndex); + + if(MiscUtilities.isSupportedEncoding(encoding)) + { + buffer.setProperty(Buffer.ENCODING,encoding); + } + else + { + Log.log(Log.WARNING,this,"XML PI specifies unsupported encoding: " + encoding); + } + } + } + + in.reset(); + } + } + + return new InputStreamReader(in,encoding); + } //}}} + + //{{{ read() method + private SegmentBuffer read(Reader in, long length, + boolean insert) throws IOException + { + /* we guess an initial size for the array */ + IntegerArray endOffsets = new IntegerArray( + Math.max(1,(int)(length / 50))); + + // only true if the file size is known + boolean trackProgress = (!buffer.isTemporary() && length != 0); + + if(trackProgress) + { + setProgressValue(0); + setProgressMaximum((int)length); + } + + // if the file size is not known, start with a resonable + // default buffer size + if(length == 0) + length = IOBUFSIZE; + + SegmentBuffer seg = new SegmentBuffer((int)length + 1); + + char[] buf = new char[IOBUFSIZE]; + + // Number of characters in 'buf' array. + // InputStream.read() doesn't always fill the + // array (eg, the file size is not a multiple of + // IOBUFSIZE, or it is a GZipped file, etc) + int len; + + // True if a \n was read after a \r. Usually + // means this is a DOS/Windows file + boolean CRLF = false; + + // A \r was read, hence a MacOS file + boolean CROnly = false; + + // Was the previous read character a \r? + // If we read a \n and this is true, we assume + // we have a DOS/Windows file + boolean lastWasCR = false; + + // Number of lines read. Every 100 lines, we update the + // progress bar + int lineCount = 0; + + while((len = in.read(buf,0,buf.length)) != -1) + { + // Offset of previous line, relative to + // the start of the I/O buffer (NOT + // relative to the start of the document) + int lastLine = 0; + + for(int i = 0; i < len; i++) + { + // Look for line endings. + switch(buf[i]) + { + case '\r': + // If we read a \r and + // lastWasCR is also true, + // it is probably a Mac file + // (\r\r in stream) + if(lastWasCR) + { + CROnly = true; + CRLF = false; + } + // Otherwise set a flag, + // so that \n knows that last + // was a \r + else + { + lastWasCR = true; + } + + // Insert a line + seg.append(buf,lastLine,i - + lastLine); + seg.append('\n'); + endOffsets.add(seg.count); + if(trackProgress && lineCount++ % PROGRESS_INTERVAL == 0) + setProgressValue(seg.count); + + // This is i+1 to take the + // trailing \n into account + lastLine = i + 1; + break; + case '\n': + // If lastWasCR is true, + // we just read a \r followed + // by a \n. We specify that + // this is a Windows file, + // but take no further + // action and just ignore + // the \r. + if(lastWasCR) + { + CROnly = false; + CRLF = true; + lastWasCR = false; + // Bump lastLine so + // that the next line + // doesn't erronously + // pick up the \r + lastLine = i + 1; + } + // Otherwise, we found a \n + // that follows some other + // character, hence we have + // a Unix file + else + { + CROnly = false; + CRLF = false; + seg.append(buf,lastLine, + i - lastLine); + seg.append('\n'); + endOffsets.add(seg.count); + if(trackProgress && lineCount++ % PROGRESS_INTERVAL == 0) + setProgressValue(seg.count); + lastLine = i + 1; + } + break; + default: + // If we find some other + // character that follows + // a \r, so it is not a + // Windows file, and probably + // a Mac file + if(lastWasCR) + { + CROnly = true; + CRLF = false; + lastWasCR = false; + } + break; + } + } + + if(trackProgress) + setProgressValue(seg.count); + + // Add remaining stuff from buffer + seg.append(buf,lastLine,len - lastLine); + } + + setAbortable(false); + + String lineSeparator; + if(seg.count == 0) + { + // fix for "[ 865589 ] 0-byte files should open using + // the default line seperator" + lineSeparator = jEdit.getProperty( + "buffer.lineSeparator", + System.getProperty("line.separator")); + } + else if(CRLF) + lineSeparator = "\r\n"; + else if(CROnly) + lineSeparator = "\r"; + else + lineSeparator = "\n"; + + in.close(); + + // Chop trailing newline and/or ^Z (if any) + int bufferLength = seg.count; + if(bufferLength != 0) + { + char ch = seg.array[bufferLength - 1]; + if(ch == 0x1a /* DOS ^Z */) + seg.count--; + } + + buffer.setBooleanProperty(Buffer.TRAILING_EOL,false); + if(bufferLength != 0 && jEdit.getBooleanProperty("stripTrailingEOL")) + { + char ch = seg.array[bufferLength - 1]; + if(ch == '\n') + { + buffer.setBooleanProperty(Buffer.TRAILING_EOL,true); + seg.count--; + endOffsets.setSize(endOffsets.getSize() - 1); + } + } + + // add a line marker at the end for proper offset manager + // operation + endOffsets.add(seg.count + 1); + + // to avoid having to deal with read/write locks and such, + // we insert the loaded data into the buffer in the + // post-load cleanup runnable, which runs in the AWT thread. + if(!insert) + { + buffer.setProperty(LOAD_DATA,seg); + buffer.setProperty(END_OFFSETS,endOffsets); + buffer.setProperty(NEW_PATH,path); + if(lineSeparator != null) + buffer.setProperty(Buffer.LINESEP,lineSeparator); + } + + // used in insert() + return seg; + } //}}} + + //{{{ readMarkers() method + private void readMarkers(Buffer buffer, InputStream _in) + throws IOException + { + // For `reload' command + buffer.removeAllMarkers(); + + BufferedReader in = new BufferedReader(new InputStreamReader(_in)); + + try + { + String line; + while((line = in.readLine()) != null) + { + // compatibility kludge for jEdit 3.1 and earlier + if(!line.startsWith("!")) + continue; + + char shortcut = line.charAt(1); + int start = line.indexOf(';'); + int end = line.indexOf(';',start + 1); + int position = Integer.parseInt(line.substring(start + 1,end)); + buffer.addMarker(shortcut,position); + } + } + finally + { + in.close(); + } + } //}}} + + //{{{ save() method + private void save() + { + OutputStream out = null; + + try + { + String[] args = { vfs.getFileName(path) }; + setStatus(jEdit.getProperty("vfs.status.save",args)); + + // the entire save operation can be aborted... + setAbortable(true); + + path = vfs._canonPath(session,path,view); if(!MiscUtilities.isURL(path)) + path = MiscUtilities.resolveSymlinks(path); + + // Only backup once per session + if(buffer.getProperty(Buffer.BACKED_UP) == null + || jEdit.getBooleanProperty("backupEverySave")) + { + vfs._backup(session,path,view); + buffer.setBooleanProperty(Buffer.BACKED_UP,true); + } + + /* if the VFS supports renaming files, we first + * save to #<filename>#save#, then rename that + * to <filename>, so that if the save fails, + * data will not be lost. + * + * as of 4.1pre7 we now call vfs.getTwoStageSaveName() + * instead of constructing the path directly + * since some VFS's might not allow # in filenames. + */ + String savePath; + + boolean twoStageSave = (vfs.getCapabilities() & VFS.RENAME_CAP) != 0 + && jEdit.getBooleanProperty("twoStageSave"); + if(twoStageSave) + savePath = vfs.getTwoStageSaveName(path); + else + savePath = path; + + out = vfs._createOutputStream(session,savePath,view); + + try + { + // this must be after the stream is created or + // we deadlock with SSHTools. + buffer.readLock(); + if(out != null) + { + // Can't use buffer.getName() here because + // it is not changed until the save is + // complete + if(savePath.endsWith(".gz")) + buffer.setBooleanProperty(Buffer.GZIPPED,true); + + if(buffer.getBooleanProperty(Buffer.GZIPPED)) + out = new GZIPOutputStream(out); + + write(buffer,out); + + if(twoStageSave) + { + if(!vfs._rename(session,savePath,path,view)) + throw new IOException("Rename failed: " + savePath); + } + + // We only save markers to VFS's that support deletion. + // Otherwise, we will accumilate stale marks files. + if((vfs.getCapabilities() & VFS.DELETE_CAP) != 0) + { + if(jEdit.getBooleanProperty("persistentMarkers") + && buffer.getMarkers().size() != 0) + { + setStatus(jEdit.getProperty("vfs.status.save-markers",args)); + setProgressValue(0); + out = vfs._createOutputStream(session,markersPath,view); + if(out != null) + writeMarkers(buffer,out); + } + else + vfs._delete(session,markersPath,view); + } + } + else + buffer.setBooleanProperty(ERROR_OCCURRED,true); + + if(!twoStageSave) + VFSManager.sendVFSUpdate(vfs,path,true); + } + finally + { + buffer.readUnlock(); + } + } + catch(IOException io) + { + Log.log(Log.ERROR,this,io); + String[] pp = { io.toString() }; + VFSManager.error(view,path,"ioerror.write-error",pp); + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + catch(WorkThread.Abort a) + { + if(out != null) + { + try + { + out.close(); + } + catch(IOException io) + { + } + } + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + finally + { + try + { + vfs._saveComplete(session,buffer,path,view); + vfs._endVFSSession(session,view); + } + catch(IOException io) + { + Log.log(Log.ERROR,this,io); + String[] pp = { io.toString() }; + VFSManager.error(view,path,"ioerror.write-error",pp); + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + catch(WorkThread.Abort a) + { + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + } + } //}}} + + //{{{ autosave() method + private void autosave() + { + OutputStream out = null; + + try + { + String[] args = { vfs.getFileName(path) }; + setStatus(jEdit.getProperty("vfs.status.autosave",args)); + + // the entire save operation can be aborted... + setAbortable(true); + + try + { + //buffer.readLock(); + + if(!buffer.isDirty()) + { + // buffer has been saved while we + // were waiting. + return; + } + + out = vfs._createOutputStream(session,path,view); + if(out == null) + return; + + write(buffer,out); + } + catch(Exception e) + { + } + finally + { + //buffer.readUnlock(); + } + } + catch(WorkThread.Abort a) + { + if(out != null) + { + try + { + out.close(); + } + catch(IOException io) + { + } + } + } + } //}}} + + //{{{ write() method + private void write(Buffer buffer, OutputStream _out) + throws IOException + { + BufferedWriter out = null; + + try + { + String encoding = buffer.getStringProperty(Buffer.ENCODING); + if(encoding.equals(MiscUtilities.UTF_8_Y)) + { + // not supported by Java... + _out.write(UTF8_MAGIC_1); + _out.write(UTF8_MAGIC_2); + _out.write(UTF8_MAGIC_3); + _out.flush(); + encoding = "UTF-8"; + } + + out = new BufferedWriter( + new OutputStreamWriter(_out,encoding), + IOBUFSIZE); + + Segment lineSegment = new Segment(); + String newline = buffer.getStringProperty(Buffer.LINESEP); + if(newline == null) + newline = System.getProperty("line.separator"); + + setProgressMaximum(buffer.getLineCount() / PROGRESS_INTERVAL); + setProgressValue(0); + + int i = 0; + while(i < buffer.getLineCount()) + { + buffer.getLineText(i,lineSegment); + out.write(lineSegment.array,lineSegment.offset, + lineSegment.count); + + if(i != buffer.getLineCount() - 1) + { + out.write(newline); + } + + if(++i % PROGRESS_INTERVAL == 0) + setProgressValue(i / PROGRESS_INTERVAL); + } + + if(jEdit.getBooleanProperty("stripTrailingEOL") + && buffer.getBooleanProperty(Buffer.TRAILING_EOL)) + { + out.write(newline); + } + } + finally + { + if(out != null) + out.close(); + else + _out.close(); + } + } //}}} + + //{{{ writeMarkers() method + private void writeMarkers(Buffer buffer, OutputStream out) + throws IOException + { + Writer o = new BufferedWriter(new OutputStreamWriter(out)); + try + { + Vector markers = buffer.getMarkers(); + for(int i = 0; i < markers.size(); i++) + { + Marker marker = (Marker)markers.elementAt(i); + o.write('!'); + o.write(marker.getShortcut()); + o.write(';'); + + String pos = String.valueOf(marker.getPosition()); + o.write(pos); + o.write(';'); + o.write(pos); + o.write('\n'); + } + } + finally + { + o.close(); + } + } //}}} + + //{{{ insert() method + private void insert() + { + InputStream in = null; + + try + { + try + { + String[] args = { vfs.getFileName(path) }; + setStatus(jEdit.getProperty("vfs.status.load",args)); + setAbortable(true); + + path = vfs._canonPath(session,path,view); + + VFS.DirectoryEntry entry = vfs._getDirectoryEntry( + session,path,view); + long length; + if(entry != null) + length = entry.length; + else + length = 0L; + + in = vfs._createInputStream(session,path,false,view); + if(in == null) + return; + + final SegmentBuffer seg = read( + autodetect(in),length,true); + + /* we don't do this in Buffer.insert() so that + we can insert multiple files at once */ + VFSManager.runInAWTThread(new Runnable() + { + public void run() + { + view.getTextArea().setSelectedText( + seg.toString()); + } + }); + } + catch(IOException io) + { + Log.log(Log.ERROR,this,io); + String[] pp = { io.toString() }; + VFSManager.error(view,path,"ioerror.read-error",pp); + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + } + catch(WorkThread.Abort a) + { + if(in != null) + { + try + { + in.close(); + } + catch(IOException io) + { + } + } + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + finally + { + try + { + vfs._endVFSSession(session,view); + } + catch(IOException io) + { + Log.log(Log.ERROR,this,io); + String[] pp = { io.toString() }; + VFSManager.error(view,path,"ioerror.read-error",pp); + + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + catch(WorkThread.Abort a) + { + buffer.setBooleanProperty(ERROR_OCCURRED,true); + } + } + } //}}} + + //}}} +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java ___________________________________________________________________ Name: svn:executable + * Added: branches/jsxe2/src/net/sourceforge/jsxe/io/FileRootsVFS.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/FileRootsVFS.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/FileRootsVFS.java 2006-07-27 18:59:59 UTC (rev 1079) @@ -0,0 +1,256 @@ +/* +FileVFS.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2000, 2003 Slava Pestov +Portions copyright (C) 2002 Kris Kopicki +Portions copyright (C) 2002 Carmine Lucarelli +Portions Copyright (C) 2004 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package org.gjt.sp.jedit.io; + +//{{{ Imports +import javax.swing.filechooser.FileSystemView; +import java.awt.Component; +import java.lang.reflect.*; +import java.io.File; +import java.util.LinkedList; +import net.sourceforge.jsxe.util.MiscUtilities; +import net.sourceforge.jsxe.OperatingSystem; +import net.sourceforge.jsxe.util.Log; +//}}} + +/** + * A VFS that lists local root filesystems. + * @author Slava Pestov + * @author Kris Kopicki + * @author Carmine Lucarelli + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @since jsXe 0.5 pre3 + */ +public class FileRootsVFS extends VFS { + + public static final String PROTOCOL = "roots"; + + //{{{ FileRootsVFS constructor + public FileRootsVFS() { + + super("roots",LOW_LATENCY_CAP,new String[] { + EA_TYPE }); + + try { + getSystemDisplayName = FileSystemView.class.getMethod("getSystemDisplayName", + new Class[] { java.io.File.class }); + getRoots = FileSystemView.class.getMethod("getRoots", + new Class[0]); + isFileSystemRoot = FileSystemView.class.getMethod("isFileSystemRoot", + new Class[] { java.io.File.class }); + isFloppyDrive = FileSystemView.class.getMethod("isFloppyDrive", + new Class[] { java.io.File.class }); + isDrive = FileSystemView.class.getMethod("isDrive", + new Class[] { java.io.File.class }); + fsView = FileSystemView.getFileSystemView(); + Log.log(Log.DEBUG,this,"Java 1.4 FileSystemView detected"); + } + catch(Exception e) + { + Log.log(Log.DEBUG,this,"Java 1.4 FileSystemView not detected"); + } + } //}}} + + //{{{ getParentOfPath() method + public String getParentOfPath(String path) { + return PROTOCOL + ":"; + } //}}} + + //{{{ _listDirectory() method + public VFS.DirectoryEntry[] _listDirectory(Object session, String url, + Component comp) + { + File[] roots = listRoots(); + + if (roots == null) { + return null; + } + + VFS.DirectoryEntry[] rootDE = new VFS.DirectoryEntry[roots.length]; + for (int i = 0; i < roots.length; i++) { + rootDE[i] = new RootsEntry(roots[i]); + } + + return rootDE; + } //}}} + + //{{{ _getDirectoryEntry() method + public DirectoryEntry _getDirectoryEntry(Object session, String path, + Component comp) + { + return new RootsEntry(new File(path)); + } //}}} + + //{{{ Private members + private static FileSystemView fsView; + private static Method getSystemDisplayName; + private static Method getRoots; + private static Method isFileSystemRoot; + private static Method isFloppyDrive; + private static Method isDrive; + + //{{{ listRoots() method + private static File[] listRoots() { + + if (OperatingSystem.isMacOS()) { + // Nasty hardcoded values + File[] volumes = new File("/Volumes").listFiles(); + LinkedList roots = new LinkedList(); + + roots.add(new File("/")); + + for (int i=0; i<volumes.length; i++) { + // Make sure people don't do stupid things like putting files in /Volumes + if (volumes[i].isDirectory()) + roots.add(volumes[i]); + } + + return (File[])roots.toArray(new File[0]); + } else { + File[] roots = File.listRoots(); + File[] desktop = null; + + if (getRoots != null) { + try { + desktop = (File[])getRoots.invoke(fsView, + new Object[0]); + } catch(Exception e) { + Log.log(Log.ERROR, FileRootsVFS.class, "Error getting Desktop: " + e.getMessage()); + desktop = null; + } + } + + if (desktop == null) { + return roots; + } + + File[] rootsPlus = new File[roots.length + desktop.length]; + System.arraycopy(desktop, 0, rootsPlus, 0, desktop.length); + System.arraycopy(roots, 0, rootsPlus, 1, roots.length); + return rootsPlus; + } + } //}}} + + //}}} + + //{{{ RootsEntry class + static class RootsEntry extends VFS.DirectoryEntry { + + RootsEntry(File file) { + // REMIND: calling isDirectory() on a floppy drive + // displays stupid I/O error dialog box on Windows + + this.path = this.deletePath = this.symlinkPath = file.getPath(); + + if (isFloppy(file)) { + type = VFS.DirectoryEntry.FILESYSTEM; + name = path; + } else { + if(isDrive(file)) { + + type = VFS.DirectoryEntry.FILESYSTEM; + + if (getSystemDisplayName != null) { + try { + name = path + " " + (String)getSystemDisplayName + .invoke(fsView,new Object[] { file }); + } catch(Exception e) { + Log.log(Log.ERROR,this,e); + name = path; + } + } + } else { + if (file.isDirectory()) { + + type = VFS.DirectoryEntry.FILESYSTEM; + + if (isFileSystemRoot != null) { + try { + if (Boolean.FALSE.equals(isFileSystemRoot + .invoke(fsView,new Object[] { file }))) + { + type = VFS.DirectoryEntry.DIRECTORY; + } + } + catch(Exception e) {} + } + + if (OperatingSystem.isMacOS()) { + name = MiscUtilities.getFileName(path); + } else { + name = path; + } + } else { + type = VFS.DirectoryEntry.FILE; + } + } + } + } + + public String getExtendedAttribute(String name) { + if (name.equals(EA_TYPE)) { + return super.getExtendedAttribute(name); + } else { + // don't want it to show "0 bytes" for size, + // etc. + return null; + } + } + + private boolean isFloppy(File file) { + // to prevent windows looking for a disk in the floppy drive + if (isFloppyDrive != null) { + try { + return Boolean.TRUE.equals(isFloppyDrive. + invoke(fsView, new Object[] { file })); + } catch(Exception e) { + Log.log(Log.ERROR,this,e); + return false; + } + } else { + return path.startsWith("A:") || path.startsWith("B:"); + } + } + + private boolean isDrive(File file) { + // so an empty cd drive is not reported as a file + if (isDrive != null) { + try { + return Boolean.TRUE.equals(isDrive. + invoke(fsView, new Object[] { file })); + } catch(Exception e) { + Log.log(Log.ERROR,this,e); + return false; + } + } else { + return true; + } + } + } //}}} +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/io/FileRootsVFS.java ___________________________________________________________________ Name: svn:executable + * Added: branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java 2006-07-27 18:59:59 UTC (rev 1079) @@ -0,0 +1,483 @@ +/* +FileVFS.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 1998, 1999, 2000, 2001, 2002 Slava Pestov +Portions Copyright (C) 2004 Ian Lewis (Ian...@me...) + +This program 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 +of the License, or (at your option) any later version. + +This program 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 this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.io; + +//{{{ Imports +import java.awt.Component; +import java.io.*; +import java.text.*; +import java.util.Date; +import net.sourceforge.jsxe.util.Log; +//}}} + +/** + * Local filesystem VFS. + * @author Slava Pestov + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @since jsXe 0.5 pre3 + * @version $Id: FileVFS.java,v 1.47 2004/06/09 16:48:40 spestov Exp $ + */ +public class FileVFS extends VFS { + + public static final String PERMISSIONS_PROPERTY = "FileVFS__perms"; + + //{{{ FileVFS method + public FileVFS() + { + super("file",READ_CAP | WRITE_CAP | DELETE_CAP + | RENAME_CAP | MKDIR_CAP | LOW_LATENCY_CAP + | ((OperatingSystem.isMacOS() + || OperatingSystem.isDOSDerived()) + ? CASE_INSENSITIVE_CAP : 0), + new String[] { EA_TYPE, EA_SIZE, EA_STATUS, + EA_MODIFIED }); + } //}}} + + //{{{ getParentOfPath() method + public String getParentOfPath(String path) + { + if(OperatingSystem.isDOSDerived()) + { + if(path.length() == 2 && path.charAt(1) == ':') + return FileRootsVFS.PROTOCOL + ":"; + else if(path.length() == 3 && path.endsWith(":\\")) + return FileRootsVFS.PROTOCOL + ":"; + else if(path.startsWith("\\\\") && path.indexOf('\\',2) == -1) + return path; + } + + return super.getParentOfPath(path); + } //}}} + + //{{{ constructPath() method + public String constructPath(String parent, String path) + { + if(parent.endsWith(File.separator) + || parent.endsWith("/")) + return parent + path; + else + return parent + File.separator + path; + } //}}} + + //{{{ getFileSeparator() method + public char getFileSeparator() + { + return File.separatorChar; + } //}}} + + //{{{ save() method + public boolean save(View view, Buffer buffer, String path) + { + if(OperatingSystem.isUnix()) + { + int permissions = getPermissions(buffer.getPath()); + Log.log(Log.DEBUG,this,buffer.getPath() + " has permissions 0" + + Integer.toString(permissions,8)); + buffer.setIntegerProperty(PERMISSIONS_PROPERTY,permissions); + } + + return super.save(view,buffer,path); + } //}}} + + //{{{ insert() method + public boolean insert(View view, Buffer buffer, String path) + { + File file = new File(path); + + //{{{ Check if file is valid + if(!file.exists()) + return false; + + if(file.isDirectory()) + { + VFSManager.error(view,file.getPath(), + "ioerror.open-directory",null); + return false; + } + + if(!file.canRead()) + { + VFSManager.error(view,file.getPath(), + "ioerror.no-read",null); + return false; + } //}}} + + return super.insert(view,buffer,path); + } //}}} + + //{{{ _canonPath() method + /** + * Returns the canonical form if the specified path name. For example, + * <code>~</code> might be expanded to the user's home directory. + * @param session The session + * @param path The path + * @param comp The component that will parent error dialog boxes + * @exception IOException if an I/O error occurred + */ + public String _canonPath(Object session, String path, Component comp) + throws IOException + { + return MiscUtilities.canonPath(path); + } //}}} + + //{{{ LocalDirectoryEntry class + public static class LocalDirectoryEntry extends VFS.DirectoryEntry + { + // use system default short format + public static DateFormat DATE_FORMAT + = DateFormat.getInstance(); + + public long modified; + + public LocalDirectoryEntry(File file) + { + super(file.getName(),file.getPath(), + file.getPath(),file.isDirectory() ? DIRECTORY : FILE,file.length(),file.isHidden()); + this.modified = file.lastModified(); + this.canRead = file.canRead(); + this.canWrite = file.canWrite(); + this.symlinkPath = MiscUtilities.resolveSymlinks(path); + } + + public String getExtendedAttribute(String name) + { + if(name.equals(EA_MODIFIED)) + return DATE_FORMAT.format(new Date(modified)); + else + return super.getExtendedAttribute(name); + } + } //}}} + + //{{{ _listDirectory() method + public VFS.DirectoryEntry[] _listDirectory(Object session, String path, + Component comp) + { + //{{{ Windows work around + /* On Windows, paths of the form X: list the last *working + * directory* on that drive. To list the root of the drive, + * you must use X:\. + * + * However, the VFS browser and friends strip off trailing + * path separators, for various reasons. So to work around + * that, we add a '\' to drive letter paths on Windows. + */ + if(OperatingSystem.isWindows()) + { + if(path.length() == 2 && path.charAt(1) == ':') + path = path.concat(File.separator); + } //}}} + + File directory = new File(path); + File[] list = directory.listFiles(); + if(list == null) + { + VFSManager.error(comp,path,"ioerror.directory-error-nomsg",null); + return null; + } + + VFS.DirectoryEntry[] list2 = new VFS.DirectoryEntry[list.length]; + for(int i = 0; i < list.length; i++) + list2[i] = new LocalDirectoryEntry(list[i]); + + return list2; + } //}}} + + //{{{ _getDirectoryEntry() method + public DirectoryEntry _getDirectoryEntry(Object session, String path, + Component comp) + { + if(path.equals("/") && OperatingSystem.isUnix()) + { + return new VFS.DirectoryEntry(path,path,path, + VFS.DirectoryEntry.DIRECTORY,0L,false); + } + + File file = new File(path); + if(!file.exists()) + return null; + + return new LocalDirectoryEntry(file); + } //}}} + + //{{{ _delete() method + public boolean _delete(Object session, String path, Component comp) + { + File file = new File(path); + // do some platforms throw exceptions if the file does not exist + // when we ask for the canonical path? + String canonPath; + try + { + canonPath = file.getCanonicalPath(); + } + catch(IOException io) + { + canonPath = path; + } + + boolean retVal = file.delete(); + if(retVal) + VFSManager.sendVFSUpdate(this,canonPath,true); + return retVal; + } //}}} + + //{{{ _rename() method + public boolean _rename(Object session, String from, String to, + Component comp) + { + File _to = new File(to); + + String toCanonPath; + try + { + toCanonPath = _to.getCanonicalPath(); + } + catch(IOException io) + { + toCanonPath = to; + } + + // this is needed because on OS X renaming to a non-existent + // directory causes problems + File parent = new File(_to.getParent()); + if(parent.exists()) + { + if(!parent.isDirectory()) + return false; + } + else + { + parent.mkdirs(); + if(!parent.exists()) + return false; + } + + File _from = new File(from); + + String fromCanonPath; + try + { + fromCanonPath = _from.getCanonicalPath(); + } + catch(IOException io) + { + fromCanonPath = from; + } + + // Case-insensitive fs workaround + if(!fromCanonPath.equalsIgnoreCase(toCanonPath)) + _to.delete(); + + boolean retVal = _from.renameTo(_to); + VFSManager.sendVFSUpdate(this,fromCanonPath,true); + VFSManager.sendVFSUpdate(this,toCanonPath,true); + return retVal; + } //}}} + + //{{{ _mkdir() method + public boolean _mkdir(Object session, String directory, Component comp) + { + String parent = getParentOfPath(directory); + if(!new File(parent).exists()) + { + if(!_mkdir(session,parent,comp)) + return false; + } + + File file = new File(directory); + + boolean retVal = file.mkdir(); + String canonPath; + try + { + canonPath = file.getCanonicalPath(); + } + catch(IOException io) + { + canonPath = directory; + } + VFSManager.sendVFSUpdate(this,canonPath,true); + return retVal; + } //}}} + + //{{{ _backup() method + public void _backup(Object session, String path, Component comp) + throws IOException + { + // Fetch properties + int backups = jEdit.getIntegerProperty("backups",1); + + if(backups == 0) + return; + + String backupPrefix = jEdit.getProperty("backup.prefix"); + String backupSuffix = jEdit.getProperty("backup.suffix"); + + String backupDirectory = jEdit.getProperty("backup.directory"); + + int backupTimeDistance = jEdit.getIntegerProperty("backup.minTime",0); + File file = new File(path); + + // Check for backup.directory, and create that + // directory if it doesn't exist + if(backupDirectory == null || backupDirectory.length() == 0) + backupDirectory = file.getParent(); + else + { + backupDirectory = MiscUtilities.constructPath( + System.getProperty("user.home"),backupDirectory); + + // Perhaps here we would want to guard with + // a property for parallel backups or not. + backupDirectory = MiscUtilities.concatPath( + backupDirectory,file.getParent()); + + File dir = new File(backupDirectory); + + if (!dir.exists()) + dir.mkdirs(); + } + + MiscUtilities.saveBackup(file,backups,backupPrefix, + backupSuffix,backupDirectory,backupTimeDistance); + } //}}} + + //{{{ _createInputStream() method + public InputStream _createInputStream(Object session, String path, + boolean ignoreErrors, Component comp) throws IOException + { + try + { + return new FileInputStream(path); + } + catch(IOException io) + { + if(ignoreErrors) + return null; + else + throw io; + } + } //}}} + + //{{{ _createOutputStream() method + public OutputStream _createOutputStream(Object session, String path, + Component comp) throws IOException + { + return new FileOutputStream(path); + } //}}} + + //{{{ _saveComplete() method + public void _saveComplete(Object session, Buffer buffer, String path, + Component comp) + { + int permissions = buffer.getIntegerProperty(PERMISSIONS_PROPERTY,0); + setPermissions(path,permissions); + } //}}} + + //{{{ Permission preservation code + + /** Code borrowed from j text editor (http://www.armedbear.org) */ + /** I made some changes to make it support suid, sgid and sticky files */ + + //{{{ getPermissions() method + /** + * Returns numeric permissions of a file. On non-Unix systems, always + * returns zero. + */ + public static int getPermissions(String path) { + int permissions = 0; + + if (jEdit.getBooleanProperty("chmodDisabled")) { + return permissions; + } + + if (OperatingSystem.isUnix()) { + String[] cmdarray = { "ls", "-ld", path }; + + try { + Process process = Runtime.getRuntime().exec(cmdarray); + + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + + String output = reader.readLine(); + + if (output != null) { + String s = output.substring(1, 10); + + permissions = MiscUtilities.parsePermissions(s); + } + } + + // Feb 4 2000 5:30 PM + // Catch Throwable here rather than Exception. + // Kaffe's implementation of Runtime.exec throws java.lang.InternalError. + catch (Throwable t) + { + } + } + + return permissions; + } //}}} + + //{{{ setPermissions() method + /** + * Sets numeric permissions of a file. On non-Unix platforms, + * does nothing. + */ + public static void setPermissions(String path, int permissions) { + if (jEdit.getBooleanProperty("chmodDisabled")) + return; + + if (permissions != 0) { + if (OperatingSystem.isUnix()) { + + String[] cmdarray = { "chmod", Integer.toString(permissions, 8), path }; + + try { + Process process = Runtime.getRuntime().exec(cmdarray); + process.getInputStream().close(); + process.getOutputStream().close(); + process.getErrorStream().close(); + // Jun 9 2004 12:40 PM + // waitFor() hangs on some Java + // implementations. + /* int exitCode = process.waitFor(); + if(exitCode != 0) + Log.log(Log.NOTICE,FileVFS.class,"chmod exited with code " + exitCode); */ + } + + // Feb 4 2000 5:30 PM + // Catch Throwable here rather than Exception. + // Kaffe's implementation of Runtime.exec throws java.lang.InternalError. + catch (Throwable t) + { + } + } + } + } //}}} + + //}}} +} Property changes on: branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java ___________________________________________________________________ Name: svn:executable + * Added: branches/jsxe2/src/net/sourceforge/jsxe/io/UrlVFS.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/UrlVFS.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/UrlVFS.java 2006-07-27 18:59:59 UTC (rev 1079) @@ -0,0 +... [truncated message content] |