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

The following examples show how to use org.eclipse.swt.widgets.Control#getData() . These examples are extracted from open source projects. 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
private void obfuscatedImage(Composite c, Image image) {
	if (c == null || c.isDisposed() || !c.isVisible()) {
		return;
	}
	Control[] children = c.getChildren();
	for (Control childControl : children) {
		if (!childControl.isVisible()) {
			continue;
		}
		ObfuscateImage oi = (ObfuscateImage) childControl.getData("ObfuscateImage");
		if (oi != null) {
			oi.obfuscatedImage(image);
			continue;
		}
		if (childControl instanceof Composite) {
			obfuscatedImage((Composite) childControl, image);
		}
	}
}
 
Example 2
protected String[] getControlValue( Control control )
{
	if ( control instanceof Text )
	{
		return new String[]{
				( (Text) control ).getText( ),
				(String) control.getData( ExpressionButtonUtil.EXPR_TYPE )
		};
	}
	else if ( control instanceof Combo )
	{
		return new String[]{
				( (Combo) control ).getText( ),
				(String) control.getData( ExpressionButtonUtil.EXPR_TYPE )
		};
	}
	return null;
}
 
Example 3
Source Project: nebula   File: CTreeComboViewer.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/** 
 * @see org.eclipse.jface.viewers.AbstractTreeViewer#internalInitializeTree(org.eclipse.swt.widgets.Control)
 */
protected void internalInitializeTree(Control widget) {
	if (contentProviderIsLazy) {
		if (widget instanceof CTreeCombo && widget.getData() != null) {
			virtualLazyUpdateChildCount(widget, 0);
			return;
		}
	}
	super.internalInitializeTree(tree);
}
 
Example 4
Source Project: nebula   File: SWTGraphicUtil.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Enable all widgets of a control
 *
 * @param control control to enable/disable
 * @param enable <code>true</code> to enable, <code>false</code> to disable
 */
public static void enableAllChildrenWidgets(final Control control) {
	if (control instanceof Composite) {
		for (final Control c : ((Composite) control).getChildren()) {
			enableAllChildrenWidgets(c);
		}
	}
	boolean enable = true;
	final Boolean previousState = (Boolean) control.getData(SWTGraphicUtil.class.toString() + "_enableState");
	if (previousState != null) {
		enable = previousState;
	}
	control.setEnabled(enable);
}
 
Example 5
public static ExpressionButton getExpressionButton( Control control )
{
	Object button = control.getData( ExpressionButtonUtil.EXPR_BUTTON );
	if ( button instanceof ExpressionButton )
	{
		return ( (ExpressionButton) button );
	}
	return null;
}
 
Example 6
Source Project: nebula   File: PromptSupport.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <p>
 * Sets the prompt text on <code>control</code>
 * </p>
 *
 * @param promptText
 * @param textComponent
 * @exception IllegalArgumentException if the control is not a Text Box, a
 *                Combo Box, a StyledText or a CCombo
 */
public static void setPrompt(final String promptText, final Control control) {
	checkControl(control);

	final boolean alreadySet = control.getData(SET) == null ? false : (Boolean) control.getData(SET);
	if (alreadySet) {
		throw new IllegalArgumentException("A prompt has already been set on this control !");
	}
	control.setData(PROMPT, promptText);

	final BaseFocusControlListener focusControlListener = FocusControlListenerFactory.getFocusControlListenerFor(control);
	control.addFocusListener(focusControlListener);
	control.addControlListener(focusControlListener);
	control.setData(SET, true);
}
 
Example 7
Source Project: BiglyBT   File: BaseMDI.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static BaseMdiEntry getEntryFromSkinObject(PluginUISWTSkinObject pluginSkinObject) {
	if (pluginSkinObject instanceof SWTSkinObject) {
		Control control = ((SWTSkinObject) pluginSkinObject).getControl();
		while (control != null && !control.isDisposed()) {
			Object entry = control.getData("BaseMDIEntry");
			if (entry instanceof BaseMdiEntry) {
				BaseMdiEntry mdiEntry = (BaseMdiEntry) entry;
				return mdiEntry;
			}
			control = control.getParent();
		}
	}
	return null;
}
 
Example 8
public static void
removeCopyToClipMenu(
Control		control )
{
 MouseAdapter ml = (MouseAdapter)control.getData( MOUSE_LISTENER_KEY );
 
 if ( ml != null ){
 
  control.removeMouseListener( ml );
 }
}
 
Example 9
protected DropTarget findDropTarget(Control control) {
	Object object = control.getData(DND.DROP_TARGET_KEY);
	if (object instanceof DropTarget) {
		return (DropTarget) object;
	}
	return null;
}
 
Example 10
public static IWorkbenchPartSite findSite(Control c) {
	while (c != null && !c.isDisposed()) {
		Object data= c.getData();
		if (data instanceof IWorkbenchPart)
			return ((IWorkbenchPart)data).getSite();
		c= c.getParent();
	}
	return null;
}
 
Example 11
private static ExpressionButton getExpressionButton( Control control )
{
	Object button = control.getData( ExpressionButtonUtil.EXPR_BUTTON );
	if ( button instanceof ExpressionButton )
	{
		return ( (ExpressionButton) button );
	}
	return null;
}
 
Example 12
Source Project: birt   File: AccordionControl.java    License: Eclipse Public License 1.0 4 votes vote down vote up
/** Returns the header object for the given header label */
private Object getHeader( Control label )
{
	return label.getData( KEY_HEADER );
}
 
Example 13
public static BrowserWrapper
create(
	Composite		composite,
	int				style )
{
	try{
		Map<String,Object> properties = new HashMap<>();
				
		for ( BrowserProvider provider: providers ){
			
			try{
				BrowserWrapper browser = provider.create( composite, style, properties);
				
				if ( browser != null ){
					
					return( browser );
				}
				
			}catch( Throwable e ){
				
				Debug.out( e );
			}
			
			Utils.disposeComposite( composite, false );
		}
		
		return( new BrowserWrapperSWT( composite, style ));

	}catch( SWTError error ){
		Control[] children = composite.getChildren();
		for (Control child : children) {
			if ( child.getData( BROWSER_KEY ) != null ){
				try {
					child.dispose();
				} catch (Throwable t) {

				}
			}
		}

		return( new BrowserWrapperFake( composite, style, error ));
	}
}
 
Example 14
public static void
 addCopyToClipMenu(
final Control				control,
final copyToClipProvider	provider )
 {
  MouseAdapter ml = (MouseAdapter)control.getData( MOUSE_LISTENER_KEY );
  
  if ( ml != null ){
  
	  control.removeMouseListener( ml );
  }
  
  ml =
	  new MouseAdapter()
	  {
		  @Override
		  public void
		  mouseDown(
			 MouseEvent e )
		  {
			  if ( control.isDisposed()){

				  return;
			  }

			  final String	text = provider.getText();

			  if ( control.getMenu() != null || text == null || text.length() == 0 ){

				  return;
			  }

			  if (!(e.button == 3 || (e.button == 1 && e.stateMask == SWT.CONTROL))){

				  return;
			  }

			  final Menu menu = new Menu(control.getShell(),SWT.POP_UP);

			  MenuItem   item = new MenuItem( menu,SWT.NONE );

			  item.setData( MENU_ITEM_KEY, "" );

			  String	msg_text_id;

			  if ( provider instanceof copyToClipProvider2 ){

				  msg_text_id = ((copyToClipProvider2)provider).getMenuResource();

			  }else{

				  msg_text_id = "label.copy.to.clipboard";
			  }

			  item.setText( MessageText.getString( msg_text_id ));

			  item.addSelectionListener(
					  new SelectionAdapter()
					  {
						  @Override
						  public void
						  widgetSelected(
								  SelectionEvent arg0)
						  {
							  new Clipboard(control.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
						  }
					  });

			  control.setMenu( menu );

			  menu.addMenuListener(
					  new MenuAdapter()
					  {
						  @Override
						  public void
						  menuHidden(
								  MenuEvent arg0 )
						  {
							  if ( control.getMenu() == menu ){

								  control.setMenu( null );
							  }
						  }
					  });

			  menu.setVisible( true );
		  }
	  };
  
  control.setData( MOUSE_LISTENER_KEY, ml );
  
  control.addMouseListener( ml );
 }
 
Example 15
Source Project: birt   File: AccordionControl.java    License: Eclipse Public License 1.0 4 votes vote down vote up
/** Returns the content area for the given header label */
private ScrolledComposite getContentArea( Control label )
{
	return (ScrolledComposite) label.getData( KEY_CONTENT );
}
 
Example 16
Source Project: birt   File: TaskSelectType.java    License: Eclipse Public License 1.0 4 votes vote down vote up
private String getSubtypeFromButton( Control button )
{
	return (String) button.getData( );
}
 
Example 17
Source Project: nebula   File: PromptSupport.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Get the {@link FocusBehavior} of <code>control</code>.
 *
 * @param control
 * @return the {@link FocusBehavior} or {@link FocusBehavior#HIDE_PROMPT} if
 *         none is set
 */
public static FocusBehavior getFocusBehavior(final Control control) {
	final FocusBehavior temp = (FocusBehavior) control.getData(BEHAVIOR);
	return temp == null ? FocusBehavior.HIDE_PROMPT : temp;

}
 
Example 18
Source Project: nebula   File: PromptSupport.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the font style of the prompt text, which is a OR mix of
 * SWT.ITALIC, SWT.NONE or SWT.BOLD
 *
 * @param control
 * @return font style of the prompt text
 */
public static int getFontStyle(final Control control) {
	final Integer temp = (Integer) control.getData(STYLE);
	return temp == null ? SWT.ITALIC : temp;

}
 
Example 19
Source Project: nebula   File: PromptSupport.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Get the foreground color of the prompt text. If no color has been set,
 * the <code>GREY</code> color will be returned.
 *
 * @param color
 * @return the color of the prompt text or <code>GREY</code>if none is set
 */
public static Color getForeground(final Control control) {
	final Color temp = (Color) control.getData(FOREGROUND);
	return temp == null ? control.getForeground() : temp;

}
 
Example 20
Source Project: nebula   File: PromptSupport.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Get the prompt text of <code>control</code>.
 *
 * @param control
 * @return the prompt text
 */
public static String getPrompt(final Control control) {
	return (String) control.getData(PROMPT);
}