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


Java CaretEvent类代码示例

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


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

示例1: caretMoved

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
@Override
public void caretMoved(CaretEvent event) {
	int offset = event.caretOffset;
	int line = unitSelectionArea.getLineAtOffset(offset);
	if (line % 2 == 0) {
		String lineContent = unitSelectionArea.getLine(line);
		if (!lineContent.trim().isEmpty()) {
			// remove previous selection
			int lineCount = unitSelectionArea.getLineCount();
			unitSelectionArea.setLineBackground(0, lineCount, null);

			// set the new selection
			unitSelectionArea.setLineBackground(line, 1, lineHighlight);

			int unitIndex = line / 2;
			selectedUnit = selectedMethod.getUnits().get(unitIndex);
		}
	}
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:20,代码来源:UnitBreakpointPropertiesDialog.java

示例2: caretMoved

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
@Override
public void caretMoved(CaretEvent event) {
	if (event == null) {
		return;
	}
	lastCaretPosition = event.caretOffset;
	if (EclipseDevelopmentSettings.DEBUG_ADD_SPECIAL_TEXTS) {
		setStatusLineMessage("caret moved:" + event.caretOffset);
	}
	if (ignoreNextCaretMove) {
		ignoreNextCaretMove = false;
		return;
	}
	if (outlinePage == null) {
		return;
	}
	outlinePage.onEditorCaretMoved(event.caretOffset);
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:19,代码来源:AbstractGroovyBasedEditor.java

示例3: BTSTextSelectionEvent

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
public BTSTextSelectionEvent(TypedEvent event, BTSObject parentObject) {
	this.setOriginalEvent(event);
	this.display = event.display;
	this.widget = event.widget;
	this.time = event.time;
	if (event instanceof CaretEvent)
	{
		this.x = ((CaretEvent)event).caretOffset;
		this.y = ((CaretEvent)event).caretOffset;
	}
	else if (event instanceof SelectionEvent)
	{
		this.x = ((SelectionEvent)event).x;
		this.y = ((SelectionEvent)event).y;
		this.text = ((SelectionEvent)event).text;
		
	}
	this.setParentObject(parentObject);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:20,代码来源:BTSTextSelectionEvent.java

示例4: caretMoved

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
@Override
public void caretMoved(CaretEvent event) {
	if (event == null) {
		return;
	}
	lastCaretPosition = event.caretOffset;
	if (ignoreNextCaretMove) {
		ignoreNextCaretMove = false;
		return;
	}
	if (outlinePage == null) {
		return;
	}
	outlinePage.onEditorCaretMoved(event.caretOffset);
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:16,代码来源:BatchEditor.java

示例5: internalSetCaretListener

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
private void internalSetCaretListener(OnValueChanged<Integer> l) {
	getStyledText().addCaretListener(new CaretListener() {

		@Override
		public void caretMoved(CaretEvent event) {
			l.notify(event.caretOffset);
		}
	});
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:10,代码来源:FtcEditor.java

示例6: initCaretListener

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
protected void initCaretListener() {		
		CaretListener caretListener = new CaretListener() {
			@Override
			public void caretMoved(CaretEvent event) {
				logger.trace("caret moved = "+event.caretOffset+" selection (old) = "+text.getSelection());	
//				updateLineAndWordObjects();
			}
		};
		addUserCaretListener(caretListener);
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:11,代码来源:ATranscriptionWidget.java

示例7: caretMoved

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
public void caretMoved(CaretEvent event) {
    // TODO Auto-generated method stub
    editor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(
            null);
    editor.getViewer().getTextWidget().removeCaretListener(this);
    try {
     resource.deleteMarkers(PAREN_ERROR_MARKER_TYPE, false, 99);
 } catch (CoreException e) {
     // TODO Auto-generated catch block
     System.out.println("caretMoved threw exception");
 }

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

示例8: caretMoved

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
@Override
public void caretMoved(CaretEvent event) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window == null) return;
    if (window.getPartService() == null) return;
    if (window.getPartService().getActivePart() == null) return;
    if (window.getPartService().getActivePart().getSite() == null) return;
    if (window.getPartService().getActivePart().getSite().getPage() == null) return;
    if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() == null) return;
    if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput() == null) return;

    // log file if one is opened by default
    IEditorInput input = window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput();
    if (input instanceof IURIEditorInput) {
        URI uri = ((IURIEditorInput)input).getURI();
        if (uri != null && uri.getPath() != null) {
            String currentFile = uri.getPath();
            long currentTime = System.currentTimeMillis() / 1000;
            if (!currentFile.equals(WakaTime.getDefault().lastFile) || WakaTime.getDefault().lastTime + WakaTime.FREQUENCY * 60 < currentTime) {
                WakaTime.sendHeartbeat(currentFile, WakaTime.getActiveProject(), false);
                WakaTime.getDefault().lastFile = currentFile;
                WakaTime.getDefault().lastTime = currentTime;
            }
        }
    }
}
 
开发者ID:wakatime,项目名称:eclipse-wakatime,代码行数:28,代码来源:CustomCaretListener.java

示例9: caretMoved

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
public void caretMoved(CaretEvent event)
{
    update();
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:5,代码来源:ProofFoldAction.java

示例10: processTextSelection

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
/**
 * Process text selection.
 *
 * @param event the event
 */
protected void processTextSelection(TypedEvent event) {
	BTSTextSelectionEvent btsEvent = new BTSTextSelectionEvent(event, text);
	btsEvent.data = text;
	if (this.delaySelectionJob == null) {
		this.btsTextEvent = btsEvent;
		Job.getJobManager().cancel(BTSTextSelectionEvent.class);
		delaySelectionJob = new Job("delay_selection_processing"){
			@Override
			protected IStatus run(IProgressMonitor monitor) {
				while (System.nanoTime() < lastSelectionTimeStamp + 350000000)
					try {
						Thread.sleep(100);
					} catch (InterruptedException e) {
						e.printStackTrace();
						return Status.CANCEL_STATUS;
					}
				final BTSTextSelectionEvent btsEvent = btsTextEvent;
				sync.asyncExec(new Runnable() {
					
					@Override
					public void run() {
						List<BTSModelAnnotation> annotations = getModelAnnotationAtSelection(
								btsEvent.x, btsEvent.y, btsEvent);							
						btsEvent.getTextAnnotations().addAll(annotations);
						processSelection(annotations, false, btsEvent);
						selectionService.setSelection(btsEvent);
						
					}
				});
				delaySelectionJob = null;
				return Status.OK_STATUS;
			}
			@Override
			public boolean belongsTo(Object family) {
				return family.equals(BTSTextSelectionEvent.class);
			}
		};
		this.delaySelectionJob.schedule(400);
	} else if (!(event instanceof CaretEvent) || (this.btsTextEvent == null)
		|| (this.btsTextEvent.getOriginalEvent() instanceof CaretEvent))
		this.btsTextEvent = btsEvent;
	this.lastSelectionTimeStamp = System.nanoTime();
}
 
开发者ID:cplutte,项目名称:bts,代码行数:49,代码来源:EgyTextEditorPart.java

示例11: caretMoved

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
@Override
public void caretMoved(CaretEvent ignored)
{
	int caretOffset = source.getCaretOffset();
	int lineIndex = source.getLineAtOffset(caretOffset);
	int lineOffset = source.getOffsetAtLine(lineIndex);

	//   play line margin bell
	if(lineMarginClip != null && lineMarginBell > 0 && caretOffset == prevCaretOffset + 1)
	{
		if(caretOffset - lineOffset == lineMarginBell)
		if(!lineMarginClip.isActive())
		{
			lineMarginClip.setFramePosition(0);
			lineMarginClip.start();
		}
	}

	//   play line end bell
	if(lineEndClip != null && charsPerLine > 0 && caretOffset == prevCaretOffset + 1)
	{
		if(caretOffset - lineOffset == charsPerLine)
			if(!lineEndClip.isActive())
			{
				lineEndClip.setFramePosition(0);
				lineEndClip.start();
			}
	}

	prevCaretOffset = caretOffset;

	//   scroll other text to match current
	if(lineIndex == prevLineIndex)
		return;
	prevLineIndex = lineIndex;
	if(source != currentText)
		return;

	int sourceLinePixel = source.getLinePixel(lineIndex);
	int sourceHeight = source.getClientArea().height;
	int sourceLineHeight = source.getLineHeight();

	//   check if have to wait until after paint event
	if(sourceLinePixel < 0 || sourceLinePixel + sourceLineHeight > sourceHeight)
		adjustOtherThread.waitPainted(source, other);
	else
		adjustOtherThread.adjustOther(source, other);
}
 
开发者ID:MikeGray-APH,项目名称:BrailleZephyr,代码行数:49,代码来源:BZStyledText.java

示例12: selectionChanged

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
	
	if (part != null) {
		
		Class c = part.getClass();		
		
		if (c.getName().equals("org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor")) {
			
			IEditorPart editor = (IEditorPart) part;
				
			
			final StyledText st = (StyledText) editor.getAdapter(Control.class);
						
			
			Listener[] ls = st.getListeners(SWT.None);
			
			
			if (st.getListeners(SWT.None).length==0){
				
				st.addCaretListener(new CaretListener() {
					
					@Override
					public void caretMoved(CaretEvent event) {
						// TODO Auto-generated method stub
						System.out.println("SOY EL CARACTER DEL CODIGO: " + event.caretOffset);
						int nextCaretWithNode = event.caretOffset;
						ArrayList<JavaMarioNode> node = null;
						while (node == null && nextCaretWithNode<st.getCharCount()) node = visitor.hm.get(++nextCaretWithNode);
						if (node!=null) {
							System.out.println("SOY EL MARIONODE ASOCIADO: " + node.get(0) + ", x="+node.get(0).rectangle.x+" y="+node.get(0).rectangle.y);
							if (!node.get(0).rectangle.isEmpty()) {
								
								marioX = node.get(0).rectangle.x*16;
								marioY = drawingBox.height - node.get(0).rectangle.y*16-maryoImg.getBounds().height;
								myCanvas.redraw();
																										
							}
						}
					}
				});
			}
			
			IEditorInput input = editor.getEditorInput();
			System.out.println("Evento de selecci�n sobre un editor java");
			System.out.println("IWortkbenchPart = "+c.getName());				
			System.out.println("IEditorInput = "+input.getName());
			System.out.println("----------------CONTENT-----------------");
			
			System.out.println("----------------------------------------");
		}
	}		
	
	System.out.println(getSite().getPage().getEditorReferences().length+" editores abiertos.");
	action1.run();
}
 
开发者ID:javiplay,项目名称:Progamer,代码行数:57,代码来源:ProgamerMainView.java

示例13: construct

import org.eclipse.swt.custom.CaretEvent; //导入依赖的package包/类
@Override
public Control construct(Composite parent) {
	Composite composite = new Composite(parent, SWT.BORDER);
	GridLayoutFactory.swtDefaults().numColumns(3).applyTo(composite);
	GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
			.grab(true, true).applyTo(composite);

	Display display = composite.getDisplay();
	Color green = new Color(composite.getDisplay(), new RGB(0, 255, 0));
	Color red = new Color(composite.getDisplay(), new RGB(255, 0, 0));

	StyledText t1 = new StyledText(composite, SWT.SINGLE | SWT.BORDER);
	t1.setLayoutData(new GridData(GridData.FILL_BOTH));
	t1.setText("SINGLE, Green Background");
	t1.setBackground(green);

	StyledText t2 = new StyledText(composite, SWT.FULL_SELECTION
			| SWT.BORDER);
	t2.setLayoutData(new GridData(GridData.FILL_BOTH));
	t2.setText("Full_Selection, Red Foreground");
	t2.setForeground(red);

	StyledText t3 = new StyledText(composite, SWT.MULTI | SWT.BORDER);
	t3.setLayoutData(new GridData(GridData.FILL_BOTH));
	t3.setText("MULTI, Style Range is applied");

	StyleRange styleRange = new StyleRange();
	styleRange.start = 0;
	styleRange.length = t3.getText().length();
	styleRange.fontStyle = SWT.BOLD;
	styleRange.foreground = display.getSystemColor(SWT.COLOR_BLUE);
	t3.setStyleRange(styleRange);

	StyledText t4 = new StyledText(composite, SWT.READ_ONLY | SWT.BORDER);
	t4.setLayoutData(new GridData(GridData.FILL_BOTH));
	t4.setText("READ ONLY");

	StyleRange styleRange2 = new StyleRange();
	styleRange2.start = 5;
	styleRange2.length = t4.getText().length() - 5;
	styleRange2.fontStyle = SWT.ITALIC;
	styleRange2.foreground = display.getSystemColor(SWT.COLOR_MAGENTA);
	t4.setStyleRange(styleRange2);

	StyledText t5 = new StyledText(composite, SWT.WRAP | SWT.BORDER);
	t5.setLayoutData(new GridData(GridData.FILL_BOTH));
	t5.setText("WRAP");

	StyledText t6 = new StyledText(composite, SWT.MULTI | SWT.BORDER);
	t6.setLayoutData(new GridData(GridData.FILL_BOTH));
	t6.setText("This is a text for testing Caret Offset");
	CaretListener caretListener = new CaretListener() {
		@Override
		public void caretMoved(CaretEvent event) {
			Shell shell = event.widget.getDisplay().getActiveShell();
			MessageDialog.openInformation(shell, "Info", "Info for you");
		}
	};
	t6.addCaretListener(caretListener);

	StyledText tMouseDown = new StyledText(composite, SWT.MULTI | SWT.BORDER);
	tMouseDown.setLayoutData(new GridData(GridData.FILL_BOTH));
	tMouseDown.setText("Handler on mouse down Listener");
	tMouseDown.addMouseListener(new StyledTextMouseDownHandler());

	StyledText tArgument = new StyledText(composite, SWT.MULTI | SWT.BORDER);
	tArgument.setLayoutData(new GridData(GridData.FILL_BOTH));
	tArgument.setText("Custom Argument Handler on mouse with case e.button=SWT.KeyDown");
	@SuppressWarnings("unused")
	ArgumentHandler argumentHandler = new ArgumentHandler(tArgument);

	StyledText tMouseUp = new StyledText(composite, SWT.MULTI | SWT.BORDER);
	tMouseUp.setLayoutData(new GridData(GridData.FILL_BOTH));
	tMouseUp.setText("Handler on mouse up Listener");
	tMouseUp.addMouseListener(new StyledTextMouseUpHandler());

	return null;

}
 
开发者ID:xored,项目名称:q7.quality.mockups,代码行数:80,代码来源:Styled_Text.java


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