org.eclipse.swt.events.ControlEvent Java Examples
The following examples show how to use
org.eclipse.swt.events.ControlEvent.
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: FontSizer.java From gama with GNU General Public License v3.0 | 6 votes |
/** * @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); }
Example #2
Source File: SelectableControlList.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * 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); }
Example #3
Source File: PaletteEditorComposite.java From birt with Eclipse Public License 1.0 | 6 votes |
public void controlResized( ControlEvent arg0 ) { updateScrollBar( ); if ( imgBuffer != null ) { gc.dispose( ); imgBuffer.dispose( ); gc = null; imgBuffer = null; } if ( coEditor != null ) { final Rectangle rCA = coPaletteEntries.getClientArea( ); coEditor.setSize( rCA.width - 6, ITEM_HEIGHT - 6 ); } }
Example #4
Source File: TableLayoutComposite.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * 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); } }); }
Example #5
Source File: ListDialogField.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * 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); } }); }
Example #6
Source File: DetailsTabView.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * Create the composite. * @param parent * @param style */ public DetailsTabView() { super(SWT.NONE); setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); FillLayout fillLayout = new FillLayout(SWT.HORIZONTAL); fillLayout.marginWidth = 5; fillLayout.marginHeight = 5; setLayout(fillLayout); scrolledComposite = new ScrolledComposite(this, SWT.BORDER | SWT.V_SCROLL); scrolledComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { ScrolledComposites.updateOnlyVerticalScrollableComposite(scrolledComposite); } }); scrolledComposite.setAlwaysShowScrollBars(true); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); }
Example #7
Source File: VisualInterfaceViewer.java From neoscada with Eclipse Public License 1.0 | 5 votes |
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; }
Example #8
Source File: ChartPreview.java From birt with Eclipse Public License 1.0 | 5 votes |
public void controlResized( ControlEvent e ) { if ( preview != null && !preview.isDisposed( ) ) { updateBuffer( ); preview.redraw( ); } }
Example #9
Source File: PreviewPage.java From birt with Eclipse Public License 1.0 | 5 votes |
public void buildUI( Composite parent ) { container = new ScrolledComposite( parent, SWT.V_SCROLL | SWT.H_SCROLL ); container.setLayoutData( new GridData( GridData.FILL_BOTH ) ); ( (ScrolledComposite) container ).setExpandHorizontal( true ); ( (ScrolledComposite) container ).setExpandVertical( true ); container.addControlListener( new ControlAdapter( ) { public void controlResized( ControlEvent e ) { computeSize( ); } } ); composite = new Composite( container, SWT.NONE ); composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); if ( sections == null ) sections = new SortMap( ); composite.setLayout( WidgetUtil.createGridLayout( 1 ) ); previewSection = new PreviewSection( provider.getDisplayName( ), composite, true, isTabbed ); previewSection.setPreview( preview ); previewSection.setProvider( provider ); previewSection.setHeight( 160 ); previewSection.setFillPreview( true ); addSection( PageSectionId.PREVIEW_PREVIEW, previewSection ); createSections( ); layoutSections( ); ( (ScrolledComposite) container ).setContent( composite ); }
Example #10
Source File: CvwRestPage.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
@Override public void controlResized(ControlEvent event) { if (event.widget == _tableViewer.getTable()) { Table table = (Table) event.widget; table.getColumn(2).setWidth(table.getClientArea().width - table.getColumn(0).getWidth() - table.getColumn(1).getWidth()); } }
Example #11
Source File: AngleSelectorComposite.java From birt with Eclipse Public License 1.0 | 5 votes |
public void controlResized(ControlEvent e) { if (imgBuffer != null) { gcBuffer.dispose(); imgBuffer.dispose(); gcBuffer = null; imgBuffer = null; } }
Example #12
Source File: InternalCompositeTable.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void controlResized(ControlEvent e) { Point size = hScroller.getSize(); int preferredWidth = controlHolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x; if (preferredWidth > size.x && !isHSliderVisible()) { setHSliderVisible(true); } if (preferredWidth <= size.x && isHSliderVisible()) { setHSliderVisible(false); } if (preferredWidth <= size.x) { controlHolder.setBounds(0, 0, size.x, size.y); return; } if (isHSliderVisible()) { hSlider.setMaximum(preferredWidth); hSlider.setPageIncrement(size.x); hSlider.setThumb(preferredWidth - (preferredWidth - size.x)); int currentSelection = hSlider.getSelection(); if (preferredWidth - currentSelection < size.x) { hSlider.setSelection(preferredWidth - size.x); } } hSlider.notifyListeners(SWT.Selection, new Event()); }
Example #13
Source File: SWTUtil.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void controlResized(ControlEvent e) { // update the internal bounds Shell shell = (Shell) e.getSource(); mMaximized = shell.getMaximized(); mMinimized = shell.getMinimized(); // only store new bounds if the shell is not minimized or maximized. // This way the original size (before minimizing/maximizing will be // remembered. if (!mMinimized && !mMaximized) { mNewBounds = shell.getBounds(); } }
Example #14
Source File: HeaderLayout.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void controlResized(ControlEvent e) { if (lastWidths == null) return; wasResized = true; if (!layingOut) { layingOut = true; try { TableColumn tableColumn = (TableColumn) e.widget; AbstractNativeHeader header = asHeader(tableColumn.getParent().getParent()); adjustWeights(header, tableColumn); storeLastWidths(tableColumn.getParent()); } finally { layingOut = false; } } }
Example #15
Source File: HeaderLayout.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void controlMoved(ControlEvent e) { // Eat the move event that is fired after resize events if (wasResized) { wasResized = false; return; } Table table = header.headerTable; fireColumnMovedEvent(table.getColumnOrder()); storeLastWidths(table); }
Example #16
Source File: ErrorTraceTreeViewer.java From tlaplus with MIT License | 5 votes |
@Override public void controlResized(final ControlEvent e) { inControlResized = true; final int treeWidth = computeMaximumWidthOfAllColumns(); final int firstColWidth = Math.round(Math.round(firstColumnPercentageWidth * treeWidth)); final int secondColWidth = treeWidth - firstColWidth; columns[0].setWidth(firstColWidth); columns[1].setWidth(secondColWidth); inControlResized = false; }
Example #17
Source File: FilterBugsDialog.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
private ContainerCheckedTreeViewer createTree(Composite parent, int style) { final ContainerCheckedTreeViewer viewer = new ContainerCheckedTreeViewer(parent, style | SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.RESIZE) { /** * Overriden to re-set checked state of elements after filter change */ @Override public void refresh(boolean updateLabels) { super.refresh(updateLabels); setCheckedElements(checkedElements); } }; viewer.setContentProvider(contentProvider); viewer.setLabelProvider(labelProvider); viewer.setInput(allowedTypes); Object[] preselected = getPreselected(); viewer.setCheckedElements(preselected); viewer.addPostSelectionChangedListener(new TreeSelectionChangedListener()); viewer.getTree().addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { updateDescription((IStructuredSelection) viewer.getSelection()); } }); viewer.addCheckStateListener(new TreeCheckStateListener()); return viewer; }
Example #18
Source File: SWTBotUtils.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Maximize a workbench part and wait for one of its controls to be resized. * Calling this a second time will "un-maximize" the part. * * @param partReference * the {@link IWorkbenchPartReference} which contains the control * @param controlBot * a control that should be resized */ public static void maximize(IWorkbenchPartReference partReference, AbstractSWTBotControl<?> controlBot) { final AtomicBoolean controlResized = new AtomicBoolean(); Control control = controlBot.widget; assertNotNull(control); UIThreadRunnable.syncExec(new VoidResult() { @Override public void run() { control.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { control.removeControlListener(this); controlResized.set(true); } }); } }); IWorkbenchPart part = partReference.getPart(false); assertNotNull(part); maximize(part); new SWTBot().waitUntil(new DefaultCondition() { @Override public boolean test() throws Exception { return controlResized.get(); } @Override public String getFailureMessage() { return "Control was not resized"; } }); }
Example #19
Source File: SwtXYChartViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public void controlResized(@Nullable ControlEvent e) { /* Refresh titles */ refreshDisplayTitles(); /* Refresh the Axis labels to fit the current chart size */ refreshDisplayLabels(); /* Relocate the close button */ fCloseButton.setLocation(fChart.getSize().x - fCloseButton.getSize().x - CLOSE_BUTTON_MARGIN, CLOSE_BUTTON_MARGIN); }
Example #20
Source File: TmfRawEventViewer.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public void controlResized(ControlEvent event) { int areaHeight = fScrolledComposite.getSize().y; if (fScrolledComposite.getHorizontalBar() != null) { areaHeight -= fScrolledComposite.getHorizontalBar().getSize().y; } int lineHeight = fStyledText.getLineHeight(); fNumVisibleLines = Math.max((areaHeight + lineHeight - 1) / lineHeight, 1); if (fBottomContext != null) { loadLineData(); fillTextArea(); } }
Example #21
Source File: OptionsConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void createScrolledArea() { fScrolledPageContent= new ScrolledPageContent(fParentComposite); fScrolledPageContent.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { fScrolledPageContent.getVerticalBar().setVisible(true); } }); }
Example #22
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public void controlMoved(ControlEvent e) { int[] order = fTable.getColumnOrder(); if (order[0] != MARGIN_COLUMN_INDEX) { for (int i = order.length - 1; i > 0; i--) { if (order[i] == MARGIN_COLUMN_INDEX) { order[i] = order[i - 1]; order[i - 1] = MARGIN_COLUMN_INDEX; } } fTable.setColumnOrder(order); } fColumnOrder = order; fTable.layout(); }
Example #23
Source File: TmfEventsTable.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public void controlResized(ControlEvent e) { TableColumn column = (TableColumn) e.widget; if (fPacking) { /* Don't update column width if resize due to packing */ return; } if (column.getResizable() && !isExpanded(column)) { int index = (int) column.getData(Key.INDEX); fColumnSize[index] = column.getWidth(); /* Turns off AutoFit */ column.setData(Key.WIDTH, fColumnSize[index]); } }
Example #24
Source File: AbstractCubePropertyPage.java From birt with Eclipse Public License 1.0 | 5 votes |
public Control createPageControl( Composite parent ) { sComposite = new ScrolledComposite( parent, SWT.H_SCROLL | SWT.V_SCROLL ); sComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); sComposite.setExpandHorizontal( true ); sComposite.setExpandVertical( true ); sComposite.addControlListener( new ControlAdapter( ) { public void controlResized( ControlEvent e ) { computeSize( ); } } ); composite = new Composite( sComposite, SWT.NONE ); GridLayout layout = new GridLayout( ); layout.marginWidth = 0; layout.marginHeight = 0; composite.setLayout( layout ); if ( getPageDescription( ) != null ) { pageDescription = new Label( composite, SWT.NONE ); pageDescription.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); pageDescription.setText( getPageDescription( ) ); pageDescription.setToolTipText( getPageDescription( ) ); } GridData data = new GridData( GridData.FILL_BOTH ); Control control = createContents( composite ); control.setLayoutData( data ); sComposite.setContent( composite ); return sComposite; }
Example #25
Source File: RenameInformationPopup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void controlResized(ControlEvent e) { updatePopupLocation(true); updateVisibility(); //only for hiding outside editor area }
Example #26
Source File: ExpressionBuilder.java From birt with Eclipse Public License 1.0 | 4 votes |
private void initTable( TableViewer tableViewer, boolean leafOnly ) { final Table table = tableViewer.getTable( ); GridData gd = new GridData( GridData.FILL_BOTH ); gd.heightHint = 150; table.setLayoutData( gd ); table.setToolTipText( null ); final TableColumn column = new TableColumn( table, SWT.NONE ); column.setWidth( 200 ); table.getShell( ).addControlListener( new ControlAdapter( ) { public void controlResized( ControlEvent e ) { Display.getCurrent( ).asyncExec( new Runnable( ) { public void run( ) { if ( column != null && !column.isDisposed( ) ) { column.setWidth( table.getSize( ).x > 204 ? table.getSize( ).x - 4 : 200 ); } } } ); } } ); table.addMouseTrackListener( new MouseTrackAdapter( ) { public void mouseHover( MouseEvent event ) { Widget widget = event.widget; if ( widget == table ) { Point pt = new Point( event.x, event.y ); TableItem item = table.getItem( pt ); if ( item == null ) { table.setToolTipText( null ); } else { table.setToolTipText( provider.getTooltipText( item.getData( ) ) ); } } } } ); tableViewer.setLabelProvider( new ExpressionLabelProvider( ) ); tableViewer.setContentProvider( new TableContentProvider( tableViewer, leafOnly ) ); tableViewer.addSelectionChangedListener( selectionListener ); tableViewer.addDoubleClickListener( doubleClickListener ); }
Example #27
Source File: RenameInformationPopup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void addMoveSupport(final Shell popupShell, final Control movedControl) { movedControl.addMouseListener(new MouseAdapter() { @Override public void mouseDown(final MouseEvent downEvent) { if (downEvent.button != 1) { return; } final Point POPUP_SOURCE= popupShell.getLocation(); final StyledText textWidget= fEditor.getViewer().getTextWidget(); Point pSize= getExtent(); int originalSnapPosition= fSnapPosition; /* * Feature in Tracker: it is not possible to directly control the feedback, * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=121300 * and https://bugs.eclipse.org/bugs/show_bug.cgi?id=121298#c1 . * * Workaround is to have an offscreen rectangle for tracking mouse movement * and a manually updated rectangle for the actual drop target. */ final Tracker tracker= new Tracker(textWidget, SWT.NONE); final Point[] LOCATIONS= { textWidget.toControl(computePopupLocation(SNAP_POSITION_UNDER_RIGHT_FIELD)), textWidget.toControl(computePopupLocation(SNAP_POSITION_OVER_RIGHT_FIELD)), textWidget.toControl(computePopupLocation(SNAP_POSITION_UNDER_LEFT_FIELD)), textWidget.toControl(computePopupLocation(SNAP_POSITION_OVER_LEFT_FIELD)), textWidget.toControl(computePopupLocation(SNAP_POSITION_LOWER_RIGHT)) }; final Rectangle[] DROP_TARGETS= { Geometry.createRectangle(LOCATIONS[0], pSize), Geometry.createRectangle(LOCATIONS[1], pSize), new Rectangle(LOCATIONS[2].x, LOCATIONS[2].y + HAH, pSize.x, pSize.y), Geometry.createRectangle(LOCATIONS[3], pSize), Geometry.createRectangle(LOCATIONS[4], pSize) }; final Rectangle MOUSE_MOVE_SOURCE= new Rectangle(1000000, 0, 0, 0); tracker.setRectangles(new Rectangle[] { MOUSE_MOVE_SOURCE, DROP_TARGETS[fSnapPosition] }); tracker.setStippled(true); ControlListener moveListener= new ControlAdapter() { /* * @see org.eclipse.swt.events.ControlAdapter#controlMoved(org.eclipse.swt.events.ControlEvent) */ @Override public void controlMoved(ControlEvent moveEvent) { Rectangle[] currentRects= tracker.getRectangles(); final Rectangle mouseMoveCurrent= currentRects[0]; Point popupLoc= new Point( POPUP_SOURCE.x + mouseMoveCurrent.x - MOUSE_MOVE_SOURCE.x, POPUP_SOURCE.y + mouseMoveCurrent.y - MOUSE_MOVE_SOURCE.y); popupShell.setLocation(popupLoc); Point ePopupLoc= textWidget.toControl(popupLoc); int minDist= Integer.MAX_VALUE; for (int snapPos= 0; snapPos < DROP_TARGETS.length; snapPos++) { int dist= Geometry.distanceSquared(ePopupLoc, LOCATIONS[snapPos]); if (dist < minDist) { minDist= dist; fSnapPosition= snapPos; fSnapPositionChanged= true; currentRects[1]= DROP_TARGETS[snapPos]; } } tracker.setRectangles(currentRects); } }; tracker.addControlListener(moveListener); boolean committed= tracker.open(); tracker.close(); tracker.dispose(); if (committed) { getDialogSettings().put(SNAP_POSITION_KEY, fSnapPosition); } else { fSnapPosition= originalSnapPosition; fSnapPositionChanged= true; } updatePopupLocation(true); activateEditor(); } }); }
Example #28
Source File: AngleSelectorComposite.java From birt with Eclipse Public License 1.0 | 4 votes |
public void controlMoved(ControlEvent e) { // NOT USED }
Example #29
Source File: ContentAssistant.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent) */ public void controlResized(ControlEvent e) { hide(); }
Example #30
Source File: CustomPreviewTable.java From birt with Eclipse Public License 1.0 | 4 votes |
public void controlMoved( ControlEvent e ) { }