Java Code Examples for org.eclipse.swt.widgets.Composite#addMouseListener()

The following examples show how to use org.eclipse.swt.widgets.Composite#addMouseListener() . 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: TitaniumUpdatePopup.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected Control createDialogArea(Composite parent)
{
	dialogArea = new Composite(parent, SWT.NONE);
	dialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	dialogArea.setLayout(layout);
	dialogArea.addMouseListener(clickListener);

	// The "click to update" label
	Label infoLabel = new Label(dialogArea, SWT.NONE);
	infoLabel.setText(MessageFormat.format(EplMessages.TitaniumUpdatePopup_update_detail,
			EclipseUtil.getStudioPrefix()));
	infoLabel.setLayoutData(new GridData(GridData.FILL_BOTH));
	infoLabel.addMouseListener(clickListener);

	return dialogArea;

}
 
Example 2
Source File: GenericInfoPopupDialog.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent)
{
	Composite main = new Composite(parent, SWT.NONE);
	main.setLayout(GridLayoutFactory.swtDefaults().create());
	main.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
	if (clickListener != null)
	{
		main.addMouseListener(clickListener);
	}

	Label infoLabel = new Label(main, SWT.WRAP);
	infoLabel.setText(message);
	infoLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
	if (clickListener != null)
	{
		infoLabel.addMouseListener(clickListener);
	}

	return main;
}
 
Example 3
Source File: AbstractPopup.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
public void open() {
  shell.setLayout(new FillLayout());
  shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
  shell.setBackground(backgroundColor);
  Composite top = new Group(shell, SWT.NONE);
  // Closes when clicking in some whitespace, but not enough.
  // TODO(konigsberg): close when clicking anywhere but whitespace.
  top.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseUp(MouseEvent e) {
      close();
    }
  });

  initializeLayout(top);

  Composite titleBar = new Composite(top, SWT.NONE);
  initializeLayout(titleBar);
  createTitleBar(titleBar);

  Composite popupArea = new Composite(top, SWT.NONE);
  initializeLayout(popupArea);
  createContents(popupArea);

  shell.pack();

  setPosition(shell);
  shell.setVisible(true);
  if (displayTimeMillis > 0) {
    display.timerExec(displayTimeMillis, new Runnable() {
      public void run() {
        close();
      }
    });
  }
}
 
Example 4
Source File: TmfRawEventViewer.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Create the text area and add listeners
 */
private void createTextArea(int style) {
    fScrolledComposite = new ScrolledComposite(this, style);
    fScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    fTextArea = new Composite(fScrolledComposite, SWT.NONE);
    fTextArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    fScrolledComposite.setContent(fTextArea);
    fScrolledComposite.setExpandHorizontal(true);
    fScrolledComposite.setExpandVertical(true);
    fScrolledComposite.setAlwaysShowScrollBars(true);
    fScrolledComposite.setMinSize(fTextArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    fScrolledComposite.addControlListener(this);

    GridLayout textAreaGridLayout = new GridLayout();
    textAreaGridLayout.marginHeight = 0;
    textAreaGridLayout.marginWidth = 0;
    fTextArea.setLayout(textAreaGridLayout);

    fStyledText = new StyledText(fTextArea, SWT.READ_ONLY);
    fStyledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    initializeFonts();
    initializeColors();
    PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(this);

    fStyledText.addCaretListener(this);
    fStyledText.addMouseMoveListener(this);
    fStyledText.addMouseTrackListener(this);
    fStyledText.addMouseWheelListener(this);
    /* disable mouse scroll of horizontal scroll bar */
    fStyledText.addListener(SWT.MouseWheel, event -> event.doit = false);
    fStyledText.addKeyListener(this);

    fTextArea.setBackground(fStyledText.getBackground());
    fTextArea.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            fTextArea.setFocus();
        }
    });
}
 
Example 5
Source File: SwtRendererImpl.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public final void setProperty( final String sProperty, final Object oValue )
{
	if ( sProperty.equals( IDeviceRenderer.UPDATE_NOTIFIER ) )
	{
		_iun = (IUpdateNotifier) oValue;
		iv.reset( );
		iv.setUpdateNotifier( _iun );

		cleanUpTriggers( );
		Object obj = _iun.peerInstance( );

		if ( obj instanceof Composite )
		{
			Composite jc = (Composite) obj;

			if ( _eh != null )
			{
				// We can't promise to remove all the old swtEventHandler
				// due to SWT limitation here, so be sure to just attach the
				// update_notifier only to one renderer.

				jc.removeMouseListener( _eh );
				jc.removeMouseMoveListener( _eh );
				jc.removeMouseTrackListener( _eh );
				jc.removeKeyListener( _eh );
				jc.removeFocusListener( _eh );

				_eh.dispose( );
			}

			_eh = new SwtEventHandler( iv, _lhmAllTriggers, _iun, getULocale( ) );
			
			jc.addMouseListener( _eh );
			jc.addMouseMoveListener( _eh );
			jc.addMouseTrackListener( _eh );
			jc.addKeyListener( _eh );
			jc.addFocusListener( _eh );
		}
	}
	else if ( sProperty.equals( IDeviceRenderer.GRAPHICS_CONTEXT ) )
	{
		_gc = (GC) oValue;

		if ( R31Enhance.isR31Available( ) )
		{
			Region rg = new Region( );
			_gc.getClipping( rg );

			R31Enhance.setAdvanced( _gc, true, rg );
			R31Enhance.setAntialias( _gc, SWT.ON );
			R31Enhance.setTextAntialias( _gc, SWT.ON );

			rg.dispose( );
		}
		_ids.setGraphicsContext(_gc );

		logger.log( ILogger.INFORMATION,
				Messages.getString( "SwtRendererImpl.info.graphics.context",//$NON-NLS-1$
						new Object[]{
								_gc.getClass( ).getName( ), _gc
						},
						getULocale( ) ) );
	}
	else if ( sProperty.equals( IDeviceRenderer.DPI_RESOLUTION ) )
	{
		getDisplayServer( ).setDpiResolution( ( (Integer) oValue ).intValue( ) );
	}
	else if ( sProperty.equals( IDeviceRenderer.EXPECTED_BOUNDS ) )
	{
		Bounds bo = (Bounds)oValue;
		int x = (int)Math.round( bo.getLeft( ) );
		int y = (int)Math.round( bo.getTop( ) );
		int width = (int)Math.round( bo.getWidth( ) );
		int height = (int)Math.round( bo.getHeight( ) );
		this._gc.setClipping( x, y, width, height );
	}
}