-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance the SQL-dataset-editor with a search option (#1700) #1701
Enhance the SQL-dataset-editor with a search option (#1700) #1701
Conversation
...a.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/editors/SQLDataSetEditorPage.java
Outdated
Show resolved
Hide resolved
...a.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/editors/SQLDataSetEditorPage.java
Outdated
Show resolved
Hide resolved
...a.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/editors/SQLDataSetEditorPage.java
Outdated
Show resolved
Hide resolved
|
||
private void setupLabelFindQueryTextGroup(int findMode) { | ||
Device device = Display.getCurrent(); | ||
Color fontColor = new Color(device, 0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming you’re not in dark mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the color of the label is changed to "red" for the hint message it will be set back to default-color black.
Therefore I define the default color. We need the color-reset because if not the label would be always red when a red-message was displayed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What color is the text in dark mode? I’m on a phone so it limits the links to send. Setting to black assumes the text is black. Not a good assumption. Also Color needs to be disposed. Better to look how other parts of the framework get colors and set them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, black text with black background is really hard.
I store the original color on a privat member and the label color will be disposed after use directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and optimized.
It would be really good to learn how to amend a commit and force push it so that a PR is a single commit in the history with no semi-bogus intermediate commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a fair bit of room for improvement, but the color handling is especially poor.
} | ||
|
||
private boolean isFindQueryTextBackward(KeyEvent e) { | ||
// CTRL + SHIFT + f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the comment matches the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -149,6 +156,11 @@ public class SQLDataSetEditorPage extends DataSetWizardPage { | |||
private static final int DB_OBJECT_TREE_HEIGHT_MIN = 150; | |||
private static final int DB_OBJECT_TREE_WIDTH_MIN = 200; | |||
|
|||
private static final String FIND_DIRECTION_SYMBOLE_FORWARD = "\u25BC"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The German spelling for symbol is has kicked it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
private static final String FIND_DIRECTION_SYMBOLE_FORWARD = "\u25BC"; | ||
private static final String FIND_DIRECTION_SYMBOLE_BACKWARD = "\u25B2"; | ||
|
||
private Color findGroupLabelOriginalColor = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed. I expect you can get the color from some other textual thing in the dialog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my point of view it is better to use the original element instead of another text element of the dialog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
@@ -998,6 +1031,21 @@ private boolean isRedoKeyPress(KeyEvent e) { | |||
return ((e.stateMask & SWT.CONTROL) > 0) && ((e.keyCode == 'y') || (e.keyCode == 'Y')); | |||
} | |||
|
|||
private boolean isFindQueryText(KeyEvent e) { | |||
// CTRL + f | |||
return ((e.stateMask & SWT.CONTROL) > 0) && ((e.keyCode == 'f') || (e.keyCode == 'F')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places in the Platform I see tests like this:
if (e.stateMask == SWT.CTRL && e.keyCode == 'a') {
That makes me wonder what cases are all being covered by your guard other than ctrl-f?
This verbose and to me confusing pattern is repeated often...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I used the original pattern which was used in this viewer part.
Yes, I know, your example is more clean, so I will change it to your version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All keyboard keys changed to your way - also the old versions (!)
|
||
// forward search end | ||
if (findMode == 1) { | ||
fontColor = new Color(Display.getCurrent(), 255, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many better ways to get colors and better ways to get the display. E.g.,
findQueryTextGroup.getDisplay().getSystemColor(SWT.COLOR_RED);
But look at how the Platform handles such a case of a status error in the find and replace dialog:
Nowhere is the color hard coded but rather is controlled by the user's preferences that are sensitive to the color mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
if (findQueryText != null) { | ||
boolean found = viewer.findQueryText(findQueryText.getText(), true, | ||
findQueryTextCaseSensitive.getSelection(), findQueryTextWholeWord.getSelection()); | ||
if (found) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More concise would be setupLabelFindQueryTextGroup(found ? 0 : 1)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
@@ -1075,4 +1123,149 @@ private void insertTreeItemText() { | |||
insertText(text); | |||
} | |||
} | |||
|
|||
private void setupFindQueryTextBox(Group group) { | |||
this.findQueryText = new Text(group, SWT.BORDER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of this use of this
where it just isn't necessary. I expect that to be used only when there is a local variable with the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of "this" is my personal style, I will remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
private void setupFindQueryTextOptions(Group group) { | ||
|
||
GridData csLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); | ||
this.findQueryTextCaseSensitive = new Button(group, SWT.CHECK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many pointless this
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
...a.oda.jdbc.ui/src/org/eclipse/birt/report/data/oda/jdbc/ui/editors/SQLDataSetEditorPage.java
Show resolved
Hide resolved
|
||
findQueryTextGroup.setForeground(fontColor); | ||
findQueryTextGroup.setText(groupLabel); | ||
fontColor.dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, does this even work? Setting the color doesn't copy so you can't dispose something that's in use. I have a feeling that Color doesn't actually do anything when disposed, on some or maybe all platforms, but in any case this is a super bad pattern to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your suggestion for the Color-dispose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dispose will work!
Because that this is the reason why I copy the color-object to a new object value.
If I use the same reference without copy then the dispose destroy/dispose really the color object and it isn't available any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If disposed did something then the widget using the color would be broken.
Please look at how the platform is doing the same thing as I've referenced elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
Here is how to amend. You must push the amend toolbar button: Once pushed, it will bring back the commit message of the current commit: (It's possible to unpush the button too.) You can add any changes to the commit being amended via what is staged. Then Commit it; Commit and Push will fail to do the push because the changes are not fast-forward. Bring up up the Push... dialog on the branch via the context menu: In the dialog, it's generally best to use Rebase, but most importantly, check mark the Force option. Then you can complete the operation. The PR's commit will be updated and a new build will kick off. |
Please, please, do the colors similar to like this:
No hard coded colors, no copying, no disposing. The colors of fonts within a dialog is consistently the same, so assuming that you need to keep the original color is overkill. But in any case, don't create colors and don't dispose them. |
I will use this pattern to set the color setting and will remove the dispose. |
0c54dec
to
1a075fb
Compare
@merks |
It looks very promising! I’ll look tomorrow when I’m back at the computer. |
FYI, SimRel disaster kicked in this morning: https://www.eclipse.org/lists/cross-project-issues-dev/msg19901.html I've temporarily disable BIRT's builds because of this problem; I don't want any badly signing content in the update sites. I hope the certificate will be resolved in the coming hours. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good. Thanks for the improvements.
Thanks for your time and detailed support! |
No description provided.