org.eclipse.swt.widgets.Slider Java Examples

The following examples show how to use org.eclipse.swt.widgets.Slider. 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: XbaseInformationControl.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Tells whether the SWT Browser widget and hence this information control is available.
 * 
 * @param parent
 *            the parent component used for checking or <code>null</code> if none
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
	if (!fgAvailabilityChecked) {
		try {
			Browser browser = new Browser(parent, SWT.NONE);
			browser.dispose();

			fgIsAvailable = true;

			Slider sliderV = new Slider(parent, SWT.VERTICAL);
			Slider sliderH = new Slider(parent, SWT.HORIZONTAL);
			int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
			int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
			fgScrollBarSize = new Point(width, height);
			sliderV.dispose();
			sliderH.dispose();
		} catch (SWTError er) {
			fgIsAvailable = false;
		} finally {
			fgAvailabilityChecked = true;
		}
	}

	return fgIsAvailable;
}
 
Example #2
Source File: InternalCompositeTable.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Initialize the sliderHolder and slider. The SliderHolder is a Composite
 * that is responsible for showing and hiding the vertical slider upon
 * request.
 */
private void createVSliderHolder() {
	GridData gd = getVSliderGridData();
	vSliderHolder = new Composite(this, SWT.NULL);
	vSlider = new Slider(vSliderHolder, SWT.VERTICAL);
	vSlider.addSelectionListener(sliderSelectionListener);
	vSliderHolder.setLayout(new FillLayout());
	vSliderHolder.setLayoutData(gd);
	vSliderHolder.setTabList(new Control[] {});
}
 
Example #3
Source File: InternalCompositeTable.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Initialize the sliderHolder and slider. The SliderHolder is a Composite
 * that is responsible for showing and hiding the vertical slider upon
 * request.
 */
private void createHSliderHolder() {
	GridData gd = getHSliderGridData();
	hSliderHolder = new Composite(this, SWT.NULL);
	hSlider = new Slider(hSliderHolder, SWT.HORIZONTAL);
	hSlider.setMinimum(0);
	hSlider.setIncrement(20);
	hSlider.addSelectionListener(sliderSelectionListener);
	hSliderHolder.setLayout(new FillLayout());
	hSliderHolder.setLayoutData(gd);
	hSliderHolder.setTabList(new Control[] {});
	hSlider.addSelectionListener(hSliderSelectionListener);
}
 
Example #4
Source File: TmfRawEventViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void createSlider(int style) {
    fSlider = new Slider(this, SWT.VERTICAL);
    fSlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    fSlider.setValues(0, 0, SLIDER_MAX, SLIDER_MAX, 1, 1);
    fSlider.addSelectionListener(this);
    fSlider.addMouseListener(this);
    if ((style & SWT.V_SCROLL) == 0) {
        fSlider.setVisible(false);
    }
}
 
Example #5
Source File: TmfAbstractToolTipHandler.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static synchronized Point getScrollbarSize(Composite parent) {
    if (fScrollBarSize == null) {
        // Don't move these lines below the new Browser() line
        Slider sliderV = new Slider(parent, SWT.VERTICAL);
        Slider sliderH = new Slider(parent, SWT.HORIZONTAL);
        int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
        int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
        Point scrollBarSize = new Point(width, height);
        sliderV.dispose();
        sliderH.dispose();
        fScrollBarSize = scrollBarSize;
    }
    return fScrollBarSize;
}
 
Example #6
Source File: KernelTimeGraphViewTestBase.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test the vertical scroll bar position
 */
@Test
public void testVerticalScrollbar() {
    SWTBotView viewBot = openView();
    List<? extends @NonNull Slider> sliders = viewBot.bot().widgets(WidgetOfType.widgetOfType(Slider.class));
    assertTrue("The view has " + sliders.size() + " sliders", sliders.size() >= 2);
    Rectangle sliderRect = getBounds(sliders.get(VERTICAL_SCROLLBAR_INDEX));

    Rectangle timegraphRect = getBounds(viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)));
    assertEquals("Incorrect vertical slider start position", timegraphRect.width, sliderRect.x);
    assertEquals("Incorrect vertical slider height", timegraphRect.height, sliderRect.height);
}
 
Example #7
Source File: KernelTimeGraphViewTestBase.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test the horizontal scroll bar position
 */
@Test
public void testHorizontalScrollbar() {
    SWTBotView viewBot = openView();
    List<? extends @NonNull Slider> sliders = viewBot.bot().widgets(WidgetOfType.widgetOfType(Slider.class));
    assertTrue("The view has " + sliders.size() + " sliders", sliders.size() >= 2);
    Rectangle sliderRect = getBounds(sliders.get(HORIZONTAL_SCROLLBAR_INDEX));

    SWTBotTimeGraph tgBot = new SWTBotTimeGraph(viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)));
    Rectangle timegraphRect = getBounds(viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class)));
    assertEquals("Incorrect horizontal slider start position", timegraphRect.x + tgBot.getNameSpace(), sliderRect.x);
}
 
Example #8
Source File: CustomAbstractInformationControl.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private int getResizeHandleSize(Composite parent)
{
	if (fResizeHandleSize == -1)
	{
		Slider sliderV = new Slider(parent, SWT.VERTICAL);
		Slider sliderH = new Slider(parent, SWT.HORIZONTAL);
		int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
		int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
		sliderV.dispose();
		sliderH.dispose();
		fResizeHandleSize = Math.min(width, height);
	}

	return fResizeHandleSize;
}
 
Example #9
Source File: CustomBrowserInformationControl.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tells whether the SWT Browser widget and hence this information control is available.
 * 
 * @param parent
 *            the parent component used for checking or <code>null</code> if none
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent)
{
	if (!fgAvailabilityChecked)
	{
		try
		{
			Browser browser = new Browser(parent, SWT.NONE);
			browser.dispose();
			fgIsAvailable = true;

			Slider sliderV = new Slider(parent, SWT.VERTICAL);
			Slider sliderH = new Slider(parent, SWT.HORIZONTAL);
			int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
			int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
			fgScrollBarSize = new Point(width, height);
			sliderV.dispose();
			sliderH.dispose();
		}
		catch (SWTError er)
		{
			fgIsAvailable = false;
		}
		finally
		{
			fgAvailabilityChecked = true;
		}
	}

	return fgIsAvailable;
}
 
Example #10
Source File: ChartSlider.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected void placeComponents( int style )
{
	GridLayout gl = new GridLayout( 1, false );
	gl.marginBottom = 0;
	gl.marginHeight = 0;
	gl.marginLeft = 0;
	gl.marginRight = 0;
	gl.marginTop = 0;
	gl.marginWidth = 0;
	this.setLayout( gl );
	
	slider = new Slider( this, style );
	GridData gd = new GridData( GridData.FILL_BOTH );
	slider.setLayoutData( gd );
}
 
Example #11
Source File: FontAwesomeSnippet3.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
public static void main(final String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setText("FontAwesome Snippet");
	shell.setSize(1000, 600);
	shell.setLayout(new GridLayout(2, false));

	fScrolledComposite = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
	fScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
	fScrolledComposite.setAlwaysShowScrollBars(false);
	fScrolledComposite.setExpandHorizontal(true);
	fScrolledComposite.setExpandVertical(true);

	Composite composite = new Composite(fScrolledComposite, SWT.NONE);
	fScrolledComposite.setContent(composite);

	RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
	rowLayout.marginTop = 5;
	rowLayout.marginRight = 5;
	rowLayout.marginLeft = 5;
	rowLayout.marginBottom = 5;
	rowLayout.pack = false;
	composite.setLayout(rowLayout);
	buildComposite(composite);
	calcMinsize(composite);
	shell.layout(true, true);

	fFontLabel = new Label(shell, SWT.NONE);
	fFontLabel.setText("Font size (22)");


	fSlider = new Slider(shell, SWT.NONE);
	fSlider.addListener(SWT.MouseUp, e -> {
		shell.setRedraw(false);
		Arrays.asList(composite.getChildren()).forEach(c -> c.dispose());
		fFontSize = fSlider.getSelection();
		buildComposite(composite);
		fFontLabel.setText("Font size (" + fFontSize + ")");
		shell.setRedraw(true);

		shell.layout(true, true);
		calcMinsize(composite);
	});
	fSlider.setPageIncrement(1);
	fSlider.setMaximum(150);
	fSlider.setMinimum(4);
	fSlider.setSelection(22);
	fSlider.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
	shell.open();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
	display.dispose();

}
 
Example #12
Source File: SWTSlider.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public SWTSlider(SWTContainer<? extends Composite> parent, int orientation) {
	super(new Slider(parent.getControl(), SWT.BORDER | orientation), parent);
	
	this.selectionListener = new SWTSelectionListenerManager(this);
}
 
Example #13
Source File: CompositeTableRow.java    From dawnsci with Eclipse Public License 1.0 4 votes vote down vote up
public CompositeTableRow(CompositeEntry entry,
					     Table container,
						 CompositingControl control,
						 boolean disableOp) {
	
	this.name = entry.getName();
	TableItem newItem = new TableItem(container,SWT.DOUBLE_BUFFERED);
	TableEditor editor0 = new TableEditor(container);
	editor0.horizontalAlignment = SWT.CENTER;
	editor0.grabHorizontal = true;
	chkActive = new Button(container,SWT.CHECK);
	chkActive.setSelection(true);
	chkActive.addSelectionListener(control);
	editor0.setEditor(chkActive,newItem,0);
	
	TableEditor editor = new TableEditor(container);
	editor.horizontalAlignment = SWT.CENTER;
	editor.grabHorizontal = true;
	panel = new Composite(container, SWT.NONE);
	panel.setLayout(new GridLayout(2,true));
	slider = new Slider(panel,SWT.HORIZONTAL|SWT.NO_TRIM);
	slider.setValues((int)(entry.getWeight()*100), 0, 104, 5, 1, 5);
	slider.addSelectionListener(this);
	slider.addSelectionListener(control);
	spinner = new Spinner(panel,SWT.DOUBLE_BUFFERED);
	spinner.setMinimum(0);
	spinner.setMaximum(100);
	spinner.setSelection((int)(entry.getWeight()*100));
	spinner.addSelectionListener(control);
	spinner.addSelectionListener(this);
	panel.pack();
	editor.setEditor(panel,newItem,2);
	newItem.setText(1,name);
	TableEditor editor2 = new TableEditor(container);
	editor2.horizontalAlignment = SWT.CENTER;
	editor2.grabHorizontal = true;
	editor2.grabVertical = true;
	op = new Combo(container,SWT.NONE);
	op.add("ADD");
	op.add("SUBTRACT");
	op.add("MULTIPLY");
	op.add("DIVIDE");
	op.add("MINIMUM");
	op.add("MAXIMUM");
	op.select(convertOperationToInt(entry.getOperation()));
	op.pack();
	op.addSelectionListener(control);
	op.setEnabled(!disableOp);
	editor2.setEditor(op,newItem,3);
	TableEditor editor3 = new TableEditor(container);
	editor3.horizontalAlignment = SWT.CENTER;
	editor3.grabHorizontal = true;
	editor3.grabVertical = true;
	chkRed = new Button(container,SWT.CHECK);
	chkRed.setSelection(true);
	chkRed.pack();
	chkRed.addSelectionListener(control);
	editor3.setEditor(chkRed,newItem,4);
	TableEditor editor4 = new TableEditor(container);
	editor4.horizontalAlignment = SWT.CENTER;
	editor4.grabHorizontal = true;
	editor4.grabVertical = true;
	chkGreen = new Button(container,SWT.CHECK);
	chkGreen.pack();
	chkGreen.setSelection(true);
	chkGreen.addSelectionListener(control);
	editor4.setEditor(chkGreen,newItem,5);
	TableEditor editor5 = new TableEditor(container);
	editor5.horizontalAlignment = SWT.CENTER;
	editor5.grabHorizontal = true;
	editor5.grabVertical = true;
	chkBlue = new Button(container,SWT.CHECK);
	chkBlue.pack();
	chkBlue.setSelection(true);
	chkBlue.addSelectionListener(control);
	editor5.setEditor(chkBlue,newItem,6);		
	
}
 
Example #14
Source File: ChartSlider.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public Slider getWidget( )
{
	return this.slider;
}
 
Example #15
Source File: TimeGraphViewer.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Get the horizontal scroll bar object
 *
 * @return The scroll bar
 */
public Slider getHorizontalBar() {
    return fHorizontalScrollBar;
}
 
Example #16
Source File: TimeGraphViewer.java    From tracecompass with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Get the vertical scroll bar object
 *
 * @return The scroll bar
 */
public Slider getVerticalBar() {
    return fVerticalScrollBar;
}