List of usage examples for org.eclipse.jface.viewers CheckboxTableViewer newCheckList
public static CheckboxTableViewer newCheckList(Composite parent, int style)
From source file:org.dawnsci.spectrum.ui.views.SpectrumDatasetView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { parent.setLayout(new GridLayout(1, true)); final CheckBoxGroup group = new CheckBoxGroup(parent, SWT.NONE); group.setLayout(new GridLayout(1, false)); group.setText("Use X-Axis"); group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final Composite content = group.getContent(); final CCombo combo = new CCombo(content, SWT.READ_ONLY | SWT.BORDER); combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group.setEnabled(false);/*from ww w . j a va 2 s . c o m*/ combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (currentFile == null) return; String name = combo.getText(); if (currentFile.contains(name)) { currentFile.setxDatasetName(name); for (ISpectrumFile file : otherFiles) { if (file.contains(name)) file.setxDatasetName(name); } } updateViewer(); } }); group.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (currentFile == null) return; if (!group.isActivated()) { currentFile.setUseAxis(false); for (ISpectrumFile file : otherFiles) { file.setUseAxis(false); } } else { currentFile.setUseAxis(true); for (ISpectrumFile file : otherFiles) { file.setUseAxis(true); } if (combo.getText().equals("")) { combo.select(0); String name = combo.getText(); if (currentFile.contains(name)) { currentFile.setxDatasetName(name); for (ISpectrumFile file : otherFiles) { if (file.contains(name)) file.setxDatasetName(name); } } } } updateViewer(); } }); viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); viewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); getSite().getPage().addSelectionListener("org.dawnsci.spectrum.ui.views.SpectrumView", new ISelectionListener() { @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (combo.isDisposed()) return; otherFiles = SpectrumUtils.getSpectrumFilesList((IStructuredSelection) selection); if (otherFiles.isEmpty()) { if (viewer == null || viewer.getTable().isDisposed()) return; viewer.setInput(new ArrayList<String>()); combo.removeAll(); currentFile = null; group.deactivate(); group.setEnabled(false); return; } else { currentFile = otherFiles.get(0); otherFiles.remove(0); List<String> names = currentFile.getPossibleAxisNames(); combo.setItems(names.toArray(new String[names.size()])); int i = 0; for (String name : currentFile.getPossibleAxisNames()) { if (name.equals(currentFile.getxDatasetName())) { combo.select(i); break; } i++; } updateViewer(); group.setEnabled(true); if (currentFile.isUsingAxis()) { group.activate(); } else { group.deactivate(); } } } }); viewer.setLabelProvider(new LabelProvider()); viewer.setContentProvider(new ViewContentProvider()); viewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { String name = event.getElement().toString(); if (event.getChecked()) { if (currentFile.contains(name)) { currentFile.addyDatasetName(name); for (ISpectrumFile file : otherFiles) { if (file.contains(name)) file.addyDatasetName(name); } } } else { if (currentFile.contains(name)) { currentFile.removeyDatasetName(name); for (ISpectrumFile file : otherFiles) { if (file.contains(name)) file.removeyDatasetName(name); } } } } }); }
From source file:org.dawnsci.spectrum.ui.views.SpectrumTracesView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { //Create table viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(new ViewContentProvider()); TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); viewerColumn.setLabelProvider(new ViewLabelProvider()); TableColumnLayout tableColumnLayout = new TableColumnLayout(); tableColumnLayout.setColumnData(viewerColumn.getColumn(), new ColumnWeightData(1)); parent.setLayout(tableColumnLayout); ColumnViewerToolTipSupport.enableFor(viewer); //Get plotting system from PlotView, use it to create file manager IWorkbenchPage page = getSite().getPage(); IViewPart view = page.findView("org.dawnsci.spectrum.ui.views.SpectrumPlot"); system = (IPlottingSystem<Composite>) view.getAdapter(IPlottingSystem.class); manager = new SpectrumFileManager(system); viewer.setInput(manager);/*from w ww .j a v a 2 s . c o m*/ manager.addFileListener(new ISpectrumFileListener() { @Override public void fileLoaded(final SpectrumFileEvent event) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { ISpectrumFile file = updateSelection(event); file.setShowPlot(true); } }); } @Override public void fileRemoved(SpectrumFileEvent event) { updateSelection(event); } }); processMenuManager = new ProcessMenuManager(viewer, manager, system); getSite().setSelectionProvider(viewer); //Set up drag-drop DropTargetAdapter dropListener = new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { Object dropData = event.data; List<String> paths = new ArrayList<String>(); if (dropData instanceof TreeSelection) { TreeSelection selectedNode = (TreeSelection) dropData; Object obj[] = selectedNode.toArray(); for (int i = 0; i < obj.length; i++) { if (obj[i] instanceof IFile) { IFile file = (IFile) obj[i]; paths.add(file.getRawLocation().toOSString()); } } } else if (dropData instanceof String[]) { for (String path : (String[]) dropData) { paths.add(path); } } manager.addFiles(paths); } }; DropTarget dt = new DropTarget(viewer.getControl(), DND.DROP_MOVE | DND.DROP_DEFAULT | DND.DROP_COPY); dt.setTransfer(new Transfer[] { TextTransfer.getInstance(), FileTransfer.getInstance(), ResourceTransfer.getInstance(), LocalSelectionTransfer.getTransfer() }); dt.addDropListener(dropListener); // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.dawnsci.spectrum.viewer"); makeActions(); hookContextMenu(); //hookDoubleClickAction(); contributeToActionBars(); //hook up delete key to remove from list viewer.getTable().addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { removeAction.run(); } } }); //Highlight trace on selection viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { List<ISpectrumFile> list = SpectrumUtils .getSpectrumFilesList((IStructuredSelection) event.getSelection()); for (ISpectrumFile file : manager.getFiles()) { if (list.contains(file)) { file.setSelected(true); } else { file.setSelected(false); } } } }); viewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { Object ob = event.getElement(); if (ob instanceof ISpectrumFile) { if (event.getChecked()) { ((ISpectrumFile) ob).setShowPlot(true); } else { ((ISpectrumFile) ob).setShowPlot(false); } } } }); //set axis as tight List<IAxis> axes = system.getAxes(); for (IAxis axis : axes) axis.setAxisAutoscaleTight(true); system.setColorOption(ColorOption.BY_NAME); logger.debug("Controls created"); }
From source file:org.dawnsci.spectrum.ui.views.TraceProcessPage.java
License:Open Source License
public Composite createPartControl(Composite parent) { //Create table viewer = CheckboxTableViewer.newCheckList(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(new ViewContentProvider()); TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); viewerColumn.setLabelProvider(new ViewLabelProvider()); TableColumnLayout tableColumnLayout = new TableColumnLayout(); tableColumnLayout.setColumnData(viewerColumn.getColumn(), new ColumnWeightData(1)); parent.setLayout(tableColumnLayout); ColumnViewerToolTipSupport.enableFor(viewer); //Get plotting system from PlotView, use it to create file manager IWorkbenchPage page = getView().getSite().getPage(); IViewPart view = page.findView("org.dawnsci.spectrum.ui.views.SpectrumPlot"); system = (IPlottingSystem) view.getAdapter(IPlottingSystem.class); manager = new SpectrumFileManager(system); viewer.setInput(manager);/* w w w. j a va2s . c om*/ manager.addFileListener(new ISpectrumFileListener() { @Override public void fileLoaded(final SpectrumFileOpenedEvent event) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { viewer.refresh(); viewer.setSelection(new StructuredSelection(event.getFile()), true); viewer.setChecked(event.getFile(), true); } }); } }); processMenuManager = new ProcessMenuManager(viewer, manager, system); getView().getSite().setSelectionProvider(viewer); //Set up drag-drop DropTargetAdapter dropListener = new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { Object dropData = event.data; if (dropData instanceof TreeSelection) { TreeSelection selectedNode = (TreeSelection) dropData; Object obj[] = selectedNode.toArray(); for (int i = 0; i < obj.length; i++) { if (obj[i] instanceof IFile) { IFile file = (IFile) obj[i]; manager.addFile(file.getRawLocation().toOSString()); } } } else if (dropData instanceof String[]) { for (String path : (String[]) dropData) { manager.addFile(path); } } } }; DropTarget dt = new DropTarget(viewer.getControl(), DND.DROP_MOVE | DND.DROP_DEFAULT | DND.DROP_COPY); dt.setTransfer(new Transfer[] { TextTransfer.getInstance(), FileTransfer.getInstance(), ResourceTransfer.getInstance(), LocalSelectionTransfer.getTransfer() }); dt.addDropListener(dropListener); // Create the help context id for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "org.dawnsci.spectrum.viewer"); makeActions(); hookContextMenu(); //hookDoubleClickAction(); contributeToActionBars(); //hook up delete key to remove from list viewer.getTable().addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { removeAction.run(); } } }); //Highlight trace on selection viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { List<ISpectrumFile> list = SpectrumUtils .getSpectrumFilesList((IStructuredSelection) event.getSelection()); for (ISpectrumFile file : manager.getFiles()) { if (list.contains(file)) { file.setSelected(true); } else { file.setSelected(false); } } } }); viewer.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { // TODO Auto-generated method stub Object ob = event.getElement(); if (ob instanceof ISpectrumFile) { if (event.getChecked()) { ((ISpectrumFile) ob).setShowPlot(true); } else { ((ISpectrumFile) ob).setShowPlot(false); } } } }); //set axis as tight List<IAxis> axes = system.getAxes(); for (IAxis axis : axes) axis.setAxisAutoscaleTight(true); system.setColorOption(ColorOption.BY_NAME); // Currently we do not want the run actions visible final IToolBarManager man = getView().getViewSite().getActionBars().getToolBarManager(); if (man.find(IAlgorithmProcessContext.RUN_ID_STUB) != null) man.find(IAlgorithmProcessContext.RUN_ID_STUB).setVisible(false); if (man.find(IAlgorithmProcessContext.STOP_ID_STUB) != null) man.find(IAlgorithmProcessContext.STOP_ID_STUB).setVisible(false); return viewer.getTable(); }
From source file:org.deidentifier.arx.gui.view.impl.wizard.ImportWizardPageColumns.java
License:Open Source License
/** * Creates the design of this page along with the appropriate listeners *//* w ww. j a v a 2s . c o m*/ public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); setControl(container); container.setLayout(new GridLayout(2, false)); /* TableViewer for the columns with a checkbox in each row */ checkboxTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.FULL_SELECTION); checkboxTableViewer.setContentProvider(new ArrayContentProvider()); checkboxTableViewer.setCheckStateProvider(new ICheckStateProvider() { /** @return {@link ImportWizardModelColumn#isEnabled()} */ @Override public boolean isChecked(Object column) { return ((ImportWizardModelColumn) column).isEnabled(); } /** No column should be grayed out */ @Override public boolean isGrayed(Object column) { return false; } }); checkboxTableViewer.addCheckStateListener(new ICheckStateListener() { /** * Sets the enabled status for the given item * * Using {@link ImportWizardModelColumn#setEnabled(boolean)} this * method will set the enabled flag for the given column. * Furthermore it makes sure the page is marked as complete once at * least one item is selected. */ @Override public void checkStateChanged(CheckStateChangedEvent event) { setPageComplete(false); ((ImportWizardModelColumn) event.getElement()).setEnabled(event.getChecked()); for (ImportWizardModelColumn column : wizardImport.getData().getWizardColumns()) { if (column.isEnabled()) { setPageComplete(true); return; } } } }); /* Actual table for {@link #checkboxTableViewer} */ table = checkboxTableViewer.getTable(); table.setHeaderVisible(true); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); table.addSelectionListener(new SelectionAdapter() { /** * Makes the buttons for column reordering (un)clickable * * This checks the current selection and will enable and/or disable * the {@link #btnUp} and {@link #btnDown} if either the first or * last item is currently selected. */ @Override public void widgetSelected(SelectionEvent e) { /* Check for first item */ if (table.getSelectionIndex() == 0) { btnUp.setEnabled(false); } else { btnUp.setEnabled(true); } /* Check for last item */ if (table.getSelectionIndex() == table.getItemCount() - 1) { btnDown.setEnabled(false); } else { btnDown.setEnabled(true); } } }); /* Empty column to make checkboxes appear in an own cell */ tableViewerColumnEnabled = new TableViewerColumn(checkboxTableViewer, SWT.NONE); tableViewerColumnEnabled.setLabelProvider(new ColumnLabelProvider() { /** Cells within this column should always be empty */ @Override public String getText(Object element) { return null; } }); /* Actual column for {@link tableViewerColumnEnabled} */ tblclmnEnabled = tableViewerColumnEnabled.getColumn(); tblclmnEnabled.setToolTipText("Deselect all"); tblclmnEnabled.setText("DA"); tblclmnEnabled.setWidth(40); tblclmnEnabled.addSelectionListener(new ColumnEnabledSelectionListener()); /* Column containing the names */ tableViewerColumnName = new TableViewerColumn(checkboxTableViewer, SWT.NONE); tableViewerColumnName.setEditingSupport(new NameEditingSupport(checkboxTableViewer)); tableViewerColumnName.setLabelProvider(new ColumnLabelProvider() { /** * Gets name of cells from {@link ImportColumn#getAliasName()} * * This also makes sure that all column names are unique using * {@link #uniqueColumnNames()}. In case there are duplicates it * sets an error message. */ @Override public String getText(Object element) { if (!uniqueColumnNames()) { setErrorMessage("Column names need to be unique"); setPageComplete(false); } else { setErrorMessage(null); setPageComplete(true); } ImportWizardModelColumn column = (ImportWizardModelColumn) element; return column.getColumn().getAliasName(); } }); /* Actual column for {@link tableViewerColumnName} */ tblclmnName = tableViewerColumnName.getColumn(); tblclmnName.setToolTipText("Name of the column"); tblclmnName.setWidth(300); tblclmnName.setText("Name"); /* Column containing the datatypes */ tableViewerColumnDatatype = new TableViewerColumn(checkboxTableViewer, SWT.NONE); tableViewerColumnDatatype.setEditingSupport(new DatatypeEditingSupport(checkboxTableViewer)); tableViewerColumnDatatype.setLabelProvider(new ColumnLabelProvider() { /** * Gets string representation for given datatype of column * * Internally it makes use of {@link ImportColumn#getDataType()}. */ @Override public String getText(Object element) { DataType<?> datatype = ((ImportWizardModelColumn) element).getColumn().getDataType(); for (DataTypeDescription<?> description : DataType.list()) { if (description.newInstance().getClass() == datatype.getClass()) { return description.getLabel(); } } return null; } }); /* Actual column for {@link tableViewerColumnDatatype} */ tblclmnDatatype = tableViewerColumnDatatype.getColumn(); tblclmnDatatype.setToolTipText("Datatype of the column"); tblclmnDatatype.setWidth(120); tblclmnDatatype.setText("Datatype"); /* Column containing the format of the format */ tableViewerColumnFormat = new TableViewerColumn(checkboxTableViewer, SWT.NONE); tableViewerColumnFormat.setLabelProvider(new ColumnLabelProvider() { /** * Returns format string of datatype for column * * This retrieves the used format string of the chosen datatype for * each column. * * @note In case of simple datatypes without a format specifier an * empty string is returned. * * @param element * Column in question */ @Override public String getText(Object element) { DataType<?> column = ((ImportWizardModelColumn) element).getColumn().getDataType(); if (column instanceof DataTypeWithFormat) { return ((DataTypeWithFormat) column).getFormat(); } return ""; } }); /* Actual column for {@link tableViewerColumnFormat} */ tblclmnFormat = tableViewerColumnFormat.getColumn(); tblclmnFormat.setWidth(120); tblclmnFormat.setToolTipText("Format of the associated datatype"); tblclmnFormat.setWidth(100); tblclmnFormat.setText("Format"); /* Buttons to move column up */ btnUp = new Button(container, SWT.NONE); btnUp.setText("Move up"); btnUp.setImage(wizardImport.getController().getResources().getImage("arrow_up.png")); btnUp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); btnUp.setEnabled(false); btnUp.addSelectionListener(new SelectionAdapter() { /** * Swaps the current element with the one above * * This makes also sure that the button is disabled once the top is * reached by notifying the appropriate selection listener. */ @Override public void widgetSelected(SelectionEvent e) { int current = table.getSelectionIndex(); if (current > 0) { List<ImportWizardModelColumn> columns = wizardImport.getData().getWizardColumns(); Collections.swap(columns, current, current - 1); checkboxTableViewer.setInput(columns); table.notifyListeners(SWT.Selection, null); } } }); /* Buttons to move column down */ btnDown = new Button(container, SWT.NONE); btnDown.setText("Move down"); btnDown.setImage(wizardImport.getController().getResources().getImage("arrow_down.png")); btnDown.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); btnDown.setEnabled(false); btnDown.addSelectionListener(new SelectionAdapter() { /** * Swaps the current element with the one below * * This makes also sure that the button is disabled once the bottom * is reached by notifying the appropriate selection listener. */ @Override public void widgetSelected(SelectionEvent e) { int current = table.getSelectionIndex(); if (current < table.getItemCount() - 1) { List<ImportWizardModelColumn> columns = wizardImport.getData().getWizardColumns(); Collections.swap(columns, current, current + 1); checkboxTableViewer.setInput(columns); table.notifyListeners(SWT.Selection, null); } } }); /* Wait for at least one column to be enabled */ setPageComplete(false); }
From source file:org.deidentifier.arx.gui.view.SWTUtil.java
License:Apache License
/** * Returns a checkbox table viewer. Implements hacks for fixing OSX bugs. * @param parent/*from w w w . j a va 2s . com*/ * @param style * @return */ public static CheckboxTableViewer createTableViewerCheckbox(Composite container, int style) { CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(container, style); fixOSXTableBug(viewer.getTable()); return viewer; }
From source file:org.ebayopensource.vjet.eclipse.internal.debug.ui.pref.VjetStepFilterPreferencePage.java
License:Open Source License
/** * Create a group to contain the step filter related widgetry *///from w w w . ja va 2 s . c o m private void createStepFilterPreferences(Composite parent) { Composite container = SWTFactory.createComposite(parent, parent.getFont(), 2, 1, GridData.FILL_BOTH, 0, 0); m_useStepFiltersButton = SWTFactory.createCheckButton(container, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage__Use_step_filters, null, DebugUITools.isUseStepFilters(), 2); m_useStepFiltersButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { setPageEnablement(m_useStepFiltersButton.getSelection()); } public void widgetDefaultSelected(SelectionEvent e) { } }); SWTFactory.createLabel(container, ScriptDebugPreferencesMessages.ScriptStepFilterPreferencePage_Defined_step_fi_lters__8, 2); m_tableViewer = CheckboxTableViewer.newCheckList(container, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); m_tableViewer.getTable().setFont(container.getFont()); m_tableViewer.setLabelProvider(new FilterLabelProvider() { @Override public Image getColumnImage(Object object, int column) { return null; } }); m_tableViewer.setComparator(new FilterViewerComparator()); m_tableViewer.setContentProvider(new StepFilterContentProvider()); m_tableViewer.setInput(getAllStoredFilters(false)); m_tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); m_tableViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { ((Filter) event.getElement()).setChecked(event.getChecked()); } }); m_tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); if (selection.isEmpty()) { m_removeFilterButton.setEnabled(false); } else { m_removeFilterButton.setEnabled(true); } } }); m_tableViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { handleFilterViewerKeyPress(event); } }); createStepFilterButtons(container); createStepFilterCheckboxes(container); setPageEnablement(m_useStepFiltersButton.getSelection()); }
From source file:org.eclipse.acceleo.internal.ide.ui.editors.template.actions.refactor.pullup.AcceleoPullUpFirstInputWizardPage.java
License:Open Source License
/** * {@inheritDoc}//from ww w. j av a 2s. c o m * * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new FillLayout()); this.setControl(composite); this.viewer = CheckboxTableViewer.newCheckList(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); this.viewer.setLabelProvider(new AcceleoPullUpTableLabelProvider()); this.viewer.setContentProvider(new AcceleoPullUpTableContentProvider()); this.viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { Refactoring refactoring = getRefactoring(); if (refactoring instanceof AcceleoPullUpRefactoring) { AcceleoPullUpRefactoring acceleoPullUpRefactoring = (AcceleoPullUpRefactoring) refactoring; acceleoPullUpRefactoring.setTemplates(getSelectedTemplate()); setPageComplete(getSelectedTemplate().size() > 0); } } }); this.viewer.setInput(this.module); }
From source file:org.eclipse.andmore.android.certmanager.ui.dialogs.BackupDialog.java
License:Apache License
@Override protected Control createDialogArea(Composite parent) { getShell().setText(title);//ww w . j a va 2 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:org.eclipse.andmore.android.certmanager.ui.dialogs.importks.ImportEntriesDialog.java
License:Apache License
/** * Create contents of the dialog./*w w w. j a v a2s . com*/ * * @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) { AndmoreLogger.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:org.eclipse.andmore.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 .ja v a 2 s .c om*/ 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); }