當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。