提交 02bc43c3 编写于 作者: S serge@jkiss.org

RSV filter dialog UI glitch fix


Former-commit-id: fd3e3331
上级 091a9456
...@@ -55,20 +55,12 @@ class FilterSettingsDialog extends HelpEnabledDialog { ...@@ -55,20 +55,12 @@ class FilterSettingsDialog extends HelpEnabledDialog {
private static final String DIALOG_ID = "DBeaver.FilterSettingsDialog";//$NON-NLS-1$ private static final String DIALOG_ID = "DBeaver.FilterSettingsDialog";//$NON-NLS-1$
public final Comparator<DBDAttributeBinding> POSITION_SORTER = new Comparator<DBDAttributeBinding>() { private final Comparator<DBDAttributeBinding> POSITION_SORTER = (o1, o2) -> {
@Override final DBDAttributeConstraint c1 = getBindingConstraint(o1);
public int compare(DBDAttributeBinding o1, DBDAttributeBinding o2) { final DBDAttributeConstraint c2 = getBindingConstraint(o2);
final DBDAttributeConstraint c1 = getBindingConstraint(o1); return c1.getVisualPosition() - c2.getVisualPosition();
final DBDAttributeConstraint c2 = getBindingConstraint(o2);
return c1.getVisualPosition() - c2.getVisualPosition();
}
};
public final Comparator<DBDAttributeBinding> ALPHA_SORTER = new Comparator<DBDAttributeBinding>() {
@Override
public int compare(DBDAttributeBinding o1, DBDAttributeBinding o2) {
return o1.getName().compareTo(o2.getName());
}
}; };
private final Comparator<DBDAttributeBinding> ALPHA_SORTER = Comparator.comparing(DBDAttributeBinding::getName);
private final ResultSetViewer resultSetViewer; private final ResultSetViewer resultSetViewer;
private final List<DBDAttributeBinding> attributes; private final List<DBDAttributeBinding> attributes;
...@@ -85,7 +77,7 @@ class FilterSettingsDialog extends HelpEnabledDialog { ...@@ -85,7 +77,7 @@ class FilterSettingsDialog extends HelpEnabledDialog {
private ToolItem moveBottomButton; private ToolItem moveBottomButton;
private Comparator<DBDAttributeBinding> activeSorter = POSITION_SORTER; private Comparator<DBDAttributeBinding> activeSorter = POSITION_SORTER;
public FilterSettingsDialog(ResultSetViewer resultSetViewer) FilterSettingsDialog(ResultSetViewer resultSetViewer)
{ {
super(resultSetViewer.getControl().getShell(), IHelpContextIds.CTX_DATA_FILTER); super(resultSetViewer.getControl().getShell(), IHelpContextIds.CTX_DATA_FILTER);
this.resultSetViewer = resultSetViewer; this.resultSetViewer = resultSetViewer;
...@@ -126,7 +118,7 @@ class FilterSettingsDialog extends HelpEnabledDialog { ...@@ -126,7 +118,7 @@ class FilterSettingsDialog extends HelpEnabledDialog {
if (nestedBindings == null || nestedBindings.isEmpty()) { if (nestedBindings == null || nestedBindings.isEmpty()) {
return null; return null;
} }
final DBDAttributeBinding[] res = nestedBindings.toArray(new DBDAttributeBinding[nestedBindings.size()]); final DBDAttributeBinding[] res = nestedBindings.toArray(new DBDAttributeBinding[0]);
Arrays.sort(res, activeSorter); Arrays.sort(res, activeSorter);
return res; return res;
} }
...@@ -206,12 +198,9 @@ class FilterSettingsDialog extends HelpEnabledDialog { ...@@ -206,12 +198,9 @@ class FilterSettingsDialog extends HelpEnabledDialog {
} }
}; };
columnsViewer.addCheckStateListener(new ICheckStateListener() { columnsViewer.addCheckStateListener(event -> {
@Override DBDAttributeConstraint constraint = getBindingConstraint((DBDAttributeBinding) event.getElement());
public void checkStateChanged(CheckStateChangedEvent event) { constraint.setVisible(event.getChecked());
DBDAttributeConstraint constraint = getBindingConstraint((DBDAttributeBinding) event.getElement());
constraint.setVisible(event.getChecked());
}
}); });
{ {
...@@ -220,93 +209,65 @@ class FilterSettingsDialog extends HelpEnabledDialog { ...@@ -220,93 +209,65 @@ class FilterSettingsDialog extends HelpEnabledDialog {
gd.verticalIndent = 3; gd.verticalIndent = 3;
toolbar.setLayoutData(gd); toolbar.setLayoutData(gd);
toolbar.setLayout(new FillLayout()); toolbar.setLayout(new FillLayout());
moveTopButton = createToolItem(toolbar, "Move to top", UIIcon.ARROW_TOP, new Runnable() { moveTopButton = createToolItem(toolbar, "Move to top", UIIcon.ARROW_TOP, () -> {
@Override int selectionIndex = getSelectionIndex(columnsViewer.getTree());
public void run() { moveColumns(selectionIndex, 0);
int selectionIndex = getSelectionIndex(columnsViewer.getTree());
moveColumns(selectionIndex, 0);
}
}); });
moveTopButton.setEnabled(false); moveTopButton.setEnabled(false);
moveUpButton = createToolItem(toolbar, "Move up", UIIcon.ARROW_UP, new Runnable() { moveUpButton = createToolItem(toolbar, "Move up", UIIcon.ARROW_UP, () -> {
@Override int selectionIndex = getSelectionIndex(columnsViewer.getTree());
public void run() { swapColumns(selectionIndex, selectionIndex - 1);
int selectionIndex = getSelectionIndex(columnsViewer.getTree());
swapColumns(selectionIndex, selectionIndex - 1);
}
}); });
moveUpButton.setEnabled(false); moveUpButton.setEnabled(false);
moveDownButton = createToolItem(toolbar, "Move down", UIIcon.ARROW_DOWN, new Runnable() { moveDownButton = createToolItem(toolbar, "Move down", UIIcon.ARROW_DOWN, () -> {
@Override int selectionIndex = getSelectionIndex(columnsViewer.getTree());
public void run() { swapColumns(selectionIndex, selectionIndex + 1);
int selectionIndex = getSelectionIndex(columnsViewer.getTree());
swapColumns(selectionIndex, selectionIndex + 1);
}
}); });
moveDownButton.setEnabled(false); moveDownButton.setEnabled(false);
moveBottomButton = createToolItem(toolbar, "Move to bottom", UIIcon.ARROW_BOTTOM, new Runnable() { moveBottomButton = createToolItem(toolbar, "Move to bottom", UIIcon.ARROW_BOTTOM, () -> {
@Override int selectionIndex = getSelectionIndex(columnsViewer.getTree());
public void run() { moveColumns(selectionIndex, getItemsCount() - 1);
int selectionIndex = getSelectionIndex(columnsViewer.getTree());
moveColumns(selectionIndex, getItemsCount() - 1);
}
}); });
moveBottomButton.setEnabled(false); moveBottomButton.setEnabled(false);
UIUtils.createToolBarSeparator(toolbar, SWT.VERTICAL); UIUtils.createToolBarSeparator(toolbar, SWT.VERTICAL);
createToolItem(toolbar, "Sort", UIIcon.SORT, new Runnable() { createToolItem(toolbar, "Sort", UIIcon.SORT, () -> {
@Override attributes.sort(ALPHA_SORTER);
public void run() { for (int i = 0; i < attributes.size(); i++) {
Collections.sort(attributes, ALPHA_SORTER); final DBDAttributeConstraint constraint = getBindingConstraint(attributes.get(i));
for (int i = 0; i < attributes.size(); i++) { constraint.setVisualPosition(i);
final DBDAttributeConstraint constraint = getBindingConstraint(attributes.get(i));
constraint.setVisualPosition(i);
}
columnsViewer.refresh();
} }
columnsViewer.refresh();
}); });
UIUtils.createToolBarSeparator(toolbar, SWT.VERTICAL); UIUtils.createToolBarSeparator(toolbar, SWT.VERTICAL);
ToolItem showAllButton = createToolItem(toolbar, "Show All", null, new Runnable() { ToolItem showAllButton = createToolItem(toolbar, "Show All", null, () -> {
@Override for (DBDAttributeConstraint constraint : constraints) {
public void run() { constraint.setVisible(true);
for (DBDAttributeConstraint constraint : constraints) {
constraint.setVisible(true);
}
columnsViewer.refresh();
} }
columnsViewer.refresh();
}); });
showAllButton.setImage(UIUtils.getShardImage(ISharedImages.IMG_ETOOL_DEF_PERSPECTIVE)); showAllButton.setImage(UIUtils.getShardImage(ISharedImages.IMG_ETOOL_DEF_PERSPECTIVE));
ToolItem showNoneButton = createToolItem(toolbar, "Show None", null, new Runnable() { ToolItem showNoneButton = createToolItem(toolbar, "Show None", null, () -> {
@Override for (DBDAttributeConstraint constraint : constraints) {
public void run() { constraint.setVisible(false);
for (DBDAttributeConstraint constraint : constraints) {
constraint.setVisible(false);
}
columnsViewer.refresh();
} }
columnsViewer.refresh();
}); });
showNoneButton.setImage(UIUtils.getShardImage(ISharedImages.IMG_ELCL_REMOVEALL)); showNoneButton.setImage(UIUtils.getShardImage(ISharedImages.IMG_ELCL_REMOVEALL));
createToolItem(toolbar, "Reset", UIIcon.REFRESH, new Runnable() { createToolItem(toolbar, "Reset", UIIcon.REFRESH, () -> {
@Override dataFilter.reset();
public void run() { constraints = new ArrayList<>(dataFilter.getConstraints());
dataFilter.reset(); refreshData();
constraints = new ArrayList<>(dataFilter.getConstraints()); //columnsViewer.refresh();
refreshData(); orderText.setText(""); //$NON-NLS-1$
//columnsViewer.refresh(); whereText.setText(""); //$NON-NLS-1$
orderText.setText(""); //$NON-NLS-1$
whereText.setText(""); //$NON-NLS-1$
}
}); });
columnsViewer.addSelectionChangedListener(new ISelectionChangedListener() { columnsViewer.addSelectionChangedListener(event -> {
@Override int selectionIndex = getSelectionIndex(columnsViewer.getTree());
public void selectionChanged(SelectionChangedEvent event) { moveTopButton.setEnabled(selectionIndex > 0);
int selectionIndex = getSelectionIndex(columnsViewer.getTree()); moveUpButton.setEnabled(selectionIndex > 0);
moveTopButton.setEnabled(selectionIndex > 0); moveDownButton.setEnabled(selectionIndex >= 0 && selectionIndex < getItemsCount() - 1);
moveUpButton.setEnabled(selectionIndex > 0); moveBottomButton.setEnabled(selectionIndex >= 0 && selectionIndex < getItemsCount() - 1);
moveDownButton.setEnabled(selectionIndex >= 0 && selectionIndex < getItemsCount() - 1);
moveBottomButton.setEnabled(selectionIndex >= 0 && selectionIndex < getItemsCount() - 1);
}
}); });
} }
...@@ -323,12 +284,7 @@ class FilterSettingsDialog extends HelpEnabledDialog { ...@@ -323,12 +284,7 @@ class FilterSettingsDialog extends HelpEnabledDialog {
refreshData(); refreshData();
// Pack UI // Pack UI
UIUtils.asyncExec(new Runnable() { UIUtils.asyncExec(() -> UIUtils.packColumns(columnsViewer.getTree()));
@Override
public void run() {
UIUtils.packColumns(columnsViewer.getTree());
}
});
//UIUtils.packColumns(filterViewer.getTable()); //UIUtils.packColumns(filterViewer.getTable());
if (criteriaColumn.getWidth() < 200) { if (criteriaColumn.getWidth() < 200) {
...@@ -350,7 +306,7 @@ class FilterSettingsDialog extends HelpEnabledDialog { ...@@ -350,7 +306,7 @@ class FilterSettingsDialog extends HelpEnabledDialog {
} }
private void refreshData() { private void refreshData() {
Collections.sort(attributes, activeSorter); attributes.sort(activeSorter);
columnsViewer.refresh(); columnsViewer.refresh();
columnsViewer.expandAll(); columnsViewer.expandAll();
} }
...@@ -522,7 +478,7 @@ class FilterSettingsDialog extends HelpEnabledDialog { ...@@ -522,7 +478,7 @@ class FilterSettingsDialog extends HelpEnabledDialog {
case 2: { case 2: {
int orderPosition = constraint.getOrderPosition(); int orderPosition = constraint.getOrderPosition();
if (orderPosition > 0) { if (orderPosition > 0) {
return String.valueOf(orderPosition); return " " + String.valueOf(orderPosition);
} }
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
...@@ -568,7 +524,7 @@ class FilterSettingsDialog extends HelpEnabledDialog { ...@@ -568,7 +524,7 @@ class FilterSettingsDialog extends HelpEnabledDialog {
} }
public static ToolItem createToolItem(ToolBar toolBar, String text, DBIcon icon, final Runnable action) private static ToolItem createToolItem(ToolBar toolBar, String text, DBIcon icon, final Runnable action)
{ {
ToolItem item = new ToolItem(toolBar, SWT.PUSH); ToolItem item = new ToolItem(toolBar, SWT.PUSH);
if (icon != null) { if (icon != null) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册