List of usage examples for org.eclipse.jface.viewers CheckboxTableViewer newCheckList
public static CheckboxTableViewer newCheckList(Composite parent, int style)
From source file:com.mercatis.lighthouse3.security.ui.editors.pages.AbstractPermissionEditorPage.java
License:Apache License
/** * Use this method to create the role section. Roles are displayed as a list * of checkboxes.//from w w w . ja v a 2 s .com * * @param form * @param toolkit * @param sectionText */ protected void createRoleSection(ScrolledForm form, FormToolkit toolkit) { Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR); section.clientVerticalSpacing = 5; section.marginHeight = 3; section.marginWidth = 3; GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); section.setLayoutData(gd); section.setText(getPermissionSectionName()); Composite client = toolkit.createComposite(section); toolkit.paintBordersFor(client); client.setLayout(new FillLayout()); roleViewer = CheckboxTableViewer.newCheckList(client, SWT.BORDER); roleViewer.setSorter(new ViewerSorter()); roleViewer.setContentProvider(ArrayContentProvider.getInstance()); List<String> roles = new LinkedList<String>(); for (Role role : Role.values()) { roles.add(role.roleAsString()); } roleViewer.setInput(roles); roleViewer.addCheckStateListener(checkStateListener); section.setClient(client); }
From source file:com.mobilesorcery.sdk.profiles.ui.internal.FeatureFilterDialog.java
License:Open Source License
public Control createDialogArea(Composite parent) { getShell().setText(getName());// w ww . j av a 2 s . c o m Composite contents = new Composite(parent, SWT.NONE); contents.setLayout(new GridLayout(1, false)); require = new Button(contents, SWT.RADIO); require.setText(Messages.FeatureFilterDialog_Require); require.setSelection(filter.getStyle() == FeatureFilter.REQUIRE); disallow = new Button(contents, SWT.RADIO); disallow.setText(Messages.FeatureFilterDialog_Disallow); require.setSelection(filter.getStyle() == FeatureFilter.DISALLOW); selectedFeature = CheckboxTableViewer.newCheckList(contents, SWT.BORDER | SWT.SINGLE); selectedFeature.setContentProvider(new ArrayContentProvider()); selectedFeature.setLabelProvider(new FeatureLabelProvider()); selectedFeature.getControl() .setLayoutData(new GridData(UIUtils.getDefaultFieldSize(), UIUtils.getDefaultListHeight())); selectedFeature.setInput( MoSyncTool.getDefault().getAvailableFeatureDescriptions(MoSyncTool.EXCLUDE_CONSTANTS_FILTER)); selectedFeature.setCheckedElements(filter.getFeatureIds()); selectedFeature.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { updateUI(); } }); GridData selectedFeatureData = new GridData(); selectedFeatureData.grabExcessHorizontalSpace = true; selectedFeatureData.heightHint = 200; selectedFeature.getControl().setLayoutData(selectedFeatureData); return contents; }
From source file:com.motorola.studio.android.codeutils.codegeneration.CreateSampleDatabaseActivityColumnsPage.java
License:Apache License
@Override protected void createExtendedControls(Composite parent) { Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(new GridLayout()); mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite composite = new Composite(mainComposite, SWT.NONE); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); // Create a checkbox table viewer checkboxTableViewer = CheckboxTableViewer.newCheckList(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); checkboxTableViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Set a content and label provider checkboxTableViewer.setLabelProvider(new SampleDatabaseActivityColumnsPageLabelProvider()); checkboxTableViewer.setContentProvider(new ArrayContentProvider()); // Add a listener to the table viewer checkboxTableViewer.addCheckStateListener(new CheckboxTableViewerListener()); // Add a listener to the wizard to listen for page changes if (getContainer() instanceof IPageChangeProvider) { ((IPageChangeProvider) getContainer()).addPageChangedListener(new PageChangeListener()); }//from w w w .jav a 2 s .c o m Composite buttonsComposite = new Composite(mainComposite, SWT.NONE); buttonsComposite.setLayout(new RowLayout(SWT.HORIZONTAL)); // Create buttons to select and deselect all items Button selectAllButton = new Button(buttonsComposite, SWT.PUSH | SWT.CENTER); selectAllButton.setText(CodeUtilsNLS.UI_CreateSampleDatabaseActivityColumnsPage_SelectAllButton); selectAllButton.addSelectionListener(new SelectAllButtonListener()); Button unselectAllButton = new Button(buttonsComposite, SWT.PUSH | SWT.CENTER); unselectAllButton.setText(CodeUtilsNLS.UI_CreateSampleDatabaseActivityColumnsPage_DeselectAllButton); unselectAllButton.addSelectionListener(new DeselectAllButtonLister()); PlatformUI.getWorkbench().getHelpSystem().setHelp(mainComposite, PAGE_HELP_ID); setControl(mainComposite); }
From source file:com.motorolamobility.preflighting.ui.tabs.CheckersTabComposite.java
License:Apache License
/** * Create and return the Checkers group. * It contains the table with all checkers listed. When a checker is * selected, the corresponding conditions are updated in the conditions * table.//from w w w . j a va2 s . co m * * @param topComposite the parent composite */ private void createCheckersGroup(Composite topComposite) { Group checkersGroup = new Group(topComposite, SWT.NONE); checkersGroup.setLayout(new GridLayout(1, false)); checkersGroup.setText(PreflightingUiNLS.CheckersTabComposite_Checkers_Group); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); checkersGroup.setLayoutData(gd); checkersTableViewer = CheckboxTableViewer.newCheckList(checkersGroup, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); Control checkersTableControl = checkersTableViewer.getTable(); gd = new GridData(SWT.FILL, SWT.FILL, true, true); checkersTableControl.setLayoutData(gd); checkersTableComparator = new CheckersTableComparator(); checkersTableViewer.setComparator(checkersTableComparator); /* * Create Columns */ TableViewerColumn column = new TableViewerColumn(checkersTableViewer, SWT.NONE); // Name column.getColumn().setText(PreflightingUiNLS.CheckersTabComposite_Name_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(230); column.setLabelProvider(new CheckersLabelProvider()); column.getColumn().addSelectionListener(new CheckersColumnSelectionAdapter(NAME_COLUMN_INDEX)); column = new TableViewerColumn(checkersTableViewer, SWT.NONE); // ID column.getColumn().setText(PreflightingUiNLS.CheckersTabComposite_Id_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(100); column.setLabelProvider(new CheckersLabelProvider()); column.getColumn().addSelectionListener(new CheckersColumnSelectionAdapter(ID_COLUMN_INDEX)); column = new TableViewerColumn(checkersTableViewer, SWT.NONE); // Parameters column.getColumn().setText(PreflightingUiNLS.CheckersTabComposite_Checker_Params_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(100); column.setLabelProvider(new CheckersLabelProvider()); column.getColumn().addSelectionListener(new CheckersColumnSelectionAdapter(CHECKER_PARAMS_COLUMN_INDEX)); // set a custom editor for this column column.setEditingSupport(new ParameterEditingSupport(checkersTableViewer)); column = new TableViewerColumn(checkersTableViewer, SWT.NONE); // Change Warning Level column.getColumn().setText(PreflightingUiNLS.CheckersTabComposite_ChangeWarningLevel_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(100); column.setLabelProvider(new CheckersLabelProvider()); column.getColumn().addSelectionListener( new CheckersColumnSelectionAdapter(CHECKER_CHANGE_WARNING_LEVEL_COLUMN_INDEX)); // set a custom editor for this column column.setEditingSupport(new WarningLevelEditingSupport(checkersTableViewer)); checkersTableViewer.getTable().setHeaderVisible(true); checkersTableViewer.setContentProvider(new CheckersContentProvider()); ColumnViewerToolTipSupport.enableFor(checkersTableViewer); // Selection Change Listener handles needed UI updates on the paramsText according to checkers selected // It also updates the conditions table checkersTableViewer.getTable().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CheckerDescription checkerDescription = (CheckerDescription) e.item.getData(); TableItem tableItem = (TableItem) e.item; updateConditionTableBasedOnChecker(tableItem.getChecked()); populateConditionsTable(checkerDescription.getId()); } }); // CheckStateListener handles the selectAll check box behavior and also selects the clicked item on the table. checkersTableViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { boolean isAllSelected = areAllItemsChecked(checkersTableViewer); selectAllCheckersCheck.setSelection(isAllSelected); checkersTableViewer.setSelection(new StructuredSelection(event.getElement()), true); updateConditionTableBasedOnChecker(event.getChecked()); notifyListener(); } }); ValidationManager validationManager = new ValidationManager(); checkersDescriptions = validationManager.getCheckersDescription(); checkerParams = new HashMap<String, String>(checkersDescriptions.size()); checkersTableViewer.setInput(checkersDescriptions); selectAllCheckersCheck = new Button(checkersGroup, SWT.CHECK); selectAllCheckersCheck.setText(PreflightingUiNLS.CheckersTabComposite_Checkers_SelectAll_Check); gd = new GridData(SWT.LEFT, SWT.BOTTOM, false, false); selectAllCheckersCheck.setLayoutData(gd); selectAllCheckersCheck.setSelection(true); selectAllCheckersCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { checkersTableViewer.setAllChecked(selectAllCheckersCheck.getSelection()); updateConditionTableBasedOnChecker(selectAllCheckersCheck.getSelection()); super.widgetSelected(e); notifyListener(); } }); checkersTableComparator.setColumn(0); }
From source file:com.motorolamobility.preflighting.ui.tabs.CheckersTabComposite.java
License:Apache License
/** * @param topComposite//from w ww .j a v a2s .c om */ private void createConditionsGroup(Composite topComposite) { Group conditionsGroup = new Group(topComposite, SWT.NONE); conditionsGroup.setLayout(new GridLayout(1, false)); conditionsGroup.setText(PreflightingUiNLS.CheckersTabComposite_Conditions_Group); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = 200; conditionsGroup.setLayoutData(gd); conditionsTableViewer = CheckboxTableViewer.newCheckList(conditionsGroup, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); Control conditionsTableControl = conditionsTableViewer.getTable(); gd.heightHint = 200; conditionsTableControl.setLayoutData(gd); conditionsTableViewer.setContentProvider(new ConditionsContentProvider()); ColumnViewerToolTipSupport.enableFor(conditionsTableViewer); conditionsTableComparator = new ConditionsTableComparator(); conditionsTableViewer.setComparator(conditionsTableComparator); // Create Columns TableViewerColumn column = new TableViewerColumn(conditionsTableViewer, SWT.NONE); // Name column.getColumn().setText(PreflightingUiNLS.CheckersTabComposite_Name_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(230); column.setLabelProvider(new ConditionsLabelProvider()); column.getColumn().addSelectionListener(new ConditionsColumnSelectionAdapter(NAME_COLUMN_INDEX)); column = new TableViewerColumn(conditionsTableViewer, SWT.NONE); // ID column.getColumn().setText(PreflightingUiNLS.CheckersTabComposite_Id_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(100); column.setLabelProvider(new ConditionsLabelProvider()); column.getColumn().addSelectionListener(new ConditionsColumnSelectionAdapter(ID_COLUMN_INDEX)); column = new TableViewerColumn(conditionsTableViewer, SWT.NONE); // Warning Level column.getColumn().setText(PreflightingUiNLS.CheckersTabComposite_WarningLevel_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(100); column.setLabelProvider(new ConditionsLabelProvider()); column.getColumn() .addSelectionListener(new ConditionsColumnSelectionAdapter(CONDITION_WARNING_LEVEL_COLUMN_INDEX)); column = new TableViewerColumn(conditionsTableViewer, SWT.NONE); // Change Warning Level column.getColumn().setText(PreflightingUiNLS.CheckersTabComposite_ChangeWarningLevel_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(100); column.setLabelProvider(new ConditionsLabelProvider()); column.getColumn().addSelectionListener( new ConditionsColumnSelectionAdapter(CONDITION_CHANGE_WARNING_LEVEL_COLUMN_INDEX)); // set a custom editor for this column column.setEditingSupport(new WarningLevelEditingSupport(conditionsTableViewer)); conditionsTableViewer.getTable().setHeaderVisible(true); conditionsTableViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { // update "select all" control boolean isAllSelected = areAllItemsChecked(conditionsTableViewer); selectAllConditionsCheck.setSelection(isAllSelected); // move the selection to the checked item conditionsTableViewer.setSelection(new StructuredSelection(event.getElement()), true); // get the condition and the checker that are selected Condition condition = (Condition) event.getElement(); CheckerDescription selectedChecker = (CheckerDescription) ((StructuredSelection) checkersTableViewer .getSelection()).getFirstElement(); // update the selected conditions maps accordingly, adding the specified condition // if the checkbox is checked or removing it otherwise List<Condition> conditions = selectedConditionsMap.get(selectedChecker.getId()); if (event.getChecked()) { conditions.add(condition); } else { conditions.remove(condition); } notifyListener(); } }); selectAllConditionsCheck = new Button(conditionsGroup, SWT.CHECK); selectAllConditionsCheck.setText(PreflightingUiNLS.CheckersTabComposite_Checkers_SelectAll_Check); gd = new GridData(SWT.LEFT, SWT.BOTTOM, false, false); selectAllConditionsCheck.setLayoutData(gd); selectAllConditionsCheck.setSelection(true); selectAllConditionsCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // update UI conditionsTableViewer.setAllChecked(selectAllConditionsCheck.getSelection()); // update model CheckerDescription selectedChecker = (CheckerDescription) ((StructuredSelection) checkersTableViewer .getSelection()).getFirstElement(); // get all conditions of the selected checker and add them to the selected conditions list if (selectAllConditionsCheck.getSelection()) { selectAllConditions(selectedChecker.getId()); } // clear the selected conditions list else { selectedConditionsMap.put(selectedChecker.getId(), new ArrayList<Condition>()); } super.widgetSelected(e); notifyListener(); } }); selectAllConditionsCheck.setEnabled(conditionsTableViewer.getTable().isEnabled()); conditionsTableComparator.setColumn(0); }
From source file:com.motorolamobility.preflighting.ui.tabs.DevicesTabComposite.java
License:Apache License
/** * Construct the GUI for the Devices Tab. * @param parent// w w w .j a v a 2 s . c om * @param style * @param preferenceStore */ public DevicesTabComposite(Composite parent, int style, IPreferenceStore preferenceStore) { super(parent, style); //Create main layout this.setLayout(new GridLayout(1, false)); Group deviceListGroup = new Group(this, SWT.NONE); Layout layout = new GridLayout(1, false); deviceListGroup.setLayout(layout); deviceListGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); deviceListGroup.setText(PreflightingUiNLS.DevicesTabComposite_Devices_Group); devicesTableViewer = CheckboxTableViewer.newCheckList(deviceListGroup, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); Control devicesTableControl = devicesTableViewer.getTable(); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = parent.getSize().y; devicesTableControl.setLayoutData(gd); devicesTableComparator = new DevicesTableComparator(); devicesTableViewer.setComparator(devicesTableComparator); //Create Columns TableViewerColumn column = new TableViewerColumn(devicesTableViewer, SWT.NONE); column.getColumn().setText(PreflightingUiNLS.DevicesTabComposite_Name_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(250); column.getColumn().addSelectionListener(new ColumnSelectionAdapter(NAME_COLUMN_INDEX)); column = new TableViewerColumn(devicesTableViewer, SWT.NONE); column.getColumn().setText(PreflightingUiNLS.DevicesTabComposite_ScreenSize_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(80); column.getColumn().addSelectionListener(new ColumnSelectionAdapter(SCREENSIZE_COLUMN_INDEX)); column = new TableViewerColumn(devicesTableViewer, SWT.NONE); column.getColumn().setText(PreflightingUiNLS.DevicesTabComposite_pixelDensity_Column); column.getColumn().setResizable(true); column.getColumn().setWidth(80); column.getColumn().addSelectionListener(new ColumnSelectionAdapter(PIXELDENSITY_COLUMN_INDEX)); //Configure Table devicesTableViewer.getTable().setHeaderVisible(true); devicesTableViewer.setContentProvider(new DevicesContentProvider()); devicesTableViewer.setLabelProvider(new DevicesLabelProvider()); ValidationManager validationManager = new ValidationManager(); Collection<DeviceSpecification> deviceSpecifications = validationManager.getDevicesSpecsContainer() .getDeviceSpecifications(); devicesTableViewer.setInput(deviceSpecifications); devicesTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { boolean isAllSelected = isAllItemsChecked(); selectAllCheck.setSelection(isAllSelected); } }); //Create Select all section Composite bottomComposite = new Composite(deviceListGroup, SWT.NONE); gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false); bottomComposite.setLayoutData(gd); layout = new GridLayout(2, true); bottomComposite.setLayout(layout); gd = new GridData(SWT.END, SWT.CENTER, false, true); selectAllCheck = new Button(bottomComposite, SWT.CHECK); selectAllCheck.setText(PreflightingUiNLS.DevicesTabComposite_SelectAll_Check); selectAllCheck.setLayoutData(gd); selectAllCheck.setSelection(true); selectAllCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { modifyCheckBoxes(selectAllCheck.getSelection()); super.widgetSelected(e); } }); init(preferenceStore); }
From source file:com.motorolamobility.studio.android.certmanager.ui.dialogs.BackupDialog.java
License:Apache License
@Override protected Control createDialogArea(Composite parent) { getShell().setText(title);/* ww w. j a v a2 s.c o m*/ setTitle(CertificateManagerNLS.BackupDialog_DialogTitle); //the shell has the same help as its page PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), BackupDialog.BACKUP_KEYSTORE_HELP_ID); Composite dialogArea = new Composite(parent, SWT.FILL); dialogArea.setLayout(new GridLayout()); dialogArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Group pathGroup = new Group(dialogArea, SWT.SHADOW_NONE); pathGroup.setText(CertificateManagerNLS.BackupDialog_Backup_File); pathGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); pathGroup.setLayout(new GridLayout(3, false)); Label pathLabel = new Label(pathGroup, SWT.NONE); pathLabel.setText(CertificateManagerNLS.BackupDialog_Path); pathLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); final Text pathText = new Text(pathGroup, SWT.BORDER); pathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); pathText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { archivePath = pathText.getText(); archiveFile = new File(archivePath); verifyOverwrite = true; validate(); } }); Button browseButton = new Button(pathGroup, SWT.PUSH); browseButton.setText(CertificateManagerNLS.BackupDialog_Browse); browseButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(getShell(), SWT.SAVE); fileDialog.setFilterExtensions(new String[] { "*" + ZIP_EXT //$NON-NLS-1$ }); fileDialog.setOverwrite(true); String choosenPath = fileDialog.open(); pathText.setText(choosenPath); verifyOverwrite = false; super.widgetSelected(e); } }); Group keystoresGroup = new Group(dialogArea, SWT.SHADOW_NONE); keystoresGroup.setText(CertificateManagerNLS.BackupDialog_KeyStores); keystoresGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); keystoresGroup.setLayout(new GridLayout(1, false)); tableViewer = CheckboxTableViewer.newCheckList(keystoresGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK | SWT.BORDER); tableViewer.setContentProvider(contentProvider); tableViewer.setLabelProvider(labelProvider); tableViewer.setInput(input); selectKeystores(); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.widthHint = 400; layoutData.heightHint = 200; tableViewer.getControl().setLayoutData(layoutData); tableViewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { String keyStore = null; Object element = event.getElement(); if (element instanceof String) { keyStore = (String) element; } if (keyStore != null) { if (event.getChecked()) { selectedKeyStores.add(keyStore); } else { selectedKeyStores.remove(keyStore); } } updateSelectAllState(); validate(); } }); Composite selectButtonArea = new Composite(keystoresGroup, SWT.NONE); selectButtonArea.setLayout(new GridLayout(1, true)); selectButtonArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); selectAllButton = new Button(selectButtonArea, SWT.CHECK); selectAllButton.setText(CertificateManagerNLS.BackupDialog_Select_All); selectAllButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); selectAllButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { tableViewer.setAllChecked(selectAllButton.getSelection()); selectedKeyStores.clear(); for (Object element : tableViewer.getCheckedElements()) { String keyStoreEl = (String) element; selectedKeyStores.add(keyStoreEl); } validate(); super.widgetSelected(e); } }); updateSelectAllState(); setMessage(CertificateManagerNLS.BackupDialog_Default_Message); return dialogArea; }
From source file:com.motorolamobility.studio.android.certmanager.ui.dialogs.importks.ImportEntriesDialog.java
License:Apache License
/** * Create contents of the dialog./*from ww w. j ava 2 s .c om*/ * @param parent */ @Override protected Control createDialogArea(Composite parent) { parent.getShell().setText(CertificateManagerNLS.ImportKeyStoreDialog_Dialog_Title); setMessage(CertificateManagerNLS.ImportKeyStoreDialog_Default_Message); setTitle(CertificateManagerNLS.ImportKeyStoreDialog_Dialog_Title); Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(1, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); Group SourceGroup = new Group(container, SWT.NONE); SourceGroup.setText(CertificateManagerNLS.ImportKeyStoreDialog_Source_Group); SourceGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); SourceGroup.setLayout(new GridLayout(1, false)); Composite keyStoreComposite = new Composite(SourceGroup, SWT.NONE); keyStoreComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); keyStoreComposite.setLayout(new GridLayout(3, false)); Label keyStoreLabel = new Label(keyStoreComposite, SWT.NONE); keyStoreLabel.setText(CertificateManagerNLS.ImportKeyStoreDialog_KeyStore_Label); keyStoreCombo = new Combo(keyStoreComposite, SWT.READ_ONLY); keyStoreCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Label passwdLabel = new Label(keyStoreComposite, SWT.NONE); passwdLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); passwdLabel.setText(CertificateManagerNLS.ImportKeyStoreDialog_Password_Label); passwdText = new Text(keyStoreComposite, SWT.BORDER | SWT.PASSWORD); passwdText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { sourcePassword = passwdText.getText(); } }); passwdText.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent e) { super.widgetDefaultSelected(e); loadEntries(); } }); passwdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Button loadButton = new Button(keyStoreComposite, SWT.NONE); GridData gd_loadButton = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_loadButton.widthHint = 80; loadButton.setLayoutData(gd_loadButton); loadButton.setText(CertificateManagerNLS.ImportKeyStoreDialog_Load_Button); Composite entriesComposite = new Composite(SourceGroup, SWT.NONE); GridData gd_entriesComposite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_entriesComposite.heightHint = 200; entriesComposite.setLayoutData(gd_entriesComposite); entriesComposite.setLayout(new GridLayout(1, true)); entriesTableViewer = CheckboxTableViewer.newCheckList(entriesComposite, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION); entriesTableViewer.setContentProvider(new EntriesContentProvider()); entriesTable = entriesTableViewer.getTable(); entriesTable.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (e.detail == SWT.CHECK) { validateUi(); TableItem item = (TableItem) e.item; if (item.getChecked()) { selectedAlias.add(item.getText(0)); } else { selectedAlias.remove(item.getText(0)); } } } }); entriesTable.setHeaderVisible(true); GridData gd_entriesTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_entriesTable.heightHint = 250; entriesTable.setLayoutData(gd_entriesTable); TableViewerColumn aliasViewerColumn = new TableViewerColumn(entriesTableViewer, SWT.NONE); TableColumn tblclmnAlias = aliasViewerColumn.getColumn(); tblclmnAlias.setWidth(100); tblclmnAlias.setText(CertificateManagerNLS.ImportKeyStoreDialog_Alias_Column); aliasViewerColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((EntryModel) element).getAlias(); } }); TableViewerColumn passwordViewerColumn_1 = new TableViewerColumn(entriesTableViewer, SWT.NONE); passwordViewerColumn_1.setEditingSupport(new PasswordEditingSupport(entriesTableViewer)); TableColumn tblclmnPassword = passwordViewerColumn_1.getColumn(); tblclmnPassword.setWidth(100); tblclmnPassword.setText(CertificateManagerNLS.ImportKeyStoreDialog_Passwd_Column); passwordViewerColumn_1.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((EntryModel) element).getPasswd().replaceAll(".", "*"); //$NON-NLS-1$ //$NON-NLS-2$ } }); TableViewerColumn verifiedViewerColumn_2 = new TableViewerColumn(entriesTableViewer, SWT.NONE); TableColumn tblclmnVerified = verifiedViewerColumn_2.getColumn(); tblclmnVerified.setWidth(130); tblclmnVerified.setText(CertificateManagerNLS.ImportKeyStoreDialog_Verified_Column); verifiedViewerColumn_2.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ((EntryModel) element).isVerified() ? CertificateManagerNLS.ImportKeyStoreDialog_Verified_Pass_Yes : CertificateManagerNLS.ImportKeyStoreDialog_Verified_Pass_Wrong; } }); loadButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { loadEntries(); } }); keyStoreCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); sourceKeyStore = (IKeyStore) keyStoreCombo.getData(keyStoreCombo.getText()); IKeyStore keyStore = (IKeyStore) keyStoreCombo.getData(keyStoreCombo.getText()); try { sourcePassword = keyStore.getPasswordProvider().getKeyStorePassword(false); } catch (KeyStoreManagerException e1) { StudioLogger.error("Error while accessing keystore manager. " + e1.getMessage()); } if (sourcePassword == null) { sourcePassword = ""; //$NON-NLS-1$ } passwdText.setText(sourcePassword); loadEntries(); updateTargetCombo(); validateUi(); } }); Group targetGroup = new Group(container, SWT.NONE); targetGroup.setLayout(new GridLayout(2, false)); targetGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); targetGroup.setText(CertificateManagerNLS.ImportKeyStoreDialog_Target_Group); Label targetKsLabel = new Label(targetGroup, SWT.NONE); targetKsLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); targetKsLabel.setText(CertificateManagerNLS.ImportKeyStoreDialog_KeyStore_Label); targetKsCombo = new Combo(targetGroup, SWT.READ_ONLY); targetKsCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); targetKsCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); String selectedItem = targetKsCombo.getText(); targetKeyStore = (IKeyStore) targetKsCombo.getData(selectedItem); validateUi(); } }); final KeyStoreManager keyStoreManager = KeyStoreManager.getInstance(); try { List<IKeyStore> keyStores = keyStoreManager.getKeyStores(); for (IKeyStore keyStore : keyStores) { File ksFile = keyStore.getFile(); String comboItem = ksFile.getName() + " - " + ksFile.getAbsolutePath(); //$NON-NLS-1$ keyStoreCombo.add(comboItem); keyStoreCombo.setData(comboItem, keyStore); if (keyStore.equals(this.sourceKeyStore)) { keyStoreCombo.select(keyStoreCombo.indexOf(comboItem)); } else { targetKsCombo.add(comboItem); targetKsCombo.setData(comboItem, keyStore); if (keyStore.equals(this.targetKeyStore)) { targetKsCombo.select(targetKsCombo.indexOf(comboItem)); } } } } catch (KeyStoreManagerException e1) { setErrorMessage(CertificateManagerNLS.ImportKeyStoreDialog_Error_Loading_Keystores); } return area; }
From source file:com.motorolamobility.studio.android.certmanager.ui.dialogs.RestoreBackupDialog.java
License:Apache License
@Override protected Control createDialogArea(Composite parent) { getShell().setText(title);//from w w w . ja v a 2 s . co m setTitle(CertificateManagerNLS.RestoreBackupDialog_TitleArea_Message); PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), RestoreBackupDialog.RESTORE_KEYSTORE_HELP_ID); Composite dialogArea = new Composite(parent, SWT.FILL); dialogArea.setLayout(new GridLayout()); dialogArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Group pathGroup = new Group(dialogArea, SWT.SHADOW_NONE); pathGroup.setText(CertificateManagerNLS.RestoreBackupDialog_Path_Group); pathGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); pathGroup.setLayout(new GridLayout(3, false)); Label pathLabel = new Label(pathGroup, SWT.NONE); pathLabel.setText(CertificateManagerNLS.RestoreBackupDialog_BackUp_File); pathLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); final Text pathText = new Text(pathGroup, SWT.BORDER); pathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); pathText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { archiveFile = new File(pathText.getText()); selectAllButton.setSelection(false); validate(); loadArchiveEntries(); } }); Button browseButton = new Button(pathGroup, SWT.PUSH); browseButton.setText(CertificateManagerNLS.RestoreBackupDialog_Browse_Button); browseButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FileDialog fileDialog = new FileDialog(getShell()); fileDialog.setFilterExtensions(new String[] { ZIP_EXT }); fileDialog.setOverwrite(false); String choosenPath = fileDialog.open(); pathText.setText(choosenPath); super.widgetSelected(e); } }); Label destinPath = new Label(pathGroup, SWT.NONE); destinPath.setText(CertificateManagerNLS.RestoreBackupDialog_Destination); destinPath.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); final Text destinText = new Text(pathGroup, SWT.BORDER); destinText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); destinText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { destinationPath = destinText.getText(); destinationFile = new File(destinationPath); validate(); } }); Button destinBrowseButton = new Button(pathGroup, SWT.PUSH); destinBrowseButton.setText(CertificateManagerNLS.RestoreBackupDialog_Browse_Button); destinBrowseButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false)); destinBrowseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog directoryDialog = new DirectoryDialog(getShell()); String choosenPath = directoryDialog.open(); destinText.setText(choosenPath); super.widgetSelected(e); } }); Group keystoresGroup = new Group(dialogArea, SWT.SHADOW_NONE); keystoresGroup.setText(CertificateManagerNLS.RestoreBackupDialog_KeyStores); keystoresGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); keystoresGroup.setLayout(new GridLayout(1, false)); tableViewer = CheckboxTableViewer.newCheckList(keystoresGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK | SWT.BORDER); tableViewer.setContentProvider(contentProvider); tableViewer.setLabelProvider(labelProvider); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); layoutData.widthHint = 400; layoutData.heightHint = 200; tableViewer.getControl().setLayoutData(layoutData); tableViewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { String keyStore = null; Object element = event.getElement(); if (element instanceof String) { keyStore = (String) element; } if (keyStore != null) { if (event.getChecked()) { selectedKeyStores.add(keyStore); } else { selectedKeyStores.remove(keyStore); } } if (tableViewer.getCheckedElements().length == tableViewer.getTable().getItems().length) { selectAllButton.setSelection(true); } else { selectAllButton.setSelection(false); } validate(); } }); Composite selectButtonArea = new Composite(keystoresGroup, SWT.NONE); selectButtonArea.setLayout(new GridLayout(1, true)); selectButtonArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); selectAllButton = new Button(selectButtonArea, SWT.CHECK); selectAllButton.setText(CertificateManagerNLS.RestoreBackupDialog_Select_All); selectAllButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); selectAllButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { tableViewer.setAllChecked(selectAllButton.getSelection()); selectedKeyStores.clear(); for (Object element : tableViewer.getCheckedElements()) { String keyStoreEl = (String) element; selectedKeyStores.add(keyStoreEl); } validate(); super.widgetSelected(e); } }); setMessage(CertificateManagerNLS.RestoreBackupDialog_Default_Message); return dialogArea; }
From source file:com.nokia.carbide.cdt.internal.api.builder.ui.MMPSelectionUI.java
License:Open Source License
/** * Create the composite//w w w .ja v a 2s . co m * @param parent * @param style */ public MMPSelectionUI(Composite parent, int style, IRunnableContext runnableContext) { super(parent, style); this.runnableContext = runnableContext; // layout self final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; gridLayout.marginBottom = 5; gridLayout.marginRight = 10; gridLayout.marginLeft = 10; setLayout(gridLayout); // viewer viewer = CheckboxTableViewer.newCheckList(this, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); Table table = viewer.getTable(); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); table.setData(AUTOTEST_UID, "table"); //$NON-NLS-1$ // build order column TableColumn buildOrderColumn = new TableColumn(table, SWT.NONE); // alignment ignored when checkboxes in column buildOrderColumn.setText(Messages.getString("MMPSelectionUI.BuildOrderColumnLabel")); //$NON-NLS-1$ buildOrderColumn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSortDirection(BUILD_ORDER_COLUMN); ViewerComparator comparator = getViewerComparator(BUILD_ORDER_COLUMN); viewer.setComparator(comparator); setColumnSorting((TableColumn) e.getSource(), sortDirection); } }); buildOrderColumn.setData(AUTOTEST_UID, "buildOrderColumn"); //$NON-NLS-1$ // file name column TableColumn fileNameColumn = new TableColumn(table, SWT.LEFT); fileNameColumn.setText(Messages.getString("MMPSelectionUI.FileNameColumnLabel")); //$NON-NLS-1$ fileNameColumn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSortDirection(FILENAME_COLUMN); ViewerComparator comparator = getViewerComparator(FILENAME_COLUMN); viewer.setComparator(comparator); setColumnSorting((TableColumn) e.getSource(), sortDirection); } }); fileNameColumn.setData(AUTOTEST_UID, "fileNameColumn"); //$NON-NLS-1$ // location column final TableColumn locationColumn = new TableColumn(table, SWT.LEFT); locationColumn.setText(Messages.getString("MMPSelectionUI.LocationColumnLabel")); //$NON-NLS-1$ locationColumn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSortDirection(LOCATION_COLUMN); ViewerComparator comparator = getViewerComparator(LOCATION_COLUMN); viewer.setComparator(comparator); setColumnSorting((TableColumn) e.getSource(), sortDirection); } }); locationColumn.setData(AUTOTEST_UID, "locationColumn"); //$NON-NLS-1$ setColumnSorting(buildOrderColumn, sortDirection); table.setHeaderVisible(true); // listen to checks viewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { FileInfo info = (FileInfo) event.getElement(); info.setChecked(event.getChecked()); fireSelectionChanged(); } }); // listen to double clicks viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); for (Iterator iterator = selection.iterator(); iterator.hasNext();) { FileInfo info = (FileInfo) iterator.next(); info.setChecked(!info.isChecked()); viewer.setChecked(info, info.isChecked()); fireSelectionChanged(); } } }); // select all/deselect all buttons final Composite composite = new Composite(this, SWT.NONE); composite.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false)); composite.setLayout(new GridLayout()); selectAllButton = new Button(composite, SWT.NONE); selectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); selectAllButton.setText(Messages.getString("MMPSelectionUI.SelectAllLabel")); //$NON-NLS-1$ selectAllButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setAllChecked(true); } }); selectAllButton.setData(AUTOTEST_UID, "selectAllButton"); //$NON-NLS-1$ deselectAllButton = new Button(composite, SWT.NONE); deselectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); deselectAllButton.setText(Messages.getString("MMPSelectionUI.DeselectAllLabel")); //$NON-NLS-1$ deselectAllButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setAllChecked(false); } }); deselectAllButton.setData(AUTOTEST_UID, "deselectAllButton"); //$NON-NLS-1$ // exclude extension makefiles check box excludeExtensionMakefilesCheckbox = new Button(this, SWT.CHECK); excludeExtensionMakefilesCheckbox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); excludeExtensionMakefilesCheckbox.setText(Messages.getString("MMPSelectionUI.ExcludeExtMakefilesLabel")); //$NON-NLS-1$ excludeExtensionMakefilesCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean exclude = ((Button) e.getSource()).getSelection(); if (extMakFileFilter == null) { extMakFileFilter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { FileInfo info = (FileInfo) element; boolean select = info.isMMP(); if (!select) info.setChecked(false); return select; } }; } if (exclude) { viewer.addFilter(extMakFileFilter); fireSelectionChanged(); } else { viewer.removeFilter(extMakFileFilter); } updateCheckedStateFromViewer(); } }); excludeExtensionMakefilesCheckbox.setData(AUTOTEST_UID, "excludeExtensionMakefilesCheckbox"); //$NON-NLS-1$ // exclude test components checkbox excludeTestComponentsCheckbox = new Button(this, SWT.CHECK); excludeTestComponentsCheckbox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); excludeTestComponentsCheckbox.setText(Messages.getString("MMPSelectionUI.ExcludeTestCompsLabel")); //$NON-NLS-1$ excludeTestComponentsCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean exclude = ((Button) e.getSource()).getSelection(); if (testFileFilter == null) { testFileFilter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { FileInfo info = (FileInfo) element; boolean select = !info.isTest(); if (!select) info.setChecked(false); return select; } }; } if (exclude) { viewer.addFilter(testFileFilter); fireSelectionChanged(); } else { viewer.removeFilter(testFileFilter); } updateCheckedStateFromViewer(); } }); excludeTestComponentsCheckbox.setData(AUTOTEST_UID, "excludeTestComponentsCheckbox"); //$NON-NLS-1$ }