类org.eclipse.swt.widgets.Sash源码实例Demo

下面列出了怎么用org.eclipse.swt.widgets.Sash的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: http4e   文件: LiveSashForm.java
private Control[] getControls(boolean onlyVisible)
{
  Control[] children = getChildren();
  Control[] result = new Control[0];
  for (int i = 0; i < children.length; i++)
  {
    if (children[i] instanceof Sash)
      continue;
    if (onlyVisible && !children[i].getVisible())
      continue;

    Control[] newResult = new Control[result.length + 1];
    System.arraycopy(result, 0, newResult, 0, result.length);
    newResult[result.length] = children[i];
    result = newResult;
  }
  return result;
}
 
源代码2 项目: http4e   文件: UrbanSashForm.java
Control[] getControls( boolean onlyVisible){
    Control[] children = getChildren();
    Control[] result = new Control[0];
    for (int i = 0; i < children.length; i++) {
        if (children[i] instanceof Sash)
            continue;
        if (onlyVisible && !children[i].getVisible())
            continue;

        Control[] newResult = new Control[result.length + 1];
        System.arraycopy(result, 0, newResult, 0, result.length);
        newResult[result.length] = children[i];
        result = newResult;
    }
    return result;
}
 
源代码3 项目: http4e   文件: UrbanSashForm.java
/**
 * If orientation is SWT.HORIZONTAL, lay the controls in the SashForm out
 * side by side. If orientation is SWT.VERTICAL, lay the controls in the
 * SashForm out top to bottom.
 * 
 * @param orientation
 *            SWT.HORIZONTAL or SWT.VERTICAL
 * 
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                <li>ERROR_INVALID_ARGUMENT - if the value of orientation
 *                is not SWT.HORIZONTAL or SWT.VERTICAL
 *                </ul>
 */
public void setOrientation( int orientation){
    checkWidget();
    if (getOrientation() == orientation)
        return;
    if (orientation != SWT.HORIZONTAL && orientation != SWT.VERTICAL) {
        SWT.error(SWT.ERROR_INVALID_ARGUMENT);
    }
    sashStyle &= ~(SWT.HORIZONTAL | SWT.VERTICAL);
    sashStyle |= orientation == SWT.VERTICAL ? SWT.HORIZONTAL
            : SWT.VERTICAL;
    for (int i = 0; i < sashes.length; i++) {
        sashes[i].dispose();
        sashes[i] = new Sash(this, sashStyle);
        sashes[i].setBackground(background);
        sashes[i].setForeground(foreground);
        sashes[i].addListener(SWT.Selection, sashListener);
    }
    layout(false);
}
 
源代码4 项目: xds-ide   文件: UiUtils.java
public static Sash createSplitter(Composite parent, FormAttachment left) {
  final Sash sash = new Sash(parent, SWT.VERTICAL);
  FormData formData = new FormData();
  formData.top = new FormAttachment(0, 0); // Attach to top
  formData.bottom = new FormAttachment(100, 0); // Attach to bottom
  formData.left = left;
  sash.setLayoutData(formData);
  sash.addSelectionListener(new SelectionAdapter() {
    public void widgetSelected(SelectionEvent event) {
      // We reattach to the left edge, and we use the x value of the event to
      // determine the offset from the left
      ((FormData) sash.getLayoutData()).left = new FormAttachment(0, event.x);

      // Until the parent window does a layout, the sash will not be redrawn
      // in
      // its new location.
      sash.getParent().layout();
    }
  });
  return sash;
}
 
源代码5 项目: xds-ide   文件: SwtUtils.java
public static Sash createSplitter(Composite parent, FormAttachment left) {
	final Sash sash = new Sash(parent, SWT.VERTICAL);
	FormData formData = new FormData();
	formData.top = new FormAttachment(0, 0); // Attach to top
	formData.bottom = new FormAttachment(100, 0); // Attach to bottom
	formData.left = left;
	sash.setLayoutData(formData);
	sash.addSelectionListener(new SelectionAdapter() {
		public void widgetSelected(SelectionEvent event) {
			// We reattach to the left edge, and we use the x value of the
			// event to
			// determine the offset from the left
			((FormData) sash.getLayoutData()).left = new FormAttachment(0,
					event.x);

			// Until the parent window does a layout, the sash will not be
			// redrawn
			// in
			// its new location.
			sash.getParent().layout();
		}
	});
	return sash;
}
 
源代码6 项目: tracecompass   文件: TmfAlignTimeAxisTest.java
private static AbstractSWTBot<?> getAlignmentControl(String viewId) {
    SWTBotView viewBot = fBot.viewById(viewId);
    switch (viewId) {
    case HistogramView.ID:
        return new SWTBotSash(viewBot.bot().widget(WidgetOfType.widgetOfType(Sash.class)));
    case TimeGraphViewStub.ID:
    case TimeChartView.ID:
        return new SWTBotTimeGraph(viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)));
    default:
        return null;
    }
}
 
源代码7 项目: birt   文件: AbstractPropertyDialog.java
protected Control createDialogArea( Composite parent )
{
	Composite composite = new Composite( parent, SWT.NONE );
	composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	GridLayout layout = new GridLayout( );
	layout.numColumns = 1;
	layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN );
	layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN );
	layout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING );
	composite.setLayout( layout );

	container = new Composite( composite, SWT.NONE );
	layout = new GridLayout( );
	layout.numColumns = 3;
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	layout.horizontalSpacing = 2;
	container.setLayout( layout );
	container.setLayoutData( new GridData( GridData.FILL_BOTH ) );

	treeViewer = createTreeViewer( container );
	treeViewer.setLayoutData( new GridData( GridData.FILL_VERTICAL ) );
	Sash sash = createSash( container );
	pageContainer = createPropertyPane( container );
	pageContainer.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	addDragListerner( sash, container, treeViewer, pageContainer );

	Label label = new Label( composite, SWT.HORIZONTAL | SWT.SEPARATOR );
	label.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );

	initTreeSelection( );

	return composite;
}
 
源代码8 项目: bonita-studio   文件: BonitaSashForm.java
protected void saveChildControlSizes() {
    // Save control sizes
    Control [] children = getChildren();
    int iChildToSave = 0;
    for (int i = 0; i < children.length && iChildToSave < 2; i++){
        Control child = children[i];
        if (! (child instanceof Sash)){
            currentSashInfo.savedSizes[iChildToSave] = child.getSize();
            iChildToSave++;
        }
    }
}
 
源代码9 项目: bonita-studio   文件: BonitaSashForm.java
protected Sash getSash() {
    Control[] kids = getChildren();
    for (int i = 0; i < kids.length; i++) {
        if (kids[i] instanceof Sash) {
            return (Sash)kids[i];
        }
    }
    return null;
}
 
源代码10 项目: depan   文件: Sasher.java
/**
 * Initialize the sasher, with the two given contained controls, the style,
 * {@link SWT#VERTICAL} or {@link SWT#HORIZONTAL}, and the percentage of
 * space initially used by the first Control.
 *
 * @param first first control (top or left)
 * @param second second control (down or right)
 * @param sasherStyle {@link SWT#VERTICAL} or {@link SWT#HORIZONTAL}.
 * @param percent percentage of space initially used by the first Control
 */
public void init(Control first, Control second,
    int sasherStyle, int percent) {
  this.sashStyle = sasherStyle;

  sash = new Sash(this, sashStyle);

  // create position instructions
  FormData firstData = new FormData();
  final FormData sashData = new FormData();
  FormData secondData = new FormData();

  // setup constant positions
  firstData.left = new FormAttachment(0);
  firstData.top = new FormAttachment(0);
  sashData.left = new FormAttachment(0);
  sashData.top = new FormAttachment(percent);
  secondData.right = new FormAttachment(100);
  secondData.bottom = new FormAttachment(100);

  // setup direction dependent positions
  if (isVertical()) { // horizontal == top/down
    firstData.right = new FormAttachment(sash);
    firstData.bottom = new FormAttachment(100);
    sashData.bottom = new FormAttachment(100);
    secondData.left = new FormAttachment(sash);
    secondData.top = new FormAttachment(0);
  } else {
    firstData.right = new FormAttachment(100);
    firstData.bottom = new FormAttachment(sash);
    sashData.right = new FormAttachment(100);
    secondData.left = new FormAttachment(0);
    secondData.top = new FormAttachment(sash);
  }

  // set the layouts
  first.setLayoutData(firstData);
  sash.setLayoutData(sashData);
  second.setLayoutData(secondData);

  // move event / constraints:
  sash.addListener(SWT.Selection, new Listener() {

    @Override
    public void handleEvent(Event e) {
      if (isVertical()) {
        resizeVertical(e, sashData);
      } else {
        resizeHorizontal(e, sashData);
      }
    }
  });
}
 
源代码11 项目: translationstudio8   文件: TermDbManagerDialog.java
/**
 * Create the sash with right control on the right. Note that this method assumes GridData for the layout data of
 * the rightControl.
 * @param composite
 * @param rightControl
 * @return Sash
 */
protected Sash createSash(final Composite composite, final Control rightControl) {
	final Sash sash = new Sash(composite, SWT.VERTICAL);
	sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
	sash.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
	// the following listener resizes the tree control based on sash deltas.
	// If necessary, it will also grow/shrink the dialog.
	sash.addListener(SWT.Selection, new Listener() {
		/*
		 * (non-Javadoc)
		 * 
		 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt. widgets.Event)
		 */
		public void handleEvent(Event event) {
			if (event.detail == SWT.DRAG) {
				return;
			}
			int shift = event.x - sash.getBounds().x;
			GridData data = (GridData) rightControl.getLayoutData();
			int newWidthHint = data.widthHint + shift;
			if (newWidthHint < 20) {
				return;
			}
			Point computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			Point currentSize = getShell().getSize();
			// if the dialog wasn't of a custom size we know we can shrink
			// it if necessary based on sash movement.
			boolean customSize = !computedSize.equals(currentSize);
			data.widthHint = newWidthHint;
			setLastTreeWidth(newWidthHint);
			composite.layout(true);
			// recompute based on new widget size
			computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			// if the dialog was of a custom size then increase it only if
			// necessary.
			if (customSize) {
				computedSize.x = Math.max(computedSize.x, currentSize.x);
			}
			computedSize.y = Math.max(computedSize.y, currentSize.y);
			if (computedSize.equals(currentSize)) {
				return;
			}
			setShellSize(computedSize.x, computedSize.y);
			lastShellSize = getShell().getSize();
		}
	});
	return sash;
}
 
源代码12 项目: translationstudio8   文件: TmDbManagerDialog.java
/**
 * Create the sash with right control on the right. Note that this method assumes GridData for the layout data of
 * the rightControl.
 * @param composite
 * @param rightControl
 * @return Sash
 */
protected Sash createSash(final Composite composite, final Control rightControl) {
	final Sash sash = new Sash(composite, SWT.VERTICAL);
	sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
	sash.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
	// the following listener resizes the tree control based on sash deltas.
	// If necessary, it will also grow/shrink the dialog.
	sash.addListener(SWT.Selection, new Listener() {
		/*
		 * (non-Javadoc)
		 * 
		 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt. widgets.Event)
		 */
		public void handleEvent(Event event) {
			if (event.detail == SWT.DRAG) {
				return;
			}
			int shift = event.x - sash.getBounds().x;
			GridData data = (GridData) rightControl.getLayoutData();
			int newWidthHint = data.widthHint + shift;
			if (newWidthHint < 20) {
				return;
			}
			Point computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			Point currentSize = getShell().getSize();
			// if the dialog wasn't of a custom size we know we can shrink
			// it if necessary based on sash movement.
			boolean customSize = !computedSize.equals(currentSize);
			data.widthHint = newWidthHint;
			setLastTreeWidth(newWidthHint);
			composite.layout(true);
			// recompute based on new widget size
			computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			// if the dialog was of a custom size then increase it only if
			// necessary.
			if (customSize) {
				computedSize.x = Math.max(computedSize.x, currentSize.x);
			}
			computedSize.y = Math.max(computedSize.y, currentSize.y);
			if (computedSize.equals(currentSize)) {
				return;
			}
			setShellSize(computedSize.x, computedSize.y);
			lastShellSize = getShell().getSize();
		}
	});
	return sash;
}
 
源代码13 项目: tmxeditor8   文件: TmDbManagerDialog.java
/**
 * Create the sash with right control on the right. Note that this method assumes GridData for the layout data of
 * the rightControl.
 * @param composite
 * @param rightControl
 * @return Sash
 */
protected Sash createSash(final Composite composite, final Control rightControl) {
	final Sash sash = new Sash(composite, SWT.VERTICAL);
	sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
	sash.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
	// the following listener resizes the tree control based on sash deltas.
	// If necessary, it will also grow/shrink the dialog.
	sash.addListener(SWT.Selection, new Listener() {
		/*
		 * (non-Javadoc)
		 * 
		 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt. widgets.Event)
		 */
		public void handleEvent(Event event) {
			if (event.detail == SWT.DRAG) {
				return;
			}
			int shift = event.x - sash.getBounds().x;
			GridData data = (GridData) rightControl.getLayoutData();
			int newWidthHint = data.widthHint + shift;
			if (newWidthHint < 20) {
				return;
			}
			Point computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			Point currentSize = getShell().getSize();
			// if the dialog wasn't of a custom size we know we can shrink
			// it if necessary based on sash movement.
			boolean customSize = !computedSize.equals(currentSize);
			data.widthHint = newWidthHint;
			setLastTreeWidth(newWidthHint);
			composite.layout(true);
			// recompute based on new widget size
			computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			// if the dialog was of a custom size then increase it only if
			// necessary.
			if (customSize) {
				computedSize.x = Math.max(computedSize.x, currentSize.x);
			}
			computedSize.y = Math.max(computedSize.y, currentSize.y);
			if (computedSize.equals(currentSize)) {
				return;
			}
			setShellSize(computedSize.x, computedSize.y);
			lastShellSize = getShell().getSize();
		}
	});
	return sash;
}
 
源代码14 项目: tmxeditor8   文件: TermDbManagerDialog.java
/**
 * Create the sash with right control on the right. Note that this method assumes GridData for the layout data of
 * the rightControl.
 * @param composite
 * @param rightControl
 * @return Sash
 */
protected Sash createSash(final Composite composite, final Control rightControl) {
	final Sash sash = new Sash(composite, SWT.VERTICAL);
	sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
	sash.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
	// the following listener resizes the tree control based on sash deltas.
	// If necessary, it will also grow/shrink the dialog.
	sash.addListener(SWT.Selection, new Listener() {
		/*
		 * (non-Javadoc)
		 * 
		 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt. widgets.Event)
		 */
		public void handleEvent(Event event) {
			if (event.detail == SWT.DRAG) {
				return;
			}
			int shift = event.x - sash.getBounds().x;
			GridData data = (GridData) rightControl.getLayoutData();
			int newWidthHint = data.widthHint + shift;
			if (newWidthHint < 20) {
				return;
			}
			Point computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			Point currentSize = getShell().getSize();
			// if the dialog wasn't of a custom size we know we can shrink
			// it if necessary based on sash movement.
			boolean customSize = !computedSize.equals(currentSize);
			data.widthHint = newWidthHint;
			setLastTreeWidth(newWidthHint);
			composite.layout(true);
			// recompute based on new widget size
			computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			// if the dialog was of a custom size then increase it only if
			// necessary.
			if (customSize) {
				computedSize.x = Math.max(computedSize.x, currentSize.x);
			}
			computedSize.y = Math.max(computedSize.y, currentSize.y);
			if (computedSize.equals(currentSize)) {
				return;
			}
			setShellSize(computedSize.x, computedSize.y);
			lastShellSize = getShell().getSize();
		}
	});
	return sash;
}
 
源代码15 项目: tmxeditor8   文件: TmDbManagerDialog.java
/**
 * Create the sash with right control on the right. Note that this method assumes GridData for the layout data of
 * the rightControl.
 * @param composite
 * @param rightControl
 * @return Sash
 */
protected Sash createSash(final Composite composite, final Control rightControl) {
	final Sash sash = new Sash(composite, SWT.VERTICAL);
	sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
	sash.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
	// the following listener resizes the tree control based on sash deltas.
	// If necessary, it will also grow/shrink the dialog.
	sash.addListener(SWT.Selection, new Listener() {
		/*
		 * (non-Javadoc)
		 * 
		 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt. widgets.Event)
		 */
		public void handleEvent(Event event) {
			if (event.detail == SWT.DRAG) {
				return;
			}
			int shift = event.x - sash.getBounds().x;
			GridData data = (GridData) rightControl.getLayoutData();
			int newWidthHint = data.widthHint + shift;
			if (newWidthHint < 20) {
				return;
			}
			Point computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			Point currentSize = getShell().getSize();
			// if the dialog wasn't of a custom size we know we can shrink
			// it if necessary based on sash movement.
			boolean customSize = !computedSize.equals(currentSize);
			data.widthHint = newWidthHint;
			setLastTreeWidth(newWidthHint);
			composite.layout(true);
			// recompute based on new widget size
			computedSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
			// if the dialog was of a custom size then increase it only if
			// necessary.
			if (customSize) {
				computedSize.x = Math.max(computedSize.x, currentSize.x);
			}
			computedSize.y = Math.max(computedSize.y, currentSize.y);
			if (computedSize.equals(currentSize)) {
				return;
			}
			setShellSize(computedSize.x, computedSize.y);
			lastShellSize = getShell().getSize();
		}
	});
	return sash;
}
 
源代码16 项目: birt   文件: AbstractPropertyDialog.java
private Sash createSash( final Composite composite )
{
	final Sash sash = new Sash( composite, SWT.VERTICAL );
	sash.setLayoutData( new GridData( GridData.FILL_VERTICAL ) );
	return sash;
}
 
源代码17 项目: bonita-studio   文件: BonitaSashForm.java
public SashInfo(Sash sash) {
    this.sash = sash;
}
 
源代码18 项目: tracecompass   文件: SWTBotSash.java
/**
 * The widget wrapper
 *
 * @param w
 *            the sash
 * @throws WidgetNotFoundException
 *             if there is no widget
 */
public SWTBotSash(Sash w) throws WidgetNotFoundException {
    super(w);
}
 
 类所在包
 同包方法