Java Code Examples for org.eclipse.swt.custom.StyledText#setFont()

The following examples show how to use org.eclipse.swt.custom.StyledText#setFont() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StyledTextForShowingCodeFactory.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @return a styled text that can be used to show code with the colors based on the color cache received.
 */
public StyledText createStyledTextForCodePresentation(Composite parent) {
    styledText = new StyledText(parent, SWT.BORDER | SWT.READ_ONLY);
    this.backgroundColorCache = new ColorAndStyleCache(new PreferenceStore());
    this.colorCache = new ColorAndStyleCache(null);

    try {
        styledText.setFont(new Font(parent.getDisplay(), FontUtils.getFontData(IFontUsage.STYLED, true)));
    } catch (Throwable e) {
        //ignore
    }
    updateBackgroundColor();

    PyDevUiPrefs.getChainedPrefStore().addPropertyChangeListener(this);

    return styledText;
}
 
Example 2
Source File: PythonSourceViewer.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sets the font for the given viewer sustaining selection and scroll position.
 *
 * @param font the font
 */
private void applyFont(Font font) {
    IDocument doc = getDocument();
    if (doc != null && doc.getLength() > 0) {
        Point selection = getSelectedRange();
        int topIndex = getTopIndex();

        StyledText styledText = getTextWidget();
        styledText.setRedraw(false);

        styledText.setFont(font);
        setSelectedRange(selection.x, selection.y);
        setTopIndex(topIndex);

        styledText.setRedraw(true);
    } else {
        getTextWidget().setFont(font);
    }
}
 
Example 3
Source File: TextFilterAdapter.java    From AppleCommander with GNU General Public License v2.0 6 votes vote down vote up
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()));
}
 
Example 4
Source File: ScrolledTextEx.java    From SWET with MIT License 6 votes vote down vote up
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;
}
 
Example 5
Source File: InputPageUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a signature preview viewer in a parent composite with a 1-column GridLayout.
 * 
 * @param parent the parent 
 * @return the preview viewer
 * @since 3.9
 */
public static JavaSourceViewer createSignaturePreview(Composite parent) {
	IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
	JavaSourceViewer signaturePreview= new JavaSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP, store);
	signaturePreview.configure(new JavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, null));
	StyledText textWidget= signaturePreview.getTextWidget();
	textWidget.setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
	textWidget.setAlwaysShowScrollBars(false);
	signaturePreview.adaptBackgroundColor(parent);
	signaturePreview.setDocument(new Document());
	signaturePreview.setEditable(false);

	GridData gdata= new GridData(GridData.FILL_BOTH);
	gdata.widthHint= new PixelConverter(textWidget).convertWidthInCharsToPixels(50);
	gdata.heightHint= textWidget.getLineHeight() * 2;
	textWidget.setLayoutData(gdata);
	
	return signaturePreview;
}
 
Example 6
Source File: Notifier.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates the text part of the window
 *
 * @param shell the window
 * @param text the text
 * @param colors the color set
 */
private static void createText(final Shell shell, final String text, final NotifierColors colors) {
	final StyledText textLabel = new StyledText(shell, SWT.WRAP | SWT.READ_ONLY);
	final GridData gdText = new GridData(GridData.FILL, GridData.FILL, true, true);
	gdText.horizontalIndent = 15;
	textLabel.setLayoutData(gdText);
	textLabel.setEnabled(false);
	final Font textFont = SWTGraphicUtil.buildFontFrom(textLabel, SWT.NONE, 10);
	textLabel.setFont(textFont);

	final Color textColor = colors.textColor;
	textLabel.setForeground(textColor);
	final Color fillColor = colors.rightColor;
	textLabel.setBackground(fillColor);

	textLabel.setText(text);
	SWTGraphicUtil.applyHTMLFormating(textLabel);

	SWTGraphicUtil.addDisposer(shell, textFont);
}
 
Example 7
Source File: CustomTxtParserInputWizardPage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void openLegend() {
    final String cg = Messages.CustomTxtParserInputWizardPage_capturedGroup;
    final String ucg = Messages.CustomTxtParserInputWizardPage_unidentifiedCaptureGroup;
    final String ut = Messages.CustomTxtParserInputWizardPage_uncapturedText;
    int line1start = 0;
    String line1 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine;
    int line2start = line1start + line1.length();
    String line2 = Messages.CustomTxtParserInputWizardPage_matchingRootLine + ' ' + cg + ' ' + ucg + ' ' + ut + " \n"; //$NON-NLS-1$
    int line3start = line2start + line2.length();
    String line3 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + ' '  + cg + ' ' + ucg + ' ' + ut + " \n"; //$NON-NLS-1$
    int line4start = line3start + line3.length();
    String line4 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + ' ' + cg + ' ' + ucg + ' ' + ut + " \n"; //$NON-NLS-1$
    int line5start = line4start + line4.length();
    String line5 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine;
    int line6start = line5start + line5.length();
    String line6 = Messages.CustomTxtParserInputWizardPage_matchingRootLine + cg + ' ' + ucg + ' ' + ut + " \n"; //$NON-NLS-1$

    final Shell legendShell = new Shell(getShell(), SWT.DIALOG_TRIM);
    legendShell.setLayout(new FillLayout());
    StyledText legendText = new StyledText(legendShell, SWT.MULTI);
    legendText.setFont(fixedFont);
    legendText.setText(line1 + line2 + line3 + line4 + line5 + line6);
    legendText.setStyleRange(new StyleRange(line2start, line2.length(), COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));
    legendText.setStyleRange(new StyleRange(line3start, line3.length(), COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
    legendText.setStyleRange(new StyleRange(line4start, line4.length(), COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
    legendText.setStyleRange(new StyleRange(line6start, line6.length(), COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));
    legendText.setStyleRange(new StyleRange(line2start + line2.indexOf(cg), cg.length(), COLOR_BLACK, COLOR_GREEN, SWT.BOLD));
    legendText.setStyleRange(new StyleRange(line2start + line2.indexOf(ucg), ucg.length(), COLOR_BLACK, COLOR_MAGENTA));
    legendText.setStyleRange(new StyleRange(line3start + line3.indexOf(cg), cg.length(), COLOR_BLACK, COLOR_LIGHT_GREEN, SWT.BOLD));
    legendText.setStyleRange(new StyleRange(line3start + line3.indexOf(ucg), ucg.length(), COLOR_BLACK, COLOR_LIGHT_MAGENTA));
    legendText.setStyleRange(new StyleRange(line4start + line4.indexOf(cg), cg.length(), COLOR_BLACK, COLOR_LIGHT_GREEN, SWT.BOLD));
    legendText.setStyleRange(new StyleRange(line4start + line4.indexOf(ucg), ucg.length(), COLOR_BLACK, COLOR_LIGHT_MAGENTA));
    legendText.setStyleRange(new StyleRange(line6start + line6.indexOf(cg), cg.length(), COLOR_BLACK, COLOR_GREEN, SWT.BOLD));
    legendText.setStyleRange(new StyleRange(line6start + line6.indexOf(ucg), ucg.length(), COLOR_BLACK, COLOR_MAGENTA));
    legendShell.setText(Messages.CustomTxtParserInputWizardPage_previewLegend);
    legendShell.pack();
    legendShell.open();
}
 
Example 8
Source File: SourceCodeView.java    From dawnsci with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Basic source code viewer...
 * @param content
 */
private void createSourceContent(Composite content) {
	
	JavaLineStyler lineStyler = new JavaLineStyler();
	
	StyledText text = new StyledText(content, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
	GridData spec = new GridData();
	spec.horizontalAlignment = GridData.FILL;
	spec.grabExcessHorizontalSpace = true;
	spec.verticalAlignment = GridData.FILL;
	spec.grabExcessVerticalSpace = true;
	text.setLayoutData(spec);
	text.addLineStyleListener(lineStyler);
	// Use a monospaced font, which is not as easy as it might be.
	// http://stackoverflow.com/questions/221568/swt-os-agnostic-way-to-get-monospaced-font
	text.setFont(JFaceResources.getTextFont());
	text.setEditable(false);
	
	// Providing that they run this from a debug session:
	try {
		File   dir = BundleUtils.getBundleLocation("org.eclipse.dawnsci.plotting.examples");
		String loc = "/src/"+getClass().getName().replace('.', '/')+".java";
		File   src = new File(dir, loc);
		text.setText(readFile(src).toString());
		
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 9
Source File: AbstractSimpleLangSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public void configureViewer(ProjectionViewerExt sourceViewer) {
	StyledText textWidget = sourceViewer.getTextWidget();
	if (textWidget != null) {
		textWidget.setFont(JFaceResources.getFont(getFontPropertyPreferenceKey()));
		// TODO: respond to font changes
	}
	
	new ViewerColorUpdater(fPreferenceStore, sourceViewer).configureViewer();
}
 
Example 10
Source File: SeparatorPanel.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void initComponents(String label) {
       GridLayout gridLayout = new GridLayout(2, false);
	setLayout(gridLayout);
	
	GridData layoutData = new GridData();
	layoutData.grabExcessHorizontalSpace = true;
	layoutData.horizontalAlignment = GridData.FILL;
	setLayoutData(layoutData);

	// Text label
	StyledText gridLinesLabel = new StyledText(this, SWT.NONE);
	gridLinesLabel.setEditable(false);
	Display display = Display.getDefault();
	FontData data = display .getSystemFont().getFontData()[0];
	Font font = new Font(display, data.getName(), data.getHeight(), SWT.BOLD);
	gridLinesLabel.setFont(font);
	gridLinesLabel.setBackground(Display.getCurrent().getSystemColor (SWT.COLOR_WIDGET_BACKGROUND));
	gridLinesLabel.setText(label);

	// Separator line
	Label separator = new Label (this, SWT.SEPARATOR | SWT.HORIZONTAL);
	GridData separatorData = new GridData();
	separatorData.grabExcessHorizontalSpace = true;
	separatorData.horizontalAlignment = GridData.FILL;
	separatorData.horizontalIndent = 5;
	separator.setLayoutData(separatorData);
}
 
Example 11
Source File: AbstractLangBasicSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public void configureViewer(ProjectionViewerExt sourceViewer) {
	StyledText textWidget = sourceViewer.getTextWidget();
	if (textWidget != null) {
		textWidget.setFont(JFaceResources.getFont(getFontPropertyPreferenceKey()));
		// TODO: respond to font changes
	}
	
	new ViewerColorUpdater(fPreferenceStore, sourceViewer).configureViewer();
}
 
Example 12
Source File: FormHelper.java    From tlaplus with MIT License 5 votes vote down vote up
public static SourceViewer createSourceViewer(Composite parent, int flags, SourceViewerConfiguration config)
{
    SourceViewer sourceViewer = new SourceViewer(parent, null, null, false, flags);
    sourceViewer.configure(config);
    sourceViewer.setTabsToSpacesConverter(getTabToSpacesConverter());

    StyledText control = sourceViewer.getTextWidget();
    control.setWordWrap(true);
    control.setFont(TLCUIActivator.getDefault().getCourierFont());
    control.setEditable(true);
    return sourceViewer;
}
 
Example 13
Source File: HoverInfoWithText.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void deferredCreateContent(Composite parent,
        HoverInformationControl miControl) {
    this.fParent = parent;
    this.fMIControl = miControl;

    fText = new StyledText(parent, SWT.MULTI | SWT.READ_ONLY
            | fMIControl.getAdditionalTextStyles());
    fText.setForeground(parent.getForeground());
    fText.setBackground(parent.getBackground());
    fText.setFont(JFaceResources.getDialogFont());
    fText.addPaintObjectListener(new PaintObjectListener() {
        public void paintObject(PaintObjectEvent event) {
            StyleRange style = event.style;
            Image image = (Image) style.data;
            if (image != null && !image.isDisposed()) {
                int x = event.x + 2;
                int y = event.y + event.ascent / 2 - style.metrics.ascent
                        / 2 + 2;
                event.gc.drawImage(image, x, y);
            }
        }
    });
    FillLayout layout = new FillLayout();
    layout.marginHeight = 2;
    layout.marginWidth = 2;
    parent.setLayout(layout);

    if (monospace) {
        fText.setFont(JFaceResources.getTextFont());
    } else {
        fText.setFont(JFaceResources.getDialogFont());
    }

    fText.setText(xsString.getText());
    fText.setStyleRanges(xsString.getStyleRanges().toArray(new StyleRange[0]));

    parent.layout(true);
}
 
Example 14
Source File: Header.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create the description
 */
private void createDescription() {
	final StyledText labelDescription = new StyledText(this, SWT.WRAP | SWT.READ_ONLY);
	labelDescription.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
	labelDescription.setEnabled(false);
	labelDescription.setFont(getFont());
	labelDescription.setForeground(getForeground());
	labelDescription.setText(description);
	SWTGraphicUtil.applyHTMLFormating(labelDescription);
}
 
Example 15
Source File: TmMatchEditDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.setLayout(new GridLayout(1, false));

	Group srcGroup = new Group(container, SWT.NONE);
	srcGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	srcGroup.setLayout(new GridLayout(1, false));
	String srcGroupTile = Messages.getString("dialog.TmMatchEditDialog.component.src");
	srcGroupTile = MessageFormat.format(srcGroupTile, fuzzyResult.getTu().getSource().getLangCode());
	srcGroup.setText(srcGroupTile);

	srcSegmentViewer = new SegmentViewer(srcGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, null);
	StyledText srcTextControl = srcSegmentViewer.getTextWidget();
	srcTextControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	srcTextControl.setLineSpacing(Constants.SEGMENT_LINE_SPACING);
	srcTextControl.setLeftMargin(Constants.SEGMENT_LEFT_MARGIN);
	srcTextControl.setRightMargin(Constants.SEGMENT_RIGHT_MARGIN);
	srcTextControl.setTopMargin(Constants.SEGMENT_TOP_MARGIN);
	srcTextControl.setBottomMargin(Constants.SEGMENT_TOP_MARGIN);
	srcTextControl.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));

	Group targetGroup = new Group(container, SWT.NONE);
	targetGroup.setLayout(new GridLayout(1, false));
	targetGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	String tgtGroupTile = Messages.getString("dialog.TmMatchEditDialog.component.tgt");
	tgtGroupTile = MessageFormat.format(tgtGroupTile, fuzzyResult.getTu().getSource().getLangCode());
	targetGroup.setText(tgtGroupTile);

	tgtSegmentViewer = new SegmentViewer(targetGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, null);
	StyledText tgtTextControl = tgtSegmentViewer.getTextWidget();
	tgtTextControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	tgtTextControl.setLineSpacing(Constants.SEGMENT_LINE_SPACING);
	tgtTextControl.setLeftMargin(Constants.SEGMENT_LEFT_MARGIN);
	tgtTextControl.setRightMargin(Constants.SEGMENT_RIGHT_MARGIN);
	tgtTextControl.setTopMargin(Constants.SEGMENT_TOP_MARGIN);
	tgtTextControl.setBottomMargin(Constants.SEGMENT_TOP_MARGIN);
	tgtTextControl.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));

	net.heartsome.cat.ts.ui.innertag.tagstyle.TagStyleConfigurator.configure(srcSegmentViewer);
	net.heartsome.cat.ts.ui.innertag.tagstyle.TagStyleConfigurator.configure(tgtSegmentViewer);

	TmMatchEditorBodyMenu srcMenu = new TmMatchEditorBodyMenu(srcSegmentViewer);
	srcSegmentViewer.getTextWidget().setMenu(srcMenu.getBodyMenu());

	TmMatchEditorBodyMenu tgtMenu = new TmMatchEditorBodyMenu(tgtSegmentViewer);
	tgtSegmentViewer.getTextWidget().setMenu(tgtMenu.getBodyMenu());

	loadData();

	return container;
}
 
Example 16
Source File: SourceViewerInformationControl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Initialize the font to the Java editor font.
 *
 * @since 3.2
 */
private void initializeFont() {
	fTextFont= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
	StyledText styledText= getViewer().getTextWidget();
	styledText.setFont(fTextFont);
}
 
Example 17
Source File: CTabItemWithHexViewer.java    From Flashtool with GNU General Public License v3.0 4 votes vote down vote up
private void createEditor(){		
	CTabItem tabItem = new CTabItem(parent, style);
	tabItem.setText(name);
	
	Composite composite = new Composite(parent, SWT.NONE);
	tabItem.setControl(composite);
	FormLayout fl_composite = new FormLayout();
	fl_composite.marginWidth = 0;
	fl_composite.marginHeight = 0;
	composite.setLayout(fl_composite);
	
	counter = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY);
	//counter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	FormData fd_counter = new FormData();
	fd_counter.top=new FormAttachment(0, 0);
	fd_counter.bottom=new FormAttachment(100, 0);
	fd_counter.left=new FormAttachment(0, 0);
	counter.setLayoutData(fd_counter);
	counter.setFont(SWTResourceManager.getFont("Courier New", 10, SWT.NORMAL));
	addListeners(counter);

	hexContent = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL);
	FormData fd_hexContent = new FormData();
	fd_hexContent.top=new FormAttachment(0, 0);
	fd_hexContent.bottom=new FormAttachment(100, 0);
	fd_hexContent.left=new FormAttachment(counter, 0);
	fd_hexContent.width=400;
	hexContent.setLayoutData(fd_hexContent);
	hexContent.setFont(SWTResourceManager.getFont("Courier New", 10, SWT.NORMAL));
	addListeners(hexContent);

	binContent = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY );
	FormData fd_binContent = new FormData();
	fd_binContent.top=new FormAttachment(0, 0);
	fd_binContent.bottom=new FormAttachment(100, 0);
	fd_binContent.left=new FormAttachment(hexContent, 0);
	fd_binContent.right=new FormAttachment(100, 0);
	binContent.setLayoutData(fd_binContent);
	//binContent.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, true, 1, 1));
	binContent.setFont(SWTResourceManager.getFont("Courier New", 10, SWT.NORMAL));
	addListeners(binContent);

	parent.setSelection(tabItem);

}
 
Example 18
Source File: TmMatchEditDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create contents of the dialog.
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
	Composite container = (Composite) super.createDialogArea(parent);
	container.setLayout(new GridLayout(1, false));

	Group srcGroup = new Group(container, SWT.NONE);
	srcGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	srcGroup.setLayout(new GridLayout(1, false));
	String srcGroupTile = Messages.getString("dialog.TmMatchEditDialog.component.src");
	srcGroupTile = MessageFormat.format(srcGroupTile, fuzzyResult.getTu().getSource().getLangCode());
	srcGroup.setText(srcGroupTile);

	srcSegmentViewer = new SegmentViewer(srcGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, null);
	StyledText srcTextControl = srcSegmentViewer.getTextWidget();
	srcTextControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	srcTextControl.setLineSpacing(Constants.SEGMENT_LINE_SPACING);
	srcTextControl.setLeftMargin(Constants.SEGMENT_LEFT_MARGIN);
	srcTextControl.setRightMargin(Constants.SEGMENT_RIGHT_MARGIN);
	srcTextControl.setTopMargin(Constants.SEGMENT_TOP_MARGIN);
	srcTextControl.setBottomMargin(Constants.SEGMENT_TOP_MARGIN);
	srcTextControl.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));

	Group targetGroup = new Group(container, SWT.NONE);
	targetGroup.setLayout(new GridLayout(1, false));
	targetGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	String tgtGroupTile = Messages.getString("dialog.TmMatchEditDialog.component.tgt");
	tgtGroupTile = MessageFormat.format(tgtGroupTile, fuzzyResult.getTu().getSource().getLangCode());
	targetGroup.setText(tgtGroupTile);

	tgtSegmentViewer = new SegmentViewer(targetGroup, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL, null);
	StyledText tgtTextControl = tgtSegmentViewer.getTextWidget();
	tgtTextControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	tgtTextControl.setLineSpacing(Constants.SEGMENT_LINE_SPACING);
	tgtTextControl.setLeftMargin(Constants.SEGMENT_LEFT_MARGIN);
	tgtTextControl.setRightMargin(Constants.SEGMENT_RIGHT_MARGIN);
	tgtTextControl.setTopMargin(Constants.SEGMENT_TOP_MARGIN);
	tgtTextControl.setBottomMargin(Constants.SEGMENT_TOP_MARGIN);
	tgtTextControl.setFont(JFaceResources.getFont(Constants.MATCH_VIEWER_TEXT_FONT));

	net.heartsome.cat.ts.ui.innertag.tagstyle.TagStyleConfigurator.configure(srcSegmentViewer);
	net.heartsome.cat.ts.ui.innertag.tagstyle.TagStyleConfigurator.configure(tgtSegmentViewer);

	TmMatchEditorBodyMenu srcMenu = new TmMatchEditorBodyMenu(srcSegmentViewer);
	srcSegmentViewer.getTextWidget().setMenu(srcMenu.getBodyMenu());

	TmMatchEditorBodyMenu tgtMenu = new TmMatchEditorBodyMenu(tgtSegmentViewer);
	tgtSegmentViewer.getTextWidget().setMenu(tgtMenu.getBodyMenu());

	loadData();

	return container;
}
 
Example 19
Source File: CheckForUpdates.java    From Rel with Apache License 2.0 4 votes vote down vote up
/**
 * Create the composite.
 * 
 * @param parent
 * @param style
 */
public CheckForUpdates(Composite parent, int style) {
	super(parent, style);
	GridLayout gridLayout = new GridLayout(1, false);
	gridLayout.marginHeight = 0;
	gridLayout.marginWidth = 0;
	gridLayout.verticalSpacing = 0;
	gridLayout.horizontalSpacing = 0;
	setLayout(gridLayout);
	setVisible(false);

	txtStatus = new StyledText(this, SWT.WRAP);
	txtStatus.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	txtStatus.setEditable(false);
	txtStatus.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
	txtStatus.setBackground(getBackground());
	txtStatus.setFont(FontSize.getThisFontInNewSize(txtStatus.getFont(), 10, SWT.NORMAL));
	txtStatus.addMouseListener(mouseHandler);
	txtStatus.setCaret(new Caret(txtStatus, SWT.NONE));
	setText("Rel updates?");

	updateChecker = new UpdatesCheck(parent.getDisplay()) {
		@Override
		public void completed(SendStatus sendStatus) {
			CheckForUpdates.this.completed(sendStatus);
		}
	};

	TimerTask checkForUpdates = new TimerTask() {
		@Override
		public void run() {
			if (CheckForUpdates.this.isDisposed())
				return;
			getDisplay().asyncExec(() -> {
				if (CheckForUpdates.this.isDisposed())
					return;
				setVisible(true);
				setText("Rel updates?");
				System.out.println("CheckForUpdates: check for updates.");
				updateChecker.doCancel();
				updateChecker.doSend();
			});
		}
	};

	// Check for updates after 10 seconds, then every 12 hours
	Timer checkTimer = new Timer();
	checkTimer.schedule(checkForUpdates, 1000 * 5, 1000 * 60 * 60 * 12);
}
 
Example 20
Source File: SWTFactory.java    From goclipse with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Creates a new styled text widget 
 * @param parent the parent composite to add this styled text widget to
 * @param style the style bits for the styled text widget
 * @param hspan the horizontal span to take up on the parent composite
 * @param width the desired width of the styled text widget
 * @param height the desired height of the styled text widget
 * @param fill the fill style for the widget
 * @return the new styled text widget
 * @since 3.9
 */
public static StyledText createStyledText(Composite parent, int style, int hspan, int width, int height, int fill) {
	StyledText t = new StyledText(parent, style);
	t.setFont(parent.getFont());
	GridData gd = new GridData(fill);
	gd.horizontalSpan = hspan;
	gd.widthHint = width;
	gd.heightHint = height;
	t.setLayoutData(gd);
	return t;
}