@OpenApiAll
public interface ExtractManager
Refactoring.Extracting
class to create the extract
manager for a symbol which you want to extract. Configure the extract refactoring by changing
ExtractSource
and ExtractTarget
. Invoke the refactoring with RefactorManager.refactor().
Review refactoring results by inspecting ExtractSource
and ExtractTarget
.
// Creates extract refactor manager. ExtractManager extractManager = Refactoring.Extracting.createExtractManager(symbols); if (extractManager != null) { // A session has to be started before refactoring. SessionManager sessionManager = SessionManager.getInstance(); sessionManager.createSession("Extract Refactor Symbols"); // We may control the extract refactor result by modifying extract target. ExtractTarget extractTarget = extractManager.getExtractTarget(); // Create a namespace to which we are going to refactor. Project project = Project.getProject(symbols[0]); Package package1 = project.getElementsFactory().createPackageInstance(); package1.setOwner(project.getModel()); // Set the namespace to which the extract result will go. extractTarget.setTargetNamespace(package1); // Choose target diagram type from allowed diagram types if the default type does not suite. ListallowedTargetDiagramTypes = extractTarget.getAllowedTargetDiagramTypes(); extractTarget.setTargetDiagramType(allowedTargetDiagramTypes.get(0)); // Modify reference names which link the extract refactor source to the target. List extends ExtractReference> references = extractTarget.getReferences(); for (int i = 0; i < references.size(); i++) { ExtractReference reference = references.get(i); reference.setName(Integer.toString(i)); } // We may control the extract refactor source by modifying the extract source. ExtractSource extractSource = extractManager.getExtractSource(); extractSource.setElementName("sourceElementName"); // Perform actual refactoring. extractManager.extract(); sessionManager.closeSession(); // The element which was created in the source during refactoring. Element sourceElement = extractSource.getElement(); // The element which was created in the target during refactoring. Element targetElement = extractTarget.getElement(); // The diagram which was created in the target during refactoring. DiagramPresentationElement targetDiagram = extractTarget.getDiagram(); }
ExtractSource
,
ExtractTarget
,
Refactoring.Extracting
Modifier and Type | Method and Description |
---|---|
boolean |
extract()
Performs actual extract refactoring of the model.
|
ExtractSource |
getExtractSource()
Gets extract refactor source end of extract refactoring.
|
ExtractTarget |
getExtractTarget()
Gets extract refactor target which is used to customize the extracted result.
|
boolean extract()
ExtractTarget getExtractTarget()
ExtractSource getExtractSource()