Java Code Examples for org.eclipse.swt.SWT#TOGGLE

The following examples show how to use org.eclipse.swt.SWT#TOGGLE . 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: FocusTests.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void setUp4() throws Exception {
	Shell shell = getShell();
	shell.setLayout(new GridLayout(4, false));

	cdt1 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdt1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button1 = new Button(shell, SWT.TOGGLE);
	button1.setText("B1");
	button1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt2 = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE);
	cdt2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button2 = new Button(shell, SWT.PUSH);
	button2.setText("B2");
	button2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
}
 
Example 2
Source File: FocusTests.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void setUp6() throws Exception {
	Shell shell = getShell();
	shell.setLayout(new GridLayout(4, false));

	button1 = new Button(shell, SWT.TOGGLE);
	button1.setText("B1");
	button1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt1 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN | CDT.TAB_FIELDS);
	cdt1.setPattern("z MM/dd/yyyy");
	cdt1.setSelection(new Date());
	cdt1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button2 = new Button(shell, SWT.PUSH);
	button2.setText("B2");
	button2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt2 = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE | CDT.TAB_FIELDS);
	cdt2.setPattern("MM/dd/yyyy");
	cdt2.setSelection(new Date());
	cdt2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
}
 
Example 3
Source File: FocusTests.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void doSetUp1(Shell shell) {
	shell.setLayout(new GridLayout(4, false));

	button1 = new Button(shell, SWT.TOGGLE);
	button1.setText("B1");
	button1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt1 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
	cdt1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button2 = new Button(shell, SWT.PUSH);
	button2.setText("B2");
	button2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt2 = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE);
	cdt2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
}
 
Example 4
Source File: CTreeCell.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
void initialize() {
	toggleBounds = new Rectangle(0,0,0,0);
	iBounds = new Rectangle[0];
	tBounds = new Rectangle(0,0,0,0);
	if((style & SWT.DROP_DOWN) != 0) {
		hasChild = true;
		setChildVisible(true);
	} else {
		hasChild = false;
	}
	if((style & SWT.TOGGLE) != 0) {
		setToggleVisible(true, true);
	}
	if(isCheckCell()) setCheck(true);
	if(isTreeCell()) {
		if(((CTreeItem) item).hasParentItem()) {
			setIndent(((CTreeItem) item).getParentIndent() + ctree.getTreeIndent());
		}
		setToggleVisible(((CTreeItem) item).hasItems(), true);
	}
	inited = true;
}
 
Example 5
Source File: RoundedToolbarSnippet.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private static void createToggleButtons(final Shell shell) {
	final RoundedToolbar roundedToolBar = new RoundedToolbar(shell, SWT.NONE);

	roundedToolBar.setBackground(grey1);
	roundedToolBar.setCornerRadius(6);

	final RoundedToolItem item1 = new RoundedToolItem(roundedToolBar, SWT.TOGGLE);
	item1.setSelection(true);
	item1.setTooltipText("Multiple ballons");
	item1.setWidth(40);
	item1.setSelectionImage(iconBubble3w);
	item1.setImage(iconBubble3b);

	final RoundedToolItem item2 = new RoundedToolItem(roundedToolBar, SWT.TOGGLE);
	item2.setTooltipText("Simple item");
	item2.setSelectionImage(iconBubble1w);
	item2.setImage(iconBubble1b);
	item2.setWidth(40);

	final RoundedToolItem item3 = new RoundedToolItem(roundedToolBar, SWT.TOGGLE);
	item3.setTooltipText("Lot of lines\r\n\r\nThis item has a line-break");
	item3.setSelectionImage(iconBubble2w);
	item3.setImage(iconBubble2b);
	item3.setWidth(40);
}
 
Example 6
Source File: ButtonProfileEntry.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public ButtonProfileEntry ( final DataBindingContext dbc, final Composite parent, final ProfileManager profileManager, final Profile profile, final ChartContext chartContext )
{
    super ( dbc, profileManager, profile, chartContext );

    this.widget = new Button ( parent, SWT.TOGGLE );

    addBinding ( dbc.bindValue ( SWTObservables.observeText ( this.widget ), EMFObservables.observeValue ( profile, ChartPackage.Literals.PROFILE__LABEL ) ) );

    this.widget.addSelectionListener ( new SelectionAdapter () {
        @Override
        public void widgetSelected ( final SelectionEvent e )
        {
            fireSelection ( ButtonProfileEntry.this.widget.getSelection () );
        };
    } );
}
 
Example 7
Source File: FocusTests.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void setUp5() throws Exception {
	Shell shell = getShell();
	shell.setLayout(new GridLayout(4, false));

	button1 = new Button(shell, SWT.TOGGLE);
	button1.setText("B1");
	button1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt1 = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN | CDT.TAB_FIELDS);
	cdt1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	button2 = new Button(shell, SWT.PUSH);
	button2.setText("B2");
	button2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));

	cdt2 = new CDateTime(shell, CDT.BORDER | CDT.SIMPLE | CDT.TAB_FIELDS);
	cdt2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
}
 
Example 8
Source File: HighlightRuleBuilder.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private Button createToggleButton( Composite parent )
{
	Composite wrapper = new Composite( parent, 0 );
	GridLayout layout = new GridLayout( );
	layout.marginWidth = 0;
	layout.horizontalSpacing = 0;
	wrapper.setLayout( layout );

	Button btn = new Button( wrapper, SWT.TOGGLE );
	GridData gdata = new GridData( );
	// gdata.widthHint = 22;
	// gdata.heightHint = 22;
	btn.setLayoutData( gdata );

	return btn;
}
 
Example 9
Source File: DefaultColumnGroupHeaderRenderer.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    if ((group.getStyle() & SWT.TOGGLE) != 0)
    {
        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (getToggleBounds().contains(point))
            {
                group.setExpanded(!group.getExpanded());

                if (group.getExpanded())
                {
                    group.notifyListeners(SWT.Expand,new Event());
                }
                else
                {
                    group.notifyListeners(SWT.Collapse,new Event());
                }
                return true;
            }
        }
        else
        {
            if (getToggleBounds().contains(point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }
    }

    return false;
}
 
Example 10
Source File: TogglePropertyDescriptor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public Control createControl( Composite parent )
{
	button = new Button( parent, SWT.TOGGLE );
	button.addSelectionListener( new SelectionAdapter( ) {

		public void widgetSelected( SelectionEvent e )
		{
			handleSelectEvent( );
		}
	} );
	return button;
}
 
Example 11
Source File: FontDefinitionDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Button createAlighmentButton( Composite parent )
{
	Button button = new Button( parent, SWT.TOGGLE );
	GridData gd = new GridData( );
	gd.widthHint = 32;
	gd.heightHint = 32;
	button.setLayoutData( gd );
	button.addSelectionListener( this );
	listAlignmentButtons.add( button );
	return button;
}
 
Example 12
Source File: TaskSelectionPage.java    From CogniCrypt with Eclipse Public License 2.0 5 votes vote down vote up
private Button createImageButton(final Composite container, final Image startImage, String taskName) {
	final Button imageButton = new Button(container, SWT.WRAP | SWT.TOGGLE);
	final Rectangle bounds = startImage.getBounds();
	imageButton.setSize(bounds.width, bounds.height);
	imageButton.setImage(startImage);
	imageButton.setToolTipText(taskName);
	return imageButton;
}
 
Example 13
Source File: RoundedToolItem.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private static int checkStyle(final int style) {
	if ((style & SWT.CHECK) != 0) {
		return SWT.CHECK;
	}
	if ((style & SWT.RADIO) != 0) {
		return SWT.RADIO;
	}
	if ((style & SWT.TOGGLE) != 0) {
		return SWT.TOGGLE;
	}
	if ((style & SWT.DROP_DOWN) != 0) {
		return SWT.DROP_DOWN;
	}
	return SWT.PUSH;
}
 
Example 14
Source File: VButtonImageBak.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void createImage(VButton button) {
	String key = getKey(button);
	if(requests.containsKey(key)) {
		requests.get(key).add(button);
	} else {
		requests.put(key, new ArrayList<VButton>());
		requests.get(key).add(button);

		int style = button.getStyle() & (SWT.CHECK | SWT.RADIO);
		if(style == 0) {
			style = SWT.TOGGLE; // defaults to, and converts PUSH buttons to, TOGGLE
		}

		Button b = new Button(button.composite, style);
		b.setBackground(button.getBackground());
		b.setBounds(button.getBounds());
		if(button.hasState(VControl.STATE_SELECTED)) {
			b.setSelection(true);
		}
		if(button == VTracker.getFocusControl()) {
			 b.setFocus();
		}
		b.addListener(SWT.Paint, new ImageListener(key, b));

		b.redraw();
		b.update();
	}
}
 
Example 15
Source File: DefaultColumnGroupHeaderRenderer.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    if ((group.getStyle() & SWT.TOGGLE) != 0)
    {
        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (getToggleBounds().contains(point))
            {
                group.setExpanded(!group.getExpanded());

                if (group.getExpanded())
                {
                    group.notifyListeners(SWT.Expand,new Event());
                }
                else
                {
                    group.notifyListeners(SWT.Collapse,new Event());
                }
                return true;
            }
        }
        else
        {
            if (getToggleBounds().contains(point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }
    }

    return false;
}
 
Example 16
Source File: DefaultColumnGroupHeaderRenderer.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public boolean notify(int event, Point point, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    if ((group.getStyle() & SWT.TOGGLE) != 0)
    {
        if (event == IInternalWidget.LeftMouseButtonDown)
        {
            if (getToggleBounds().contains(point))
            {
                group.setExpanded(!group.getExpanded());

                if (group.getExpanded())
                {
                    group.notifyListeners(SWT.Expand,new Event());
                }
                else
                {
                    group.notifyListeners(SWT.Collapse,new Event());
                }
                return true;
            }
        }
        else
        {
            if (getToggleBounds().contains(point))
            {
                setHoverDetail("toggle");
                return true;
            }
        }
    }

    return false;
}
 
Example 17
Source File: TextIconButton.java    From swt-bling with MIT License 4 votes vote down vote up
protected boolean isToggleButton() {
  return (getStyle() & SWT.TOGGLE) == SWT.TOGGLE;
}
 
Example 18
Source File: AbstractInfoView.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public LinkAction() {
	super(InfoViewMessages.LinkAction_label, SWT.TOGGLE);
	setToolTipText(InfoViewMessages.LinkAction_tooltip);
	setChecked(fLinking);
}
 
Example 19
Source File: DefaultColumnGroupHeaderRenderer.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Point computeSize(GC gc, int wHint, int hHint, Object value)
{
    GridColumnGroup group = (GridColumnGroup)value;

    gc.setFont(group.getHeaderFont());

    int x = leftMargin;
    int y = topMargin + gc.getFontMetrics().getHeight() + bottomMargin;


    if (group.getImage() != null)
    {
        x += group.getImage().getBounds().width + imageSpacing;

        y = Math.max(y, topMargin + group.getImage().getBounds().height + bottomMargin);
    }

    if (!isWordWrap())
    {
      x += gc.stringExtent(group.getText()).x + rightMargin;
    }
    else
    {
      int toggleWidth = 0;
        if ((group.getStyle() & SWT.TOGGLE) != 0)
          toggleWidth = toggleRenderer.getSize().x;

      int plainTextWidth;
      if (wHint == SWT.DEFAULT)
        plainTextWidth = getBounds().width - x - rightMargin - toggleWidth;
      else
        plainTextWidth = wHint - x - rightMargin - toggleWidth;

      getTextLayout(gc, group);
        textLayout.setText(group.getText());
        textLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);

        x += plainTextWidth + rightMargin;

        int textHeight = topMargin;
        textHeight += textLayout.getBounds().height;
        textHeight += bottomMargin;

        y = Math.max(y, textHeight);
    }
    return new Point(x, y);
}
 
Example 20
Source File: TabbedPropertyTitle.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void handleWidgetSelection( Event e, ToolItem item )
{

	boolean selection = item.getSelection( );

	int style = item.getStyle( );
	IAction action = (IAction) actionMap.get( item );

	if ( ( style & ( SWT.TOGGLE | SWT.CHECK ) ) != 0 )
	{
		if ( action.getStyle( ) == IAction.AS_CHECK_BOX )
		{
			action.setChecked( selection );
		}
	}
	else if ( ( style & SWT.RADIO ) != 0 )
	{
		if ( action.getStyle( ) == IAction.AS_RADIO_BUTTON )
		{
			action.setChecked( selection );
		}
	}
	else if ( ( style & SWT.DROP_DOWN ) != 0 )
	{
		if ( e.detail == 4 )
		{ // on drop-down button
			if ( action.getStyle( ) == IAction.AS_DROP_DOWN_MENU )
			{
				IMenuCreator mc = action.getMenuCreator( );
				ToolItem ti = (ToolItem) item;
				if ( mc != null )
				{
					Menu m = mc.getMenu( ti.getParent( ) );
					if ( m != null )
					{
						Point point = ti.getParent( )
								.toDisplay( new Point( e.x, e.y ) );
						m.setLocation( point.x, point.y ); // waiting
						m.setVisible( true );
						return; // we don't fire the action
					}
				}
			}
		}
	}

	action.runWithEvent( e );
}