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


Java StyledText类代码示例

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


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

示例1: createStyledTextRenderer

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
private static /* org.eclipse.swt.custom.StyledTextRenderer */ Object createStyledTextRenderer(
		StyledText styledText, ILineSpacingProvider lineSpacingProvider) throws Exception {
	// get the org.eclipse.swt.custom.StyledTextRenderer instance of
	// StyledText
	/* org.eclipse.swt.custom.StyledTextRenderer */ Object originalRenderer = getRendererField(styledText)
			.get(styledText);

	// Create a Javassist proxy
	ProxyFactory factory = new ProxyFactory();
	factory.setSuperclass(originalRenderer.getClass());
	StyledTextRenderer renderer = new StyledTextRenderer(styledText, originalRenderer.getClass());
	renderer.setLineSpacingProvider(lineSpacingProvider);
	factory.setHandler(renderer);
	return factory.create(new Class[] { Device.class, StyledText.class },
			new Object[] { styledText.getDisplay(), styledText });
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:17,代码来源:StyledTextPatcher.java

示例2: createSuffixText

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
 * Creates, configures and returns the suffix text control.
 */
private StyledText createSuffixText() {
	StyledText styledText = new StyledText(this, SWT.TRANSPARENT);
	styledText.setText("");
	styledText.setForeground(INACTIVE_COLOR);
	styledText.setBackground(getDisplay().getSystemColor(SWT.COLOR_TRANSPARENT));
	styledText.setEditable(false);
	styledText.setEnabled(false);
	styledText.setLeftMargin(0);

	return styledText;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:15,代码来源:SuffixText.java

示例3: createPartControl

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
@Override
public void createPartControl(Composite parent) {
	super.createPartControl(parent);

	Control adapter = getAdapter(Control.class);
	if (adapter instanceof StyledText) {
		StyledText text = (StyledText) adapter;
		text.addCaretListener(new BatchEditorCaretListener());
	}

	
	activateBatchEditorContext();

	installAdditionalSourceViewerSupport();

	StyledText styledText = getSourceViewer().getTextWidget();
	styledText.addKeyListener(new BatchBracketInsertionCompleter(this));

	/*
	 * register as resource change listener to provide marker change
	 * listening
	 */
	ResourcesPlugin.getWorkspace().addResourceChangeListener(this);

	setTitleImageInitial();
}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:27,代码来源:BatchEditor.java

示例4: createPartControl

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
@Override
public void createPartControl(Composite parent) {
	super.createPartControl(parent);

	Control adapter = getAdapter(Control.class);
	if (adapter instanceof StyledText) {
		StyledText text = (StyledText) adapter;
		text.addCaretListener(new BashEditorCaretListener());
	}

	activateBashEditorContext();

	installAdditionalSourceViewerSupport();

	StyledText styledText = getSourceViewer().getTextWidget();
	styledText.addKeyListener(new BashBracketInsertionCompleter(this));

	/*
	 * register as resource change listener to provide marker change
	 * listening
	 */
	ResourcesPlugin.getWorkspace().addResourceChangeListener(this);

	setTitleImageInitial();
}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:26,代码来源:BashEditor.java

示例5: paint

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
@Override
public void paint(int reason) {
	IDocument document = textViewer.getDocument();
	if (document == null) {
		deactivate(false);
		return;
	}
	if (!fIsActive) {
		StyledText styledText = textViewer.getTextWidget();
		fIsActive = true;
		styledText.addPaintListener(this);
		redrawAll();
	} else if (reason == CONFIGURATION || reason == INTERNAL) {
		redrawAll();
	}
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:17,代码来源:ViewZoneChangeAccessor.java

示例6: draw

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
@Override
public void draw(int paintX, int paintSpaceLeadingX, int paintY, GC gc) {
	StyledText styledText = getTextViewer().getTextWidget();
	Rectangle client = styledText.getClientArea();
	gc.setBackground(styledText.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	styledText.drawBackground(gc, paintX, paintY, client.width, this.getHeightInPx());

	gc.setForeground(styledText.getDisplay().getSystemColor(SWT.COLOR_GRAY));

	Font font = new Font(styledText.getDisplay(), "Arial", 9, SWT.ITALIC);
	gc.setFont(font);
	String text = getText(gc, paintSpaceLeadingX);
	if (text != null) {
		int y = paintY + 4;
		gc.drawText(text, paintSpaceLeadingX, y);

		if (hoveredCodeLensEndX != null) {
			Point extent = gc.textExtent(text);
			gc.drawLine(hoveredCodeLensStartX, y + extent.y - 1, hoveredCodeLensEndX, y + extent.y - 1);
		}
	}
}
 
开发者ID:angelozerr,项目名称:codelens-eclipse,代码行数:23,代码来源:CodeLensViewZone.java

示例7: setupControls

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
 * Recursive function for setting up children controls for a control if it is
 * a composite and setting up the main control's manager.
 * @param part
 * @param control
 */
private void setupControls(IWorkbenchPart part, Control control) {
	//If composite, setup children controls.
    if (control instanceof Composite) {
        Composite composite = (Composite) control;

        Control[] children = composite.getChildren();
        if (children.length > 0 && children[0] != null) {
           for (Control curControl : children)
               setupControls(part, curControl);
        }
    }
    
    if (control instanceof StyledText) {
    	//set up styled text manager if there is one
    	setupStyledText((IEditorPart) part, (StyledText) control);
    	
    } else if (control instanceof Browser) {
    	//set up browser manager if there is one
    	setupBrowser((Browser) control);
    }
    //TODO: no control set up for a ProjectExplorer, since there isn't an need for 
    //a Manager right now, might be needed in the future
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:30,代码来源:ControlView.java

示例8: createTextWidget

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
protected void createTextWidget(String textContents) {
	StyledText styledText = new StyledText(getComposite(), SWT.NONE);
	styledText.setText(textContents);
	styledText.setFont(getCourierFont());
	styledText.setEditable(false);
	//styledText.setWordWrap(true);		// seems to throw size out-of-whack
	Point size = styledText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
	getComposite().setContent(styledText);
	getComposite().setExpandHorizontal(true);
	getComposite().setExpandVertical(true);
	getComposite().setMinWidth(size.x);
	getComposite().setMinHeight(size.y);
	getComposite().getContent().addListener(SWT.KeyUp, getToolbarCommandHandler());

	getToolItem().setSelection(true);		
	setContentTypeAdapter(new StyledTextAdapter(styledText, getFileEntry().getFilename()));
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:18,代码来源:TextFilterAdapter.java

示例9: createContents

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
private void createContents(String str) {
	aboutToolsShell = new Shell(getParent(), getStyle());
	aboutToolsShell.setImage(SWTResourceManager.getImage(ShortcutKeyExplain.class, Resource.IMAGE_ICON));
	aboutToolsShell.setSize(400, 391);
	aboutToolsShell.setText(getText());
	PubUtils.setCenterinParent(getParent(), aboutToolsShell);

	Link link = new Link(aboutToolsShell, SWT.NONE);
	link.setBounds(143, 336, 108, 17);
	link.setText("<a>www.itlaborer.com</a>");
	link.addSelectionListener(new LinkSelection());

	StyledText readMeTextLabel = new StyledText(aboutToolsShell,
			SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
	readMeTextLabel.setBounds(3, 33, 389, 297);
	readMeTextLabel.setText(str);

	Label label_2 = new Label(aboutToolsShell, SWT.NONE);
	label_2.setFont(org.eclipse.wb.swt.SWTResourceManager.getFont("微软雅黑", 9, SWT.BOLD));
	label_2.setText("快捷键说明:");
	label_2.setBounds(3, 12, 136, 17);
}
 
开发者ID:cnldw,项目名称:APITools,代码行数:23,代码来源:ShortcutKeyExplain.java

示例10: createStyledText

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
private StyledText createStyledText() {
	styledText = new StyledText(shell,
			SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); // SWT.WRAP
	GridData gridData = new GridData();
	styledText.setFont(
			new Font(shell.getDisplay(), "Source Code Pro Light", 10, SWT.NORMAL));
	gridData.horizontalAlignment = GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	gridData.verticalAlignment = GridData.FILL;
	gridData.grabExcessVerticalSpace = true;
	styledText.setLayoutData(gridData);
	styledText.addLineStyleListener(lineStyler);
	styledText.setEditable(false);
	styledText
			.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
	return styledText;
}
 
开发者ID:sergueik,项目名称:SWET,代码行数:18,代码来源:ScrolledTextEx.java

示例11: newTextArea

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
public StyledText newTextArea(Composite composite, boolean editable, int sty) {
    int style = SWT.MULTI | SWT.V_SCROLL;
    if (!editable)
        style |= SWT.READ_ONLY;
    else
        style |= SWT.WRAP;

    StyledText d = new StyledText(composite, style);
    d.setText("To be entered\ntest\n\test\ntest");
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 80;
    gd.widthHint = 460;
    gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
    d.setEditable(editable);
    d.setLayoutData(gd);
    d.setFont(FontShop.textFont());
    if (keyListener != null)
        d.addKeyListener(keyListener);
    d.setWordWrap(editable);
    WidgetShop.tweakTextWidget(d);
    return d;
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:23,代码来源:GridComposite.java

示例12: prevButtonListener

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
 *  The function will move cursor in reverse direction.
 * @param styledText
 * @param text
 * @param prevLineIndex
 * @param nextLineIndex
 * @return int[]
 */
public int[] prevButtonListener(StyledText styledText, String text, int prevLineIndex, int nextLineIndex){
	logger.debug("StyledText prev button selected");
	if(prevLineIndex == 0){
		prevLineIndex = styledText.getText().length() - 1;
	}
	int lastIndex = StringUtils.lastIndexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), prevLineIndex-1);
	
	if(lastIndex < 0 ){
		prevLineIndex = styledText.getText().length() - 1;
		prevLineIndex= StringUtils.lastIndexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), prevLineIndex-1);
		styledText.setSelection(prevLineIndex);
		setStyledRange(styledText, prevLineIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
		nextLineIndex = prevLineIndex + 1;
		return new int[]{prevLineIndex,nextLineIndex};
	}else{
		setStyledRange(styledText, lastIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
		styledText.setSelection(lastIndex);
		prevLineIndex = lastIndex;
		nextLineIndex = lastIndex + 1;
		styledText.redraw();
	}
	return new int[]{prevLineIndex,nextLineIndex};
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:32,代码来源:StyledTextEventListener.java

示例13: nextButtonListener

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
 * The function will move the cursor in forward direction.
 * @param styledText
 * @param text
 * @param prevLineIndex
 * @param nextLineIndex
 * @return int[]
 */
public int[] nextButtonListener(StyledText styledText, String text, int prevLineIndex, int nextLineIndex){
	logger.debug("StyledText next button selected");
	int txtIndex = StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), nextLineIndex);
	
	if(txtIndex < 0){
		nextLineIndex = 0;
		prevLineIndex =  StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), nextLineIndex);
		nextLineIndex = prevLineIndex + 1;
		styledText.setSelection(prevLineIndex);
		setStyledRange(styledText, prevLineIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
		return new int[]{prevLineIndex,nextLineIndex};
	}else{
		setStyledRange(styledText, txtIndex, text.length(), null, Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
		styledText.setSelection(txtIndex);
		prevLineIndex = txtIndex;
		nextLineIndex = txtIndex+1;
		styledText.redraw();
	}
	return new int[]{prevLineIndex,nextLineIndex};
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:29,代码来源:StyledTextEventListener.java

示例14: allButtonListener

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
/**
 * The function will change selected text background color.
 * @param styledText
 * @param text
 * @param foreground
 * @param background
 */
public void allButtonListener(StyledText styledText, String text, Color foreground, Color background, Label label){
	logger.debug("StyledText All button selected");
	int index = 0;
	int recordCount = 0;
	if(styledText == null){return;}
	for(;index < styledText.getText().length();){
		  int lastIndex = StringUtils.indexOf(StringUtils.lowerCase(styledText.getText()), StringUtils.lowerCase(text), index);
		  
		  if(lastIndex < 0){return;}
		  else{
			  setStyledRange(styledText, lastIndex, text.length(), null, background);
			  index = lastIndex + 1;
			  recordCount++ ;
			  label.setVisible(true);
			  label.setText("Matching count - " + recordCount);
		  }
	  }
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:26,代码来源:StyledTextEventListener.java

示例15: validateAndCloseCommentEditor

import org.eclipse.swt.custom.StyledText; //导入依赖的package包/类
private void validateAndCloseCommentEditor(StyledText styledText) {
	commentFigure.setText(styledText.getText(),commentBoxModel);

	if (!StringUtils.equals(styledText.getText(), commentBoxModel.getLabelContents())) {
		commentBoxModel.setLabelContents(styledText.getText());
		((ELTGraphicalEditor) commentFigure.getComponentCanvas()).setDirty(true);
	}

	shell.close();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:11,代码来源:CommentBoxEditor.java


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