本文整理汇总了Java中org.netbeans.api.editor.mimelookup.MimeLookup.getLookup方法的典型用法代码示例。如果您正苦于以下问题:Java MimeLookup.getLookup方法的具体用法?Java MimeLookup.getLookup怎么用?Java MimeLookup.getLookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.editor.mimelookup.MimeLookup
的用法示例。
在下文中一共展示了MimeLookup.getLookup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRemovingMimeDataProvider
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
private <T> void checkRemovingMimeDataProvider(String instanceFile, Class<T> markerClass) throws Exception {
TestUtilities.createFile(getWorkDir(), instanceFile);
TestUtilities.sleepForWhile();
MimePath path = MimePath.get("text/x-java");
Lookup lookup = MimeLookup.getLookup(path);
Collection markers = lookup.lookupAll(markerClass);
assertEquals("No markers found", 1, markers.size());
TestUtilities.deleteFile(getWorkDir(), instanceFile);
TestUtilities.sleepForWhile();
markers = lookup.lookupAll(markerClass);
assertEquals("There should be no markers", 0, markers.size());
}
示例2: testLookupsGCedAfterKbs
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
public void testLookupsGCedAfterKbs() {
MimePath mimePath = MimePath.parse("text/x-type-A");
KeyBindingSettingsImpl kbsi = KeyBindingSettingsImpl.get(mimePath);
Lookup lookup = MimeLookup.getLookup(mimePath);
KeyBindingSettings kbs = lookup.lookup(KeyBindingSettings.class);
WeakReference<KeyBindingSettingsImpl> kbsiRef = new WeakReference<KeyBindingSettingsImpl>(kbsi);
WeakReference<MimePath> mimePathRef = new WeakReference<MimePath>(mimePath);
WeakReference<Lookup> lookupRef = new WeakReference<Lookup>(lookup);
WeakReference<KeyBindingSettings> kbsRef = new WeakReference<KeyBindingSettings>(kbs);
kbsi = null;
mimePath = null;
lookup = null;
kbs = null;
// release text/x-type-A from MimePath's LRU
for(int i = 0; i < 10; i++) {
MimePath.parse("text/x-type-" + ('Z' + i));
}
assertGC("KBSI hasn't been GCed", kbsiRef);
assertGC("MimePath hasn't been GCed", mimePathRef);
assertGC("Lookup hasn't been GCed", lookupRef);
assertGC("KBS hasn't been GCed", kbsRef);
}
示例3: getLookup
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
/** This method is here to simulate that it is possible to get
* instance of the lookup without querying any of registered InstanceProvider.
* They could acquire AWT lock and that can cause deadlocks.
*/
private Lookup getLookup(final MimePath path) throws Exception {
class BlockAWTLock implements Runnable {
Lookup l;
public void run() {
l = MimeLookup.getLookup(path);
}
}
BlockAWTLock b = new BlockAWTLock();
synchronized (PopupActions.LOCK) {
SwingUtilities.invokeAndWait(b);
}
return b.l;
}
示例4: testColoringsForMimeType
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
public void testColoringsForMimeType() throws Exception {
final String mimeType = "text/x-orig";
Lookup lookup = MimeLookup.getLookup(MimePath.parse(mimeType));
// Check the API class
Collection<? extends FontColorSettings> c = lookup.lookupAll(FontColorSettings.class);
assertEquals("Wrong number of fcs", 1, c.size());
FontColorSettings fcs = c.iterator().next();
assertNotNull("FCS should not be null", fcs);
assertTrue("Wrong fcs impl", fcs instanceof CompositeFCS);
CompositeFCS compositeFcs = (CompositeFCS) fcs;
assertEquals("CompositeFCS using wrong profile", EditorSettingsImpl.DEFAULT_PROFILE, compositeFcs.profile);
}
示例5: testLookupsGCedAfterFcs
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
public void testLookupsGCedAfterFcs() {
MimePath mimePath = MimePath.parse("text/x-type-A");
FontColorSettingsImpl fcsi = FontColorSettingsImpl.get(mimePath);
Lookup lookup = MimeLookup.getLookup(mimePath);
FontColorSettings fcs = lookup.lookup(FontColorSettings.class);
WeakReference<FontColorSettingsImpl> fcsiRef = new WeakReference<FontColorSettingsImpl>(fcsi);
WeakReference<MimePath> mimePathRef = new WeakReference<MimePath>(mimePath);
WeakReference<Lookup> lookupRef = new WeakReference<Lookup>(lookup);
WeakReference<FontColorSettings> fcsRef = new WeakReference<FontColorSettings>(fcs);
fcsi = null;
mimePath = null;
lookup = null;
fcs = null;
// release text/x-type-A from MimePath's LRU
for(int i = 0; i < 10; i++) {
MimePath.parse("text/x-type-" + ('Z' + i));
}
assertGC("FCSI hasn't been GCed", fcsiRef);
assertGC("MimePath hasn't been GCed", mimePathRef);
assertGC("Lookup hasn't been GCed", lookupRef);
assertGC("FCS hasn't been GCed", fcsRef);
}
示例6: getDefaultAccelerator
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
@Override
protected KeyStroke getDefaultAccelerator(){
Lookup ml = MimeLookup.getLookup(MimePath.EMPTY); //NOI18N
KeyBindingSettings kbs = (KeyBindingSettings) ml.lookup(KeyBindingSettings.class);
if (kbs != null){
List lst = kbs.getKeyBindings();
if (lst != null){
for (int i=0; i<lst.size(); i++){
MultiKeyBinding mkb = (MultiKeyBinding)lst.get(i);
String an = mkb.getActionName();
if (an != null && an.equals(getActionName())){
if (mkb.getKeyStrokeCount() == 1){// we do not support multi KB in mnemonics
return mkb.getKeyStroke(0);
}
}
}
}
}
return null;
}
示例7: testClassLookuping
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
public void testClassLookuping() throws IOException{
MimePath mp = MimePath.parse("text/x-java/text/html/text/xml");
Lookup lookup = MimeLookup.getLookup(mp);
PopupActions popup = (PopupActions) lookup.lookup(PopupActions.class);
List list = popup.getPopupActions();
checkPopupItemPresence(lookup, RenameAction.class, true);
gc();
int size = assertSize("", Arrays.asList( new Object[] {lookup} ), 10000000, getFilter());
for (int i=0; i<30; i++){
popup = (PopupActions) lookup.lookup(PopupActions.class);
list = popup.getPopupActions();
checkPopupItemPresence(lookup, RenameAction.class, true);
}
gc();
assertSize("", size + 20, lookup);
}
示例8: getRegisteredExtensions
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
public static Collection<? extends HtmlExtension> getRegisteredExtensions(String mimeType) {
if(TEST_EXTENSION != null) {
return Collections.singleton(TEST_EXTENSION);
}
Lookup lookup = MimeLookup.getLookup(mimeType);
return lookup.lookupAll(HtmlExtension.class);
}
示例9: checkAddingMimeDataProvider
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
private <T> void checkAddingMimeDataProvider(String instanceFile, Class<T> markerClass) throws Exception {
MimePath path = MimePath.get("text/x-java");
Lookup lookup = MimeLookup.getLookup(path);
Collection markers = lookup.lookupAll(markerClass);
assertEquals("There should be no markers", 0, markers.size());
// Add the data provider
TestUtilities.createFile(getWorkDir(), instanceFile);
TestUtilities.sleepForWhile();
markers = lookup.lookupAll(markerClass);
assertEquals("No markers found", 1, markers.size());
}
示例10: findKit
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
private EditorKit findKit(String mimeType) {
if (!MimePath.validate(mimeType)) // #146276 - exclude invalid mime paths
return null;
Lookup lookup = MimeLookup.getLookup(MimePath.parse(mimeType));
EditorKit kit = (EditorKit) lookup.lookup(EditorKit.class);
return kit == null ? null : (EditorKit) kit.clone();
}
示例11: run
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
@Override
public void run() {
// System.out.println("T1 running");
MimePath path = MimePath.get("text/x-java");
Lookup lookup = MimeLookup.getLookup(path);
lookup.lookup(Task1.class);
// System.out.println("T1 done");
done = true;
}
示例12: checkSingleAttribute
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
private void checkSingleAttribute(String coloringName, Object attributeKey, int rgb) {
MimePath mimePath = MimePath.parse("text/x-type-A");
Lookup lookup = MimeLookup.getLookup(mimePath);
FontColorSettings fcs = lookup.lookup(FontColorSettings.class);
assertNotNull("Can't find FontColorSettings", fcs);
AttributeSet attribs = fcs.getTokenFontColors(coloringName);
assertNotNull("Can't find " + coloringName + " coloring", attribs);
assertEquals("Wrong " + attributeKey, new Color(rgb), attribs.getAttribute(attributeKey));
}
示例13: setBackgroundColorForNonEditable
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
private void setBackgroundColorForNonEditable(JTextComponent leftEditor,
JTextComponent rightEditor) {
String mimeType = DocumentUtilities.getMimeType(leftEditor);
if (mimeType == null) {
mimeType = CONTENT_TYPE_PLAIN; //NOI18N
}
Color bgColor = null;
Lookup lookup = MimeLookup.getLookup(mimeType);
if (lookup != null) {
FontColorSettings fontColorSettings = lookup.lookup(FontColorSettings.class);
if (fontColorSettings != null) {
AttributeSet attrSet = fontColorSettings.getFontColors(
FontColorNames.GUARDED_COLORING);
if (attrSet != null) {
Object bgColorObj = attrSet.getAttribute(StyleConstants.Background);
if (bgColorObj instanceof Color) {
bgColor = (Color) bgColorObj;
}
}
}
}
if (bgColor == null) {
/* Fallback to the old routine: */
int editableBgColor = rightEditor.getBackground().getRGB() & 0xFFFFFF;
if ((editableBgColor == 0xFFFFFF)
&& System.getProperty("netbeans.experimental.diff.ReadonlyBg") == null) { //NOI18N
bgColor = COLOR_READONLY_BG;
}
}
if (bgColor != null) {
leftEditor.setBackground(bgColor);
}
}
示例14: checkSingleAttribute
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
private void checkSingleAttribute(MimePath mimePath, String coloringName, Object attributeKey, Object attributeValue) {
Lookup lookup = MimeLookup.getLookup(mimePath);
FontColorSettings fcs = lookup.lookup(FontColorSettings.class);
assertNotNull("Can't find FontColorSettings", fcs);
AttributeSet attribs = fcs.getTokenFontColors(coloringName);
assertNotNull("Can't find " + coloringName + " coloring", attribs);
assertEquals("Wrong value of '" + attributeKey + "'", attributeValue, attribs.getAttribute(attributeKey));
}
示例15: createFrom
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
/**
* Factory method for obtaining a {@linkplain JavaProfilerSource} from a file or NULL
* @return Returns a {@linkplain JavaProfilerSource} instance or NULL
*/
public static JavaProfilerSource createFrom(FileObject fo) {
if (fo == null || !fo.isValid()) return null;
Lookup lkp = MimeLookup.getLookup(fo.getMIMEType());
AbstractJavaProfilerSource impl = lkp.lookup(AbstractJavaProfilerSource.class);
if (impl == null && fo.isData() && fo.hasExt("java")) // NOI18N
impl = Lookup.getDefault().lookup(AbstractJavaProfilerSource.class);
if (impl == null) {
return null;
}
return new JavaProfilerSource(fo, impl);
}