use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.
the class TabFolderEditors method createComponents.
/**
* qzhang Comment method "createComponents".
*/
private void createComponents() {
CTabItem item = new CTabItem(tabFolderEditors, SWT.BORDER);
//$NON-NLS-1$
item.setText(Messages.getString("TabFolderEditors.FunParamTab.TitleText"));
inOutMetaEditorContainer = new SashForm(tabFolderEditors, SWT.SMOOTH | SWT.HORIZONTAL | SWT.SHADOW_OUT);
inOutMetaEditorContainer.setLayout(new RowLayout(SWT.HORIZONTAL));
item.setControl(inOutMetaEditorContainer);
createTableView();
item = new CTabItem(tabFolderEditors, SWT.BORDER);
//$NON-NLS-1$
item.setText(Messages.getString("TabFolderEditors.PreviewTab.TitleText"));
Composite composite = new Composite(tabFolderEditors, SWT.BORDER);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
composite.setLayout(gridLayout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
createPreview(composite, 700, 210);
item.setControl(composite);
tabFolderEditors.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
lastSelectedTab = tabFolderEditors.getSelectionIndex();
}
});
tabFolderEditors.setSelection(0);
}
use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.
the class RowGeneratorUI method addParentListeners.
/**
* qzhang Comment method "addParentListeners".
*
* @param uiManager
* @param uiProperties
*/
private void addParentListeners(final UIManager uiManager, final ExternalRowGeneratorUiProperties uiProperties) {
rowGenUIParent.addListener(SWT.Close, new Listener() {
@Override
public void handleEvent(Event event) {
if (uiManager.getRowGenResponse() == SWT.NONE) {
uiManager.closeRowGenerator(SWT.CANCEL, false);
}
}
});
rowGenUIParent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
updateBackground(false, true);
}
@Override
public void focusLost(FocusEvent e) {
}
});
// store size if not maximized
if (rowGenUIParent instanceof Shell) {
((Shell) rowGenUIParent).addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (!((Shell) e.getSource()).getMaximized()) {
ExternalRowGeneratorUiProperties.setBoundsRowGen(((Shell) e.getSource()).getBounds());
}
}
});
}
}
use of org.eclipse.swt.widgets.Listener in project yyl_example by Relucent.
the class ImageViewer method addListeners.
void addListeners() {
hBar.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
hscroll();
}
});
vBar.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
vscroll();
}
});
addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
resize();
}
});
addListener(SWT.Paint, new Listener() {
public void handleEvent(Event e) {
paint(e);
}
});
}
use of org.eclipse.swt.widgets.Listener in project yyl_example by Relucent.
the class ScrolledComposite_TEST method main.
public static void main(String[] args) {
Display display = new Display();
Color red = display.getSystemColor(SWT.COLOR_RED);
Color blue = display.getSystemColor(SWT.COLOR_BLUE);
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
// set the size of the scrolled content - method 1
final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Composite c1 = new Composite(sc1, SWT.NONE);
sc1.setContent(c1);
c1.setBackground(red);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
c1.setLayout(layout);
Button b1 = new Button(c1, SWT.PUSH);
b1.setText("first button");
c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
// set the minimum width and height of the scrolled content - method 2
final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
sc2.setExpandHorizontal(true);
sc2.setExpandVertical(true);
final Composite c2 = new Composite(sc2, SWT.NONE);
sc2.setContent(c2);
c2.setBackground(blue);
layout = new GridLayout();
layout.numColumns = 4;
c2.setLayout(layout);
Button b2 = new Button(c2, SWT.PUSH);
b2.setText("first button");
sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Button add = new Button(shell, SWT.PUSH);
add.setText("add children");
final int[] index = new int[] { 0 };
add.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
index[0]++;
Button button = new Button(c1, SWT.PUSH);
button.setText("button " + index[0]);
// reset size of content so children can be seen - method 1
c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
c1.layout();
button = new Button(c2, SWT.PUSH);
button.setText("button " + index[0]);
// reset the minimum width and height so children can be seen - method 2
sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
c2.layout();
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
use of org.eclipse.swt.widgets.Listener in project Main by SpartanRefactoring.
the class SpartanWidgetHandler method setMovable.
static void setMovable(final Display d, final Control source, final Shell target) {
final Listener l = new Listener() {
Point origin;
@Override
public void handleEvent(final Event e) {
switch(e.type) {
case SWT.MouseUp:
origin = null;
break;
case SWT.MouseDown:
origin = new Point(e.x, e.y);
break;
case SWT.MouseMove:
if (origin != null) {
final Point p = d.map(target, null, e.x, e.y);
target.setLocation(p.x - origin.x, p.y - origin.y);
}
break;
default:
break;
}
}
};
source.addListener(SWT.MouseDown, l);
source.addListener(SWT.MouseUp, l);
source.addListener(SWT.MouseMove, l);
}
Aggregations