public int compare(Viewer viewer, Object e1, Object e2) { int r1= ((RefactoringStatusEntry)e1).getSeverity(); int r2= ((RefactoringStatusEntry)e2).getSeverity(); if (r1 < r2) return 1; if (r2 < r1) return -1; return 0; }
/** * Adds the given <code>RefactoringStatusEntry</code>. The severity of this * status is set to the maximum of <code>fSeverity</code> and the severity of * the entry. * * @param entry the <code>RefactoringStatusEntry</code> to be added */ public void addEntry(RefactoringStatusEntry entry) { Assert.isNotNull(entry); fEntries.add(entry); fSeverity= Math.max(fSeverity, entry.getSeverity()); }
/** * Adds the given <code>RefactoringStatusEntry</code>. The severity of this * status is set to the maximum of <code>fSeverity</code> and the severity of * the entry. * * @param entry the <code>RefactoringStatusEntry</code> to be added */ public void addEntry(RefactoringStatusEntry entry) { Assert.isNotNull(entry); fEntries.add(entry); fSeverity= Math.max(fSeverity, entry.getSeverity()); }
/** * Adds the given <code>RefactoringStatusEntry</code>. The severity of this * status is set to the maximum of <code>fSeverity</code> and the severity of * the entry. * * @param entry the <code>RefactoringStatusEntry</code> to be added */ public void addEntry(RefactoringStatusEntry entry) { Assert.isNotNull(entry); fEntries.add(entry); fSeverity= Math.max(fSeverity, entry.getSeverity()); }
/** * Returns the entry with the highest severity. If there is more than one * entry that matches the first one found in the list of entries is returned. * * @return the entry with the highest severity or <code>null</code> if no * entries are present * * @since 3.1 */ public RefactoringStatusEntry getEntryWithHighestSeverity() { if (fEntries == null || fEntries.size() == 0) return null; RefactoringStatusEntry result= fEntries.get(0); for (int i= 1; i < fEntries.size(); i++) { RefactoringStatusEntry entry= fEntries.get(i); if (result.getSeverity() < entry.getSeverity()) result= entry; } return result; }
/** * Returns the entry with the highest severity. If there is more than one * entry that matches the first one found in the list of entries is returned. * * @return the entry with the highest severity or <code>null</code> if no * entries are present * * @since 3.1 */ public RefactoringStatusEntry getEntryWithHighestSeverity() { if (fEntries == null || fEntries.size() == 0) return null; RefactoringStatusEntry result= (RefactoringStatusEntry)fEntries.get(0); for (int i= 1; i < fEntries.size(); i++) { RefactoringStatusEntry entry= (RefactoringStatusEntry)fEntries.get(i); if (result.getSeverity() < entry.getSeverity()) result= entry; } return result; }
/** * Returns the entry with the highest severity. If there is more than one * entry that matches the first one found in the list of entries is returned. * * @return the entry with the highest severity or <code>null</code> if no * entries are present * * @since 3.1 */ public RefactoringStatusEntry getEntryWithHighestSeverity() { if (fEntries == null || fEntries.size() == 0) return null; RefactoringStatusEntry result= fEntries.get(0); for (int i= 1; i < fEntries.size(); i++) { RefactoringStatusEntry entry= fEntries.get(i); if (result.getSeverity() < entry.getSeverity()) result= entry; } return result; }
/** * Returns the first entry which severity is equal or greater than the * given severity. If more than one entry exists that matches the * criteria the first one is returned. Returns <code>null</code> if no * entry matches. * * @param severity the severity to search for. Must be one of <code>FATAL * </code>, <code>ERROR</code>, <code>WARNING</code> or <code>INFO</code> * @return the entry that matches the search criteria */ public RefactoringStatusEntry getEntryMatchingSeverity(int severity) { Assert.isTrue(severity >= OK && severity <= FATAL); if (severity > fSeverity) return null; Iterator<RefactoringStatusEntry> iter= fEntries.iterator(); while (iter.hasNext()) { RefactoringStatusEntry entry= iter.next(); if (entry.getSeverity() >= severity) return entry; } return null; }
/** * Returns the first entry which severity is equal or greater than the * given severity. If more than one entry exists that matches the * criteria the first one is returned. Returns <code>null</code> if no * entry matches. * * @param severity the severity to search for. Must be one of <code>FATAL * </code>, <code>ERROR</code>, <code>WARNING</code> or <code>INFO</code> * @return the entry that matches the search criteria */ public RefactoringStatusEntry getEntryMatchingSeverity(int severity) { Assert.isTrue(severity >= OK && severity <= FATAL); if (severity > fSeverity) return null; Iterator iter= fEntries.iterator(); while (iter.hasNext()) { RefactoringStatusEntry entry= (RefactoringStatusEntry)iter.next(); if (entry.getSeverity() >= severity) return entry; } return null; }
/** * Returns the first entry which severity is equal or greater than the * given severity. If more than one entry exists that matches the * criteria the first one is returned. Returns <code>null</code> if no * entry matches. * * @param severity the severity to search for. Must be one of <code>FATAL * </code>, <code>ERROR</code>, <code>WARNING</code> or <code>INFO</code> * @return the entry that matches the search criteria */ public RefactoringStatusEntry getEntryMatchingSeverity(int severity) { Assert.isTrue(severity >= OK && severity <= FATAL); if (severity > fSeverity) return null; Iterator<RefactoringStatusEntry> iter= fEntries.iterator(); while (iter.hasNext()) { RefactoringStatusEntry entry= iter.next(); if (entry.getSeverity() >= severity) return entry; } return null; }
switch (getSeverity()) { case RefactoringStatus.OK: statusSeverity= IStatus.OK;
switch (getSeverity()) { case RefactoringStatus.OK: statusSeverity= IStatus.OK;
switch (getSeverity()) { case RefactoringStatus.OK: statusSeverity= IStatus.OK;
private boolean validChanges(CompositeChange change) { RefactoringStatus result= new RefactoringStatus(); List files= new ArrayList(); try { findFilesToBeModified(change, files); } catch (JavaModelException e) { JavaPlugin.log(e); return false; } result.merge(Checks.validateModifiesFiles((IFile[])files.toArray(new IFile[files.size()]), JavaPlugin.getActiveWorkbenchShell().getShell())); if (result.hasFatalError()) { RefactoringStatusEntry[] entries= result.getEntries(); IStatus status; if (entries.length > 1) { status= new MultiStatus(JavaUI.ID_PLUGIN, 0, result.getMessageMatchingSeverity(RefactoringStatus.ERROR), null); for (int i= 0; i < entries.length; i++) { ((MultiStatus)status).add(new Status(entries[i].getSeverity(), JavaUI.ID_PLUGIN, 0, entries[i].getMessage(), null)); } } else { RefactoringStatusEntry entry= entries[0]; status= new Status(entry.getSeverity(), JavaUI.ID_PLUGIN, 0, entry.getMessage(), null); } ErrorDialog.openError(JavaPlugin.getActiveWorkbenchShell().getShell(), CorrectionMessages.CorrectionMarkerResolutionGenerator__multiFixErrorDialog_Titel, CorrectionMessages.CorrectionMarkerResolutionGenerator_multiFixErrorDialog_description, status); return false; } return true; }
/** * {@inheritDoc} */ public IWizardPage getNextPage() { if (fChange != null && fRefactoring != null && !fStatus.hasFatalError()) { final RefactoringHistoryWizard result= getRefactoringHistoryWizard(); if (result != null) { final RefactoringStatus status= result.performPreviewChange(fChange, fRefactoring); if (!status.isOK()) { final RefactoringStatusEntry entry= status.getEntryWithHighestSeverity(); if (entry != null) { if (entry.getSeverity() == RefactoringStatus.INFO && entry.getCode() == RefactoringHistoryWizard.STATUS_CODE_INTERRUPTED) return this; final IErrorWizardPage page= result.getErrorPage(); if (page instanceof RefactoringHistoryErrorPage) { final RefactoringHistoryErrorPage extended= (RefactoringHistoryErrorPage) page; extended.setStatus(status); extended.setNextPageDisabled(fNextPageDisabled); extended.setTitle(RefactoringUIMessages.RefactoringHistoryPreviewPage_apply_error_title); extended.setDescription(RefactoringUIMessages.RefactoringHistoryPreviewPage_apply_error); return extended; } } } } } return getWizard().getNextPage(this); }
protected void updateDecoration(ControlDecoration decoration, RefactoringStatus status) { RefactoringStatusEntry highestSeverity= status.getEntryWithHighestSeverity(); if (highestSeverity != null) { Image newImage= null; FieldDecorationRegistry registry= FieldDecorationRegistry.getDefault(); switch (highestSeverity.getSeverity()) { case RefactoringStatus.INFO: newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage(); break; case RefactoringStatus.WARNING: newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage(); break; case RefactoringStatus.FATAL: case RefactoringStatus.ERROR: newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage(); } decoration.setDescriptionText(highestSeverity.getMessage()); decoration.setImage(newImage); decoration.show(); } else { decoration.setDescriptionText(null); decoration.hide(); } }
protected void updateDecoration(ControlDecoration decoration, RefactoringStatus status) { RefactoringStatusEntry highestSeverity= status.getEntryWithHighestSeverity(); if (highestSeverity != null) { Image newImage= null; FieldDecorationRegistry registry= FieldDecorationRegistry.getDefault(); switch (highestSeverity.getSeverity()) { case RefactoringStatus.INFO: newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage(); break; case RefactoringStatus.WARNING: newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage(); break; case RefactoringStatus.FATAL: case RefactoringStatus.ERROR: newImage= registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage(); } decoration.setDescriptionText(highestSeverity.getMessage()); decoration.setImage(newImage); decoration.show(); } else { decoration.setDescriptionText(null); decoration.hide(); } }
if (!status.isOK()) { final RefactoringStatusEntry entry= status.getEntryWithHighestSeverity(); if (entry.getSeverity() == RefactoringStatus.INFO && entry.getCode() == RefactoringHistoryWizard.STATUS_CODE_INTERRUPTED) return false; fErrorPage.setStatus(status);
protected RefactoringStatus validateRefactoring() { RefactoringStatus status= new RefactoringStatus(); setErrorMessage(null); setMessage(null); setPageComplete(true); status.merge(validateTopLevel()); status.merge(validateClassName()); status.merge(validateParameterName()); status.merge(validateFields()); RefactoringStatusEntry highestSeverity= status.getEntryWithHighestSeverity(); if (highestSeverity != null) { switch (highestSeverity.getSeverity()) { case RefactoringStatus.ERROR: case RefactoringStatus.FATAL: setErrorMessage(highestSeverity.getMessage()); setPageComplete(false); break; case RefactoringStatus.WARNING: setMessage(highestSeverity.getMessage(), IMessageProvider.WARNING); break; case RefactoringStatus.INFO: setMessage(highestSeverity.getMessage(), IMessageProvider.INFORMATION); break; } } return status; }
protected RefactoringStatus validateRefactoring() { RefactoringStatus status= new RefactoringStatus(); setErrorMessage(null); setMessage(null); setPageComplete(true); status.merge(validateTopLevel()); status.merge(validateClassName()); status.merge(validateParameterName()); status.merge(validateFields()); RefactoringStatusEntry highestSeverity= status.getEntryWithHighestSeverity(); if (highestSeverity != null) { switch (highestSeverity.getSeverity()) { case RefactoringStatus.ERROR: case RefactoringStatus.FATAL: setErrorMessage(highestSeverity.getMessage()); setPageComplete(false); break; case RefactoringStatus.WARNING: setMessage(highestSeverity.getMessage(), IMessageProvider.WARNING); break; case RefactoringStatus.INFO: setMessage(highestSeverity.getMessage(), IMessageProvider.INFORMATION); break; } } return status; }