org.eclipse.swt.widgets.Layout#org.eclipse.swt.events.ControlAdapter源码实例Demo

下面列出了org.eclipse.swt.widgets.Layout#org.eclipse.swt.events.ControlAdapter 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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();

}
 
源代码2 项目: scava   文件: DetailsTabView.java
/**
 * 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);
}
 
源代码3 项目: xtext-eclipse   文件: ListDialogField.java
/**
 * 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);
		}
	});
}
 
/**
 * 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);
}
 
源代码5 项目: gama   文件: FontSizer.java
/**
 * @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);

}
 
/**
 * 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);
           }
       });
}
 
源代码7 项目: ice   文件: ScrollClientComposite.java
/**
 * 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;
}
 
源代码8 项目: Pydev   文件: TableLayoutComposite.java
/**
 * 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);
        }
    });
}
 
源代码9 项目: bonita-studio   文件: AdvancedPropertySection.java
@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();
		}
	});
}
 
源代码10 项目: arx   文件: SWTUtil.java
/**
 * 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;
            }
        }
    }
}
 
源代码11 项目: nebula   文件: GridColumn_Test.java
@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 ) );
}
 
源代码12 项目: neoscada   文件: VisualInterfaceViewer.java
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;
}
 
源代码13 项目: spotbugs   文件: FilterBugsDialog.java
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;
}
 
源代码14 项目: tracecompass   文件: SWTBotUtils.java
/**
 * 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";
        }
    });
}
 
源代码15 项目: gama   文件: SwtMapPane.java
/**
 * 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());
		}
	});

}
 
private void createScrolledArea() {
	fScrolledPageContent= new ScrolledPageContent(fParentComposite);
	fScrolledPageContent.addControlListener(new ControlAdapter() {
		@Override
		public void controlResized(ControlEvent e) {
			fScrolledPageContent.getVerticalBar().setVisible(true);
		}
	});
}
 
源代码17 项目: birt   文件: AbstractCubePropertyPage.java
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;
}
 
源代码18 项目: birt   文件: PreviewPage.java
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 );
}
 
源代码19 项目: arx   文件: ComponentResponsiveLayout.java
/**
 * 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();
                }
            }
        }
    });
}
 
源代码20 项目: uima-uimaj   文件: HeaderPage.java
/**
 * 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);
}
 
源代码21 项目: nebula   文件: GridWithTextWrapping.java
public static void main(String[] args) {
	Display display = new Display();
	Shell shell = new Shell(display);
	shell.setLayout(new FillLayout());

	fGrid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL);

	fGrid.setTreeLinesVisible(false);
	fGrid.setWordWrapHeader(true);
	fGrid.setHeaderVisible(true);
	GridColumn column = new GridColumn(fGrid, SWT.NONE);
	column.setWordWrap(true);
	column.setText("Column 1");
	column.setWidth(100);
	GridColumn column2 = new GridColumn(fGrid, SWT.NONE);
	column2.setText("Column 2");
	column2.setWidth(100);

	GridItem item1 = new GridItem(fGrid, SWT.NONE);
	item1.setText("First Item. First Item. First Item.");
	item1.setText(1, "xxxxxxx");

	System.out.println("item2");
	final GridItem item2 = new GridItem(fGrid, SWT.NONE);
	item2.setText("This cell contains a lot of text. This cell contains a lot of text");
	item2.setText(1, "xxxxxxx");
	column.addControlListener(new ControlAdapter() {
		@Override
		public void controlResized(ControlEvent e) {
			calculateHeight();
		}
	});

	GridItem item3 = new GridItem(fGrid, SWT.NONE);
	item3.setText("Third Item. Third Item. Third Item. Third Item. Third Item. ");
	item3.setText(1, "xxxxxxx");

	calculateHeight();

	shell.setSize(200, 200);
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch())
			display.sleep();
	}
	display.dispose();
}
 
源代码22 项目: nebula   文件: PTWidgetTable.java
/**
 * @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());
	});

}
 
源代码23 项目: nebula   文件: PTWidgetTree.java
/**
 * @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());
	});

}
 
源代码24 项目: BiglyBT   文件: ProgressReporterWindow.java
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");

}
 
源代码25 项目: typescript.java   文件: RenameInformationPopup.java
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();
		}
	});
}
 
源代码26 项目: tracecompass   文件: TimeGraphLegend.java
/**
 * Creates a states group
 *
 * @param composite
 *            the parent composite
 * @since 3.3
 */
private void addStateGroups(Composite composite) {

    StateItem[] stateTable = fProvider.getStateTable();
    if (stateTable == null) {
        return;
    }
    List<StateItem> stateItems = Arrays.asList(stateTable);
    Collection<StateItem> linkStates = Collections2.filter(stateItems, TimeGraphLegend::isLinkState);

    ScrolledComposite sc = new ScrolledComposite(composite, SWT.V_SCROLL | SWT.H_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setLayout(GridLayoutFactory.swtDefaults().margins(200, 0).create());

    Composite innerComposite = new Composite(sc, SWT.NONE);
    fInnerComposite = innerComposite;
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    innerComposite.setLayoutData(gd);
    innerComposite.setLayout(new GridLayout());
    innerComposite.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            /*
             * Find the highest number of columns that fits in the new width
             */
            Point size = innerComposite.getSize();
            List<GridLayout> gridLayouts = getGridLayouts(innerComposite);
            Point minSize = new Point(0, 0);
            for (int columns = 8; columns > 0; columns--) {
                final int numColumns = columns;
                gridLayouts.forEach(gl -> gl.numColumns = numColumns);
                minSize = innerComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                if (minSize.x <= size.x) {
                    break;
                }
            }
            sc.setMinSize(0, minSize.y);
        }
    });

    sc.setContent(innerComposite);

    createStatesGroup(innerComposite);
    createLinkGroup(linkStates, innerComposite);

    sc.setMinSize(0, innerComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
}
 
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();
		}
	});
}
 
@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()));
}
 
源代码29 项目: birt   文件: SQLDataSetEditorPage.java
/**
 * 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;
}
 
源代码30 项目: birt   文件: ExpressionBuilder.java
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 );
}