use of org.eclipse.swt.custom.StyledText in project otertool by wuntee.
the class SmaliController method saveTab.
public void saveTab(CTabItem tab) throws IOException {
if ((Boolean) tab.getData(MODIFIED) == true) {
String file = (String) tab.getData(FILENAME);
logger.debug("Saving file: " + file);
BufferedWriter out = new BufferedWriter(new FileWriter(file));
StyledText styledText = (StyledText) tab.getData(StyledText.class.getName());
out.write(styledText.getText());
out.flush();
out.close();
// Change the tab object to show it has been saved
tab.setData(ORIGINAL_TEXT, styledText.getText());
tab.setData(MODIFIED, false);
tab.setText(tab.getText().substring(2));
}
}
use of org.eclipse.swt.custom.StyledText in project otertool by wuntee.
the class CTabItemWithHexViewer method createEditor.
private void createEditor() {
CTabItem tabItem = new CTabItem(parent, style);
tabItem.setText(name);
Composite composite = new Composite(parent, SWT.NONE);
tabItem.setControl(composite);
GridLayout gl_composite = new GridLayout(4, false);
gl_composite.marginWidth = 0;
gl_composite.verticalSpacing = 0;
gl_composite.marginHeight = 0;
gl_composite.horizontalSpacing = 0;
composite.setLayout(gl_composite);
counter = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY);
//counter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
counter.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 1, 1));
counter.setFont(SWTResourceManager.getFont("Courier New", 11, SWT.NORMAL));
addListeners(counter);
hexContent = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL);
hexContent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
hexContent.setFont(SWTResourceManager.getFont("Courier New", 11, SWT.NORMAL));
addListeners(hexContent);
binContent = new StyledText(composite, SWT.BORDER | SWT.READ_ONLY);
binContent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
//binContent.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, true, 1, 1));
binContent.setFont(SWTResourceManager.getFont("Courier New", 11, SWT.NORMAL));
addListeners(binContent);
parent.setSelection(tabItem);
}
use of org.eclipse.swt.custom.StyledText in project tdi-studio-se by Talend.
the class ExpressionCellEditor method highlightLineAndSetSelectionOfStyledTextFromTextControl.
protected void highlightLineAndSetSelectionOfStyledTextFromTextControl(final Control textWidget) {
final StyledTextHandler styledTextHandler = mapperManager.getMapperUI().getTabFolderEditors().getStyledTextHandler();
Runnable runnable = new Runnable() {
public void run() {
StyledText styledText = styledTextHandler.getStyledText();
if (styledText.isDisposed() || textWidget.isDisposed()) {
return;
}
String text = ControlUtils.getText(textWidget);
Point selection = ControlUtils.getSelection(textWidget);
String lineDelimiter = ControlUtils.getLineDelimiter(textWidget);
if (selection.x - 1 > 0) {
while (lineDelimiter.equals(text.charAt(selection.x - 1))) {
selection.x++;
}
}
if (selection.y - 1 > 0) {
while (lineDelimiter.equals(text.charAt(selection.y - 1))) {
selection.y++;
}
}
int length = styledText.getText().length();
if (selection.x < 0) {
selection.x = 0;
}
if (selection.x > length) {
selection.x = length;
}
if (selection.y < 0) {
selection.y = 0;
}
if (selection.y > length) {
selection.y = length;
}
styledText.setSelection(selection);
styledTextHandler.highlightLineOfCursorPosition(selection);
}
};
new AsynchronousThreading(50, true, parent.getDisplay(), runnable).start();
}
use of org.eclipse.swt.custom.StyledText 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();
}
use of org.eclipse.swt.custom.StyledText in project tdi-studio-se by Talend.
the class TargetExecComposite method createTargetExecutionComposite.
protected Composite createTargetExecutionComposite(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
StyledText text = new StyledText(composite, SWT.NONE);
//$NON-NLS-1$
text.setText(Messages.getString("ProcessComposite.targetExecutionTabTooltipAvailable"));
text.setWordWrap(true);
text.setEditable(false);
text.setLayoutData(new GridData(GridData.FILL_BOTH));
return composite;
}
Aggregations