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

The following examples show how to use org.eclipse.swt.widgets.Button#getData() . 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: 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 2
Source File: OptionsConfigurationBlock.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void updateCheckBox( Button curr )
{
	ControlData data = (ControlData) curr.getData( );

	String currValue = getValue( data.getKey( ) );
	curr.setSelection( data.getSelection( currValue ) == 0 );

	if ( fProject != null )
	{
		if ( ignoreKeys != null
				&& Arrays.asList( ignoreKeys ).contains( data.getKey( ) ) )
		{
			ControlEnableState.disable( curr );
		}
	}
}
 
Example 3
Source File: RouteResourceController.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param source
 * @return
 */
private PropertyChangeCommand createButtonCommand(Button button) {
    RouteResourceSelectionDialog dialog = new RouteResourceSelectionDialog(button.getShell());

    selectNodeIfExists(button, dialog);

    if (dialog.open() == Window.OK) {

        IRepositoryViewObject repositoryObject = dialog.getResult().getObject();

        // refreshItemeProperty(repositoryObject);

        final Item item = repositoryObject.getProperty().getItem();
        String id = item.getProperty().getId();
        String paramName = (String) button.getData(PARAMETER_NAME);

        return new PropertyChangeCommand(elem, paramName, id);
    }
    return null;
}
 
Example 4
Source File: ControlBindingManager.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void initRadioControls()
{
	Iterator<Button> it = radioControls.keySet().iterator();
	while (it.hasNext())
	{
		Button button = it.next();
		String key = radioControls.get(button);

		String enable = (String) button.getData();
		String value = preferenceDelegate.getString(key);

		if (enable != null && enable.equals(value))
		{
			button.setSelection(true);
		}
		else
		{
			button.setSelection(false);
		}
	}
}
 
Example 5
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 6
Source File: AppEngineLibrariesSelectorGroupTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testButtonOrder() {
  Control container = shell.getChildren()[0];
  assertThat(container, instanceOf(Composite.class));
  Control groupAsControl = ((Composite) container).getChildren()[0];
  assertThat(groupAsControl, instanceOf(Group.class));
  Control[] buttonsAsControls = ((Group) groupAsControl).getChildren();
  String[] expectedLibraryOrder =
      new String[] {"appengine-api", "appengine-endpoints", "objectify"};
  for (int i = 0; i < buttonsAsControls.length; i++) {
    Control control = buttonsAsControls[i];
    assertThat(control, instanceOf(Button.class));
    Button button = (Button) control;
    assertNotNull(button.getData());
    assertThat(button.getData(), instanceOf(Library.class));
    Library library = (Library) button.getData();
    assertThat(library.getId(), is(expectedLibraryOrder[i]));
  }
}
 
Example 7
Source File: CheckBoxGroupFieldEditor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private String gatherSettings() {
	String[][] settings = new String[checkBoxButtons.length][3];
	for (int i = 0; i < checkBoxButtons.length; i++) {
		Button currentCheckBox = checkBoxButtons[i];
		String name = currentCheckBox.getText();
		String value = (String) currentCheckBox.getData();
		String checked = String.valueOf(currentCheckBox.getSelection());
		settings[i] = new String[] { name, value, checked };
	}
	return calculateResult(settings);
}
 
Example 8
Source File: ModulaSearchPage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private int getSelectedBtns(ArrayList<Button> btns, boolean combineBits) {
    int res = 0;
    for (Button btn : btns) {
        if (btn.getSelection()) {
            res |= (Integer)btn.getData();
            if (!combineBits) {
                return res;
            }
        }
    }
    return res;
}
 
Example 9
Source File: ReportConfigurationTab.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Synchronize selected bug category checkboxes with the current user
 * preferences.
 */
protected void syncSelectedCategories() {
    ProjectFilterSettings filterSettings = getCurrentProps().getFilterSettings();
    for (Button checkBox : chkEnableBugCategoryList) {
        String category = (String) checkBox.getData();
        if (checkBox.getSelection()) {
            filterSettings.addCategory(category);
        } else {
            filterSettings.removeCategory(category);
        }
    }
    propertyPage.getVisibleDetectors().clear();
}
 
Example 10
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 5 votes vote down vote up
protected Button getCheckBox(Key key) {
	for (int i = fCheckBoxes.size() - 1; i >= 0; i--) {
		Button curr = (Button) fCheckBoxes.get(i);
		ControlData data = (ControlData) curr.getData();
		if (key.equals(data.getKey())) {
			return curr;
		}
	}
	return null;
}
 
Example 11
Source File: OptionsConfigurationBlock.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
protected Button getCheckBox( Key key )
{
	for ( int i = fCheckBoxes.size( ) - 1; i >= 0; i-- )
	{
		Button curr = (Button) fCheckBoxes.get( i );
		ControlData data = (ControlData) curr.getData( );
		if ( key.equals( data.getKey( ) ) )
		{
			return curr;
		}
	}
	return null;
}
 
Example 12
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected Button getCheckBox(Key key) {
	for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
		Button curr= fCheckBoxes.get(i);
		ControlData data= (ControlData) curr.getData();
		if (key.equals(data.getKey())) {
			return curr;
		}
	}
	return null;
}
 
Example 13
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected Link getCheckBoxLink(Key key) {
	if (fCheckBoxes == null)
		return null;
	
	for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
		Button curr= fCheckBoxes.get(i);
		ControlData data= (ControlData) curr.getData();
		if (key.equals(data.getKey()) && data instanceof LinkControlData) {
			return ((LinkControlData)data).getLink();
		}
	}
	return null;
}
 
Example 14
Source File: HadoopLocationWizard.java    From RDFS with Apache License 2.0 5 votes vote down vote up
public void widgetSelected(SelectionEvent e) {
  final Button button = (Button) e.widget;
  final ConfProp prop = (ConfProp) button.getData("hProp");

  Display.getDefault().syncExec(new Runnable() {
    public void run() {
      // We want to receive the update also!
      mediator.notifyChange(null, prop, button.getSelection() ? "yes"
          : "no");
    }
  });
}
 
Example 15
Source File: RouteResourceController.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
/**
 * see feature 0003664: tRunJob: When opening the tree dialog to select the job target, it could be useful to open
 * it on previous selected job if exists.
 *
 * @param button
 * @param dialog
 */
private void selectNodeIfExists(Button button, RouteResourceSelectionDialog dialog) {
    try {
        if (elem != null && elem instanceof Node) {
            Node runJobNode = (Node) elem;
            String paramName = (String) button.getData(PARAMETER_NAME);
            String jobId = (String) runJobNode.getPropertyValue(paramName); // .getElementParameter(name).getValue();
            dialog.setSelectedNodeId(jobId);
        }
    } catch (Throwable e) {
        ExceptionHandler.process(e);
    }
}
 
Example 16
Source File: RouteInputProcessTypeController.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
protected Command createButtonCommand(Button button) {
	AssignJobWizard assignJobWizard = new AssignJobWizard();
	WizardDialog wizardDialog = new AssignJobWizardDialog(button.getShell(), assignJobWizard);
	if (wizardDialog.open() == WizardDialog.OK) {
		String id = assignJobWizard.getSelectedProcessId();
		if(id != null){
			String paramName = (String) button.getData(PARAMETER_NAME);
			return new PropertyChangeCommand(elem, paramName, id);
		}
	}
	return null;
}
 
Example 17
Source File: HadoopLocationWizard.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
public void widgetSelected(SelectionEvent e) {
  final Button button = (Button) e.widget;
  final ConfProp prop = (ConfProp) button.getData("hProp");

  Display.getDefault().syncExec(new Runnable() {
    public void run() {
      // We want to receive the update also!
      mediator.notifyChange(null, prop, button.getSelection() ? "yes"
          : "no");
    }
  });
}
 
Example 18
Source File: OptionsConfigurationBlock.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void updateCheckBox(Button curr) {
	ControlData data = (ControlData) curr.getData();
	curr.setSelection(checkBoxValue(data));
}
 
Example 19
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 4 votes vote down vote up
protected void updateCheckBox(Button curr) {
	ControlData data = (ControlData) curr.getData();

	String currValue = getValue(data.getKey());
	curr.setSelection(data.getSelection(currValue) == 0);
}
 
Example 20
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected void updateCheckBox(Button curr) {
	ControlData data= (ControlData) curr.getData();

	String currValue= getValue(data.getKey());
	curr.setSelection(data.getSelection(currValue) == 0);
}