use of org.eclipse.jface.fieldassist.SimpleContentProposalProvider in project dbeaver by serge-rider.
the class StreamConsumerPageOutput method createControl.
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite composite = new Composite(parent, SWT.NULL);
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
composite.setLayout(gl);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
{
Group generalSettings = UIUtils.createControlGroup(composite, CoreMessages.data_transfer_wizard_output_group_general, 5, GridData.FILL_HORIZONTAL, 0);
clipboardCheck = UIUtils.createLabelCheckbox(generalSettings, "Copy to clipboard", false);
clipboardCheck.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 4, 1));
clipboardCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setOutputClipboard(clipboardCheck.getSelection());
toggleClipboardOutput();
updatePageCompletion();
}
});
directoryText = DialogUtils.createOutputFolderChooser(generalSettings, null, new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
settings.setOutputFolder(directoryText.getText());
updatePageCompletion();
}
});
((GridData) directoryText.getParent().getLayoutData()).horizontalSpan = 4;
UIUtils.createControlLabel(generalSettings, CoreMessages.data_transfer_wizard_output_label_file_name_pattern);
fileNameText = new Text(generalSettings, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
UIUtils.setContentProposalToolTip(fileNameText, "Output file name pattern", StreamTransferConsumer.VARIABLE_TABLE, StreamTransferConsumer.VARIABLE_TIMESTAMP, StreamTransferConsumer.VARIABLE_PROJECT);
fileNameText.setLayoutData(gd);
fileNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
settings.setOutputFilePattern(fileNameText.getText());
updatePageCompletion();
}
});
UIUtils.installContentProposal(fileNameText, new TextContentAdapter(), new SimpleContentProposalProvider(new String[] { GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TABLE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_PROJECT) }));
{
UIUtils.createControlLabel(generalSettings, CoreMessages.data_transfer_wizard_output_label_encoding);
encodingCombo = UIUtils.createEncodingCombo(generalSettings, settings.getOutputEncoding());
//encodingCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, true, false, 1, 1));
encodingCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
int index = encodingCombo.getSelectionIndex();
if (index >= 0) {
settings.setOutputEncoding(encodingCombo.getItem(index));
}
updatePageCompletion();
}
});
encodingBOMLabel = UIUtils.createControlLabel(generalSettings, CoreMessages.data_transfer_wizard_output_label_insert_bom);
encodingBOMLabel.setToolTipText(CoreMessages.data_transfer_wizard_output_label_insert_bom_tooltip);
encodingBOMCheckbox = new Button(generalSettings, SWT.CHECK);
encodingBOMCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END, GridData.VERTICAL_ALIGN_BEGINNING, true, false, 1, 1));
encodingBOMCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setOutputEncodingBOM(encodingBOMCheckbox.getSelection());
}
});
new Label(generalSettings, SWT.NONE);
}
compressCheckbox = UIUtils.createLabelCheckbox(generalSettings, CoreMessages.data_transfer_wizard_output_checkbox_compress, false);
compressCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, true, false, 4, 1));
compressCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setCompressResults(compressCheckbox.getSelection());
}
});
}
{
Group resultsSettings = UIUtils.createControlGroup(composite, "Results", 2, GridData.FILL_HORIZONTAL, 0);
showFolderCheckbox = UIUtils.createCheckbox(resultsSettings, CoreMessages.data_transfer_wizard_output_checkbox_open_folder, true);
showFolderCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setOpenFolderOnFinish(showFolderCheckbox.getSelection());
}
});
showFolderCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 2, 1));
execProcessCheckbox = UIUtils.createCheckbox(resultsSettings, "Execute process on finish", true);
execProcessCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setExecuteProcessOnFinish(execProcessCheckbox.getSelection());
toggleExecProcessControls();
}
});
execProcessText = new Text(resultsSettings, SWT.BORDER);
execProcessText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
execProcessText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
settings.setFinishProcessCommand(execProcessText.getText());
updatePageCompletion();
}
});
UIUtils.setContentProposalToolTip(execProcessText, "Process command line", StreamTransferConsumer.VARIABLE_FILE, StreamTransferConsumer.VARIABLE_TABLE, StreamTransferConsumer.VARIABLE_TIMESTAMP, StreamTransferConsumer.VARIABLE_PROJECT);
UIUtils.installContentProposal(execProcessText, new TextContentAdapter(), new SimpleContentProposalProvider(new String[] { GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TABLE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_PROJECT), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_FILE) }));
}
setControl(composite);
}
use of org.eclipse.jface.fieldassist.SimpleContentProposalProvider in project dbeaver by dbeaver.
the class StreamPOIConsumerPageOutput method createControl.
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite composite = new Composite(parent, SWT.NULL);
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
composite.setLayout(gl);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final StreamPOIConsumerSettings settings = getWizard().getPageSettings(this, StreamPOIConsumerSettings.class);
{
Group generalSettings = UIUtils.createControlGroup(composite, CoreMessages.data_transfer_wizard_output_group_general, 5, GridData.FILL_HORIZONTAL, 0);
directoryText = DialogUtils.createOutputFolderChooser(generalSettings, null, new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
settings.setOutputFolder(directoryText.getText());
updatePageCompletion();
}
});
((GridData) directoryText.getParent().getLayoutData()).horizontalSpan = 4;
UIUtils.createControlLabel(generalSettings, CoreMessages.data_transfer_wizard_output_label_file_name_pattern);
fileNameText = new Text(generalSettings, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
UIUtils.setContentProposalToolTip(fileNameText, "Output file name pattern", StreamPOITransferConsumer.VARIABLE_TABLE, StreamPOITransferConsumer.VARIABLE_TIMESTAMP, StreamPOITransferConsumer.VARIABLE_PROJECT);
fileNameText.setLayoutData(gd);
fileNameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
settings.setOutputFilePattern(fileNameText.getText());
updatePageCompletion();
}
});
UIUtils.installContentProposal(fileNameText, new TextContentAdapter(), new SimpleContentProposalProvider(new String[] { GeneralUtils.variablePattern(StreamPOITransferConsumer.VARIABLE_TABLE), GeneralUtils.variablePattern(StreamPOITransferConsumer.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(StreamPOITransferConsumer.VARIABLE_PROJECT) }));
{
new Label(generalSettings, SWT.NONE);
}
}
{
Group resultsSettings = UIUtils.createControlGroup(composite, "Results", 2, GridData.FILL_HORIZONTAL, 0);
showFolderCheckbox = UIUtils.createCheckbox(resultsSettings, CoreMessages.data_transfer_wizard_output_checkbox_open_folder, true);
showFolderCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setOpenFolderOnFinish(showFolderCheckbox.getSelection());
}
});
showFolderCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_BEGINNING, false, false, 2, 1));
execProcessCheckbox = UIUtils.createCheckbox(resultsSettings, "Execute process on finish", true);
execProcessCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setExecuteProcessOnFinish(execProcessCheckbox.getSelection());
toggleExecProcessControls();
updatePageCompletion();
}
});
execProcessText = new Text(resultsSettings, SWT.BORDER);
execProcessText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
execProcessText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
settings.setFinishProcessCommand(execProcessText.getText());
updatePageCompletion();
}
});
UIUtils.setContentProposalToolTip(execProcessText, "Process command line", StreamPOITransferConsumer.VARIABLE_FILE, StreamPOITransferConsumer.VARIABLE_TABLE, StreamPOITransferConsumer.VARIABLE_TIMESTAMP, StreamPOITransferConsumer.VARIABLE_PROJECT);
UIUtils.installContentProposal(execProcessText, new TextContentAdapter(), new SimpleContentProposalProvider(new String[] { GeneralUtils.variablePattern(StreamPOITransferConsumer.VARIABLE_TABLE), GeneralUtils.variablePattern(StreamPOITransferConsumer.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(StreamPOITransferConsumer.VARIABLE_PROJECT), GeneralUtils.variablePattern(StreamPOITransferConsumer.VARIABLE_FILE) }));
}
setControl(composite);
}
use of org.eclipse.jface.fieldassist.SimpleContentProposalProvider in project dbeaver by dbeaver.
the class PrefPageSQLFormat method createPreferenceContent.
@Override
protected Control createPreferenceContent(Composite parent) {
Composite composite = UIUtils.createPlaceholder(parent, 2, 5);
// Autoclose
{
Composite acGroup = UIUtils.createControlGroup(composite, CoreMessages.pref_page_sql_format_group_auto_close, 1, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
acSingleQuotesCheck = UIUtils.createCheckbox(acGroup, CoreMessages.pref_page_sql_format_label_single_quotes, false);
acDoubleQuotesCheck = UIUtils.createCheckbox(acGroup, CoreMessages.pref_page_sql_format_label_double_quotes, false);
acBracketsCheck = UIUtils.createCheckbox(acGroup, CoreMessages.pref_page_sql_format_label_brackets, false);
}
{
// Formatting
Composite afGroup = UIUtils.createControlGroup(composite, CoreMessages.pref_page_sql_format_group_auto_format, 1, GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING, 0);
afKeywordCase = UIUtils.createCheckbox(afGroup, CoreMessages.pref_page_sql_format_label_convert_keyword_case, CoreMessages.pref_page_sql_format_label_convert_keyword_case_tip, false, 1);
afExtractFromSource = UIUtils.createCheckbox(afGroup, CoreMessages.pref_page_sql_format_label_extract_sql_from_source_code, CoreMessages.pref_page_sql_format_label_extract_sql_from_source_code_tip, false, 1);
}
Composite formatterGroup = UIUtils.createControlGroup(composite, CoreMessages.pref_page_sql_format_group_formatter, 1, GridData.FILL_BOTH, 0);
((GridData) formatterGroup.getLayoutData()).horizontalSpan = 2;
{
Composite formatterPanel = UIUtils.createPlaceholder(formatterGroup, 2);
formatterPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
formatterSelector = UIUtils.createLabelCombo(formatterPanel, CoreMessages.pref_page_sql_format_label_formatter, SWT.DROP_DOWN | SWT.READ_ONLY);
formatters = SQLFormatterConfigurationRegistry.getInstance().getFormatters();
for (SQLFormatterDescriptor formatterDesc : formatters) {
formatterSelector.add(DBPIdentifierCase.capitalizeCaseName(formatterDesc.getLabel()));
}
formatterSelector.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showFormatterSettings();
performApply();
}
});
formatterSelector.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
}
// Default formatter settings
{
defaultGroup = UIUtils.createPlaceholder(formatterGroup, 2, 0);
defaultGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
keywordCaseCombo = UIUtils.createLabelCombo(defaultGroup, CoreMessages.pref_page_sql_format_label_keyword_case, SWT.DROP_DOWN | SWT.READ_ONLY);
keywordCaseCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
keywordCaseCombo.add("Database");
for (DBPIdentifierCase c : DBPIdentifierCase.values()) {
keywordCaseCombo.add(DBPIdentifierCase.capitalizeCaseName(c.name()));
}
keywordCaseCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
performApply();
}
});
}
// External formatter
{
externalGroup = UIUtils.createPlaceholder(formatterGroup, 2, 5);
externalGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
externalCmdText = UIUtils.createLabelText(externalGroup, CoreMessages.pref_page_sql_format_label_external_command_line, "");
externalCmdText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.installContentProposal(externalCmdText, new TextContentAdapter(), new SimpleContentProposalProvider(new String[] { GeneralUtils.variablePattern(SQLFormatterExternal.VAR_FILE) }));
UIUtils.setContentProposalToolTip(externalCmdText, CoreMessages.pref_page_sql_format_label_external_set_content_tool_tip, SQLFormatterExternal.VAR_FILE);
externalUseFile = UIUtils.createLabelCheckbox(externalGroup, CoreMessages.pref_page_sql_format_label_external_use_temp_file, CoreMessages.pref_page_sql_format_label_external_use_temp_file_tip + GeneralUtils.variablePattern(SQLFormatterExternal.VAR_FILE), false);
externalTimeout = UIUtils.createLabelSpinner(externalGroup, CoreMessages.pref_page_sql_format_label_external_exec_timeout, CoreMessages.pref_page_sql_format_label_external_exec_timeout_tip, 100, 100, 10000);
}
{
// SQL preview
Composite previewGroup = new Composite(formatterGroup, SWT.BORDER);
previewGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
previewGroup.setLayout(new FillLayout());
sqlViewer = new SQLEditorBase() {
@Override
public DBCExecutionContext getExecutionContext() {
final DBPDataSourceContainer container = getDataSourceContainer();
if (container != null) {
final DBPDataSource dataSource = container.getDataSource();
if (dataSource != null) {
return dataSource.getDefaultContext(false);
}
}
return null;
}
};
try {
try (final InputStream sqlStream = getClass().getResourceAsStream(FORMAT_FILE_NAME)) {
final String sqlText = ContentUtils.readToString(sqlStream, GeneralUtils.DEFAULT_ENCODING);
IEditorSite subSite = new SubEditorSite(DBeaverUI.getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
StringEditorInput sqlInput = new StringEditorInput("SQL preview", sqlText, true, GeneralUtils.getDefaultFileEncoding());
sqlViewer.init(subSite, sqlInput);
}
} catch (Exception e) {
log.error(e);
}
sqlViewer.createPartControl(previewGroup);
Object text = sqlViewer.getAdapter(Control.class);
if (text instanceof StyledText) {
((StyledText) text).setWordWrap(true);
}
sqlViewer.reloadSyntaxRules();
previewGroup.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
sqlViewer.dispose();
}
});
}
return composite;
}
use of org.eclipse.jface.fieldassist.SimpleContentProposalProvider in project n4js by eclipse.
the class SourceFolderContentProposalProviderFactory method createProviderForProject.
/**
* Returns a source folder proposal provider for the given project.
*
* @param contextProject
* The project to look for source folders
* @return The provider
*/
public IContentProposalProvider createProviderForProject(IProject contextProject) {
if (null == contextProject) {
return null;
}
IN4JSProject n4Project = StreamSupport.stream(n4jsCore.findAllProjects().spliterator(), false).filter(// Filter for the context
project -> project.getProjectId().equals(contextProject.getName())).findAny().orElse(null);
if (n4Project == null) {
return null;
}
SimpleContentProposalProvider provider = new SimpleContentProposalProvider(n4Project.getSourceContainers().stream().map(src -> src.getRelativeLocation()).toArray(String[]::new));
provider.setFiltering(true);
return provider;
}
use of org.eclipse.jface.fieldassist.SimpleContentProposalProvider in project egit by eclipse.
the class PushToGerritPage method addTopicProposal.
private void addTopicProposal(Text textField) {
if (topicProposals.isEmpty()) {
return;
}
KeyStroke stroke = UIUtils.getKeystrokeOfBestActiveBindingFor(IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST);
if (stroke != null) {
UIUtils.addBulbDecorator(textField, NLS.bind(UIText.PushToGerritPage_TopicContentProposalHoverText, stroke.format()));
}
String[] recentTopics = topicProposals.keySet().toArray(new String[topicProposals.size()]);
Arrays.sort(recentTopics, CommonUtils.STRING_ASCENDING_COMPARATOR);
SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(recentTopics);
proposalProvider.setFiltering(true);
ContentProposalAdapter adapter = new ContentProposalAdapter(textField, new TextContentAdapter(), proposalProvider, stroke, null);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
}
Aggregations