/** * Adds the tab folder to property window. * * @return the tab folder */ public CTabFolder addTabFolderToPropertyWindow(){ CTabFolder tabFolder = new CTabFolder(container, SWT.NONE); GridData tabFolderGridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); tabFolder.setLayoutData(tabFolderGridData); tabFolder.addListener(SWT.FOCUSED,getMouseClickListener() ); container.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { tabFolderGridData.heightHint = container.getBounds().height - 500; } }); tabFolder.addListener(SWT.FOCUSED,getMouseClickListener() ); return tabFolder; }
/** * Arrange the columns size in equal ratio */ private void arrangeTableViewerColumns() { tableViewerComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { int totalWidth = tableViewer.getTable().getColumnCount() * COLUMN_WIDTH; int widthDifference = tableViewerComposite.getSize().x - totalWidth; if (widthDifference > 0) { widthDifference = widthDifference / tableViewer.getTable().getColumnCount(); for (TableColumn tableColumn : tableViewer.getTable().getColumns()) { tableColumn.setWidth(COLUMN_WIDTH+widthDifference); } } } }); }
private void createColumns(final Table table) { table.setLayout(new TableLayout()); final ControlListener layoutWhenResizedListener = new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { ((TableColumn) e.widget).getParent().layout(); } }; for (int i = 0; i < COLUMN_DATA.length; i++) { final ColumnData columnData = COLUMN_DATA[i]; final TableColumn column = new TableColumn(table, columnData.style); column.setWidth(columnData.defaultWidth); column.setResizable(columnData.resizable); if (columnData.label != null) { column.setText(columnData.label); } column.addControlListener(layoutWhenResizedListener); } }
/** * Creates a new <code>TableLayoutComposite</code>. * * @param parent * the parent composite * @param style * the SWT style */ public TableLayoutComposite(Composite parent, int style) { super(parent, style); addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle area = getClientArea(); Table table = (Table) getChildren()[0]; Point preferredSize = computeTableSize(table); int width = area.width - 2 * table.getBorderWidth(); if (preferredSize.y > area.height) { // Subtract the scrollbar width from the total column // width // if a vertical scrollbar will be required Point vBarSize = table.getVerticalBar().getSize(); width -= vBarSize.x; } layoutTable(table, width, area, table.getSize().x < area.width); } }); }
@Override public void controlResized(ControlEvent e) { if (getBounds().height <= 20) { mTree.setHeaderVisible(false); noHeader = true; } else if (noHeader) { mTree.setHeaderVisible(true); noHeader = false; } if (getBounds().height <= 38) { mTreeViewer.setInput(null); noInput = true; } else if (noInput) { mTreeViewer.setInput(mModel); noInput = false; } }
public void controlResized(ControlEvent e) { Rectangle area; if(e.widget instanceof Composite){ area = ((Composite)e.widget).getClientArea(); }else if(e.widget instanceof Table){ area = ((Table)e.widget).getClientArea(); }else{ return; } org.eclipse.swt.graphics.Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT); int width = area.width - 2 * table.getBorderWidth(); if (preferredSize.y > area.height + table.getHeaderHeight()) { org.eclipse.swt.graphics.Point vBarSize = table.getVerticalBar().getSize(); width -= vBarSize.x; } org.eclipse.swt.graphics.Point oldSize = table.getSize(); if (oldSize.x > area.width) { adjustColumnSize(width - 20); table.setSize(area.width, area.height); } else { table.setSize(area.width, area.height); adjustColumnSize(width - 20); } super.controlResized(e); }
/** * Do layout. Several magic #s in here... * * @param scrolledComposite */ private void setupScrolledComposite() { setAlwaysShowScrollBars(true); scrolledCanvas = new Composite(this, SWT.NONE); GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(scrolledCanvas); setMinWidth(100); setMinHeight(100); setExpandHorizontal(true); setExpandVertical(true); setMinHeight(1); Point size = scrolledCanvas.computeSize(getParent().getSize().x, SWT.DEFAULT, true); scrolledCanvas.setSize(size); addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { doUpdateContentSize(); updateScrollIncrements(); } }); setContent(scrolledCanvas); }
@Override public void createPartControl(Composite parent) { scrollComp = new ScrolledComposite(parent, SWT.V_SCROLL); scrollComp.setLayoutData(new GridData(GridData.FILL_BOTH)); scrollComp.setLayout(new GridLayout(1,false)); scrollComp.setExpandVertical(true); scrollComp.setExpandHorizontal(true); scrollComp.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { refreshScrolledHeight(); } }); mainContainer = new Composite(scrollComp, SWT.BORDER); mainContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); scrollComp.setContent(mainContainer); mainContainer.setLayout(new ButtonFillLayout()); IWorkbenchPart editor = getContributingPart(); if (editor instanceof CachedSelectionProvider){ CachedSelectionProvider cachedSelEditor = (CachedSelectionProvider)editor; cachedSelEditor.getSelectionCache().addSelectionChangeListener(selectionListener); } }
/** * @param tb */ public void install(final GamaToolbar2 tb) { // We add a control listener to the toolbar in order to install the // gesture once the control to resize have been created. tb.addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { final Control c = view.getSizableFontControl(); if (c != null) { c.addGestureListener(gl); // once installed the listener removes itself from the // toolbar tb.removeControlListener(this); } } }); tb.button("console.increase2", "Increase font size", "Increase font size", e -> changeFontSize(2), SWT.RIGHT); tb.button("console.decrease2", "Decrease font size", "Decrease font size", e -> changeFontSize(-2), SWT.RIGHT); tb.sep(16, SWT.RIGHT); }
private void autoAdjustColumnWidth(final TableColumn col, final Table table) { final Composite comp = table.getParent(); comp.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Rectangle area = comp.getClientArea(); Point preferredSize = comp.computeSize(SWT.DEFAULT, SWT.DEFAULT); int width = area.width - 2 * comp.getBorderWidth(); if (preferredSize.y > area.height + table.getHeaderHeight()) { if(comp.getVerticalBar() != null) { Point vBarSize = comp.getVerticalBar().getSize(); width -= vBarSize.x; } } col.setWidth(width - 75 > 0 ? width - 75 : 0); comp.setSize(area.width, area.height); } }); }
private void autoAdjustColumnWidth(final TableColumn colName, final TableColumn colVal, final Table table) { final Composite comp = table.getParent(); comp.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Rectangle area = comp.getClientArea(); Point preferredSize = comp.computeSize(SWT.DEFAULT, SWT.DEFAULT); int width = area.width - 2 * comp.getBorderWidth(); if (preferredSize.y > area.height + table.getHeaderHeight()) { if(comp.getVerticalBar() != null) { Point vBarSize = comp.getVerticalBar().getSize(); width -= vBarSize.x; } } colName.setWidth(width / 3 > 0 ? width / 3 : 0); colVal.setWidth(width - colName.getWidth() - 15 > 0 ? width - colName.getWidth() - 15 : 0); comp.setSize(area.width, area.height); } }); }
/** * Creates a new <code>TableLayoutComposite</code>. */ public TableLayoutComposite(Composite parent, int style) { super(parent, style); addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle area= getClientArea(); Table table= (Table)getChildren()[0]; Point preferredSize= computeTableSize(table); int width= area.width - 2 * table.getBorderWidth(); if (preferredSize.y > area.height) { // Subtract the scrollbar width from the total column width // if a vertical scrollbar will be required Point vBarSize = table.getVerticalBar().getSize(); width -= vBarSize.x; } layoutTable(table, width, area, table.getSize().x < area.width); } }); }
private void createUI(final Composite parent) { _tk = new FormToolkit(parent.getDisplay()); _scrolledContainer = new ScrolledComposite(parent, SWT.V_SCROLL); { _scrolledContent = _tk.createComposite(_scrolledContainer); GridDataFactory.fillDefaults().applyTo(_scrolledContent); GridLayoutFactory.swtDefaults().numColumns(1).applyTo(_scrolledContent); { createUI_10_StatisticsContainer(_scrolledContent); } // setup scrolled container _scrolledContainer.setExpandVertical(true); _scrolledContainer.setExpandHorizontal(true); _scrolledContainer.addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { onResizeScrolledContainer(_scrolledContent); } }); _scrolledContainer.setContent(_scrolledContent); } }
/** * Column: Color image */ private void defineColumn_30_ColorImage() { final TableViewerColumn tvc = new TableViewerColumn(_colorViewer, SWT.LEAD); final TableColumn tc = tvc.getColumn(); tc.setWidth(_pc.convertWidthInCharsToPixels(COLUMN_WITH_COLOR_IMAGE)); _tcProfileImage = tc; _columnIndexProfileImage = _colorViewer.getTable().getColumnCount() - 1; tc.addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { onResizeImageColumn(); } }); tvc.setLabelProvider(new CellLabelProvider() { // !!! set dummy label provider, otherwise an error occures !!! @Override public void update(final ViewerCell cell) {} }); }
private void createUI_30_ProfileImage(final Composite parent) { /* * profile image */ _canvasProfileImage = new ImageCanvas(parent, SWT.DOUBLE_BUFFERED); GridDataFactory.fillDefaults()// .grab(true, true) // .minSize(SWT.DEFAULT, 20) .hint(_pc.convertWidthInCharsToPixels(20), SWT.DEFAULT) .applyTo(_canvasProfileImage); _canvasProfileImage.addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { drawProfileImage(); } }); }
private Composite createUI_568_IL_SpeedTourType_ScrolledContainer(final Composite parent) { // scrolled container _speedTourType_ScrolledContainer = new ScrolledComposite(parent, SWT.V_SCROLL); GridDataFactory.fillDefaults().grab(true, true).applyTo(_speedTourType_ScrolledContainer); _speedTourType_ScrolledContainer.setExpandVertical(true); _speedTourType_ScrolledContainer.setExpandHorizontal(true); // container final Composite speedTTContainer = new Composite(_speedTourType_ScrolledContainer, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(speedTTContainer); GridLayoutFactory .fillDefaults()// .numColumns(5) .applyTo(speedTTContainer); _speedTourType_ScrolledContainer.setContent(speedTTContainer); _speedTourType_ScrolledContainer.addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { _speedTourType_ScrolledContainer.setMinSize(speedTTContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } }); return speedTTContainer; }
private Composite createUI_72_VertexScrolledContainer(final Composite parent) { // scrolled container _vertexScrolledContainer = new ScrolledComposite(parent, SWT.V_SCROLL); GridDataFactory.fillDefaults().grab(false, true).applyTo(_vertexScrolledContainer); _vertexScrolledContainer.setExpandVertical(true); _vertexScrolledContainer.setExpandHorizontal(true); // vertex container final Composite vertexContainer = new Composite(_vertexScrolledContainer, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(vertexContainer); _vertexScrolledContainer.setContent(vertexContainer); _vertexScrolledContainer.addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { _vertexScrolledContainer.setMinSize(vertexContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT)); } }); return vertexContainer; }
private void addListeners() { final IWorkbenchPage page = getSite().getPage(); _partContainer.addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent event) { onResizeUI(); } }); _postSelectionListener = new ISelectionListener() { @Override public void selectionChanged(final IWorkbenchPart part, final ISelection selection) { onSelectionChanged(selection); } }; page.addPostSelectionListener(_postSelectionListener); }
/** * Column: Color image */ private void defineColumn_30_ColorImage() { final TreeColumnDefinition colDef = new TreeColumnDefinition(_columnManager, "colorImage", SWT.LEAD); //$NON-NLS-1$ _colDefProfileImage = colDef; colDef.setColumnLabel(Messages.Pref_Map3Color_Column_Colors); colDef.setColumnHeaderText(Messages.Pref_Map3Color_Column_Colors); colDef.setDefaultColumnWidth(_pc.convertWidthInCharsToPixels(20)); colDef.setIsDefaultColumn(); colDef.setIsColumnMoveable(false); colDef.setCanModifyVisibility(false); colDef.setLabelProvider(new CellLabelProvider() { // !!! set dummy label provider, otherwise an error occures !!! @Override public void update(final ViewerCell cell) {} }); colDef.setControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { onResizeImageColumn(); } }); }
/** * Creates a new <code>TableLayoutComposite</code>. */ public TableLayoutComposite(final Composite parent, final int style) { super(parent, style); addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { final Rectangle area = getClientArea(); final Table table = (Table) getChildren()[0]; final Point preferredSize = computeTableSize(table); int width = area.width - 2 * table.getBorderWidth(); if (preferredSize.y > area.height) { // Subtract the scrollbar width from the total column width // if a vertical scrollbar will be required final Point vBarSize = table.getVerticalBar().getSize(); width -= vBarSize.x; } layoutTable(table, width, area, table.getSize().x < area.width); } }); }
@Override public void controlResized(final ControlEvent e) { final TableColumn column = (TableColumn) e.widget; final long time = getTime(e); if (time != -1) { lastResizeTime = time; } if (column != null) { final int columnIndex = getColumnIndex(column); final int width = column.getWidth(); setWidthInvokedOnModel = true; columnModel.getColumn(columnIndex).setWidth(width); setWidthInvokedOnModel = false; tableColumnObservable.fireColumnResized(new TableColumnResizeEvent(columnIndex, width)); } }
@Override public void controlResized(final ControlEvent event) { final Composite composite = (Composite) event.widget; final Rectangle rectangle = composite.getClientArea(); if (lastRectangle != null) { final int dy = rectangle.height - lastRectangle.height; final int dx = rectangle.width - lastRectangle.width; if (dx > 0 || dy > 0) { final GC graphicContext = new GC(composite); try { graphicContext.fillRectangle(rectangle.x, lastRectangle.height, rectangle.width, dy); graphicContext.fillRectangle(lastRectangle.width, rectangle.y, dx, rectangle.height); } finally { graphicContext.dispose(); } } } lastRectangle = rectangle; }
protected FigureCanvas createCanvas () { final FigureCanvas canvas = new FigureCanvas ( this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE ); addControlListener ( new ControlAdapter () { @Override public void controlResized ( final ControlEvent e ) { handleResize ( getBounds () ); } } ); return canvas; }
@Override protected void subscribeActual(Observer<? super ControlEvent> observer) { if (!Preconditions.checkWidget(observer, control)) { return; } AbstractControlListener listener = getControlListener(control, observer); observer.onSubscribe(listener); control.addDisposeListener(e -> listener.dispose()); control.addControlListener(listener); }
@Override protected AbstractControlListener getControlListener(Control control, Observer<? super ControlEvent> observer) { return new AbstractControlListener(control) { @Override public void controlMoved(ControlEvent e) { if (!isDisposed()) { observer.onNext(e); } } }; }
@Override protected AbstractControlListener getControlListener(Control control, Observer<? super ControlEvent> observer) { return new AbstractControlListener(control) { @Override public void controlResized(ControlEvent e) { if (!isDisposed()) { observer.onNext(e); } } }; }
/** * Resizes base container on outer shell resize * * @param container */ private void addControlListener(final Composite container) { container.getParent().addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { //textGrid.setHeight(container.getParent().getBounds().height - 150); textGrid.setHeight(container.getParent().getBounds().height - 165); } }); }
private void addControlListener(Table table, TableColumn tableColumn) { ControlListener controlistener= new ControlAdapter() { @Override public void controlResized(ControlEvent e) { for (TableColumn column : table.getColumns()) { column.setWidth(table.getSize().x / table.getColumnCount() - (4 - table.getColumnCount())); } } }; table.addControlListener(controlistener); }
private void createInputFieldSection(Composite composite) { Composite inputComposite = new Composite(composite, SWT.NONE); GridLayout gl_inputComposite = new GridLayout(1, false); gl_inputComposite.horizontalSpacing = 0; gl_inputComposite.verticalSpacing = 0; gl_inputComposite.marginWidth = 0; gl_inputComposite.marginHeight = 0; inputComposite.setLayout(gl_inputComposite); GridData gd_inputComposite = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1); gd_inputComposite.widthHint = 269; inputComposite.setLayoutData(gd_inputComposite); inputComposite.setBounds(0, 0, 64, 64); ScrolledComposite inputScrolledComposite = new ScrolledComposite( inputComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); inputScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); inputScrolledComposite.setExpandHorizontal(true); inputScrolledComposite.setExpandVertical(true); final SashForm inputComposite2 = new SashForm(inputScrolledComposite, SWT.VERTICAL); inputComposite2.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { in0Table.getColumn(0).setWidth(inputComposite2.getSize().x-5); in1Table.getColumn(0).setWidth(inputComposite2.getSize().x-5); } }); inputComposite2.setLayout(new GridLayout(1, false)); addIn0InputFields(inputComposite2); addIn1InputFields(inputComposite2); inputScrolledComposite.setContent(inputComposite2); inputScrolledComposite.setMinSize(inputComposite2.computeSize(SWT.DEFAULT, SWT.DEFAULT)); }
public ErrorLabel(final Composite parent, final int style) { super(parent, style); label = new Label(this, SWT.NONE); GridDataBuilder.newInstance().hHint(16).wHint(16).applyTo(label); errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); warningImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK); validatorBinding = new AbstractValidatorBinding() { @Override protected void update(final IValidity validity) { if (validity.getSeverity() == Severity.OK) { clearErrorState(); } else { final IValidationMessage validationMessage = validity.getFirstMessage(); if (validationMessage == null) { setErrorState(validity.getSeverity(), null); } else { setErrorState(validationMessage.getSeverity(), validationMessage.getMessage()); } } } }; addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { ErrorLabel.this.controlResized(e); } }); }
@Override public void controlResized(ControlEvent e) { if (autosizing) return; autosizing = true; try { autoSizeColumns(); } finally { autosizing = false; } }
/** * Primary will be shown as long as width and height are within the given bounds, * otherwise the composite will switch to the secondary control * * @param parent * @param minWidth * @param minHeight */ public ComponentResponsiveLayout(final Composite parent, final int minWidth, final int minHeight, final Control primary, final Control secondary) { final StackLayout layout = new StackLayout(); parent.setLayout (layout); layout.topControl = primary; parent.layout(); parent.addControlListener(new ControlAdapter(){ @Override public void controlResized(ControlEvent arg0) { if (parent.getSize().x < minWidth || parent.getSize().y < minHeight) { if (layout.topControl != secondary) { layout.topControl = secondary; parent.layout(); } } else { if (layout.topControl != primary) { layout.topControl = primary; parent.layout(); } } } }); }
@Override public void controlResized(ControlEvent e) { if(valid()) { ImageData buffer = AudioPanel.this.buffer.get(); this.buffer.set(buffer.scaledTo(canvasUI.getSize().x, buffer.height)); x = 0; } }
public void controlResized(ControlEvent e) { inControlResized = true; int treeWidth = computeMaximumWidthOfAllColumns(); int firstColWidth = Math.round(Math.round(firstColumnPercentageWidth * treeWidth)); int secondColWidth = treeWidth - firstColWidth; column[0].setWidth(firstColWidth); column[1].setWidth(secondColWidth); inControlResized = false; }
private void createRelationTabItem(CTabFolder folder) { CTabItem tbtmMain = new CTabItem(folder, SWT.NONE); tbtmMain.setText("Relations"); tbtmMain.setData("relation", "relation"); final ScrolledComposite scrollComposite = new ScrolledComposite(folder, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); final Composite relationsComp = new Composite(scrollComposite, SWT.NONE); tbtmMain.setControl(scrollComposite); scrollComposite.setContent(relationsComp); scrollComposite.setExpandVertical(true); scrollComposite.setExpandHorizontal(true); scrollComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle r = scrollComposite.getClientArea(); scrollComposite.setMinSize(relationsComp.computeSize(r.width, SWT.DEFAULT)); } }); relationsComp.setLayout(new GridLayout( BTSUIConstants.PASSPORT_COLUMN_NUMBER, true)); ((GridLayout) relationsComp.getLayout()).marginWidth = 0; ((GridLayout) relationsComp.getLayout()).marginHeight = 0; }
private void createIdentifiersTabItem(CTabFolder folder) { CTabItem tbtmMain = new CTabItem(folder, SWT.NONE); tbtmMain.setText("IDs"); tbtmMain.setToolTipText("External Identifiers"); tbtmMain.setData("id", "id"); final ScrolledComposite scrollComposite = new ScrolledComposite(folder, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); final Composite idsComp = new Composite(scrollComposite, SWT.NONE); tbtmMain.setControl(scrollComposite); scrollComposite.setContent(idsComp); scrollComposite.setExpandVertical(true); scrollComposite.setExpandHorizontal(true); scrollComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle r = scrollComposite.getClientArea(); scrollComposite.setMinSize(idsComp.computeSize(r.width, SWT.DEFAULT)); } }); idsComp.setLayout(new GridLayout( BTSUIConstants.PASSPORT_COLUMN_NUMBER, true)); ((GridLayout) idsComp.getLayout()).marginWidth = 0; ((GridLayout) idsComp.getLayout()).marginHeight = 0; }
@Override public void controlResized(ControlEvent e) { // Update the current size. size.set(getSize()); // Trigger an update to the client. refresh(); }
@Override public void controlResized(ControlEvent ignored) { prevShellSize = shellSize; shellSize = parentShell.getSize(); if(!checkingMaximize) { checkingMaximize = true; parentShell.getDisplay().timerExec(100, new CheckMaximizeThread()); } }