private String getName(SchemaComponent component) { if (component instanceof Named) { return ((Named) component).getName(); } return ""; }
@Override public WebBeansModel getModel(ModelSource source) { return (WebBeansModel) super.getModel(source); }
/** * Return the model of the component being customized. * * @return component model. */ public Model getComponentModel() { return getModelComponent().getModel(); }
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); } } } } } }
/** * 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) { DataObject dobj = DataObject.find(fobj); ViewComponentCookie cake = (ViewComponentCookie) dobj. getCookie(ViewComponentCookie.class); if (cake != null && cake.canView(view, comp)) { return cake;
/** * Guarantees transaction */ public void apply() throws IOException { Model model = component.getModel(); // It is possible that current component is not in model, // or a transaction already exists, so don't start transaction. boolean startTransaction = model != null && !model.isIntransaction(); if (startTransaction) { model.startTransaction(); } try { applyChanges(); setSaveEnabled(false); setResetEnabled(false); } finally { if (startTransaction) { model.endTransaction(); } } }
public OccurrenceItem(JSFConfigComponent component, String newValue, String oldValue, String name) { this(null, component , newValue, oldValue , name ); this.config = component.getModel().getModelSource().getLookup(). lookup(FileObject.class); }
/** * Indicates if the given name (possibly provided by the user) is a * valid name for this component. Ensures that the name is unique * among the siblings of this component, that are of the same type. * * @param name name to validate. * @return true if name is okay, false otherwise. */ protected boolean isNameValid(String name) { T comp = getModelComponent(); if (!(comp instanceof Nameable)) { return true; } if (name == null || name.trim().length() == 0) { return false; } Iterator iter = comp.getParent().getChildren().iterator(); while (iter.hasNext()) { Object child = iter.next(); if (child instanceof Nameable) { Nameable named = (Nameable) child; if (name.equals(named.getName())) { return false; } } } return true; }
/** * Return the target namespace of the model that contains the * component being customized. * * @return target namespace, or null if none. */ public String getTargetNamespace() { return getTargetNamespace(getModelComponent().getModel()); }
public boolean isEditable() { return XAMUtils.isWritable(component.getModel()); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = inflater.inflate(R.layout.single_row, null, false); TextView tv = (TextView) view.findViewById(R.id.content); CheckedTextView ctv = (CheckedTextView) view.findViewById(R.id.checker); Model m = backingsource.get(position); tv.setText(m.getData()); ctv.setChecked(m.getState()); return view; }
/** * Sync the Model so it does not perform the auto-sync at some * later time, causing additional undoable edits from appearing * on the undo queue. That would be pointless anyway, since we * are simply undoing or redoing edits anyway. */ private void syncModel() { if (model != null) { try { // Fortunately this method is efficient in that it knows // if the change that occurred was done by the model or // if the change is coming from the document (the model // has a document listener on the Swing document). model.sync(); for(Model m: otherModels) m.sync(); } catch (IOException ioe) { // Ignore, nothing we can do about it. } } }
/** * Wrap up after performing an undo/redo operation. * * @param listeners undoable edit listeners to be added to document. */ private void finish(UndoableEditListener[] listeners) { if (model != null) { // When model is non-null, add ourselves as a listener since // we removed us in the preparation step. model.addUndoableEditListener(this); } if (listeners != null && listeners.length > 0) { for (UndoableEditListener uel : listeners) { document.addUndoableEditListener(uel); } } }
/** * Prepare to perform an undo/redo operation. * * @return the set of undoable edit listeners removed from document. */ private UndoableEditListener[] prepare() { if (model != null) { // If the model is set, that means we are to sync the model // after performing the undo/redo operation. That, however, // means we cannot be listening to the model lest we receive // additional undoable edits, which would be bad. model.removeUndoableEditListener(this); } if (document == null) { return null; } UndoableEditListener[] listeners = document.getUndoableEditListeners(); if (listeners != null && listeners.length > 0) { for (UndoableEditListener uel : listeners) { document.removeUndoableEditListener(uel); } } return listeners; }
private String getName(SchemaComponent component) { if (component instanceof Named) { return ((Named) component).getName(); } return ""; }
public JSFConfigModel getModel(ModelSource source) { return (JSFConfigModel) super.getModel(source); }
public String getName() { return ((Named)mElement).getName(); }
public String getName() { return ((Named)mSchemaType).getName(); }
public String getName() { return ((Named)mAttribute).getName(); }