private boolean canEnable(TableItem[] selection) { if (selection.length == 0) return false; for (int i= 0; i < selection.length; i++) { TableItem item= selection[i]; Object data= item.getData(); if (!(data instanceof TypeNameMatch)) return false; if (!(fHistory.contains((TypeNameMatch)data))) return false; } return true; }
public static boolean needsExecution() { OpenTypeHistory history= OpenTypeHistory.getInstance(); return fgFirstTime || history.isEmpty() || history.needConsistencyCheck(); } private void refreshSearchIndices(IProgressMonitor monitor) throws InvocationTargetException {
@Override public synchronized boolean remove(Object element) { OpenTypeHistory.getInstance().remove((TypeNameMatch) element); return super.remove(element); }
/* package */ static void initializeAfterLoad(IProgressMonitor monitor) { OpenTypeHistory.getInstance().checkConsistency(monitor); }
List typesToCheck= new ArrayList(getKeys()); monitor.beginTask(CorextMessages.TypeInfoHistory_consistency_check, typesToCheck.size()); monitor.setTaskName(CorextMessages.TypeInfoHistory_consistency_check); for (Iterator iter= typesToCheck.iterator(); iter.hasNext();) { TypeNameMatch type= (TypeNameMatch)iter.next(); long currentTimestamp= getContainerTimestamp(type); Long lastTested= (Long)fTimestampMapping.get(type); if (lastTested != null && currentTimestamp != IResource.NULL_STAMP && currentTimestamp == lastTested.longValue() && !isContainerDirty(type)) continue; try { IType jType= type.getType(); if (jType == null || !jType.exists()) { remove(type); } else { replace(type, SearchEngine.createTypeNameMatch(jType, modifiers)); } else { fTimestampMapping.put(type, new Long(currentTimestamp)); remove(type);
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (fgFirstTime) { // Join the initialize after load job. IJobManager manager= Job.getJobManager(); manager.join(JavaUI.ID_PLUGIN, monitor); } OpenTypeHistory history= OpenTypeHistory.getInstance(); if (fgFirstTime || history.isEmpty()) { if (history.needConsistencyCheck()) { monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100); refreshSearchIndices(new SubProgressMonitor(monitor, 90)); history.checkConsistency(new SubProgressMonitor(monitor, 10)); } else { refreshSearchIndices(monitor); } monitor.done(); fgFirstTime= false; } else { history.checkConsistency(monitor); } } public static boolean needsExecution() {
OpenTypeHistory history= OpenTypeHistory.getInstance(); List result= new ArrayList(selected.length); for (int i= 0; i < selected.length; i++) { String message= Messages.format(JavaUIMessages.TypeSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName }); MessageDialog.openError(getShell(), title, message); history.remove(typeInfo); setResult(null); } else { history.accessed(typeInfo); result.add(type);
private void internalRunVirtual(ProgressMonitor monitor) throws CoreException, InterruptedException { if (monitor.isCanceled()) throw new OperationCanceledException(); fViewer.clear(fTicket); TypeNameMatch[] matchingTypes= fHistory.getFilteredTypeInfos(fFilter); fViewer.setHistoryResult(fTicket, matchingTypes); if ((fMode & INDEX) == 0) return; Set filteredMatches= new HashSet(matchingTypes.length * 2); for (int i= 0; i < matchingTypes.length; i++) { filteredMatches.add(matchingTypes[i]); } TypeNameMatch[] result= getSearchResult(filteredMatches, monitor); if (monitor.isCanceled()) throw new OperationCanceledException(); fViewer.setSearchResult(fTicket, result); } private IStatus canceled(Exception e, boolean removePendingItems) {
/** * Stores contents of the local history into persistent history * container. */ private synchronized void persistHistory() { if (getReturnCode() == OK) { Object[] items= getHistoryItems(); for (int i= 0; i < items.length; i++) { OpenTypeHistory.getInstance().accessed((TypeNameMatch) items[i]); } } }
@Override public void elementChanged(ElementChangedEvent event) { if (processDelta(event.getDelta())) { OpenTypeHistory.getInstance().markAsInconsistent(); } }
public boolean close() { boolean result; try { if (getReturnCode() == OK) { OpenTypeHistory.getInstance().save(); } } finally { result= super.close(); } return result; }
@Override public void load(IMemento memento) { TypeNameMatch[] types= OpenTypeHistory.getInstance().getTypeInfos(); for (int i= types.length - 1; i >= 0 ; i--) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=205314 TypeNameMatch type= types[i]; accessed(type); } }
@Override protected IStatus run(IProgressMonitor monitor) { OpenTypeHistory history= OpenTypeHistory.getInstance(); history.internalCheckConsistency(monitor); return Status.OK_STATUS; } @Override
if (!(element instanceof TypeNameMatch)) return; if (fHistory.remove((TypeNameMatch) element) != null) { item.dispose(); fItems.remove(index);
@Override public synchronized void accessed(TypeNameMatch info) { // Fetching the timestamp might not be cheap (remote file system // external Jars. So check if we alreay have one. if (!fTimestampMapping.containsKey(info)) { fTimestampMapping.put(info, new Long(getContainerTimestamp(info))); } super.accessed(info); }
public static synchronized OpenTypeHistory getInstance() { if (fgInstance == null) fgInstance= new OpenTypeHistory(); return fgInstance; }
public static synchronized void shutdown() { if (fgInstance == null) return; fgInstance.doShutdown(); }
List<TypeNameMatch> typesToCheck= new ArrayList<>(getKeys()); monitor.beginTask(CorextMessages.TypeInfoHistory_consistency_check, typesToCheck.size()); monitor.setTaskName(CorextMessages.TypeInfoHistory_consistency_check); for (Iterator<TypeNameMatch> iter= typesToCheck.iterator(); iter.hasNext();) { TypeNameMatch type= iter.next(); long currentTimestamp= getContainerTimestamp(type); Long lastTested= fTimestampMapping.get(type); if (lastTested != null && currentTimestamp != IResource.NULL_STAMP && currentTimestamp == lastTested.longValue() && !isContainerDirty(type)) continue; try { IType jType= type.getType(); if (jType == null || !jType.exists()) { remove(type); } else { replace(type, SearchEngine.createTypeNameMatch(jType, modifiers)); } else { fTimestampMapping.put(type, new Long(currentTimestamp)); remove(type);
@Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (fgFirstTime) { // Join the initialize after load job. IJobManager manager= Job.getJobManager(); manager.join(JavaUI.ID_PLUGIN, monitor); } OpenTypeHistory history= OpenTypeHistory.getInstance(); if (fgFirstTime || history.isEmpty()) { if (history.needConsistencyCheck()) { monitor.beginTask(JavaUIMessages.TypeSelectionDialog_progress_consistency, 100); refreshSearchIndices(new SubProgressMonitor(monitor, 90)); history.checkConsistency(new SubProgressMonitor(monitor, 10)); } else { refreshSearchIndices(monitor); } monitor.done(); fgFirstTime= false; } else { history.checkConsistency(monitor); } } public static boolean needsExecution() {
OpenTypeHistory history= OpenTypeHistory.getInstance(); List result= new ArrayList(selected.length); for (int i= 0; i < selected.length; i++) { String message= Messages.format(JavaUIMessages.TypeSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName }); MessageDialog.openError(getShell(), title, message); history.remove(typeInfo); setResult(null); } else { history.accessed(typeInfo); result.add(type);