use of org.eclipse.swt.events.MouseEvent in project tdi-studio-se by Talend.
the class ImportComponentDialog method createDialogArea.
/*
* (non-Javadoc) Method declared on Dialog.
*/
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
GridLayout gl = new GridLayout(5, true);
composite.setLayout(gl);
if (message != null) {
Label label = new Label(composite, SWT.WRAP);
label.setText(message);
GridData data = new GridData(GridData.GRAB_HORIZONTAL);
data.horizontalSpan = 5;
label.setLayoutData(data);
label.setFont(parent.getFont());
}
Label label1 = new Label(composite, SWT.NONE);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
gd.horizontalSpan = 2;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.SelectDirectoryLabel"));
text = new Text(composite, SWT.BORDER);
text.setEditable(false);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
text.setLayoutData(gd);
if (paletteComponentsPath == null) {
//$NON-NLS-1$
paletteComponentsPath = "";
}
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(true);
}
});
Button button = new Button(composite, SWT.NONE);
//$NON-NLS-1$
button.setText(Messages.getString("ImportComponentDialog.Browser"));
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 1;
button.setLayoutData(gd);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dd = new DirectoryDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
String path = dd.open();
if (path != null) {
text.setText(path);
}
}
});
Button showPaletteComponents = new Button(composite, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 2;
showPaletteComponents.setLayoutData(gd);
//$NON-NLS-1$
showPaletteComponents.setText(Messages.getString("ImportComponentDialog.ShowPaletteComponents"));
showPaletteComponents.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
text.setText(paletteComponentsPath);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 1;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.Filter"));
filterText = new Text(composite, SWT.BORDER);
filterText.setEditable(true);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
filterText.setLayoutData(gd);
filterText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(false);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.ChooseComponentsLabel"));
componentList = new List(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
componentList.setLayoutData(gd);
componentList.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
validateSelected();
}
public void mouseUp(MouseEvent e) {
validateSelected();
}
});
errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.CENTER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
errorMessageText.setLayoutData(gd);
errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
applyDialogFont(composite);
//$NON-NLS-1$
text.setText("");
return composite;
}
use of org.eclipse.swt.events.MouseEvent in project tdi-studio-se by Talend.
the class AbstractTalendEditor method initializeGraphicalViewer.
// ------------------------------------------------------------------------
// Abstract methods from GraphicalEditor
@Override
protected void initializeGraphicalViewer() {
super.initializeGraphicalViewer();
// this uses the PartFactory set in configureGraphicalViewer
// to create an EditPart for the diagram and sets it as the
// content for the viewer
IProcess2 process = getProcess();
getGraphicalViewer().setContents(process);
// containers are not correctly updated by default, so update them after all nodes have been added
if (process != null) {
for (ISubjobContainer subjobContainer : process.getSubjobContainers()) {
subjobContainer.updateSubjobContainer();
}
}
getGraphicalViewer().getControl().addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
updateActions(getSelectionActions());
}
});
talendEditorDropTargetListener = new TalendEditorDropTargetListener(this);
getGraphicalViewer().addDropTargetListener(talendEditorDropTargetListener);
}
use of org.eclipse.swt.events.MouseEvent 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.MouseEvent in project tdi-studio-se by Talend.
the class DataMapTableView method attachCellExpressionToStyledTextEditor.
/**
* DOC amaumont Comment method "attachCellExpressionToStyledTextEditor".
*
* @param tableViewerCreator TODO
* @param styledTextHandler
* @param expressionEditorText2
*/
protected void attachCellExpressionToStyledTextEditor(final TableViewerCreator tableViewerCreator, final Text expressionTextEditor, final StyledTextHandler styledTextHandler) {
expressionTextEditor.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
ITableEntry currentModifiedEntry = (ITableEntry) tableViewerCreator.getModifiedObjectInfo().getCurrentModifiedBean();
styledTextHandler.setCurrentEntry(currentModifiedEntry);
Text text = (Text) e.widget;
if (Math.abs(text.getText().length() - styledTextHandler.getStyledText().getText().length()) > 1) {
styledTextHandler.setTextWithoutNotifyListeners(text.getText());
// highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
}
});
expressionTextEditor.addKeyListener(new KeyListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
*/
@Override
public void keyPressed(KeyEvent e) {
// System.out.println("e.character=" + e.character);
// System.out.println("keyCode=" + e.keyCode);
boolean ctrl = (e.stateMask & SWT.CTRL) != 0;
boolean altgr = (e.stateMask & SWT.ALT) != 0;
if (e.character == '\0' || ctrl && !altgr) {
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
} else {
UnnotifiableColorStyledText mapperColorStyledText = (UnnotifiableColorStyledText) styledTextHandler.getStyledText();
Point selection = expressionTextEditor.getSelection();
if (e.character == '\r' || e.character == '') {
e.doit = false;
styledTextHandler.setTextWithoutNotifyListeners(expressionTextEditor.getText());
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
} else {
if (e.character == SWT.BS || e.character == SWT.DEL) {
if (selection.x == selection.y) {
if (e.character == SWT.BS) {
if (selection.x - 1 > 0 && mapperColorStyledText.getText().length() > selection.x - 1) {
char previousChar = mapperColorStyledText.getText().charAt(selection.x - 1);
if (previousChar == '\n') {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x - 2, 2, "");
} else {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x - 1, 1, "");
}
}
} else {
if (selection.x < mapperColorStyledText.getText().length()) {
char nextChar = mapperColorStyledText.getText().charAt(selection.x);
if (nextChar == '\r') {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, 2, "");
} else {
//$NON-NLS-1$
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, 1, "");
}
}
}
} else {
if (selection.y <= mapperColorStyledText.getCharCount()) {
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, selection.y - selection.x, //$NON-NLS-1$
"");
}
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
} else {
// System.out.println("mapperColorStyledText.getText()="+mapperColorStyledText.getText().length());
if (selection.y <= mapperColorStyledText.getCharCount()) {
mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, selection.y - selection.x, String.valueOf(e.character));
}
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
}
}
}
@Override
public void keyReleased(KeyEvent e) {
// highlightLineOfCursorPosition();
}
});
expressionTextEditor.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClick(MouseEvent e) {
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
@Override
public void mouseDown(MouseEvent e) {
highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
}
@Override
public void mouseUp(MouseEvent e) {
}
});
}
use of org.eclipse.swt.events.MouseEvent in project tdi-studio-se by Talend.
the class Marker method createLineHover.
private void createLineHover(Integer invertedSeriesIndex) {
if (lineHover == null || lineHover.isDisposed() || !lineHover.isVisible()) {
lineHover = new Shell(chart.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL | SWT.NO_BACKGROUND);
lineHover.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
e.gc.setLineStyle(SWT.LINE_DOT);
e.gc.setAntialias(SWT.ON);
e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
// e.gc.fillOval(2-1,150-1, 3, 3);
e.gc.drawLine(2, 0, 2, chart.getPlotArea().getSize().y);
}
});
lineHover.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseEnter(MouseEvent e) {
if (!isDisposed()) {
setPosition(mouseXPosition);
}
}
});
}
lineHover.setSize(4, chart.getPlotArea().getSize().y);
ISeries largestSeries = getLargestSeries();
Date[] dates = largestSeries.getXDateSeries();
long time = dates[dates.length - invertedSeriesIndex].getTime();
int timeInPixel = chart.getAxisSet().getXAxes()[0].getPixelCoordinate(time);
lineHover.setLocation(chart.getPlotArea().toDisplay(timeInPixel - 3, 0));
lineHover.redraw();
lineHover.setVisible(true);
}
Aggregations