Java Code Examples for org.eclipse.jdt.internal.ui.JavaPlugin#logErrorMessage()

The following examples show how to use org.eclipse.jdt.internal.ui.JavaPlugin#logErrorMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfileStore.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static Element createProfileElement(Profile profile, Document document, IProfileVersioner profileVersioner) {
	final Element element= document.createElement(XML_NODE_PROFILE);
	element.setAttribute(XML_ATTRIBUTE_NAME, profile.getName());
	element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion()));
	element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind());

	final Iterator<String> keyIter= profile.getSettings().keySet().iterator();

	while (keyIter.hasNext()) {
		final String key= keyIter.next();
		final String value= profile.getSettings().get(key);
		if (value != null) {
			final Element setting= document.createElement(XML_NODE_SETTING);
			setting.setAttribute(XML_ATTRIBUTE_ID, key);
			setting.setAttribute(XML_ATTRIBUTE_VALUE, value);
			element.appendChild(setting);
		} else {
			JavaPlugin.logErrorMessage("ProfileStore: Profile does not contain value for key " + key); //$NON-NLS-1$
		}
	}
	return element;
}
 
Example 2
Source File: ContributedJavadocWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static ContributedJavadocWizardPage[] getContributedPages(JavadocOptionsManager store) {
	ArrayList<ContributedJavadocWizardPage> pages= new ArrayList<ContributedJavadocWizardPage>();

	IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(JavaUI.ID_PLUGIN, ATT_EXTENSION);
	for (int i = 0; i < elements.length; i++) {
		IConfigurationElement curr= elements[i];
		String id= curr.getAttribute(ATT_ID);
		String description= curr.getAttribute(ATT_DESCRIPTION);
		String pageClassName= curr.getAttribute(ATT_PAGE_CLASS);

		if (id == null || description == null || pageClassName == null) {
			JavaPlugin.logErrorMessage("Invalid extension " + curr.toString()); //$NON-NLS-1$
			continue;
		}
		pages.add(new ContributedJavadocWizardPage(elements[i], store));
	}
	return pages.toArray(new ContributedJavadocWizardPage[pages.size()]);
}
 
Example 3
Source File: SuperListener.java    From lapse-plus with GNU General Public License v3.0 6 votes vote down vote up
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
	
	if (part != this.view.fEditor && part instanceof ITextEditor && (LapseView.getJavaInput((ITextEditor) part) != null)) 
	{
		try {
			if(LapseView.TRACE) {
			    System.out.println("In selectionChanged: setting the input");
			}

			this.view.setInput((ITextEditor) part);
			
			if(this.view.fEditor == null) {
				throw new RuntimeException("Couldn't set the editor properly");
			}
			
		} catch (CoreException e) {
			JavaPlugin.logErrorMessage("Caught exception: " + e.toString());
			return;
		}				
	}
	
}
 
Example 4
Source File: RenameTypeParameterProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public RefactoringStatus checkNewElementName(String name) throws CoreException {
	Assert.isNotNull(name);
	RefactoringStatus result= Checks.checkTypeParameterName(name, fTypeParameter);
	if (Checks.startsWithLowerCase(name))
		result.addWarning(RefactoringCoreMessages.RenameTypeParameterRefactoring_should_start_lowercase);
	if (Checks.isAlreadyNamed(fTypeParameter, name))
		result.addFatalError(RefactoringCoreMessages.RenameTypeParameterRefactoring_another_name);

	IMember member= fTypeParameter.getDeclaringMember();
	if (member instanceof IType) {
		IType type= (IType) member;
		if (type.getTypeParameter(name).exists())
			result.addFatalError(RefactoringCoreMessages.RenameTypeParameterRefactoring_class_type_parameter_already_defined);
	} else if (member instanceof IMethod) {
		IMethod method= (IMethod) member;
		if (method.getTypeParameter(name).exists())
			result.addFatalError(RefactoringCoreMessages.RenameTypeParameterRefactoring_method_type_parameter_already_defined);
	} else {
		JavaPlugin.logErrorMessage("Unexpected sub-type of IMember: " + member.getClass().getName()); //$NON-NLS-1$
		Assert.isTrue(false);
	}
	return result;
}
 
Example 5
Source File: ImagesOnFileSystemRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private File getTempDir() {
	try {
		File imageDir= JavaPlugin.getDefault().getStateLocation().append(IMAGE_DIR).toFile();
		if (imageDir.exists()) {
			// has not been deleted on previous shutdown
			delete(imageDir);
		}
		if (!imageDir.exists()) {
			imageDir.mkdir();
		}
		if (!imageDir.isDirectory()) {
			JavaPlugin.logErrorMessage("Failed to create image directory " + imageDir.toString()); //$NON-NLS-1$
			return null;
		}
		return imageDir;
	} catch (IllegalStateException e) {
		// no state location
		return null;
	}
}
 
Example 6
Source File: LapseView.java    From lapse-plus with GNU General Public License v3.0 6 votes vote down vote up
private CompilationUnit internalSetInput(IOpenable input) throws CoreException {
	IBuffer buffer = input.getBuffer();
	if (buffer == null) {
		JavaPlugin.logErrorMessage("Input has no buffer"); //$NON-NLS-1$
	}
	if (input instanceof ICompilationUnit) {
		fParser.setSource((ICompilationUnit) input);
	} else {
		fParser.setSource((IClassFile) input);
	}

	try {
		CompilationUnit root = (CompilationUnit) fParser.createAST(null);
		log("Recomputed the AST for " + buffer.getUnderlyingResource().getName());
						
		if (root == null) {
			JavaPlugin.logErrorMessage("Could not create AST"); //$NON-NLS-1$
		}

		return root;
	} catch (RuntimeException e) {
		JavaPlugin.logErrorMessage("Could not create AST:\n" + e.getMessage()); //$NON-NLS-1$
		return null;
	}
}
 
Example 7
Source File: LapseView.java    From lapse-plus with GNU General Public License v3.0 5 votes vote down vote up
void toggleViewer() {
	if(fContentProvider == null) {
		JavaPlugin.logErrorMessage("In switchViewer with null");
		return;
	}
	// do the switch
	fContentProvider = fContentProvider.switchType();
	fViewer.setContentProvider(fContentProvider);
	
	//System.out.println("Switched the viewer type to " + fContentProvider);
	refresh();
}
 
Example 8
Source File: ChangeTypeRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Do the actual work of computing allowable types. Invoked by the wizard when
 * "compute" button is pressed
 * @param pm the progress monitor
 * @return the valid types
 */
public Collection<ITypeBinding> computeValidTypes(IProgressMonitor pm) {

	pm.beginTask(RefactoringCoreMessages.ChangeTypeRefactoring_checking_preconditions, 100);

	try {
		fCv= findConstraintVariableForSelectedNode(new SubProgressMonitor(pm, 3));
		if (DEBUG) System.out.println("selected CV: " + fCv +  //$NON-NLS-1$
									  " (" + fCv.getClass().getName() +  //$NON-NLS-1$
									  ")");  //$NON-NLS-1$

		if (pm.isCanceled())
			throw new OperationCanceledException();
		fRelevantVars= findRelevantConstraintVars(fCv, new SubProgressMonitor(pm, 50));

		if (DEBUG)
			printCollection("relevant vars:", fRelevantVars); //$NON-NLS-1$

		if (pm.isCanceled())
			throw new OperationCanceledException();
		fRelevantConstraints= findRelevantConstraints(fRelevantVars, new SubProgressMonitor(pm, 30));

		if (pm.isCanceled())
			throw new OperationCanceledException();
		fValidTypes.addAll(computeValidTypes(fSelectionTypeBinding, fRelevantVars,
											 fRelevantConstraints, new SubProgressMonitor(pm, 20)));

		if (DEBUG)
			printCollection("valid types:", getValidTypeNames()); //$NON-NLS-1$
	} catch (CoreException e) {
		JavaPlugin.logErrorMessage("Error occurred during computation of valid types: " + e.toString()); //$NON-NLS-1$
		fValidTypes.clear(); // error occurred during computation of valid types
	}

	pm.done();

	return fValidTypes;
}
 
Example 9
Source File: BufferedDocumentScanner.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public final int read() {

		if (fOffset == fBufferLength) {
			int end= fBufferOffset + fBufferLength;
			if (end == fDocument.getLength() || end == fRangeOffset + fRangeLength)
				return EOF;
			else {
				updateBuffer(fBufferOffset + fBufferLength);
				fOffset= 0;
			}
		}

		try {
			return fBuffer[fOffset++];
		} catch (ArrayIndexOutOfBoundsException ex) {
			StringBuffer buf= new StringBuffer();
			buf.append("Detailed state of 'BufferedDocumentScanner:'"); //$NON-NLS-1$
			buf.append("\n\tfOffset= "); //$NON-NLS-1$
			buf.append(fOffset);
			buf.append("\n\tfBufferOffset= "); //$NON-NLS-1$
			buf.append(fBufferOffset);
			buf.append("\n\tfBufferLength= "); //$NON-NLS-1$
			buf.append(fBufferLength);
			buf.append("\n\tfRangeOffset= "); //$NON-NLS-1$
			buf.append(fRangeOffset);
			buf.append("\n\tfRangeLength= "); //$NON-NLS-1$
			buf.append(fRangeLength);
			JavaPlugin.logErrorMessage(buf.toString());
			throw ex;
		}
	}
 
Example 10
Source File: RenameTypeParameterProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the necessary changes for the renaming of the type parameter.
 *
 * @param monitor
 *            the progress monitor to display progress
 * @return the status of the operation
 * @throws CoreException
 *             if the change could not be generated
 */
private RefactoringStatus createRenameChanges(IProgressMonitor monitor) throws CoreException {
	Assert.isNotNull(monitor);
	RefactoringStatus status= new RefactoringStatus();
	try {
		monitor.beginTask(RefactoringCoreMessages.RenameTypeParameterRefactoring_searching, 2);
		ICompilationUnit cu= fTypeParameter.getDeclaringMember().getCompilationUnit();
		CompilationUnit root= RefactoringASTParser.parseWithASTProvider(cu, true, null);
		CompilationUnitRewrite rewrite= new CompilationUnitRewrite(cu, root);
		IMember member= fTypeParameter.getDeclaringMember();
		ASTNode declaration= null;
		if (member instanceof IMethod) {
			declaration= ASTNodeSearchUtil.getMethodDeclarationNode((IMethod) member, root);
		} else if (member instanceof IType) {
			declaration= ASTNodeSearchUtil.getAbstractTypeDeclarationNode((IType) member, root);
		} else {
			JavaPlugin.logErrorMessage("Unexpected sub-type of IMember: " + member.getClass().getName()); //$NON-NLS-1$
			Assert.isTrue(false);
		}
		monitor.worked(1);
		RenameTypeParameterVisitor visitor= new RenameTypeParameterVisitor(rewrite, fTypeParameter.getNameRange(), status);
		if (declaration != null)
			declaration.accept(visitor);
		fChange= visitor.getResult();
	} finally {
		monitor.done();
	}
	return status;
}
 
Example 11
Source File: ProvenanceContentProvider.java    From lapse-plus with GNU General Public License v3.0 5 votes vote down vote up
public void addElement(HistoryDefinitionLocation defLoc) {
	if(element == null) {
		setElement(defLoc);
	} else 
	if(defLoc != element){
		JavaPlugin.logErrorMessage("Error in addElement(...): calling addElement with " + defLoc + 
				" old value: " + element);
	} else {
		// just setting it twice, it's benign, I guess
	}
}
 
Example 12
Source File: RenamePackageProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void rewriteImports(TextChangeManager changeManager, IProgressMonitor pm) throws CoreException {
	for (Iterator<Entry<ICompilationUnit, ImportChange>> iter= fImportChanges.entrySet().iterator(); iter.hasNext();) {
		Entry<ICompilationUnit, ImportChange> entry= iter.next();
		ICompilationUnit cu= entry.getKey();
		ImportChange importChange= entry.getValue();

		ImportRewrite importRewrite= StubUtility.createImportRewrite(cu, true);
		importRewrite.setFilterImplicitImports(false);
		for (Iterator<String> iterator= importChange.fStaticToRemove.iterator(); iterator.hasNext();) {
			importRewrite.removeStaticImport(iterator.next());
		}
		for (Iterator<String> iterator= importChange.fToRemove.iterator(); iterator.hasNext();) {
			importRewrite.removeImport(iterator.next());
		}
		for (Iterator<String[]> iterator= importChange.fStaticToAdd.iterator(); iterator.hasNext();) {
			String[] toAdd= iterator.next();
			importRewrite.addStaticImport(toAdd[0], toAdd[1], true);
		}
		for (Iterator<String> iterator= importChange.fToAdd.iterator(); iterator.hasNext();) {
			importRewrite.addImport(iterator.next());
		}

		if (importRewrite.hasRecordedChanges()) {
			TextEdit importEdit= importRewrite.rewriteImports(pm);
			String name= RefactoringCoreMessages.RenamePackageRefactoring_update_imports;
			try {
				TextChangeCompatibility.addTextEdit(changeManager.get(cu), name, importEdit);
			} catch (MalformedTreeException e) {
				JavaPlugin.logErrorMessage("MalformedTreeException while processing cu " + cu); //$NON-NLS-1$
				throw e;
			}
		}
	}
}
 
Example 13
Source File: CleanUpRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param element the configuration element
 */
public CleanUpTabPageDescriptor(IConfigurationElement element) {
	fElement= element;
	fName= element.getAttribute(ATTRIBUTE_ID_NAME);
	String kind= fElement.getAttribute(ATTRIBUTE_NAME_KIND);
	fKind= getCleanUpKind(kind);
	if (fKind == -1)
		JavaPlugin.logErrorMessage(Messages.format(FixMessages.CleanUpRegistry_WrongKindForConfigurationUI_error, new String[] { fName, element.getContributor().getName(),
				kind }));
}
 
Example 14
Source File: CleanUpRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public CleanUpInitializerDescriptor(IConfigurationElement element) {
	fElement= element;
	String kind= fElement.getAttribute(ATTRIBUTE_NAME_KIND);
	fKind= getCleanUpKind(kind);
	if (fKind == -1)
		JavaPlugin.logErrorMessage(Messages.format(FixMessages.CleanUpRegistry_UnknownInitializerKind_errorMessage, new String[] { element.getContributor().getName(), kind }));
}
 
Example 15
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new <code>CustomFiltersActionGroup</code>.
 *
 * @param ownerId	the id of this action group's owner
 * @param viewer	the viewer to be filtered
 */
public CustomFiltersActionGroup(String ownerId, StructuredViewer viewer) {
	Assert.isNotNull(ownerId);
	Assert.isNotNull(viewer);
	fTargetId= ownerId;
	fViewer= viewer;
	fPatternFilter= new NamePatternFilter();

	fLRUFilterIdsStack= new Stack<String>();

	fUserDefinedPatterns= new String[0];
	fUserDefinedPatternsEnabled= false;
	fPreviousPatterns= new String[0];

	fFilterItems= new HashMap<String, FilterItem>();
	FilterDescriptor[] filterDescriptors= FilterDescriptor.getFilterDescriptors(fTargetId);
	for (int i= 0; i < filterDescriptors.length; i++) {
		FilterItem item= new FilterItem(filterDescriptors[i]);
		Object existing= fFilterItems.put(item.id, item);
		if (existing != null) {
			JavaPlugin.logErrorMessage("WARNING: Duplicate id for extension-point \"org.eclipse.jdt.ui.javaElementFilters\" in " + ownerId); //$NON-NLS-1$
		}
	}

	initializeWithViewDefaults();

	updateViewerFilters();
}
 
Example 16
Source File: FocusDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private ImageData getImageData(ImageDescriptor descriptor) {
	ImageData data= descriptor.getImageData(); // see bug 51965: getImageData can return null
	if (data == null) {
		data= DEFAULT_IMAGE_DATA;
		JavaPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
	}
	return data;
}
 
Example 17
Source File: JavaElementImageDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private ImageData getImageData(ImageDescriptor descriptor) {
	ImageData data= descriptor.getImageData(); // see bug 51965: getImageData can return null
	if (data == null) {
		data= DEFAULT_IMAGE_DATA;
		JavaPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
	}
	return data;
}
 
Example 18
Source File: OpenJavaSearchPageAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void run(IAction action) {
	if (fWindow == null || fWindow.getActivePage() == null) {
		beep();
		JavaPlugin.logErrorMessage("Could not open the search dialog - for some reason the window handle was null"); //$NON-NLS-1$
		return;
	}
	NewSearchUI.openSearchDialog(fWindow, JAVA_SEARCH_PAGE_ID);
}
 
Example 19
Source File: ProvenanceContentProvider.java    From lapse-plus with GNU General Public License v3.0 5 votes vote down vote up
private void addElementsUnder(HistoryDefinitionLocation currentInput, ArrayList<HistoryDefinitionLocation> result) {
	if(currentInput == null) {
		JavaPlugin.logErrorMessage("Called addElementsUnder with currentInput==null");
		return;
	} else {
		result.add(currentInput);		// the only place where elements are added
		if ( currentInput.hasChildren() ) {
			for (Iterator iter = currentInput.getChildren().iterator(); iter.hasNext();) {
				HistoryDefinitionLocation element = (HistoryDefinitionLocation) iter.next();
				addElementsUnder(element, result);
			}
		}
	}
}
 
Example 20
Source File: CleanUpRegistry.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private synchronized void ensureCleanUpsRegistered() {
	if (fCleanUpDescriptors != null)
		return;


	final ArrayList<CleanUpDescriptor> descriptors= new ArrayList<CleanUpDescriptor>();

	IExtensionPoint point= Platform.getExtensionRegistry().getExtensionPoint(JavaPlugin.getPluginId(), EXTENSION_POINT_NAME);
	IConfigurationElement[] elements= point.getConfigurationElements();
	for (int i= 0; i < elements.length; i++) {
		IConfigurationElement element= elements[i];

		if (CLEAN_UP_CONFIGURATION_ELEMENT_NAME.equals(element.getName())) {
			descriptors.add(new CleanUpDescriptor(element));
		}
	}


	// Make sure we filter those who fail or misbehave
	for (int i= 0; i < descriptors.size(); i++) {
		final CleanUpDescriptor cleanUpDescriptor= descriptors.get(i);
		final boolean disable[]= new boolean[1];
		ISafeRunnable runnable= new SafeRunnable() {
			
			public void run() throws Exception {
				ICleanUp cleanUp= cleanUpDescriptor.createCleanUp();
				if (cleanUp == null)
					disable[0]= true;
				else {
					cleanUp.setOptions(new CleanUpOptions());
					String[] enbledSteps= cleanUp.getStepDescriptions();
					if (enbledSteps != null && enbledSteps.length > 0) {
						JavaPlugin.logErrorMessage(
								Messages.format(FixMessages.CleanUpRegistry_cleanUpAlwaysEnabled_error, new String[] { cleanUpDescriptor.getId(),
								cleanUpDescriptor.fElement.getContributor().getName() }));
						disable[0]= true;
					}
				}
			}
			@Override
			public void handleException(Throwable t) {
				disable[0]= true;
				String message= Messages.format(FixMessages.CleanUpRegistry_cleanUpCreation_error, new String[] { cleanUpDescriptor.getId(),
						cleanUpDescriptor.fElement.getContributor().getName() });
				IStatus status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, message, t);
				JavaPlugin.log(status);
			}

		};
		SafeRunner.run(runnable);
		if (disable[0])
			descriptors.remove(i--);
	}

	fCleanUpDescriptors= descriptors.toArray(new CleanUpDescriptor[descriptors.size()]);
	sort(fCleanUpDescriptors);

}