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

IEP-1346 Make it possible to copy values ​​from fields with dynamic variables #1068

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

sigmaaa
Copy link
Collaborator

@sigmaaa sigmaaa commented Oct 17, 2024

Description

Previously, when we clicked a button in a text box to show a dynamic variable, we had to hold it down. Users can now click on it once and the dynamic variables will be resolved, but the text will not be editable.

Fixes # (IEP-1346)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • click resolve dynamic variables button (eye button in the text field) and save the setting in the main tab or the debugger tab -> click edit again -> the fields should be with dynamic variables
  • run flash, jtag flash, debug
  • when we resolve dynamic variables the text field should not be editable, when we have dynamic variables or the eye icon isn't clicked we can edit it

Test Configuration:

  • ESP-IDF Version:
  • OS (Windows,Linux and macOS):

Dependent components impacted by this PR:

  • Main tab in the launch configuration
  • Debugger tab in the debug configuration

Checklist

  • PR Self Reviewed
  • Applied Code formatting
  • Added Documentation
  • Added Unit Test
  • Verified on all platforms - Windows,Linux and macOS

Summary by CodeRabbit

  • New Features
    • Enhanced handling of dynamic variables in the text field for improved interactivity.
    • Added functionality to display dynamic variables when the text field is non-editable.
  • Bug Fixes
    • Updated text retrieval to ensure dynamic variables are returned correctly when the text field is not editable.

Copy link

coderabbitai bot commented Oct 17, 2024

Walkthrough

The TextWithButton class in the com.espressif.idf.swt.custom package has been modified to improve the handling of dynamic variables. A new private member variable, textWithDynamicVariables, was added to manage text when dynamic variables are shown. The mouseDown method was updated to check if the text field is editable, and if not, it calls showDynamicVariables() to display the dynamic variables. A new method, showDynamicVariables(), was introduced to manage the display logic, and the getText() method was updated to return the dynamic variable text when the field is non-editable.

Changes

File Change Summary
bundles/com.espressif.idf.swt.custom/src/com/espressif/idf/swt/custom/TextWithButton.java - Added private variable textWithDynamicVariables.
- Added method showDynamicVariables().
- Updated getText() to return textWithDynamicVariables when not editable.

Suggested reviewers

  • AndriiFilippov
  • kolipakakondal
  • alirana01

Poem

In a field where rabbits play,
Dynamic text comes out to sway.
With buttons bright and fields so neat,
Our changes make the work complete!
Hop along, let's celebrate,
A code that’s better, oh so great! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
bundles/com.espressif.idf.swt.custom/src/com/espressif/idf/swt/custom/TextWithButton.java (3)

62-62: Improve the clarity of the inline comment

The current comment at line 62 can be rephrased for better readability and understanding.

Apply this diff to enhance the comment:

-                // text is not editable means that the button isn't pressed now and we have to show dynamic variables
+                // If the text is not editable, display the dynamic variables

69-75: Ensure consistent exception handling

While the try block correctly attempts string substitution, consider handling the exception more gracefully or providing user feedback in case of failure.

Optionally, you could inform the user if the substitution fails:

                 try
                 {
                     text.setText(VariablesPlugin.getDefault().getStringVariableManager()
                             .performStringSubstitution((textWithDynamicVariables), false));
+                }
+                catch (CoreException e1)
+                {
+                    Logger.log(e1);
+                    MessageDialog.openError(parent.getShell(), "Error", "Failed to resolve dynamic variables.");
                 }
-                catch (CoreException e1)
-                {
-                    Logger.log(e1);
-                }

This provides a better user experience by notifying them of the issue.


107-112: Clarify the method comment in 'getText()'

The comment above the getText() method states "Always return text with dynamic variables," but the method returns textWithDynamicVariables only when the text is not editable.

Consider updating the comment for accuracy:

-    /*
-     * Always return text with dynamic variables.
-     */
+    /**
+     * Returns the original text with dynamic variables when not resolved.
+     * If dynamic variables are resolved (text is not editable), returns the resolved text.
+     */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b6d1458 and cf197e2.

📒 Files selected for processing (1)
  • bundles/com.espressif.idf.swt.custom/src/com/espressif/idf/swt/custom/TextWithButton.java (3 hunks)
🧰 Additional context used

@espressif espressif deleted a comment from coderabbitai bot Oct 18, 2024
Copy link
Collaborator

@kolipakakondal kolipakakondal left a comment

Choose a reason for hiding this comment

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

LGTM

@kolipakakondal
Copy link
Collaborator

@AndriiFilippov Please take a look.

@kolipakakondal kolipakakondal added this to the v3.1.1 milestone Oct 22, 2024
@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi!

Tested:
OS - Windows 11 / Mac arm64

Add a variable from the list and try displaying it with 'eye'—nothing happens.
image

@sigmaaa
Copy link
Collaborator Author

sigmaaa commented Nov 4, 2024

Hi @AndriiFilippov,

I don't have a fix for it right now. Since this issue is not caused by this pr, let's handle it in the separate issue

@AndriiFilippov
Copy link
Collaborator

@sigmaaa hi !
ok , I will create ticket

Tested:
OS - Windows 11 / Mac arm64
able to display and copy string
image

LGTM 👍

@kolipakakondal kolipakakondal merged commit c30f7d8 into master Nov 5, 2024
7 checks passed
@kolipakakondal kolipakakondal deleted the IEP-1346 branch November 5, 2024 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants