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;
}
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;
}
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);
}
}
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);
}
});
}
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());
}
});
}
Aggregations