提交 0f8c3782 编写于 作者: N Nikita Akilov

#10370 add search in comments option to ctrl + shift + d dialog

上级 ba300a3c
......@@ -229,6 +229,7 @@ public class UINavigatorMessages extends NLS {
public static String question_no_sql_available;
public static String error_sql_generation_title;
public static String error_sql_generation_message;
public static String dialog_search_objects_search_in_comments;
static {
// initialize resource bundle
......
......@@ -205,3 +205,4 @@ error_deleting_resource_message = Error deleting''{0}''
question_no_sql_available = No SQL script available. \nAre you sure you want to proceed?
error_sql_generation_title = Script generation error
error_sql_generation_message = Error generating alter script
dialog_search_objects_search_in_comments = Search in comments
......@@ -156,3 +156,4 @@ confirm_deleting_dependent_objects = \u0414\u0440\u0443\u0433\u0438\u0435 \u043E
confirm_deleting_dependent_one_object = \u0414\u0440\u0443\u0433\u043E\u0439 \u043E\u0431\u044A\u0435\u043A\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043E\u0442 \u044D\u0442\u043E\u0433\u043E \u043E\u0431\u044A\u0435\u043A\u0442\u0430 \u0438 \u0434\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u0443\u0434\u0430\u043B\u0451\u043D.\n\u0412\u044B \u0443\u0432\u0435\u0440\u0435\u043D\u044B, \u0447\u0442\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C {0} {1}?
search_dependencies_error_title = \u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u043E\u0438\u0441\u043A\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0435\u0439
search_dependencies_error_message = \u041E\u0448\u0438\u0431\u043A\u0430 \u0432\u043E\u0437\u043D\u0438\u043A\u043B\u0430 \u043F\u0440\u0438 \u043F\u043E\u0438\u0441\u043A\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0435\u0439 \u0434\u043B\u044F \u044D\u0442\u043E\u0433\u043E \u043E\u0431\u044A\u0435\u043A\u0442\u0430.
dialog_search_objects_search_in_comments = \u0418\u0441\u043A\u0430\u0442\u044C \u0432 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u044F\u0445
......@@ -61,17 +61,20 @@ import java.util.regex.Pattern;
* GotoObjectDialog
*/
public class GotoObjectDialog extends FilteredItemsSelectionDialog {
private static final String DIALOG_ID = "GotoObjectDialog";
private static final String DO_NOT_SEARCH_IN_COMMENTS = "SearchInComments";
private static final boolean SHOW_OBJECT_TYPES = true;
private static final int MAX_RESULT_COUNT = 1000;
private final DBCExecutionContext context;
private DBSObject container;
private Map<String, Boolean> enabledTypes = new HashMap<>();
private final DBSObject container;
private final Map<String, Boolean> enabledTypes = new HashMap<>();
private boolean hasMoreResults;
//This variable is "reverted" because we want to store it in preferences and be enabled by default.
private boolean doNotSearchInComments;
public GotoObjectDialog(Shell shell, DBCExecutionContext context, DBSObject container) {
super(shell, true);
this.context = context;
......@@ -84,15 +87,39 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
@Override
protected Control createExtendedContentArea(Composite parent) {
Composite composite = UIUtils.createComposite(parent, 1);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
createObjectTypesGroup(composite);
Button searchInCommentsCheckbox = UIUtils.createCheckbox(
composite,
UINavigatorMessages.dialog_search_objects_search_in_comments,
!doNotSearchInComments
);
GridData gd = new GridData();
gd.horizontalIndent = 6;
searchInCommentsCheckbox.setLayoutData(gd);
searchInCommentsCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doNotSearchInComments = !searchInCommentsCheckbox.getSelection();
}
});
return composite;
}
private void createObjectTypesGroup(Composite parent) {
if (!SHOW_OBJECT_TYPES) {
return null;
return;
}
IDialogSettings driverSettings = DialogSettings.getOrCreateSection(
getDialogSettings(), context.getDataSource().getContainer().getDriver().getId());
DBSStructureAssistant structureAssistant = DBUtils.getAdapter(DBSStructureAssistant.class, context.getDataSource());
DBSStructureAssistant<?> structureAssistant = DBUtils.getAdapter(DBSStructureAssistant.class, context.getDataSource());
if (structureAssistant == null) {
return null;
return;
}
List<DBSObjectType> typesToSearch = new ArrayList<>();
......@@ -104,46 +131,42 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
}
typesToSearch.add(type);
}
if (!CommonUtils.isEmpty(typesToSearch)) {
Group cbGroup = new Group(parent, SWT.NONE);
cbGroup.setText("Objects:");
RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
rowLayout.wrap = true;
cbGroup.setLayout(rowLayout);
cbGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
for (DBSObjectType type : typesToSearch) {
if (!isValidObjectType(type)) {
continue;
}
if (CommonUtils.isEmpty(typesToSearch)) {
return;
}
Group cbGroup = new Group(parent, SWT.NONE);
cbGroup.setText("Objects:");
RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
rowLayout.wrap = true;
cbGroup.setLayout(rowLayout);
cbGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
for (DBSObjectType type : typesToSearch) {
if (!isValidObjectType(type)) {
continue;
}
Button cb = new Button(cbGroup, SWT.CHECK);
cb.setData(type);
String typeName = CommonUtils.notEmpty(type.getTypeName());
cb.setText(typeName);
Button cb = new Button(cbGroup, SWT.CHECK);
cb.setData(type);
String typeName = CommonUtils.notEmpty(type.getTypeName());
cb.setText(typeName);
boolean enabled;
if (driverSettings.get(typeName) != null) {
enabled = driverSettings.getBoolean(typeName);
} else {
enabled = true;
}
cb.setSelection(enabled);
enabledTypes.put(typeName, enabled);
cb.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
enabledTypes.put(typeName, cb.getSelection());
driverSettings.put(typeName, cb.getSelection());
applyFilter();
//scheduleRefresh();
}
});
boolean enabled;
if (driverSettings.get(typeName) != null) {
enabled = driverSettings.getBoolean(typeName);
} else {
enabled = true;
}
return cbGroup;
cb.setSelection(enabled);
enabledTypes.put(typeName, enabled);
cb.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
enabledTypes.put(typeName, cb.getSelection());
driverSettings.put(typeName, cb.getSelection());
applyFilter();
}
});
}
return null;
}
@Override
......@@ -151,6 +174,18 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
return UIUtils.getDialogSettings(DIALOG_ID);
}
@Override
protected void restoreDialog(IDialogSettings settings) {
super.restoreDialog(settings);
doNotSearchInComments = settings.getBoolean(DO_NOT_SEARCH_IN_COMMENTS);
}
@Override
protected void storeDialog(IDialogSettings settings) {
super.storeDialog(settings);
settings.put(DO_NOT_SEARCH_IN_COMMENTS, doNotSearchInComments);
}
@Override
protected IStatus validateItem(Object item) {
return Status.OK_STATUS;
......@@ -372,6 +407,7 @@ public class GotoObjectDialog extends FilteredItemsSelectionDialog {
params.setParentObject(container);
params.setGlobalSearch(true);
params.setMaxResults(MAX_RESULT_COUNT);
params.setSearchInComments(!doNotSearchInComments);
result = structureAssistant.findObjectsByMask(monitor, executionContext, params);
hasMoreResults = result.size() >= MAX_RESULT_COUNT;
} catch (Exception e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册