use of org.eclipse.ui.editors.text.TextSourceViewerConfiguration in project tmdm-studio-se by Talend.
the class ProcessResultsDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
try {
parent.getShell().setText(title);
Composite composite = (Composite) super.createDialogArea(parent);
GridLayout layout = (GridLayout) composite.getLayout();
layout.numColumns = 2;
((GridData) composite.getLayoutData()).widthHint = 800;
Label variableLabel = new Label(composite, SWT.NONE);
variableLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1));
variableLabel.setText(Messages.ProcessResultsDialog_PipelineVariables);
variablesCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
variablesCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
/*
* variablesCombo.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent e) {} public void
* keyReleased(KeyEvent e) { if ((e.stateMask==0) && (e.character == SWT.CR)) {
* ProcessResultsPage.this.variablesViewer.setDocument(new Document(getText(variablesCombo.getText()))); }
* }//keyReleased }//keyListener );
*/
variablesViewer = new SourceViewer(composite, new VerticalRuler(10), SWT.V_SCROLL | SWT.H_SCROLL);
variablesViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 1));
variablesViewer.configure(new TextSourceViewerConfiguration());
((GridData) variablesViewer.getControl().getLayoutData()).minimumHeight = 500;
final Button seeInBrowser = new Button(composite, SWT.PUSH);
seeInBrowser.setText(Messages.ProcessResultsDialog_display);
seeInBrowser.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String htmlContent = variablesViewer.getTextWidget().getText();
IFile file = FileProvider.createdTempFile(htmlContent, Messages.ProcessResultsDialog_temphtml, null);
File htmlFile = file.getLocation().toFile();
// $NON-NLS-1$
String SHARED_ID = "org.eclipse.ui.browser";
try {
IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
if (WebBrowserPreference.getBrowserChoice() == WebBrowserPreference.INTERNAL) {
support.createBrowser(IWorkbenchBrowserSupport.AS_EDITOR, file.getLocation().toPortableString(), null, null).openURL(htmlFile.toURL());
} else {
support.createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL, SHARED_ID, null, null).openURL(htmlFile.toURL());
}
} catch (Exception e1) {
log.error(e1.getMessage(), e1);
}
}
});
variablesCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String output = variablesCombo.getText();
if (output.startsWith(TransformerMainPage.DEFAULT_DISPLAY)) {
// TransformerMainPage.DEFAULT_VAR+output.substring(TransformerMainPage.DEFAULT_DISPLAY.length());
output = DEFAULT_DISPLAY_TEXT;
}
String text = variablesCombo.getText();
if (text.equals(DEFAULT_DISPLAY_TEXT)) {
text = TransformerMainPage.DEFAULT_DISPLAY;
}
variablesViewer.setDocument(new Document(getText(text)));
// $NON-NLS-1$
seeInBrowser.setEnabled("html".equals(text));
}
});
variablesCombo.setFocus();
refreshData();
return composite;
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(this.getShell(), Messages._Error, Messages.bind(Messages.ProcessResultsDialog_ErrorMsg, e.getLocalizedMessage()));
return null;
}
}
use of org.eclipse.ui.editors.text.TextSourceViewerConfiguration in project ecf by eclipse.
the class ChatComposite method createStyledTextWidget.
private StyledText createStyledTextWidget(Composite parent) {
try {
final SourceViewer result = new SourceViewer(parent, null, null, true, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY);
result.configure(new TextSourceViewerConfiguration(EditorsUI.getPreferenceStore()));
result.setDocument(new Document());
return result.getTextWidget();
} catch (final Exception e) {
// $NON-NLS-1$
ClientPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, ClientPlugin.PLUGIN_ID, IStatus.WARNING, MessageLoader.getString("ChatComposite.NO_HYPERLINKING"), e));
return new StyledText(parent, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY);
} catch (final NoClassDefFoundError e) {
// $NON-NLS-1$
ClientPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, ClientPlugin.PLUGIN_ID, IStatus.WARNING, MessageLoader.getString("ChatComposite.NO_HYPERLINKING"), e));
return new StyledText(parent, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY);
}
}
Aggregations