use of org.eclipse.swt.events.FocusEvent 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.FocusEvent in project translationstudio8 by heartsome.
the class Grid method initListeners.
/**
* Initialize all listeners.
*/
private void initListeners() {
disposeListener = new Listener() {
public void handleEvent(Event e) {
onDispose(e);
}
};
addListener(SWT.Dispose, disposeListener);
addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
onPaint(e);
}
});
addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
onResize();
}
});
if (getVerticalBar() != null) {
getVerticalBar().addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
onScrollSelection();
}
});
}
if (getHorizontalBar() != null) {
getHorizontalBar().addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
onScrollSelection();
}
});
}
addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event e) {
onKeyDown(e);
}
});
addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
e.doit = true;
}
});
addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
onMouseDoubleClick(e);
}
public void mouseDown(MouseEvent e) {
onMouseDown(e);
}
public void mouseUp(MouseEvent e) {
onMouseUp(e);
}
});
addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent e) {
onMouseMove(e);
}
});
addMouseTrackListener(new MouseTrackListener() {
public void mouseEnter(MouseEvent e) {
}
public void mouseExit(MouseEvent e) {
onMouseExit(e);
}
public void mouseHover(MouseEvent e) {
}
});
addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
onFocusIn();
redraw();
}
public void focusLost(FocusEvent e) {
redraw();
}
});
// Special code to reflect mouse wheel events if using an external
// scroller
addListener(SWT.MouseWheel, new Listener() {
public void handleEvent(Event e) {
onMouseWheel(e);
}
});
}
use of org.eclipse.swt.events.FocusEvent 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.FocusEvent 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.FocusEvent in project translationstudio8 by heartsome.
the class StyledTextCellEditor method createTextControl.
protected StyledText createTextControl(Composite parent) {
TagStyleManager tagStyleManager = xliffEditor.getTagStyleManager();
IStyle cellStyle = this.hsCellEditor.getCellStyle();
int styled = HorizontalAlignmentEnum.getSWTStyle(cellStyle);
styled |= SWT.MULTI | SWT.WRAP;
viewer = new SegmentViewer(parent, styled, tagStyleManager.getTagStyle());
// 添加标记样式改变监听
// addTagStyleChangeListener();
// 注册标记样式调节器
net.heartsome.cat.ts.ui.innertag.tagstyle.TagStyleConfigurator.configure(viewer);
// TagStyleConfigurator.configure(viewer);
// 将原来直接创建StyledText的方式改为由TextViewer提供
final StyledText textControl = viewer.getTextWidget();
initStyle(textControl, cellStyle);
textControl.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
}
public void focusGained(FocusEvent e) {
getActionHandler().updateGlobalActionHandler();
}
});
viewer.getDocument().addDocumentListener(new IDocumentListener() {
public void documentChanged(DocumentEvent e) {
// 自动行高
autoResize();
}
public void documentAboutToBeChanged(DocumentEvent event) {
}
});
// 实现编辑模式下添加右键菜单
// dispose textControl前应去掉右键menu,因为右键menu是和nattable共享的,不能在这儿dispose,说见close()方法
final Menu menu = (Menu) xliffEditor.getTable().getData(Menu.class.getName());
textControl.setMenu(menu);
return textControl;
}
Aggregations