Search in sources :

Example 36 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project cubrid-manager by CUBRID.

the class AutoIncrementCellEditor method createControl.

protected Control createControl(Composite parent) {
    composite = new Composite(parent, SWT.NONE);
    {
        GridLayout gl = new GridLayout(3, false);
        gl.marginHeight = 0;
        gl.marginBottom = 0;
        gl.marginTop = 0;
        gl.marginLeft = 0;
        gl.marginRight = 0;
        gl.marginWidth = 0;
        composite.setLayout(gl);
    }
    startVal = new Text(composite, SWT.BORDER);
    startVal.setLayoutData(new GridData(50, -1));
    startVal.setToolTipText(Messages.lblAutoIncrStart);
    new Label(composite, SWT.NONE).setText(",");
    increVal = new Text(composite, SWT.BORDER);
    increVal.setLayoutData(new GridData(15, -1));
    increVal.setToolTipText(Messages.lblAutoIncrIncr);
    KeyAdapter keyAdapter = new KeyAdapter() {

        public void keyReleased(KeyEvent e) {
            if (e.character == '\r') {
                deactivateWidget();
            }
        }
    };
    startVal.addKeyListener(keyAdapter);
    increVal.addKeyListener(keyAdapter);
    ModifyListener modifyListener = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            value = getAutoIncrementValue();
            markDirty();
            valueChanged(true, true);
        }
    };
    startVal.addModifyListener(modifyListener);
    increVal.addModifyListener(modifyListener);
    FocusAdapter focusAdapter = new FocusAdapter() {

        public void focusGained(FocusEvent e) {
            deactivateWidget();
            AutoIncrementCellEditor.this.focusLost();
        }
    };
    parent.addFocusListener(focusAdapter);
    return composite;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) FocusAdapter(org.eclipse.swt.events.FocusAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 37 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project cubrid-manager by CUBRID.

the class DataTypeCellEditor method createControl.

protected Control createControl(Composite parent) {
    comboBox = new DataTypeCombo(parent, getStyle());
    comboBox.setFont(parent.getFont());
    populateComboBoxItems();
    //		comboBox.addKeyListener(new KeyAdapter() {
    //			public void keyPressed(KeyEvent event) {
    //				if (event.character == '\r') {
    //					applyEditorValueAndDeactivate();
    //				}
    //				keyReleaseOccured(event);
    //			}
    //
    //			public void keyReleased(KeyEvent event) {
    //			}
    //		});
    comboBox.addModifyListener(getModifyListener());
    comboBox.addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent event) {
            applyEditorValueAndDeactivate();
        }

        public void widgetSelected(SelectionEvent event) {
            value = comboBox.getText();
        }
    });
    comboBox.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_ESCAPE || event.detail == SWT.TRAVERSE_RETURN) {
                event.doit = false;
            }
        }
    });
    comboBox.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent event) {
            applyEditorValueAndDeactivate();
            DataTypeCellEditor.this.focusLost();
        }
    });
    return comboBox;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 38 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project translationstudio8 by heartsome.

the class RenameResourceAndCloseEditorAction method createTextEditor.

/**
	 * Create the text editor widget.
	 * 
	 * @param resource
	 *            the resource to rename
	 */
private void createTextEditor(final IResource resource) {
    // Create text editor parent. This draws a nice bounding rect.
    textEditorParent = createParent();
    textEditorParent.setVisible(false);
    final int inset = getCellEditorInset(textEditorParent);
    if (inset > 0) {
        textEditorParent.addListener(SWT.Paint, new Listener() {

            public void handleEvent(Event e) {
                Point textSize = textEditor.getSize();
                Point parentSize = textEditorParent.getSize();
                e.gc.drawRectangle(0, 0, Math.min(textSize.x + 4, parentSize.x - 1), parentSize.y - 1);
            }
        });
    }
    // Create inner text editor.
    textEditor = new Text(textEditorParent, SWT.NONE);
    textEditor.setFont(navigatorTree.getFont());
    textEditorParent.setBackground(textEditor.getBackground());
    textEditor.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event e) {
            Point textSize = textEditor.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            // Add extra space for new
            textSize.x += textSize.y;
            // characters.
            Point parentSize = textEditorParent.getSize();
            textEditor.setBounds(2, inset, Math.min(textSize.x, parentSize.x - 4), parentSize.y - 2 * inset);
            textEditorParent.redraw();
        }
    });
    textEditor.addListener(SWT.Traverse, new Listener() {

        public void handleEvent(Event event) {
            // traverse events
            switch(event.detail) {
                case SWT.TRAVERSE_ESCAPE:
                    // Do nothing in this case
                    disposeTextWidget();
                    event.doit = true;
                    event.detail = SWT.TRAVERSE_NONE;
                    break;
                case SWT.TRAVERSE_RETURN:
                    saveChangesAndDispose(resource);
                    event.doit = true;
                    event.detail = SWT.TRAVERSE_NONE;
                    break;
            }
        }
    });
    textEditor.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent fe) {
            saveChangesAndDispose(resource);
            closeRelatedEditors();
        }
    });
    if (textActionHandler != null) {
        textActionHandler.addText(textEditor);
    }
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Listener(org.eclipse.swt.widgets.Listener) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point)

Example 39 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project translationstudio8 by heartsome.

the class QAPage method addTgtLengthGroup.

/**
	 * 添加目标文本段长度限制检查
	 * @param tParent
	 */
private void addTgtLengthGroup(Composite tParent) {
    Group group = new Group(tParent, SWT.NONE);
    group.setText(Messages.getString("preference.QAPage.group"));
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    group.setLayout(new GridLayout());
    HsImageLabel tgtLengthSetLbl = new HsImageLabel(Messages.getString("preference.QAPage.tgtLengthSetLbl"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_QA_Page_tgtLengthSet));
    Composite tgtLengthLblCmp = tgtLengthSetLbl.createControl(group);
    tgtLengthLblCmp.setLayout(new GridLayout(3, false));
    tgtLengthLblCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Composite tgtLengthSetCmp = new Composite(tgtLengthLblCmp, SWT.NONE);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).equalWidth(false).numColumns(3).applyTo(tgtLengthSetCmp);
    GridDataFactory.fillDefaults().span(3, SWT.DEFAULT).grab(true, true).applyTo(tgtLengthSetCmp);
    GridData txtData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    txtData.widthHint = 200;
    minBtn = new Button(tgtLengthSetCmp, SWT.CHECK);
    minBtn.setText(Messages.getString("preference.QAPage.minBtn"));
    minTxt = new Text(tgtLengthSetCmp, SWT.BORDER);
    minTxt.setLayoutData(txtData);
    Label label = new Label(tgtLengthSetCmp, SWT.NONE);
    label.setText("%");
    maxBtn = new Button(tgtLengthSetCmp, SWT.CHECK);
    maxBtn.setText(Messages.getString("preference.QAPage.maxBtn"));
    maxTxt = new Text(tgtLengthSetCmp, SWT.BORDER);
    maxTxt.setLayoutData(txtData);
    label = new Label(tgtLengthSetCmp, SWT.NONE);
    label.setText("%");
    tgtLengthSetLbl.computeSize();
    minTxt.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            validMinValue(isNumericRegex);
        }
    });
    maxTxt.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            validMaxValue(isNumericRegex);
        }
    });
    minBtn.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            validMinValue(isNumericRegex);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            validMinValue(isNumericRegex);
        }
    });
    maxBtn.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            validMaxValue(isNumericRegex);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            validMaxValue(isNumericRegex);
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Composite(org.eclipse.swt.widgets.Composite) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) HsImageLabel(net.heartsome.cat.common.ui.HsImageLabel) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 40 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project translationstudio8 by heartsome.

the class ImportProjectWizardPage method createProjectsRoot.

/**
	 * Create the area where you select the root directory for the projects.
	 * 
	 * @param workArea
	 * 		Composite
	 */
private void createProjectsRoot(Composite workArea) {
    // project specification group
    Composite projectGroup = new Composite(workArea, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = false;
    layout.marginWidth = 0;
    projectGroup.setLayout(layout);
    projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // new project from archive radio button
    projectFromArchiveRadio = new Label(projectGroup, SWT.None);
    projectFromArchiveRadio.setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle);
    // project location entry field
    archivePathField = new Text(projectGroup, SWT.BORDER);
    GridData archivePathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    archivePathData.widthHint = new PixelConverter(archivePathField).convertWidthInCharsToPixels(25);
    // browse button
    archivePathField.setLayoutData(archivePathData);
    browseArchivesButton = new Button(projectGroup, SWT.PUSH);
    browseArchivesButton.setText(DataTransferMessages.DataTransfer_browse);
    setButtonLayoutData(browseArchivesButton);
    browseArchivesButton.addSelectionListener(new SelectionAdapter() {

        /*
			 * (non-Javadoc)
			 * 
			 * @see
			 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
			 * .swt.events.SelectionEvent)
			 */
        public void widgetSelected(SelectionEvent e) {
            handleLocationArchiveButtonPressed();
        }
    });
    archivePathField.addTraverseListener(new TraverseListener() {

        /*
			 * (non-Javadoc)
			 * 
			 * @see
			 * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse
			 * .swt.events.TraverseEvent)
			 */
        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_RETURN) {
                e.doit = false;
                updateProjectsList(archivePathField.getText().trim());
            }
        }
    });
    archivePathField.addFocusListener(new FocusAdapter() {

        /*
			 * (non-Javadoc)
			 * 
			 * @see
			 * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt
			 * .events.FocusEvent)
			 */
        public void focusLost(org.eclipse.swt.events.FocusEvent e) {
            updateProjectsList(archivePathField.getText().trim());
        }
    });
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) Composite(org.eclipse.swt.widgets.Composite) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) PixelConverter(org.eclipse.jface.layout.PixelConverter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

FocusAdapter (org.eclipse.swt.events.FocusAdapter)68 FocusEvent (org.eclipse.swt.events.FocusEvent)64 SelectionEvent (org.eclipse.swt.events.SelectionEvent)42 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)36 Composite (org.eclipse.swt.widgets.Composite)29 GridData (org.eclipse.swt.layout.GridData)28 Text (org.eclipse.swt.widgets.Text)26 GridLayout (org.eclipse.swt.layout.GridLayout)25 Label (org.eclipse.swt.widgets.Label)20 Button (org.eclipse.swt.widgets.Button)17 Menu (org.eclipse.swt.widgets.Menu)17 Point (org.eclipse.swt.graphics.Point)16 MenuManager (org.eclipse.jface.action.MenuManager)15 MenuItem (org.eclipse.swt.widgets.MenuItem)15 ModifyEvent (org.eclipse.swt.events.ModifyEvent)14 ModifyListener (org.eclipse.swt.events.ModifyListener)14 KeyEvent (org.eclipse.swt.events.KeyEvent)12 Combo (org.eclipse.swt.widgets.Combo)12 KeyAdapter (org.eclipse.swt.events.KeyAdapter)11 Group (org.eclipse.swt.widgets.Group)11