use of org.eclipse.swt.widgets.Widget in project translationstudio8 by heartsome.
the class GridTableViewer method editElement.
/**
* {@inheritDoc}
*/
public void editElement(Object element, int column) {
try {
getControl().setRedraw(false);
Widget item = findItem(element);
if (item != null) {
ViewerRow row = getViewerRowFromItem(item);
if (row != null) {
ViewerCell cell = row.getCell(column);
if (cell != null) {
triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
}
}
}
} finally {
getControl().setRedraw(true);
}
// }
}
use of org.eclipse.swt.widgets.Widget in project translationstudio8 by heartsome.
the class XLFEditor method hookListener.
/**
* 初始化监听器。
*/
private void hookListener() {
// 添加文本修改监听器,用于调整文本框大小,使其高度自适应文本内容。
textModifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
StyledText st = (StyledText) e.widget;
GridData gd = (GridData) st.getLayoutData();
if (gd == null) {
gd = new GridData(GridData.FILL_BOTH);
}
Point computeSize = st.computeSize(st.getSize().x, SWT.DEFAULT, false);
// 此行代码是为了保持列宽不变。减 10 是因为 computeSize 后宽度每次会增加 5 个像素,
// 因此需要减去上次和本次增加的共10像素。为什么会这样原因不明。
gd.widthHint = computeSize.x - 10;
st.setLayoutData(gd);
editorContentComposite.layout();
oScrolledComposite.setMinSize(editorContentComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
};
// 添加鼠标跟踪监听器,用于监听鼠标位置,根据编辑器模式切换光标样式。
mouseTrackListener = new MouseTrackListener() {
private void setArrowCursor(MouseEvent arg0) {
Widget srcWidget = arg0.widget;
if (isEditModel && srcWidget instanceof StyledText) {
((StyledText) srcWidget).setCursor(cursorIbeam);
} else {
((StyledText) srcWidget).setCursor(cursorArrow);
}
}
public void mouseEnter(MouseEvent arg0) {
setArrowCursor(arg0);
}
public void mouseExit(MouseEvent arg0) {
setArrowCursor(arg0);
}
public void mouseHover(MouseEvent arg0) {
setArrowCursor(arg0);
}
};
mouseListener = new MouseListener() {
public void mouseDoubleClick(MouseEvent arg0) {
// 切换为编辑模式
isEditModel = true;
System.out.println("It's running edit model.");
Control ctrl = arg0.display.getCursorControl();
ctrl.setCursor(cursorIbeam);
}
public void mouseDown(MouseEvent arg0) {
int inx = (Integer) arg0.widget.getData(DATAKEY_INDEX);
setSelectionRowColor(inx);
// 选中模式下要隐藏光标。
if (!isEditModel) {
// 通过为容器组件设置焦点,实现在选中模式时隐藏文本框组件中闪烁的光标
txtComposites[inx].forceFocus();
}
}
public void mouseUp(MouseEvent arg0) {
}
};
keyListener = new KeyListener() {
public void keyPressed(KeyEvent arg0) {
// 按 Esc 键切换到选择模式。
if (arg0.keyCode == SWT.ESC) {
isEditModel = false;
Control ctrl = arg0.display.getCursorControl();
ctrl.setCursor(cursorArrow);
}
}
public void keyReleased(KeyEvent arg0) {
}
};
}
use of org.eclipse.swt.widgets.Widget in project cubrid-manager by CUBRID.
the class DropDownAction method runWithEvent.
public void runWithEvent(Event event) {
// FIXME remove commented code if don't need it anymore.
//if (event.detail == SWT.ARROW) {
Widget widget = event.widget;
if (widget instanceof ToolItem) {
ToolItem toolItem = (ToolItem) widget;
Composite parent = toolItem.getParent();
Rectangle rect = toolItem.getBounds();
Point pt = new Point(rect.x, rect.y + rect.height);
pt = parent.toDisplay(pt);
Menu contextMenu = menuManager.createContextMenu(parent);
contextMenu.setLocation(pt.x, pt.y);
contextMenu.setVisible(true);
}
// } else {
// run();
// }
}
use of org.eclipse.swt.widgets.Widget in project cubrid-manager by CUBRID.
the class ProxyAction method runWithEvent.
public void runWithEvent(Event event) {
if (event.detail == SWT.ARROW) {
Widget widget = event.widget;
if (widget instanceof ToolItem) {
ToolItem toolItem = (ToolItem) widget;
Composite parent = toolItem.getParent();
Rectangle rect = toolItem.getBounds();
Point pt = new Point(rect.x, rect.y + rect.height);
pt = parent.toDisplay(pt);
MenuManager menuManager = new MenuManager();
ActionManager.getInstance().setActionsMenu(menuManager);
Menu contextMenu = menuManager.createContextMenu(parent);
contextMenu.setLocation(pt.x, pt.y);
contextMenu.setVisible(true);
}
} else {
run();
}
}
use of org.eclipse.swt.widgets.Widget in project tesb-studio-se by Talend.
the class JavaCamelJobScriptsExportWSWizardPage method handleEvent.
@Override
public void handleEvent(Event e) {
super.handleEvent(e);
Widget source = e.widget;
if (source instanceof Combo) {
String destination = ((Combo) source).getText();
if (getDialogSettings() != null) {
IDialogSettings section = getDialogSettings().getSection(DESTINATION_FILE);
if (section == null) {
section = getDialogSettings().addNewSection(DESTINATION_FILE);
}
section.put(DESTINATION_FILE, destination);
}
}
}
Aggregations