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

Refactor: IProject: add getter and setter of Segmenter and removal of static fileds of the objects in Core class #1194

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

miurahr
Copy link
Member

@miurahr miurahr commented Nov 20, 2024

Move segmenter object to be hold by RealProject object.

There are Preferences and configurations of SRX in User preferences and project-specific custom segmentation rules.
There is a segmenter object which is for the current live project, which is runtime property of the live project.

Current implementation hold the segmenter in the Core class as static field.
Here propose it to move into RealProject class, and extend IProject interface to have getter and setter of the segmenter.

Pull request type

  • Other (describe below)
    refactoring

Which ticket is resolved?

Discussed on DEV-ML thread

What does this PR change?

  • Extend IProject to have getter and setter for Segmenter and FilterMaster
  • add segmenter and filterMaster fields in RealProject class, and put setter and getter
  • Update Core class:
    * removal of static fileds of segmenter
    * removal of initialization of these fields in initilizeGuiImpl method
    * Update getters to return value from currentProject#getSegmenter
    * Update setters as well
    * We don't need to reset Core static fields value when closing project.
  • Update test cases
    * Removal of Core.setSegmenter. We define private filed of the test class for these objects.
    * We extend mock project class with these private fields
    * These changes make the test case does not depend on the static context, so there will be no interference among test cases.
  • Extent AlignFilesCallback ctor to take segmenter object.
    * the callback object does not depend on static context of the OmegaT project.
    * We can test ExternalTMFactory without Core static context.

Other information

@miurahr miurahr requested a review from t-cordonnier November 20, 2024 14:58
@miurahr miurahr changed the title Refactor: IProject: add getter and setter of Segmenter and FilterMaster Refactor: IProject: add getter and setter of Segmenter and FilterMaster, and removal of static fileds of the objects in Core class Nov 20, 2024

This comment was marked as outdated.

Copy link
Member Author

@miurahr miurahr left a comment

Choose a reason for hiding this comment

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

There are space to improve an order of arguments.

src/org/omegat/core/data/RealProject.java Outdated Show resolved Hide resolved
test/src/org/omegat/core/data/ExternalTMFactoryTest.java Outdated Show resolved Hide resolved

This comment was marked as outdated.

@miurahr miurahr changed the title Refactor: IProject: add getter and setter of Segmenter and FilterMaster, and removal of static fileds of the objects in Core class Refactor: IProject: add getter and setter of Segmenter and removal of static fileds of the objects in Core class Nov 20, 2024
@miurahr
Copy link
Member Author

miurahr commented Nov 20, 2024

refactoring FilterMaster does not work well. I want to revert it.

@miurahr miurahr force-pushed the topic/miurahr/core/project/getter-setter-segmenter branch from 70dbe22 to 05f4c8d Compare November 20, 2024 23:16

This comment was marked as outdated.

@miurahr
Copy link
Member Author

miurahr commented Nov 20, 2024

There are unrelated refactorings. I want to skip it.

…ject

- Add getSegmenter/setSegmenter to IProject
- Update Core.getSegmenter/setSegmenter to use currentProject.getSegmenter/setSegmenter

Signed-off-by: Hiroshi Miura <[email protected]>
@miurahr miurahr force-pushed the topic/miurahr/core/project/getter-setter-segmenter branch from 05f4c8d to 2bffaf0 Compare November 20, 2024 23:34

This comment was marked as resolved.

@miurahr
Copy link
Member Author

miurahr commented Nov 21, 2024

The test failure is happened because an aligner test uses Core.setSegmenter() without initializing Core.setProject with NotLoadedProject or a real project.

- Allow Aligner to have segmenter object without depending Core.getSegmenter()
- Aligner should works without loading project, so it should have its own object
- Aligner also have a feature to call SegmentationCustomizer, so when user customize the segmenter, Aligner uses new one.
- SegmentetionCustomizer saves customized SRX as user preference and store it in the project, so Aligner do not need to call Core.setSegmenter()

Signed-off-by: Hiroshi Miura <[email protected]>

This comment was marked as resolved.

…egmenter

Signed-off-by: Hiroshi Miura <[email protected]>

# Conflicts:
#	aligner/src/main/java/org/omegat/gui/align/AlignPanelController.java
#	aligner/src/main/java/org/omegat/gui/align/Aligner.java
@miurahr
Copy link
Member Author

miurahr commented Nov 21, 2024

The issue in Aligner is dealt with #1190. Now merge it.

Copy link

❌ Acceptance Tests failed.

Please look a Gradle Scan page for details:
https://gradle.com/s/hsknpdkbulfvu

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants