Search in sources :

Example 1 with AssertionFailedException

use of org.eclipse.core.runtime.AssertionFailedException in project che by eclipse.

the class RefactoringManager method applyLinkedRename.

/**
     * Apply linked mode rename refactoring.
     *
     * @param apply
     *         contains new element name
     * @return refactoring result
     * @throws RefactoringException
     *         when refactoring session not found.
     * @throws CoreException
     *         when impossible to apply rename refactoring
     */
public RefactoringResult applyLinkedRename(LinkedRenameRefactoringApply apply) throws RefactoringException, CoreException {
    RefactoringSession session = getRefactoringSession(apply.getSessionId());
    if (session instanceof RenameLinkedModeRefactoringSession) {
        RenameLinkedModeRefactoringSession renameSession = (RenameLinkedModeRefactoringSession) session;
        try {
            RefactoringResult refactoringResult = renameSession.doRename(apply.getNewName());
            deleteRefactoringSession(apply.getSessionId());
            return refactoringResult;
        } catch (InvocationTargetException | InterruptedException | AssertionFailedException e) {
            LOG.error(e.getMessage(), e);
            return DtoConverter.toRefactoringResultDto(org.eclipse.ltk.core.refactoring.RefactoringStatus.createFatalErrorStatus(e.getMessage()));
        }
    }
    throw new RefactoringException("There is no RenameLinkedModeRefactoringSession.");
}
Also used : RefactoringResult(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) MoveRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession) RenameLinkedModeRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession) ReorgRefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession) RefactoringSession(org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession) RenameRefactoringSession(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession) AssertionFailedException(org.eclipse.core.runtime.AssertionFailedException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with AssertionFailedException

use of org.eclipse.core.runtime.AssertionFailedException in project che by eclipse.

the class TextEditChangePreviewViewer method setInput.

//	public void createControl(Composite parent) {
//		fViewer = new ComparePreviewer(parent);
//	}
//
//	public Control getControl() {
//		return fViewer;
//	}
public ChangePreview setInput(ChangePreviewViewerInput input) {
    try {
        Change change = input.getChange();
        if (input instanceof TextEditBasedChangeInput) {
            TextEditBasedChangeInput extended = (TextEditBasedChangeInput) input;
            if (extended.group != null && extended.surroundingLines >= 0) {
                TextEditBasedChangeGroup group = extended.group;
                TextEditBasedChange editChange = group.getTextEditChange();
                //					setInput(editChange, editChange.getCurrentContent(group.getRegion(), true, 2, new NullProgressMonitor()),
                //							 editChange.getPreviewContent(new TextEditBasedChangeGroup[]{group}, group.getRegion(), true, 2,
                //														  new NullProgressMonitor()),
                //							 editChange.getTextType());
                ChangePreview preview = DtoFactory.newDto(ChangePreview.class);
                preview.setFileName(getFileName(editChange));
                preview.setOldContent(editChange.getCurrentContent(group.getRegion(), true, 2, new NullProgressMonitor()));
                preview.setNewContent(editChange.getPreviewContent(new TextEditBasedChangeGroup[] { group }, group.getRegion(), true, 2, new NullProgressMonitor()));
                return preview;
            } else if (extended.groups != null && extended.groups.length > 0 && extended.range != null) {
                TextEditBasedChange editChange = extended.groups[0].getTextEditChange();
                TextEditBasedChangeGroup[] groups = extended.groups;
                //					if (extended.groupCategory != null) {
                //
                //					}
                //					setInput(editChange, editChange.getCurrentContent(extended.range, true, 0, new NullProgressMonitor()),
                //							 editChange.getPreviewContent(groups, extended.range, true, 0, new NullProgressMonitor()),
                //							 editChange.getTextType());
                ChangePreview preview = DtoFactory.newDto(ChangePreview.class);
                preview.setFileName(getFileName(editChange));
                preview.setOldContent(editChange.getCurrentContent(extended.range, true, 0, new NullProgressMonitor()));
                preview.setNewContent(editChange.getPreviewContent(groups, extended.range, true, 0, new NullProgressMonitor()));
                return preview;
            }
        } else if (change instanceof TextEditBasedChange) {
            TextEditBasedChange editChange = (TextEditBasedChange) change;
            //				setInput(editChange, editChange.getCurrentContent(new NullProgressMonitor()),
            //						 editChange.getPreviewContent(new NullProgressMonitor()), editChange.getTextType());
            ChangePreview preview = DtoFactory.newDto(ChangePreview.class);
            preview.setFileName(getFileName(editChange));
            preview.setOldContent(editChange.getCurrentContent(new NullProgressMonitor()));
            preview.setNewContent(editChange.getPreviewContent(new NullProgressMonitor()));
            return preview;
        } else {
            //				fViewer.setInput(null);
            return null;
        }
    } catch (CoreException | AssertionFailedException e) {
        JavaPlugin.log(e);
        //			fViewer.setInput(null);
        return null;
    }
    //		}
    return null;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ChangePreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangePreview) TextEditBasedChange(org.eclipse.ltk.core.refactoring.TextEditBasedChange) TextEditBasedChange(org.eclipse.ltk.core.refactoring.TextEditBasedChange) Change(org.eclipse.ltk.core.refactoring.Change) AssertionFailedException(org.eclipse.core.runtime.AssertionFailedException) TextEditBasedChangeGroup(org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup)

Example 3 with AssertionFailedException

use of org.eclipse.core.runtime.AssertionFailedException in project tdi-studio-se by Talend.

the class PaletteItemHelper method getRootPaletteItem.

/**
     * DOC nrousseau Comment method "getRootPaletteItem".
     * 
     * @param valueOf
     * @param paletteItems
     * @return
     */
private static IPaletteItem getRootPaletteItem(ComponentCategory category, List<IPaletteItem> paletteItems) {
    for (IPaletteItem paletteItem : paletteItems) {
        if (paletteItem.getPaletteType() == category) {
            return paletteItem;
        }
    }
    try {
        IPaletteItem rootPaletteItem = new RootPaletteItem(category);
        paletteItems.add(rootPaletteItem);
        return rootPaletteItem;
    } catch (AssertionFailedException e) {
        // if go here,means can not get the paletteItem for the componentCatgory,just return null
        return null;
    }
}
Also used : IPaletteItem(org.talend.core.ui.component.preference.provider.IPaletteItem) AssertionFailedException(org.eclipse.core.runtime.AssertionFailedException)

Aggregations

AssertionFailedException (org.eclipse.core.runtime.AssertionFailedException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ChangePreview (org.eclipse.che.ide.ext.java.shared.dto.refactoring.ChangePreview)1 RefactoringResult (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringResult)1 RenameRefactoringSession (org.eclipse.che.ide.ext.java.shared.dto.refactoring.RenameRefactoringSession)1 MoveRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.MoveRefactoringSession)1 RefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.RefactoringSession)1 RenameLinkedModeRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.RenameLinkedModeRefactoringSession)1 ReorgRefactoringSession (org.eclipse.che.plugin.java.server.refactoring.session.ReorgRefactoringSession)1 CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Change (org.eclipse.ltk.core.refactoring.Change)1 TextEditBasedChange (org.eclipse.ltk.core.refactoring.TextEditBasedChange)1 TextEditBasedChangeGroup (org.eclipse.ltk.core.refactoring.TextEditBasedChangeGroup)1 IPaletteItem (org.talend.core.ui.component.preference.provider.IPaletteItem)1