use of org.eclipse.jface.text.source.SourceViewer in project webtools.sourceediting by eclipse.
the class ResultView method createViewer.
private SourceViewer createViewer(Composite parent) {
SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() {
StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationXSL();
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return baseConfiguration.getConfiguredContentTypes(sourceViewer);
}
@Override
public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
}
};
SourceViewer viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
// $NON-NLS-1$
((StructuredTextViewer) viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
viewer.configure(sourceViewerConfiguration);
viewer.setEditable(false);
return viewer;
}
use of org.eclipse.jface.text.source.SourceViewer in project webtools.sourceediting by eclipse.
the class XMLTemplatePreferencePage method doCreateViewer.
SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) {
SourceViewer viewer = null;
String contentTypeID = ContentTypeIdForXML.ContentTypeID_XML;
viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
// $NON-NLS-1$
viewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID);
IDocument document = scratchModel.getStructuredDocument();
viewer.configure(viewerConfiguration);
viewer.setDocument(document);
return viewer;
}
use of org.eclipse.jface.text.source.SourceViewer in project dbeaver by serge-rider.
the class SQLEditor method createPartControl.
@Override
public void createPartControl(Composite parent) {
setRangeIndicator(new DefaultRangeIndicator());
// divides editor area and results/panels area
resultsSash = UIUtils.createPartDivider(this, parent, resultSetOrientation.getSashOrientation() | SWT.SMOOTH);
CSSUtils.setCSSClass(resultsSash, DBStyles.COLORED_BY_CONNECTION_TYPE);
resultsSash.setSashWidth(5);
UIUtils.setHelp(resultsSash, IHelpContextIds.CTX_SQL_EDITOR);
Composite editorContainer;
sqlEditorPanel = UIUtils.createPlaceholder(resultsSash, 3, 0);
// Create left vertical toolbar
createControlsBar(sqlEditorPanel);
// Create editor presentations sash
Composite pPlaceholder = null;
if (extraPresentationDescriptor != null) {
presentationSash = UIUtils.createPartDivider(this, sqlEditorPanel, ((resultSetOrientation.getSashOrientation() == SWT.VERTICAL) ? SWT.HORIZONTAL : SWT.VERTICAL) | SWT.SMOOTH);
presentationSash.setSashWidth(5);
presentationSash.setLayoutData(new GridData(GridData.FILL_BOTH));
editorContainer = presentationSash;
pPlaceholder = new Composite(presentationSash, SWT.NONE);
pPlaceholder.setLayout(new FillLayout());
} else {
editorContainer = sqlEditorPanel;
}
super.createPartControl(editorContainer);
getEditorControlWrapper().setLayoutData(new GridData(GridData.FILL_BOTH));
// Create right vertical toolbar
createPresentationSwitchBar(sqlEditorPanel);
if (pPlaceholder != null) {
switch(extraPresentationDescriptor.getActivationType()) {
case HIDDEN:
presentationSash.setMaximizedControl(presentationSash.getChildren()[SQL_EDITOR_CONTROL_INDEX]);
break;
case MAXIMIZED:
case VISIBLE:
extraPresentation.createPresentation(pPlaceholder, this);
if (extraPresentationDescriptor.getActivationType() == SQLEditorPresentation.ActivationType.MAXIMIZED) {
if (presentationSash.getChildren()[EXTRA_CONTROL_INDEX] != null) {
presentationSash.setMaximizedControl(pPlaceholder);
}
}
break;
}
}
getSite().setSelectionProvider(new DynamicSelectionProvider());
DBPProject project = getProject();
if (project != null && project.isRegistryLoaded()) {
createResultTabs();
} else {
UIExecutionQueue.queueExec(this::createResultTabs);
}
setAction(ITextEditorActionConstants.SHOW_INFORMATION, null);
SourceViewer viewer = getViewer();
if (viewer != null) {
StyledText textWidget = viewer.getTextWidget();
if (textWidget != null) {
textWidget.addModifyListener(this::onTextChange);
textWidget.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
refreshActions();
}
});
}
}
SQLEditorFeatures.SQL_EDITOR_OPEN.use();
// Start output reader
new ServerOutputReader().schedule();
updateExecutionContext(null);
// Update controls
UIExecutionQueue.queueExec(this::onDataSourceChange);
}
use of org.eclipse.jface.text.source.SourceViewer in project hale by halestudio.
the class TypeStructureTray method createContents.
@Override
protected Control createContents(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(page);
// retrieve the types
final Collection<? extends TypeDefinition> types = this.types.getTypes();
// heading
Label caption = new Label(page, SWT.NONE);
switch(schemaSpace) {
case SOURCE:
caption.setText("Source structure");
break;
case TARGET:
caption.setText("Target structure");
break;
}
caption.setFont(JFaceResources.getHeaderFont());
// create tree viewer
PatternFilter patternFilter = new SchemaPatternFilter();
patternFilter.setIncludeLeadingWildcard(true);
final FilteredTree filteredTree = new TreePathFilteredTree(page, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);
TreeViewer tree = filteredTree.getViewer();
tree.setUseHashlookup(true);
StyledDefinitionLabelProvider labelProvider = new StyledDefinitionLabelProvider(tree);
tree.setLabelProvider(labelProvider);
IContentProvider contentProvider = createContentProvider(tree);
tree.setContentProvider(contentProvider);
GridDataFactory.fillDefaults().grab(true, true).hint(280, 400).applyTo(filteredTree);
tree.setComparator(new DefinitionComparator());
// set input
if (types.size() == 1) {
tree.setInput(types.iterator().next());
} else {
tree.setInput(types);
}
/*
* Groovy specific part
*/
// caption
Label example = new Label(page, SWT.NONE);
switch(schemaSpace) {
case SOURCE:
example.setText("Examples: Access variables");
break;
case TARGET:
example.setText("Example: Build instance");
break;
default:
example.setText("Example");
}
// source viewer
final SourceViewer viewer = new SourceViewer(page, null, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
final IColorManager colorManager = new GroovyColorManager();
SourceViewerConfiguration configuration = new SimpleGroovySourceViewerConfiguration(colorManager, ImmutableList.of(BINDING_TARGET, BINDING_BUILDER, BINDING_INDEX, BINDING_SOURCE, BINDING_SOURCE_TYPES, BINDING_TARGET_TYPE, BINDING_CELL, BINDING_LOG, BINDING_CELL_CONTEXT, BINDING_FUNCTION_CONTEXT, BINDING_TRANSFORMATION_CONTEXT), null);
viewer.configure(configuration);
GridDataFactory.fillDefaults().grab(true, false).hint(200, 130).applyTo(viewer.getControl());
// make sure the color manager is disposed
viewer.getControl().addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
colorManager.dispose();
}
});
// react to tree selection changes
tree.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IDocument doc = new Document();
GroovySourceViewerUtil.setupDocument(doc);
String example = null;
if (!event.getSelection().isEmpty()) {
switch(schemaSpace) {
case SOURCE:
example = createSourceSample(event.getSelection(), types);
break;
case TARGET:
example = createTargetSample(event.getSelection(), types);
break;
}
}
if (example == null || example.isEmpty()) {
switch(schemaSpace) {
case SOURCE:
doc.set("// Please select schema elements to access");
break;
case TARGET:
doc.set("// Please select which schema elements\n// to include in the instance to build");
break;
default:
doc.set("// Please select one or more schema elements");
}
} else {
doc.set(example);
}
viewer.setDocument(doc);
}
});
tree.setSelection(StructuredSelection.EMPTY);
return page;
}
use of org.eclipse.jface.text.source.SourceViewer in project dbeaver by dbeaver.
the class SQLEditor method createPartControl.
@Override
public void createPartControl(Composite parent) {
setRangeIndicator(new DefaultRangeIndicator());
// divides editor area and results/panels area
resultsSash = UIUtils.createPartDivider(this, parent, resultSetOrientation.getSashOrientation() | SWT.SMOOTH);
CSSUtils.setCSSClass(resultsSash, DBStyles.COLORED_BY_CONNECTION_TYPE);
resultsSash.setSashWidth(5);
UIUtils.setHelp(resultsSash, IHelpContextIds.CTX_SQL_EDITOR);
Composite editorContainer;
sqlEditorPanel = UIUtils.createPlaceholder(resultsSash, 3, 0);
// Create left vertical toolbar
createControlsBar(sqlEditorPanel);
// Create editor presentations sash
Composite pPlaceholder = null;
if (extraPresentationDescriptor != null) {
presentationSash = UIUtils.createPartDivider(this, sqlEditorPanel, ((resultSetOrientation.getSashOrientation() == SWT.VERTICAL) ? SWT.HORIZONTAL : SWT.VERTICAL) | SWT.SMOOTH);
presentationSash.setSashWidth(5);
presentationSash.setLayoutData(new GridData(GridData.FILL_BOTH));
editorContainer = presentationSash;
pPlaceholder = new Composite(presentationSash, SWT.NONE);
pPlaceholder.setLayout(new FillLayout());
} else {
editorContainer = sqlEditorPanel;
}
super.createPartControl(editorContainer);
getEditorControlWrapper().setLayoutData(new GridData(GridData.FILL_BOTH));
// Create right vertical toolbar
createPresentationSwitchBar(sqlEditorPanel);
if (pPlaceholder != null) {
switch(extraPresentationDescriptor.getActivationType()) {
case HIDDEN:
presentationSash.setMaximizedControl(presentationSash.getChildren()[SQL_EDITOR_CONTROL_INDEX]);
break;
case MAXIMIZED:
case VISIBLE:
extraPresentation.createPresentation(pPlaceholder, this);
if (extraPresentationDescriptor.getActivationType() == SQLEditorPresentation.ActivationType.MAXIMIZED) {
if (presentationSash.getChildren()[EXTRA_CONTROL_INDEX] != null) {
presentationSash.setMaximizedControl(pPlaceholder);
}
}
break;
}
}
getSite().setSelectionProvider(new DynamicSelectionProvider());
DBPProject project = getProject();
if (project != null && project.isRegistryLoaded()) {
createResultTabs();
} else {
UIExecutionQueue.queueExec(this::createResultTabs);
}
setAction(ITextEditorActionConstants.SHOW_INFORMATION, null);
SourceViewer viewer = getViewer();
if (viewer != null) {
StyledText textWidget = viewer.getTextWidget();
if (textWidget != null) {
textWidget.addModifyListener(this::onTextChange);
textWidget.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
refreshActions();
}
});
}
}
SQLEditorFeatures.SQL_EDITOR_OPEN.use();
// Start output reader
new ServerOutputReader().schedule();
updateExecutionContext(null);
// Update controls
UIExecutionQueue.queueExec(this::onDataSourceChange);
}
Aggregations