Java Code Examples for org.eclipse.jdt.internal.ui.JavaPlugin#log()
The following examples show how to use
org.eclipse.jdt.internal.ui.JavaPlugin#log() .
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: DestinationContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public Object[] getChildren(Object element) { try { if (element instanceof IJavaModel) { return concatenate(getJavaProjects((IJavaModel)element), getOpenNonJavaProjects((IJavaModel)element)); } else { Object[] children= doGetChildren(element); ArrayList<Object> result= new ArrayList<Object>(children.length); for (int i= 0; i < children.length; i++) { IReorgDestination destination= ReorgDestinationFactory.createDestination(children[i]); if (fValidator.canElementBeDestination(destination) || fValidator.canChildrenBeDestinations(destination)) result.add(children[i]); } return result.toArray(); } } catch (JavaModelException e) { JavaPlugin.log(e); return new Object[0]; } }
Example 2
Source File: DialogPackageExplorer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Set the selection and focus to the list of elements * @param elements the object to be selected and displayed */ public void setSelection(final List<?> elements) { if (elements == null || elements.size() == 0) return; try { ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) throws CoreException { fPackageViewer.refresh(); IStructuredSelection selection= new StructuredSelection(elements); fPackageViewer.setSelection(selection, true); fPackageViewer.getTree().setFocus(); if (elements.size() == 1 && elements.get(0) instanceof IJavaProject) fPackageViewer.expandToLevel(elements.get(0), 1); } }, ResourcesPlugin.getWorkspace().getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor()); } catch (CoreException e) { JavaPlugin.log(e); } }
Example 3
Source File: CodeTemplateBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public boolean performOk(boolean enabled) { boolean res= super.performOk(); if (!res) return false; if (fProject != null) { TemplatePersistenceData[] templateData= fTemplateStore.getTemplateData(); for (int i= 0; i < templateData.length; i++) { fTemplateStore.setProjectSpecific(templateData[i].getId(), enabled); } } try { fTemplateStore.save(); } catch (IOException e) { JavaPlugin.log(e); openWriteErrorDialog(); } return true; }
Example 4
Source File: FilteredTypesSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void storeDialog(IDialogSettings settings) { super.storeDialog(settings); if (! BUG_184693) { settings.put(SHOW_CONTAINER_FOR_DUPLICATES, fShowContainerForDuplicatesAction.isChecked()); } if (fFilterActionGroup != null) { XMLMemento memento= XMLMemento.createWriteRoot("workingSet"); //$NON-NLS-1$ fFilterActionGroup.saveState(memento); fFilterActionGroup.dispose(); StringWriter writer= new StringWriter(); try { memento.save(writer); settings.put(WORKINGS_SET_SETTINGS, writer.getBuffer().toString()); } catch (IOException e) { // don't do anything. Simply don't store the settings JavaPlugin.log(e); } } }
Example 5
Source File: RenameCompilationUnitProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private RefactoringStatus initialize(JavaRefactoringArguments extended) { final String handle= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT); if (handle == null) { return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT)); } final IJavaElement element= JavaRefactoringDescriptorUtil.handleToElement(extended.getProject(), handle, false); if (element == null || !element.exists() || element.getElementType() != IJavaElement.COMPILATION_UNIT) return JavaRefactoringDescriptorUtil.createInputFatalStatus(element, getProcessorName(), IJavaRefactorings.RENAME_COMPILATION_UNIT); final String name= extended.getAttribute(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME); if (name == null || name.length() == 0) return RefactoringStatus.createFatalErrorStatus(Messages.format(RefactoringCoreMessages.InitializableRefactoring_argument_not_exist, JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME)); fCu= (ICompilationUnit) element; try { computeRenameTypeRefactoring(); setNewElementName(name); } catch (CoreException exception) { JavaPlugin.log(exception); return JavaRefactoringDescriptorUtil.createInputFatalStatus(element, getProcessorName(), IJavaRefactorings.RENAME_COMPILATION_UNIT); } return new RefactoringStatus(); }
Example 6
Source File: ExternalizeStringsAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void selectionChanged(IStructuredSelection selection) { try { setEnabled(RefactoringAvailabilityTester.isExternalizeStringsAvailable(selection)); } catch (JavaModelException e) { if (JavaModelUtil.isExceptionToBeLogged(e)) JavaPlugin.log(e); setEnabled(false);//no UI - happens on selection changes } }
Example 7
Source File: EditorInputTransferDragAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void dragStart(DragSourceEvent event) { fEditorInputDatas= new ArrayList<EditorInputData>(); ISelection selection= fProvider.getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection= (IStructuredSelection) selection; for (Iterator<?> iter= structuredSelection.iterator(); iter.hasNext();) { Object element= iter.next(); IEditorInput editorInput= EditorUtility.getEditorInput(element); if (editorInput != null && editorInput.getPersistable() != null) { try { String editorId= EditorUtility.getEditorID(editorInput); // see org.eclipse.ui.internal.ide.EditorAreaDropAdapter.openNonExternalEditor(..): IEditorRegistry editorReg= PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor editorDesc= editorReg.findEditor(editorId); if (editorDesc != null && !editorDesc.isOpenExternal()) { fEditorInputDatas.add(EditorInputTransfer.createEditorInputData(editorId, editorInput)); } } catch (PartInitException e) { JavaPlugin.log(e); } } } } event.doit= fEditorInputDatas.size() > 0; }
Example 8
Source File: JavadocProjectContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public Object[] getElements(Object inputElement) { IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); try { return JavaCore.create(root).getJavaProjects(); } catch (JavaModelException e) { JavaPlugin.log(e); } return new Object[0]; }
Example 9
Source File: FindMethodExitOccurrencesAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final void run(ITextSelection ts) { ITypeRoot input= getEditorInput(fEditor); if (!ActionUtil.isProcessable(getShell(), input)) return; FindOccurrencesEngine engine= FindOccurrencesEngine.create(new MethodExitsFinder()); try { String result= engine.run(input, ts.getOffset(), ts.getLength()); if (result != null) showMessage(getShell(), fEditor, result); } catch (JavaModelException e) { JavaPlugin.log(e); } }
Example 10
Source File: BuildPathsPropertyPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean isJavaProject(IProject proj) { try { return proj.hasNature(JavaCore.NATURE_ID); } catch (CoreException e) { JavaPlugin.log(e); } return false; }
Example 11
Source File: StubUtility.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static Template getCodeTemplate(String id, IJavaProject project) { if (project == null) return JavaPlugin.getDefault().getCodeTemplateStore().findTemplateById(id); ProjectTemplateStore projectStore= new ProjectTemplateStore(project.getProject()); try { projectStore.load(); } catch (IOException e) { JavaPlugin.log(e); } return projectStore.findTemplateById(id); }
Example 12
Source File: FixedFatJarExportPage.java From sarl with Apache License 2.0 | 5 votes |
@Override public boolean hasVMArguments() { try { return fLaunchConfiguration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String) null) != null; } catch (CoreException e) { JavaPlugin.log(e); return false; } }
Example 13
Source File: JavaCompareUtilities.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
static ImageDescriptor getImageDescriptor(IMember element) { int t= element.getElementType(); if (t == IJavaElement.TYPE) { IType type= (IType) element; try { return getTypeImageDescriptor(type.isClass()); } catch (CoreException e) { JavaPlugin.log(e); return JavaPluginImages.DESC_OBJS_GHOST; } } return getImageDescriptor(t); }
Example 14
Source File: FindBreakContinueTargetOccurrencesAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public final void run(ITextSelection ts) { ITypeRoot input= getEditorInput(fEditor); if (!ActionUtil.isProcessable(getShell(), input)) return; FindOccurrencesEngine engine= FindOccurrencesEngine.create(new BreakContinueTargetFinder()); try { String result= engine.run(input, ts.getOffset(), ts.getLength()); if (result != null) showMessage(getShell(), fEditor, result); } catch (JavaModelException e) { JavaPlugin.log(e); } }
Example 15
Source File: NewModuleWizardPage.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private IPackageFragment choosePackage() { IPackageFragmentRoot root = getPackageFragmentRoot(); IJavaElement[] packages = null; try { if (root != null && root.exists()) { packages = root.getChildren(); } } catch (JavaModelException e) { JavaPlugin.log(e); } if (packages == null) { packages = new IJavaElement[0]; } ElementListSelectionDialog dialog = new ElementListSelectionDialog( getShell(), new JavaElementLabelProvider( JavaElementLabelProvider.SHOW_DEFAULT)); dialog.setIgnoreCase(false); dialog.setTitle(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_title); dialog.setMessage(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_description); dialog.setEmptyListMessage(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_empty); dialog.setElements(packages); dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { return (IPackageFragment) dialog.getFirstResult(); } return null; }
Example 16
Source File: ArchiveFileFilter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parent, Object element) { if (element instanceof IFile) { if (fExcludes != null && fExcludes.contains(element)) { return false; } return isArchivePath(((IFile)element).getFullPath(), fAllowAllArchives); } else if (element instanceof IContainer) { // IProject, IFolder if (!fRecursive) { return true; } // ignore closed projects if (element instanceof IProject && !((IProject)element).isOpen()) return false; try { IResource[] resources= ((IContainer)element).members(); for (int i= 0; i < resources.length; i++) { // recursive! Only show containers that contain an archive if (select(viewer, parent, resources[i])) { return true; } } } catch (CoreException e) { JavaPlugin.log(e.getStatus()); } } return false; }
Example 17
Source File: ProfileConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void performApply() { try { fCurrContext.getNode(JavaUI.ID_PLUGIN).flush(); fCurrContext.getNode(JavaCore.PLUGIN_ID).flush(); if (fCurrContext != fInstanceScope) { fInstanceScope.getNode(JavaUI.ID_PLUGIN).flush(); fInstanceScope.getNode(JavaCore.PLUGIN_ID).flush(); } } catch (BackingStoreException e) { JavaPlugin.log(e); } }
Example 18
Source File: SelfEncapsulateFieldRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void checkArgName() { String fieldName= fField.getElementName(); boolean isStatic= true; try { isStatic= JdtFlags.isStatic(fField); } catch (JavaModelException e) { JavaPlugin.log(e); } if ( (isStatic && fArgName.equals(fieldName) && fieldName.equals(fField.getDeclaringType().getElementName())) || JavaConventionsUtil.validateIdentifier(fArgName, fField).getSeverity() == IStatus.ERROR) { fArgName= "_" + fArgName; //$NON-NLS-1$ } }
Example 19
Source File: CompletionProposalComputerRegistry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void informUser(IStatus status) { JavaPlugin.log(status); String title= JavaTextMessages.CompletionProposalComputerRegistry_error_dialog_title; String message= status.getMessage(); MessageDialog.openError(JavaPlugin.getActiveWorkbenchShell(), title, message); }
Example 20
Source File: WordCompletionProposalComputer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { if (contributes()) { try { IDocument document= context.getDocument(); final int offset= context.getInvocationOffset(); final IRegion region= document.getLineInformationOfOffset(offset); final String content= document.get(region.getOffset(), region.getLength()); int index= offset - region.getOffset() - 1; while (index >= 0 && Character.isLetter(content.charAt(index))) index--; final int start= region.getOffset() + index + 1; final String candidate= content.substring(index + 1, offset - region.getOffset()); if (candidate.length() > 0) { final ISpellCheckEngine engine= SpellCheckEngine.getInstance(); final ISpellChecker checker= engine.getSpellChecker(); if (checker != null) { final List<RankedWordProposal> proposals= new ArrayList<RankedWordProposal>(checker.getProposals(candidate, Character.isUpperCase(candidate.charAt(0)))); final List<ICompletionProposal> result= new ArrayList<ICompletionProposal>(proposals.size()); for (Iterator<RankedWordProposal> it= proposals.iterator(); it.hasNext();) { RankedWordProposal word= it.next(); String text= word.getText(); if (text.startsWith(candidate)) word.setRank(word.getRank() + PREFIX_RANK_SHIFT); result.add(new JavaCompletionProposal(text, start, candidate.length(), JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_RENAME), text, word.getRank()) { /* * @see org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent) */ @Override public boolean validate(IDocument doc, int validate_offset, DocumentEvent event) { return offset == validate_offset; } }); } return result; } } } catch (BadLocationException exception) { // log & ignore JavaPlugin.log(exception); } } return Collections.emptyList(); }