Java Code Examples for org.eclipse.swt.widgets.Button#getSelection()

The following examples show how to use org.eclipse.swt.widgets.Button#getSelection() . 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: CheckDefaultPreferencesDialog.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void applyChanges() {
    for (Button bt : checkBoxes) {
        Object data = bt.getData();
        if (data instanceof CheckInfo) {
            if (bt.getSelection()) {
                CheckInfo checkInfo = (CheckInfo) data;
                checkInfo.apply();
            }

        } else if (data.equals(PydevRootPrefs.CHECK_PREFERRED_PYDEV_SETTINGS)) {
            PydevRootPrefs.setCheckPreferredPydevSettings(bt.getSelection());

        } else {
            Log.log("Unexpected data: " + data);
        }
    }
}
 
Example 2
Source File: IndexTabWrapper.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public void removeIndex() {
	int selectedIndex = -1;

	for (int i = 0; i < this.checkButtonList.size(); i++) {
		Button checkButton = this.checkButtonList.get(i);
		if (checkButton.getSelection()) {
			selectedIndex = i;
			break;
		}
	}

	if (selectedIndex == -1) {
		return;
	}

	this.copyData.removeIndex(selectedIndex);

	this.restruct();
}
 
Example 3
Source File: FallDetailBlatt2.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * changing state: empty -> checked -> unchecked (cycling through)
 */
@Override
public void widgetSelected(SelectionEvent e){
	Button button = ((Button) e.getSource());
	boolean selection = !button.getSelection();
	boolean grayed = button.getGrayed();
	if (selection) {
		if (grayed) {
			button.setSelection(true);
			button.setGrayed(false);
		} else {
			button.setSelection(false);
			button.setGrayed(false);
		}
	} else {
		button.setSelection(true);
		button.setGrayed(true);
	}
}
 
Example 4
Source File: CMakePropertyTab.java    From cmake4eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void handleEvent(Event event) {
  final Button btn = (Button) event.widget;
  if (btn != null && Boolean.TRUE.equals(btn.getData())) {
    // button is in tri-state mode
    if (btn.getSelection()) {
      if (!btn.getGrayed()) {
        btn.setGrayed(true);
      }
    } else {
      if (btn.getGrayed()) {
        btn.setGrayed(false);
        btn.setSelection(true);
      }
    }
  }
}
 
Example 5
Source File: ComplexFormEx.java    From SWET with MIT License 6 votes vote down vote up
private static void doSelection(Button button) {
	if (button.getSelection()) {
		String key = (String) button.getData("key");
		if (key != null && key != "" && elementData.containsKey(key)) {
			elementData.replace("ElementSelectedBy", key);
			logger.info("Set ElementSelectedBy: " + key);
		} else {
			// System.out.println(
			// String.format("Skip processing of key '%s'", selectedKey));
		}
	}
	/*
	  idRadio.addListener(SWT.Selection, new Listener() {
	    public void handleEvent(Event event) {
	      switch (event.type) {
	      case SWT.Selection:
	        Button button = ((Button) event.widget);
	        if (button.getSelection()) {
	          System.out.println(button.getText() + " selected (*)");
	        }
	        break;
	      }
	    }
	  });
	*/
}
 
Example 6
Source File: DiscreteEntryComposite.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void widgetSelected(SelectionEvent e) {
	// Notify any listeners that the selection has changed
	notifyListeners(SWT.Selection, new Event());

	// Get the checkbox state
	Button button = (Button) e.getSource();
	if (button.getSelection()) {
		DiscreteEntryComposite.this.setEntryValue(yes);
	} else {
		DiscreteEntryComposite.this.setEntryValue(no);
	}

	logger.info(
			"EntryComposite Message: Updated Entry " + entry.getName() + " with value = " + entry.getValue());

	return;
}
 
Example 7
Source File: IndexTabWrapper.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
public void addIndexData(final Index index, final boolean add) {
    int selectedIndex = -1;

    for (int i = 0; i < checkButtonList.size(); i++) {
        final Button checkButton = checkButtonList.get(i);
        if (checkButton.getSelection()) {
            selectedIndex = i;
            break;
        }
    }

    Index copyIndex = null;

    if (add || selectedIndex == -1) {
        copyIndex = new CopyIndex(copyData, index, null);
        copyData.addIndex(copyIndex);

    } else {
        copyIndex = copyData.getIndex(selectedIndex);
        CopyIndex.copyData(index, copyIndex);

    }

    restruct();
}
 
Example 8
Source File: RadioTab.java    From hop with Apache License 2.0 5 votes vote down vote up
public int selectedIndex() {
  Control[] children = radioGroup.getChildren();
  for ( int i = 0; i < children.length; i++ ) {
    Control child = children[ i ];
    Button button = (Button) child;
    if ( button.getSelection() ) {
      return i;
    }
  }
  return -1;
}
 
Example 9
Source File: TristateCheckbox.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void widgetSelected(SelectionEvent e){
	Button button = ((Button) e.getSource());
	boolean selection = !button.getSelection();
	boolean grayed = button.getGrayed();
	if (falseFirst) {
		if (selection) {
			if (grayed) {
				button.setSelection(false);
				button.setGrayed(false);
			} else {
				button.setSelection(true);
				button.setGrayed(true);
			}
		} else {
			button.setSelection(true);
			button.setGrayed(false);
		}
	} else {
		if (selection) {
			if (grayed) {
				button.setSelection(true);
				button.setGrayed(false);
			} else {
				button.setSelection(false);
				button.setGrayed(false);
			}
		} else {
			button.setSelection(true);
			button.setGrayed(true);
		}
	}
}
 
Example 10
Source File: TranslationManageDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
public void validatePage() {
    final List<String> selectedTranslations = new ArrayList<String>();

    for (final String translation : allTranslations) {
        final Button button = (Button) translationCheckMap.get(translation).getEditor();

        if (button.getSelection()) {
            selectedTranslations.add(translation);
        }
    }

    translationSettings.setSelectedTranslations(selectedTranslations);
    translationSettings.setUse(useButton.getSelection());
}
 
Example 11
Source File: SelectionButtonDialogFieldGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void doWidgetSelected(SelectionEvent e) {
	Button button= (Button)e.widget;
	for (int i= 0; i < fButtons.length; i++) {
		if (fButtons[i] == button) {
			fButtonsSelected[i]= button.getSelection();
			dialogFieldChanged();
			return;
		}
	}
}
 
Example 12
Source File: MappingDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void setTabFlags( Button wMainPath, Label wlInputStep, Text wInputStep, Button wbInputStep,
                          Label wlOutputStep, Text wOutputStep, Button wbOutputStep, Label wlDescription,
                          Text wDescription ) {
  boolean mainPath = wMainPath.getSelection();
  wlInputStep.setEnabled( !mainPath );
  wInputStep.setEnabled( !mainPath );
  wbInputStep.setEnabled( !mainPath );
  wlOutputStep.setEnabled( !mainPath );
  wOutputStep.setEnabled( !mainPath );
  wbOutputStep.setEnabled( !mainPath );
  wlDescription.setEnabled( !mainPath );
  wDescription.setEnabled( !mainPath );
}
 
Example 13
Source File: JavaSearchPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private int getSearchFor() {
	for (int i= 0; i < fSearchFor.length; i++) {
		Button button= fSearchFor[i];
		if (button.getSelection()) {
			return getIntData(button);
		}
	}
	Assert.isTrue(false, "shouldNeverHappen"); //$NON-NLS-1$
	return -1;
}
 
Example 14
Source File: SubtaskSheetImpl.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean getToggleButtonSelection( String buttonId )
{
	Button button = popupButtonRegistry.get( buttonId );
	if ( button == null )
	{
		button = popupButtonRegistry.get( getNodePath( ) + buttonId );
	}
	if ( button != null )
	{
		return button.getSelection( );
	}
	return false;
}
 
Example 15
Source File: MappingDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void setTabFlags( Button wMainPath, Label wlInputTransform, Text wInputTransform, Button wbInputTransform,
                          Label wlOutputTransform, Text wOutputTransform, Button wbOutputTransform, Label wlDescription,
                          Text wDescription ) {
  boolean mainPath = wMainPath.getSelection();
  wlInputTransform.setEnabled( !mainPath );
  wInputTransform.setEnabled( !mainPath );
  wbInputTransform.setEnabled( !mainPath );
  wlOutputTransform.setEnabled( !mainPath );
  wOutputTransform.setEnabled( !mainPath );
  wbOutputTransform.setEnabled( !mainPath );
  wlDescription.setEnabled( !mainPath );
  wDescription.setEnabled( !mainPath );
}
 
Example 16
Source File: IndexTabWrapper.java    From erflute with Apache License 2.0 5 votes vote down vote up
public ERIndex getTargetIndex() {
    int selectedIndex = -1;
    for (int i = 0; i < checkButtonList.size(); i++) {
        final Button checkButton = checkButtonList.get(i);
        if (checkButton.getSelection()) {
            selectedIndex = i;
            break;
        }
    }
    if (selectedIndex == -1) {
        return null;
    }
    return copyData.getIndex(selectedIndex);
}
 
Example 17
Source File: UnmanageAction.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void widgetSelected(SelectionEvent e) {
	Button button = (Button) e.widget;
	if (button.getSelection()) {
		deleteContent = (button == radio1);
	}
}
 
Example 18
Source File: TaskSelectType.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected void handleSubtypeBtnSelected( SelectionEvent e )
{
	Button btn = (Button) e.getSource( );
	if ( btn.getSelection( ) )
	{
		if ( this.sSubType != null
				&& !getSubtypeFromButton( btn ).equals( sSubType ) )
		{
			int iTypeIndex = vSubTypeNames.indexOf( sSubType );
			if ( iTypeIndex >= 0 )
			{
				( (Button) cmpTypeButtons.getChildren( )[iTypeIndex] ).setSelection( false );
				cmpTypeButtons.redraw( );
			}
		}

		// Cache label position for stacked or non-stacked case.
		ChartUIUtil.saveLabelPositionIntoCache( getSeriesDefinitionForProcessing( ) );

		sSubType = getSubtypeFromButton( btn );
		ChartCacheManager.getInstance( ).cacheSubtype( sType,
				sSubType );
	}
	else
	{
		if ( this.sSubType != null
				&& getSubtypeFromButton( btn ).equals( sSubType ) )
		{
			// Clicking on the same button should not cause it to be
			// unselected
			btn.setSelection( true );

			// Disable the statement to avoid when un-check all
			// stacked attributes of series on format tab, the
			// default chart is painted as side-by-side, but it
			// can't select stacked button to change chart type to
			// stacked in chart type tab.
			// needUpdateModel = false;
		}
	}
}
 
Example 19
Source File: CodewindPrefsParentPage.java    From codewind-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public boolean performOk() {
	if (!isValid()) {
		return false;
	}
	
	if (CodewindInstall.ENABLE_STOP_APPS_OPTION) {
		for (Button button : stopAppsButtons) {
			if (button.getSelection()) {
				prefs.setValue(InstallUtil.STOP_APP_CONTAINERS_PREFSKEY, (String)button.getData());
				break;
			}
		}
	}
	
	prefs.setValue(CodewindCorePlugin.AUTO_OPEN_OVERVIEW_PAGE, autoOpenOverviewButton.getSelection());
	prefs.setValue(CodewindCorePlugin.ENABLE_SUPPORT_FEATURES, supportFeaturesButton.getSelection());
	
	prefs.setValue(CodewindCorePlugin.CW_INSTALL_TIMEOUT, Integer.parseInt(installTimeoutText.getText().trim()));
	prefs.setValue(CodewindCorePlugin.CW_UNINSTALL_TIMEOUT, Integer.parseInt(uninstallTimeoutText.getText().trim()));
	prefs.setValue(CodewindCorePlugin.CW_START_TIMEOUT, Integer.parseInt(startTimeoutText.getText().trim()));
	prefs.setValue(CodewindCorePlugin.CW_STOP_TIMEOUT, Integer.parseInt(stopTimeoutText.getText().trim()));
	
	// validate in validate() that this is a good integer
	int debugTimeout = Integer.parseInt(debugTimeoutText.getText().trim());
	prefs.setValue(CodewindCorePlugin.DEBUG_CONNECT_TIMEOUT_PREFSKEY, debugTimeout);

	// removes any trimmed space
	debugTimeoutText.setText("" + debugTimeout); //$NON-NLS-1$
	
	if (useBuiltinDebugButton != null) {
		prefs.setValue(CodewindCorePlugin.USE_BUILTIN_NODEJS_DEBUG_PREFSKEY, useBuiltinDebugButton.getSelection());
	}
	
	if (this.webBrowserCombo != null) {
		// The first option in the webBrowserCombo is to not use the default browser.
		// As a result, if the first option is selected, then remove the preference
		if (webBrowserCombo.getSelectionIndex() > 0) {
			// If it is selected, then save the preference. Do not add if it's the first item, since the option
			// for the first entry is "No browser selected"
			if (browserName != null) {
				prefs.setValue(CodewindCorePlugin.NODEJS_DEBUG_BROWSER_PREFSKEY, browserName);
			}
		} else {
			prefs.setToDefault(CodewindCorePlugin.NODEJS_DEBUG_BROWSER_PREFSKEY);
		}
	}

	return true;
}
 
Example 20
Source File: NewProjectNameAndLocationWizardPage.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates the project location specification controls.
 *
 * @param parent the parent composite
 */
private final void createProjectLocationGroup(Composite parent) {
    Font font = parent.getFont();
    // project specification group
    Composite projectGroup = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    projectGroup.setLayout(layout);
    projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    projectGroup.setFont(font);

    // new project label
    Label projectContentsLabel = new Label(projectGroup, SWT.NONE);
    projectContentsLabel.setFont(font);

    projectContentsLabel.setText("Project contents:");

    GridData labelData = new GridData();
    labelData.horizontalSpan = 3;
    projectContentsLabel.setLayoutData(labelData);

    final Button useDefaultsButton = new Button(projectGroup, SWT.CHECK | SWT.RIGHT);
    useDefaultsButton.setText("Use &default");
    useDefaultsButton.setSelection(useDefaults);
    useDefaultsButton.setFont(font);

    GridData buttonData = new GridData();
    buttonData.horizontalSpan = 3;
    useDefaultsButton.setLayoutData(buttonData);

    createUserSpecifiedProjectLocationGroup(projectGroup, !useDefaults);

    SelectionListener listener = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            useDefaults = useDefaultsButton.getSelection();
            browseButton.setEnabled(!useDefaults);
            locationPathField.setEnabled(!useDefaults);
            locationLabel.setEnabled(!useDefaults);
            if (useDefaults) {
                customLocationFieldValue = locationPathField.getText();
                setLocationForSelection();
            } else {
                locationPathField.setText(customLocationFieldValue);
            }
        }
    };
    useDefaultsButton.addSelectionListener(listener);
}