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

The following examples show how to use org.eclipse.swt.custom.StyledText#setWordWrap() . 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: 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 2
Source File: AbstractThemeableEditor.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void setWordWrapEnabled(boolean enabled)
{
	StyledText textWidget = getSourceViewer().getTextWidget();
	if (textWidget.getWordWrap() != enabled)
	{
		textWidget.setWordWrap(enabled);
		fLineNumberRulerColumn.redraw();
	}
}
 
Example 3
Source File: CDSSGroup.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createContents(Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayout(new FillLayout());
	StyledText text = new StyledText(ret, SWT.READ_ONLY);
	text.setWordWrap(true);
	text.setText(Messages.CDSSGroup_ExplanationCDSSLine1
		+ Messages.CDSSGroup_ExplanationCDSSLine2 + Messages.CDSSGroup_ExplanationCDSSLine3);
	return ret;
}
 
Example 4
Source File: Services.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createContents(Composite parent){
	Composite ret = new Composite(parent, SWT.NONE);
	ret.setLayout(new FillLayout());
	StyledText text = new StyledText(ret, SWT.NONE);
	text.setWordWrap(true);
	text.setText(Messages.Services_ExplanationLine1 + Messages.Services_ExplanationLine2
		+ Messages.Services_ExplanationLine3);
	return ret;
}
 
Example 5
Source File: IllegalBinaryStateDialog.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates a control with some message and with link to the Binaries preference page.
 *
 * @param parent
 *            the parent composite.
 * @param dialog
 *            the container dialog that has to be closed.
 * @param binary
 *            the binary with the illegal state.
 *
 * @return a control with error message and link that can be reused in dialogs.
 */
public static Control createCustomAreaWithLink(final Composite parent, final Dialog dialog, final Binary binary) {
	final String binaryLabel = binary.getLabel();
	final String prefix = "The requested operation cannot be performed due to invalid '" + binaryLabel
			+ "' settings. Check your '" + binaryLabel
			+ "' configuration and preferences under the corresponding ";
	final String link = "preference page";
	final String suffix = ".";
	final String text = prefix + link + suffix;

	final Composite control = new Composite(parent, NONE);
	control.setLayout(GridLayoutFactory.fillDefaults().create());
	final GridData gridData = GridDataFactory.fillDefaults().align(LEFT, TOP).grab(true, true).create();
	control.setLayoutData(gridData);

	final StyleRange style = new StyleRange();
	style.underline = true;
	style.underlineStyle = UNDERLINE_LINK;

	final StyledText styledText = new StyledText(control, MULTI | READ_ONLY | WRAP);
	styledText.setWordWrap(true);
	styledText.setJustify(true);
	styledText.setText(text);
	final GridData textGridData = GridDataFactory.fillDefaults().align(FILL, FILL).grab(true, true).create();
	textGridData.widthHint = TEXT_WIDTH_HINT;
	textGridData.heightHint = TEXT_HEIGHT_HINT;
	styledText.setLayoutData(textGridData);

	styledText.setEditable(false);
	styledText.setBackground(UIUtils.getSystemColor(COLOR_WIDGET_BACKGROUND));
	final int[] ranges = { text.indexOf(link), link.length() };
	final StyleRange[] styles = { style };
	styledText.setStyleRanges(ranges, styles);

	styledText.addMouseListener(new MouseAdapter() {

		@Override
		public void mouseDown(final MouseEvent event) {
			try {
				final int offset = styledText.getOffsetAtPoint(new Point(event.x, event.y));
				final StyleRange actualStyle = offset >= 0 ? styledText.getStyleRangeAtOffset(offset) : null;
				if (null != actualStyle && actualStyle.underline
						&& UNDERLINE_LINK == actualStyle.underlineStyle) {

					dialog.close();
					final PreferenceDialog preferenceDialog = createPreferenceDialogOn(
							UIUtils.getShell(),
							BinariesPreferencePage.ID,
							FILTER_IDS,
							null);

					if (null != preferenceDialog) {
						preferenceDialog.open();
					}

				}
			} catch (final IllegalArgumentException e) {
				// We are not over the actual text.
			}
		}

	});

	return control;
}
 
Example 6
Source File: StatisticsView.java    From CogniCrypt with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
	GridLayout layout = new GridLayout(3, false);
	parent.setLayout(layout);
	resultsEnabled = true;

	// Project Name
	Label projectnameLabel = new Label(parent, SWT.NONE);
	projectnameLabel.setText("Project Name: ");
	projectname = new StyledText(parent, SWT.NONE);
	projectname.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
	projectname.setText("Nothing for now");
	projectname.setEditable(false);

	// Refresh Button
	reRunButton = new Button(parent, SWT.PUSH);
	reRunButton.setText("Rerun the Analysis on this Project");
	reRunButton.setEnabled(false);
	reRunButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
	// register listener for the selection event
	reRunButton.addSelectionListener(new SelectionListener() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			final AnalysisKickOff runningAnalysis = new AnalysisKickOff();
			runningAnalysis.setUp(JavaCore.create(lastProject));
			runningAnalysis.run();
			resultsEnabled = true;
		}

		@Override
		public void widgetDefaultSelected(SelectionEvent arg0) {}

	});

	// Time of Analysis
	Label timeofanalysisLabel = new Label(parent, SWT.NONE);
	timeofanalysisLabel.setText("Time of Analysis: ");
	timeofanalysis = new StyledText(parent, SWT.NONE);
	timeofanalysis.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
	timeofanalysis.setWordWrap(true);
	timeofanalysis.setEditable(false);

	// Results Table
	createViewer(parent);
}
 
Example 7
Source File: NaiveShowTab.java    From Rel with Apache License 2.0 4 votes vote down vote up
protected Composite getContents(Composite parent) {
	definition = new StyledText(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
	definition.setEditable(false);
	definition.setWordWrap(true);
	return definition;
}
 
Example 8
Source File: WordWrapAction.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void run() {
    StyledText control = getStyledText();
    control.setWordWrap(!control.getWordWrap());
    update();
}