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

Adding SWT + JFace when creating a plugin that "makes contribution to the UI" #1306 #1472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cervantes-yadira
Copy link

According to the original issue, using JFace and SWT is almost necessary for plugins that contribute to the UI. Since these dependencies can be easily removed and are already dependencies of Eclipse, we decided to add them by default.

Fixes #1306

@HannesWell HannesWell self-requested a review November 12, 2024 23:26
Copy link

github-actions bot commented Nov 12, 2024

Test Results

   285 files  ±0     285 suites  ±0   52m 21s ⏱️ - 1m 17s
 3 586 tests ±0   3 508 ✅  - 2   76 💤 ±0  0 ❌ ±0  2 🔥 +2 
10 950 runs  ±0  10 717 ✅  - 2  231 💤 ±0  0 ❌ ±0  2 🔥 +2 

For more details on these errors, see this check.

Results for commit be4dc0b. ± Comparison against base commit ef694eb.

♻️ This comment has been updated with latest results.

Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

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

Hi @cervantes-yadira, thank you for this PR. It already looks quite good. Nice work.
I just have a comment in the code to further refine this.

If you apply the changes, please amend your commit locally and force push the amended commit to the branch of this PR so that we get a nice and clean history.

Comment on lines 557 to 561
}
// Else if a plug-in project is being created...
else if (fData instanceof IPluginFieldData) {
// And the plug-in project makes contributions to the UI...
if (((IPluginFieldData) fData).isUIPlugin()) {
// Add SWT and JFace as dependencies
result.add(new PluginReference("org.eclipse.swt")); //$NON-NLS-1$
result.add(new PluginReference("org.eclipse.jface")); //$NON-NLS-1$
}
}
Copy link
Member

@HannesWell HannesWell Nov 14, 2024

Choose a reason for hiding this comment

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

You can use Pattern matching for instanceof here and then combine the two if statements nicely into one.
Furthermore the comments can be reduced here. It's not necessary to write down every action in a corresponding comment. Comments should only be used to clarify the logic where it is not obvious from the code (ideally the code is readable and understandable in itself).

And last but not least the logic should be enhanced to to not add the dependencies if a user has selected a template.
If a template is selected that template already defines the necessary dependencies and nothing should be change here.
Just as described in #1306 (comment).

Suggested change
}
// Else if a plug-in project is being created...
else if (fData instanceof IPluginFieldData) {
// And the plug-in project makes contributions to the UI...
if (((IPluginFieldData) fData).isUIPlugin()) {
// Add SWT and JFace as dependencies
result.add(new PluginReference("org.eclipse.swt")); //$NON-NLS-1$
result.add(new PluginReference("org.eclipse.jface")); //$NON-NLS-1$
}
}
} else if (fContentWizard == null && fData instanceof IPluginFieldData pluginData && pluginData.isUIPlugin()) {
// a plug-in project is being created and makes contributions to UI
result.add(new PluginReference("org.eclipse.swt")); //$NON-NLS-1$
result.add(new PluginReference("org.eclipse.jface")); //$NON-NLS-1$
}

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the suggestions! I added the additional check for the use of templates and used pattern matching as you suggested. I have appended the commit and pushed it to this branch.

Dependencies aren't added for plug-ins that generate an activator file
or use a template.
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.

Adding SWT + JFace when creating a plugin that "makes contribution to the UI"
2 participants