Lines 43-53
Link Here
|
43 |
import java.beans.PropertyChangeEvent; |
43 |
import java.beans.PropertyChangeEvent; |
44 |
import java.beans.PropertyChangeListener; |
44 |
import java.beans.PropertyChangeListener; |
45 |
import java.lang.ref.WeakReference; |
45 |
import java.lang.ref.WeakReference; |
46 |
import javax.swing.text.Document; |
46 |
import org.openide.filesystems.FileObject; |
47 |
import org.netbeans.modules.css.editor.CssEditorSupport; |
47 |
import org.netbeans.modules.css.editor.CssEditorSupport; |
48 |
import org.netbeans.modules.css.visual.api.StyleBuilderTopComponent; |
48 |
import org.netbeans.modules.css.visual.api.StyleBuilderTopComponent; |
49 |
import org.openide.cookies.EditorCookie; |
|
|
50 |
import org.openide.util.Lookup; |
51 |
import org.openide.util.WeakListeners; |
49 |
import org.openide.util.WeakListeners; |
52 |
import org.openide.windows.TopComponent; |
50 |
import org.openide.windows.TopComponent; |
53 |
import org.openide.windows.TopComponent.Registry; |
51 |
import org.openide.windows.TopComponent.Registry; |
Lines 124-132
Link Here
|
124 |
if(tc == null) { |
122 |
if(tc == null) { |
125 |
return false; |
123 |
return false; |
126 |
} |
124 |
} |
127 |
Document doc = getDocument(tc); |
125 |
FileObject fob = tc.getLookup().lookup(FileObject.class); |
128 |
if (doc != null) { |
126 |
if (fob != null) { |
129 |
String mimeType = (String) doc.getProperty("mimeType"); |
127 |
String mimeType = (String) fob.getMIMEType(); |
130 |
if (mimeType != null && "text/x-css".equals(mimeType)) { |
128 |
if (mimeType != null && "text/x-css".equals(mimeType)) { |
131 |
return true; |
129 |
return true; |
132 |
} |
130 |
} |
Lines 134-152
Link Here
|
134 |
return false; |
132 |
return false; |
135 |
} |
133 |
} |
136 |
|
134 |
|
137 |
private Document getDocument(TopComponent tc) { |
|
|
138 |
Lookup lookup = tc.getLookup(); //should be always non null unless someone overrides the TC |
139 |
if(lookup == null) { |
140 |
return null; |
141 |
} |
142 |
EditorCookie ec = lookup.lookup(EditorCookie.class); |
143 |
if (ec != null) { |
144 |
return ec.getDocument(); |
145 |
} else { |
146 |
return null; |
147 |
} |
148 |
} |
149 |
|
150 |
private void previewableActivated(TopComponent tc) { |
135 |
private void previewableActivated(TopComponent tc) { |
151 |
this.lastCSSTC = tc; |
136 |
this.lastCSSTC = tc; |
152 |
WindowManager.getDefault().findTopComponentGroup("Csswsgrp").open(); |
137 |
WindowManager.getDefault().findTopComponentGroup("Csswsgrp").open(); |