/** * 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); } } }
/** * 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(); } } }
@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; }
model.startTransaction(); try { for (Node node : nodes) { boolean srcInTransaction = srcModel.isIntransaction(); try { if (!srcInTransaction) { srcModel.startTransaction(); srcModel.removeChildComponent(child); } finally { if (!srcInTransaction) { srcModel.endTransaction(); model.addChildComponent(target, copy, index); model.endTransaction();
/** * 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; } }
/** * 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; }
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); } } } } } }