Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.StyledText


      public void selectionChanged(SelectionChangedEvent event) {
        updateActions();
      }
    });
   
    StyledText styleText = textViewer.getTextWidget();
    styleText.setEditable(true);
    styleText.setEnabled(true);
    styleText.setTabs(4);
   
    PresentationReconciler presentationReconciler = new PresentationReconciler();
    presentationReconciler.install(textViewer);
   
    // Enable the TextViewerUndoManager.
View Full Code Here


  private Point computeMenuLocation(Control focus) {
    Point cursorLocation = focus.getDisplay().getCursorLocation();
    Rectangle clientArea = null;
    Point result = null;
    if (focus instanceof StyledText) {
      StyledText styledText = (StyledText) focus;
      clientArea = styledText.getClientArea();
      result = computeMenuLocation(styledText);
    } else if (focus instanceof Tree) {
      Tree tree = (Tree) focus;
      clientArea = tree.getClientArea();
      result = computeMenuLocation(tree);
View Full Code Here

    // Build the split
    buildSplit(frame, sfLeft, sfRight);

    // Top Left
    mainTextArea = new StyledText(sfLeft, SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
    mainTextArea.setEditable(false);

    // Bottom Left
    Text textInput = new Text(sfLeft, SWT.SINGLE | SWT.BORDER);
View Full Code Here

public class StyledTextStatistics {
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);

    styledText.setText("12345\r\n67890\r\nabcde");
   
    styledText.setCaretOffset(7);
   
    System.out.println("Caret Offset: " + styledText.getCaretOffset());
    System.out.println("Total Lines of Text: " + styledText.getLineCount());
    System.out.println("Total Characters: " + styledText.getCharCount());
    System.out.println("Current Line: " + (styledText.getLineAtOffset(styledText.getCaretOffset()) + 1));

    styledText.setCaretOffset(styledText.getCharCount() + 1);
   
   
    styledText.setBounds(10,10,100,100);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
View Full Code Here

 
  private StringBuffer tmpBuf;
 
  public TabItem(final CTabFolder folder) {
    tab = new CTabItem(folder, SWT.CLOSE);
    text = new StyledText(folder, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP);
    tab.setControl(text);
    text.setEditable(false);
  }
View Full Code Here

    btnExecNextButton.setToolTipText(RedisClient.i18nFile.getText(I18nFile.RUNFOLLOWTIP)+"\tF9");

    SashForm sashForm3 = new SashForm(composite_3, SWT.VERTICAL);
    sashForm3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
   
    inputCmd = new StyledText(sashForm3, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    inputCmd.addLineStyleListener(new LineStyleListener()
    {
        public void lineGetStyle(LineStyleEvent e)
        {
            StyleRange style = new StyleRange();
            style.metrics = new GlyphMetrics(0, 0, Integer.toString(100000).length()*5);

        e.bullet = new Bullet(ST.BULLET_DOT, style);
      }
    });

    inputCmd.addControlListener(new ControlAdapter() {
      @Override
      public void controlResized(ControlEvent e) {
        inputCmd.setFocus();
      }
    });
    inputCmd.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseDown(MouseEvent e) {
        text = inputCmd;
        final Clipboard cb = new Clipboard(tabFolder.getShell().getDisplay());
        TextTransfer transfer = TextTransfer.getInstance();
            String data = (String) cb.getContents(transfer);
            if(data != null)
              menu.getItem(2).setEnabled(true);
            else
              menu.getItem(2).setEnabled(false);
           
        if(inputCmd.getSelectionText().length() > 0){
          menu.getItem(0).setEnabled(true);
          menu.getItem(1).setEnabled(true);
        }else{
          menu.getItem(0).setEnabled(false);
          menu.getItem(1).setEnabled(false);
        }
        inputCmd.setMenu(menu);
         
      }
    });
   
    tabFolder_2 = new CTabFolder(sashForm3, SWT.BORDER);

    tbtmNewItem_1 = new CTabItem(tabFolder_2, SWT.NONE);
    tbtmNewItem_1.setText(RedisClient.i18nFile.getText(I18nFile.RESULT));

    Composite composite_5 = new Composite(tabFolder_2, SWT.NONE);
    tbtmNewItem_1.setControl(composite_5);
    composite_5.setLayout(new GridLayout(1, false));
   
    cmdResult = new StyledText(composite_5, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    cmdResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    cmdResult.setEditable(false);
    cmdResult.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseDown(MouseEvent e) {
View Full Code Here

  @Override
  public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout());
    ReInjector.getInstance().reInject(this);
    messagingService.addDataListener(this);
    text = new StyledText(parent, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    text.setEditable(false);
    input = new Text(parent, SWT.BORDER);
    input.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    input.addTraverseListener(new TraverseListener() {
View Full Code Here

  private void highlight(int start, int length) {
    ISourceViewer sourceViewer = getSourceViewer();

    assert sourceViewer != null;

    StyledText text = sourceViewer.getTextWidget();

    if (mCurrentStyleRange != null) {
      // reset current style range
      StyleRange resetedStyleRange = new StyleRange(mCurrentStyleRange.start,
              mCurrentStyleRange.length, null, null);

      text.setStyleRange(resetedStyleRange);
      mCurrentStyleRange = null;
    }

    if (length != 0) {
      mCurrentStyleRange = new StyleRange(start, length, text.getSelectionForeground(), text
              .getSelectionBackground());

      text.setStyleRange(mCurrentStyleRange);
    }
  }
View Full Code Here

        compositeGD.verticalSpan = rows;
        compositeGD.widthHint = 100;
        mapcalcComposite.setLayoutData(compositeGD);
        mapcalcComposite.setLayout(new GridLayout(2, false));

        final StyledText text = new StyledText(mapcalcComposite, SWT.MULTI | SWT.WRAP | SWT.LEAD | SWT.BORDER | SWT.V_SCROLL);
        GridData textGD = new GridData(SWT.FILL, SWT.FILL, true, true);
        textGD.verticalSpan = rows;
        textGD.heightHint = 100;
        text.setLayoutData(textGD);
        text.addModifyListener(new ModifyListener(){
            public void modifyText( ModifyEvent e ) {
                MapcalculatorUtils.checkStyle(text);
            }
        });

        Composite buttonsComposite = new Composite(mapcalcComposite, SWT.NONE);
        buttonsComposite.setLayoutData(new GridData(SWT.END, SWT.FILL, false, true));
        GridLayout buttonsCompositeLayout = new GridLayout(1, true);
        buttonsCompositeLayout.marginWidth = 0;
        buttonsComposite.setLayout(buttonsCompositeLayout);

        String[] mapcalcHistoryItems = new String[0];
        String mapcalcHistory = OmsBoxPlugin.getDefault().getMapcalcHistory();
        if (mapcalcHistory != null && mapcalcHistory.length() > 0) {
            mapcalcHistoryItems = mapcalcHistory.split(OmsBoxConstants.MAPCALCHISTORY_SEPARATOR);
        }

        HashMap<String, String> items2ValuesMap = new HashMap<String, String>();
        for( String item : mapcalcHistoryItems ) {
            String descr = item.replaceAll("\n", " ");
            items2ValuesMap.put(descr, item);
        }
        mapcalcHistoryItems = items2ValuesMap.keySet().toArray(new String[0]);

        final Combo historyCombo = new Combo(mapcalcComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
        GridData historyComboGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
        historyComboGD.horizontalSpan = 2;
        historyCombo.setLayoutData(historyComboGD);
        historyCombo.setItems(mapcalcHistoryItems);
        historyCombo.setData(items2ValuesMap);
        historyCombo.select(0);
        historyCombo.addSelectionListener(new SelectionAdapter(){
            public void widgetSelected( SelectionEvent e ) {
                int selectionIndex = historyCombo.getSelectionIndex();
                String item = historyCombo.getItem(selectionIndex);
                @SuppressWarnings("unchecked")
                HashMap<String, String> descriptionsMap = (HashMap<String, String>) historyCombo.getData();
                String value = descriptionsMap.get(item);
                text.setText(value);
            }
        });

        createMapcalcConstructsButtons(buttonsComposite, text);
        MapcalculatorUtils.checkStyle(text);
View Full Code Here

        // new CommentFormattingStrategy(...),
        // IJavaPartitions.JAVA_DOC);
        //

        final IDragAndDropService dndService = (IDragAndDropService) this.getSite().getService(IDragAndDropService.class);
        StyledText st = viewer.getTextWidget();
        textTransfer = TextTransfer.getInstance();
        fileTransfer = FileTransfer.getInstance();
        urlTransfer = URLTransfer.getInstance();
        udigTransfer = UDigByteAndLocalTransfer.getInstance();
        Transfer[] types = new Transfer[]{fileTransfer, textTransfer, urlTransfer, udigTransfer};
View Full Code Here

TOP

Related Classes of org.eclipse.swt.custom.StyledText

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.