org.eclipse.swt.events.ControlAdapter Java Examples
The following examples show how to use
org.eclipse.swt.events.ControlAdapter.
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: MultiScope_ScopeWithDataAndProgression2Channels_2.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Create contents of the window. */ protected static void createContents() { shell = new Shell(); shell.setText("Nebula Oscilloscope"); shell.setLayout(new FillLayout()); // Create a single channel scope final Oscilloscope scope = new Oscilloscope(2, shell, SWT.NONE); scope.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { scope.setProgression(0, ((Oscilloscope) e.widget).getSize().x); scope.setProgression(1, ((Oscilloscope) e.widget).getSize().x); } }); scope.addStackListener(0, getStackAdapter()); scope.addStackListener(1, getStackAdapter()); scope.getDispatcher(0).dispatch(); }
Example #2
Source File: SWTUtil.java From arx with Apache License 2.0 | 6 votes |
/** * Tries to fix a bug when resizing sash forms in OSX * @param sash */ public static void fixOSXSashBug(final SashForm sash) { // Only if on OSX if (isMac()) { // Listen for resize event in first composite for (Control c : sash.getChildren()) { if (c instanceof Composite) { // In case of resize, redraw the sash form c.addControlListener(new ControlAdapter(){ @Override public void controlResized(ControlEvent arg0) { sash.redraw(); } }); return; } } } }
Example #3
Source File: AdvancedPropertySection.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void createControls(Composite parent, final TabbedPropertySheetPage atabbedPropertySheetPage) { super.createControls(parent, atabbedPropertySheetPage); Composite composite = getWidgetFactory() .createFlatFormComposite(parent); page = new PropertySheetPage(); page.createControl(composite); FormData data = new FormData(); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); page.getControl().setLayoutData(data); page.getControl().addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { atabbedPropertySheetPage.resizeScrolledComposite(); } }); }
Example #4
Source File: TableLayoutComposite.java From Pydev 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: 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 #6
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 #7
Source File: ScrollClientComposite.java From ice with Eclipse Public License 1.0 | 6 votes |
/** * Creates a {@code ControlListener} to listen for resize events from the * {@link #scrolledAncestor}. When triggered, it causes the horizontal * scroll bar to be re-adjusted. */ private void createResizeListener() { scrolledAncestor.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { // Recompute the child layouts. We should flush the layout cache // if the container is too big to properly fit inside. Without // the occasional call reflow(true), the default "preferred" // size of the container would take over and the computeSize() // method above will not be called. scrolledAncestor.reflow(getSize().x >= getAvailableWidth()); // Note: There is a bug where reflowing does not get rid of the // horizontal scrollbar when this ScrollClientComposite is // created. If you shrink the scrolled ancestor a little and // then grow it, the horizontal scroll will disappear, // presumably due to caching sizes. } }); return; }
Example #8
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 #9
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 #10
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 #11
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 #12
Source File: HeaderPage.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Setup 2 column layout. * * @param managedForm the managed form * @param w1 the w 1 * @param w2 the w 2 * @return the form 2 panel */ public Form2Panel setup2ColumnLayout(IManagedForm managedForm, int w1, int w2) { final ScrolledForm sform = managedForm.getForm(); final Composite form = sform.getBody(); form.setLayout(new GridLayout(1, false)); // this is required ! Composite xtra = toolkit.createComposite(form); xtra.setLayout(new GridLayout(1, false)); xtra.setLayoutData(new GridData(GridData.FILL_BOTH)); Control c = xtra.getParent(); while (!(c instanceof ScrolledComposite)) c = c.getParent(); ((GridData) xtra.getLayoutData()).widthHint = c.getSize().x; ((GridData) xtra.getLayoutData()).heightHint = c.getSize().y; sashForm = new SashForm(xtra, SWT.HORIZONTAL); sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); // needed leftPanel = newComposite(sashForm); ((GridLayout) leftPanel.getLayout()).marginHeight = 5; ((GridLayout) leftPanel.getLayout()).marginWidth = 5; rightPanel = newComposite(sashForm); ((GridLayout) rightPanel.getLayout()).marginHeight = 5; ((GridLayout) rightPanel.getLayout()).marginWidth = 5; sashForm.setWeights(new int[] { w1, w2 }); leftPanelPercent = (float) w1 / (float) (w1 + w2); rightPanelPercent = (float) w2 / (float) (w1 + w2); rightPanel.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { setSashFormWidths(); } }); return new Form2Panel(form, leftPanel, rightPanel); }
Example #13
Source File: ComponentResponsiveLayout.java From arx with Apache License 2.0 | 5 votes |
/** * 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(); } } } }); }
Example #14
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 #15
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 #16
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 #17
Source File: GridColumn_Test.java From nebula with Eclipse Public License 2.0 | 5 votes |
@Test public void testAddRemoveControlListener() { ControlListener listener = new ControlAdapter() { }; assertFalse( column.isListening( SWT.Move ) ); assertFalse( column.isListening( SWT.Resize ) ); column.addControlListener( listener ); assertTrue( column.isListening( SWT.Move ) ); assertTrue( column.isListening( SWT.Resize ) ); column.removeControlListener( listener ); assertFalse( column.isListening( SWT.Move ) ); assertFalse( column.isListening( SWT.Resize ) ); }
Example #18
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 #19
Source File: SwtMapPane.java From gama with GNU General Public License v3.0 | 5 votes |
/** * Constructor - creates an instance of JMapPane with the given renderer and map context. * * @param renderer * a renderer object * */ public SwtMapPane(final Composite parent, final int style, final GTRenderer renderer, final MapContent content) { super(parent, style); white = getDisplay().getSystemColor(SWT.COLOR_WHITE); yellow = getDisplay().getSystemColor(SWT.COLOR_YELLOW); addListener(SWT.Paint, this); addListener(SWT.MouseDown, this); addListener(SWT.MouseUp, this); imageOrigin = new Point(0, 0); redrawBaseImage = true; setRenderer(renderer); setMapContent(content); this.addMouseListener(this); this.addMouseMoveListener(this); addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent e) { curPaintArea = getVisibleRect(); doSetDisplayArea(SwtMapPane.this.content.getViewport().getBounds()); } }); }
Example #20
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 #21
Source File: TreePropertySection.java From ice with Eclipse Public License 1.0 | 4 votes |
/** * This operation draws the (initial) controls in the properties view based * on the input. In this case, there are initially no widgets to prepare. */ @Override public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { super.createControls(parent, aTabbedPropertySheetPage); // Get the default background color. Color backgroundColor = parent.getBackground(); // Create a section for the data composites. section = getWidgetFactory().createSection(parent, ExpandableComposite.SHORT_TITLE_BAR | Section.DESCRIPTION); section.setText("Node properties"); section.setDescription("All properties available for " + "this node can be modified here."); section.setBackground(backgroundColor); // Create the Composite that contains all DataComponentComposites. final Composite client = new Composite(section, SWT.NONE); GridLayout clientLayout = new GridLayout(2, false); // Set the margins and spacing based on the tabbed property constants. clientLayout.marginLeft = ITabbedPropertyConstants.HMARGIN; clientLayout.marginRight = ITabbedPropertyConstants.HMARGIN; clientLayout.marginTop = ITabbedPropertyConstants.VMARGIN; clientLayout.marginBottom = ITabbedPropertyConstants.VMARGIN; clientLayout.horizontalSpacing = ITabbedPropertyConstants.HSPACE; clientLayout.verticalSpacing = ITabbedPropertyConstants.VSPACE; client.setLayout(clientLayout); // Make the background of the section client white unless ICE is in // debug mode. if (System.getProperty("DebugICE") == null) { client.setBackground(backgroundColor); } else { client.setBackground( Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } // Set the client area for the section. section.setClient(client); // Get the property viewer's ScrolledComposite and its first Composite // (its "client" Composite). scrollCompositeClient = section.getParent().getParent().getParent() .getParent(); scrollComposite = (ScrolledComposite) scrollCompositeClient.getParent(); // Add a listener to resize the Section's properties and update the // ScrollComposite's minimum bounds correctly based on the displayed // properties. scrollComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { resizePropertyView(); } }); // Create the type Combo Composite. typeComposite = createTypeComposite(client); GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false); gridData.horizontalSpan = 2; typeComposite.setLayoutData(gridData); // Refresh the contents of the type Combo and its containing Composite. refreshTypeWidgets(); // Create the table of properties. tableViewer = createTableViewer(client); // Set the table's layout data so it occupies all spare space in the // property section client. tableViewer.getControl() .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Create the add/delete buttons. Composite buttonComposite = createButtons(client); // The button Composite shouldn't grab any space. Align it along the // center and top of the space to the right of the table. buttonComposite .setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false)); return; }
Example #22
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 #23
Source File: PTWidgetTable.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * @see org.eclipse.nebula.widgets.opal.propertytable.AbstractPTWidget#buildWidget(org.eclipse.swt.widgets.Composite) */ @Override protected void buildWidget(final Composite parent) { table = new Table(parent, SWT.FULL_SELECTION); table.setLinesVisible(true); table.setHeaderVisible(true); table.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1)); final TableColumn propertyColumn = new TableColumn(table, SWT.NONE); propertyColumn.setText(ResourceManager.getLabel(ResourceManager.PROPERTY)); final TableColumn valueColumn = new TableColumn(table, SWT.NONE); valueColumn.setText(ResourceManager.getLabel(ResourceManager.VALUE)); fillData(); table.addControlListener(new ControlAdapter() { /** * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent) */ @Override public void controlResized(final ControlEvent e) { final Rectangle area = table.getParent().getClientArea(); final Point size = table.computeSize(SWT.DEFAULT, SWT.DEFAULT); final ScrollBar vBar = table.getVerticalBar(); int width = area.width - table.computeTrim(0, 0, 0, 0).width - vBar.getSize().x; if (size.y > area.height + table.getHeaderHeight()) { // Subtract the scrollbar width from the total column width // if a vertical scrollbar will be required final Point vBarSize = vBar.getSize(); width -= vBarSize.x; } propertyColumn.pack(); valueColumn.setWidth(width - propertyColumn.getWidth()); table.removeControlListener(this); } }); table.addListener(SWT.Selection, event -> { if (table.getSelectionCount() == 0 || table.getSelection()[0] == null) { return; } updateDescriptionPanel(table.getSelection()[0].getData()); }); }
Example #24
Source File: PTWidgetTree.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * @see org.eclipse.nebula.widgets.opal.propertytable.AbstractPTWidget#buildWidget(org.eclipse.swt.widgets.Composite) */ @Override protected void buildWidget(final Composite parent) { tree = new Tree(parent, SWT.FULL_SELECTION); tree.setLinesVisible(true); tree.setHeaderVisible(true); tree.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 3, 1)); final TreeColumn propertyColumn = new TreeColumn(tree, SWT.NONE); propertyColumn.setText(ResourceManager.getLabel(ResourceManager.PROPERTY)); final TreeColumn valueColumn = new TreeColumn(tree, SWT.NONE); valueColumn.setText(ResourceManager.getLabel(ResourceManager.VALUE)); fillData(); tree.addControlListener(new ControlAdapter() { /** * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent) */ @Override public void controlResized(final ControlEvent e) { final Rectangle area = tree.getParent().getClientArea(); final Point size = tree.computeSize(SWT.DEFAULT, SWT.DEFAULT); final ScrollBar vBar = tree.getVerticalBar(); int width = area.width - tree.computeTrim(0, 0, 0, 0).width - vBar.getSize().x; if (size.y > area.height + tree.getHeaderHeight()) { // Subtract the scrollbar width from the total column width // if a vertical scrollbar will be required final Point vBarSize = vBar.getSize(); width -= vBarSize.x; } propertyColumn.pack(); valueColumn.setWidth(width - propertyColumn.getWidth()); tree.removeControlListener(this); } }); tree.addListener(SWT.Selection, event -> { if (tree.getSelectionCount() == 0 || tree.getSelection()[0] == null) { return; } updateDescriptionPanel(tree.getSelection()[0].getData()); }); }
Example #25
Source File: ProblemsDialog.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override protected Control createCustomArea(Composite parent) { Collection<T> input = getInput(); Assert.isNotNull(input); if (input.isEmpty()) { return super.createCustomArea(parent); } if(messageLabel != null) { GridData layoutData = (GridData) messageLabel.getLayoutData(); layoutData.verticalAlignment = SWT.CENTER; } TableViewer problemsViewer = new TableViewer(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION); problemsViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(600, 100).create()); problemsViewer.setContentProvider(ArrayContentProvider.getInstance()); problemsViewer.setComparator(getComparator()); TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(1, false)); problemsViewer.getTable().setLayout(layout); tableViewerColumn = new TableViewerColumn(problemsViewer, SWT.NONE); TypedLabelProvider<T> typedLabelProvider = getTypedLabelProvider(); Assert.isNotNull(typedLabelProvider); tableViewerColumn.setLabelProvider(new LabelProviderBuilder<T>() .withTextProvider(typedLabelProvider::getText) .withImageProvider(typedLabelProvider::getImage) .withTooltipProvider(typedLabelProvider::getToolTipText) .createColumnLabelProvider()); problemsViewer.getTable().getShell().addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { tableViewerColumn.getColumn().pack(); } }); problemsViewer.setInput(input); ColumnViewerToolTipSupport.enableFor(problemsViewer); return problemsViewer.getControl(); }
Example #26
Source File: JavadocView.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected void internalCreatePartControl(Composite parent) { try { fBrowser= new Browser(parent, SWT.NONE); fBrowser.setJavascriptEnabled(false); fIsUsingBrowserWidget= true; addLinkListener(fBrowser); fBrowser.addOpenWindowListener(new OpenWindowListener() { public void open(WindowEvent event) { event.required= true; // Cancel opening of new windows } }); } catch (SWTError er) { /* The Browser widget throws an SWTError if it fails to * instantiate properly. Application code should catch * this SWTError and disable any feature requiring the * Browser widget. * Platform requirements for the SWT Browser widget are available * from the SWT FAQ web site. */ IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); boolean doNotWarn= store.getBoolean(DO_NOT_WARN_PREFERENCE_KEY); if (WARNING_DIALOG_ENABLED) { if (!doNotWarn) { String title= InfoViewMessages.JavadocView_error_noBrowser_title; String message= InfoViewMessages.JavadocView_error_noBrowser_message; String toggleMessage= InfoViewMessages.JavadocView_error_noBrowser_doNotWarn; MessageDialogWithToggle dialog= MessageDialogWithToggle.openError(parent.getShell(), title, message, toggleMessage, false, null, null); if (dialog.getReturnCode() == Window.OK) store.setValue(DO_NOT_WARN_PREFERENCE_KEY, dialog.getToggleState()); } } fIsUsingBrowserWidget= false; } if (!fIsUsingBrowserWidget) { fText= new StyledText(parent, SWT.V_SCROLL | SWT.H_SCROLL); fText.setEditable(false); fPresenter= new HTMLTextPresenter(false); fText.addControlListener(new ControlAdapter() { /* * @see org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse.swt.events.ControlEvent) */ @Override public void controlResized(ControlEvent e) { doSetInput(fOriginalInput); } }); } initStyleSheet(); listenForFontChanges(); getViewSite().setSelectionProvider(new SelectionProvider(getControl())); }
Example #27
Source File: TabbedPropertySheetPage.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
/** * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) */ @Override public void createControl(Composite parent) { widgetFactory = new TabbedPropertySheetWidgetFactory(); tabbedPropertyComposite = new TabbedPropertyComposite(parent, widgetFactory, hasTitleBar); widgetFactory.paintBordersFor(tabbedPropertyComposite); tabbedPropertyComposite.setLayout(new FormLayout()); FormData formData = new FormData(); formData.left = new FormAttachment(0, 0); formData.right = new FormAttachment(100, 0); formData.top = new FormAttachment(0, 0); formData.bottom = new FormAttachment(100, 0); tabbedPropertyComposite.setLayoutData(formData); tabbedPropertyViewer = new TabbedPropertyViewer(tabbedPropertyComposite .getList()); tabbedPropertyViewer.setContentProvider(tabListContentProvider); tabbedPropertyViewer .setLabelProvider(new TabbedPropertySheetPageLabelProvider()); tabbedPropertyViewer .addSelectionChangedListener(new SelectionChangedListener()); tabbedPropertyComposite.getScrolledComposite().addControlListener( new ControlAdapter() { @Override public void controlResized(ControlEvent e) { resizeScrolledComposite(); } }); /** * Add a part activation listener. */ cachedWorkbenchWindow = getSite().getWorkbenchWindow(); cachedWorkbenchWindow.getPartService().addPartListener( partActivationListener); /** * Add a label provider change listener. */ if (hasTitleBar) { registry.getLabelProvider().addListener(this); } }
Example #28
Source File: ProgressReporterWindow.java From BiglyBT with GNU General Public License v2.0 | 4 votes |
private void createControls() { /* * Sets up the shell */ int shellStyle = SWT.DIALOG_TRIM | SWT.RESIZE; if ((style & MODAL) != 0) { shellStyle |= SWT.APPLICATION_MODAL; } shell = ShellFactory.createMainShell(shellStyle); shell.setText(MessageText.getString("progress.window.title")); Utils.setShellIcon(shell); GridLayout gLayout = new GridLayout(); gLayout.marginHeight = 0; gLayout.marginWidth = 0; shell.setLayout(gLayout); /* * Using ScrolledComposite with only vertical scroll */ scrollable = new ScrolledComposite(shell, SWT.V_SCROLL); scrollable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); /* * Main content composite where panels will be created */ scrollChild = new Composite(scrollable, SWT.NONE); GridLayout gLayoutChild = new GridLayout(); gLayoutChild.marginHeight = 0; gLayoutChild.marginWidth = 0; gLayoutChild.verticalSpacing = 0; scrollChild.setLayout(gLayoutChild); scrollable.setContent(scrollChild); scrollable.setExpandVertical(true); scrollable.setExpandHorizontal(true); /* * Re-adjust scrollbar setting when the window resizes */ scrollable.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle r = scrollable.getClientArea(); scrollable.setMinSize(scrollChild.computeSize(r.width, SWT.DEFAULT)); } }); /* * On closing remove all reporters that was handled by this instance of the window from the registry */ shell.addListener(SWT.Close, new Listener() { @Override public void handleEvent(Event event) { /* * Remove this class as a listener to the disposal event for the panels or else * as the shell is closing the panels would be disposed one-by-one and each one would * force a re-layouting of the shell. */ Control[] controls = scrollChild.getChildren(); for (int i = 0; i < controls.length; i++) { if (controls[i] instanceof ProgressReporterPanel) { ((ProgressReporterPanel) controls[i]).removeDisposeListener(ProgressReporterWindow.this); } } /* * Removes all the reporters that is still handled by this window */ for (int i = 0; i < pReporters.length; i++) { reportersRegistry.remove(pReporters[i]); } isShowingEmpty = false; } }); if (pReporters.length == 0) { createEmptyPanel(); } else { createPanels(); } /* * Shows the toolbar if specified */ if ((style & SHOW_TOOLBAR) != 0) { createToolbar(); } isAutoRemove = COConfigurationManager.getBooleanParameter("auto_remove_inactive_items"); }
Example #29
Source File: ExtractMethodComposite.java From Pydev with Eclipse Public License 1.0 | 4 votes |
private Composite createArgumentsTable(Composite parent) { final Composite argumentsComposite = new Composite(parent, SWT.NONE); FormLayout compositeLayout = new FormLayout(); GridData compositeLData = new GridData(GridData.FILL_BOTH); argumentsComposite.setLayoutData(compositeLData); argumentsComposite.setLayout(compositeLayout); argumentsTable = new Table(argumentsComposite, SWT.BORDER | SWT.FULL_SELECTION); FormData tableLData = new FormData(); tableLData.bottom = new FormAttachment(1000, 1000, 0); tableLData.left = new FormAttachment(0, 1000, 0); tableLData.right = new FormAttachment(1000, 1000, -80); tableLData.top = new FormAttachment(0, 1000, 4); argumentsTable.setLayoutData(tableLData); argumentsTable.setHeaderVisible(true); argumentsTable.setLinesVisible(true); nameColumn = new TableColumn(argumentsTable, SWT.NONE); nameColumn.setText(Messages.extractMethodArgumentName); createArgumentsButton(argumentsComposite); argumentsComposite.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Rectangle area = argumentsTable.getClientArea(); Point preferredSize = argumentsTable.computeSize(SWT.DEFAULT, SWT.DEFAULT); int width = area.width - 2 * argumentsTable.getBorderWidth(); if (preferredSize.y > area.height + argumentsTable.getHeaderHeight()) { Point vBarSize = argumentsTable.getVerticalBar().getSize(); width -= vBarSize.x; } Point oldSize = argumentsTable.getSize(); if (oldSize.x > area.width) { nameColumn.setWidth(width); argumentsTable.setSize(area.width, area.height); } else { argumentsTable.setSize(area.width, area.height); nameColumn.setWidth(width); } } }); argumentsComposite.notifyListeners(SWT.CONTROL, new Event()); return argumentsComposite; }
Example #30
Source File: SQLDataSetEditorPage.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Creates the composite, for displaying the list of available db objects * * @param parent */ private Control createDBMetaDataSelectionComposite( 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.setMinHeight( 500 ); sComposite.setMinWidth( 250 ); sComposite.addControlListener( new ControlAdapter( ) { public void controlResized( ControlEvent e ) { computeSize( ); } } ); boolean supportsSchema = false ; boolean supportsProcedure = false; if ( continueConnect ) { supportsSchema = JdbcMetaDataProvider.getInstance( ) .isSupportSchema( ); supportsProcedure = JdbcMetaDataProvider.getInstance( ) .isSupportProcedure( ); } tablescomposite = new Composite( sComposite, SWT.NONE ); tablescomposite.setLayout( new GridLayout( ) ); GridData data = new GridData( GridData.FILL_BOTH ); data.grabExcessVerticalSpace = true; tablescomposite.setLayoutData( data ); createDBObjectTree( tablescomposite ); createObjectTreeMenu(); createSchemaFilterComposite( supportsSchema, supportsProcedure, tablescomposite ); createSQLOptionGroup( tablescomposite ); addDragSupportToTree( ); // bidi_hcg: pass value of metadataBidiFormatStr addFetchDbObjectListener( metadataBidiFormatStr ); sComposite.setContent( tablescomposite ); return tablescomposite; }