javax.swing.text.AbstractDocument Java Examples

The following examples show how to use javax.swing.text.AbstractDocument. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLSyntaxSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Get token at given offet or previous one if at token boundary.
 * It does not lock the document. Returns {@code null} for invalid offsets.
 * 
 * @param offset valid position in document
 * @return Token instance
 */
public Token<XMLTokenId> getNextToken( int offset) throws BadLocationException {
    if (offset == 0) {
        offset = 1;
    }
    if (offset < 0) throw new BadLocationException("Offset " +
            offset + " cannot be less than 0.", offset);  //NOI18N
    ((AbstractDocument)document).readLock();
    try {
        TokenSequence ts = getSequence();
        synchronized (ts) {
            return getToken(ts, offset, true, null);
        }
    } finally {
        ((AbstractDocument)document).readUnlock();
    }
}
 
Example #2
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public View create(Element elem) {
  switch (elem.getName()) {
    // case AbstractDocument.ContentElementName:
    //   return new WhitespaceLabelView(elem);
    case AbstractDocument.ParagraphElementName:
      return new ParagraphWithEopmView(elem);
    case AbstractDocument.SectionElementName:
      return new BoxView(elem, View.Y_AXIS);
    case StyleConstants.ComponentElementName:
      return new ComponentView(elem);
    case StyleConstants.IconElementName:
      return new IconView(elem);
    default:
      return new WhitespaceLabelView(elem);
  }
}
 
Example #3
Source File: CompletionUtil.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Checks to see if this document declares any DOCTYPE or not?
 * If exists, it must appear before the first xml tag.
 * @return true if found, else false.
 */
public static boolean isDTDBasedDocument(Document document) {
    ((AbstractDocument)document).readLock();
    try {
        TokenHierarchy th = TokenHierarchy.get(document);
        TokenSequence ts = th.tokenSequence();
        while(ts.moveNext()) {
            Token token = ts.token();
            //if an xml tag is found, we have come too far.
            if(token.id() == XMLTokenId.TAG)
                return false;
            if(token.id() == XMLTokenId.DECLARATION)
                return true;
        }
    } finally {
        ((AbstractDocument)document).readUnlock();
    }
    return false;
}
 
Example #4
Source File: TokenSequenceTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSubSequenceInUnfinishedTH() throws Exception {
    Document doc = new ModificationTextDocument();
    //             012345678
    String text = "ab cd efg";
    doc.insertString(0, text, null);
    
    doc.putProperty(Language.class,TestTokenId.language());
    TokenHierarchy<?> hi = TokenHierarchy.get(doc);

    ((AbstractDocument)doc).readLock();
    try {
        TokenSequence<?> ts = hi.tokenSequence();
        assertTrue(ts.moveNext());

        ts = ts.subSequence(2, 6);
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts,TestTokenId.WHITESPACE, " ", 2);
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts,TestTokenId.IDENTIFIER, "cd", 3);
        assertTrue(ts.moveNext());
        LexerTestUtilities.assertTokenEquals(ts,TestTokenId.WHITESPACE, " ", 5);
        assertFalse(ts.moveNext());
    } finally {
        ((AbstractDocument)doc).readUnlock();
    }
}
 
Example #5
Source File: HighlightingTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Check highlight ranges.
 *
 * @param content Javadoc
 * @param offsetRanges start and end offset ranges
 */
private void checkHighlights(String content, int[] offsetRanges) {
    Document document = createDocument(content);
    ((AbstractDocument) document).readLock();
    try {
        Highlighting highlighting = new Highlighting(document);
        HighlightsSequence hs = highlighting.getHighlights(0, document.getLength());
        assertEquals(0, offsetRanges.length % 2);
        assertTrue(hs.moveNext());
        for (int i = 0; i < offsetRanges.length; i += 2) {
            assertEquals(offsetRanges[i], hs.getStartOffset());
            assertEquals(offsetRanges[i + 1], hs.getEndOffset());
            if (!hs.moveNext()) {
                assertEquals(offsetRanges.length, i + 2);
                break;
            }
        }
    } finally {
        ((AbstractDocument) document).readUnlock();
    }
}
 
Example #6
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
private MainPanel() {
  super(new GridLayout(2, 1));
  JTextField field = new JTextField(12);

  ((AbstractDocument) field.getDocument()).setDocumentFilter(new SizeFilter());
  // ((AbstractDocument) field.getDocument()).setDocumentFilter(new DocumentSizeFilter(5));

  ActionMap am = field.getActionMap();

  String key = DefaultEditorKit.deletePrevCharAction; // "delete-previous";
  am.put(key, new SilentDeleteTextAction(key, am.get(key)));

  key = DefaultEditorKit.deleteNextCharAction; // "delete-next";
  am.put(key, new SilentDeleteTextAction(key, am.get(key)));

  add(makeTitledPanel("Default", new JTextField()));
  add(makeTitledPanel("Override delete-previous, delete-next beep", field));
  setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
  setPreferredSize(new Dimension(320, 240));
}
 
Example #7
Source File: CodeTemplateManagerOperation.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static MimePath getFullMimePath(Document document, int offset) {
    String langPath = null;

    if (document instanceof AbstractDocument) {
        AbstractDocument adoc = (AbstractDocument)document;
        adoc.readLock();
        try {
            List<TokenSequence<?>> list = TokenHierarchy.get(document).embeddedTokenSequences(offset, true);
            if (list.size() > 1) {
                langPath = list.get(list.size() - 1).languagePath().mimePath();
            }
        } finally {
            adoc.readUnlock();
        }
    }

    if (langPath == null) {
        langPath = NbEditorUtilities.getMimeType(document);
    }

    if (langPath != null) {
        return MimePath.parse(langPath);
    } else {
        return null;
    }
}
 
Example #8
Source File: LanguageManagerTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testKnownMimeType() {
    PlainDocument doc = new PlainDocument();
    doc.putProperty("mimeType", MIME_TYPE_KNOWN);
    
    TokenHierarchy th = TokenHierarchy.get(doc);
    ((AbstractDocument)doc).readLock();
    try {
        Language lang = th.tokenSequence().language();
        assertNotNull("There should be language for " + MIME_TYPE_KNOWN, lang);

        assertNotNull("Invalid mime type", lang.mimeType());
        assertEquals("Wrong language's mime type", MIME_TYPE_KNOWN, lang.mimeType());
    } finally {
        ((AbstractDocument)doc).readUnlock();
    }
}
 
Example #9
Source File: NbGenerateCodeAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static MimePath getFullMimePath(Document document, int offset) {
    String langPath = null;

    if (document instanceof AbstractDocument) {
        AbstractDocument adoc = (AbstractDocument)document;
        adoc.readLock();
        try {
            List<TokenSequence<?>> list = TokenHierarchy.get(document).embeddedTokenSequences(offset, true);
            if (list.size() > 1) {
                langPath = list.get(list.size() - 1).languagePath().mimePath();
            }
        } finally {
            adoc.readUnlock();
        }
    }

    if (langPath == null) {
        langPath = NbEditorUtilities.getMimeType(document);
    }

    if (langPath != null) {
        return MimePath.parse(langPath);
    } else {
        return null;
    }
}
 
Example #10
Source File: ViewFactoryImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new LabelView(elem);
        } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return null;
        } else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new DocumentView(elem);
        } else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        } else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }
    return null;
}
 
Example #11
Source File: JoinSectionsPositioningTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testShortDoc() throws Exception {
    //             000000000011111111112222222222
    //             012345678901234567890123456789
    String text = "a<b>c";
    ModificationTextDocument doc = new ModificationTextDocument();
    doc.insertString(0, text, null);
    doc.putProperty(Language.class, TestJoinTopTokenId.language());
    TokenHierarchy<?> hi = TokenHierarchy.get(doc);
    ((AbstractDocument)doc).readLock();
    try {
        TokenSequence<?> ts = hi.tokenSequence();
        assertTrue(ts.moveNext());
        ts.embedded(); // Creates JTL
    } finally {
        ((AbstractDocument)doc).readUnlock();
    }
}
 
Example #12
Source File: TextManager.java    From jeveassets with GNU General Public License v2.0 6 votes vote down vote up
public static void installTextComponent(final JTextComponent component) {
	//Make sure this component does not already have a UndoManager
	Document document = component.getDocument();
	boolean found = false;
	if (document instanceof AbstractDocument) {
		AbstractDocument abstractDocument = (AbstractDocument) document;
		for (UndoableEditListener editListener : abstractDocument.getUndoableEditListeners()) {
			if (editListener.getClass().equals(CompoundUndoManager.class)) {
				CompoundUndoManager undoManager = (CompoundUndoManager) editListener;
				undoManager.reset();
				return;
			}
		}
	}
	if (!found) {
		new TextManager(component);
	}
}
 
Example #13
Source File: LogPane.java    From libreveris with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Create the log pane, with a standard mailbox.
 */
public LogPane ()
{
    // Build the scroll pane
    component = new JScrollPane();
    component.setBorder(null);

    // log/status area
    logArea = new JTextPane();
    logArea.setEditable(false);
    logArea.setMargin(new Insets(5, 5, 5, 5));
    document = (AbstractDocument) logArea.getStyledDocument();

    // Let the scroll pane display the log area
    component.setViewportView(logArea);
}
 
Example #14
Source File: XMLSyntaxSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Executes user code on token sequence from the document.
 * Read-locks the document, obtains {@link TokenSequence} from the Lexer and executes {@code userCode} 
 * passing the initialized sequence. The sequence is moved to the desired offset and the token that contains
 * or starts at that position. The client can move the sequence elsewhere.
 * <p/>
 * If the {@code userCode} calls this {@code SyntaxSupport} methods like {@link #getNextToken(int)}, they will use
 * the <b>same TokenSequence</b> as passed to {@code userCode}. This allows to combine navigation calls from {@link XMLSyntaxSupport}
 * with client's own sequence movements. The TokenSequence instance passed to {@code userCode} can be queried for
 * current token offset after navigation.
 * 
 * @param <T>
 * @param offset offset to position the sequence at
 * @param userCode code to execute
 * @return user-defined value
 * @throws BadLocationException if the user code throws BadLocationException
 * @throws IllegalStateException if the user code throws a checked exception
 */
@NullUnknown
public <T> T runWithSequence(int offset, SequenceCallable<T> userCode) throws BadLocationException {
    T result;
    TokenSequence old = null;
    try {
        ((AbstractDocument)document).readLock();
        old = cachedSequence.get();
        cachedSequence.remove();
        TokenSequence ts = getSequence();
        if (ts == null) {
            throw new BadLocationException("No sequence for position", offset); // NOI18N
        }
        cachedSequence.set(ts);
        synchronized (ts) {
            ts.move(offset);
            ts.moveNext();
            result = userCode.call(ts);
        }
    } finally {
        cachedSequence.set(old);
        ((AbstractDocument)document).readUnlock();
    }
    return result;
}
 
Example #15
Source File: WrapEditorKit.java    From PacketProxy with Apache License 2.0 6 votes vote down vote up
public View create(Element elem) {
	String kind = elem.getName();
	if (kind != null) {
		if (kind.equals(AbstractDocument.ContentElementName)) {
			return new WrapLabelView(elem);
		} else if (kind.equals(AbstractDocument.ParagraphElementName)) {
			return new CustomParagraphView(elem);
		} else if (kind.equals(AbstractDocument.SectionElementName)) {
			return new BoxView(elem, View.Y_AXIS);
		} else if (kind.equals(StyleConstants.ComponentElementName)) {
			return new ComponentView(elem);
		} else if (kind.equals(StyleConstants.IconElementName)) {
			return new IconView(elem);
		}
	}
	return new LabelView(elem);
}
 
Example #16
Source File: KTextEdit.java    From stendhal with GNU General Public License v2.0 6 votes vote down vote up
@Override
public View create(Element elem) {
	String kind = elem.getName();
	if (kind != null) {
		if (kind.equals(AbstractDocument.ContentElementName)) {
			return new WrapLabelView(elem);
		} else if (kind.equals(AbstractDocument.ParagraphElementName)) {
			return new ParagraphView(elem);
		} else if (kind.equals(AbstractDocument.SectionElementName)) {
			return new BoxView(elem, View.Y_AXIS);
		} else if (kind.equals(StyleConstants.ComponentElementName)) {
			return new ComponentView(elem);
		} else if (kind.equals(StyleConstants.IconElementName)) {
			return new IconView(elem);
		}
	}

	// default to text display
	return new LabelView(elem);
}
 
Example #17
Source File: CharacterMatcher.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public int [] findMatches() throws BadLocationException {
    ((AbstractDocument) context.getDocument()).readLock();
    try {
        int offset = BracesMatcherSupport.matchChar(
            context.getDocument(),
            backward ? originOffset : originOffset + 1,
            backward ?
                Math.max(0, lowerBound) :
                Math.min(context.getDocument().getLength(), upperBound),
            originalChar,
            matchingChar
        );

        return offset != -1 ? new int [] { offset, offset + 1 } : null;
    } finally {
        ((AbstractDocument) context.getDocument()).readUnlock();
    }
}
 
Example #18
Source File: CharacterMatcher.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public int [] findOrigin() throws BadLocationException {
    ((AbstractDocument) context.getDocument()).readLock();
    try {
        int result [] = BracesMatcherSupport.findChar(
            context.getDocument(),
            context.getSearchOffset(),
            context.isSearchingBackward() ?
                Math.max(context.getLimitOffset(), lowerBound) :
                Math.min(context.getLimitOffset(), upperBound),
            matchingPairs
        );

        if (result != null) {
            originOffset = result[0];
            originalChar = matchingPairs[result[1]];
            matchingChar = matchingPairs[result[1] + result[2]];
            backward = result[2] < 0;
            return new int [] { originOffset, originOffset + 1 };
        } else {
            return null;
        }
    } finally {
        ((AbstractDocument) context.getDocument()).readUnlock();
    }
}
 
Example #19
Source File: LegacyEssMatcher.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public int[] findOrigin() throws BadLocationException {
    ((AbstractDocument) context.getDocument()).readLock();
    try {
        int offset;

        if (context.isSearchingBackward()) {
            offset = context.getSearchOffset() - 1;
        } else {
            offset = context.getSearchOffset();
        }

        block = ess.findMatchingBlock(offset, false);
        if (block == null) {
            return null;
        } else if (block.length == 0) {
            return block;
        } else {
            return new int [] { offset, offset };
        }
    } finally {
        ((AbstractDocument) context.getDocument()).readUnlock();
    }
}
 
Example #20
Source File: ImageView.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Invokes <code>preferenceChanged</code> on the event displatching
 * thread.
 */
private void safePreferenceChanged() {
    if (SwingUtilities.isEventDispatchThread()) {
        Document doc = getDocument();
        if (doc instanceof AbstractDocument) {
            ((AbstractDocument)doc).readLock();
        }
        preferenceChanged(null, true, true);
        if (doc instanceof AbstractDocument) {
            ((AbstractDocument)doc).readUnlock();
        }
    }
    else {
        SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    safePreferenceChanged();
                }
            });
    }
}
 
Example #21
Source File: GlyphVectorEditorKit.java    From PolyGlot with MIT License 6 votes vote down vote up
public View create(Element elem) {
    String kind = elem.getName();
    if (kind != null) {
        if (kind.equals(AbstractDocument.ContentElementName)) {
            return new PainterLabelView(elem);
        }
        else if (kind.equals(AbstractDocument.ParagraphElementName)) {
            return new ParagraphView(elem);
        }
        else if (kind.equals(AbstractDocument.SectionElementName)) {
            return new BoxView(elem, View.Y_AXIS);
        }
        else if (kind.equals(StyleConstants.ComponentElementName)) {
            return new ComponentView(elem);
        }
        else if (kind.equals(StyleConstants.IconElementName)) {
            return new IconView(elem);
        }
    }

    // default to text display
    return new LabelView(elem);
}
 
Example #22
Source File: DoubleField.java    From Explvs-AIO with MIT License 6 votes vote down vote up
public DoubleField() {
    ((AbstractDocument) getDocument()).setDocumentFilter(new DoubleDocumentFilter());

    addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(final KeyEvent e) {
            validateField();
        }
    });

    setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(final JComponent input) {
            return validateField();
        }
    });
}
 
Example #23
Source File: IntegerField.java    From Explvs-AIO with MIT License 6 votes vote down vote up
public IntegerField() {
    ((AbstractDocument) getDocument()).setDocumentFilter(new IntegerDocumentFilter());

    addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(final KeyEvent e) {
            validateField();
        }
    });

    setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(final JComponent input) {
            return validateField();
        }
    });
}
 
Example #24
Source File: MainPanel.java    From java-swing-tips with MIT License 6 votes vote down vote up
@Override public ViewFactory getViewFactory() {
  return new HTMLEditorKit.HTMLFactory() {
    @Override public View create(Element elem) {
      View view = super.create(elem);
      if (view instanceof LabelView) {
        System.out.println("debug: " + view.getAlignment(View.Y_AXIS));
      }
      AttributeSet attrs = elem.getAttributes();
      Object elementName = attrs.getAttribute(AbstractDocument.ElementNameAttribute);
      Object o = Objects.nonNull(elementName) ? null : attrs.getAttribute(StyleConstants.NameAttribute);
      if (o instanceof HTML.Tag) {
        HTML.Tag kind = (HTML.Tag) o;
        if (kind == HTML.Tag.IMG) {
          return new ImageView(elem) {
            @Override public float getAlignment(int axis) {
              // .8125f magic number...
              return axis == View.Y_AXIS ? .8125f : super.getAlignment(axis);
            }
          };
        }
      }
      return view;
    }
  };
}
 
Example #25
Source File: JspBracesMatching.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public int[] findMatches() throws InterruptedException, BadLocationException {
    ((AbstractDocument) context.getDocument()).readLock();
    try {
        JspSyntaxSupport syntaxSupport = JspSyntaxSupport.get(context.getDocument());
        int searchOffset = context.getSearchOffset();
        return syntaxSupport.findMatchingBlock(searchOffset, false);
    } finally {
        ((AbstractDocument) context.getDocument()).readUnlock();
    }
}
 
Example #26
Source File: JspBracesMatching.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public int[] findOrigin() throws InterruptedException, BadLocationException {
    ((AbstractDocument) context.getDocument()).readLock();
    try {
        JspSyntaxSupport syntaxSupport = JspSyntaxSupport.get(context.getDocument());
        int searchOffset = context.getSearchOffset();
        int[] found = syntaxSupport.findMatchingBlock(searchOffset, false);
        if(found == null) {
            return null;
        }
        int[] opposite = syntaxSupport.findMatchingBlock(found[0], false);
        return opposite;
    } finally {
        ((AbstractDocument) context.getDocument()).readUnlock();
    }
}
 
Example #27
Source File: SeaGlassTextFieldUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * @see javax.swing.plaf.basic.BasicTextUI#getPreferredSize(javax.swing.JComponent)
 */
public Dimension getPreferredSize(JComponent c) {
    // The following code has been derived from BasicTextUI.
    Document  doc      = ((JTextComponent) c).getDocument();
    Insets    i        = c.getInsets();
    Dimension d        = c.getSize();
    View      rootView = getRootView((JTextComponent) c);

    if (doc instanceof AbstractDocument) {
        ((AbstractDocument) doc).readLock();
    }

    try {
        if ((d.width > (i.left + i.right)) && (d.height > (i.top + i.bottom))) {
            rootView.setSize(d.width - i.left - i.right, d.height - i.top - i.bottom);
        } else if (d.width == 0 && d.height == 0) {
            // Probably haven't been layed out yet, force some sort of
            // initial sizing.
            rootView.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
        }

        d.width  = (int) Math.min((long) rootView.getPreferredSpan(View.X_AXIS) + (long) i.left + (long) i.right, Integer.MAX_VALUE);
        d.height = (int) Math.min((long) rootView.getPreferredSpan(View.Y_AXIS) + (long) i.top + (long) i.bottom, Integer.MAX_VALUE);
    } finally {
        if (doc instanceof AbstractDocument) {
            ((AbstractDocument) doc).readUnlock();
        }
    }

    // Fix: The preferred width is always two pixels too small on a Mac.
    d.width += 2;

    // We'd like our heights to be odd by default.
    if ((d.height & 1) == 0) {
        d.height--;
    }

    return d;
}
 
Example #28
Source File: bug7165725.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void checkStructureEquivalence(AbstractDocument.AbstractElement elem) {
    String name = elem.getName();
    if (!goldenName.equals(name)) {
        throw new RuntimeException("Bad structure: expected element name is '" + goldenName + "' but the actual name was '" + name + "'.");
    }
    int goldenChildCount = goldenChildren.size();
    int childCount = elem.getChildCount();
    if (childCount != goldenChildCount) {
        System.out.print("D: children: ");
        for (int i = 0; i < childCount; i++) {
            System.out.print(" " + elem.getElement(i).getName());
        }
        System.out.println("");
        System.out.print("D: goldenChildren: ");
        for (GoldenElement ge : goldenChildren) {
            System.out.print(" " + ge.goldenName);
        }
        System.out.println("");

        throw new RuntimeException("Bad structure: expected child count of element '" + goldenName + "' is '" + goldenChildCount + "' but the actual count was '" + childCount + "'.");
    }
    for (int i = 0; i < childCount; i++) {
        AbstractDocument.AbstractElement nextElem = (AbstractDocument.AbstractElement) elem.getElement(i);
        GoldenElement goldenElement = goldenChildren.get(i);
        goldenElement.checkStructureEquivalence(nextElem);
    }
}
 
Example #29
Source File: DrawEngineDocView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    JTextComponent component = (JTextComponent)getContainer();
    if (component==null || evt==null || 
        (!EditorUI.LINE_HEIGHT_CHANGED_PROP.equals(evt.getPropertyName()) &&
         !EditorUI.TAB_SIZE_CHANGED_PROP.equals(evt.getPropertyName())
        )
    ) {
        return;
    }
    
    AbstractDocument doc = (AbstractDocument)getDocument();
    if (doc!=null) {
        doc.readLock();
        try{
            LockView lockView = LockView.get(this);
            lockView.lock();
            try {
                rebuild(0, getViewCount());
            } finally {
                lockView.unlock();
            }
        } finally {
            doc.readUnlock();
        }
    component.revalidate();
    }
}
 
Example #30
Source File: InstancePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of common Payara server properties editor.
 * <p/>
 * @param instance Payara server instance to be modified.
 */
protected InstancePanel(final PayaraInstance instance) {
    this.instance = instance;
    ips = NetUtils.getHostIP4s();
    initComponents();
    ((AbstractDocument)dasPortField.getDocument())
            .setDocumentFilter(new Filter.PortNumber());
    ((AbstractDocument)httpPortField.getDocument())
            .setDocumentFilter(new Filter.PortNumber());
}