Search in sources :

Example 1 with StyledText

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));
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) CTabItemWithStyledText(com.wuntee.oter.view.widgets.CTabItemWithStyledText) FileWriter(java.io.FileWriter) BufferedWriter(java.io.BufferedWriter)

Example 2 with StyledText

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);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 3 with StyledText

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();
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) StyledTextHandler(org.talend.designer.xmlmap.ui.tabs.StyledTextHandler) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) AsynchronousThreading(org.talend.commons.ui.runtime.thread.AsynchronousThreading)

Example 4 with StyledText

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();
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) StyledText(org.eclipse.swt.custom.StyledText) SimpleJavaSourceViewerConfiguration(org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration) IAction(org.eclipse.jface.action.IAction) JavaTextTools(org.eclipse.jdt.ui.text.JavaTextTools) FillLayout(org.eclipse.swt.layout.FillLayout) Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) DesignerPlugin(org.talend.designer.core.DesignerPlugin) JavaSourceViewer(org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 5 with StyledText

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;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridData(org.eclipse.swt.layout.GridData)

Aggregations

StyledText (org.eclipse.swt.custom.StyledText)580 Point (org.eclipse.swt.graphics.Point)166 GridData (org.eclipse.swt.layout.GridData)122 Composite (org.eclipse.swt.widgets.Composite)109 GridLayout (org.eclipse.swt.layout.GridLayout)98 Control (org.eclipse.swt.widgets.Control)64 SelectionEvent (org.eclipse.swt.events.SelectionEvent)58 Label (org.eclipse.swt.widgets.Label)56 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)55 StyleRange (org.eclipse.swt.custom.StyleRange)46 Button (org.eclipse.swt.widgets.Button)42 FillLayout (org.eclipse.swt.layout.FillLayout)41 Display (org.eclipse.swt.widgets.Display)41 Rectangle (org.eclipse.swt.graphics.Rectangle)40 Color (org.eclipse.swt.graphics.Color)39 Event (org.eclipse.swt.widgets.Event)38 Shell (org.eclipse.swt.widgets.Shell)37 Text (org.eclipse.swt.widgets.Text)36 IRegion (org.eclipse.jface.text.IRegion)27 DisposeEvent (org.eclipse.swt.events.DisposeEvent)26