use of org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer in project tdi-studio-se by Talend.
the class CodeView method createPartControl.
@Override
public void createPartControl(Composite parent) {
this.parent = parent;
parent.setLayout(new FillLayout());
ECodeLanguage language = LanguageManager.getCurrentLanguage();
ISourceViewer viewer = null;
final StyledText text;
int styles = SWT.H_SCROLL | SWT.V_SCROLL;
document = new Document();
switch(language) {
case JAVA:
IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
viewer = new JavaSourceViewer(parent, null, null, false, styles, store);
viewer.setDocument(document);
JavaTextTools tools = JavaPlugin.getDefault().getJavaTextTools();
tools.setupJavaDocumentPartitioner(viewer.getDocument(), IJavaPartitions.JAVA_PARTITIONING);
SimpleJavaSourceViewerConfiguration config = new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, true);
viewer.configure(config);
viewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
document = viewer.getDocument();
break;
// empty since only have java
default:
}
viewer.setEditable(false);
text = viewer.getTextWidget();
// getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
IAction wrapAction = new Action() {
@Override
public void run() {
text.setWordWrap(isChecked());
}
};
//$NON-NLS-1$
wrapAction.setToolTipText("wrap");
wrapAction.setChecked(false);
//$NON-NLS-1$
wrapAction.setImageDescriptor(ImageDescriptor.createFromFile(DesignerPlugin.class, "/icons/wrap.gif"));
tbm.add(wrapAction);
createMenu();
}
Aggregations