Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fbabd89d982894e4e1fe46cbca23c9454aed0611 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*******************************************************************************
 * Copyright (c) 2013 Innoopract Informationssysteme GmbH and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Innoopract Informationssysteme GmbH - initial API and implementation
 *    EclipseSource - ongoing development
 ******************************************************************************/
package org.eclipse.rap.demo.ckeditor;

import org.eclipse.rap.addons.ckeditor.CKEditor;
import org.eclipse.rap.rwt.application.AbstractEntryPoint;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;


public class CkEditorDemo extends AbstractEntryPoint {

  @Override
  protected void createContents( final Composite parent ) {
    getShell().setText( "CkEditor Demo" );
    parent.setLayout( new GridLayout( 1, false ) );
    // CkEditor
    final CKEditor ckEditor = new CKEditor( parent, SWT.NONE );
    ckEditor.setFont( new Font( parent.getDisplay(), "fantasy", 19, 0 ) );
    ckEditor.setText( "Hello Fantasy Font" );
    ckEditor.setLayoutData( new GridData() );
    System.out.println( ckEditor.getText() );
    ckEditor.setBackground( parent.getDisplay().getSystemColor( SWT.COLOR_YELLOW ) );
    ckEditor.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
    ToolBar toolbar = new ToolBar( parent, SWT.FLAT );
    ToolItem printBtn = new ToolItem( toolbar, SWT.PUSH );
    printBtn.setText( "Print" );
    printBtn.addSelectionListener( new SelectionAdapter() {
      @Override
      public void widgetSelected( SelectionEvent e ) {
        System.out.println( ckEditor.getText() );
      }
    } );
    ToolItem destrBtn = new ToolItem( toolbar, SWT.PUSH );
    destrBtn.setText( "Dispose" );
    destrBtn.addSelectionListener( new SelectionAdapter() {
      @Override
      public void widgetSelected( SelectionEvent e ) {
        ckEditor.dispose();
      }
    } );
    ToolItem fontBtn = new ToolItem( toolbar, SWT.PUSH );
    fontBtn.setText( "Font" );
    fontBtn.addSelectionListener( new SelectionAdapter() {
      @Override
      public void widgetSelected( SelectionEvent e ) {
        ckEditor.setFont( new Font( parent.getDisplay(), "serif", 9, 0 ) );
      }
    } );
    ToolItem clearBtn = new ToolItem( toolbar, SWT.NONE );
    clearBtn.setText( "Clear" );
    clearBtn.addSelectionListener( new SelectionAdapter() {
      @Override
      public void widgetSelected( SelectionEvent e ) {
        ckEditor.setText( "" );
      }
    } );
  }

}

Back to the top