Search in sources :

Example 1 with ConflictImportDTO

use of org.eclipse.che.ide.ext.java.shared.dto.ConflictImportDTO in project che by eclipse.

the class CodeAssist method createListOfDTOMatches.

private List<ConflictImportDTO> createListOfDTOMatches(TypeNameMatch[][] choices) {
    List<ConflictImportDTO> typeMatches = new ArrayList<>();
    for (int i = 0; i < choices.length; i++) {
        List<String> nameMatches = new ArrayList<>();
        TypeNameMatch[] choice = choices[i];
        for (int j = 0; j < choice.length; j++) {
            nameMatches.add(choice[j].getFullyQualifiedName());
        }
        typeMatches.add(DtoFactory.newDto(ConflictImportDTO.class).withTypeMatches(nameMatches));
    }
    return typeMatches;
}
Also used : ConflictImportDTO(org.eclipse.che.ide.ext.java.shared.dto.ConflictImportDTO) TypeNameMatch(org.eclipse.jdt.core.search.TypeNameMatch) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point)

Example 2 with ConflictImportDTO

use of org.eclipse.che.ide.ext.java.shared.dto.ConflictImportDTO in project che by eclipse.

the class OrganizeImportsPresenter method onFinishButtonClicked.

/** {@inheritDoc} */
@Override
public void onFinishButtonClicked() {
    selected.put(page, view.getSelectedImport());
    ConflictImportDTO result = dtoFactory.createDto(ConflictImportDTO.class).withTypeMatches(new ArrayList<>(selected.values()));
    if (file instanceof Resource) {
        final Optional<Project> project = ((Resource) file).getRelatedProject();
        javaCodeAssistClient.applyChosenImports(project.get().getLocation().toString(), JavaUtil.resolveFQN(file), result).then(new Operation<List<Change>>() {

            @Override
            public void apply(List<Change> result) throws OperationException {
                applyChanges(((TextEditor) editor).getDocument(), result);
                view.hide();
                ((TextEditor) editor).setFocus();
            }
        }).catchError(new Operation<PromiseError>() {

            @Override
            public void apply(PromiseError arg) throws OperationException {
                String title = locale.failedToProcessOrganizeImports();
                String message = arg.getMessage();
                notificationManager.notify(title, message, FAIL, FLOAT_MODE);
            }
        });
    }
}
Also used : Resource(org.eclipse.che.ide.api.resources.Resource) Operation(org.eclipse.che.api.promises.client.Operation) Change(org.eclipse.che.ide.ext.java.shared.dto.Change) Project(org.eclipse.che.ide.api.resources.Project) ConflictImportDTO(org.eclipse.che.ide.ext.java.shared.dto.ConflictImportDTO) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) List(java.util.List) OperationException(org.eclipse.che.api.promises.client.OperationException)

Aggregations

ArrayList (java.util.ArrayList)2 ConflictImportDTO (org.eclipse.che.ide.ext.java.shared.dto.ConflictImportDTO)2 List (java.util.List)1 Operation (org.eclipse.che.api.promises.client.Operation)1 OperationException (org.eclipse.che.api.promises.client.OperationException)1 PromiseError (org.eclipse.che.api.promises.client.PromiseError)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 Project (org.eclipse.che.ide.api.resources.Project)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 Change (org.eclipse.che.ide.ext.java.shared.dto.Change)1 TypeNameMatch (org.eclipse.jdt.core.search.TypeNameMatch)1 Point (org.eclipse.swt.graphics.Point)1