org.eclipse.swt.events.PaintListener Java Examples

The following examples show how to use org.eclipse.swt.events.PaintListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PingGraphic.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void initialize(Canvas canvas) {
	super.initialize(canvas);

	drawCanvas.addPaintListener(new PaintListener() {
	@Override
	public void paintControl(PaintEvent e) {
		if (bufferImage != null && !bufferImage.isDisposed()) {
			Rectangle bounds = bufferImage.getBounds();
			if (bounds.width >= ( e.width + e.x ) && bounds.height >= ( e.height + e.y )) {

				e.gc.drawImage(bufferImage, e.x, e.y, e.width, e.height, e.x, e.y,
						e.width, e.height);
			}
		}
	}
});

	drawCanvas.addListener(SWT.Resize, new Listener() {
	@Override
	public void handleEvent(Event event) {
		drawChart(true);
	}
});
}
 
Example #2
Source File: HeaderLayout.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
protected void layout(final Composite child, boolean flushCache) {
    storeHeader(child);
    
    int childWidth = child.getSize().x;
    int shellWidth = child.getShell().getSize().x;
    
    if (childWidth == lastChildWidth && shellWidth > lastShellWidth) return;
    
    if (childWidth > lastChildWidth) {
        final Table headerTable = getHeader(child).headerTable;
        headerTable.addPaintListener(new PaintListener() {
            public void paintControl(PaintEvent e) {
                headerTable.removePaintListener(this);
                layout(child);
            }
        });
    } else {
        layout(child);
    }
    lastChildWidth = childWidth;
    lastShellWidth = shellWidth;
}
 
Example #3
Source File: SWTStrokeCanvas.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
 
Example #4
Source File: MainSplash.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param display
 * @param monitor
 */
public MainSplash(Display display, Monitor monitor) {
    
    this.version = ARXAnonymizer.VERSION;
    this.splash = Resources.getSplash(display);
    this.shell = new Shell(SWT.ON_TOP | (isMac() ? 0 : SWT.NO_TRIM));
    this.shell.setImages(Resources.getIconSet(display));
    this.shell.setSize(splash.getBounds().width, splash.getBounds().height);
    
    // Center
    SWTUtil.center(shell, monitor);
    
    // Paint
    shell.addPaintListener(new PaintListener(){
        public void paintControl(PaintEvent arg0) {
            paint(arg0.gc);
        }
    });
}
 
Example #5
Source File: RichTextViewer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 
 * @param parent
 * @param style
 *            The style bits to use.
 * 
 * @see SWT#WRAP
 */
public RichTextViewer(Composite parent, int style) {
	super(parent, style | SWT.DOUBLE_BUFFERED);

	final boolean wordWrap = (getStyle() & SWT.WRAP) != 0;
	this.painter = new RichTextPainter(wordWrap);

	addPaintListener(new PaintListener() {

		@Override
		public void paintControl(PaintEvent e) {
			painter.paintHTML(htmlText != null ? htmlText : "", e.gc, getClientArea());
		}
	});

}
 
Example #6
Source File: GeoMap.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Removes listener from appropriate listener lists depending on the listener
 * interfaces that are implemented.
 * 
 * @param listener
 *            the listener
 */
public void removeMouseHandler(EventListener listener) {
	if (listener instanceof MouseListener) {
		removeMouseListener((MouseListener) listener);
	}
	if (listener instanceof MouseMoveListener) {
		removeMouseMoveListener((MouseMoveListener) listener);
	}
	if (listener instanceof MouseTrackListener) {
		removeMouseTrackListener((MouseTrackListener) listener);
	}
	if (listener instanceof MouseWheelListener) {
		removeMouseWheelListener((MouseWheelListener) listener);
	}
	if (listener instanceof PaintListener) {
		removePaintListener((PaintListener) listener);
	}
}
 
Example #7
Source File: SWTStrokeCanvas.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
 
Example #8
Source File: SpeedGraphic.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void initialize(Canvas canvas) {
	super.initialize(canvas);

	drawCanvas.addPaintListener(new PaintListener() {
	@Override
	public void paintControl(PaintEvent e) {
		if (bufferImage != null && !bufferImage.isDisposed()) {
			Rectangle bounds = bufferImage.getBounds();
			if (bounds.width >= ( e.width + e.x ) && bounds.height >= ( e.height + e.y )) {

				e.gc.drawImage(bufferImage, e.x, e.y, e.width, e.height, e.x, e.y,
						e.width, e.height);
			}
		}
	}
});

	drawCanvas.addListener(SWT.Resize, new Listener() {
	@Override
	public void handleEvent(Event event) {
		drawChart(true);
	}
});
}
 
Example #9
Source File: SWTBGImagePainter2.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
	Display display = Display.getDefault();
	Shell shell = new Shell(display, SWT.DIALOG_TRIM);
	shell.setLayout(new FillLayout());

	Composite c = new Composite(shell, SWT.BORDER);
	c.setLayout(new FillLayout());
	c.addPaintListener(new PaintListener() {
		@Override
		public void paintControl(PaintEvent e) {
			e.gc.drawLine(0, 0, 100, 50);
		}
	});

	Label lbl = new Label(c, SWT.NONE);
	lbl.setText("text");

	shell.open();

	while (!shell.isDisposed()) {
		if (display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
Example #10
Source File: GraphicalViewer.java    From eclipsegraphviz with Eclipse Public License 1.0 6 votes vote down vote up
public GraphicalViewer(Composite parent) {
    canvas = new Canvas(parent, SWT.NONE);
    parent.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            canvas.setBounds(canvas.getParent().getClientArea());
            requestImageRedraw();
        }
    });
    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            redrawImageIfRequested();
            GC gc = e.gc;
            paintCanvas(gc);
        }

    });
}
 
Example #11
Source File: SWTStrokeCanvas.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
 
Example #12
Source File: CustomSeparator.java    From http4e with Apache License 2.0 6 votes vote down vote up
public CustomSeparator( Composite parent, int style) {
   super(parent, style = checkStyle(style));

   this.style = style;

   if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0)
      lineSize = 2;
   else
      lineSize = 1;

   addPaintListener(new PaintListener() {
      public void paintControl( PaintEvent event){
         onPaint(event);
      }
   });
}
 
Example #13
Source File: SWTStrokeCanvas.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
 
Example #14
Source File: SWTStrokeCanvas.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 *
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice());
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
 
Example #15
Source File: HoverInfoWithSpellingAnnotation.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private void createAnnotationInformation(Composite parent, final Annotation annotation) {
    Composite composite= new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    GridLayout layout= new GridLayout(2, false);
    layout.marginHeight= 2;
    layout.marginWidth= 2;
    layout.horizontalSpacing= 0;
    composite.setLayout(layout);

    final Canvas canvas= new Canvas(composite, SWT.NO_FOCUS);
    GridData gridData= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
    gridData.widthHint= 17;
    gridData.heightHint= 16;
    canvas.setLayoutData(gridData);
    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            e.gc.setFont(null);
            fMarkerAnnotationAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
        }
    });

    StyledText text= new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
    GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
    text.setLayoutData(data);
    text.setText(annotation.getText());
}
 
Example #16
Source File: SWTStrokeCanvas.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
 
Example #17
Source File: SWTStrokeCanvas.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTStrokeCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            BasicStroke stroke = (BasicStroke) getStroke();
            if (stroke != null) {
                int x, y;
                Rectangle rect = getClientArea();
                x = (rect.width - 100) / 2;
                y = (rect.height - 16) / 2;
                Transform swtTransform = new Transform(e.gc.getDevice()); 
                e.gc.getTransform(swtTransform);
                swtTransform.translate(x, y);
                e.gc.setTransform(swtTransform);
                swtTransform.dispose();
                e.gc.setBackground(getDisplay().getSystemColor(
                        SWT.COLOR_BLACK));
                e.gc.setLineWidth((int) stroke.getLineWidth());
                e.gc.drawLine(10, 8, 90, 8);
            }
        }
    });
}
 
Example #18
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected void highlight(final Composite parent, final Label labelControl, final Combo comboBox, final int color) {
	Object data= labelControl.getData();
	if (data == null) {
		if (color != HIGHLIGHT_NONE) {
			PaintListener painter= new HighlightPainter(parent, labelControl, comboBox, color);
			parent.addPaintListener(painter);
			labelControl.setData(painter);
		} else {
			return;
		}
	} else {
		if (color == HIGHLIGHT_NONE) {
			parent.removePaintListener((PaintListener) data);
			labelControl.setData(null);
		} else if (color != ((HighlightPainter) data).fColor){
			((HighlightPainter) data).fColor= color;
		} else {
			return;
		}
	}
	
	parent.redraw();
}
 
Example #19
Source File: BaseMouseProvider.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Method to register the provider to chart viewer.
 */
protected void register() {
    IPlotArea plotArea = getChart().getPlotArea();
    Control control = plotArea.getControl();
    if (this instanceof MouseListener) {
        control.addMouseListener((MouseListener) this);
    }
    if (this instanceof MouseMoveListener) {
        control.addMouseMoveListener((MouseMoveListener) this);
    }
    if (this instanceof MouseWheelListener) {
        control.addMouseWheelListener((MouseWheelListener) this);
    }
    if (this instanceof MouseTrackListener) {
        control.addMouseTrackListener((MouseTrackListener) this);
    }
    if (this instanceof ICustomPaintListener) {
        plotArea.addCustomPaintListener((ICustomPaintListener) this);
    } else if (this instanceof PaintListener) {
        control.addPaintListener((PaintListener) this);
    }
    TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler();
    if(tooltipHandler != null) {
        tooltipHandler.activateHoverHelp(control);
    }
}
 
Example #20
Source File: CheckBoxCellEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * As soon as the editor is activated, flip the current data value and commit it.<br/>
 * The repaint will pick up the new value and flip the image.
 */
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
	setCanonicalValue(originalCanonicalValue);

	checked = !checked;

	canvas = new Canvas(parent, SWT.NONE);

	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent paintEvent) {
			Rectangle bounds = canvas.getBounds();
			Rectangle rect = new Rectangle(0, 0, bounds.width, bounds.height);
			checkBoxCellPainter.paintIconImage(paintEvent.gc, rect, bounds.height / 2 - checkBoxCellPainter.getPreferredHeight(checked) / 2, checked);
		}

	});

	canvas.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseUp(MouseEvent e) {
			checked = !checked;
			canvas.redraw();
		}

	});

	commit(MoveDirectionEnum.NONE, false);

	return canvas;
}
 
Example #21
Source File: IconCanvas.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * The constructor.
 * 
 * @param parent
 * @param style
 * 
 */
public IconCanvas( final Composite parent, int style )
{
	super( parent, style );

	addPaintListener( new PaintListener( ) {

		public void paintControl( final PaintEvent event )
		{
			paint( event.gc );
		}
	} );
}
 
Example #22
Source File: AbstractAnnotationHover.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
private void createAnnotationInformation(Composite parent, final Annotation annotation) {
	Composite composite= new Composite(parent, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
	GridLayout layout= new GridLayout(2, false);
	layout.marginHeight= 2;
	layout.marginWidth= 2;
	layout.horizontalSpacing= 0;
	composite.setLayout(layout);

	final Canvas canvas= new Canvas(composite, SWT.NO_FOCUS);
	GridData gridData= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
	gridData.widthHint= 17;
	gridData.heightHint= 16;
	canvas.setLayoutData(gridData);
	canvas.addPaintListener(new PaintListener() {
		@Override
		public void paintControl(PaintEvent e) {
			e.gc.setFont(null);
			fMarkerAnnotationAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
		}
	});

	StyledText text= new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
	GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
	text.setLayoutData(data);
	String annotationText= annotation.getText();
	if (annotationText != null)
		text.setText(annotationText);
}
 
Example #23
Source File: SWTPaintCanvas.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTPaintCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            e.gc.setForeground(e.gc.getDevice().getSystemColor(
                    SWT.COLOR_BLACK));
            e.gc.setBackground(SWTPaintCanvas.this.myColor);
            e.gc.fillRectangle(getClientArea());
            e.gc.drawRectangle(getClientArea().x, getClientArea().y, 
                    getClientArea().width - 1, getClientArea().height - 1);
        }
    });
}
 
Example #24
Source File: DecisionTableWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param parent
 * @param image
 * @return
 */
public Canvas createImageButton(final Composite parent, final Image image) {
    final Canvas deleteButton = new Canvas(parent, SWT.TRANSPARENT);
    deleteButton.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(final PaintEvent e) {
            e.gc.drawImage(image, 0, 0, 16, 16, 0, 0, DELETE_SIZE, DELETE_SIZE);
        }
    });
    return deleteButton;
}
 
Example #25
Source File: CheckBoxCellEditor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * As soon as the editor is activated, flip the current data value and commit it.<br/>
 * The repaint will pick up the new value and flip the image.
 */
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue, Character initialEditValue) {
	setCanonicalValue(originalCanonicalValue);

	checked = !checked;

	canvas = new Canvas(parent, SWT.NONE);

	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent paintEvent) {
			Rectangle bounds = canvas.getBounds();
			Rectangle rect = new Rectangle(0, 0, bounds.width, bounds.height);
			checkBoxCellPainter.paintIconImage(paintEvent.gc, rect, bounds.height / 2 - checkBoxCellPainter.getPreferredHeight(checked) / 2, checked);
		}

	});

	canvas.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseUp(MouseEvent e) {
			checked = !checked;
			canvas.redraw();
		}

	});

	commit(MoveDirectionEnum.NONE, false);

	return canvas;
}
 
Example #26
Source File: AbstractAnnotationHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void createAnnotationInformation(Composite parent, final Annotation annotation) {
	Composite composite= new Composite(parent, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
	GridLayout layout= new GridLayout(2, false);
	layout.marginHeight= 2;
	layout.marginWidth= 2;
	layout.horizontalSpacing= 0;
	composite.setLayout(layout);

	final Canvas canvas= new Canvas(composite, SWT.NO_FOCUS);
	GridData gridData= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
	gridData.widthHint= 17;
	gridData.heightHint= 16;
	canvas.setLayoutData(gridData);
	canvas.addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			e.gc.setFont(null);
			fMarkerAnnotationAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
		}
	});

	StyledText text= new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
	GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
	text.setLayoutData(data);
	String annotationText= annotation.getText();
	if (annotationText != null)
		text.setText(annotationText);
}
 
Example #27
Source File: StepIndicatorComposite.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public StepIndicatorComposite(Composite parent, String[] stepNames)
{
	super(parent, SWT.NONE);

	setBackground(normalColor);

	GridLayout layout = new GridLayout(1, false);
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	layout.horizontalSpacing = 0;
	layout.marginBottom = 1;

	setLayout(layout);
	setLayoutData(GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).create());

	if (stepNames != null)
	{
		createSteps(stepNames);
	}
	else
	{
		setVisible(false);
	}

	addPaintListener(new PaintListener()
	{

		public void paintControl(PaintEvent e)
		{
			GC gc = e.gc;
			gc.setForeground(borderColor);
			Composite stepComposite = (Composite) e.widget;
			Rectangle bounds = stepComposite.getClientArea();
			bounds.width--;
			bounds.height--;
			gc.drawRectangle(bounds);
		}
	});
}
 
Example #28
Source File: DiagramPartitioningBreadcrumbViewer.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected TreeViewer createDropDownTreeViewer(final Composite composite, TreePath paramPath,
		final IBreadcrumbDropDownSite site) {
	Diagram diagram = (Diagram) paramPath.getParentPath().getLastSegment();
	TreeViewer viewer = null;
	if (diagram != null)
		viewer = createDiagramViewer(composite, diagram);
	else
		viewer = createProjectStatechartViewer(composite, (Diagram) paramPath.getLastSegment());
	viewer.getControl().addPaintListener(new PaintListener() {
		public void paintControl(PaintEvent e) {
			getDropDownShell().pack(true);
		}
	});
	return viewer;
}
 
Example #29
Source File: BaseMouseProvider.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Method to deregister the provider from chart viewer.
 */
protected void deregister() {
    IPlotArea plotArea = getChart().getPlotArea();
    if (plotArea == null) {
        return;
    }
    Control control = plotArea.getControl();
    if (!control.isDisposed()) {
        if (this instanceof MouseListener) {
            control.removeMouseListener((MouseListener) this);
        }
        if (this instanceof MouseMoveListener) {
            control.removeMouseMoveListener((MouseMoveListener) this);
        }
        if (this instanceof MouseWheelListener) {
            control.removeMouseWheelListener((MouseWheelListener) this);
        }
        if (this instanceof MouseTrackListener) {
            control.removeMouseTrackListener((MouseTrackListener) this);
        }
        if (this instanceof ICustomPaintListener) {
            plotArea.removeCustomPaintListener((ICustomPaintListener) this);
        } else if (this instanceof PaintListener) {
            control.removePaintListener((PaintListener) this);
        }
        TmfAbstractToolTipHandler tooltipHandler = getTooltipHandler();
        if(tooltipHandler != null) {
            tooltipHandler.deactivateHoverHelp(control);
        }
    }
}
 
Example #30
Source File: SWTPaintCanvas.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new instance.
 * 
 * @param parent  the parent.
 * @param style  the style.
 */
public SWTPaintCanvas(Composite parent, int style) {
    super(parent, style);
    addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            e.gc.setForeground(e.gc.getDevice().getSystemColor(
                    SWT.COLOR_BLACK));
            e.gc.setBackground(SWTPaintCanvas.this.myColor);
            e.gc.fillRectangle(getClientArea());
            e.gc.drawRectangle(getClientArea().x, getClientArea().y, 
                    getClientArea().width - 1, getClientArea().height - 1);
        }
    });
}