Java Code Examples for org.eclipse.swt.widgets.Control#addListener()

The following examples show how to use org.eclipse.swt.widgets.Control#addListener() . 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: PipelineRunConfigurationDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void addGuiCompositeWidgets() {

    // Remove existing children
    //
    for ( Control child : wPluginSpecificComp.getChildren() ) {
      child.removeListener( SWT.DefaultSelection, okListener );
      child.dispose();
    }

    if ( workingConfiguration.getEngineRunConfiguration() != null ) {
      guiCompositeWidgets = new GuiCompositeWidgets( runConfiguration, 25 );
      guiCompositeWidgets.createCompositeWidgets( workingConfiguration.getEngineRunConfiguration(), null, wPluginSpecificComp, PipelineRunConfiguration.GUI_PLUGIN_ELEMENT_PARENT_ID, null );
      for ( Control control : guiCompositeWidgets.getWidgetsMap().values() ) {
        control.addListener( SWT.DefaultSelection, okListener );
      }
    }
  }
 
Example 2
Source File: WorkflowRunConfigurationDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void addGuiCompositeWidgets() {

    // Remove existing children
    //
    for ( Control child : wPluginSpecificComp.getChildren() ) {
      child.removeListener( SWT.DefaultSelection, okListener );
      child.dispose();
    }

    if ( workingConfiguration.getEngineRunConfiguration() != null ) {
      guiCompositeWidgets = new GuiCompositeWidgets( runConfiguration, 8 );
      guiCompositeWidgets.createCompositeWidgets( workingConfiguration.getEngineRunConfiguration(), null, wPluginSpecificComp, WorkflowRunConfiguration.GUI_PLUGIN_ELEMENT_PARENT_ID, null );
      for ( Control control : guiCompositeWidgets.getWidgetsMap().values() ) {
        control.addListener( SWT.DefaultSelection, okListener );
      }
    }
  }
 
Example 3
Source File: GridToolTip.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
   * Creates an inplace tooltip.
   *
   * @param parent parent control.
   */
  public GridToolTip(final Control parent)
  {
      super(parent, SWT.NONE);

      shell = new Shell(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
      shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
      shell.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));

      parent.addListener(SWT.Dispose, new Listener()
      {
	public void handleEvent(Event arg0)
	{
		shell.dispose();
		dispose();
	}
});

      shell.addListener(SWT.Paint, new Listener()
      {
          public void handleEvent(Event e)
          {
              onPaint(e.gc);
          }
      });
  }
 
Example 4
Source File: CTreeCell.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
	 * @param eventType
	 * @param handler
	 */
	public void addListener(int eventType, Listener handler) {
		if(ehandler.add(eventType, handler)) {
			List controls = getEventManagedControls();
			for(Iterator iter = controls.iterator(); iter.hasNext(); ) {
				Control control = (Control) iter.next();
				control.addListener(eventType, l);
			}

//			if((getStyle() & SWT.DROP_DOWN) != 0 && childArea == null) {
//			DeferredListener dl = new DeferredListener(eventType, handler);
//			boolean contains = false;
//			for(Iterator i = dlisteners.iterator(); i.hasNext(); ) {
//			if(dl.equals(i.next())) {
//			contains = true;
//			break;
//			}
//			}
//			if(!contains) dlisteners.add(dl);
//			}
		}			
	}
 
Example 5
Source File: SWTTabItem.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void addChild(UIControl control) {
	Control handle = ((SWTControl<? extends Control>) control).getControl();
	
	this.control = control;
	this.item.setControl(handle);
	
	handle.addListener(SWT.Resize, new Listener() {
		public void handleEvent(Event event) {
			onResize();
		}
	});
	handle.getDisplay().asyncExec(new Runnable() {
		public void run() {
			onResize();
		}
	});
}
 
Example 6
Source File: GridToolTip.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
   * Creates an inplace tooltip.
   *
   * @param parent parent control.
   */
  public GridToolTip(final Control parent)
  {
      super(parent, SWT.NONE);

      shell = new Shell(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
      shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
      shell.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));

      parent.addListener(SWT.Dispose, new Listener()
      {
	public void handleEvent(Event arg0)
	{
		shell.dispose();
		dispose();
	}
});

      shell.addListener(SWT.Paint, new Listener()
      {
          public void handleEvent(Event e)
          {
              onPaint(e.gc);
          }
      });
  }
 
Example 7
Source File: GridToolTip.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
   * Creates an inplace tooltip.
   *
   * @param parent parent control.
   */
  public GridToolTip(final Control parent)
  {
      super(parent, SWT.NONE);

      shell = new Shell(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
      shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
      shell.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));

      parent.addListener(SWT.Dispose, new Listener()
      {
	public void handleEvent(Event arg0)
	{
		shell.dispose();
		dispose();
	}
});

      shell.addListener(SWT.Paint, new Listener()
      {
          public void handleEvent(Event e)
          {
              onPaint(e.gc);
          }
      });
  }
 
Example 8
Source File: GuiCompositeWidgets.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * If a widget changes
 * @param control
 */
private void addModifyListener( final Control control ) {
  if ( compositeWidgetsListener !=null) {
    if (control instanceof Button) {
      control.addListener( SWT.Selection, e -> compositeWidgetsListener.widgetModified( this, control ));
    } else {
      control.addListener( SWT.Modify, e -> compositeWidgetsListener.widgetModified( this, control ) );
    }
  }
}
 
Example 9
Source File: TableComboPropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void applyFont(final Control widget, final FontData fd) {
	if (widget.getFont() != null && !widget.getFont().equals(widget.getDisplay().getSystemFont())) {
		widget.getFont().dispose();
	}
	final Font newFont = new Font(widget.getDisplay(), fd);
	widget.setFont(newFont);
	widget.addListener(SWT.Dispose, e -> {
		if (newFont != null && !newFont.isDisposed()) {
			newFont.dispose();
		}
	});

}
 
Example 10
Source File: CDateTimePropertyHandler.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void applyFont(final Control widget, final FontData fd) {
	if (widget.getFont() != null && !widget.getFont().equals(widget.getDisplay().getSystemFont())) {
		widget.getFont().dispose();
	}
	final Font newFont = new Font(widget.getDisplay(), fd);
	widget.setFont(newFont);
	widget.addListener(SWT.Dispose, e -> {
		if (newFont != null && !newFont.isDisposed()) {
			newFont.dispose();
		}
	});
}
 
Example 11
Source File: ChartExpressionButton.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public ChartExpressionButton( Composite parent, Control control,
		ExtendedItemHandle eih, IExpressionProvider ep,
		ChartExpressionHelper eHelper )
{
	this.eHelper = eHelper;
	exprCodec = ChartModelHelper.instance( ).createExpressionCodec( );
	eb = ExpressionButtonUtil.createExpressionButton( parent,
			control,
			ep,
			eih,
			new Listener( ) {

				public void handleEvent( Event event )
				{
					onChange( );
				}
			},
			false,
			SWT.PUSH,
			eHelper );
	ExpressionButtonUtil.initExpressionButtonControl( control,
			(Expression) null );
	eHelper.initialize( );

	ControlListener controlListener = new ControlListener( );
	control.addListener( SWT.FocusOut, controlListener );
	control.addListener( SWT.Selection, controlListener );
	control.addListener( SWT.KeyDown, controlListener );
}
 
Example 12
Source File: AutoCompleteTextCellEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createControl(Composite parent) {
    final Control control = super.createControl(parent);
    Stream.of(control.getListeners(SWT.FocusIn)).forEach(l -> control.removeListener(SWT.FocusIn, l));
    Stream.of(control.getListeners(SWT.FocusOut)).forEach(l -> control.removeListener(SWT.FocusOut, l));
    control.addListener(SWT.Modify, e -> fireControlSpaceEvent());
    return control;
}
 
Example 13
Source File: XViewerEditAdapter.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
boolean handleEditEvent(Event event) {
   if (klickedColumn == null || klickedCell == null) {
      return false;
   }

   final Control c;
   try {
      XViewerColumn xColumn =
         xv.getXViewerFactory().getDefaultXViewerColumn(((XViewerColumn) klickedColumn.getData()).getId());
      if (xColumn instanceof ExtendedViewerColumn) {
         ExtendedViewerColumn extendedColumn = (ExtendedViewerColumn) xColumn;
         CellEditDescriptor ced = extendedColumn.getCellEditDescriptorMap().get(klickedCell.getElement().getClass());
         if (ced != null) {
            if (ced.getControl() == null) {
               return false;
            }
            if (ced.getAction() != null && !ced.getAction().isEnabled()) {
               return false;
            }
            if (!converter.isValid(ced, klickedCell.getElement())) {
               return false;
            }
            c = factory.createControl(ced, xv);
            if (c == null) {
               return false;
            }
         } else {
            return false;
         }
      } else {
         return false;
      }

      if (((TreeItem) event.item) != null) {
         Listener myListener = e-> {
               switch (e.type) {
                  case SWT.FocusOut:
                     // set new value
                     getInput(c);
                     c.dispose();
                     break;
                  case SWT.Verify:
                     c.setBounds(klickedCell.getBounds());
                     break;
                  case SWT.Traverse:
                     boolean neighbor = false;
                     switch (e.detail) {
                        case SWT.TRAVERSE_RETURN:
                           // set new value
                           getInput(c);
                           //$FALL-THROUGH$
                        case SWT.TRAVERSE_ESCAPE:
                           c.dispose();
                           e.doit = false;
                           break;
                        case SWT.TRAVERSE_TAB_NEXT:
                           getInput(c);
                           neighbor = getNeighbor(ViewerCell.RIGHT, true);
                           e.doit = false;
                           c.dispose();
                           Event eN = new Event();
                           eN.type = SWT.Selection;
                           eN.widget = xv.getTree();
                           if (neighbor) {
                              eN.item = klickedCell.getItem();
                           }
                           doHandleEvent(eN);
                           break;
                        case SWT.TRAVERSE_TAB_PREVIOUS:
                           getInput(c);
                           neighbor = getNeighbor(ViewerCell.LEFT, true);
                           e.doit = false;
                           c.dispose();
                           Event eP = new Event();
                           eP.type = SWT.Selection;
                           eP.widget = xv.getTree();
                           if (neighbor) {
                              eP.item = klickedCell.getItem();
                           }
                           doHandleEvent(eP);
                           break;
                     }
               }
         };
         c.addListener(SWT.FocusOut, myListener);
         c.addListener(SWT.Traverse, myListener);
         c.addListener(SWT.Verify, myListener);
         // set old value
         setInput(c);
         c.setFocus();
         return true;
      }
   } catch (Exception ex) {
      return false;
   }
   return false;
}
 
Example 14
Source File: JobStepDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void addListener( Control el, int event, TypedListener listener ) {
  if ( ArrayUtils.contains( el.getListeners( event ), listener ) ) {
    return;
  }
  el.addListener( event, listener );
}