Lines 22-27
Link Here
|
22 |
import java.io.ObjectInput; |
22 |
import java.io.ObjectInput; |
23 |
import java.io.ObjectOutput; |
23 |
import java.io.ObjectOutput; |
24 |
import java.io.ObjectStreamException; |
24 |
import java.io.ObjectStreamException; |
|
|
25 |
import java.util.Set; |
26 |
import java.util.Collections; |
25 |
import javax.swing.Action; |
27 |
import javax.swing.Action; |
26 |
import javax.swing.JEditorPane; |
28 |
import javax.swing.JEditorPane; |
27 |
import javax.swing.JScrollPane; |
29 |
import javax.swing.JScrollPane; |
Lines 35-40
Link Here
|
35 |
import javax.swing.text.EditorKit; |
37 |
import javax.swing.text.EditorKit; |
36 |
import org.openide.awt.UndoRedo; |
38 |
import org.openide.awt.UndoRedo; |
37 |
import org.openide.ErrorManager; |
39 |
import org.openide.ErrorManager; |
|
|
40 |
import org.openide.loaders.DataObject; |
41 |
import org.openide.filesystems.*; |
38 |
import org.openide.cookies.EditorCookie; |
42 |
import org.openide.cookies.EditorCookie; |
39 |
import org.openide.util.Task; |
43 |
import org.openide.util.Task; |
40 |
import org.openide.util.actions.SystemAction; |
44 |
import org.openide.util.actions.SystemAction; |
Lines 74-79
Link Here
|
74 |
|
78 |
|
75 |
private static final String HELP_ID = "editing.editorwindow"; // !!! NOI18N |
79 |
private static final String HELP_ID = "editing.editorwindow"; // !!! NOI18N |
76 |
|
80 |
|
|
|
81 |
/** |
82 |
* The listener is added on showing, removed on hidden. |
83 |
*/ |
84 |
private transient FileStatusListener titleListener; |
85 |
|
77 |
static final long serialVersionUID = -185739563792410059L; |
86 |
static final long serialVersionUID = -185739563792410059L; |
78 |
|
87 |
|
79 |
/** For externalization of subclasses only */ |
88 |
/** For externalization of subclasses only */ |
Lines 155-160
Link Here
|
155 |
protected void componentShowing() { |
164 |
protected void componentShowing() { |
156 |
super.componentShowing(); |
165 |
super.componentShowing(); |
157 |
initialize(); |
166 |
initialize(); |
|
|
167 |
titleListener = new TitleListener(); |
168 |
Document doc = support.getDocument(); |
169 |
FileSystem fs = getFileSystem(doc); |
170 |
fs.addFileStatusListener(titleListener); |
171 |
} |
172 |
|
173 |
protected void componentHidden() { |
174 |
Document doc = support.getDocument(); |
175 |
FileSystem fs = getFileSystem(doc); |
176 |
fs.removeFileStatusListener(titleListener); |
177 |
titleListener = null; |
178 |
super.componentHidden(); |
179 |
} |
180 |
|
181 |
/** |
182 |
* @return fs or null |
183 |
*/ |
184 |
private static FileSystem getFileSystem(Document doc) { |
185 |
FileObject fo = getFileObject(doc); |
186 |
if (fo != null) { |
187 |
try { |
188 |
return fo.getFileSystem(); |
189 |
} catch (FileStateInvalidException e) { |
190 |
ErrorManager err = ErrorManager.getDefault(); |
191 |
err.annotate(e, "TODO"); |
192 |
err.notify(e); |
193 |
} |
194 |
} |
195 |
return null; |
196 |
} |
197 |
|
198 |
/** Copy&paste from NbEditorUtilities */ |
199 |
private static FileObject getFileObject(Document doc) { |
200 |
Object sdp = doc.getProperty(Document.StreamDescriptionProperty); |
201 |
if (sdp instanceof FileObject) { |
202 |
return (FileObject)sdp; |
203 |
} |
204 |
if (sdp instanceof DataObject) { |
205 |
return ((DataObject)sdp).getPrimaryFile(); |
206 |
} |
207 |
return null; |
158 |
} |
208 |
} |
159 |
|
209 |
|
160 |
/** Performs needed initialization */ |
210 |
/** Performs needed initialization */ |
Lines 423-429
Link Here
|
423 |
if(ces != null) { |
473 |
if(ces != null) { |
424 |
Mutex.EVENT.writeAccess(new Runnable() { |
474 |
Mutex.EVENT.writeAccess(new Runnable() { |
425 |
public void run() { |
475 |
public void run() { |
426 |
setDisplayName(ces.messageName()); |
476 |
Document doc = ces.getDocument(); |
|
|
477 |
FileObject fo = getFileObject(doc); |
478 |
FileSystem fs = getFileSystem(doc); |
479 |
String displayName = ces.messageName(); |
480 |
if (fo != null && fs != null) { |
481 |
FileSystem.Status status = fs.getStatus(); |
482 |
if (status instanceof FileSystem.HtmlStatus) { |
483 |
FileSystem.HtmlStatus htmlStatus = (FileSystem.HtmlStatus) status; |
484 |
Set files = Collections.singleton(fo); |
485 |
displayName = htmlStatus.annotateNameHtml(displayName, files); |
486 |
} |
487 |
} |
488 |
setDisplayName(displayName); |
489 |
|
427 |
setName(ces.messageName()); // XXX compatibility |
490 |
setName(ces.messageName()); // XXX compatibility |
428 |
|
491 |
|
429 |
setToolTipText(ces.messageToolTip()); |
492 |
setToolTipText(ces.messageToolTip()); |
Lines 640-643
Link Here
|
640 |
requestVisible(); |
703 |
requestVisible(); |
641 |
} |
704 |
} |
642 |
|
705 |
|
|
|
706 |
/** |
707 |
* Component title may change on file status change. |
708 |
*/ |
709 |
private class TitleListener implements FileStatusListener { |
710 |
public void annotationChanged(FileStatusEvent ev) { |
711 |
support.updateTitles(); |
712 |
} |
713 |
} |
643 |
} |
714 |
} |