public static void migrateToClasspathAttributes() { final Map<IPath, String> oldLocations = loadOldForCompatibility(); if (oldLocations.isEmpty()) { IPreferenceStore preferenceStore = PreferenceConstants.getPreferenceStore(); preferenceStore.setValue(PREF_JAVADOCLOCATIONS, ""); // $NON-NLS-1$ preferenceStore.setValue(PREF_JAVADOCLOCATIONS_MIGRATED, true); return; } Job job = new Job(CorextMessages.JavaDocLocations_migratejob_name) { @Override protected IStatus run(IProgressMonitor monitor) { try { IWorkspaceRunnable runnable = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor pm) throws CoreException { updateClasspathEntries(oldLocations, pm); IPreferenceStore preferenceStore = PreferenceConstants.getPreferenceStore(); preferenceStore.setValue(PREF_JAVADOCLOCATIONS, ""); // $NON-NLS-1$ preferenceStore.setValue(PREF_JAVADOCLOCATIONS_MIGRATED, true); } }; new WorkbenchRunnableAdapter(runnable).run(monitor); } catch (InvocationTargetException e) { JavaPlugin.log(e); } catch (InterruptedException e) { // should not happen, cannot cancel } return Status.OK_STATUS; } }; job.schedule(); }
public void setLinkingEnabled(boolean enabled) { fLinkingEnabled = enabled; PreferenceConstants.getPreferenceStore().setValue(getLinkToEditorKey(), enabled); if (enabled) { IEditorPart editor = getSite().getPage().getActiveEditor(); if (editor != null) { setSelectionFromEditor(editor); } } fOpenAndLinkWithEditorHelper.setLinkWithEditor(enabled); }
@Override public void initialize(IPreferenceStoreAccess preferenceStoreAccess) { this.preferenceStoreAccess = preferenceStoreAccess; IPreferenceStore preferenceStore = org.eclipse.jdt.ui.PreferenceConstants.getPreferenceStore(); preferenceStore.addPropertyChangeListener(this); preferenceStoreAccess .getWritablePreferenceStore() .setDefault( PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, preferenceStore.getBoolean( org.eclipse.jdt.ui.PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)); }
protected final void internalDoOperation() { if (PreferenceConstants.getPreferenceStore() .getBoolean(PreferenceConstants.EDITOR_IMPORTS_ON_PASTE) && isSmartInsertMode()) { if (fOperationCode == ITextOperationTarget.PASTE) { doPasteWithImportsOperation(); } else { doCutCopyWithImportsOperation(); } } else { fOperationTarget.doOperation(fOperationCode); } }
/* * @see org.eclipse.jdt.internal.ui.text.spelling.SpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellChecker, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor) */ protected void check( IDocument document, IRegion[] regions, ISpellChecker checker, ISpellingProblemCollector collector, IProgressMonitor monitor) { SpellEventListener listener = new SpellEventListener(collector, document); boolean isIgnoringJavaStrings = PreferenceConstants.getPreferenceStore() .getBoolean(PreferenceConstants.SPELLING_IGNORE_JAVA_STRINGS); try { for (int i = 0; i < regions.length; i++) { IRegion region = regions[i]; ITypedRegion[] partitions = TextUtilities.computePartitioning( document, IJavaPartitions.JAVA_PARTITIONING, region.getOffset(), region.getLength(), false); for (int index = 0; index < partitions.length; index++) { if (monitor != null && monitor.isCanceled()) return; if (listener.isProblemsThresholdReached()) return; ITypedRegion partition = partitions[index]; final String type = partition.getType(); if (isIgnoringJavaStrings && type.equals(IJavaPartitions.JAVA_STRING)) continue; if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE) && !type.equals(IJavaPartitions.JAVA_CHARACTER)) checker.execute( listener, new SpellCheckIterator(document, partition, checker.getLocale())); } } } catch (BadLocationException x) { // ignore: the document has been changed in another thread and will be checked again } catch (AssertionFailedException x) { // ignore: the document has been changed in another thread and will be checked again } }
private void initLinkingEnabled() { fLinkingEnabled = PreferenceConstants.getPreferenceStore().getBoolean(getLinkToEditorKey()); }
private static Map<IPath, String> loadOldForCompatibility() { HashMap<IPath, String> resultingOldLocations = new HashMap<>(); // in 3.0, the javadoc locations were stored as one big string in the preferences String string = PreferenceConstants.getPreferenceStore().getString(PREF_JAVADOCLOCATIONS); if (string != null && string.length() > 0) { byte[] bytes; try { bytes = string.getBytes("UTF-8"); // $NON-NLS-1$ } catch (UnsupportedEncodingException e) { bytes = string.getBytes(); } InputStream is = new ByteArrayInputStream(bytes); try { loadFromStream(new InputSource(is), resultingOldLocations); PreferenceConstants.getPreferenceStore().setValue(PREF_JAVADOCLOCATIONS, ""); // $NON-NLS-1$ return resultingOldLocations; } catch (CoreException e) { JavaPlugin.log(e); // log but ignore } finally { try { is.close(); } catch (IOException e) { // ignore } } } // in 2.1, the Javadoc locations were stored in a file in the meta data // note that it is wrong to use a stream reader with XML declaring to be UTF-8 try { final String STORE_FILE = "javadoclocations.xml"; // $NON-NLS-1$ File file = JavaPlugin.getDefault().getStateLocation().append(STORE_FILE).toFile(); if (file.exists()) { Reader reader = null; try { reader = new FileReader(file); loadFromStream(new InputSource(reader), resultingOldLocations); file.delete(); // remove file after successful store return resultingOldLocations; } catch (IOException e) { JavaPlugin.log(e); // log but ignore } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { } } } } catch (CoreException e) { JavaPlugin.log(e); // log but ignore } // in 2.0, the Javadoc locations were stored as one big string in the persistent properties // note that it is wrong to use a stream reader with XML declaring to be UTF-8 try { final QualifiedName QUALIFIED_NAME = new QualifiedName(JavaUI.ID_PLUGIN, "jdoclocation"); // $NON-NLS-1$ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); String xmlString = root.getPersistentProperty(QUALIFIED_NAME); if (xmlString != null) { // only set when workspace is old Reader reader = new StringReader(xmlString); try { loadFromStream(new InputSource(reader), resultingOldLocations); root.setPersistentProperty(QUALIFIED_NAME, null); // clear property return resultingOldLocations; } finally { try { reader.close(); } catch (IOException e) { // error closing reader: ignore } } } } catch (CoreException e) { JavaPlugin.log(e); // log but ignore } return resultingOldLocations; }
public JavaAnnotationImageProvider() { fShowQuickFixIcon = PreferenceConstants.getPreferenceStore() .getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION); }
/* * @see org.eclipse.ui.internal.texteditor.AnnotationExpandHover#getHoverInfoForLine(org.eclipse.jface.text.source.ISourceViewer, int) */ @Override protected Object getHoverInfoForLine(final ISourceViewer viewer, final int line) { final boolean showTemporaryProblems = PreferenceConstants.getPreferenceStore() .getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION); IAnnotationModel model = viewer.getAnnotationModel(); IDocument document = viewer.getDocument(); if (model == null) return null; List<Annotation> exact = new ArrayList<Annotation>(); HashMap<Position, Object> messagesAtPosition = new HashMap<Position, Object>(); Iterator<Annotation> e = model.getAnnotationIterator(); while (e.hasNext()) { Annotation annotation = e.next(); if (fAnnotationAccess instanceof IAnnotationAccessExtension) if (!((IAnnotationAccessExtension) fAnnotationAccess).isPaintable(annotation)) continue; if (annotation instanceof IJavaAnnotation && !isIncluded((IJavaAnnotation) annotation, showTemporaryProblems)) continue; AnnotationPreference pref = fLookup.getAnnotationPreference(annotation); if (pref != null) { String key = pref.getVerticalRulerPreferenceKey(); if (key != null && !fStore.getBoolean(key)) continue; } Position position = model.getPosition(annotation); if (position == null) continue; if (compareRulerLine(position, document, line) == 1) { if (isDuplicateMessage(messagesAtPosition, position, annotation.getText())) continue; exact.add(annotation); } } sort(exact, model); if (exact.size() > 0) setLastRulerMouseLocation(viewer, line); if (exact.size() > 0) { Annotation first = exact.get(0); if (!isBreakpointAnnotation(first)) exact.add(0, new NoBreakpointAnnotation()); } if (exact.size() <= 1) return null; AnnotationHoverInput input = new AnnotationHoverInput(); input.fAnnotations = exact.toArray(new Annotation[0]); input.fViewer = viewer; input.fRulerInfo = fCompositeRuler; input.fAnnotationListener = fgListener; input.fDoubleClickListener = fDblClickListener; input.redoAction = new AnnotationExpansionControl.ICallback() { public void run(IInformationControlExtension2 control) { control.setInput(getHoverInfoForLine(viewer, line)); } }; input.model = model; return input; }
@Override public void execute(final ISpellEventListener listener, final ISpellCheckIterator iterator) { final boolean ignoreDigits = fPreferences.getBoolean(PreferenceConstants.SPELLING_IGNORE_DIGITS); final boolean ignoreMixed = fPreferences.getBoolean(PreferenceConstants.SPELLING_IGNORE_MIXED); final boolean ignoreSentence = fPreferences.getBoolean(PreferenceConstants.SPELLING_IGNORE_SENTENCE); final boolean ignoreUpper = fPreferences.getBoolean(PreferenceConstants.SPELLING_IGNORE_UPPER); final boolean ignoreURLS = fPreferences.getBoolean(PreferenceConstants.SPELLING_IGNORE_URLS); final boolean ignoreNonLetters = fPreferences.getBoolean(PreferenceConstants.SPELLING_IGNORE_NON_LETTERS); final boolean ignoreSingleLetters = fPreferences.getBoolean(PreferenceConstants.SPELLING_IGNORE_SINGLE_LETTERS); final int problemsThreshold = PreferenceConstants.getPreferenceStore() .getInt(PreferenceConstants.SPELLING_PROBLEMS_THRESHOLD); iterator.setIgnoreSingleLetters(ignoreSingleLetters); Iterator<ISpellDictionary> iter = fDictionaries.iterator(); while (iter.hasNext()) iter.next().setStripNonLetters(ignoreNonLetters); String word = null; boolean starts = false; int problemCount = 0; while (problemCount <= problemsThreshold && iterator.hasNext()) { word = iterator.next(); if (word != null) { // synchronizing is necessary as this is called inside the reconciler if (!fIgnored.contains(word)) { starts = iterator.startsSentence(); if (!isCorrect(word)) { boolean isMixed = isMixedCase(word, true); boolean isUpper = isUpperCase(word); boolean isDigits = isDigits(word); boolean isURL = isUrl(word); if (!ignoreMixed && isMixed || !ignoreUpper && isUpper || !ignoreDigits && isDigits || !ignoreURLS && isURL || !(isMixed || isUpper || isDigits || isURL)) { listener.handle( new SpellEvent( this, word, iterator.getBegin(), iterator.getEnd(), starts, false)); problemCount++; } } else { if (!ignoreSentence && starts && Character.isLowerCase(word.charAt(0))) { listener.handle( new SpellEvent(this, word, iterator.getBegin(), iterator.getEnd(), true, true)); problemCount++; } } } } } }
private boolean stackBrowsingViewsVertically() { return PreferenceConstants.getPreferenceStore() .getBoolean(PreferenceConstants.BROWSING_STACK_VERTICALLY); }