use of org.eclipse.swt.events.KeyAdapter 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.KeyAdapter in project cogtool by cogtool.
the class Keypad method makeEntry.
/**
* Creates and lays out the elements for the keypad's enter/cancel box.
*
* @author Paul Rubritz (ptr@andrew.cmu.edu)
*/
protected void makeEntry() {
GridLayout grid = new GridLayout();
grid.numColumns = 3;
GridData gridKeysOption = new GridData();
gridKeysOption.horizontalSpan = 2;
Composite entry = new Composite(dialog, SWT.NONE);
entry.setLayoutData(gridKeysOption);
entry.setLayout(grid);
int width = (keypadType == FULL_KEYPAD) ? FULL_WIDTH : NUMPAD_WIDTH;
/* text input box */
enteredText = new Text(entry, SWT.NONE);
enteredText.setFont(FontUtils.DEFAULT_FONT);
gridKeysOption = new GridData();
gridKeysOption.horizontalSpan = 3;
gridKeysOption.widthHint = width;
gridKeysOption.heightHint = 100;
enteredText.setLayoutData(gridKeysOption);
enteredText.setBackground(getDefaultBGColor());
enteredText.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent evt) {
if (evt.keyCode == SWT.ESC) {
userResponse = null;
dialog.close();
}
}
});
/* enter button */
gridKeysOption = new GridData();
gridKeysOption.verticalIndent = 10;
gridKeysOption.horizontalSpan = 2;
gridKeysOption.widthHint = width / 2;
gridKeysOption.heightHint = 75;
gridKeysOption.horizontalAlignment = SWT.RIGHT;
SelectionListener listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
userResponse = enteredText.getText();
dialog.close();
}
};
makeButton(entry, ENTER_KEY, gridKeysOption, listener);
/* cancel button */
gridKeysOption = new GridData();
gridKeysOption.verticalIndent = 10;
gridKeysOption.horizontalSpan = 1;
gridKeysOption.widthHint = width / 2;
gridKeysOption.heightHint = 75;
gridKeysOption.horizontalAlignment = SWT.RIGHT;
listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
userResponse = null;
dialog.close();
}
};
makeButton(entry, CANCEL_KEY, gridKeysOption, listener);
}
use of org.eclipse.swt.events.KeyAdapter in project translationstudio8 by heartsome.
the class ColumnCategoriesDialog method addListenersToListViewer.
private void addListenersToListViewer() {
listViewer.getControl().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
removeSelected();
}
});
listViewer.getControl().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
boolean controlMask = (e.stateMask & SWT.CONTROL) == SWT.CONTROL;
if (controlMask && e.keyCode == SWT.ARROW_UP) {
moveSelectedUp();
e.doit = false;
} else if (controlMask && e.keyCode == SWT.ARROW_DOWN) {
moveSelectedDown();
e.doit = false;
}
}
@Override
public void keyReleased(KeyEvent e) {
if (e.character == ' ')
removeSelected();
}
});
}
use of org.eclipse.swt.events.KeyAdapter in project translationstudio8 by heartsome.
the class ColumnChooserDialog method populateDialogArea.
@Override
public void populateDialogArea(Composite parent) {
GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
parent.setLayout(new GridLayout(4, false));
createLabels(parent, availableLabel, selectedLabel);
availableTree = new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.Expand);
GridData gridData = GridDataFactory.fillDefaults().grab(true, true).create();
availableTree.setLayoutData(gridData);
availableTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
addSelected();
}
});
availableTree.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.character == ' ')
addSelected();
}
});
Composite buttonComposite = new Composite(parent, SWT.NONE);
buttonComposite.setLayout(new GridLayout(1, true));
Button addButton = new Button(buttonComposite, SWT.PUSH);
addButton.setImage(GUIHelper.getImage("arrow_right"));
gridData = GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create();
addButton.setLayoutData(gridData);
addButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
addSelected();
}
});
Button removeButton = new Button(buttonComposite, SWT.PUSH);
removeButton.setImage(GUIHelper.getImage("arrow_left"));
gridData = GridDataFactory.copyData(gridData);
removeButton.setLayoutData(gridData);
removeButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
removeSelected();
}
});
selectedTree = new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.Expand);
gridData = GridDataFactory.fillDefaults().grab(true, true).create();
selectedTree.setLayoutData(gridData);
selectedTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
removeSelected();
}
});
selectedTree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
boolean controlMask = (e.stateMask & SWT.CONTROL) == SWT.CONTROL;
if (controlMask && e.keyCode == SWT.ARROW_UP) {
moveSelectedUp();
e.doit = false;
} else if (controlMask && e.keyCode == SWT.ARROW_DOWN) {
moveSelectedDown();
e.doit = false;
}
}
@Override
public void keyReleased(KeyEvent e) {
if (e.character == ' ')
removeSelected();
}
});
selectedTree.addTreeListener(new TreeListener() {
public void treeCollapsed(TreeEvent event) {
selectedTreeCollapsed(event);
}
public void treeExpanded(TreeEvent event) {
selectedTreeExpanded(event);
}
});
selectedTree.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent event) {
widgetSelected(event);
}
public void widgetSelected(SelectionEvent event) {
toggleColumnGroupSelection((TreeItem) event.item);
}
});
Composite upDownbuttonComposite = new Composite(parent, SWT.NONE);
upDownbuttonComposite.setLayout(new GridLayout(1, true));
Button upButton = new Button(upDownbuttonComposite, SWT.PUSH);
upButton.setImage(GUIHelper.getImage("arrow_up"));
gridData = GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create();
upButton.setLayoutData(gridData);
upButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
moveSelectedUp();
}
});
Button downButton = new Button(upDownbuttonComposite, SWT.PUSH);
downButton.setImage(GUIHelper.getImage("arrow_down"));
gridData = GridDataFactory.copyData(gridData);
downButton.setLayoutData(gridData);
downButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
moveSelectedDown();
}
});
}
use of org.eclipse.swt.events.KeyAdapter in project translationstudio8 by heartsome.
the class ComboBoxCellEditor method activateCell.
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
this.originalCanonicalValue = originalCanonicalValue;
combo = new NatCombo(parent, getCellStyle(), maxVisibleItems);
combo.setItems(getDisplayValues());
if (originalCanonicalValue != null) {
combo.setSelection(new String[] { getDisplayValue() });
}
combo.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if ((event.keyCode == SWT.CR && event.stateMask == 0) || (event.keyCode == SWT.KEYPAD_CR && event.stateMask == 0)) {
commit(MoveDirectionEnum.NONE);
} else if (event.keyCode == SWT.ESC && event.stateMask == 0) {
close();
}
}
});
combo.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent event) {
if (event.keyCode == SWT.TAB && event.stateMask == SWT.SHIFT) {
commit(MoveDirectionEnum.LEFT);
} else if (event.keyCode == SWT.TAB && event.stateMask == 0) {
commit(MoveDirectionEnum.RIGHT);
}
}
});
combo.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
commit(MoveDirectionEnum.NONE);
}
});
return combo;
}
Aggregations