Lines 45-60
Link Here
|
45 |
|
45 |
|
46 |
import org.netbeans.modules.xml.util.Util; |
46 |
import org.netbeans.modules.xml.util.Util; |
47 |
import java.io.*; |
47 |
import java.io.*; |
48 |
import java.text.*; |
|
|
49 |
import java.util.Enumeration; |
48 |
import java.util.Enumeration; |
50 |
import java.lang.ref.WeakReference; |
49 |
import java.lang.ref.WeakReference; |
51 |
import java.beans.PropertyChangeEvent; |
50 |
import java.beans.PropertyChangeEvent; |
52 |
|
51 |
|
|
|
52 |
import java.util.Collection; |
53 |
import javax.swing.Timer; |
53 |
import javax.swing.Timer; |
54 |
import javax.swing.event.*; |
54 |
import javax.swing.event.*; |
55 |
import javax.swing.text.*; |
55 |
import javax.swing.text.*; |
56 |
|
56 |
|
|
|
57 |
import org.netbeans.api.editor.mimelookup.MimeLookup; |
57 |
import org.netbeans.core.api.multiview.MultiViews; |
58 |
import org.netbeans.core.api.multiview.MultiViews; |
|
|
59 |
import org.netbeans.core.spi.multiview.MultiViewDescription; |
58 |
import org.netbeans.modules.xml.api.EncodingUtil; |
60 |
import org.netbeans.modules.xml.api.EncodingUtil; |
59 |
import org.openide.*; |
61 |
import org.openide.*; |
60 |
import org.openide.awt.StatusDisplayer; |
62 |
import org.openide.awt.StatusDisplayer; |
Lines 69-75
Link Here
|
69 |
import org.openide.filesystems.FileLock; |
71 |
import org.openide.filesystems.FileLock; |
70 |
|
72 |
|
71 |
import org.netbeans.modules.xml.*; |
73 |
import org.netbeans.modules.xml.*; |
72 |
import org.netbeans.modules.xml.lib.*; |
74 |
import org.netbeans.modules.xml.XMLDataObject; |
73 |
import org.netbeans.modules.xml.sync.*; |
75 |
import org.netbeans.modules.xml.sync.*; |
74 |
import org.netbeans.modules.xml.cookies.*; |
76 |
import org.netbeans.modules.xml.cookies.*; |
75 |
import org.netbeans.modules.xml.text.syntax.XMLKit; |
77 |
import org.netbeans.modules.xml.text.syntax.XMLKit; |
Lines 154-163
Link Here
|
154 |
|
156 |
|
155 |
@Override |
157 |
@Override |
156 |
protected Pane createPane() { |
158 |
protected Pane createPane() { |
|
|
159 |
// defect #202766: whatever+xml gets multiview, although there is nobody |
160 |
// who would register the editor. M |
161 |
if (getDataObject().getClass() == XMLDataObject.class && |
162 |
!mimeType.equals(XMLDataObject.MIME_PLAIN_XML) && |
163 |
!hasMultiTextEditor()) { |
164 |
return super.createCloneableEditor(); |
165 |
} |
157 |
return (CloneableEditorSupport.Pane)MultiViews.createCloneableMultiView(mimeType, |
166 |
return (CloneableEditorSupport.Pane)MultiViews.createCloneableMultiView(mimeType, |
158 |
getDataObject()); |
167 |
getDataObject()); |
159 |
} |
168 |
} |
160 |
|
169 |
|
|
|
170 |
/** |
171 |
* Detects whether XML source editor is registered: must start with 'xml.text'. If |
172 |
* a module registers such multiview, it's responsible for displaying source in this |
173 |
* pane. |
174 |
* |
175 |
* @return true, if multiview source editor is available and multiview pane should be created |
176 |
*/ |
177 |
boolean hasMultiTextEditor() { |
178 |
Collection<? extends MultiViewDescription> all = MimeLookup.getLookup(mimeType).lookupAll(MultiViewDescription.class); |
179 |
for (MultiViewDescription d : all) { |
180 |
if (d.preferredID().startsWith("xml.text")) { |
181 |
return true; |
182 |
} |
183 |
} |
184 |
return false; |
185 |
} |
186 |
|
161 |
/* |
187 |
/* |
162 |
* Add listeners at Document and document memory status (loading). |
188 |
* Add listeners at Document and document memory status (loading). |
163 |
*/ |
189 |
*/ |