Search in sources :

Example 96 with MouseEvent

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) {
                }
            });
        }
    }
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Font(org.eclipse.swt.graphics.Font) Display(org.eclipse.swt.widgets.Display)

Example 97 with MouseEvent

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);
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent)

Example 98 with MouseEvent

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);
}
Also used : IInformationControl(org.eclipse.jface.text.IInformationControl) Control(org.eclipse.swt.widgets.Control) MouseEvent(org.eclipse.swt.events.MouseEvent)

Example 99 with MouseEvent

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;
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) Control(org.eclipse.swt.widgets.Control) MouseEvent(org.eclipse.swt.events.MouseEvent) Color(org.eclipse.swt.graphics.Color) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter)

Example 100 with MouseEvent

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;
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) RGB(org.eclipse.swt.graphics.RGB) DateTime(org.eclipse.swt.widgets.DateTime) GridLayout(org.eclipse.swt.layout.GridLayout) ColorDialog(org.eclipse.swt.widgets.ColorDialog) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData)

Aggregations

MouseEvent (org.eclipse.swt.events.MouseEvent)100 MouseAdapter (org.eclipse.swt.events.MouseAdapter)50 GridData (org.eclipse.swt.layout.GridData)37 MouseListener (org.eclipse.swt.events.MouseListener)32 SelectionEvent (org.eclipse.swt.events.SelectionEvent)32 Point (org.eclipse.swt.graphics.Point)32 KeyEvent (org.eclipse.swt.events.KeyEvent)27 Composite (org.eclipse.swt.widgets.Composite)26 GridLayout (org.eclipse.swt.layout.GridLayout)25 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20 Button (org.eclipse.swt.widgets.Button)20 FocusEvent (org.eclipse.swt.events.FocusEvent)18 PaintEvent (org.eclipse.swt.events.PaintEvent)18 Event (org.eclipse.swt.widgets.Event)15 Label (org.eclipse.swt.widgets.Label)15 Text (org.eclipse.swt.widgets.Text)14 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)13 PaintListener (org.eclipse.swt.events.PaintListener)13 KeyListener (org.eclipse.swt.events.KeyListener)12 ModifyEvent (org.eclipse.swt.events.ModifyEvent)12