Search in sources :

Example 61 with Listener

use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.

the class FilterResultContrItem method createControl.

/**
	 * Create the content
	 *
	 * @param parent Composite
	 * @return Control
	 */
protected Control createControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
    comp.setLayoutData(gridData);
    final GridLayout gdLayout = new GridLayout(5, false);
    gdLayout.marginHeight = 0;
    gdLayout.marginWidth = 0;
    gdLayout.horizontalSpacing = 0;
    gdLayout.verticalSpacing = 0;
    gdLayout.marginRight = 10;
    comp.setLayout(gdLayout);
    Label lbl = new Label(comp, SWT.NONE);
    lbl.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    lbl.setText(" " + Messages.lblFilterSearch + " ");
    text = new Text(comp, SWT.NONE | SWT.BORDER | SWT.LEFT);
    text.setLayoutData(CommonUITool.createGridData(1, 1, 100, -1));
    text.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                doFilter();
            }
        }
    });
    dropDownButton = new Button(comp, SWT.FLAT | SWT.DOWN);
    dropDownButton.setText(Messages.lblFilterSearchOption);
    dropDownButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            handleSelectionEvent();
        }
    });
    Label lblLimit = new Label(comp, SWT.NONE);
    lblLimit.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    lblLimit.setText(" " + Messages.lblSearchLimit + " ");
    pageLimitCombo = new Combo(comp, SWT.READ_ONLY);
    pageLimitCombo.setItems(new String[] { "1000", "5000", "10000" });
    pageLimitCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    pageLimitCombo.setText("" + pageLimit);
    pageLimitCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            int limit = StringUtil.intValue(pageLimitCombo.getText());
            ServerInfo serverInfo = qe.getDatabase().getServer().getServerInfo();
            QueryOptions.setSearchUnitCount(serverInfo, limit);
        }
    });
    loadMenuItems();
    return comp;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 62 with Listener

use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.

the class AddQueryRecordDialog method createDialogArea.

/**
	 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    Label label1 = new Label(composite, SWT.LEFT);
    label1.setText(Messages.lblQueryName);
    label1.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    String queryPlanName = Messages.lblQueryTuningName + " ";
    if (newFlag) {
        queryPlanName += QueryRecord.DATE_FORMAT.format(new Date());
    } else {
        queryPlanName += queryRecord.getTimeStamp();
    }
    newText = new Text(composite, SWT.BORDER);
    newText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    newText.setText(queryPlanName);
    newText.selectAll();
    newText.setFocus();
    newText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            validate();
        }
    });
    newText.addListener(SWT.KeyDown, new Listener() {

        public void handleEvent(Event e) {
            if (e.type == SWT.KeyDown && e.character == SWT.CR) {
                buttonPressed(IDialogConstants.OK_ID);
            }
        }
    });
    if (newFlag) {
        setTitle(Messages.subTitleAddQueryRecord);
    } else {
        String msg = Messages.bind(Messages.subTitleRenameQueryRecord, queryRecord.getName());
        setTitle(msg);
    }
    return parent;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text) Date(java.util.Date)

Example 63 with Listener

use of org.eclipse.swt.widgets.Listener in project cubrid-manager by CUBRID.

the class JdbcOptionComposite method focusCell.

public void focusCell(final TableItem item, final int row, final int col) {
    final StyledText text = new StyledText(jdbcInfoTv.getTable(), SWT.SINGLE);
    Listener textListener = new TableItemEditor(text, item, row, col);
    text.addListener(SWT.FocusOut, textListener);
    text.addListener(SWT.Traverse, textListener);
    text.addListener(SWT.FocusIn, textListener);
    text.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
                e.doit = false;
                int newColumn = col == 0 ? 1 : 0;
                focusCell(item, row, newColumn);
            } else if (e.detail == SWT.TRAVERSE_RETURN) {
                e.doit = false;
                addButton.setFocus();
            }
        }
    });
    text.setEditable(true);
    editor.setEditor(text, item, col);
    text.setText(item.getText(col));
    text.selectAll();
    try {
        text.setFocus();
    } catch (Exception e) {
    }
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) Listener(org.eclipse.swt.widgets.Listener) TraverseListener(org.eclipse.swt.events.TraverseListener) MouseListener(org.eclipse.swt.events.MouseListener) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener)

Example 64 with Listener

use of org.eclipse.swt.widgets.Listener in project LAMSADE-tools by LAntoine.

the class Win1 method initUI.

private void initUI(Display display) {
    // Display display = new Display();
    Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.CENTER);
    Color col = new Color(display, 100, 220, 150);
    shell.setBackground(col);
    col.dispose();
    GridLayout layout = new GridLayout(2, false);
    shell.setLayout(layout);
    Label lbl1 = new Label(shell, SWT.NONE);
    Composite composite = new Composite(shell, SWT.FILL);
    lbl1.setLayoutData(composite);
    Color col1 = new Color(display, 255, 155, 10);
    lbl1.setBackground(col1);
    col1.dispose();
    Text txtTest = new Text(composite, SWT.NONE);
    txtTest.setText("Testing");
    Text txtMoreTests = new Text(composite, SWT.NONE);
    txtMoreTests.setText("Another test");
    Button button = new Button(composite, SWT.PUSH);
    button.setText("Press Me");
    button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event e) {
            switch(e.type) {
                case SWT.Selection:
                    System.out.println("Button pressed");
                    break;
                default:
                    break;
            }
        }
    });
    Label lbl3 = new Label(shell, SWT.NONE);
    GridData gd3 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd3.widthHint = 1000;
    gd3.heightHint = 500;
    gd3.horizontalSpan = 2;
    lbl3.setLayoutData(gd3);
    Color col3 = new Color(display, 100, 205, 200);
    lbl3.setBackground(col3);
    col3.dispose();
    shell.setText("Grid");
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) Color(org.eclipse.swt.graphics.Color) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text)

Example 65 with Listener

use of org.eclipse.swt.widgets.Listener in project lwjgl by LWJGL.

the class LWJGLTestView method createPartControl.

/** 
	 * {@inheritDoc}
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    String strVersion = getFeatureVersion("org.lwjgl");
    this.setPartName("org.lwjgl " + strVersion);
    IStatusLineManager statusLine = this.getViewSite().getActionBars().getStatusLineManager();
    fpsstatuslineitem = new FpsStatusLineItem();
    statusLine.add(fpsstatuslineitem);
    GLData data = new GLData();
    data.doubleBuffer = true;
    canvas = new GLCanvas(parent, SWT.NONE, data);
    canvas.setCurrent();
    try {
        GLContext.useContext(canvas);
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
    canvas.addListener(SWT.Resize, new Listener() {

        public void handleEvent(Event event) {
            Rectangle bounds = canvas.getBounds();
            float fAspect = (float) bounds.width / (float) bounds.height;
            canvas.setCurrent();
            try {
                GLContext.useContext(canvas);
            } catch (LWJGLException e) {
                e.printStackTrace();
            }
            GL11.glViewport(0, 0, bounds.width, bounds.height);
            GL11.glMatrixMode(GL11.GL_PROJECTION);
            GL11.glLoadIdentity();
            GLU.gluPerspective(45.0f, fAspect, 0.5f, 400.0f);
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glLoadIdentity();
        }
    });
    GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glClearDepth(1.0);
    GL11.glLineWidth(2);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    Display.getCurrent().asyncExec(initRunnable());
}
Also used : GLCanvas(org.eclipse.swt.opengl.GLCanvas) Listener(org.eclipse.swt.widgets.Listener) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) GLData(org.eclipse.swt.opengl.GLData) Rectangle(org.eclipse.swt.graphics.Rectangle) Event(org.eclipse.swt.widgets.Event) LWJGLException(org.lwjgl.LWJGLException)

Aggregations

Listener (org.eclipse.swt.widgets.Listener)214 Event (org.eclipse.swt.widgets.Event)199 SelectionEvent (org.eclipse.swt.events.SelectionEvent)101 GridData (org.eclipse.swt.layout.GridData)95 Composite (org.eclipse.swt.widgets.Composite)82 GridLayout (org.eclipse.swt.layout.GridLayout)78 Point (org.eclipse.swt.graphics.Point)60 SelectionListener (org.eclipse.swt.events.SelectionListener)58 Button (org.eclipse.swt.widgets.Button)58 Label (org.eclipse.swt.widgets.Label)53 Text (org.eclipse.swt.widgets.Text)49 Table (org.eclipse.swt.widgets.Table)46 DisposeListener (org.eclipse.swt.events.DisposeListener)37 DisposeEvent (org.eclipse.swt.events.DisposeEvent)36 Rectangle (org.eclipse.swt.graphics.Rectangle)35 FocusEvent (org.eclipse.swt.events.FocusEvent)34 TableColumn (org.eclipse.swt.widgets.TableColumn)34 Shell (org.eclipse.swt.widgets.Shell)31 KeyEvent (org.eclipse.swt.events.KeyEvent)30 Group (org.eclipse.swt.widgets.Group)30