org.eclipse.swt.widgets.Sash Java Examples
The following examples show how to use
org.eclipse.swt.widgets.Sash.
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: UrbanSashForm.java From http4e with Apache License 2.0 | 6 votes |
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; }
Example #2
Source File: UrbanSashForm.java From http4e with Apache License 2.0 | 6 votes |
/** * 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); }
Example #3
Source File: UiUtils.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
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; }
Example #4
Source File: SwtUtils.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
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; }
Example #5
Source File: LiveSashForm.java From http4e with Apache License 2.0 | 6 votes |
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; }
Example #6
Source File: BonitaSashForm.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
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; }
Example #7
Source File: BonitaSashForm.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
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++; } } }
Example #8
Source File: AbstractPropertyDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
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; }
Example #9
Source File: TmfAlignTimeAxisTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
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; } }
Example #10
Source File: TermDbManagerDialog.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * 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; }
Example #11
Source File: TmDbManagerDialog.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * 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; }
Example #12
Source File: TmDbManagerDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 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; }
Example #13
Source File: TermDbManagerDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 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; }
Example #14
Source File: TmDbManagerDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 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; }
Example #15
Source File: Sasher.java From depan with Apache License 2.0 | 4 votes |
/** * 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); } } }); }
Example #16
Source File: AbstractPropertyDialog.java From birt with Eclipse Public License 1.0 | 4 votes |
private Sash createSash( final Composite composite ) { final Sash sash = new Sash( composite, SWT.VERTICAL ); sash.setLayoutData( new GridData( GridData.FILL_VERTICAL ) ); return sash; }
Example #17
Source File: BonitaSashForm.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
public SashInfo(Sash sash) { this.sash = sash; }
Example #18
Source File: SWTBotSash.java From tracecompass with Eclipse Public License 2.0 | 2 votes |
/** * The widget wrapper * * @param w * the sash * @throws WidgetNotFoundException * if there is no widget */ public SWTBotSash(Sash w) throws WidgetNotFoundException { super(w); }