use of org.eclipse.swt.events.MouseEvent in project eclipse.platform.text by eclipse.
the class CompletionProposalPopup method createMessageText.
/**
* Creates the caption line under the proposal table.
*
* @since 3.2
*/
private void createMessageText() {
if (fMessageText == null) {
fMessageText = new Label(fProposalShell, SWT.RIGHT);
GridData textData = new GridData(SWT.FILL, SWT.BOTTOM, true, false);
fMessageText.setLayoutData(textData);
// $NON-NLS-1$
fMessageText.setText(fContentAssistant.getStatusMessage() + " ");
if (fMessageTextFont == null) {
Font font = fMessageText.getFont();
Display display = fProposalShell.getDisplay();
FontData[] fontDatas = font.getFontData();
for (FontData fontData : fontDatas) fontData.setHeight(fontData.getHeight() * 9 / 10);
fMessageTextFont = new Font(display, fontDatas);
}
fMessageText.setFont(fMessageTextFont);
fMessageText.setBackground(getBackgroundColor(fProposalShell));
fMessageText.setForeground(getForegroundColor(fProposalShell));
if (fContentAssistant.isRepeatedInvocationMode()) {
fMessageText.setCursor(fProposalShell.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
fMessageText.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
fLastCompletionOffset = fFilterOffset;
fProposalTable.setFocus();
handleRepeatedInvocation();
}
@Override
public void mouseDown(MouseEvent e) {
}
});
}
}
}
use of org.eclipse.swt.events.MouseEvent in project eclipse.platform.text by eclipse.
the class AnnotationBarHoverManager method computeInformationControlLocation.
@Override
protected Point computeInformationControlLocation(Rectangle subjectArea, Point controlSize) {
MouseEvent event = getHoverEvent();
IAnnotationHover hover = getHover(event);
if (hover instanceof IAnnotationHoverExtension) {
IAnnotationHoverExtension extension = (IAnnotationHoverExtension) hover;
boolean allowMouseExit = extension.canHandleMouseCursor();
if (allowMouseExit) {
return computeLocation(subjectArea, controlSize, ANCHOR_RIGHT);
}
}
return super.computeInformationControlLocation(subjectArea, controlSize);
}
use of org.eclipse.swt.events.MouseEvent in project eclipse.platform.text by eclipse.
the class AnnotationBarHoverManager method computeLocation.
@Override
protected Point computeLocation(Rectangle subjectArea, Point controlSize, Anchor anchor) {
MouseEvent event = getHoverEvent();
IAnnotationHover hover = getHover(event);
boolean allowMouseExit = false;
if (hover instanceof IAnnotationHoverExtension) {
IAnnotationHoverExtension extension = (IAnnotationHoverExtension) hover;
allowMouseExit = extension.canHandleMouseCursor();
}
boolean hideOnMouseWheel = true;
if (hover instanceof IAnnotationHoverExtension2) {
IAnnotationHoverExtension2 extension = (IAnnotationHoverExtension2) hover;
hideOnMouseWheel = !extension.canHandleMouseWheel();
}
fHideOnMouseWheel = hideOnMouseWheel;
if (allowMouseExit) {
fAllowMouseExit = true;
Control subjectControl = getSubjectControl();
// return a location that just overlaps the annotation on the bar
if (anchor == AbstractInformationControlManager.ANCHOR_RIGHT)
return subjectControl.toDisplay(subjectArea.x - 4, subjectArea.y - 2);
else if (anchor == AbstractInformationControlManager.ANCHOR_LEFT)
return subjectControl.toDisplay(subjectArea.x + subjectArea.width - controlSize.x + 4, subjectArea.y - 2);
}
fAllowMouseExit = false;
return super.computeLocation(subjectArea, controlSize, anchor);
}
use of org.eclipse.swt.events.MouseEvent in project eclipse.platform.text by eclipse.
the class ProjectionRulerColumn method createControl.
@Override
public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
Control control = super.createControl(parentRuler, parentControl);
// set background
Color background = getCachedTextViewer().getTextWidget().getBackground();
control.setBackground(background);
// install hover listener
control.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
if (clearCurrentAnnotation())
redraw();
}
});
// install mouse move listener
control.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
boolean redraw = false;
ProjectionAnnotation annotation = findAnnotation(toDocumentLineNumber(e.y), false);
if (annotation != fCurrentAnnotation) {
if (fCurrentAnnotation != null) {
fCurrentAnnotation.setRangeIndication(false);
redraw = true;
}
fCurrentAnnotation = annotation;
if (fCurrentAnnotation != null && !fCurrentAnnotation.isCollapsed()) {
fCurrentAnnotation.setRangeIndication(true);
redraw = true;
}
}
if (redraw)
redraw();
}
});
return control;
}
use of org.eclipse.swt.events.MouseEvent in project yamcs-studio by yamcs.
the class CreateAnnotationDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 20;
layout.marginWidth = 20;
layout.verticalSpacing = 2;
container.setLayout(layout);
Label lbl = new Label(container, SWT.NONE);
lbl.setText("Name");
Composite tagAndColorWrapper = new Composite(container, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
tagAndColorWrapper.setLayoutData(gd);
GridLayout gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
tagAndColorWrapper.setLayout(gl);
tag = new Text(tagAndColorWrapper, SWT.BORDER);
tag.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tag.setText(tagValue);
// Some ugly tricks to get a border around a label, which should have been a button in the first place
// but at least OSX doesn't support buttons with custom backgrounds. May be getting time to draw GC ourselves..
Composite labelBorder = new Composite(tagAndColorWrapper, SWT.BORDER);
labelBorder.setLayout(new FillLayout());
colorSelector = new Label(labelBorder, SWT.NONE);
colorSelector.setText(" ");
colorSelector.setCursor(handCursor);
colorSelector.setBackground(resourceManager.createColor(colorValue));
colorSelector.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
ColorDialog colorDialog = new ColorDialog(colorSelector.getShell());
colorDialog.setRGB(colorSelector.getBackground().getRGB());
RGB newColor = colorDialog.open();
if (newColor != null)
colorSelector.setBackground(resourceManager.createColor(newColor));
}
});
lbl = new Label(container, SWT.NONE);
lbl.setText("Description");
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
lbl.setLayoutData(gd);
description = new Text(container, SWT.MULTI | SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = description.getLineHeight() * 3;
description.setLayoutData(gd);
description.setText(descriptionValue);
Composite startLabelWrapper = new Composite(container, SWT.NONE);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
startLabelWrapper.setLayout(gl);
lbl = new Label(startLabelWrapper, SWT.NONE);
lbl.setText("Start");
startClosed = new Button(startLabelWrapper, SWT.CHECK | SWT.NONE);
startClosed.setSelection(true);
startClosed.addListener(SWT.Selection, e -> {
startDate.setVisible(startClosed.getSelection());
startTime.setVisible(startClosed.getSelection());
validate();
});
Composite startComposite = new Composite(container, SWT.NONE);
RowLayout rl = new RowLayout();
rl.marginLeft = 0;
rl.marginTop = 0;
rl.marginBottom = 0;
rl.center = true;
startComposite.setLayout(rl);
startDate = new DateTime(startComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
startDate.addListener(SWT.Selection, e -> validate());
startTime = new DateTime(startComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
startTime.addListener(SWT.Selection, e -> validate());
if (startTimeValue != null) {
startDate.setDate(startTimeValue.get(Calendar.YEAR), startTimeValue.get(Calendar.MONTH), startTimeValue.get(Calendar.DAY_OF_MONTH));
startTime.setTime(startTimeValue.get(Calendar.HOUR_OF_DAY), startTimeValue.get(Calendar.MINUTE), startTimeValue.get(Calendar.SECOND));
}
Composite stopLabelWrapper = new Composite(container, SWT.NONE);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
stopLabelWrapper.setLayout(gl);
lbl = new Label(stopLabelWrapper, SWT.NONE);
lbl.setText("Stop");
stopClosed = new Button(stopLabelWrapper, SWT.CHECK | SWT.NONE);
stopClosed.setSelection(true);
stopClosed.addListener(SWT.Selection, e -> {
stopDate.setVisible(stopClosed.getSelection());
stopTime.setVisible(stopClosed.getSelection());
validate();
});
Composite stopComposite = new Composite(container, SWT.NONE);
rl = new RowLayout();
rl.marginLeft = 0;
rl.marginTop = 0;
rl.marginBottom = 0;
rl.center = true;
rl.fill = true;
stopComposite.setLayout(rl);
stopDate = new DateTime(stopComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
stopDate.addListener(SWT.Selection, e -> validate());
stopTime = new DateTime(stopComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
stopTime.addListener(SWT.Selection, e -> validate());
if (stopTimeValue != null) {
stopDate.setDate(stopTimeValue.get(Calendar.YEAR), stopTimeValue.get(Calendar.MONTH), stopTimeValue.get(Calendar.DAY_OF_MONTH));
stopTime.setTime(stopTimeValue.get(Calendar.HOUR_OF_DAY), stopTimeValue.get(Calendar.MINUTE), stopTimeValue.get(Calendar.SECOND));
}
return container;
}
Aggregations