@NotNull public static Text createOutputFolderChooser( final Composite parent, @Nullable String label, @Nullable ModifyListener changeListener) { UIUtils.createControlLabel( parent, label != null ? label : CoreMessages.data_transfer_wizard_output_label_directory); Composite chooserPlaceholder = UIUtils.createPlaceholder(parent, 2); chooserPlaceholder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); final Text directoryText = new Text(chooserPlaceholder, SWT.BORDER); directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); if (changeListener != null) { directoryText.addModifyListener(changeListener); } final Runnable folderChooser = new Runnable() { @Override public void run() { DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.NONE); dialog.setMessage(CoreMessages.data_transfer_wizard_output_dialog_directory_message); dialog.setText(CoreMessages.data_transfer_wizard_output_dialog_directory_text); String directory = directoryText.getText(); if (!CommonUtils.isEmpty(directory)) { dialog.setFilterPath(directory); } directory = dialog.open(); if (directory != null) { directoryText.setText(directory); } } }; directoryText.addMouseListener( new MouseAdapter() { @Override public void mouseUp(MouseEvent e) { folderChooser.run(); } }); Button openFolder = new Button(chooserPlaceholder, SWT.PUSH | SWT.FLAT); openFolder.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER)); openFolder.setLayoutData( new GridData(GridData.VERTICAL_ALIGN_CENTER | GridData.HORIZONTAL_ALIGN_CENTER)); openFolder.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { folderChooser.run(); } }); return directoryText; }
/* (non-Javadoc) * @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 GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); setControl(composite); Label label = new Label(composite, SWT.WRAP); label.setText(PDEUIMessages.PluginWorkingSet_setName); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fWorkingSetName = new Text(composite, SWT.SINGLE | SWT.BORDER); fWorkingSetName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fWorkingSetName.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { validatePage(); } }); fWorkingSetName.setFocus(); label = new Label(composite, SWT.WRAP); label.setText(PDEUIMessages.PluginWorkingSet_setContent); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fTree = new CheckboxFilteredTree(composite, SWT.BORDER, new PatternFilter()); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 250; fTree.getViewer().getControl().setLayoutData(gd); final IStructuredContentProvider fTableContentProvider = new ContentProvider(); fTree.getCheckboxTreeViewer().setContentProvider(fTableContentProvider); fTree.getCheckboxTreeViewer().setLabelProvider(new WorkingSetLabelProvider()); fTree.getCheckboxTreeViewer().setUseHashlookup(true); fTree.getCheckboxTreeViewer().setInput(PDECore.getDefault()); fTree .getCheckboxTreeViewer() .addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { validatePage(); } }); // Add select / deselect all buttons for bug 46669 Composite buttonComposite = new Composite(composite, SWT.NONE); buttonComposite.setLayout(new GridLayout(2, true)); buttonComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); Button selectAllButton = new Button(buttonComposite, SWT.PUSH); selectAllButton.setText(PDEUIMessages.PluginWorkingSet_selectAll_label); selectAllButton.setToolTipText(PDEUIMessages.PluginWorkingSet_selectAll_toolTip); selectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent selectionEvent) { fTree .getCheckboxTreeViewer() .setCheckedElements( fTableContentProvider.getElements(fTree.getCheckboxTreeViewer().getInput())); validatePage(); } }); selectAllButton.setLayoutData(new GridData()); SWTUtil.setButtonDimensionHint(selectAllButton); Button deselectAllButton = new Button(buttonComposite, SWT.PUSH); deselectAllButton.setText(PDEUIMessages.PluginWorkingSet_deselectAll_label); deselectAllButton.setToolTipText(PDEUIMessages.PluginWorkingSet_deselectAll_toolTip); deselectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent selectionEvent) { fTree.getCheckboxTreeViewer().setCheckedElements(new Object[0]); validatePage(); } }); deselectAllButton.setLayoutData(new GridData()); SWTUtil.setButtonDimensionHint(deselectAllButton); setPageComplete(false); setMessage(PDEUIMessages.PluginWorkingSet_message); initialize(); Dialog.applyDialogFont(composite); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(composite, IHelpContextIds.PLUGIN_WORKING_SET); }