当前位置: 首页>>代码示例>>Java>>正文


Java ITextViewer.getSelectedRange方法代码示例

本文整理汇总了Java中org.eclipse.jface.text.ITextViewer.getSelectedRange方法的典型用法代码示例。如果您正苦于以下问题:Java ITextViewer.getSelectedRange方法的具体用法?Java ITextViewer.getSelectedRange怎么用?Java ITextViewer.getSelectedRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.text.ITextViewer的用法示例。


在下文中一共展示了ITextViewer.getSelectedRange方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
@Override
public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
	initIfNeeded();
	IDocument document = viewer.getDocument();
	if (fTextViewer == null) {
		fTextViewer = viewer;
	}
	// don't eat if not in preferences, XOR with modifier key 1 (Ctrl)
	// but: if there is a selection, replace it!
	Point selection = viewer.getSelectedRange();
	fToggleEating = (stateMask & SWT.MOD1) != 0;
	int newLength = selection.x + selection.y - getReplacementOffset();
	if ((insertCompletion() ^ fToggleEating) && newLength >= 0) {
		setReplacementLength(newLength);
	}
	apply(document, trigger, offset);
	fToggleEating = false;
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:19,代码来源:EditorConfigCompletionProposal.java

示例2: computeCompletionProposals

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
@Override
public ComparableCompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
	List<ComparableCompletionProposal> results = new ArrayList<ComparableCompletionProposal>();
	IDocument document = viewer.getDocument();

	if (viewer.getSelectedRange().y == 0) {
		try {
			int position = getCurrentWordStart(document, offset);
			String start = document.get(position, offset - position);
			results.addAll(AsciidocVariablesProposals.getValidCompletionProposals(document, offset, start));
			if (isCurrentLineStart(document, offset)) {
				results.addAll(AsciidocBlocksAndHeadersProposals.getValidCompletionProposals(document, offset));
			}
			results.addAll(AsciidocAnchorsProposals.getValidCompletionProposals(document, offset, start));
			results.addAll(AsciidocMacrosCompletionProposals.getValidCompletionProposals(document, offset, start));
		} catch (BadLocationException e) {
			e.printStackTrace();
		}
	} else {

	}
	Collections.sort(results);
	return results.toArray(new ComparableCompletionProposal[0]);
}
 
开发者ID:awltech,项目名称:eclipse-asciidoctools,代码行数:25,代码来源:AsciidocContentAssistProcessor.java

示例3: computeContextInformation

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset)
{
    // Retrieve selected range
    Point selectedRange = viewer.getSelectedRange();
    if (selectedRange.y > 0)
    {
        // Text is selected. Create a context information array.
        ContextInformation[] contextInfos = new ContextInformation[ITLAReserveredWords.ALL_WORDS_ARRAY.length];

        // Create one context information item for each style
        for (int i = 0; i < ITLAReserveredWords.ALL_WORDS_ARRAY.length; i++)
            contextInfos[i] = new ContextInformation(null, ITLAReserveredWords.ALL_WORDS_ARRAY[i] + " Style");
        return contextInfos;
    }
    return new ContextInformation[0];
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:17,代码来源:TLACompletionProcessor.java

示例4: computeCompletionProposals

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public List<ICompletionProposal> computeCompletionProposals(ITextViewer textViewer, String prefix, int offset,
			IProgressMonitor monitor) {
		List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
		try {
			int replacementLength = textViewer.getSelectedRange().y;
			if (replacementLength == 0) {
				replacementLength = prefix.length();
			}
			String displayLabel;
			String replacementString;
			List<ClassDetails> classList = ClassRepo.INSTANCE.getClassList();
			Image image=ImagePathConstant.INTELLISENCE_IMAGE.getImageFromRegistry();
			
			for (ClassDetails classDetails : classList) {
//				if (!classDetails.isUserDefined()) {
					List<MethodDetails> methodlist = classDetails.getMethodList();
					for (MethodDetails methodDetails : methodlist) {
						displayLabel = classDetails.getcName() + Constants.DOT + methodDetails.getSignature();
						replacementString = methodDetails.getPlaceHolder();

						HydrographCompletionProposal customProposal=new HydrographCompletionProposal(replacementString,offset-prefix.length(),replacementLength,replacementString.length(),
								image,displayLabel,null,null);
			        	customProposal.setType(CUSTOM_TYPE);
			        	proposals.add(customProposal);
					}
//				}
			}
			addAvailableFieldsProposals(textViewer,image,proposals,prefix,offset,replacementLength);
		} catch (RuntimeException exception) {
			LOGGER.error("Error occurred while building custom proposals", exception);
		}
		filterProposalsOnPrefix(prefix, proposals);
		System.gc();
		return proposals;
	}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:36,代码来源:HydrographCompletionProposalComputer.java

示例5: getHoverRegion

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
	Point selection = textViewer.getSelectedRange();
	if (selection.x <= offset && offset < selection.x + selection.y) {
		return new Region(selection.x, selection.y);
	}
	return new Region(offset, 0);
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:8,代码来源:DwprofileTextHover.java

示例6: doubleClicked

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public void doubleClicked( ITextViewer part){
   int pos = part.getSelectedRange().x;

   if (pos < 0)
      return;

   fText = part;

   if (!selectComment(pos)) {
      selectWord(pos);
   }
}
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:13,代码来源:HDoubleClickStrategy.java

示例7: doubleClicked

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public void doubleClicked(ITextViewer part) {
	int pos = part.getSelectedRange().x;

	if (pos < 0)
		return;

	fText = part;

	if (!selectComment(pos)) {
		selectWord(pos);
	}
}
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:13,代码来源:XMLDoubleClickStrategy.java

示例8: computeContextInformation

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public IContextInformation[] computeContextInformation(ITextViewer viewer,
		int offset) {

	// FIXME -- for testing
	// Retrieve selected range
	Point selectedRange = viewer.getSelectedRange();
	if (selectedRange.y > 0) {

		if (styleManager == null) {
			styleManager = TexStyleCompletionManager.getInstance();
		}
		return styleManager.getStyleContext();
	}
	return new ContextInformation[0];
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:16,代码来源:TexCompletionProcessor.java

示例9: doubleClicked

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
@Override
public void doubleClicked(ITextViewer viewer) {
	final int offset = viewer.getSelectedRange().x;
	if (offset < 0) return;

	PageRoot model = editor.getPageModel();
	PagePart part = model.partAtOffset(offset);

	if (part.getKind() != Kind.TABLE) {
		super.doubleClicked(viewer);
		return;
	}

	UIJob job = new UIJob("Table editor") {

		@Override
		public IStatus runInUIThread(IProgressMonitor monitor) {
			TableDialog dialog = new TableDialog(part);
			int ret = dialog.open();
			if (ret == 0) {
				String newTable = dialog.build();
				ISourceRange range = part.getSourceRange();
				editor.getViewer().setSelectedRange(range.getOffset(), 0);
				TextEdit edit = new ReplaceEdit(range.getOffset(), range.getLength(), newTable);
				try {
					edit.apply(editor.getDocument());
				} catch (MalformedTreeException | BadLocationException e) {
					Log.error("Failed to insert new table in part " + part + " (" + e.getMessage() + ")");
					return Status.CANCEL_STATUS;
				}
			}
			return Status.OK_STATUS;
		}
	};
	job.setPriority(Job.INTERACTIVE);
	job.schedule(200);
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:38,代码来源:DoubleClickStrategy.java

示例10: getHoverRegion

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public IRegion getHoverRegion( ITextViewer textViewer, int offset){
   Point selection = textViewer.getSelectedRange();
   if (selection.x <= offset && offset < selection.x + selection.y)
      return new Region(selection.x, selection.y);
   return new Region(offset, 0);
}
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:7,代码来源:MyTextHover.java

示例11: computeCompletionProposals

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset)
{
    /*
    // show all proposals without checking the context
    ICompletionProposal[] result = new ICompletionProposal[fgProposals.length];
    for (int i = 0; i < fgProposals.length; i++)
    {
        IContextInformation info = new ContextInformation(fgProposals[i], "");
        result[i] = new CompletionProposal(fgProposals[i], offset, 0, fgProposals[i].length(), null,
                fgProposals[i], info, "");
    }
    return result;
    */

    IDocument document = viewer.getDocument();
    // get the selection range
    Point selectedRange = viewer.getSelectedRange();

    List propList = new ArrayList();
    try
    {
        if (selectedRange.y > 0)
        {
            // the range is non-empty
            String text = document.get(selectedRange.x, selectedRange.y);
            computeWordProposals(text, offset, propList);
        } else
        {
            // the range is empty, no selection in the editor

            // get the region
            IRegion wordRegion = DocumentHelper.getRegionExpandedBackwards(document, offset, DocumentHelper
                    .getDefaultWordDetector());
            String word = document.get(wordRegion.getOffset(), wordRegion.getLength());
            TLAEditorActivator.getDefault().logDebug("Content assist for '" + word + "'" + wordRegion );
            computeWordProposals(word, offset, propList);
        }
    } catch (BadLocationException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    ICompletionProposal[] proposals = new ICompletionProposal[propList.size()];
    propList.toArray(proposals);

    return proposals;

}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:50,代码来源:TLACompletionProcessor.java

示例12: computeCompletionProposals

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
/**
 * Responsavel por computar os valores que aparecerao na lista de sugestoes.
 * Retorna uma lista de ICompletionProposal
 */
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
		int offset) {

	// get the active IFile
	IWorkbench wb = PlatformUI.getWorkbench();
	IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
	IWorkbenchPage page = win.getActivePage();
	IEditorPart editor = page.getActiveEditor();
	List <CompletionProposal> propList = new ArrayList <CompletionProposal>();

	boolean isFileEditor = true;

	try {
		if (editor.getEditorInput() instanceof IFileEditorInput) {
			currentFile = new File(
					((IFileEditorInput) editor.getEditorInput()).getFile()
							.getLocationURI());

			isFileEditor = false;

		} else {
			currentFile = new File(
					((IURIEditorInput) editor.getEditorInput()).getURI());
		}
	} catch (Exception e) {
		e.printStackTrace();
		ICompletionProposal[] proposal = new ICompletionProposal[0];
		return proposal;
	}

	IDocument doc = viewer.getDocument();
	text = doc.get();

	NCLSourceDocument nclDoc = null;

	if (isFileEditor)
		nclDoc = NCLSourceDocument
				.createNCLSourceDocumentFromIDocument(doc);
	else
		nclDoc = (NCLSourceDocument) doc;

	isAttributeValue = nclDoc.isAttributeValue(offset);
	isAttribute = nclDoc.isAttribute(offset);
	isEndTagName = nclDoc.isEndTagName(offset);
	Point selectedRange = viewer.getSelectedRange();
	if (selectedRange.y > 0) {
		// TODO:
	} else {

		// System.out.println("Attributo = " + isAttribute);
		
		String qualifier = getQualifier(nclDoc, offset);
		if (isEndTagName) {
			computeEndTagName(nclDoc, qualifier, offset, propList);
		} else if (isAttributeValue) {
			computeAttributesValuesProposals(nclDoc, qualifier, offset,
					propList);
		} else if (!isAttribute) {
			computeTagsProposals(nclDoc, qualifier, offset, propList);
		} else if (!nclDoc.isTagname(offset))
			computeAttributesProposals(nclDoc, qualifier, offset, propList);
	}
	ICompletionProposal[] proposals = new ICompletionProposal[propList
			.size()];
	propList.toArray(proposals);
	return proposals;
}
 
开发者ID:ncleclipse,项目名称:ncl30-eclipse,代码行数:72,代码来源:NCLCompletionProposal.java

示例13: getCaretOffset

import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
private int getCaretOffset() {
	ITextViewer viewer = fViewer;
	Point point = viewer.getSelectedRange();
	return point.x;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:6,代码来源:SmartBackspaceManager.java


注:本文中的org.eclipse.jface.text.ITextViewer.getSelectedRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。