Skip to content
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

Conversation

speckyspooky
Copy link
Contributor

No description provided.

@speckyspooky speckyspooky added this to the 4.16 milestone May 21, 2024
@speckyspooky speckyspooky requested a review from merks May 21, 2024 19:01
@speckyspooky speckyspooky self-assigned this May 21, 2024

private void setupLabelFindQueryTextGroup(int findMode) {
Device device = Display.getCurrent();
Color fontColor = new Color(device, 0, 0, 0);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done and optimized.

@merks
Copy link
Contributor

merks commented May 21, 2024

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.

@speckyspooky speckyspooky requested a review from merks May 22, 2024 04:18
Copy link
Contributor

@merks merks left a 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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it

Copy link
Contributor Author

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";
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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'));
Copy link
Contributor

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...

Copy link
Contributor Author

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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:

https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java#L1310-L1324

Nowhere is the color hard coded but rather is controlled by the user's preferences that are sensitive to the color mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it.

Copy link
Contributor Author

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) {
Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it.

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many pointless this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed


findQueryTextGroup.setForeground(fontColor);
findQueryTextGroup.setText(groupLabel);
fontColor.dispose();
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@merks
Copy link
Contributor

merks commented May 22, 2024

Here is how to amend. You must push the amend toolbar button:

image

Once pushed, it will bring back the commit message of the current commit:

image

(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:

image

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.

@merks
Copy link
Contributor

merks commented May 22, 2024

Please, please, do the colors similar to like this:

	private void evaluateFindReplaceStatus(boolean allowBeep) {
		IFindReplaceStatus status = findReplaceLogic.getStatus();

		String dialogMessage = status.accept(new FindReplaceLogicMessageGenerator());
		fStatusLabel.setText(dialogMessage);
		if (status.isInputValid()) {
			fStatusLabel.setForeground(fReplaceLabel.getForeground());
		} else {
			fStatusLabel.setForeground(JFaceColors.getErrorText(fStatusLabel.getDisplay()));
		}

		if (!status.wasSuccessful()) {
			tryToBeep(allowBeep);
		}
	}

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.

@speckyspooky
Copy link
Contributor Author

Please, please, do the colors similar to like this:

	private void evaluateFindReplaceStatus(boolean allowBeep) {
...
	}

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.

@speckyspooky speckyspooky force-pushed the enhance_sql_dataset_editor_with_search branch from 0c54dec to 1a075fb Compare May 22, 2024 18:54
@speckyspooky
Copy link
Contributor Author

@merks
The color handling is optimized according to your suggestion.
I have reused the last commit and there isn't an additional commit listed.

@merks
Copy link
Contributor

merks commented May 22, 2024

It looks very promising! I’ll look tomorrow when I’m back at the computer.

@merks
Copy link
Contributor

merks commented May 23, 2024

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.

Copy link
Contributor

@merks merks left a 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.

@speckyspooky
Copy link
Contributor Author

Thanks for your time and detailed support!

@speckyspooky speckyspooky merged commit 833a176 into eclipse-birt:master May 23, 2024
3 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants