org.eclipse.ui.forms.widgets.SharedScrolledComposite Java Examples

The following examples show how to use org.eclipse.ui.forms.widgets.SharedScrolledComposite. 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: DeployPropertyPageTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorrectPanelIsShownForFacetedProject() {
  DeployPropertyPage page = new DeployPropertyPage(loginService, googleApiFactory);
  Shell parent = shellTestResource.getShell();
  page.setElement(getProject());
  page.createControl(parent);
  page.setVisible(true);
  Composite preferencePageComposite = (Composite) parent.getChildren()[0];
  for (Control control : preferencePageComposite.getChildren()) {
    if (control instanceof SharedScrolledComposite) {
      assertThat(getDeployPreferencesPanel((Composite) control), instanceOf(getPanelClass()));
      return;
    }
  }
  fail("Did not find the deploy preferences panel");
}
 
Example #2
Source File: DeployPropertyPage.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
protected Control createContents(Composite parent) {
  container = new SharedScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL) {};
  container.setExpandHorizontal(true);
  container.setExpandVertical(true);
  container.setLayout(new GridLayout());

  IProject project = AdapterUtil.adapt(getElement(), IProject.class);

  try {
    facetedProject = ProjectFacetsManager.create(project);
  } catch (CoreException ex) {
    logger.log(Level.WARNING, ex.getMessage());
    return container;
  }

  GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
  evaluateFacetConfiguration();
  return container;
}
 
Example #3
Source File: SWTFactory.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Creates a scrolled composite 
 * 
 * @param parent the parent to add to
 * @param columns the number of columns for the composite
 * @param hspan the horizontal span to take up in the parent
 * @param marginwidth the width of the margins
 * @param marginheight the height of the margins
 * @return a new scrolled composite
 */
public static SharedScrolledComposite createScrolledComposite(Composite parent, int columns, int hspan, int marginwidth, int marginheight) {
	SharedScrolledComposite comp = new SharedScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL) {};
	GridLayout layout = new GridLayout(columns, false);
	layout.marginHeight = marginheight;
	layout.marginWidth = marginwidth;
	comp.setLayout(layout);
	GridData gd = new GridData(GridData.FILL_BOTH);
	gd.horizontalSpan = hspan;
	comp.setLayoutData(gd);
	comp.setExpandHorizontal(true);
	comp.setExpandVertical(true);
	return comp;
}
 
Example #4
Source File: ScrollClientComposite.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * The default constructor. Creates a {@link ScrollClientComposite}
 * constructor. The parent and style are passed to the {@link Composite}
 * constructor. The {@link #minWidth} is set to its default value. The
 * closest scrolled ancestor is determined automatically, but an
 * {@code IllegalArgumentException} is thrown if one cannot be found.
 * 
 * @param parent
 *            A widget which will be the parent of the new instance (cannot
 *            be null).
 * @param style
 *            The style of widget to construct.
 */
public ScrollClientComposite(Composite parent, int style) {
	super(parent, style);

	// Find the ancestor ScrolledComposite.
	while (parent != null && !(parent instanceof SharedScrolledComposite)) {
		parent = parent.getParent();
	}

	// If a ScrolledComposite was found, then set the class reference to it.
	// Otherwise throw an exception.
	if (parent != null) {
		scrolledAncestor = (SharedScrolledComposite) parent;
	} else {
		scrolledAncestor = null;
		throw new IllegalArgumentException("HorizontalScrollManager error: "
				+ "Client Control does not have a ScrolledComposite ancestor.");
	}

	// We need to add a resize listener to reflow the ancestor
	// ScrolledComposite when it's client area is too small.
	createResizeListener();

	// We must ensure the padding is correct for resizing.
	recomputePads();

	return;
}
 
Example #5
Source File: ScrollClientComposite.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a {@link ScrollClientComposite}. The parent and style are passed
 * to the {@link Composite} constructor. The ancestor is verified, and the
 * {@link #minWidth} is set to its default value.
 * 
 * @param parent
 *            A widget which will be the parent of the new instance (cannot
 *            be null).
 * @param style
 *            The style of widget to construct.
 * @param scrolledAncestor
 *            The ancestor scrolled {@code Composite}. Must be a non-null
 *            ancestor (parent, grandparent, etc.), else an
 *            {@code IllegalArgumentException} will be thrown.
 */
public ScrollClientComposite(Composite parent, int style,
		SharedScrolledComposite scrolledAncestor) {
	super(parent, style);

	// Check the scrolledAncestor parameter for null.
	if (scrolledAncestor == null) {
		this.scrolledAncestor = null;
		throw new IllegalArgumentException("HorizontalScrollManager error: "
				+ "Null ancestor ScrolledComposite passed to constructor!");
	}

	// Find the scrolledAncestor among this Composite's ancestors.
	while (parent != null && parent != scrolledAncestor) {
		parent = parent.getParent();
	}

	// If the correct ancestor was found, then set the class reference to
	// it. Otherwise, throw an exception.
	if (parent != null) {
		this.scrolledAncestor = scrolledAncestor;
	} else {
		this.scrolledAncestor = null;
		throw new IllegalArgumentException("HorizontalScrollManager error: "
				+ "Specified ScrolledComposite is not an ancestor of client Control.");
	}

	// We need to add a resize listener to reflow the ancestor
	// ScrolledComposite when it's client area is too small.
	createResizeListener();

	// We must ensure the padding is correct for resizing.
	recomputePads();

	return;
}
 
Example #6
Source File: ScrollClientComposite.java    From ice with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * The full {@link ScrollClientComposite} constructor. The parent and style
 * are passed to the {@link Composite} constructor. The ancestor is
 * verified, and the {@link #minWidth} is set.
 * 
 * @param parent
 *            A widget which will be the parent of the new instance (cannot
 *            be null).
 * @param style
 *            The style of widget to construct.
 * @param scrolledAncestor
 *            The ancestor scrolled {@code Composite}. Must be a non-null
 *            ancestor (parent, grandparent, etc.), else an
 *            {@code IllegalArgumentException} will be thrown.
 * @param minWidth
 *            The width at which this {@code Composite} will stop getting
 *            smaller, thus forcing its ancestor {@code ScrolledComposite}
 *            to use a horizontal scroll bar. If less than 0, the value 0
 *            will be used instead.
 */
public ScrollClientComposite(Composite parent, int style,
		SharedScrolledComposite scrolledAncestor, int minWidth) {
	this(parent, style, scrolledAncestor);
	setMinWidth(minWidth);
}