Java Code Examples for org.eclipse.jface.viewers.CheckStateChangedEvent#getChecked()

The following examples show how to use org.eclipse.jface.viewers.CheckStateChangedEvent#getChecked() . 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: SDKsPreferencePage.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
    if (isCancelEvents) return;
    try{
        isCancelEvents = true;

        Sdk activeSdk = sdkRegistry.getDefaultSdk();
        if (activeSdk == event.getElement() && !event.getChecked()) {
            sdkTableViewer.setChecked(activeSdk, true);
        }
        else if (activeSdk != event.getElement()) {
            if (activeSdk != null) {
                sdkTableViewer.setChecked(activeSdk, false);
            }
            activeSdk = (Sdk)event.getElement();
            sdkRegistry.setDefaultSdk(activeSdk.getName());
            getApplyButton().setEnabled(true);

        }
    }
    finally{
        isCancelEvents = false;
    }
}
 
Example 2
Source File: ExportBarWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void checkStateChanged(final CheckStateChangedEvent event) {
    final Object element = event.getElement();
    if (element instanceof MainProcess) {
        viewer.setGrayChecked(element, false);
        viewer.setChecked(element, event.getChecked());
        for (final AbstractProcess proc : ModelHelper.getAllProcesses((Element) element)) {
            viewer.setChecked(proc, event.getChecked());
            if (event.getChecked()) {
                selectedProcess.add(proc);
            } else {
                selectedProcess.remove(proc);
            }
        }
    }
    if (element instanceof Pool) {
        final MainProcess diagram = ModelHelper.getMainProcess((EObject) element);
        viewer.setGrayChecked(diagram, false);
        if (isGrayed(diagram)) {
            viewer.setGrayChecked(diagram, true);
        } else {
            viewer.setChecked(diagram, event.getChecked());
        }
    }
}
 
Example 3
Source File: ChartMakerDialog.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void checkStateChanged(@Nullable CheckStateChangedEvent event) {
    if (event == null) {
        return;
    }

    /* Set Y filter if needed */
    if (event.getChecked()) {
        if (fYFilter == null) {
            IDataChartDescriptor<?, ?> descriptor = (IDataChartDescriptor<?, ?>) event.getElement();
            fYFilter = descriptor;
        }
    } else {
        tryResetYFilter();
    }

    /* Refresh controls */
    fSelectionYTable.refresh();
    fAddButton.setEnabled(checkIfButtonReady());

    configureLogscaleCheckboxes();
}
 
Example 4
Source File: TimeGraphFilterDialog.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
    try {
        ITimeGraphEntry entry = (ITimeGraphEntry) event.getElement();
        boolean checked = event.getChecked();
        if (checked) {
            checkElement(entry);
        } else {
            uncheckElement(entry);
        }
    } catch (ClassCastException e) {
        return;
    } finally {
        updateOKStatus();
    }
}
 
Example 5
Source File: FieldToContractInputMappingViewerCheckStateManager.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void deselectParentIfNoChildSelected(CheckStateChangedEvent event,
        FieldToContractInputMapping mapping,
        CheckboxTreeViewer checkboxTreeViewer) {
    FieldToContractInputMapping parentMapping = mapping.getParent();
    if (parentMapping != null && !event.getChecked() && hasNoChildGenerated(parentMapping)) {
        checkboxTreeViewer.setChecked(parentMapping, false);
        parentMapping.setGenerated(false);
        setGeneratedStatePersistenceIdChild(parentMapping, false);
        deselectParentIfNoChildSelected(event, parentMapping, checkboxTreeViewer);
    }
}
 
Example 6
Source File: FieldToContractInputMappingViewerCheckStateManager.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void selectParentIfChildIsSelected(CheckStateChangedEvent event, FieldToContractInputMapping mapping,
        CheckboxTreeViewer checkboxTreeViewer) {
    if (event.getChecked()) {
        final FieldToContractInputMapping parentMapping = mapping.getParent();
        if (parentMapping != null) {
            checkboxTreeViewer.setChecked(parentMapping, true);
            parentMapping.setGenerated(true);
            setGeneratedStatePersistenceIdChild(parentMapping, true);
            selectParentIfChildIsSelected(event, parentMapping, checkboxTreeViewer);
        }
    }
}
 
Example 7
Source File: ConstraintAttributeCheckListener.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void checkStateChanged(CheckStateChangedEvent e) {
    Field element = (Field) e.getElement();
    if (e.getChecked()) {
        selectedConstraintObservable.getValue().getFieldNames().add(element.getName());
    } else {
        selectedConstraintObservable.getValue().getFieldNames().remove(element.getName());
    }
    selectedAttributeObservable.setValue(element);
    constraintViewer.refresh(selectedConstraintObservable.getValue());
    formPage.updateDefaultQueries();
}
 
Example 8
Source File: BaseResourceSelectionComposite.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
  final Object element = event.getElement();
  boolean isChecked = event.getChecked();

  IResource resource = (IResource) element;

  handleCheckStateChanged(resource, isChecked);
  notifyResourceSelectionChanged(resource, isChecked);

  rememberSelection();
}
 
Example 9
Source File: SliceProfileDialog.java    From JDeodorant with MIT License 5 votes vote down vote up
public void checkStateChanged(CheckStateChangedEvent event) {
	PlainVariable element = (PlainVariable)event.getElement();
	enabledVariableMap.put(element, event.getChecked());
	int index = getColumnIndex(element);
	if(event.getChecked())
		sliceProfileTableViewer.getTable().getColumn(index).setWidth(columnWidthMap.get(element));
	else
		sliceProfileTableViewer.getTable().getColumn(index).setWidth(0);
	updateMetrics();
}
 
Example 10
Source File: WebSearchPreferencePage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * (non-Javadoc)
 * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
 */
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
	Object element = event.getElement();
	if (element instanceof SearchEntry) {
		SearchEntry searchEntry = (SearchEntry) element;
		if (searchEntry.isChecked() != event.getChecked()) {
			searchEntry.setChecked(event.getChecked());
			setDirty(true);
		}
	}
}
 
Example 11
Source File: CheckedListDialogField.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void doCheckStateChanged(CheckStateChangedEvent e) {
	if (e.getChecked()) {
		@SuppressWarnings("unchecked")
		E element= (E) e.getElement();
		fCheckedElements.add(element);
	} else {
		fCheckedElements.remove(e.getElement());
	}
	checkStateChanged();
}
 
Example 12
Source File: WizardFolderImportPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void checkStateChanged(CheckStateChangedEvent event)
{
	// Check if the current checked items are the same as the initial ones.
	Object[] checkedElements = fTableViewer.getCheckedElements();
	if (fPrimaryNature == null)
	{
		// in case that the item was checked, set it as the primary
		if (event.getChecked())
		{
			updatePrimaryNature(event.getElement().toString());
			fTableViewer.refresh();
		}
	}
	else
	{
		if (!event.getChecked() && isPrimary(event.getElement()))
		{
			// find the next available item which is checked and set it to
			// the primary
			if (checkedElements.length == 0)
			{
				updatePrimaryNature(null);
			}
			else
			{
				updatePrimaryNature(checkedElements[0].toString());
			}
			fTableViewer.refresh();
		}
	}
	updateButtons();
}
 
Example 13
Source File: ProjectNaturesPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void checkStateChanged(CheckStateChangedEvent event)
{
	// Check if the current checked items are the same as the initial ones.
	Object[] checkedElements = fTableViewer.getCheckedElements();
	fNaturesModified = !Arrays.equals(fInitialCheckedItems, checkedElements);
	if (fPrimaryNature == null)
	{
		// in case that the item was checked, set it as the primary
		if (event.getChecked())
		{
			updatePrimaryNature(event.getElement().toString());
			fTableViewer.refresh();
		}
	}
	else
	{
		if (!event.getChecked() && isPrimary(event.getElement()))
		{
			// find the next available item which is checked and set it to
			// the primary
			if (checkedElements.length == 0)
			{
				updatePrimaryNature(null);
			}
			else
			{
				updatePrimaryNature(checkedElements[0].toString());
			}
			fTableViewer.refresh();
		}
	}
	updateButtons();
}
 
Example 14
Source File: AddContextDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
  if (event.getChecked()) {
      if (event.getElement() instanceof AllContexts) {
          fContextsViewer.setSubtreeChecked(event.getElement(), true);
      }
  } else {
      if (event.getElement() instanceof AllContexts) {
          fContextsViewer.setSubtreeChecked(event.getElement(), false);
      } else {
          IContextModelComponent component = (IContextModelComponent) event.getElement();
          fContextsViewer.setChecked(component.getParent(), false);
      }
  }
}
 
Example 15
Source File: EnableKernelEventComposite.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
  if (event.getChecked()) {
      if (event.getElement() instanceof KernelProviderComponent) {
          fCheckBoxTreeViewer.setSubtreeChecked(event.getElement(), true);
      }
  } else {
      if (event.getElement() instanceof KernelProviderComponent) {
          fCheckBoxTreeViewer.setSubtreeChecked(event.getElement(), false);
      } else {
          ITraceControlComponent component = (ITraceControlComponent) event.getElement();
          fCheckBoxTreeViewer.setChecked(component.getParent(), false);
      }
  }
}
 
Example 16
Source File: TraceTypePreferencePageViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
    try {
        boolean checked = event.getChecked();
        if (checked) {
            checkElement(event.getElement());
        } else {
            uncheckElement(event.getElement());
        }
    } catch (ClassCastException e) {
        Activator.getDefault().logError("Failed to enable trace types", e); //$NON-NLS-1$
        return;
    }
}
 
Example 17
Source File: FilterBugsDialog.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
    Object element = event.getElement();
    boolean checked = event.getChecked();

    elementChecked(element, checked);
    updateTextIds();
}
 
Example 18
Source File: MOOSETreeCheckStateManager.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * This method is called when one of the nodes in the tree is checked. For
 * MOOSE trees, this must enforce two rules:
 * <ul>
 * <li>When a node is checked, all of its ancestor nodes should be checked.</li>
 * <li>When a node is unchecked, all of its descendant nodes should be
 * unchecked.</li>
 * </ul>
 */
@Override
public void checkStateChanged(CheckStateChangedEvent event) {

	if (event != null && event.getElement() instanceof TreeComposite) {
		// Get the checked/unchecked node.
		TreeViewer treeViewer = (TreeViewer) event.getSource();
		TreeComposite node = (TreeComposite) event.getElement();

		boolean checked = event.getChecked();

		// If checked, all ancestor nodes should also be checked. This is
		// done by setting their active flags.
		if (checked) {
			while (node != null) {
				// If the state of the node changes, we need to tell the
				// TreeViewer to refresh that element.
				if (!node.isActive()) {
					node.setActive(true);
					treeViewer.update(node, null);
				}
				node = node.getParent();
			}
		}

		// Either way, all descendant nodes should have the same check state
		// as the ancestor node when it changes.

		// Get the root node (it may have changed due to the above loop).
		node = (TreeComposite) event.getElement();

		// Get a breadth-first iterator so we can walk the tree.
		Iterator<TreeComposite> iterator;
		iterator = new BreadthFirstTreeCompositeIterator(node);
		// Loop over and deactivate the children.
		while (iterator.hasNext()) {
			node = iterator.next();
			// If the state of the node changes, we need to tell the
			// TreeViewer to refresh that element.
			if (node.isActive() != checked) {
				node.setActive(checked);
				treeViewer.update(node, null);
			}
		}
	}

	return;
}
 
Example 19
Source File: ValidPreferenceCheckedTreeViewer.java    From dsl-devkit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * React to a change event on the Checked state of a category.
 *
 * @param event
 *          the event
 * @param category
 *          the category
 */
private void categoryChecked(final CheckStateChangedEvent event, final PreferenceCategory category) {
  if (!event.getChecked() && category.hasOnlyMandatoryRules()) {
    // revert the change
    event.getCheckable().setChecked(category, true);
  }
}
 
Example 20
Source File: ValidPreferenceCheckedTreeViewer.java    From dsl-devkit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Emit a warning (a dialog box) whenever the users tries to uncheck a mandatory rule.
 *
 * @param event
 *          the event
 * @param rule
 *          the rule
 */
private void ruleChecked(final CheckStateChangedEvent event, final PreferenceRule rule) {
  if (!event.getChecked() && !rule.isOptional()) {
    // revert the change
    event.getCheckable().setChecked(rule, true);
  }
}