Refine search
public static InstrumentAVK getAVKImplemenation() { InstrumentAVK avkSupport = null; FileObject dir = FileUtil.getConfigFile(DIR_EXTENSION); FileObject[] ch =null; if(dir!=null){ ch = dir.getChildren(); } if(ch != null){ for(int i = 0; i < ch.length; i++) { try{ DataObject dobj = DataObject.find(ch[i]); InstanceCookie cookie = (InstanceCookie) dobj.getCookie(InstanceCookie.class); if(cookie != null) { avkSupport = (InstrumentAVK)cookie.instanceCreate(); } } catch (Exception e){ //Unable to find AVK } } } return avkSupport; }
public boolean canCut() { if (!getDataObject().getPrimaryFile().hasExt(XML_EXT)) return super.canCut(); try { InstanceCookie ic = ic(); if (ic == null) return false; Class clazz = ic.instanceClass(); return (!SharedClassObject.class.isAssignableFrom(clazz)); } catch (Exception ex) { return false; } }
/** Full name of the data folder's primary file separated by dots. * @return the name */ public String instanceName () { return cookie.instanceName (); }
"LBL_BrokenSettings"); //NOI18N Class clazz = ic.instanceClass(); Method nameGetter; Class[] param = new Class [0]; Object bean = ic.instanceCreate(); return (String) nameGetter.invoke (bean, null); } catch (Exception ex) {
name = fo.getName(); FileObject descriptor = fo.getFileObject("Descriptor"); assert descriptor != null; needsFindServerUI = getBooleanValue(descriptor.getAttribute(ATTR_NEEDS_FIND_SERVER_UI), false); dep = NetbeansDeployment.createGraph(descriptor.getInputStream()); return; DataObject dobj = DataObject.find(factoryinstance); InstanceCookie cookie = (InstanceCookie) dobj.getCookie(InstanceCookie.class); if (cookie == null) { String msg = NbBundle.getMessage(Server.class, "MSG_FactoryFailed", name); return; factoryCls = cookie.instanceClass(); factory = (DeploymentFactory) cookie.instanceCreate(); } catch (Exception e) { LOGGER.log(Level.INFO, null, e);
/** search all data objects containing service type instance. */ private void searchServices(FileObject folder, Map<ServiceType,DataObject> services) { FileObject[] fobjs = folder.getChildren(); for (int i = 0; i < fobjs.length; i++) { if (!fobjs[i].isValid()) continue; if (fobjs[i].isFolder()) { searchServices(fobjs[i], services); } else { try { DataObject dobj = DataObject.find(fobjs[i]); InstanceCookie inst = (InstanceCookie) dobj.getCookie(InstanceCookie.class); if (inst == null) continue; if (instanceOf(inst, ServiceType.class)) { ServiceType ser = (ServiceType) inst.instanceCreate(); services.put(ser, dobj); } } catch (DataObjectNotFoundException ex) { } catch (Exception ex) { Logger.getLogger(Services.class.getName()).log(Level.WARNING, null, ex); } } } }
if (storage != null) { java.util.Map<String,PlatformCategoriesDescriptor> categories = new HashMap<String,PlatformCategoriesDescriptor>(); for (FileObject child : storage.getChildren()) { try { final DataObject dobj = DataObject.find(child); Node node = dobj.getNodeDelegate(); JavaPlatform platform = node.getLookup().lookup(JavaPlatform.class); if (platform == null) { final InstanceCookie ic = dobj.getLookup().lookup(InstanceCookie.class); if (ic != null) { try { final Object instance = ic.instanceCreate(); if (instance instanceof JavaPlatform) { node = new FilterNode (new BeanNode(instance), Children.LEAF, Lookups.singleton(instance));
private static String getInstanceLabel(FileObject fo) { try { InstanceCookie ic = DataObject.find(fo).getLookup().lookup(InstanceCookie.class); if (ic != null) { final Object o; o = ic.instanceCreate(); if (o instanceof Action) { String name = Mutex.EVENT.readAccess(new Mutex.ExceptionAction<String>() { String clazz = (String) fo.getAttribute("instanceClass"); // NOI18N if (clazz == null) { clazz = fo.getName().replace('-', '.'); String instanceCreate = (String) fo.getAttribute("literal:instanceCreate"); // NOI18N if (instanceCreate != null && instanceCreate.startsWith("new:")) { // NOI18N clazz = instanceCreate.substring("new:".length()); // NOI18N
synchronized Action loadAction() { assert actionDefinition != null; if (action == null) { try { DataObject d = DataObject.find(actionDefinition); InstanceCookie ic = d.getLookup().lookup(InstanceCookie.class); if (ic == null) { return null; } action = (Action) ic.instanceCreate(); } catch (/*ClassNotFoundException,IOException,ClassCastException*/Exception x) { LOG.log(Level.INFO, "could not load action for " + actionDefinition.getPath(), x); } } if (action == null) { action = BROKEN; } return action; } }
FileObject[] ch =null; if(dir!=null){ ch = dir.getChildren(); nbextraoptions = ch.length; for(int i = 0; i < nbextraoptions; i++) { try{ DataObject dobj = DataObject.find(ch[i]); InstanceCookie cookie = (InstanceCookie) dobj.getCookie(InstanceCookie.class); newActions[a+i]=null; Class theActionClass = cookie.instanceClass(); String attr = (String) ch[i].getAttribute("8.x");//NOI18N if (attr==null ){ //not extra attr defined: add the action newActions[a+i]=(SystemAction.get(theActionClass));
private void applyShortcuts() { if (!termOptions.getIgnoreKeymap()) { Set<String> actions = new HashSet<String>(); for (FileObject def : shortcutsDir.getChildren()) { try { DataObject dobj = DataObject.find(def); InstanceCookie ic = dobj.getLookup().lookup(InstanceCookie.class); if (ic != null) { // put class names in the map, // otherwise we may end with several instances of the action actions.add(ic.instanceCreate().getClass().getName()); } } catch (Exception e) { Exceptions.printStackTrace(e); } } term.setKeymap(Lookup.getDefault().lookup(Keymap.class), actions); // needed for Ctrl+Tab, Ctrl+Shift+Tab switching term.getScreen().setFocusTraversalKeysEnabled(false); } else { term.setKeymap(null, null); term.getScreen().setFocusTraversalKeysEnabled(true); } }
private static boolean isExternal( HtmlBrowser.Factory brow ) { // check if it is not set to be hidden FileObject fo = FileUtil.getConfigFile ("Services/Browsers"); // NOI18N DataFolder folder = DataFolder.findFolder (fo); DataObject [] dobjs = folder.getChildren (); for (int i = 0; i < dobjs.length; i++) { Object o = null; try { if (Boolean.TRUE.equals (dobjs[i].getPrimaryFile ().getAttribute ("hidden"))) continue; if (!Boolean.TRUE.equals (dobjs[i].getPrimaryFile ().getAttribute ("internal")) ) continue; InstanceCookie cookie = (InstanceCookie) dobjs[i].getCookie (InstanceCookie.class); if (cookie == null) continue; o = cookie.instanceCreate (); if (o != null && o.equals (brow)) { return false; } } // exceptions are thrown if module is uninstalled catch (java.io.IOException ex) { Logger.getLogger (IDESettings.class.getName ()).log (Level.WARNING, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger (IDESettings.class.getName ()).log (Level.WARNING, null, ex); } } return false; }
public static Action findAction( String key ) { FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource(key); if (fo != null && fo.isValid()) { try { DataObject dob = DataObject.find(fo); InstanceCookie ic = dob.getCookie(InstanceCookie.class); if (ic != null) { Object instance = ic.instanceCreate(); if (instance instanceof Action) { Action a = (Action) instance; return a; } } } catch (Exception e) { Logger.getLogger(ExistingWizardIterator.class.getName()).log(Level.WARNING, e.getMessage(), e); return null; } } return null; }
String mimeType = getDataObject().getPrimaryFile().getMIMEType(); InstanceCookie ic = dob[i].getCookie(InstanceCookie.class); Class clazz = ic.instanceClass(); actions.add((Action)ic.instanceCreate());
private static Rule instantiateRule( FileObject fileObject ) { try { DataObject dobj = DataObject.find(fileObject); InstanceCookie ic = dobj.getCookie( InstanceCookie.class ); Object instance = ic.instanceCreate(); if (instance instanceof Rule) { return (Rule) instance; } else { return null; } } catch( IOException e ) { LOG.log(Level.INFO, null, e); } catch ( ClassNotFoundException e ) { LOG.log(Level.INFO, null, e); } return null; }
protected DataObject handleCreateFromTemplate ( DataFolder df, String name ) throws IOException { try { if (getPrimaryFile().hasExt(XML_EXT)) { InstanceCookie ic = (InstanceCookie)this.getCookie(InstanceCookie.class); Object obj = ic.instanceCreate(); DataObject d = createSettingsFile(df, name, obj); // reset template instance to null attachToConvertor(null); return d; } else if ( (!getPrimaryFile().hasExt(INSTANCE)) && Serializable.class.isAssignableFrom( instanceClass()) ) { InstanceCookie ic = (InstanceCookie)this.getCookie(InstanceCookie.class); Object obj = ic.instanceCreate(); return DataObject.find( createSerFile( df, name, obj ) ); } } catch (ClassNotFoundException ex) { inform(ex); } return super.handleCreateFromTemplate(df, name); }
public void setName(String name) { if (!getDataObject().getPrimaryFile().hasExt(XML_EXT)) { super.setName(name); return ; } String old = getNameImpl(); if (old != null && old.equals(name)) return; InstanceCookie ic = ic(); if (ic == null) { super.setName(name); return; } Method nameSetter = getDeclaredSetter(); if (nameSetter != null) { try { Object bean = ic.instanceCreate(); nameSetter.invoke(bean, new Object[] {name}); i().scheduleSave(); } catch (Exception ex) { } } super.setName(name); }
/** Gets the short description of this feature. */ public String getShortDescription() { if (noBeanInfo) return super.getShortDescription(); try { InstanceCookie ic = ic(); if (ic == null) { // it must be unrecognized instance return getDataObject().getPrimaryFile().toString(); } Class clazz = ic.instanceClass(); java.beans.BeanDescriptor bd = Utilities.getBeanInfo(clazz).getBeanDescriptor(); String desc = bd.getShortDescription(); return (desc.equals(bd.getName()))? getDisplayName(): desc; } catch (Exception ex) { return super.getShortDescription(); } catch (LinkageError ex) { // #30650 - catch also LinkageError. return super.getShortDescription(); } }
private static Children getChildren(DataObject dobj, boolean noBeanInfo) { if (noBeanInfo) { return Children.LEAF; } InstanceCookie inst = (InstanceCookie)dobj.getCookie(InstanceCookie.class); if (inst == null) return Children.LEAF; try { Class clazz = inst.instanceClass(); if (BeanContext.class.isAssignableFrom(clazz) || BeanContextProxy.class.isAssignableFrom(clazz)) { return new InstanceChildren ((InstanceDataObject) dobj); } else { return Children.LEAF; } } catch (Exception ex) { return Children.LEAF; } }
public Object instanceCreate () throws java.io.IOException, ClassNotFoundException { return ic.instanceCreate (); }