Java Code Examples for org.eclipse.swt.custom.StyledText#addLineStyleListener()
The following examples show how to use
org.eclipse.swt.custom.StyledText#addLineStyleListener() .
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: ScrolledTextEx.java From SWET with MIT License | 6 votes |
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 2
Source File: ExportJavaViewer.java From http4e with Apache License 2.0 | 6 votes |
void createStyledText(Composite parent){ text = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); // text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridData spec = new GridData(); spec.heightHint = HEIGHT; spec.widthHint = WEIGHT; spec.horizontalAlignment = GridData.FILL; spec.grabExcessHorizontalSpace = true; spec.verticalAlignment = GridData.FILL; spec.grabExcessVerticalSpace = true; text.setLayoutData(spec); text.addLineStyleListener(lineStyler); text.setEditable(false); Color bg = Display.getDefault().getSystemColor(SWT.COLOR_WHITE); text.setBackground(bg); }
Example 3
Source File: LogAnalysis.java From AndroidRobot with Apache License 2.0 | 6 votes |
public void createLogDetail() { tabFolderLogDetail = new CTabFolder(sashFormLog, SWT.CLOSE | SWT.BORDER); tabFolderLogDetail.setTabHeight(0); tabFolderLogDetail.marginHeight = 0; tabFolderLogDetail.marginWidth = 0; tabFolderLogDetail.setMaximizeVisible(false); tabFolderLogDetail.setMinimizeVisible(false); //tabFolderLogDetail.setSelectionBackground(new Color(display, new RGB(153, 186, 243))); tabFolderLogDetail.setSimple(false); tabFolderLogDetail.setUnselectedCloseVisible(true); CTabItem tabItemLogList = new CTabItem(tabFolderLogDetail, SWT.NONE | SWT.MULTI | SWT.V_SCROLL); tabFolderLogDetail.setSelection(tabItemLogList); //styledTextLog = new List(tabFolderLogDetail, SWT.BORDER); styledTextLog = new StyledText(tabFolderLogDetail, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY); styledTextLog.addLineStyleListener(new LogLineStyleListener(shell)); tabItemLogList.setControl(styledTextLog); //sTextLog.setFont(new Font(display,"Courier New",10,SWT.NONE)); }
Example 4
Source File: ResponseView.java From http4e with Apache License 2.0 | 5 votes |
private StyledText buildJsonEditorText( Composite parent){ final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); StyledText st = sourceViewer.getTextWidget(); JSONLineStyler jsonStyler = new JSONLineStyler(); st.addLineStyleListener(jsonStyler); return st; }
Example 5
Source File: RequestView.java From http4e with Apache License 2.0 | 5 votes |
private StyledText buildJsonEditorText( Composite parent){ final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); StyledText st = sourceViewer.getTextWidget(); JSONLineStyler jsonStyler = new JSONLineStyler(); st.addLineStyleListener(jsonStyler); return st; }
Example 6
Source File: SourceCodeView.java From dawnsci with Eclipse Public License 1.0 | 5 votes |
/** * 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 7
Source File: BibtexMergeDialog.java From slr-toolkit with Eclipse Public License 1.0 | 4 votes |
private void buildPreview(Composite container) { GridData gridData = new GridData(); gridData.horizontalAlignment = SWT.RIGHT; gridData.verticalAlignment = SWT.TOP; gridData.grabExcessVerticalSpace = true; gridData.horizontalSpan = 1; gridData.verticalSpan = 5; Composite composite = new Composite(container, SWT.NONE); composite.setLayout(new GridLayout(1, false)); composite.setLayoutData(gridData); // create overview Table table = new Table(composite, SWT.BORDER); table.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true, 1, 1)); TableColumn intersection = new TableColumn(table, SWT.CENTER); TableColumn mergeConflicts = new TableColumn(table, SWT.CENTER); TableColumn unionWithoutConflicts = new TableColumn(table, SWT.CENTER); intersection.setText("Intersection"); mergeConflicts.setText("Merge conflicts"); unionWithoutConflicts.setText("Union without conflicts"); intersection.setWidth(80); mergeConflicts.setWidth(100); unionWithoutConflicts.setWidth(140); table.setHeaderVisible(true); previewStats = new TableItem(table, SWT.NONE); Label label = new Label(composite, SWT.NONE); label.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true, 1, 1)); label.setText("Preview: "); preview = new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); preview.setLayoutData(new GridData(GridData.FILL_BOTH)); preview.setEditable(false); preview.setEnabled(false); preview.setBlockSelection(true); // highlight current conflict initializeConflictIterator(); preview.addLineStyleListener(new LineStyleListener() { public void lineGetStyle(LineStyleEvent event) { if (currentConflictedField == null || currentConflictedResource.getConflictForField(currentConflictedField) == null) return; String currentConflict = currentConflictedResource.getConflictForField(currentConflictedField); StyleRange styleRange = new StyleRange(); styleRange.start = preview.getText().indexOf(currentConflict); styleRange.length = currentConflict.length(); styleRange.background = getParentShell().getDisplay().getSystemColor(SWT.COLOR_YELLOW); event.styles = new StyleRange[] { styleRange }; } }); GridData textGrid = new GridData(500, 500); textGrid.horizontalSpan = 2; preview.setLayoutData(textGrid); updatePreview(); }
Example 8
Source File: ESBRuntimeConsolePageParticipant.java From tesb-studio-se with Apache License 2.0 | 4 votes |
@Override public void init(IPageBookViewPage page, IConsole console) { if (page.getControl() instanceof StyledText) { StyledText viewer = (StyledText) page.getControl(); AnsiConsoleStyleListener myListener = new AnsiConsoleStyleListener(); viewer.addLineStyleListener(myListener); ESBRunContainerPlugin.getDefault().addViewer(viewer, this); } startRuntimeAction = new StartRuntimeAction(true, page.getControl().getShell()); haltRuntimeAction = new StopRuntimeAction(page.getControl().getShell()); openRuntimeInfoAction = new OpenRuntimeInfoAction(); openRuntimePrefsAction = new OpenRuntimePrefsAction(); serverListener = new RuntimeStatusChangeListener() { @Override public void stopRunning() { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { startRuntimeAction.setEnabled(true); haltRuntimeAction.setEnabled(false); openRuntimeInfoAction.setEnabled(false); } }); } @Override public void startRunning() { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { startRuntimeAction.setEnabled(false); haltRuntimeAction.setEnabled(true); openRuntimeInfoAction.setEnabled(true); } }); } @Override public void featureUninstalled(int id) { } @Override public void featureInstalled(int id) { } }; RuntimeServerController.getInstance().addStatusChangeListener(serverListener); IActionBars actionBars = page.getSite().getActionBars(); configureToolBar(actionBars.getToolBarManager()); }