本文整理了Java中javax.swing.text.Element.getParentElement()
方法的一些代码示例,展示了Element.getParentElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getParentElement()
方法的具体详情如下:
包路径:javax.swing.text.Element
类名称:Element
方法名:getParentElement
暂无
代码示例来源:origin: robotframework/SwingLibrary
public Element getParentElement() {
return element.getParentElement();
}
代码示例来源:origin: freeplane/freeplane
private Element getStandAloneElement(final Element element) {
final String name = element.getName();
if (name.equals("ul") || name.equals("ol") || name.equals("table") || name.equals("html")) {
return element;
}
return getStandAloneElement(element.getParentElement());
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
/**
* Method for inserting list elements
*/
public void insertListStyle(Element element) throws BadLocationException, IOException {
if (element.getParentElement().getName() == "ol") {
actionListOrdered.actionPerformed(new ActionEvent(new Object(), 0, "newListPoint"));
} else {
actionListUnordered.actionPerformed(new ActionEvent(new Object(), 0, "newListPoint"));
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
/**
* Method that handles initial list insertion and deletion
*/
public void manageListElement(Element element) {
Element h = htmlUtilities.getListItemParent();
Element listElement = h.getParentElement();
if (h != null) {
htmlUtilities.removeTag(h, true);
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
private int getRealStart() {
fixedStart = start.getParentElement().getElementIndex(start.getStartOffset());
return fixedStart;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Get the total count of lines in the document */
public static int getRowCount(BaseDocument doc) {
return doc.getParagraphElement(0).getParentElement().getElementCount();
}
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
private int getRealEnd() {
return end.getParentElement().getElementIndex(end.getStartOffset());
}
代码示例来源:origin: com.google.code.findbugs/findbugs
public Integer getLineNumber() {
Element element = this.getElement();
Integer result = elementLineNumberCache.get(element);
if (result != null) {
return result;
}
Element parent = element.getParentElement();
int count = parent.getElementCount();
for (int i = 0; i < count; i++) {
elementLineNumberCache.put(parent.getElement(i), i + 1);
}
result = elementLineNumberCache.get(element);
if (result != null) {
return result;
}
return -1;
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Count of rows between these two positions */
public static int getRowCount(BaseDocument doc, int startPos, int endPos)
throws BadLocationException {
if (startPos > endPos) {
return 0;
}
Element lineRoot = doc.getParagraphElement(0).getParentElement();
return lineRoot.getElementIndex(endPos) - lineRoot.getElementIndex(startPos) + 1;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document
public static int getLineCount(@NonNull LineDocument doc) {
return doc.getParagraphElement(0).getParentElement().getElementCount();
}
代码示例来源:origin: org.netbeans.api/org-openide-text
/** Find the root element of all lines.
* All conforming NetBeans documents
* should return a valid element.
*
* @param doc styled document (expecting NetBeans document)
* @return the root element
* @exception NullPointerException If the <code>doc</code> parameter
* is <code>null</code>.
*/
public static Element findLineRootElement(StyledDocument doc) {
checkDocParameter(doc);
Element e = doc.getParagraphElement(0).getParentElement();
if (e == null) {
// try default root (should work for text/plain)
e = doc.getDefaultRootElement();
}
return e;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document
/**
* Return line index (line number - 1) for the given offset in the document.
*
* @param doc document to operate on
* @param offset position in document where to start searching
*/
public static int getLineIndex(@NonNull LineDocument doc, int offset) throws BadLocationException {
checkOffsetValid(doc, offset);
Element lineRoot = doc.getParagraphElement(0).getParentElement();
return lineRoot.getElementIndex(offset);
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document
/** Count of rows between these two positions */
public static int getLineCount(@NonNull LineDocument doc, int startOffset, int endOffset) {
if (startOffset > endOffset) {
return 0;
}
Element lineRoot = doc.getParagraphElement(0).getParentElement();
return lineRoot.getElementIndex(endOffset) - lineRoot.getElementIndex(startOffset) + 1;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Return line offset (line number - 1) for some position in the document
* @param doc document to operate on
* @param offset position in document where to start searching
*/
public static int getLineOffset(BaseDocument doc, int offset)
throws BadLocationException {
checkOffsetValid(offset, doc.getLength() + 1);
Element lineRoot = doc.getParagraphElement(0).getParentElement();
return lineRoot.getElementIndex(offset);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/**
* Get the line at which the insert/remove occured.
* @deprecated
*/
public int getLine() {
Element lineRoot = ((BaseDocument)getDocument()).getParagraphElement(0).getParentElement();
int lineIndex = lineRoot.getElementIndex(getOffset());
return lineIndex;
// return (getModifyUndoEdit() != null) ? getModifyUndoEdit().getLine() : 0;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Return start offset of the line
* @param lineIndex line index starting from 0
* @return start position of the line or -1 if lineIndex was invalid
*/
public static int getRowStartFromLineOffset(BaseDocument doc, int lineIndex) {
Element lineRoot = doc.getParagraphElement(0).getParentElement();
if (lineIndex < 0 || lineIndex >= lineRoot.getElementCount()) {
return -1; // invalid line number
} else {
return lineRoot.getElement(lineIndex).getStartOffset();
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
public boolean checkParentsTag(HTML.Tag tag)
{
Element e = parent.getExtendedHtmlDoc().getParagraphElement(parent.getCaretPosition());
String tagString = tag.toString();
if(e.getName().equalsIgnoreCase(tag.toString()))
{
return true;
}
do
{
if((e = e.getParentElement()).getName().equalsIgnoreCase(tagString))
{
return true;
}
} while(!(e.getName().equalsIgnoreCase("html")));
return false;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document
/**
* Return start offset of the line with the given index.
*
* @param lineIndex line index starting from 0
* @return start offset of the line or -1 if lineIndex was invalid
*/
public static int getLineStartFromIndex(@NonNull LineDocument doc, int lineIndex) {
Element lineRoot = doc.getParagraphElement(0).getParentElement();
if (lineIndex < 0 || lineIndex >= lineRoot.getElementCount()) {
return -1; // invalid line number
} else {
return lineRoot.getElement(lineIndex).getStartOffset();
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
public Element getListItemParent()
{
String listItemTag = HTML.Tag.LI.toString();
Element eleSearch = parent.getExtendedHtmlDoc().getCharacterElement(parent.getCaretPosition());
do
{
if(listItemTag.equals(eleSearch.getName()))
{
return eleSearch;
}
eleSearch = eleSearch.getParentElement();
} while(eleSearch.getName() != HTML.Tag.HTML.toString());
return null;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
private View getExpandedView(){
Element parentElem = getElement().getParentElement();
int sei = parentElem.getElementIndex(getStartOffset());
int so = parentElem.getElement(sei).getStartOffset();
int eei = parentElem.getElementIndex(getEndOffset());
int eo = parentElem.getElement(eei).getEndOffset();
LockView fakeView = new LockView(
new DrawEngineFakeDocView(parentElem, so, eo, false)
);
RootView rootView = new RootView();
rootView.setView(fakeView);
return fakeView;
}
内容来源于网络,如有侵权,请联系作者删除!