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

The following examples show how to use org.eclipse.swt.widgets.Composite#getChildren() . 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: XLFEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 获取指定容器下的源文本框和目标文本框组件。第一个为源文本框,第二个为目标文本框。
 * @param parent
 *            每行的 txtComposite
 * @return ;
 */
private StyledText[] getTextWidgets(Composite parent) {
	StyledText[] sts = new StyledText[2];
	Control[] ctrls = parent.getChildren();
	for (Control ctrl : ctrls) {
		if (ctrl instanceof StyledText) {
			sts[0] = (StyledText) ctrl;
		}

		if (ctrl instanceof Composite) {
			Control[] children = ((Composite) ctrl).getChildren();
			for (Control child : children) {
				if (child instanceof StyledText) {
					sts[1] = (StyledText) child;

					return sts;
				}
			}
		}
	}

	return sts;
}
 
Example 2
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various
 * types of preferences. Each field editor knows how to save and restore itself.
 */
protected void createFieldEditors()
{
	appearanceComposite = getFieldEditorParent();
	createMarkOccurrenceOptions(appearanceComposite);
	createTextEditingOptions(appearanceComposite, Messages.CommonEditorPreferencePage_Text_Editing_Label);
	Composite group = AptanaPreferencePage.createGroup(appearanceComposite,
			Messages.CommonEditorPreferencePage_Folding);
	group.setLayout(GridLayoutFactory.swtDefaults().create());
	group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

	createFoldingOptions(group);

	Composite caGroup = AptanaPreferencePage.createGroup(appearanceComposite,
			Messages.CommonEditorPreferencePage_ContentAssist);
	caGroup.setLayout(GridLayoutFactory.swtDefaults().create());
	caGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

	Composite caOptions = createContentAssistOptions(caGroup);
	if (caOptions.getChildren().length == 1)
	{
		caGroup.getParent().setVisible(false);
	}
}
 
Example 3
Source File: SuffixText.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
	int width = 0;
	int height = 0;
	Point textDimension = textDimensions();
	Control[] children = composite.getChildren();
	for (Control child : children) {
		if (child instanceof Text) {
			final String textContent = ((Text) child).getText();
			textDimension = gc.textExtent(textContent);
			width += textDimension.x;
			height += textDimension.y;
		}
		if (child instanceof Label) {
			Point computedSize = child.computeSize(0, 0);
			width += computedSize.x;
		}
	}
	return new Point(width, height + 4);
}
 
Example 4
Source File: ControlEnableState.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Recursively reads the enable/disable state for the given window and disables all controls.
 * 
 * @param control
 *            Control
 */
@SuppressWarnings("unchecked")
private void readStateForAndDisable(Control control)
{
	if ((exceptions != null && exceptions.contains(control)))
	{
		return;
	}
	if (control instanceof Composite)
	{
		Composite c = (Composite) control;
		Control[] children = c.getChildren();
		for (int i = 0; i < children.length; i++)
		{
			readStateForAndDisable(children[i]);
		}
	}
	// XXX: Workaround for 1G2Q8SS: ITPUI:Linux - Combo box is not enabled
	// in "File->New->Solution"
	states.add(new ItemState(control, true));
	control.setEnabled(false);
}
 
Example 5
Source File: CompositeToHoldGranularUIElements.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
public void updateClaferContainer() {
	final Composite compositeContentOfThisScrolledComposite = (Composite) getContent();

	// first dispose all the granular UI elements (which includes the deleted one).
	for (final Control uiRepresentationOfClaferFeatures : compositeContentOfThisScrolledComposite.getChildren()) {
		uiRepresentationOfClaferFeatures.dispose();
	}

	// update the size values.
	setLowestWidgetYAxisValue(0);
	setMinHeight(getLowestWidgetYAxisValue());

	// add all the clafer features excluding the deleted one.
	for (final ClaferFeature featureUnderConsideration : this.claferModel) {
		addGranularClaferUIElements(featureUnderConsideration);
	}

	((Composite) getContent()).layout();
}
 
Example 6
Source File: SB_Transfers.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
private static void
collapseAll(
	Composite	comp )
{
		// don't like this but meh
	
	Object obj = comp.getData( "MyTorrentsView.instance" );
	
	if ( obj != null ){
		
		((MyTorrentsView)obj).collapseAll();
	}
	
	Control[] kids = comp.getChildren();
	
	for ( Control k: kids ){
		
		if ( k instanceof Composite ){
			
			collapseAll((Composite)k);
		}
	}
}
 
Example 7
Source File: SpinnerYear.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void layout( Composite composite, boolean changed )
{
	Control[] children = composite.getChildren( );
	children[0].setBounds( 44, 0, 16, 12 );
	children[1].setBounds( 44, 13, 16, 12 );
	children[2].setBounds( 0, 0, 46, 25 );
	children[3].setBounds( 44, 12, 17, 3 );
}
 
Example 8
Source File: SWTUtil.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
/** Sets the enable state of the composite's children, recursively. */
public static void recursiveSetEnabled(Composite composite, boolean enabled) {
	for(Control control : composite.getChildren() ) {
		if(control instanceof Composite) {
			recursiveSetEnabled((Composite) control, enabled);
		}
		control.setEnabled(enabled);
	}
}
 
Example 9
Source File: TimeSlice.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
protected Point computeSize(Composite composite, int wHint, int hHint,
		boolean flushCache) {
	if (preferredSize.x == -1 || flushCache) {
		preferredSize.x = wHint;
		preferredSize.y = -1; // NOTE: This assumes at least one child
								// control
		Control[] children = composite.getChildren();
		for (int i = 0; i < children.length; i++) {
			Control child = children[i];
			preferredSize.y = Math.max(preferredSize.y, child
					.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y);
		}
	}
	return preferredSize;
}
 
Example 10
Source File: TSWizardDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void layout(Composite composite, boolean force) {
	Rectangle rect = getClientArea(composite);
	Control[] children = composite.getChildren();
	for (int i = 0; i < children.length; i++) {
		children[i].setBounds(rect);
	}
}
 
Example 11
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 12
Source File: CalendarComposite.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
protected void layout(Composite composite, boolean flushCache) {
	int bheight = mSettings.getButtonHeight();
	int bwidth = mSettings.getButtonWidth();
	int vspacer = mSettings.getButtonVerticalSpace();
	int bspacer = mSettings.getButtonsHorizontalSpace();
	if (CalendarCombo.OS_CARBON) {
		bwidth = mSettings.getButtonWidthCarbon();
		bheight = mSettings.getCarbonButtonHeight();
		vspacer = mSettings.getCarbonButtonVerticalSpace();
		bspacer = mSettings.getCarbonButtonsHorizontalSpace();
	}

	// see how much space we put on the left and right sides of the
	// buttons
	int width = mSettings.getCalendarWidth() - (bwidth * 2) - bspacer;
	width /= 2;

	int button1Left = width;
	int button2Left = mSettings.getCalendarWidth() - width - bwidth;

	Control[] children = composite.getChildren();
	for (int i = 0; i < children.length; i++) {
		switch (i) {
		case 0:
			children[i].setBounds(button1Left, vspacer, bwidth, bheight);

			break;
		case 1:
			children[i].setBounds(button2Left, vspacer, bwidth, bheight);
			break;
		}

	}
}
 
Example 13
Source File: SliderEditor.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Composite createToolbar2() {
	final Composite t = super.createToolbar2();
	t.setBackground(getNormalBackground());
	for (final Control c : t.getChildren()) {
		c.setBackground(getNormalBackground());
	}
	return t;
}
 
Example 14
Source File: VControl.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
protected final static boolean containsControl(Control control, Composite composite) {
	if(composite != null && !composite.isDisposed()) {
		Control[] children = composite.getChildren();
		for(Control child : children) {
			if(!child.isDisposed()) {
				if(child == control) {
					return true;
				} else if(child instanceof Composite){
					return containsControl(control, (Composite) child);
				}
			}
		}
	}
	return false;
}
 
Example 15
Source File: SelectableControlList.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void updateBackground(Composite composite, Color background) {
  composite.setBackground(background);

  for (Control control : composite.getChildren()) {
    if (control instanceof Composite) {
      updateBackground((Composite) control, background);
    } else {
      control.setBackground(background);
    }
  }
}
 
Example 16
Source File: SWTUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Recursively sets enabled on this control and all of its descendants. This
 * is necessary on Windows, since just disabling the parent control will
 * result in the child controls appearing enabled, but not responding to any
 * user interaction.
 */
public static void setEnabledRecursive(Control control, boolean enabled) {
  control.setEnabled(enabled);
  if (control instanceof Composite) {
    Composite composite = (Composite) control;
    for (Control child : composite.getChildren()) {
      setEnabledRecursive(child, enabled);
    }
  }
}
 
Example 17
Source File: GridRowLayout.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
protected int computeMaxHeight(Composite rowOrHeader) {
    Control[] children = rowOrHeader.getChildren();
    int maxHeight = 0;
    for (int i = 0; i < children.length; i++) {
        int height = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT,
                false).y;
        if (maxHeight < height) {
            maxHeight = height;
        }
    }
    ++maxHeight;
    return maxHeight;
}
 
Example 18
Source File: CompositeUtil.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
public static Control findControl(Composite composite, Predicate<Control> predicate) {
  for (Control control : composite.getChildren()) {
    if (predicate.test(control)) {
      return control;
    } else if (control instanceof Composite) {
      Control result = findControl((Composite) control, predicate);
      if (result != null) {
        return result;
      }
    }
  }
  return null;
}
 
Example 19
Source File: ReportLayoutEditorFormPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void createPartControl( Composite parent )
{
	super.createPartControl( parent );
	Control[] children = parent.getChildren( );
	control = children[children.length - 1];
}
 
Example 20
Source File: GridRowLayout.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
protected Widget getColumnAt(Composite rowOrHeader, int offset) {
    return rowOrHeader.getChildren()[offset];
}