Subversion Repositories general

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
240 swalkenh 1
PK
813 swalkenh 2
 
3
 
4
Class-Path: 
240 swalkenh 5
Transform-To-File: src/plugins/textEditorPlugin/TextEditorPluginTransf
6
 orm.xsl
813 swalkenh 7
XMLEditor-Plugin-Name: TextEditor
8
Created-By: 1.4.2 (Sun Microsystems Inc.)
9
Main-Class: src.plugins.textEditorPlugin.TextEditorPlugin
240 swalkenh 10
Description: ...(todo)
11
Transform-Fro-File: src/plugins/textEditorPlugin/TextEditorPluginTrans
12
 formBack.xsl
813 swalkenh 13
Comment: view everything as text, best as default plugin
240 swalkenh 14
 
15
Name: src/plugins/textEditorPlugin
813 swalkenh 16
Specification-Title: plugin for XMLEditor
17
Implementation-Title: src.plugins.textEditorPlugin
240 swalkenh 18
Specification-Version: 0.4 (05/07/03)
813 swalkenh 19
Specification-Vendor: group5, software practice SS_2003, University Bi
20
 elefeld, Germany
240 swalkenh 21
Implementation-Version: 0.1 (05/07/03)
22
Implementation-Vendor: group5, software practice SS_2003, University B
23
 ielefeld, Germany
24
 
25
PK
813 swalkenh 26
 
27
 
28
 
29
 
30
 
31
 
32
 
33
 
34
 
35
SourceFileTextEditorPlugin.javaInnerClassesMyUndoListener 	
36
 
37
*·*+µ±S
38
 
39
nq#s$$789:;
40
 
41
 
42
ƒƒEsrc/plugins/textEditorPlugin/TextEditorPlugin$OwnStyledDocument.classÊþº¾-"?src/plugins/textEditorPlugin/TextEditorPlugin$OwnStyledDocument&javax/swing/text/DefaultStyledDocumentthis$0/Lsrc/plugins/textEditorPlugin/TextEditorPlugin;	Synthetic<init>2(Lsrc/plugins/textEditorPlugin/TextEditorPlugin;)VCode()V
43
 
44
 
45
SourceFileTextEditorPlugin.javaInnerClasses-src/plugins/textEditorPlugin/TextEditorPluginOwnStyledDocument 	
46
 
47
*·
*+µ±
48
78
49
 
50
 
51
 
52
 
53
 
54
 
55
 
56
LineNumberTableLocalVariableTablethis:Lsrc/plugins/textEditorPlugin/TextEditorPlugin$UndoAction;actionPerformed(Ljava/awt/event/ActionEvent;)V-src/plugins/textEditorPlugin/TextEditorPluginaccess$0O(Lsrc/plugins/textEditorPlugin/TextEditorPlugin;)Ljavax/swing/undo/UndoManager;
57
 
58
 
59
 
60
 
61
 
62
 
63
 
64
 
65
 
66
 
67
 
68
UndoAction 	
69
C*·*+µ*¶±çêë
70
 
71
 
72
 
73
 
74
A‰ù.˜xîpŒ-Œ-3src/plugins/textEditorPlugin/TextEditorPlugin.classÊþº¾-!-src/plugins/textEditorPlugin/TextEditorPluginjavax/swing/JPanelsrc/plugins/PluginInterfacejava/awt/event/ActionListenerjavax/swing/event/CaretListener	"javax/swing/event/DocumentListener
75
 
76
TextEditorguiInterfaceLsrc/gui/GuiInterface;logInterfaceLsrc/gui/LogInterface;ourEventListenerLsrc/control/OurEventListener;statusInterfaceLsrc/gui/StatusInterface;textDocumentALsrc/plugins/textEditorPlugin/TextEditorPlugin$OwnStyledDocument;textAreaLjavax/swing/JTextArea;
77
 
78
 
79
 
521 swalkenh 80
undoAction:Lsrc/plugins/textEditorPlugin/TextEditorPlugin$UndoAction;undoManagerLjavax/swing/undo/UndoManager;<init>()VCode./
81
1
	3?src/plugins/textEditorPlugin/TextEditorPlugin$OwnStyledDocument52(Lsrc/plugins/textEditorPlugin/TextEditorPlugin;)V.7
813 swalkenh 82
68	:javax/swing/JTextArea<(Ljavax/swing/text/Document;)V.>
521 swalkenh 83
=?	Ajavax/swing/JScrollPaneC(Ljava/awt/Component;)V.E
813 swalkenh 84
DF	Hjavax/swing/JButtonJsynchronizeL(Ljava/lang/String;)V.N
85
KO !	Q()	S8src/plugins/textEditorPlugin/TextEditorPlugin$UndoActionU
86
V8*+	Xjavax/swing/undo/UndoManagerZ
87
 
88
 
89
 
90
 
91
 
92
 
93
 
94
 
95
™8addUndoableEditListener+(Ljavax/swing/event/UndoableEditListener;)V›œ
96
 
97
 
98
 
99
 
100
 
101
 
102
 
103
 
104
 
105
 
106
 
107
åèappend,(Ljava/lang/String;)Ljava/lang/StringBuffer;êë
108
 
109
 
110
 
111
 
112
 
113
 
114
“javax/swing/text/Document!addDocumentListener'(Ljavax/swing/event/DocumentListener;)V#$"%5javax/xml/transform/TransformerConfigurationException'(javax/xml/transform/TransformerException)nodeenvironmentLorg/w3c/dom/Document;elementPathLjavax/swing/tree/TreePath;textEditorMenuLjavax/swing/JMenu;source#Ljavax/xml/transform/dom/DOMSource;stringWriterLjava/io/StringWriter;stream)Ljavax/xml/transform/stream/StreamResult;transformerFactory(Ljavax/xml/transform/TransformerFactory;tce7Ljavax/xml/transform/TransformerConfigurationException;te*Ljavax/xml/transform/TransformerException;stringstopsetOurEventListener!(Lsrc/control/OurEventListener;)V	BnewListenerforceStatusReportgetTextFç
115
 
116
 
117
 
118
 
119
 
120
UZnewDocumentBuilder%()Ljavax/xml/parsers/DocumentBuilder;\]
121
 
122
 
123
 
124
 
125
ap
getFirstChild()Lorg/w3c/dom/Node;rsÁt$%	vchangedNode = x,(Ljava/lang/Object;)Ljava/lang/StringBuffer;êz
126
à{"org/apache/xerces/dom/DocumentImpl}
127
~1NOTVALID€&org/apache/xerces/dom/CoreDocumentImpl‚createProcessingInstructionI(Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/ProcessingInstruction;„…
128
ƒ†Node Type = ˆ(I)Ljava/lang/StringBuffer;êŠ
129
à‹	cloneNode(Z)Lorg/w3c/dom/Node;ŽÁsetNodeValue‘NÁ’4Errors ignored: Input was interpreted as plain text.”Parser configuration error: –
130
IO error: ˜Illegal argument error: šSAX parser error: œorg/xml/sax/SAXExceptionž
131
ŸèReturn this node:¡firePluginChangedElement'(Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)V£¤
132
¥.javax/xml/parsers/ParserConfigurationException§java/io/IOException©"java/lang/IllegalArgumentException«validcontenterrorHandler#Lsrc/parser/ValidationErrorHandler;documentBuilderFactory*Ljavax/xml/parsers/DocumentBuilderFactory;documentBuilder#Ljavax/xml/parsers/DocumentBuilder;stringReaderLjava/io/StringReader;inputSourceLorg/xml/sax/InputSource;doc$Lorg/apache/xerces/dom/DocumentImpl;pce0Ljavax/xml/parsers/ParserConfigurationException;ioeLjava/io/IOException;iae$Ljava/lang/IllegalArgumentException;saxeLorg/xml/sax/SAXException;src/control/OurEventÃjava/lang/ObjectÅ([Ljava/lang/Object;)V.Ç
133
ÄÈsrc/control/OurEventListenerÊ
firedOurEvent(Lsrc/control/OurEvent;)VÌÍËÎeLsrc/control/OurEvent;actionPerformed(Ljava/awt/event/ActionEvent;)Vjava/util/EventObjectÔ	getSource()Ljava/lang/Object;Ö×
134
ÕØE/
135
ÚaeLjava/awt/event/ActionEvent;caretUpdate!(Ljavax/swing/event/CaretEvent;)Vjavax/swing/event/CaretEventàgetDot()Iâã
136
 
137
=ègetLineStartOffsetêç
138
=ëjava/awt/Pointí(II)V.ï
139
 
140
removeUpdate
141
isModified()Zimessageaccess$0O(Lsrc/plugins/textEditorPlugin/TextEditorPlugin;)Ljavax/swing/undo/UndoManager;	Syntheticaccess$1E(Lsrc/plugins/textEditorPlugin/TextEditorPlugin;ILjava/lang/String;)V
142
 
143
SourceFileTextEditorPlugin.javaInnerClasses
144
UndoActionOwnStyledDocumentMyUndoListener!
145

 !"#$%&%'()*+,-./0¬^*·2*µ4*»6Y*·9µ;*»=Y*´;·@µB*»DY*´B·GµI*»KYM·PµR*µT*»VY*·WµY*»[Y·\µ^±_*
146
 
147
VW%Z4^AeFhRk]q`^abcd0Åe*+µf*+¹lµn*+¹rµt*¶z*»|Y·}¶ƒ**´I…¶‰**´R‹¶‰*´R*¶‘*´B*¶—*´;»™Y*·š¶ž²¤¦¶«±_2|}~€)3‚=ƒE„M‡\ˆd‰`eabe¬­0c	3»¯Y±·²:*´Y¶µW*´f¹¹*´f*¹½*¶z*+µ¿+¹Å Î»ÇY+·Ê:»ÌY·Í:»ÏY·Ò:¸Ø:*¶ÜµÞ§#:*´n»àYâ·ã¶é¶í¶ð¹ö*´Þøú¶*´Þú¶*´Þ¶*´Þ
148
 
149
 
150
`abDE/0MÇ<*´B¶HM»JY·KN-*´n¶O-*´t¶S¸X:¶[¶_:-¶e™E»gY,·h:»jY·m:*¶q¹uµw²¤»àYy·ã*´w¶|¶ð¶«§*´¿¹ÅŸ*´¿¹Å &*´B¶HM»~Y·:*,¶‡µw<§á²¤»àY‰·ã*´¿¹Å¶Œ¶ð¶«**´¿¹µw*´w*´B¶H¹“*´n•¹ö<§’:*´n»àY—·ã¶é¶í¶ð¹ö§n:*´n»àY™·ã¶é¶í¶ð¹ö§J:*´n»àY›·ã¶é¶í¶ð¹ö§&:*´n»àY·ã¶ ¶í¶ð¹ö<™þ…²¤»àY¢·ã*´w¶|¶ð¶«**´¿*´w·¦±"

¨"
1ª"
U¬"
yŸ_Ê2
151
"'-4: >!H"S%c&€*›+£,¬-¹.¾1Ý2ë3û45
;<<=&<1A3B8BBCJBUFWG\GfHnGyL{M€MŠN’MšOœR UºVÆW`„
ÇabÅ­)
152
½®µ¯°'æ±²4Ù³´H8µ¶S-·¸¬¹º»¼3½¾W¿À{!Á£¤0t$»ÄY½ÆY+SY,SYS·ÉN*´C-¹Ï±_fg#h`*$ab$&%$$%ÐÑÒÓ0L+¶Ù*´R¦*¶Û±_tuw`abÜÝÞß0ÜT+¶å=*´B¶é>*´B¶ìd6*´t»îY``·ñ¹÷§"N*´n»àYù·ã-¶é¶í¶ð¹ö±44û_*
153
ƒ„…4‡5ˆ:ˆD‰KˆS‹`>TabTüýOþÿ&ÿÿ505±_‘`ab0L*µT*´t¹±_Ÿ ¡`ab0L*µT*´t¹±_¯°±`ab
0/*´T¬_½`abóô0N*´n,¹ö±_
154
 
155
™nù.¡½êÉLÉL2src/plugins/textEditorPlugin/TextEditorPlugin.java/* 
156
 * This file contains the TextEditorPlugin class.
157
 
158
 
159
 
160
 
161
 * @version $Revision: 1.46 $
162
 
163
 
164
 * $Id: TextEditorPlugin.java,v 1.46 2003/07/25 11:52:50 smcsporr Exp $
165
 */
166
167
package src.plugins.textEditorPlugin;
168
169
import java.awt.BorderLayout;
170
171
 
172
import java.awt.event.ActionListener;
173
 
174
import java.io.StringReader;
175
 
176
 
521 swalkenh 177
import javax.swing.Action;
178
import javax.swing.JButton;
179
import javax.swing.JMenu;
180
import javax.swing.JPanel;
181
import javax.swing.JScrollPane;
813 swalkenh 182
import javax.swing.JTextArea;
521 swalkenh 183
813 swalkenh 184
import javax.swing.event.CaretEvent;
185
import javax.swing.event.CaretListener;
521 swalkenh 186
import javax.swing.event.DocumentEvent;
187
 
188
import javax.swing.event.UndoableEditEvent;
189
 
190
191
 
813 swalkenh 192
import javax.swing.text.DefaultStyledDocument;
193
194
 
521 swalkenh 195
196
 
813 swalkenh 197
import javax.swing.undo.UndoManager;
198
521 swalkenh 199
import javax.xml.transform.Transformer;
813 swalkenh 200
import javax.xml.transform.TransformerFactory;
521 swalkenh 201
import javax.xml.transform.TransformerConfigurationException;
202
import javax.xml.transform.TransformerException;
203
import javax.xml.transform.dom.DOMSource;
813 swalkenh 204
 
205
import javax.xml.parsers.DocumentBuilder;
206
import javax.xml.parsers.DocumentBuilderFactory;
207
import javax.xml.parsers.ParserConfigurationException;
208
209
import org.w3c.dom.Document;
210
import org.w3c.dom.Node;
211
 
545 swalkenh 212
import org.xml.sax.InputSource;
813 swalkenh 213
521 swalkenh 214
 
813 swalkenh 215
import src.control.OurEventListener;
521 swalkenh 216
 
813 swalkenh 217
import src.plugins.PluginInterface;
218
521 swalkenh 219
 
220
 * The <code>TextEditor</code> plugin is used for textual XML node editing.
221
 * 
222
 * @author Christian Stollenwerk
223
 * 
224
 * @version $Revision: 1.46 $ Last modification: $Date: 2003/07/25 11:52:50 $
225
 */
226
public class TextEditorPlugin extends JPanel
227
							  implements PluginInterface, ActionListener, CaretListener,
228
							  DocumentListener {
229
 
813 swalkenh 230
	/** Name of the plugin, used in method <code>firePluginChangedElement</code> */
231
	final private String pluginName = "TextEditor";
232
 
233
	/** Reference variables to access other program objects. */	
234
 
521 swalkenh 235
	private LogInterface logInterface;
236
	private OurEventListener ourEventListener;
237
	private StatusInterface statusInterface;
238
239
 
240
	private OwnStyledDocument textDocument = new OwnStyledDocument();
813 swalkenh 241
	private JTextArea textArea = new JTextArea(textDocument);
521 swalkenh 242
	
243
	/** Put the editing area in a scroll pane. */
813 swalkenh 244
	private JScrollPane scrollPane = new JScrollPane(textArea);
245
	
521 swalkenh 246
	/** The 'synchronize' button is used to update the tree display with the text editor
247
	 * current content. */
813 swalkenh 248
	private JButton syncButton = new JButton("synchronize");
249
	private Transformer transformer;
521 swalkenh 250
 
251
	private Node oldNode;
252
	private String oldContent;
253
 
813 swalkenh 254
	/** A variable indicating if the document displayed has been modified. */
521 swalkenh 255
	private boolean modified = false;
813 swalkenh 256
	
521 swalkenh 257
	/** Create an UndoAction. UndoActions will be fired, if an undoable event occured. */
813 swalkenh 258
	private UndoAction undoAction = new UndoAction();
259
 
260
	/** Create an UndoManager that stores undoable events in an event queue. */
261
	private UndoManager undoManager = new UndoManager();
262
263
 
264
	 * Empty constructor.
521 swalkenh 265
	 */
813 swalkenh 266
 
267
	}
268
	
521 swalkenh 269
	/** 
270
	 * Initializes the Text Editor Plugin, but does not show it.
271
	 * 
272
	 * @param guiInterface: A reference to an object compliant to src.gui.GuiInterface.
273
	 * 
813 swalkenh 274
 
275
	 */
545 swalkenh 276
	public void init(GuiInterface guiInterface) {
813 swalkenh 277
 
278
		this.guiInterface = guiInterface;
279
		logInterface = guiInterface.getLogInterface();
280
 
281
		setVisible(false);
282
		setLayout(new BorderLayout());
521 swalkenh 283
 
813 swalkenh 284
		add(syncButton, BorderLayout.NORTH);
285
		syncButton.addActionListener(this);
286
		textArea.addCaretListener(this);
521 swalkenh 287
		
288
		/* Add a listener for undoable events. */
289
 
290
		System.out.println("TextEditorPlugin initialized");
813 swalkenh 291
	}
521 swalkenh 292
813 swalkenh 293
294
	/** 
521 swalkenh 295
	 * Starts the Text Editor Plugin if a registered node has been chosen.
296
	 * 
297
	 * @param element The selected node from the XML document, read-only.
298
	 * @param environment The whole XML document, read-only.
299
	 * @param elementPath The <code>TreePath</code> of the selected element in the evironment.
300
	 * 
301
	 * @see src.gui.PluginInterface#start(org.w3c.dom.Element, org.w3c.dom.Document)
302
	 */
303
	public void start(final Node node, final Document environment, final TreePath elementPath) {
304
		
305
		/* Create a JMenu entry for this plugin. */
306
		JMenu textEditorMenu = new JMenu("Text editor");
545 swalkenh 307
		textEditorMenu.add(undoAction);
813 swalkenh 308
 
309
		/* Add the text editor menu to the GUI. */
310
		this.guiInterface.setPluginMenu(textEditorMenu);
521 swalkenh 311
		this.guiInterface.setPluginPanel(this);
312
		setVisible(true);
313
 
314
 
315
		// casts the node into a DOMSource for transforming
813 swalkenh 316
		if(node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
521 swalkenh 317
			DOMSource source = new DOMSource(node);
813 swalkenh 318
			java.io.StringWriter stringWriter = new java.io.StringWriter();
319
			StreamResult stream = new StreamResult(stringWriter);
320
			try {
521 swalkenh 321
				/* Create a TransformerFactory and a new Transformer. */
322
				TransformerFactory transformerFactory = TransformerFactory.newInstance();
323
				transformer = transformerFactory.newTransformer();
813 swalkenh 324
			}
325
 
326
			/* Catch and log exceptions thrown by the TransformerFactory.*/
327
			catch (TransformerConfigurationException tce) {
328
				logInterface.log(LogInterface.TYPE_ERROR, "TransformerFactory error: "
329
 
330
			}
331
			transformer.setOutputProperty(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
332
			transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes");
333
			transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
334
 
521 swalkenh 335
			try {
336
				transformer.transform(source, stream);
337
			}
338
			
339
			/* Catch and log exception thrown during the transformation. */
340
			catch (TransformerException te){
341
				logInterface.log(LogInterface.TYPE_ERROR, "Transformer error: "
342
				+ te.getMessage());
343
			}
344
			String string = stringWriter.getBuffer().toString();
345
			oldContent = string;
346
 
347
			// try syntax highlighting
348
			/*javax.swing.text.Document textDocument = textArea.getDocument();
349
			StyleContext styleContext = StyleContext.getDefaultStyleContext();
350
			Style defaultStyle = styleContext.getStyle(StyleContext.DEFAULT_STYLE);
351
		
352
			Style tagStyle = styleContext.addStyle(null, defaultStyle);
353
			StyleConstants.setForeground(tagStyle, java.awt.Color.BLUE);
354
			//StyleConstants.setFontFamily(tagStyle, "Arial");
355
			System.out.println("tagStyle = " +tagStyle);
356
			Style style = defaultStyle;
357
			char c;
358
			boolean newLine = false;
813 swalkenh 359
 
360
				c = string.charAt(i);
521 swalkenh 361
				try {
362
					if(newLine && c == ' ') {
363
						textDocument.insertString(textDocument.getLength(), 
364
													"   ", style);
365
					}
366
					if(c != ' ')
367
 
368
					if(c == '\n') {
369
						newLine = true;
370
					}
371
					if(c == '<') {
372
 
373
						//textArea.setDisabledTextColor(java.awt.Color.BLUE);
374
					}
375
					if(c == '>') {
376
						style = defaultStyle;
377
						//textArea.setDisabledTextColor(java.awt.Color.BLACK);
378
					}
379
					textDocument.insertString(textDocument.getLength(), 
380
												String.valueOf(c), style);
381
				}
382
				catch(BadLocationException ble) {
383
					logInterface.log(LogInterface.TYPE_ERROR, ble.getMessage());
384
				}
385
				//textArea.setText(String.valueOf(c));
386
			}*/
387
			textArea.setText(string);
388
		}
389
		/* If the node ist a text node or similar, only get the value. */
390
		else {
391
			textArea.setText(node.getNodeValue());
392
		}
393
		
394
		guiInterface.setPluginPanel(this);
395
		textArea.getDocument().addDocumentListener(this);
396
		setVisible(true);
397
	}
398
399
400
	/** 
401
	 * Stops showing the TextEditor plugin by setting it invisible. The editor will
402
	 * remain loaded in RAM.
403
	 * 
404
	 * @see src.gui.PluginInterface#stop()
405
	 */
406
	public void stop() {
407
		setVisible(false);
408
	}
409
813 swalkenh 410
	/* (non-Javadoc)
521 swalkenh 411
	 * @see src.gui.PluginInterface#setOurEventListener(src.control.OurEventListener)
412
	 */
413
	public void setOurEventListener(OurEventListener newListener) {
414
 
415
	}
545 swalkenh 416
521 swalkenh 417
418
	/**
419
 
420
 
421
	 * 
813 swalkenh 422
	 * author C. Stollenwerk
423
	 * 
521 swalkenh 424
	 * @see src.gui.PluginInterface#forceStatusReport()
425
	 */
426
	public void forceStatusReport() {
427
		
428
		/* Parse the content of the JTextArea. */
429
		boolean valid = true;
430
 
431
432
		src.parser.ValidationErrorHandler errorHandler = new src.parser.ValidationErrorHandler();
433
		errorHandler.setLogInterface(logInterface);
434
		errorHandler.setStatusInterface(statusInterface);
435
		do {
436
			try {
437
 
438
 
439
				DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
813 swalkenh 440
				documentBuilder.setErrorHandler(errorHandler);
441
				// if the content of the edior is well-formed, parse only
521 swalkenh 442
				if(valid == true) {
813 swalkenh 443
					StringReader stringReader = new StringReader(content);
444
					InputSource inputSource = new InputSource(stringReader);
445
					//doc.appendChild(documentBuilder.parse(inputSource));
521 swalkenh 446
					//log(LogInterface.TYPE_INFO, content); //for debugging
447
					changedNode = documentBuilder.parse(inputSource).getFirstChild();
813 swalkenh 448
 
449
				}
521 swalkenh 450
				// if the content is not well-formed, capsule it into a processing instruction
451
				else {
813 swalkenh 452
 
521 swalkenh 453
						content = textArea.getText();
454
						org.apache.xerces.dom.DocumentImpl doc = new org.apache.xerces.dom.DocumentImpl(); 
455
						changedNode = doc.createProcessingInstruction("NOTVALID", content);
456
						valid = true;
457
					}
458
					else {
813 swalkenh 459
						System.out.println("Node Type = " + oldNode.getNodeType());
521 swalkenh 460
						changedNode = oldNode.cloneNode(true);
461
						changedNode.setNodeValue(textArea.getText());
462
						logInterface.log(LogInterface.TYPE_INFO,"Errors ignored: Input was interpreted as plain text.");
463
						valid = true;
464
					}
465
				}
466
			}
813 swalkenh 467
			
521 swalkenh 468
			/* Catch and log configuration errors. */
469
			catch(ParserConfigurationException pce) {
470
				logInterface.log(LogInterface.TYPE_ERROR, "Parser configuration error: "
471
				+ pce.getMessage());
472
			}
473
			
474
			/* Catch and log I/O-errors during parsing. */
475
			catch(java.io.IOException ioe) {
476
				logInterface.log(LogInterface.TYPE_ERROR, "IO error: "
477
				+ ioe.getMessage());
478
			}
479
			
480
			catch(IllegalArgumentException iae) {
481
				logInterface.log(LogInterface.TYPE_ERROR, "Illegal argument error: "
482
				+ iae.getMessage());
813 swalkenh 483
			}
521 swalkenh 484
			
485
			/* Catch and log parsing errors. */
486
			catch(org.xml.sax.SAXException saxe) {
487
				logInterface.log(LogInterface.TYPE_ERROR, "SAX parser error: "
488
 
489
				valid = false;
490
			}
491
		}
492
		while(valid == false);
493
494
 
495
		System.out.println("Return this node:" + changedNode);
496
		firePluginChangedElement(oldNode, changedNode);
497
	}
498
	
499
500
 
501
	 * The methode <code> firePluginChangedEvent</code> fires a new src.contrl.OurEvent
502
	 * to notify a changed Node to classes that implements the src.control.OurEventListener
503
	 * 
504
	 * @param oldNode the original Node see org.w3c.dom.Node;
505
 
506
	 * 
507
	 * @see src.control.OurEvent
508
	 * @see src.control.OurEventListener
509
	 */
510
511
	private void firePluginChangedElement(Node oldNode, Node changedNode) {
512
		OurEvent e = new OurEvent(new Object[] {oldNode, changedNode, pluginName});
513
		ourEventListener.firedOurEvent(e);
514
 
515
	
516
	/**
517
	 * Handles the action that the 'synchronize' button has been pressed by
518
	 * starting the <code>forceStatusReport</code> method.
519
 
813 swalkenh 520
 
521
	 * 'synchronize' button in the text editor has been pressed.
522
	 * 
523
	 * @see java.awt.event.ActionEvent
524
	 */
525
	public void actionPerformed(ActionEvent ae) {
526
		if(ae.getSource() == syncButton) {
527
			forceStatusReport();
528
		}
529
	}
530
	
531
 
521 swalkenh 532
	 * The methode <code> caretUpdate </code> is required  by the Interface <code>CaretListener</code>
533
	 * It is the Listener for changes in the caret position of a text component.
534
	 * 
535
	 * @see javax.swing.event.CaretListener
536
 
813 swalkenh 537
	 */
538
	public void caretUpdate(CaretEvent ce) {
539
		int dot = ce.getDot();
540
		try {
541
			int line = textArea.getLineOfOffset(dot);
542
			int column = dot - textArea.getLineStartOffset(line);
543
			statusInterface.setPoint(new java.awt.Point(line + 1, column + 1));
544
		}
545
		catch(BadLocationException badLEx) {
521 swalkenh 546
			logInterface.log(LogInterface.TYPE_ERROR, "Bad cursor location: "
547
			+ badLEx.getMessage());
548
		}
549
	}
550
	
545 swalkenh 551
 
813 swalkenh 552
	 * Empty method to implement javax.swing.event.DocumentListener. 
553
	 */
554
	public void changedUpdate(DocumentEvent de) {
555
	}
556
557
	/**
558
	 * Handles insertion <code>DocumentEvent</code>s.
545 swalkenh 559
	 * 
560
	 * These are events that indicate, that something has been inserted into the
561
	 * associated document. The method will set the 'modified' status display
562
	 * in the GUI visible, so users will see, if the current document has been changed.
563
	 * 
564
	 * @param de A document event fired by a document object.
565
	 * 
566
	 * Last revision: 20-Jul-2003
567
	 */
568
	public void insertUpdate(DocumentEvent de) {
569
		modified = true;
570
		statusInterface.setModified(true);
571
 
813 swalkenh 572
573
	/**
545 swalkenh 574
	 * Handles deletion <code>DocumentEvent</code>s.
575
	 * 
576
	 * These are events that indicate, that something has been deleted from the
577
 
813 swalkenh 578
	 * in the GUI visible, so users will see, if the current document has been changed.
579
	 * 
580
	 * @param de A document event fired by a document object.
581
	 * 
582
	 * Last revision: 20-Jul-2003
583
	 */
584
	public void removeUpdate(DocumentEvent de) {
585
		modified = true;
586
		statusInterface.setModified(true);
587
	}
545 swalkenh 588
	
589
	/**
590
	 * Returns the modification status of the current document.
591
	 * This status indicates, if the current document has been changed or not.
592
	 * 
593
 
813 swalkenh 594
	 * been changed, <code>false</code> otherwise.
595
	 * 
596
	 * author C. Stollenwerk
597
	 */
598
	public boolean isModified() {
599
		return modified;
600
	}
601
	
602
	/**
603
	 * Sends a text message of a specified type (info, error, warning) to the
545 swalkenh 604
	 * registered log panel.
605
	 * A reference to an implementation of a log panel will be set when calling the
606
	 * class constructor via the src.gui.GuiInterface method <code>getLogInterface</code>.
607
	 * 
608
	 * @param i The type of the message as defined in src.gui.LogInterface.
609
 
813 swalkenh 610
	 * 			1 or src.gui.LogInterface.TYPE_WARNING 	-> warning message (orange)
611
	 * 			2 or src.gui.LogInterface.TYPE_ERROR	-> error message (red)
612
	 * 
613
	 * @param message The text message to display in the log panel.
614
	 */	
615
	private void log(int i,String message) {
616
		logInterface.log(i,message);	
617
	}
618
	
545 swalkenh 619
	/**
620
	 * <code>UndoAction</code> implements an <code>AbstractAction</code>
621
	 * event to form an event that is released when an undoable edit
813 swalkenh 622
 
623
	 * 
624
	 * @see javax.swing.AbstractAction
625
	 * 
626
	 * @author S. McSporran
627
	 *
628
	 * Last revision: 18-Jul-2003 by S. McSporran
629
	 */
630
	private class UndoAction extends AbstractAction {
631
632
		/* Implemented as inner class, as it it only used in the context of
633
		 * the text editor. */
634
		
635
		/**
636
		 * The class constructor initializes it's superclass.
637
		 */
638
		public UndoAction() {
639
 
640
			/* Set title for this action. */
641
			super("Undo");
642
643
			/* Action is disabled at start. */
644
			setEnabled(false);
645
		}
646
          
647
        /**
648
         * The <code>actionPerformed</code> method is invoked if an
649
         * <code>UndoAction</code> action was caught by the action listener.
650
         * 
651
         * @see java.awt.event.ActionListener
652
 
653
         * author S. McSporran
654
         * 
655
 
656
         */
657
		public void actionPerformed(ActionEvent ae) {
658
			
659
			/* Try to undo the last edit. */
660
 
661
					
662
				undoManager.undo();
663
 
664
 
665
				
666
			/* Catch and log undo errors. */
667
 
668
					
669
				log(LogInterface.TYPE_ERROR, "Cannot undo : " + cue);
670
			}
671
672
			checkIfUndo();			
673
		}
674
         
675
        /**
676
         * <code>checkIfUndo</code> verifies, if an undoable event is
677
         * available. If not, it will disable the <code>UndoAction</code> event.
678
         * 
679
 
680
         * 
681
         * author S. McSporran
682
 
683
         * Last revision: 18-Jul-2003 by S. McSporran
684
         */
685
 
686
 
687
			/* Checks, if action can be undone. */
688
			if (undoManager.canUndo()) {
689
 
690
				setEnabled(true);
691
				putValue(Action.NAME, undoManager.getUndoPresentationName());
692
 
693
				
694
			else {
695
 
696
				setEnabled(false);
697
				putValue(Action.NAME, "Undo");
698
			}
699
		}      
700
	}    
701
702
	/**
703
	 * <code>OwnStyledDocument</code> extends the predefined <code>DefaultStyledDocument</code>
704
	 * and adds a method to register an <UndoableEditListener</code> to the
705
	 * text document.
706
	 * 
707
 
708
	 * 
709
	 * @author S. McSporran
710
 
711
	 * Last revision: 18-Jul-2003 by S. McSporran
712
	 */
713
	private class OwnStyledDocument extends DefaultStyledDocument {
714
 
715
		/* Implemented as inner class, as it is only used in the context
716
 
717
718
		/** 
719
		 * Empty constructor.
720
		 */
721
		public OwnStyledDocument() {
722
 
723
		
724
		/**
725
		 * Adds an <code>UndoableEditListener</code> to <code>OwnStyledDocument</code>.
726
		 * 
727
		 * @see javax.swing.text.Document
728
		 * 
729
		 * author S. McSporran
730
		 * 
731
		 * Last revision: 18-Jul-2003 by S. McSporran
732
		 */
733
		public void addUndoableEditListener (UndoableEditListener listener) {
734
			
735
 
736
		}
737
	}	
738
 
739
	/**
740
	 * <code>MyUndoListener</code> is used to handle undoable events.
741
	 * It will store events in the text editor in an <code>UndoManager</code>.
742
	 * 
743
	 * @see javax.swing.undo.UndoManager
744
 
745
	 * @author S. McSporran
746
	 *
747
	 * Last revision: 18-Jul-2003 by S. McSporran
748
	 */
749
	private class MyUndoListener implements UndoableEditListener {
750
		
751
		/* Implemented as inner class, as it is only used in the context
752
		 * of the text editor. */
753
		
754
		/**
755
 
756
		 * 
757
		 * New events will be added to a queue in the undo manager.
758
		 * Undoable events indicate, that an undoable edit has been done on a
759
 
760
		 * example.
761
		 * 
762
		 * @param uee An undoable event.
763
		 * 
764
		 * @see javax.swing.event.UndoableEditEvent
765
		 * 
766
		 * author S. McSporran
767
		 * 
768
		 * Last revision: 18-Jul-2003 by S. McSporran
769
		 */
770
		public void undoableEditHappened(UndoableEditEvent uee) {
771
 
772
			/* If the document has been modified, continue. */
773
			if (modified) {
774
 
775
				/* Register the undoable edit that happened to the UndoManager. */
776
				undoManager.addEdit(uee.getEdit());
777
			
778
				/* Update the undo action's state. */
779
				undoAction.checkIfUndo();
780
			}
781
		}
782
	}
783
}PK
784
ù.¹¤¶¶:src/plugins/textEditorPlugin/TextEditorPluginTransform.xsl<!-- to-direction for TextEditor
785
     status: ready
786
     updated to given schema from 15/07/2003 
787
     Last Revision: 17/07/2003 by Sascha Walkenhorst -->
788
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
789
<xsl:output method="xml" indent="yes" />
790
791
792
 
793
	<xsl:apply-templates />
794
</xsl:template>
795
 
796
<xsl:template match="node()">
797
	<xsl:copy-of select="." />
798
 
799
800
801
</xsl:stylesheet>PK
802
ù.…±ÁK¸¸>src/plugins/textEditorPlugin/TextEditorPluginTransformBack.xsl<!-- back-direction for TextEditor
803
     status: ready
240 swalkenh 804
     updated to given schema from 15/07/2003 
813 swalkenh 805
 
806
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
807
<xsl:output method="xml" indent="yes" />
808
545 swalkenh 809
810
<xsl:template match="/">
811
 
813 swalkenh 812
 
545 swalkenh 813
814
<xsl:template match="node()">
815
	<xsl:copy-of select="." />
816
 
817
818
819
</xsl:stylesheet>PK
820
 
813 swalkenh 821
 
240 swalkenh 822
813 swalkenh 823
 
824
825
A‰ù.càFííB“src/plugins/textEditorPlugin/TextEditorPlugin$MyUndoListener.classPK
826
545 swalkenh 827
A‰ù.èÇN
828
ƒƒEà	src/plugins/textEditorPlugin/TextEditorPlugin$OwnStyledDocument.classPK
829
 
813 swalkenh 830
 
545 swalkenh 831
832
A‰ù.˜xîpŒ-Œ-3Esrc/plugins/textEditorPlugin/TextEditorPlugin.classPK
833
834
 
835
836
ù.¹¤¶¶:;src/plugins/textEditorPlugin/TextEditorPluginTransform.xslPK
837
838