use of org.eclipse.swt.events.MouseTrackListener in project tdi-studio-se by Talend.
the class ReviewComponentDialog method createRatingComp.
private void createRatingComp(Composite parent) {
initImages();
final Composite rateBtnComp = new Composite(parent, SWT.NONE);
final GridLayout rateLayout = new GridLayout();
rateLayout.numColumns = 5;
rateBtnComp.setLayout(rateLayout);
rateBtnComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
for (int i = 0; i < 5; i++) {
final Button rateButton = new Button(rateBtnComp, SWT.NONE);
rateButton.setLayoutData(new GridData(30, SWT.DEFAULT));
rateButton.setImage(imageMap.get(1));
rateButton.setData(0);
rateBtnMap.put(i, rateButton);
rateButton.addMouseTrackListener(new MouseTrackListener() {
public void mouseHover(MouseEvent e) {
handleMouseHover(rateButton);
}
public void mouseExit(MouseEvent e) {
handleMouseExit(rateButton);
}
public void mouseEnter(MouseEvent e) {
}
});
rateButton.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
handleMouseDown(rateButton);
checkInput();
}
public void mouseDoubleClick(MouseEvent e) {
}
});
}
rateLabel = new Label(parent, SWT.NONE);
rateLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
rateLabel.setText("Please select your rating*");
}
use of org.eclipse.swt.events.MouseTrackListener in project tdi-studio-se by Talend.
the class DataMapTableView method addListeners.
/**
* DOC amaumont Comment method "addListeners".
*/
protected void addListeners() {
final UIManager uiManager = mapperManager.getUiManager();
MouseTrackListener mouseTracker = new MouseTrackListener() {
@Override
public void mouseEnter(MouseEvent e) {
}
@Override
public void mouseExit(MouseEvent e) {
setDefaultCursor();
resizeHelper.stopDrag();
}
@Override
public void mouseHover(MouseEvent e) {
}
};
this.addMouseTrackListener(mouseTracker);
SelectionListener scrollListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
uiManager.refreshBackground(true, false);
}
};
tableForEntries.getVerticalBar().addSelectionListener(scrollListener);
// /////////////////////////////////////////////////////////////////
addManualTableResizeListeners(uiManager);
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
Listener onSelectDataMapTableViewListener = new Listener() {
@Override
public void handleEvent(Event event) {
switch(event.type) {
case SWT.MouseDown:
onSelectDataMapTableView();
break;
default:
}
}
};
this.addListener(SWT.MouseDown, onSelectDataMapTableViewListener);
headerComposite.addListener(SWT.MouseDown, onSelectDataMapTableViewListener);
nameLabel.addListener(SWT.MouseDown, onSelectDataMapTableViewListener);
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
minimizeButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
@Override
public void widgetSelected(SelectionEvent e) {
minimizeTable(!abstractDataMapTable.isMinimized());
}
});
// /////////////////////////////////////////////////////////////////
initShowMessageErrorListener(tableForEntries);
}
use of org.eclipse.swt.events.MouseTrackListener in project cubrid-manager by CUBRID.
the class InformationWindow method createContents.
protected Control createContents(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
infoText = new StyledText(composite, SWT.None);
infoText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
infoText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
infoText.setEditable(false);
infoText.setEnabled(false);
infoText.addMouseTrackListener(new MouseTrackListener() {
public void mouseHover(MouseEvent e) {
increaseAlpha();
}
public void mouseExit(MouseEvent e) {
reduceAlpha();
}
public void mouseEnter(MouseEvent e) {
increaseAlpha();
}
});
parentShell.addControlListener(new ControlListener() {
public void controlResized(ControlEvent e) {
updateLocation();
}
public void controlMoved(ControlEvent e) {
updateLocation();
}
});
if (Platform.getOS().equals(Platform.OS_WIN32)) {
parentShell.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
updateLocation();
}
});
}
this.getShell().setAlpha(minAlpha);
updateLocation();
return parent;
}
use of org.eclipse.swt.events.MouseTrackListener 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.MouseTrackListener 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) {
}
};
}
Aggregations