Java Code Examples for org.eclipse.swt.widgets.TableItem#getChecked()
The following examples show how to use
org.eclipse.swt.widgets.TableItem#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: EnhancedCheckBoxTableViewer.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Sets which nodes are checked in this viewer. The given list contains the elements that are to * be checked; all other nodes are to be unchecked. * <p> * This method is typically used when restoring the interesting state of a viewer captured by an * earlier call to <code>getCheckedElements</code>. * </p> * * @param elements * the list of checked elements (element type: <code>Object</code>) * @see #getCheckedElements */ public void setCheckedElements(Object[] elements) { assertElementsNotNull(elements); CustomHashtable set = newHashtable(elements.length * 2 + 1); for (int i = 0; i < elements.length; ++i) { set.put(elements[i], elements[i]); } TableItem[] items = getTable().getItems(); for (int i = 0; i < items.length; ++i) { TableItem item = items[i]; Object element = item.getData(); if (element != null) { boolean check = set.containsKey(element); // only set if different, to avoid flicker if (item.getChecked() != check) { item.setChecked(check); } } } }
Example 2
Source File: FormHelper.java From tlaplus with MIT License | 6 votes |
/** * Reads the input (list of formulas) and returns a list of strings which can be serialized * @param source - viewer containing the formulas/assignments * @return */ public static List<String> getSerializedInput(final TableViewer tableViewer) { if (tableViewer instanceof CheckboxTableViewer) { final ArrayList<String> result = new ArrayList<>(); final TableItem[] tableItems = tableViewer.getTable().getItems(); final int itemCount = tableItems.length; for (int i = 0; i < itemCount; i++) { final TableItem item = tableItems[i]; final String serialized = (item.getChecked() ? "1" : "0") + item.getText(); result.add(serialized); } return result; } else { @SuppressWarnings("unchecked") List<Assignment> assignments = (List<Assignment>) tableViewer.getInput(); if (assignments == null) { return null; } return ModelHelper.serializeAssignmentList(assignments); } }
Example 3
Source File: FilterListDialog.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@Override public void okPressed() { if (fTable.getItemCount() > 0) { fFilters = new ArrayList<>(); } else { fFilters = null; } for (int i = 0; i < fTable.getItemCount(); i++) { TableItem item = fTable.getItem(i); CriteriaTableItem cti = (CriteriaTableItem) item.getData(); FilterCriteria fc = new FilterCriteria(cti.getCriteria(), item.getChecked(), cti.isPositive(), cti.getLoaderClassName()); FilterCriteria efc = FilterCriteria.find(fc, fFilters); if (efc == null) { fFilters.add(fc); } else { efc.setActive(efc.isActive() || fc.isActive()); } } super.close(); fProvider.filter(fFilters); saveFiltersCriteria(fFilters); }
Example 4
Source File: ManifestServicesDialog.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
@Override protected boolean performDialogOperation(IProgressMonitor progressMonitor) { // OK was pressed // Record the ticked Services _serviceList.clear(); TableItem[] items = _serviceTable.getTable().getItems(); for (TableItem item : items) { if (item.getChecked() == true) { if (item.getData() instanceof CloudService) { CloudService cs = (CloudService) item.getData(); _serviceList.add(new TableEntry(cs.getName())); } } } return true; }
Example 5
Source File: ExportToTestDataDialog.java From ermaster-b with Apache License 2.0 | 6 votes |
@Override protected String getErrorMessage() { boolean itemChecked = false; for (TableItem item : this.testDataTable.getItems()) { if (item.getChecked()) { itemChecked = true; break; } } if (!itemChecked) { return "error.testdata.not.selected"; } if (this.outputDirectoryText.isBlank()) { return "error.output.dir.is.empty"; } return null; }
Example 6
Source File: ListenersDialog.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void okPressed() { selectedEvents.clear(); for (int i = 0; i < table.getItemCount(); i++) { TableItem item = table.getItem(i); if (item.getChecked()) { selectedEvents.add(item.getData()); } } super.okPressed(); }
Example 7
Source File: EnhancedCheckBoxTableViewer.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns a list of elements corresponding to checked table items in this viewer. * <p> * This method is typically used when preserving the interesting state of a viewer; * <code>setCheckedElements</code> is used during the restore. * </p> * * @return the array of checked elements * @see #setCheckedElements */ public Object[] getCheckedElements() { TableItem[] children = getTable().getItems(); ArrayList<Object> v = new ArrayList<>(children.length); for (int i = 0; i < children.length; i++) { TableItem item = children[i]; if (item.getChecked()) { v.add(item.getData()); } } return v.toArray(); }
Example 8
Source File: IgnorePage.java From neoscada with Eclipse Public License 1.0 | 5 votes |
protected Set<String> gatherIgnoredFactories () { final Set<String> result = new HashSet<String> (); for ( final TableItem item : this.factoriesViewer.getTable ().getItems () ) { if ( item.getChecked () ) { final String data = (String)item.getData (); result.add ( data ); } } return result; }
Example 9
Source File: SWTCheckTable.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public boolean isCheckedItem(UITableItem<T> item) { TableItem tableItem = this.getTableItem(item); if( tableItem != null ) { return tableItem.getChecked(); } return false; }
Example 10
Source File: XMLAnalysesManagerPreferencePage.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Apply change to items according to their checkboxes. */ private void handleChecks() { Map<@NonNull String, @NonNull File> listFiles = XmlUtils.listFiles(); Collection<String> filesToEnable = Lists.newArrayList(); Collection<String> filesToDisable = Lists.newArrayList(); for (TableItem item : fAnalysesTable.getItems()) { String xmlName = XmlUtils.createXmlFileString(item.getText()); // Only enable/disable if the checkbox status has changed if (item.getChecked() && !XmlUtils.isAnalysisEnabled(xmlName)) { // Do not enable an invalid file if (isFileValid(xmlName, listFiles)) { filesToEnable.add(xmlName); } else { item.setChecked(false); } } else if (!item.getChecked() && XmlUtils.isAnalysisEnabled(xmlName)) { filesToDisable.add(xmlName); } } // Apply changes if (!(filesToEnable.isEmpty() && filesToDisable.isEmpty())) { enableAndDisableAnalyses(filesToEnable, filesToDisable); } // Force update for selection handling handleSelection(fAnalysesTable.getSelection()); }
Example 11
Source File: ExportTracePackageSelectTraceWizardPage.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private ArrayList<TmfTraceElement> getCheckedTraces() { TableItem[] items = fTraceTable.getItems(); ArrayList<TmfTraceElement> traces = new ArrayList<>(); for (TableItem item : items) { if (item.getChecked()) { TmfTraceElement trace = (TmfTraceElement) item.getData(); traces.add(trace); } } return traces; }
Example 12
Source File: XmlTableForm.java From tesb-studio-se with Apache License 2.0 | 5 votes |
public Collection<XmlFileConnectionItem> getSelectionItems() { final Collection<XmlFileConnectionItem> itemMap = new ArrayList<XmlFileConnectionItem>(); for (TableItem tableItem : table.getItems()) { if (tableItem.getChecked()) { itemMap.add(((Item) tableItem.getData()).getObj()); } } return itemMap; }
Example 13
Source File: ProjectBuildPathPropertyPage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Handle table selection. In case it's a single selection, enable/disable the 'Up' and 'Down' buttons according to * the selection. We only allow up and down for checked items. */ private void handleTableSelection() { ISelection selection = tableViewer.getSelection(); if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; Table table = tableViewer.getTable(); if (structuredSelection.size() == 1 && table.getItemCount() > 1) { int selectionIndex = table.getSelectionIndex(); TableItem item = table.getItem(selectionIndex); IBuildPathEntry data = (IBuildPathEntry) item.getData(); if (item.getChecked()) { upButton.setEnabled(selectionIndex != 0); downButton.setEnabled(selectionIndex < table.getItemCount() - 1 && selectionIndex < tableViewer.getCheckedElements().length - 1); if (!selectedEntries.contains(data)) { selectedEntries.add(data); tableViewer.refresh(); } } else { if (selectedEntries.contains(data)) { selectedEntries.remove(data); tableViewer.refresh(); } upButton.setEnabled(false); downButton.setEnabled(false); } } else { upButton.setEnabled(false); downButton.setEnabled(false); } } }
Example 14
Source File: NetworkPreferencePage.java From saros with GNU General Public License v2.0 | 4 votes |
@Override public boolean performOk() { setErrorMessage(null); final String stunIPAddress = stunIPAddressText.getText().trim(); final String stunPort = stunPortText.getText().trim(); if (!stunIPAddress.isEmpty() && !checkStunIpAddress(stunIPAddress)) { setErrorMessage(Messages.NetworkPreferencePage_text_stun_server_not_valid); return false; } if (!stunPort.isEmpty() && !checkPort(stunPortText.getText())) { setErrorMessage(Messages.NetworkPreferencePage_text_stun_server_not_valid2); return false; } if (!checkPort(localSocks5PortText.getText())) { setErrorMessage(Messages.NetworkPreferencePage_text_direct_connection_not_valid); return false; } getPreferenceStore() .setValue(PreferenceConstants.FORCE_IBB_CONNECTIONS, buttonOnlyAllowIBB.getSelection()); getPreferenceStore() .setValue( PreferenceConstants.LOCAL_SOCKS5_PROXY_DISABLED, buttonOnlyAllowMediatedSocks5.getSelection() || buttonOnlyAllowIBB.getSelection()); getPreferenceStore() .setValue( PreferenceConstants.FILE_TRANSFER_PORT, Integer.valueOf(localSocks5PortText.getText())); getPreferenceStore() .setValue( PreferenceConstants.USE_NEXT_PORTS_FOR_FILE_TRANSFER, buttonAllowAlternativeSocks5Port.getSelection()); getPreferenceStore() .setValue( PreferenceConstants.LOCAL_SOCKS5_PROXY_CANDIDATES, localSocks5CandidatesText.getText()); getPreferenceStore() .setValue( PreferenceConstants.LOCAL_SOCKS5_PROXY_USE_UPNP_EXTERNAL_ADDRESS, buttonIncludeUPNPGatewayAddress.getSelection()); getPreferenceStore().setValue(PreferenceConstants.STUN, stunIPAddress); getPreferenceStore() .setValue( PreferenceConstants.STUN_PORT, stunPort.isEmpty() ? 0 : Integer.valueOf(stunPort)); final String currentSavedUPNPDeviceID = getPreferenceStore().getString(PreferenceConstants.AUTO_PORTMAPPING_DEVICEID); String currentSelectedUPNPDeviceID = null; for (TableItem item : upnpDevicesTable.getItems()) { if (!item.getChecked()) continue; currentSelectedUPNPDeviceID = (String) item.getData(); } if (currentSelectedUPNPDeviceID != null) { getPreferenceStore() .setValue(PreferenceConstants.AUTO_PORTMAPPING_DEVICEID, currentSelectedUPNPDeviceID); if (!currentSelectedUPNPDeviceID.equals(currentSavedUPNPDeviceID)) SarosView.showNotification( Messages.NetworkPreferencePage_upnp_activation, Messages.NetworkPreferencePage_upnp_activation_text); } else { getPreferenceStore().setToDefault(PreferenceConstants.AUTO_PORTMAPPING_DEVICEID); } return super.performOk(); }
Example 15
Source File: ExportToTestDataDialog.java From ermaster-b with Apache License 2.0 | 4 votes |
@Override protected void perfomeOK() throws InputException { if (this.formatSqlRadio.getSelection()) { this.exportTestDataSetting .setExportFormat(TestData.EXPORT_FORMT_SQL); } else if (this.formatDBUnitRadio.getSelection()) { this.exportTestDataSetting .setExportFormat(TestData.EXPORT_FORMT_DBUNIT); } else if (this.formatDBUnitFlatXmlRadio.getSelection()) { this.exportTestDataSetting .setExportFormat(TestData.EXPORT_FORMT_DBUNIT_FLAT_XML); } else if (this.formatDBUnitXlsRadio.getSelection()) { this.exportTestDataSetting .setExportFormat(TestData.EXPORT_FORMT_DBUNIT_XLS); } this.exportTestDataSetting.setExportFilePath(this.outputDirectoryText .getFilePath()); this.exportTestDataSetting.setExportFileEncoding(this.fileEncodingCombo .getText()); try { for (int i = 0; i < this.testDataTable.getItemCount(); i++) { TableItem item = this.testDataTable.getItem(i); if (item.getChecked()) { exportTestData(this.diagram, this.exportTestDataSetting, testDataList.get(i)); } } Activator.showMessageDialog("dialog.message.export.finish"); } catch (IOException e) { Activator.showExceptionDialog(e); } this.refreshProject(); }