public Object instanceCreate () throws java.io.IOException, ClassNotFoundException { return ic.instanceCreate (); }
/** Method that is called when a the folder instance really wants to * create an object from provided cookie. * It allows subclasses to overwrite the default behaviour (which is * to call {@link InstanceCookie#instanceCreate}). * * @param obj the data object that is the source of the cookie * @param cookie the instance cookie to read the instance from * @exception IOException when there I/O error * @exception ClassNotFoundException if the class cannot be found */ protected Object instanceForCookie (DataObject obj, InstanceCookie cookie) throws IOException, ClassNotFoundException { return cookie.instanceCreate (); }
public Object instanceCreate () throws java.io.IOException, ClassNotFoundException { InstanceCookie delegateIC = delegateIC (); if (delegateIC == null) return this; return delegateIC.instanceCreate (); }
/** The class of the result item. * @return the instance of the object or null if it cannot be created */ public Object getInstance() { init (); try { Object obj = ic.instanceCreate(); ref = new WeakReference (obj); return obj; } catch (ClassNotFoundException ex) { exception(ex, fo); } catch (IOException ex) { exception(ex, fo); } return null; }
/*package*/ static <T> T createInstance(FileObject instanceFileObject, Class<T> clazz) { if (instanceFileObject != null) { try { DataObject dataObject = DataObject.find(instanceFileObject); InstanceCookie instanceCookie = dataObject.getCookie(InstanceCookie.class); if (instanceCookie != null) { return clazz.cast(instanceCookie.instanceCreate()); } } catch (DataObjectNotFoundException ex) { Exceptions.printStackTrace(ex); } catch (IOException ex) { Exceptions.printStackTrace(ex); } catch (ClassNotFoundException ex) { Exceptions.printStackTrace(ex); } catch (ClassCastException ex) { Exceptions.printStackTrace(ex); } } return null; }
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 Object createInstance(InstanceCookie[] cookies) throws java.io.IOException, ClassNotFoundException { List<Object> installers = new ArrayList<Object>(cookies.length); for (int i = 0; i < cookies.length; i++) { InstanceCookie cake = cookies[i]; Object o = null; try { if (cake instanceof InstanceCookie.Of && !((((InstanceCookie.Of)cake).instanceOf(PlatformInstall.class)) || (((InstanceCookie.Of)cake).instanceOf(CustomPlatformInstall.class)))) continue; o = cake.instanceCreate(); } catch (IOException ex) { } catch (ClassNotFoundException ex) { } if (o != null) installers.add(o); } return installers; } }
Object bean = ic.instanceCreate(); return (String) nameGetter.invoke (bean, null); } catch (Exception ex) {
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; } }
/** Overrides superclass method. It returns instance * for <code>DataObject</code>&<code>InstanceCookie</code> 'pair'. * If the instance is of <code>FolderLookup.Lkp</code> class it is created otherwise * new <code>Lkp.ICItem</code> created and returned. * * @param dobj the data object that is the source of the cookie * @param cookie the instance cookie to read the instance from * @exception IOException when there I/O error * @exception ClassNotFoundException if the class cannot be found */ protected Object instanceForCookie(DataObject dobj, InstanceCookie cookie) throws IOException, ClassNotFoundException { boolean isLookup; if(cookie instanceof InstanceCookie.Of) { isLookup = ((InstanceCookie.Of)cookie).instanceOf(Lookup.class); } else { isLookup = Lookup.class.isAssignableFrom(cookie.instanceClass ()); } if(isLookup) { // Is underlying FolderLookup create it. return cookie.instanceCreate(); } else { return new ICItem(dobj, rootName, cookie); } }
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; }
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); } }
/** try to register PropertyChangeListener to instance to fire its changes.*/ private void initPList () { try { InstanceCookie ic = ic(); if (ic == null) return; BeanInfo info = Utilities.getBeanInfo(ic.instanceClass()); java.beans.EventSetDescriptor[] descs = info.getEventSetDescriptors(); Method setter = null; for (int i = 0; descs != null && i < descs.length; i++) { setter = descs[i].getAddListenerMethod(); if (setter != null && setter.getName().equals("addPropertyChangeListener")) { // NOI18N Object bean = ic.instanceCreate(); propertyChangeListener = new PropL(); setter.invoke(bean, new Object[] {org.openide.util.WeakListeners.propertyChange(propertyChangeListener, bean)}); } } } catch (Exception ex) { } catch (LinkageError ex) { // #30650 - catch also LinkageError. // Ignoring exception the same way as the Exception handler above. } }
/** 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); } } } }
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; }
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); }
private JavaPlatform getDefaultPlatformByHint() { final FileObject storage = getStorage(); if (storage != null) { for (final FileObject defFile : storage.getChildren()) { if (defFile.getAttribute(DEFAULT_PLATFORM_ATTR) == Boolean.TRUE) { try { DataObject dobj = DataObject.find(defFile); //xxx: Using old good DO.getCookie as Lookup does not work. final InstanceCookie ic = dobj.getCookie(InstanceCookie.class); if (ic != null) { final Object instance = ic.instanceCreate(); if (instance instanceof JavaPlatform && isDefaultPlatform((JavaPlatform)instance)) { return (JavaPlatform) instance; } } } catch (IOException e) { //pass -> return null } catch (ClassNotFoundException e) { //pass -> return null } return null; } } } return null; }
protected DataObject handleCopy(DataFolder df) throws IOException { try { if (getPrimaryFile ().hasExt(XML_EXT)) { InstanceCookie ic = (InstanceCookie)getCookie(InstanceCookie.class); if (ic != null) { Object obj = ic.instanceCreate(); InstanceDataObject ido = createSettingsFile( df, getNodeDelegate().getDisplayName(), obj); ido.attachToConvertor(null); return ido; } } else if ( (!getPrimaryFile().hasExt(INSTANCE)) && Serializable.class.isAssignableFrom(instanceClass()) ) { InstanceCookie ic = (InstanceCookie)getCookie(InstanceCookie.class); if (ic != null) { Object obj = ic.instanceCreate(); return DataObject.find(createSerFile( df, getNodeDelegate().getDisplayName(), obj)); } } } catch (ClassNotFoundException ex) { inform(ex); } return super.handleCopy(df); }