/** * Determine if the given model is writable, which requires that the * source file also be writable. * * @param model the model to be tested. * @return true if model source is editable and the source file is writable. */ public static boolean isWritable(Model model) { if (model != null) { ModelSource ms = model.getModelSource(); if (ms.isEditable()) { FileObject fo = (FileObject) ms.getLookup().lookup(FileObject.class); if (fo != null) { return fo.canWrite(); } } } return false; } }
Model model = comp.getModel(); if (model != null) { FileObject fobj = (FileObject) model.getModelSource(). getLookup().lookup(FileObject.class); if (fobj != null) {
ns = getTargetNamespace(model); if (model != getModelComponent().getModel()) { referencedFO = (FileObject) model.getModelSource(). getLookup().lookup(FileObject.class);
/** * Creates new form ExternalReferenceCustomizer * * @param component external reference to customize. */ public ExternalReferenceCustomizer(T component, Model model) { super(component); initComponents(); sourceFO = (FileObject) component.getModel().getModelSource(). getLookup().lookup(FileObject.class); catalogSupport = DefaultProjectCatalogSupport.getInstance(sourceFO); init(component, model); initializeUI(); // View for selecting an external reference. BeanTreeView locationView = new BeanTreeView(); locationView.setPopupAllowed(false); locationView.setDefaultActionAllowed(false); locationView.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); locationView.setRootVisible(false); locationView.getAccessibleContext().setAccessibleName(locationLabel.getToolTipText()); locationView.getAccessibleContext().setAccessibleDescription(locationLabel.getToolTipText()); locationPanel.add(locationView, BorderLayout.CENTER); explorerManager = new ExplorerManager(); explorerManager.addPropertyChangeListener(this); explorerManager.setRootContext(createRootNode()); }
registeredNodes = new HashMap<DataObject, NodeSet>(); initComponents(); sourceFO = (FileObject) component.getModel().getModelSource(). getLookup().lookup(FileObject.class); catalogSupport = DefaultProjectCatalogSupport.getInstance(sourceFO);
public void applyChanges() throws IOException { List<Node> nodes = getSelectedNodes(); for (Node node : nodes) { if (node instanceof ExternalReferenceNode) { Model model = ((ExternalReferenceNode) node).getModel(); // Without a model, the selection is completely invalid. if (model != null && model != getModelComponent().getModel()) { FileObject fileObj = (FileObject) model.getModelSource(). getLookup().lookup(FileObject.class); if (fileObj != null) { try { if (catalogSupport.needsCatalogEntry(sourceFO, fileObj)) { // Remove the previous catalog entry, then create new one. URI uri = catalogSupport.getReferenceURI(sourceFO, fileObj); catalogSupport.removeCatalogEntry(uri); catalogSupport.createCatalogEntry(sourceFO, fileObj); } } catch (URISyntaxException use) { ErrorManager.getDefault().notify(use); } catch (IOException ioe) { ErrorManager.getDefault().notify(ioe); } catch (CatalogModelException cme) { ErrorManager.getDefault().notify(cme); } } } } } }