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

The following examples show how to use org.eclipse.swt.widgets.Composite#setEnabled() . 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: MSyncWizardOverviewPage.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
  public void createControl(Composite parent) {
  	
      container = new Composite(parent, SWT.NONE);
      GridLayout layout = new GridLayout();
      container.setLayout(layout);
      // required to avoid an error in the system
      setControl(container);
      
      treeViewer = new TreeViewer(container, SWT.BORDER);
      treeViewer.setContentProvider(new TreeContentProvider());
      treeViewer.setLabelProvider(new MendeleyTreeLabelProvider());
      
      Tree tree = treeViewer.getTree();
      tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
      
      container.setEnabled(true);
      treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
	
	@Override
	public void selectionChanged(SelectionChangedEvent event) {
		treeViewer.getTree().deselect(treeViewer.getTree().getSelection()[0]);
	}
});
      
  }
 
Example 2
Source File: TaskFormatChart.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void createSubtaskArea( Composite parent, ISubtaskSheet subtask )
{
	if ( getNavigatorTree( ).getSelection( ).length > 0 )
	{
		lblNodeTitle.setText( getNavigatorTree( ).getSelection( )[0].getText( ) );
	}
	super.createSubtaskArea( parent, subtask );

	// If the subtask is registered as disabled state, disable it.
	boolean bEnabled = ( (ChartWizardContext) getContext( ) ).isEnabled( subtask.getNodePath( ) );
	if ( !bEnabled )
	{
		disableControl( parent );
	}
	parent.setEnabled( bEnabled );
	lblNodeTitle.setEnabled( bEnabled );
}
 
Example 3
Source File: JsonInputDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void setCompositeEnabled( Composite comp, boolean enabled ) {
  // TODO: move to TableView?
  comp.setEnabled( enabled );
  for ( Control child : comp.getChildren() ) {
    child.setEnabled( enabled );
  }
}
 
Example 4
Source File: ServiceMetadataCustomPropertiesTable.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
private static void nestedSetEnabled(Composite control, boolean enabled) {
    control.setEnabled(enabled);
    for (Control childControl : control.getChildren()) {
        if (childControl instanceof Composite) {
            nestedSetEnabled((Composite) childControl, enabled);
        } else {
            childControl.setEnabled(enabled);
        }
    }
}
 
Example 5
Source File: JDBCSelectionPageHelper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Enable the specific composite
 */
private void enableParent( Control control )
{
	Composite parent = control.getParent( );
	if ( parent == null || parent instanceof Shell )
	{
		return;
	}
	if ( !parent.isEnabled( ) )
	{
		parent.setEnabled( true );
	}
	enableParent( parent );
}
 
Example 6
Source File: HiveSelectionPageHelper.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Enable the specified composite.
 */
private void enableParent( Control control )
{
    Composite parent = control.getParent( );
    if ( parent == null || parent instanceof Shell )
    {
        return;
    }
    if ( !parent.isEnabled( ) )
    {
        parent.setEnabled( true );
    }
    enableParent( parent );
}
 
Example 7
Source File: DataSetParametersPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void enableComposite( Composite composite, boolean enable )
{
	if ( composite.isEnabled( ) != enable )
	{
		composite.setEnabled( enable );
		Control[] controls = composite.getChildren( );
		for ( int i = 0; i < controls.length; i++ )
		{
			controls[i].setEnabled( enable );
		}
	}
}
 
Example 8
Source File: GroupDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void disableControl( Composite container )
{
	Control[] children = container.getChildren( );
	for ( int i = 0; i < children.length; i++ )
	{
		if ( children[i] instanceof Composite )
			disableControl( (Composite) children[i] );
		else if ( !( children[i] instanceof Label ) )
			children[i].setEnabled( false );
	}
	container.setEnabled( false );
}
 
Example 9
Source File: SWTUtil.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * En-/disables the composite and its children.
 *
 * @param elem
 * @param val
 */
private static void setEnabled(final Composite elem, final boolean val) {
    elem.setEnabled(val);
    for (final Control c : elem.getChildren()) {
        if (c instanceof Composite) {
            setEnabled((Composite) c, val);
        } else {
            c.setEnabled(val);
        }
    }
}
 
Example 10
Source File: DragButtonMouseEvents.java    From codeexamples-eclipse with Eclipse Public License 1.0 4 votes vote down vote up
public static void main(String[] args) {
  Display display = new Display();
  final Shell shell = new Shell(display);
  final Composite composite = new Composite(shell, SWT.NONE);
  composite.setEnabled(false);
  composite.setLayout(new FillLayout());
  Button button = new Button(composite, SWT.PUSH);
  button.setText("Button");
  composite.pack();
  composite.setLocation(10, 10);
  final Point[] offset = new Point[1];
  Listener listener = new Listener() {
    public void handleEvent(Event event) {
      switch (event.type) {
      case SWT.MouseDown:
        Rectangle rect = composite.getBounds();
        if (rect.contains(event.x, event.y)) {
          Point pt1 = composite.toDisplay(0, 0);
          Point pt2 = shell.toDisplay(event.x, event.y);
          offset[0] = new Point(pt2.x - pt1.x, pt2.y - pt1.y);
        }
        break;
      case SWT.MouseMove:
        if (offset[0] != null) {
          Point pt = offset[0];
          composite.setLocation(event.x - pt.x, event.y - pt.y);
        }
        break;
      case SWT.MouseUp:
        offset[0] = null;
        break;
      }
    }
  };
  shell.addListener(SWT.MouseDown, listener);
  shell.addListener(SWT.MouseUp, listener);
  shell.addListener(SWT.MouseMove, listener);
  shell.setSize(300, 300);
  shell.open();
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch())
      display.sleep();
  }
  display.dispose();
}
 
Example 11
Source File: JsonInputDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void setCompositeEnabled( Composite comp, boolean enabled ) {
  comp.setEnabled( enabled );
  for ( Control child : comp.getChildren() ) {
    child.setEnabled( enabled );
  }
}