public void removeFromHierarchy(FoldHierarchyTransaction transaction) { if (fold != null) { FoldOperation fo = getOperation(); if (fo.isAddedOrBlocked(fold)) { fo.removeFromHierarchy(fold, transaction); } } }
public void removeDamagedNotify(Fold damagedFold) { currentFolds.remove(operation.getExtraInfo(damagedFold)); if (importsFold == damagedFold) { importsFold = null;//not sure if this is correct... } if (initialCommentFold == damagedFold) { initialCommentFold = null;//not sure if this is correct... } }
public CharSequence readContent(String mime, Document d, Fold f, FoldTemplate ft) throws BadLocationException { List<ContentReader> readers = getReaders(mime, f.getType()); for (ContentReader r : readers) { CharSequence chs = r.read(d, f, ft); if (chs != null) { return chs; } } return null; }
public void run() { Document document = operation.getHierarchy().getComponent().getDocument(); if (!insideRender) { startTime = System.currentTimeMillis(); operation.getHierarchy().lock(); FoldHierarchyTransaction tr = operation.openTransaction(); Fold f = operation.addToHierarchy(i.template.getType(), i.template.getDescription(), i.collapseByDefault, Fold f = currentFolds.remove(i); operation.removeFromHierarchy(f, tr); ErrorManager.getDefault().notify(e); } finally { tr.commit(); operation.getHierarchy().unlock();
@Override public void run() { if (!getOperation().isReleased()) { Document doc = getDocument(); if (!(doc instanceof AbstractDocument)) { FoldHierarchy hierarchy = getOperation().getHierarchy(); hierarchy.lock(); try { FoldHierarchyTransaction t = getOperation().openTransaction(); try { if (log.isLoggable(Level.FINE)) { t.commit();
Document getDocument() { return getOperation().getHierarchy().getComponent().getDocument(); }
private void processRemovedFolds(FoldHierarchyTransaction transaction) { if (removedFoldList != null) { for (int i = removedFoldList.size() - 1; i >= 0; i--) { Fold removedFold = (Fold)removedFoldList.get(i); FoldMarkInfo startMark = (FoldMarkInfo)getOperation().getExtraInfo(removedFold); FoldMarkInfo endMark = startMark.getPairMark(); // get prior releasing if (getOperation().isStartDamaged(removedFold)) { // start mark area was damaged startMark.release(true, transaction); // forced remove } if (getOperation().isEndDamaged(removedFold)) { endMark.release(true, transaction); } } } removedFoldList = null; }
public void addToHierarchy(FoldHierarchyTransaction transaction) throws BadLocationException { if (FoldOperation.isBoundsValid(startOffset, endOffset, template.getStartGuardedLength(), template.getEndGuardedLength())) { if (log.isLoggable(Level.FINE)){ log.log(Level.FINE, "CFM.BlockFoldInfo.updateHierarchy: Creating fold at ({0}, {1})", // NOI18N new Object[]{startOffset, endOffset}); } fold = getOperation().addToHierarchy( template.getType(), template.getDescription(), collapse, startOffset, endOffset, template.getStartGuardedLength(), template.getEndGuardedLength(), this, transaction); } }
private void releaseFold(boolean forced, FoldHierarchyTransaction transaction) { if (isSolitaire() || !isStartMark()) { throw new IllegalStateException(); } if (fold != null) { setCollapsed(fold.isCollapsed()); // serialize the collapsed info if (!forced) { getOperation().removeFromHierarchy(fold, transaction); } fold = null; } }
public void ensureFoldExists(FoldHierarchyTransaction transaction) { if (isSolitaire() || !isStartMark()) { throw new IllegalStateException(); } if (fold == null) { try { if (!startMark) { throw new IllegalStateException("Not start mark: " + this); // NOI18N } if (pairMark == null) { throw new IllegalStateException("No pairMark for mark:" + this); // NOI18N } int startOffset = getOffset(); int startGuardedLength = getLength(); int endGuardedLength = pairMark.getLength(); int endOffset = pairMark.getOffset() + endGuardedLength; fold = getOperation().addToHierarchy( CUSTOM_FOLD_TYPE, getDescription(), collapsed, startOffset, endOffset, startGuardedLength, endGuardedLength, this, transaction ); } catch (BadLocationException e) { ErrorManager.getDefault().notify(e); } } }
private void init(Lookup mimeLookup) { Collection<? extends FoldType> types = new ArrayList<FoldType>((FoldUtilities.getFoldTypes(mime).values())); result = mimeLookup.lookupResult(ContentReader.Factory.class); Collection<? extends ContentReader.Factory> factories = result.allInstances(); List<ContentReader> l; for (FoldType ft : types) { l = null; for (ContentReader.Factory f : factories) { ContentReader cr = f.createReader(ft); if (cr != null) { if (l == null) { l = new ArrayList<ContentReader>(3); } l.add(cr); } } if (l != null) { readers.put(ft, l); } } result.addLookupListener(this); }
if (getOperation().isReleased() || !(doc instanceof AbstractDocument)) { if (log.isLoggable(Level.FINE)){ log.log(Level.FINE, "CFM.collectFoldUpdates: No doc found for {0}",
return; FoldHierarchy fh = operation.getHierarchy (); Fold fold = operation.getHierarchy ().getRootFold (); List<Fold> existingFolds = new ArrayList<Fold> (); collectFolds(fold, existingFolds); operation.getExtraInfo(fs); try { FoldHierarchyTransaction transaction = operation.openTransaction (); try { operation.removeFromHierarchy(f, transaction); && f.start < f.end && f.end <= doc.getLength()) { operation.addToHierarchy(f.type, f.foldName, false, f.start , f.end , 0, 0, fh, transaction); ble.printStackTrace(); }finally { transaction.commit();
public void init(FoldOperation operation) { this.operation = operation; String mimeType = DocumentUtilities.getMimeType(operation.getHierarchy().getComponent()); prefs = MimeLookup.getLookup(mimeType).lookup(Preferences.class); }
private void collectFolds(Fold fold, List<Fold> existingFolds) { int i, k = fold.getFoldCount(); for (i = 0; i < k; i++) { Fold f = fold.getFold (i); //hacky fix - we need to find a better solution //how to check if the fold was created by me try { operation.getExtraInfo(f); //no ISE thrown - my fold existingFolds.add(f); collectFolds(f, existingFolds); } catch (IllegalStateException e) { //not my fold } } }
private FileObject getFileObject() { FoldHierarchy h = (operation != null) ? operation.getHierarchy() : null; javax.swing.text.JTextComponent comp = (h != null) ? h.getComponent() : null; Document doc = (comp != null) ? comp.getDocument() : null; DataObject dob = (doc != null) ? NbEditorUtilities.getDataObject(doc) : null; if (dob != null) { return dob.getPrimaryFile(); } return null; }
/** Initialize this manager */ @Override public void init(FoldOperation operation) { this.operation = operation; EditorKit kit = org.netbeans.editor.Utilities.getKit(operation.getHierarchy().getComponent()); if (kit instanceof NbEditorKit) { String contentType = ((NbEditorKit) kit).getContentType(); if (contentType != null) { Preferences prefs = MimeLookup.getLookup(contentType).lookup(Preferences.class); if (prefs != null) { foldInitialCommentsPreset = prefs.getBoolean(CODE_FOLDING_COLLAPSE_INITIAL_COMMENT, false); foldIncludesPreset = prefs.getBoolean(CODE_FOLDING_COLLAPSE_IMPORT, false); foldCodeBlocksPreset = prefs.getBoolean(CODE_FOLDING_COLLAPSE_METHOD, false); foldCommentPreset = prefs.getBoolean(CODE_FOLDING_COLLAPSE_JAVADOC, false); } } } }
public synchronized void initFolds(FoldHierarchyTransaction transaction) { Document doc = operation.getHierarchy().getComponent().getDocument(); file = DataLoadersBridge.getDefault().getFileObject(doc); if (file != null) { currentFolds = new HashMap<FoldInfo, Fold>(); task = JavaElementFoldTask.getTask(file); task.setGsfFoldManager(GsfFoldManager.this); } }
/** * Initialize this manager. * * @param operation fold hierarchy operation dedicated to the fold manager. */ public void init (FoldOperation operation) { Document d = operation.getHierarchy ().getComponent ().getDocument (); if (d instanceof NbEditorDocument) { this.doc = d; this.operation = operation; parserManager = ParserManagerImpl.getImpl (doc); parserManager.addASTEvaluator (this); parserManager.fire ( parserManager.getState (), null, Collections.<String,Set<ASTEvaluator>>singletonMap (FOLD, Collections.<ASTEvaluator>singleton (this)), parserManager.getAST () ); } }
public void initFolds(FoldHierarchyTransaction transaction) { try { doc = getOperation().getHierarchy().getComponent().getDocument(); updateFolds(SyntaxUpdateTokens.getTokenInfoList(doc), transaction); } catch (BadLocationException e) { ErrorManager.getDefault().notify(e); } }