use of org.eclipse.ui.fieldassist.ContentAssistCommandAdapter in project eclipse.platform.text by eclipse.
the class ReplaceConfigurationPage method createControl.
@Override
public void createControl(Composite parent) {
Composite result = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
result.setLayout(layout);
Label description = new Label(result, SWT.NONE);
int numberOfMatches = fReplaceRefactoring.getNumberOfMatches();
int numberOfFiles = fReplaceRefactoring.getNumberOfFiles();
String[] arguments = { String.valueOf(numberOfMatches), String.valueOf(numberOfFiles) };
if (numberOfMatches > 1 && numberOfFiles > 1) {
description.setText(Messages.format(SearchMessages.ReplaceConfigurationPage_description_many_in_many, arguments));
} else if (numberOfMatches == 1) {
description.setText(SearchMessages.ReplaceConfigurationPage_description_one_in_one);
} else {
description.setText(Messages.format(SearchMessages.ReplaceConfigurationPage_description_many_in_one, arguments));
}
description.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 2, 1));
FileSearchQuery query = fReplaceRefactoring.getQuery();
Label label1 = new Label(result, SWT.NONE);
label1.setText(SearchMessages.ReplaceConfigurationPage_replace_label);
Text clabel = new Text(result, SWT.BORDER | SWT.READ_ONLY);
clabel.setText(query.getSearchString());
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = convertWidthInCharsToPixels(50);
clabel.setLayoutData(gd);
Label label2 = new Label(result, SWT.NONE);
label2.setText(SearchMessages.ReplaceConfigurationPage_with_label);
fTextField = new Combo(result, SWT.DROP_DOWN);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = convertWidthInCharsToPixels(50);
fTextField.setLayoutData(gd);
fTextField.setFocus();
fTextField.addModifyListener(e -> updateOKStatus());
IDialogSettings settings = SearchPlugin.getDefault().getDialogSettings().getSection(SETTINGS_GROUP);
if (settings != null) {
String[] previousReplaceWith = settings.getArray(SETTINGS_REPLACE_WITH);
if (previousReplaceWith != null) {
fTextField.setItems(previousReplaceWith);
fTextField.select(0);
}
}
ComboContentAdapter contentAdapter = new ComboContentAdapter();
FindReplaceDocumentAdapterContentProposalProvider replaceProposer = new FindReplaceDocumentAdapterContentProposalProvider(false);
fTextFieldContentAssist = new ContentAssistCommandAdapter(fTextField, contentAdapter, replaceProposer, ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true);
new Label(result, SWT.NONE);
fReplaceWithRegex = new Button(result, SWT.CHECK);
fReplaceWithRegex.setText(SearchMessages.ReplaceConfigurationPage_isRegex_label);
fReplaceWithRegex.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setContentAssistsEnablement(fReplaceWithRegex.getSelection());
}
});
if (query.isRegexSearch()) {
fReplaceWithRegex.setSelection(true);
} else {
fReplaceWithRegex.setSelection(false);
fReplaceWithRegex.setEnabled(false);
}
fStatusLabel = new Label(result, SWT.NULL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.verticalAlignment = SWT.BOTTOM;
gd.horizontalSpan = 2;
fStatusLabel.setLayoutData(gd);
setContentAssistsEnablement(fReplaceWithRegex.getSelection());
setControl(result);
Dialog.applyDialogFont(result);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ISearchHelpContextIds.REPLACE_DIALOG);
}
use of org.eclipse.ui.fieldassist.ContentAssistCommandAdapter in project eclipse.platform.text by eclipse.
the class FindReplaceDialog method createInputPanel.
/**
* Creates the panel where the user specifies the text to search
* for and the optional replacement text.
*
* @param parent the parent composite
* @return the input panel
*/
private Composite createInputPanel(Composite parent) {
ModifyListener listener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateButtonState();
}
};
Composite panel = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
panel.setLayout(layout);
Label findLabel = new Label(panel, SWT.LEFT);
findLabel.setText(EditorMessages.FindReplace_Find_label);
setGridData(findLabel, SWT.LEFT, false, SWT.CENTER, false);
// Create the find content assist field
ComboContentAdapter contentAdapter = new ComboContentAdapter();
FindReplaceDocumentAdapterContentProposalProvider findProposer = new FindReplaceDocumentAdapterContentProposalProvider(true);
fFindField = new Combo(panel, SWT.DROP_DOWN | SWT.BORDER);
fContentAssistFindField = new ContentAssistCommandAdapter(fFindField, contentAdapter, findProposer, ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true);
setGridData(fFindField, SWT.FILL, true, SWT.CENTER, false);
addDecorationMargin(fFindField);
fFindField.addModifyListener(fFindModifyListener);
fReplaceLabel = new Label(panel, SWT.LEFT);
fReplaceLabel.setText(EditorMessages.FindReplace_Replace_label);
setGridData(fReplaceLabel, SWT.LEFT, false, SWT.CENTER, false);
// Create the replace content assist field
FindReplaceDocumentAdapterContentProposalProvider replaceProposer = new FindReplaceDocumentAdapterContentProposalProvider(false);
fReplaceField = new Combo(panel, SWT.DROP_DOWN | SWT.BORDER);
fContentAssistReplaceField = new ContentAssistCommandAdapter(fReplaceField, contentAdapter, replaceProposer, ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true);
setGridData(fReplaceField, SWT.FILL, true, SWT.CENTER, false);
addDecorationMargin(fReplaceField);
fReplaceField.addModifyListener(listener);
return panel;
}
use of org.eclipse.ui.fieldassist.ContentAssistCommandAdapter in project eclipse.platform.text by eclipse.
the class TextSearchPage method addTextPatternControls.
private void addTextPatternControls(Composite group) {
// grid layout with 2 columns
// Info text
Label label = new Label(group, SWT.LEAD);
label.setText(SearchMessages.SearchPage_containingText_text);
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
label.setFont(group.getFont());
// Pattern combo
fPattern = new Combo(group, SWT.SINGLE | SWT.BORDER);
// Not done here to prevent page from resizing
// fPattern.setItems(getPreviousSearchPatterns());
fPattern.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleWidgetSelected();
updateOKStatus();
}
});
// add some listeners for regex syntax checking
fPattern.addModifyListener(e -> updateOKStatus());
fPattern.setFont(group.getFont());
GridData data = new GridData(GridData.FILL, GridData.FILL, true, false, 1, 2);
data.widthHint = convertWidthInCharsToPixels(50);
fPattern.setLayoutData(data);
ComboContentAdapter contentAdapter = new ComboContentAdapter();
FindReplaceDocumentAdapterContentProposalProvider findProposer = new FindReplaceDocumentAdapterContentProposalProvider(true);
fPatterFieldContentAssist = new ContentAssistCommandAdapter(fPattern, contentAdapter, findProposer, ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new char[0], true);
fPatterFieldContentAssist.setEnabled(fIsRegExSearch);
fIsCaseSensitiveCheckbox = new Button(group, SWT.CHECK);
fIsCaseSensitiveCheckbox.setText(SearchMessages.SearchPage_caseSensitive);
fIsCaseSensitiveCheckbox.setSelection(fIsCaseSensitive);
fIsCaseSensitiveCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fIsCaseSensitive = fIsCaseSensitiveCheckbox.getSelection();
}
});
fIsCaseSensitiveCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
fIsCaseSensitiveCheckbox.setFont(group.getFont());
// RegEx checkbox
fIsRegExCheckbox = new Button(group, SWT.CHECK);
fIsRegExCheckbox.setText(SearchMessages.SearchPage_regularExpression);
fIsRegExCheckbox.setSelection(fIsRegExSearch);
fIsRegExCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fIsRegExSearch = fIsRegExCheckbox.getSelection();
updateOKStatus();
writeConfiguration();
fPatterFieldContentAssist.setEnabled(fIsRegExSearch);
fIsWholeWordCheckbox.setEnabled(!fIsRegExSearch);
}
});
fIsRegExCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 2));
fIsRegExCheckbox.setFont(group.getFont());
// Text line which explains the special characters
fStatusLabel = new CLabel(group, SWT.LEAD);
fStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 2));
fStatusLabel.setFont(group.getFont());
fStatusLabel.setAlignment(SWT.LEFT);
fStatusLabel.setText(SearchMessages.SearchPage_containingText_hint);
// Whole Word checkbox
fIsWholeWordCheckbox = new Button(group, SWT.CHECK);
fIsWholeWordCheckbox.setText(SearchMessages.SearchPage_wholeWord);
fIsWholeWordCheckbox.setSelection(fIsWholeWord);
fIsWholeWordCheckbox.setEnabled(!fIsRegExSearch);
fIsWholeWordCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fIsWholeWord = fIsWholeWordCheckbox.getSelection();
}
});
fIsWholeWordCheckbox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
fIsWholeWordCheckbox.setFont(group.getFont());
}
Aggregations