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


Java LinkedModeUI类代码示例

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


LinkedModeUI类属于org.eclipse.jface.text.link包,在下文中一共展示了LinkedModeUI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpLinkedMode

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
/**
	 * Sets up a simple linked mode at {@link #getCursorPosition()} and an exit policy that will
	 * exit the mode when <code>closingCharacter</code> is typed and an exit position at
	 * <code>getCursorPosition() + 1</code>.
	 *
	 * @param document the document
	 */
	protected void setUpLinkedMode(IDocument document) {
		try {
			LinkedPositionGroup group= new LinkedPositionGroup();
			group.addPosition(new LinkedPosition(document, getSelectionStart(), getSelectionLength(), LinkedPositionGroup.NO_STOP));

			LinkedModeModel model= new LinkedModeModel();
			model.addGroup(group);
			model.forceInstall();

			LinkedModeUI ui= new LinkedModeUI(model, viewer);
//			ui.setSimpleMode(true);
			ui.setExitPolicy(new ExitPolicy(exitChars));
			ui.setExitPosition(viewer, getCursorPosition() + getReplacementOffset(), 0, Integer.MAX_VALUE);
			ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
			ui.enter();
		} catch (BadLocationException e) {
			log.info(e.getMessage(), e);
		}
	}
 
开发者ID:cplutte,项目名称:bts,代码行数:27,代码来源:ConfigurableCompletionProposal.java

示例2: setUpLinkedMode

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
/**
 * Sets up a simple linked mode at {@link #getCursorPosition()} and an exit policy that will
 * exit the mode when <code>closingCharacter</code> is typed and an exit position at
 * <code>getCursorPosition() + 1</code>.
 *
 * @param document the document
 * @param closingCharacter the exit character
 */
protected void setUpLinkedMode(IDocument document, char closingCharacter) {
	if (getTextViewer() != null && autocloseBrackets()) {
		int offset= getReplacementOffset() + getCursorPosition();
		int exit= getReplacementOffset() + getReplacementString().length();
		try {
			LinkedPositionGroup group= new LinkedPositionGroup();
			group.addPosition(new LinkedPosition(document, offset, 0, LinkedPositionGroup.NO_STOP));

			LinkedModeModel model= new LinkedModeModel();
			model.addGroup(group);
			model.forceInstall();

			LinkedModeUI ui= new EditorLinkedModeUI(model, getTextViewer());
			ui.setSimpleMode(true);
			ui.setExitPolicy(new ExitPolicy(closingCharacter, document));
			ui.setExitPosition(getTextViewer(), exit, 0, Integer.MAX_VALUE);
			ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
			ui.enter();
		} catch (BadLocationException x) {
			JavaPlugin.log(x);
		}
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:32,代码来源:AbstractJavaCompletionProposal.java

示例3: startLinkedEdit

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
private void startLinkedEdit(List<IRegion> selections, ITextViewer viewer, Point originalSelection)
		throws BadLocationException {
	final LinkedPositionGroup linkedPositionGroup = new LinkedPositionGroup();
	for (IRegion selection : selections) {
		linkedPositionGroup.addPosition(new LinkedPosition(viewer.getDocument(), selection.getOffset(), selection
				.getLength()));
	}

	LinkedModeModel model = new LinkedModeModel();
	model.addGroup(linkedPositionGroup);
	model.forceInstall();
	//FIXME can add a listener here to listen for the end of linked mode
	//model.addLinkingListener(null);

	LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
	ui.setExitPolicy(new DeleteBlockingExitPolicy(viewer.getDocument()));
	ui.enter();

	// by default the text being edited is selected so restore original selection
	viewer.setSelectedRange(originalSelection.x, originalSelection.y);
}
 
开发者ID:caspark,项目名称:eclipse-multicursor,代码行数:22,代码来源:SelectNextOccurrenceHandler.java

示例4: applyLinkedMode

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
protected void applyLinkedMode(ITextViewer viewer) throws BadLocationException {
	LinkedModeModel model = getLinkedModeModel(viewer);
	if(model == null) {
		return;
	}
	model.forceInstall();
	
	LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
	ui.setExitPolicy(new CompletionProposalExitPolicy());
	ui.setExitPosition(viewer, endPositionAfterApply, 0, Integer.MAX_VALUE);
	if(firstLinkedModeGroupPosition != -1) {
		positionAfterApply = null;
	}
	ui.setCyclingMode(LinkedModeUI.CYCLE_WHEN_NO_PARENT);
	ui.setDoContextInfo(true);
	ui.enableColoredLabels(true);
	
	ui.enter();
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:20,代码来源:LangCompletionProposal.java

示例5: apply

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
public void apply(IDocument document) {
    try {
        if (fentry.arguments > 0) {
            StringBuffer displayKey = new StringBuffer(fentry.key);
            for (int j=0; j < fentry.arguments; j++)
                displayKey.append("{}");
            document.replace(fReplacementOffset, fReplacementLength, displayKey.toString());
            if (TexlipsePlugin.getDefault().getPreferenceStore()
                    .getBoolean(TexlipseProperties.SMART_PARENS)){
                LinkedModeModel model= new LinkedModeModel();
                for (int j=0; j < fentry.arguments; j++){
                    int newOffset = fReplacementOffset + fentry.key.length() + j*2 + 1;
                    LinkedPositionGroup group = new LinkedPositionGroup();
                    group.addPosition(new LinkedPosition(document, newOffset, 0, LinkedPositionGroup.NO_STOP));
                    model.addGroup(group);
                }
                model.forceInstall();
                LinkedModeUI ui = new EditorLinkedModeUI(model, fviewer);
                ui.setSimpleMode(false);
                ui.setExitPolicy(new ExitPolicy('}', fviewer));
                ui.setExitPosition(fviewer, fReplacementOffset + displayKey.length(),
                        0, Integer.MAX_VALUE);
                ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
                ui.enter();
            }
        } else {
            document.replace(fReplacementOffset, fReplacementLength, fentry.key);
        }
    } catch (BadLocationException x) {
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:32,代码来源:TexCompletionProposal.java

示例6: start

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
public boolean start(IRenameElementContext renameElementContext, IProgressMonitor monitor) {
	if (renameElementContext == null)
		throw new IllegalArgumentException("RenameElementContext is null");
	this.linkedPositionGroup = linkedPositionGroupCalculator.getLinkedPositionGroup(renameElementContext, monitor);
	if (linkedPositionGroup == null || linkedPositionGroup.isEmpty())
		return false;
	this.editor = (XtextEditor) renameElementContext.getTriggeringEditor();
	this.focusEditingSupport = new FocusEditingSupport();
	ISourceViewer viewer = editor.getInternalSourceViewer();
	IDocument document = viewer.getDocument();
	originalSelection = viewer.getSelectedRange();
	currentPosition = linkedPositionGroup.getPositions()[0];
	originalName = getCurrentName();
	try {
		linkedModeModel = new LinkedModeModel();
		linkedModeModel.addGroup(linkedPositionGroup);
		linkedModeModel.forceInstall();
		linkedModeModel.addLinkingListener(new EditorSynchronizer());
		LinkedModeUI ui = new EditorLinkedModeUI(linkedModeModel, viewer);
		ui.setExitPolicy(new ExitPolicy(document));
		if (currentPosition.includes(originalSelection.x))
			ui.setExitPosition(viewer, originalSelection.x, 0, Integer.MAX_VALUE);
		ui.enter();
		if (currentPosition.includes(originalSelection.x)
				&& currentPosition.includes(originalSelection.x + originalSelection.y))
			viewer.setSelectedRange(originalSelection.x, originalSelection.y);
		if (viewer instanceof IEditingSupportRegistry) {
			IEditingSupportRegistry registry = (IEditingSupportRegistry) viewer;
			registry.register(focusEditingSupport);
		}
		openPopup();
		return true;
	} catch (BadLocationException e) {
		throw new WrappedException(e);
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:37,代码来源:RenameLinkedMode.java

示例7: apply

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
@Override
public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
	apply(viewer.getDocument());
	
	try {
		LinkedModeModel model = new LinkedModeModel();

		StringBuffer insert = new StringBuffer();
		insert.append(macro.name);
		insert.append("(");

		int parameterOffset = position.offset + insert.length();
		for (int k = 0; k < macro.parameters.length; k++) {
			LinkedPositionGroup group = new LinkedPositionGroup();

			if (k > 0)
				// space between parameters
				parameterOffset++;

			group.addPosition(new LinkedPosition(viewer.getDocument(), parameterOffset, macro.parameters[k].length(),
					LinkedPositionGroup.NO_STOP));
			model.addGroup(group);
			
			parameterOffset += macro.parameters[k].length();
		}
		
		model.forceInstall();

		LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
		ui.setExitPosition(viewer, parameterOffset + 1, 0, Integer.MAX_VALUE);
		ui.setCyclingMode(LinkedModeUI.CYCLE_ALWAYS);
		ui.enter();
		
		fSelectedRegion = ui.getSelectedRegion();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:39,代码来源:VelocityTemplateProposal.java

示例8: apply

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
/**
 * Special code added to allow tabstop positions so we can easily tab past the quotes for Events/Attributes.
 */
@Override
public void apply(ITextViewer viewer, char trigger, int stateMask, int offset)
{
	super.apply(viewer, trigger, stateMask, offset);

	// See if there are any positions that should be linked. Last is always exit, first is cursor position
	if (_positions != null && _positions.length > 0)
	{
		IDocument document = viewer.getDocument();
		boolean validPrefix = isValidPrefix(getPrefix(document, offset), getDisplayString());
		int shift = (validPrefix) ? offset - this._replacementOffset : 0;

		try
		{
			LinkedModeModel.closeAllModels(document); // Exit out of any existing linked mode

			LinkedModeModel model = new LinkedModeModel();
			int i = 0;
			for (int pos : _positions)
			{
				LinkedPositionGroup group = new LinkedPositionGroup();
				group.addPosition(new LinkedPosition(document, (offset - shift) + pos, 0, i++));
				model.addGroup(group);
			}

			model.forceInstall();
			LinkedModeUI ui = new LinkedModeUI(model, viewer);
			ui.setCyclingMode(LinkedModeUI.CYCLE_ALWAYS);
			ui.setExitPosition(viewer, (offset - shift) + _positions[_positions.length - 1], 0, Integer.MAX_VALUE);
			ui.enter();
		}
		catch (BadLocationException e)
		{
			IdeLog.logError(XMLPlugin.getDefault(), e);
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:41,代码来源:XMLAttributeProposal.java

示例9: apply

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
/**
 * Special code added to allow tabstop positions so we can easily tab past the quotes for Events/Attributes.
 */
@Override
public void apply(ITextViewer viewer, char trigger, int stateMask, int offset)
{
	super.apply(viewer, trigger, stateMask, offset);

	// See if there are any positions that should be linked. Last is always exit, first is cursor position
	if (_positions != null && _positions.length > 0)
	{
		IDocument document = viewer.getDocument();
		boolean validPrefix = isValidPrefix(getPrefix(document, offset), getDisplayString());
		int shift = (validPrefix) ? offset - this._replacementOffset : 0;

		try
		{
			LinkedModeModel.closeAllModels(document); // Exit out of any existing linked mode

			LinkedModeModel model = new LinkedModeModel();
			int i = 0;
			for (int pos : _positions)
			{
				LinkedPositionGroup group = new LinkedPositionGroup();
				group.addPosition(new LinkedPosition(document, (offset - shift) + pos, 0, i++));
				model.addGroup(group);
			}

			model.forceInstall();
			LinkedModeUI ui = new LinkedModeUI(model, viewer);
			ui.setCyclingMode(LinkedModeUI.CYCLE_ALWAYS);
			ui.setExitPosition(viewer, (offset - shift) + _positions[_positions.length - 1], 0, Integer.MAX_VALUE);
			ui.enter();
		}
		catch (BadLocationException e)
		{
			IdeLog.logError(HTMLPlugin.getDefault(), e);
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:41,代码来源:AttributeOrEventProposal.java

示例10: apply

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
@Override
public void apply(IDocument document, char trigger, int offset) {
	super.apply(document, trigger, offset);
	int baseOffset= getReplacementOffset();
	String replacement= getReplacementString();

	if (fArgumentOffsets != null && getTextViewer() != null) {
		try {
			LinkedModeModel model= new LinkedModeModel();
			for (int i= 0; i != fArgumentOffsets.length; i++) {
				LinkedPositionGroup group= new LinkedPositionGroup();
				group.addPosition(new LinkedPosition(document, baseOffset + fArgumentOffsets[i], fArgumentLengths[i], LinkedPositionGroup.NO_STOP));
				model.addGroup(group);
			}

			model.forceInstall();
			JavaEditor editor= getJavaEditor();
			if (editor != null) {
				model.addLinkingListener(new EditorHighlightingSynchronizer(editor));
			}

			LinkedModeUI ui= new EditorLinkedModeUI(model, getTextViewer());
			ui.setExitPosition(getTextViewer(), baseOffset + replacement.length(), 0, Integer.MAX_VALUE);
			ui.setExitPolicy(new ExitPolicy(')', document));
			ui.setDoContextInfo(true);
			ui.setCyclingMode(LinkedModeUI.CYCLE_WHEN_NO_PARENT);
			ui.enter();

			fSelectedRegion= ui.getSelectedRegion();

		} catch (BadLocationException e) {
			JavaPlugin.log(e);
			openErrorDialog(e);
		}
	} else {
		fSelectedRegion= new Region(baseOffset + replacement.length(), 0);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:39,代码来源:FilledArgumentNamesMethodProposal.java

示例11: goToLinkedMode

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
private void goToLinkedMode(ITextViewer viewer, int offset, IDocument doc, int exitPos, int iPar,
        List<Integer> offsetsAndLens) throws BadLocationException {
    if (!goToLinkedMode) {
        return;
    }
    if (offsetsAndLens.size() > 0) {
        LinkedModeModel model = new LinkedModeModel();

        for (int i = 0; i < offsetsAndLens.size(); i++) {
            Integer offs = offsetsAndLens.get(i);
            i++;
            Integer len = offsetsAndLens.get(i);
            if (i == 1) {
                firstParameterLen = len;
            }
            int location = offset + iPar + offs + 1;
            LinkedPositionGroup group = new LinkedPositionGroup();
            ProposalPosition proposalPosition = new ProposalPosition(doc, location, len, 0,
                    new ICompletionProposal[0]);
            group.addPosition(proposalPosition);
            model.addGroup(group);
        }

        model.forceInstall();

        final LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
        ui.setDoContextInfo(true); //set it to request the ctx info from the completion processor
        ui.setExitPosition(viewer, exitPos, 0, Integer.MAX_VALUE);
        Runnable r = new Runnable() {
            @Override
            public void run() {
                ui.enter();
            }
        };
        RunInUiThread.async(r);

    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:39,代码来源:AbstractLinkedModeCompletionProposal.java

示例12: doApply

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
/**
 * Really do apply the proposal. Assumed to be run within the prevent flickering mode.
 */
private int doApply(QualifiedName qualifiedName, String alias, IDocument document,
		ConfigurableCompletionProposal proposal) throws BadLocationException {
	String shortSemanticReplacementString = alias != null ? alias : lastSegmentOrDefaultHost(qualifiedName);
	String shortSyntacticReplacementString = valueConverter.toString(shortSemanticReplacementString);

	ImportRewriter importRewriter = importRewriterFactory.create(document, context);

	ReplaceEdit replaceEdit = new ReplaceEdit(
			proposal.getReplacementOffset(),
			proposal.getReplacementLength(),
			shortSyntacticReplacementString);
	MultiTextEdit compound = new MultiTextEdit();
	AliasLocation aliasLocation = null;
	if (alias != null) {
		aliasLocation = importRewriter.addSingleImport(qualifiedName, alias, compound);
	} else {
		importRewriter.addSingleImport(qualifiedName, compound);
	}
	compound.addChild(replaceEdit);

	Position caret = new Position(proposal.getReplacementOffset(), 0);
	document.addPosition(caret);
	compound.apply(document);
	document.removePosition(caret);

	int cursorPosition = caret.getOffset();
	proposal.setReplacementOffset(cursorPosition - shortSemanticReplacementString.length());
	proposal.setCursorPosition(shortSemanticReplacementString.length());

	if (aliasLocation != null) {
		final int aliasOffset = aliasLocation.getBaseOffset() + aliasLocation.getRelativeOffset();
		final int aliasLength = shortSyntacticReplacementString.length();
		N4JSCompletionProposal castedProposal = (N4JSCompletionProposal) proposal;
		castedProposal.setLinkedModeBuilder((appliedProposal, currentDocument) -> {
			try {
				LinkedPositionGroup group = new LinkedPositionGroup();
				group.addPosition(new LinkedPosition(
						currentDocument,
						aliasOffset,
						aliasLength,
						LinkedPositionGroup.NO_STOP));
				group.addPosition(new LinkedPosition(
						currentDocument,
						proposal.getReplacementOffset(),
						proposal.getCursorPosition(),
						LinkedPositionGroup.NO_STOP));
				proposal.setSelectionStart(proposal.getReplacementOffset());
				proposal.setSelectionLength(proposal.getCursorPosition());
				LinkedModeModel model = new LinkedModeModel();
				model.addGroup(group);
				model.forceInstall();

				LinkedModeUI ui = new LinkedModeUI(model, viewer);
				ui.setExitPolicy(new IdentifierExitPolicy('\n'));
				ui.setExitPosition(
						viewer,
						proposal.getCursorPosition() + proposal.getReplacementOffset(),
						0,
						Integer.MAX_VALUE);
				ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
				ui.enter();
			} catch (BadLocationException e) {
				logger.error(e.getMessage(), e);
			}
		});
	}
	return cursorPosition;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:72,代码来源:FQNImporter.java

示例13: start

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
public void start() {
	if (getActiveLinkedMode() != null) {
		// for safety; should already be handled in RenameJavaElementAction
		fgActiveLinkedMode.startFullDialog();
		return;
	}

	ISourceViewer viewer = fEditor.getViewer();
	IDocument document = viewer.getDocument();

	ITypeScriptFile tsFile = fEditor.getTypeScriptFile();
	tsFile.setDisableChanged(true);
	fOriginalSelection = viewer.getSelectedRange();
	int offset = fOriginalSelection.x;

	try {
		fLinkedPositionGroup = new LinkedPositionGroup();
		if (viewer instanceof ITextViewerExtension6) {
			IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
			if (undoManager instanceof IUndoManagerExtension) {
				IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
				IUndoContext undoContext = undoManagerExtension.getUndoContext();
				IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
				fStartingUndoOperation = operationHistory.getUndoOperation(undoContext);
			}
		}

		// Find occurrences
		List<OccurrencesResponseItem> occurrences = tsFile.occurrences(offset).get(1000, TimeUnit.MILLISECONDS);

		// Create Eclipse linked position from the occurrences list.
		int start, length;
		for (int i = 0; i < occurrences.size(); i++) {
			OccurrencesResponseItem item = occurrences.get(i);
			start = tsFile.getPosition(item.getStart());
			length = tsFile.getPosition(item.getEnd()) - start;
			LinkedPosition linkedPosition = new LinkedPosition(document, start, length, i);
			if (i == 0) {
				fOriginalName = document.get(start, length);
				fNamePosition = linkedPosition;
			}
			fLinkedPositionGroup.addPosition(linkedPosition);
		}

		fLinkedModeModel = new LinkedModeModel();
		fLinkedModeModel.addGroup(fLinkedPositionGroup);
		fLinkedModeModel.forceInstall();
		fLinkedModeModel.addLinkingListener(new EditorHighlightingSynchronizer(fEditor));
		fLinkedModeModel.addLinkingListener(new EditorSynchronizer());

		LinkedModeUI ui = new EditorLinkedModeUI(fLinkedModeModel, viewer);
		ui.setExitPosition(viewer, offset, 0, Integer.MAX_VALUE);
		ui.setExitPolicy(new ExitPolicy(document));
		ui.enter();

		viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y); // by
																				// default,
																				// full
																				// word
																				// is
																				// selected;
																				// restore
																				// original
																				// selection

		if (viewer instanceof IEditingSupportRegistry) {
			IEditingSupportRegistry registry = (IEditingSupportRegistry) viewer;
			registry.register(fFocusEditingSupport);
		}

		openSecondaryPopup();
		// startAnimation();
		fgActiveLinkedMode = this;

	} catch (Exception e) {
		JSDTTypeScriptUIPlugin.log(e);
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:79,代码来源:RenameLinkedMode.java

示例14: enterLinkedModeForPrefix

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
/**
 * Enters the linked mode for editing the namespace prefix we generated.
 */
private void enterLinkedModeForPrefix(IDocument document,
    ITextViewer viewer, IDOMElement rootElement, String prefix)
    throws BadLocationException {

  int linkedPosSequence = 0;

  // The prefix is the first thing entered at the start position
  LinkedPosition pos1 = new LinkedPosition(document, startPosition,
      prefix.length(), linkedPosSequence++);

  // The prefix is also at the cursor position + 2 (those two following
  // characters are '<' and '/')
  LinkedPosition pos2 = new LinkedPosition(document, cursorPosition + 2,
      prefix.length(), linkedPosSequence++);

  IDOMElement rootDomElement = (IDOMElement) rootElement;
  // TODO: use UiBinderConstants.XMLNS_PREFIX, but that has been modified in
  // a parallel CL. Will switch to using that constant in the latter of this
  // and that other CL.
  final String xmlnsPrefix = "xmlns:";
  String fullPrefixName = xmlnsPrefix + prefix;
  IDOMAttr domAttribute = (IDOMAttr) rootDomElement.getAttributeNode(fullPrefixName);
  LinkedPosition pos3 = new LinkedPosition(document,
      domAttribute.getStartOffset() + xmlnsPrefix.length(),
      prefix.length(), linkedPosSequence++);

  LinkedPositionGroup group = new LinkedPositionGroup();
  group.addPosition(pos1);
  group.addPosition(pos2);
  group.addPosition(pos3);

  // Boilerplate stuff below
  LinkedModeModel model = new LinkedModeModel();
  model.addGroup(group);
  model.forceInstall();

  LinkedModeUI ui = new LinkedModeUI(model, viewer);
  ui.enter();

  wasLinkedModeEntered = true;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:45,代码来源:WidgetProposalComputer.java

示例15: getLinkedPositions

import org.eclipse.jface.text.link.LinkedModeUI; //导入依赖的package包/类
/**
 * Sets up linked positions and installs them on the viewer.
 * 
 */
protected void getLinkedPositions(ITextViewer viewer) {
	final String replacement = getReplacementString();
	final IDocument document = viewer.getDocument();
	final int length = replacement.length();
	boolean inAttribute = false, hasGroup = false;
	int offset = 0;
	char attType = 0;
	int exitPosition = -1;
	LinkedModeModel model = new LinkedModeModel();

	try {
		for (int i = 0; i < length; i++) {
			final char c = replacement.charAt(i);
			switch (c) {
			case '=':
				break;
			case '\'':
			case '\"':
				if (!inAttribute) {
					offset = i;
					attType = c;
					inAttribute = true;
				} else {
					// Found matching quotes establishing an attribute value
					// region
					if (attType == c && replacement.charAt(i - 1) != '\\') {
						inAttribute = false; // Record position length
						addPosition(model, document, getReplacementOffset()
								+ offset + 1, i - offset - 1);
						hasGroup = true;
					}
				}
				break;
			case '>':
				if (!inAttribute && exitPosition == -1) {
					exitPosition = getReplacementOffset() + i + 1;
				}
				break;
			}
		}
		if (hasGroup) {
			model.forceInstall();
			final LinkedModeUI ui = new EditorLinkedModeUI(model, viewer);
			ui.setExitPosition(viewer,
					exitPosition < 0 ? getReplacementOffset()
							+ getReplacementLength() + replacement.length()
							- 1 : exitPosition, 0, Integer.MAX_VALUE);
			ui.setCyclingMode(LinkedModeUI.CYCLE_WHEN_NO_PARENT);
			ui.setDoContextInfo(true);
			ui.enter();
			fSelectedRegion = ui.getSelectedRegion();
		}
	} catch (BadLocationException e) {
		Logger.logException(e);
	}
}
 
开发者ID:angelozerr,项目名称:eclipse-wtp-json,代码行数:61,代码来源:JSONKeyCompletionProposal.java


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