Extract and Edit Component Classes
A part of a view that you want to reuse, such as a form, can become a component class of its own. Copilot extracts it, and edits inside it: the change goes into its class, and so into every view that uses it.
Extract a Component
-
Select the form: click a field, and press ← for its parent. In its ⋮ menu, point at Extract to Inner Component.
-
Click it. Copilot moves the form and its fields into a class inside the view’s class,
MyComponent, and selects it: its badge now has the ↳ button of a component class.
The new class is inside the view’s class. To use it in other views, move it to a file of its own with your IDE’s refactoring, such as Move in IntelliJ IDEA. Give it a name of its own, too.
Edit Inside a Component Class
-
Here the form is a
ContactForm, a class in a file of its own. Click a field in it, and the form is selected as a whole: its badge has a ↳ button that edits ContactForm.java instead of the view. -
Click it, and select a field inside. The Editing tag names ContactForm.java, and everything outside the form is dimmed.
-
Changes now go into ContactForm.java, and so into every view that has the form. Here Phone gets a helper text in Properties.
-
Click ↰ in the Editing tag to go back up to the view’s file, ContactView.java.