Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.team.ui')
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java1
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ITeamRunnableContext.java1
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java53
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java11
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MultipleYesNoPrompter.java45
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingHierarchyArea.java7
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java57
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/CompareFileRevisionEditorInput.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/DateHistoryCategory.java29
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/EditionHistoryPage.java26
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/FileRevisionEditorInput.java21
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryTableProvider.java8
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java85
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryViewDefaultPage.java7
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/HistoryPageSourceWorkbenchPart.java39
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java36
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java24
19 files changed, 183 insertions, 283 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java
index 89371a74c..569d09e3f 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java
@@ -30,7 +30,6 @@ import org.eclipse.ui.*;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
public class CompareRevisionAction extends BaseSelectionListenerAction {
-
HistoryPage page;
IStructuredSelection selection;
IFileRevision currentFileRevision;
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ITeamRunnableContext.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ITeamRunnableContext.java
index dee119be5..8c6bd310f 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ITeamRunnableContext.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/ITeamRunnableContext.java
@@ -22,7 +22,6 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
* 3) what shell the operation should use to display info to the user
*/
public interface ITeamRunnableContext {
-
/**
* Run the given runnable in the context of the receiver. By default, the
* progress is provided by the active workbench windows but subclasses may
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java
index 9ee66aa0b..d39b3bc18 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java
@@ -18,7 +18,6 @@ import org.eclipse.core.runtime.*;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
@@ -48,15 +47,13 @@ import com.ibm.icu.text.Collator;
* </p>
*/
public class OpenWithMenu extends ContributionItem {
-
private IStructuredSelection selection;
private HistoryPage page;
- private IEditorRegistry registry = PlatformUI.getWorkbench()
- .getEditorRegistry();
+ private IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
- private static Hashtable<ImageDescriptor, Image> imageCache = new Hashtable<ImageDescriptor, Image>(11);
+ private static Hashtable<ImageDescriptor, Image> imageCache = new Hashtable<>(11);
/**
* The id of this action.
@@ -123,8 +120,7 @@ public class OpenWithMenu extends ContributionItem {
private ImageDescriptor getImageDescriptor(IEditorDescriptor editorDesc) {
ImageDescriptor imageDesc = null;
if (editorDesc == null) {
- imageDesc = registry
- .getImageDescriptor(getFileRevision().getName());
+ imageDesc = registry.getImageDescriptor(getFileRevision().getName());
// TODO: is this case valid, and if so, what are the implications
// for content-type editor bindings?
} else {
@@ -133,9 +129,7 @@ public class OpenWithMenu extends ContributionItem {
if (imageDesc == null) {
if (editorDesc.getId().equals(
IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID)) {
- imageDesc = registry
- .getSystemExternalEditorImageDescriptor(getFileRevision()
- .getName());
+ imageDesc = registry.getSystemExternalEditorImageDescriptor(getFileRevision().getName());
}
}
return imageDesc;
@@ -327,33 +321,23 @@ public class OpenWithMenu extends ContributionItem {
try {
IProgressMonitor monitor = new NullProgressMonitor();
IStorage storage = fileRevision.getStorage(monitor);
- boolean isFile = storage instanceof IFile;
-
+ IEditorInput editorInput = storage instanceof IFile ?
+ new FileEditorInput((IFile) storage) :
+ FileRevisionEditorInput.createEditorInputFor(fileRevision, monitor);
if (openUsingDescriptor) {
- // discouraged access to open system editors
- ((WorkbenchPage) (page.getSite().getPage()))
- .openEditorFromDescriptor(
- isFile ? new FileEditorInput((IFile) storage)
- : (IEditorInput) FileRevisionEditorInput
- .createEditorInputFor(
- fileRevision, monitor),
- editorDescriptor, true, null);
+ // Discouraged access to open system editors.
+ WorkbenchPage workbenchPage = (WorkbenchPage) (page.getSite().getPage());
+ workbenchPage.openEditorFromDescriptor(editorInput, editorDescriptor, true, null);
} else {
- String editorId = editorDescriptor == null ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID
- : editorDescriptor.getId();
- page.getSite().getPage().openEditor(
- isFile ? new FileEditorInput((IFile) storage)
- : (IEditorInput) FileRevisionEditorInput
- .createEditorInputFor(fileRevision,
- monitor), editorId, true,
- MATCH_BOTH);
+ String editorId = editorDescriptor == null ?
+ IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID : editorDescriptor.getId();
+ page.getSite().getPage().openEditor(editorInput, editorId, true, MATCH_BOTH);
}
} catch (PartInitException e) {
StatusAdapter statusAdapter = new StatusAdapter(e.getStatus());
statusAdapter.setProperty(IStatusAdapterConstants.TITLE_PROPERTY,
TeamUIMessages.LocalHistoryPage_OpenEditorError);
- StatusManager.getManager()
- .handle(statusAdapter, StatusManager.SHOW);
+ StatusManager.getManager().handle(statusAdapter, StatusManager.SHOW);
} catch (CoreException e) {
StatusAdapter statusAdapter = new StatusAdapter(e.getStatus());
statusAdapter.setProperty(IStatusAdapterConstants.TITLE_PROPERTY,
@@ -383,19 +367,12 @@ public class OpenWithMenu extends ContributionItem {
return revision;
}
- /*
- * (non-Javadoc) Returns whether this menu is dynamic.
- */
@Override
public boolean isDynamic() {
return true;
}
public void selectionChanged(IStructuredSelection selection) {
- if (selection instanceof IStructuredSelection) {
- this.selection = selection;
- } else {
- this.selection = StructuredSelection.EMPTY;
- }
+ this.selection = selection;
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java
index 7b91a2d47..396608d03 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/DialogArea.java
@@ -26,18 +26,17 @@ import org.eclipse.swt.widgets.*;
/**
* This class provides facilities to allow common widget groupings to be shared
- * by mulitple dialogs or wizards.
+ * by multiple dialogs or wizards.
*/
public abstract class DialogArea {
-
private FontMetrics fontMetrics;
- private List listeners;
+ private List<IPropertyChangeListener> listeners;
/**
* Create a dialog area
*/
protected DialogArea() {
- this.listeners = new ArrayList();
+ this.listeners = new ArrayList<IPropertyChangeListener>();
}
/**
@@ -62,8 +61,8 @@ public abstract class DialogArea {
protected void firePropertyChangeChange(String property, Object oldValue, Object newValue) {
PropertyChangeEvent event = new PropertyChangeEvent(this, property, oldValue, newValue);
- for (Iterator iter = listeners.iterator(); iter.hasNext();) {
- IPropertyChangeListener listener = (IPropertyChangeListener) iter.next();
+ for (Iterator<IPropertyChangeListener> iter = listeners.iterator(); iter.hasNext();) {
+ IPropertyChangeListener listener = iter.next();
listener.propertyChange(event);
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MultipleYesNoPrompter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MultipleYesNoPrompter.java
index c11d6d2e1..d36510406 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MultipleYesNoPrompter.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/MultipleYesNoPrompter.java
@@ -22,7 +22,6 @@ import org.eclipse.swt.widgets.Shell;
* and No to All are presented). It uses the previous selection as appropriate.
*/
public class MultipleYesNoPrompter {
-
private static final int ALWAYS_ASK = 0;
private static final int YES_TO_ALL = 1;
private static final int NO_TO_ALL = 2;
@@ -37,7 +36,8 @@ public class MultipleYesNoPrompter {
* Prompt for the given resources using the specific condition. The prompt dialog will
* have the title specified.
*/
- public MultipleYesNoPrompter(IShellProvider provider, String title, boolean hasMultiple, boolean allOrNothing) {
+ public MultipleYesNoPrompter(IShellProvider provider, String title,
+ boolean hasMultiple, boolean allOrNothing) {
this.title = title;
this.shellProvider = provider;
this.hasMultiple = hasMultiple;
@@ -77,24 +77,25 @@ public class MultipleYesNoPrompter {
return true;
} else {
switch (confirmation) {
- case ALWAYS_ASK: {
- // This call has the nasty side effect of changing the
- // instance scoped "confirmation"
- if (confirmOverwrite(message)) {
- return true;
- }
- break;
- }
- case YES_TO_ALL: {
+ case ALWAYS_ASK:
+ // This call has the nasty side effect of changing the
+ // instance scoped "confirmation"
+ if (confirmOverwrite(message)) {
return true;
}
- case NO_TO_ALL: {
- // Don't overwrite
- break;
- }
+ return false;
+
+ case YES_TO_ALL:
+ return true;
+
+ case NO_TO_ALL:
+ // Don't overwrite
+ return false;
+
+ default:
+ // If we get here, the user said no or not_to_all.
+ return false;
}
- // If we get here, the user said no or not_to_all.
- return false;
}
}
@@ -118,20 +119,20 @@ public class MultipleYesNoPrompter {
});
if (hasMultiple) {
switch (dialog.getReturnCode()) {
- case 0://Yes
+ case 0:// Yes
return true;
- case 1://Yes to all
+ case 1:// Yes to all
confirmation = YES_TO_ALL;
return true;
- case 2://No (or CANCEL for all-or-nothing)
+ case 2:// No (or CANCEL for all-or-nothing)
if (allOrNothing) {
throw new InterruptedException();
}
return false;
- case 3://No to all
+ case 3:// No to all
confirmation = NO_TO_ALL;
return false;
- case 4://Cancel
+ case 4:// Cancel
default:
throw new InterruptedException();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java
index bd3a5b3e5..e74c256a3 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PreferencePageContainerDialog.java
@@ -45,7 +45,7 @@ public class PreferencePageContainerDialog extends TrayDialog
private Button fOkButton;
- private ListenerList pageChangedListeners = new ListenerList();
+ private ListenerList<IPageChangedListener> pageChangedListeners = new ListenerList<IPageChangedListener>();
/**
* The Composite in which a page is shown.
@@ -59,7 +59,7 @@ public class PreferencePageContainerDialog extends TrayDialog
*/
private Point fMinimumPageSize = new Point(200,200);
private TabFolder tabFolder;
- private Map pageMap = new HashMap();
+ private Map<TabItem, PreferencePage> pageMap = new HashMap<>();
/**
* Must declare our own images as the JFaceResource images will not be created unless
@@ -166,7 +166,7 @@ public class PreferencePageContainerDialog extends TrayDialog
protected void updatePageSelection() {
TabItem[] items = tabFolder.getSelection();
if (items.length == 1) {
- currentPage = (PreferencePage)pageMap.get(items[0]);
+ currentPage = pageMap.get(items[0]);
updateMessage();
}
firePageChanged(new PageChangedEvent(this, currentPage));
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java
index 622c24dd6..737a688e3 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/PromptingDialog.java
@@ -47,6 +47,7 @@ public class PromptingDialog extends MultipleYesNoPrompter {
this.resources = resources;
this.condition = condition;
}
+
/**
* Call to calculate and show prompt. If no resources satisfy the prompt
* condition a dialog won't be shown. The resources for which the user
@@ -57,13 +58,13 @@ public class PromptingDialog extends MultipleYesNoPrompter {
* if the user choose to cancel on the prompt dialog
*/
public IResource[] promptForMultiple() throws InterruptedException {
- List targetResources = new ArrayList();
+ List<IResource> targetResources = new ArrayList<>();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
if (!condition.needsPrompt(resource) || shouldInclude(condition.promptMessage(resource))) {
targetResources.add(resource);
}
}
- return (IResource[]) targetResources.toArray(new IResource[targetResources.size()]);
+ return targetResources.toArray(new IResource[targetResources.size()]);
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingHierarchyArea.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingHierarchyArea.java
index 62c90f101..e9a75bbb7 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingHierarchyArea.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingHierarchyArea.java
@@ -27,7 +27,6 @@ import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.ui.navigator.*;
public class ResourceMappingHierarchyArea extends DialogArea implements INavigatorContentServiceListener {
-
private static final String TEAM_NAVIGATOR_CONTENT = "org.eclipse.team.ui.navigatorViewer"; //$NON-NLS-1$
private String description;
private CommonViewer viewer;
@@ -82,7 +81,7 @@ public class ResourceMappingHierarchyArea extends DialogArea implements INavigat
if (scope == null)
return new Object[0];
ResourceMapping[] mappings = scope.getMappings();
- List result = new ArrayList();
+ List<Object> result = new ArrayList<>();
for (int i = 0; i < mappings.length; i++) {
ResourceMapping mapping = mappings[i];
result.add(mapping.getModelObject());
@@ -94,9 +93,6 @@ public class ResourceMappingHierarchyArea extends DialogArea implements INavigat
description = string;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.internal.extensions.INavigatorContentServiceListener#onLoad(org.eclipse.ui.navigator.internal.extensions.NavigatorContentExtension)
- */
@Override
public void onLoad(INavigatorContentExtension anExtension) {
anExtension.getStateModel().setProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_SCOPE, scope);
@@ -104,5 +100,4 @@ public class ResourceMappingHierarchyArea extends DialogArea implements INavigat
anExtension.getStateModel().setProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_CONTEXT, context);
}
}
-
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java
index c8016d6e0..180d22fba 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/dialogs/ResourceMappingResourceDisplayArea.java
@@ -34,17 +34,16 @@ import org.eclipse.ui.views.navigator.ResourceComparator;
* Dialog area which displays the resources for a resource mapping
*/
public class ResourceMappingResourceDisplayArea extends DialogArea {
-
private ResourceMapping mapping;
private ResourceMappingContext context = ResourceMappingContext.LOCAL_CONTEXT;
private TreeViewer viewer;
private Label label;
private IResourceMappingResourceFilter filter;
- private Map cachedFiltering = new HashMap(); // String(mapping)-> Map: Resource -> List(IResource)
+ private Map<ResourceMapping, Map<IResource, List<IResource>>> cachedFiltering = new HashMap<>();
private String message;
private static IWorkbenchAdapter getWorkbenchAdapter(IAdaptable o) {
- return (IWorkbenchAdapter)o.getAdapter(IWorkbenchAdapter.class);
+ return o.getAdapter(IWorkbenchAdapter.class);
}
/**
@@ -85,7 +84,7 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
@Override
public Object[] getChildren(Object o) {
ResourceTraversal[] traversals = getTraversals();
- List result = new ArrayList();
+ List<ResourceTraversalElement> result = new ArrayList<>();
for (int i = 0; i < traversals.length; i++) {
ResourceTraversal traversal = traversals[i];
IResource[] resources = traversal.getResources();
@@ -138,13 +137,11 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(Class adapter) {
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IWorkbenchAdapter.class)
- return this;
+ return (T) this;
return null;
}
}
@@ -182,7 +179,7 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
try {
if (resource.getType() != IResource.FILE) {
IResource[] members = members(((IContainer)resource));
- List result = new ArrayList();
+ List<ResourceTraversalElement> result = new ArrayList<ResourceTraversalElement>();
for (int i = 0; i < members.length; i++) {
IResource child = members[i];
if ((includeFolders || child.getType() == IResource.FILE)
@@ -241,15 +238,14 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
return parent;
}
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(Class adapter) {
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IWorkbenchAdapter.class)
- return this;
+ return (T) this;
return null;
}
+
public IResource getResource() {
return resource;
}
@@ -257,7 +253,8 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
/**
* Create a dialog area that will display the resources contained in the
- * given mapping
+ * given mapping.
+ *
* @param mapping the mapping
* @param filter the filter
* @param string the message to display
@@ -318,7 +315,7 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
private boolean isIncludedInFilter(IResource resource, ResourceTraversal traversal) {
if (filter == null)
return true;
- Map mappingResources = (Map)cachedFiltering.get(mapping);
+ Map<IResource, List<IResource>> mappingResources = cachedFiltering.get(mapping);
if (mappingResources == null) {
mappingResources = buildFilteredResourceMap(mapping, context);
cachedFiltering.put(mapping, mappingResources);
@@ -326,8 +323,8 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
return mappingResources.containsKey(resource);
}
- private Map buildFilteredResourceMap(final ResourceMapping mapping, final ResourceMappingContext context) {
- final Map result = new HashMap();
+ private Map<IResource, List<IResource>> buildFilteredResourceMap(final ResourceMapping mapping, final ResourceMappingContext context) {
+ final Map<IResource, List<IResource>> result = new HashMap<>();
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
@Override
@@ -346,20 +343,22 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
}
}
- private void buildFilteredResourceMap(final ResourceMapping mapping, final ResourceTraversal traversal, IProgressMonitor monitor, final Map result) throws CoreException {
+ private void buildFilteredResourceMap(final ResourceMapping mapping,
+ final ResourceTraversal traversal, IProgressMonitor monitor,
+ final Map<IResource, List<IResource>> result) throws CoreException {
traversal.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
if (filter.select(resource, mapping, traversal)) {
// Add the resource to the result
- result.put(resource, new ArrayList());
+ result.put(resource, new ArrayList<>());
// Make sure that there are parent folders for the resource up to the traversal root
IResource child = resource;
while (!isTraversalRoot(traversal, child)) {
IContainer parent = child.getParent();
- List children = (List)result.get(parent);
+ List<IResource> children = result.get(parent);
if (children == null) {
- children = new ArrayList();
+ children = new ArrayList<>();
result.put(parent, children);
}
children.add(child);
@@ -381,7 +380,7 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
}
/* private */ static ResourceTraversal[] getTraversals(final ResourceMapping mapping, final ResourceMappingContext context) {
- final List traversals = new ArrayList();
+ final List<ResourceTraversal[]> traversals = new ArrayList<>();
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
@Override
@@ -393,7 +392,7 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
}
}
});
- return (ResourceTraversal[])traversals.get(0);
+ return traversals.get(0);
} catch (InvocationTargetException e) {
TeamUIPlugin.log(IStatus.ERROR, "An error occurred while traversing " + getLabel(mapping), e); //$NON-NLS-1$
} catch (InterruptedException e) {
@@ -403,7 +402,7 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
}
/* private */ static IResource[] members(final IContainer container, final RemoteResourceMappingContext context) {
- final List members = new ArrayList();
+ final List<IResource[]> members = new ArrayList<>();
try {
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
@Override
@@ -415,7 +414,7 @@ public class ResourceMappingResourceDisplayArea extends DialogArea {
}
}
});
- return (IResource[])members.get(0);
+ return members.get(0);
} catch (InvocationTargetException e) {
TeamUIPlugin.log(IStatus.ERROR, "An error occurred while fetching the members of" + container.getFullPath(), e); //$NON-NLS-1$
} catch (InterruptedException e) {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/CompareFileRevisionEditorInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/CompareFileRevisionEditorInput.java
index d7350217f..6c06f9ef3 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/CompareFileRevisionEditorInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/CompareFileRevisionEditorInput.java
@@ -150,10 +150,7 @@ public class CompareFileRevisionEditorInput extends SaveableCompareEditorInput {
}
private IResource getResource(ICompareInput input) {
- if (getLocalElement() instanceof IResourceProvider) {
- return ((IResourceProvider) getLocalElement()).getResource();
- }
- return null;
+ return getLocalElement().getResource();
}
private ICompareInput createCompareInput() {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/DateHistoryCategory.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/DateHistoryCategory.java
index 8a90f5ad9..f85386d40 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/DateHistoryCategory.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/DateHistoryCategory.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * IBM Corporation - initial API and implementation
+ * IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.internal.ui.history;
@@ -16,11 +16,9 @@ import com.ibm.icu.util.Calendar;
import org.eclipse.team.core.history.IFileRevision;
public class DateHistoryCategory extends AbstractHistoryCategory {
-
private String name;
private Calendar fromDate;
private Calendar toDate;
-
private IFileRevision[] revisions;
/**
@@ -37,22 +35,15 @@ public class DateHistoryCategory extends AbstractHistoryCategory {
this.toDate = toDate;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.AbstractCVSHistoryCategory#getName()
- */
@Override
public String getName() {
return name;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.AbstractCVSHistoryCategory#collectFileRevisions(org.eclipse.team.core.history.IFileRevision[], boolean)
- */
@Override
public boolean collectFileRevisions(IFileRevision[] fileRevisions, boolean shouldRemove) {
-
- ArrayList pertinentRevisions = new ArrayList();
- ArrayList nonPertinentRevisions = new ArrayList();
+ ArrayList<IFileRevision> pertinentRevisions = new ArrayList<>();
+ ArrayList<IFileRevision> nonPertinentRevisions = new ArrayList<>();
for (int i = 0; i < fileRevisions.length; i++) {
//get the current file revision's date
@@ -101,7 +92,7 @@ public class DateHistoryCategory extends AbstractHistoryCategory {
}
if (pertinentRevisions.size() > 0){
- IFileRevision[] tempRevision = (IFileRevision[]) pertinentRevisions.toArray(new IFileRevision[pertinentRevisions.size()]);
+ IFileRevision[] tempRevision = pertinentRevisions.toArray(new IFileRevision[pertinentRevisions.size()]);
revisions = new IFileRevision[tempRevision.length];
System.arraycopy(tempRevision, 0, revisions, 0, tempRevision.length);
return true;
@@ -110,23 +101,13 @@ public class DateHistoryCategory extends AbstractHistoryCategory {
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.AbstractCVSHistoryCategory#getRevisions()
- */
@Override
public IFileRevision[] getRevisions() {
return revisions;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ccvs.ui.AbstractCVSHistoryCategory#hasRevisions()
- */
@Override
public boolean hasRevisions() {
- if (revisions != null && revisions.length > 0)
- return true;
-
- return false;
+ return revisions != null && revisions.length != 0;
}
-
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/EditionHistoryPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/EditionHistoryPage.java
index b68b4888f..b0da330a3 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/EditionHistoryPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/EditionHistoryPage.java
@@ -38,14 +38,13 @@ import org.eclipse.ui.IWorkbenchPage;
* methods are only used when the site is modal so they can use the localEdition.
*/
public class EditionHistoryPage extends LocalHistoryPage {
-
private IFile file;
private Object element;
private LocalResourceTypedElement localFileElement;
private IStructureCreator structureCreator;
- private Map editions = new HashMap();
+ private Map<IFileRevision, ITypedElement> editions = new HashMap<IFileRevision, ITypedElement>();
private ITypedElement localEdition;
private String name;
@@ -230,7 +229,7 @@ public class EditionHistoryPage extends LocalHistoryPage {
private IFileRevision[] filterRevisions(ITypedElement localEdition, IFileRevision[] revisions,
IProgressMonitor monitor) {
ITypedElement previousEdition = localEdition;
- List result = new ArrayList();
+ List<IFileRevision> result = new ArrayList<IFileRevision>();
sortDescending(revisions);
editions.clear();
for (int i = 0; i < revisions.length; i++) {
@@ -242,21 +241,14 @@ public class EditionHistoryPage extends LocalHistoryPage {
result.add(revision);
}
}
- return (IFileRevision[]) result.toArray(new IFileRevision[result.size()]);
+ return result.toArray(new IFileRevision[result.size()]);
}
private static void sortDescending(IFileRevision[] revisions) {
- Arrays.sort(revisions, new Comparator() {
+ Arrays.sort(revisions, new Comparator<IFileRevision>() {
@Override
- public int compare(Object o1, Object o2) {
- IFileRevision d1= (IFileRevision) o1;
- IFileRevision d2= (IFileRevision) o2;
- long d= d2.getTimestamp() - d1.getTimestamp();
- if (d < 0)
- return -1;
- if (d > 0)
- return 1;
- return 0;
+ public int compare(IFileRevision d1, IFileRevision d2) {
+ return -Long.compare(d1.getTimestamp(), d2.getTimestamp());
}
});
}
@@ -282,7 +274,7 @@ public class EditionHistoryPage extends LocalHistoryPage {
}
public ITypedElement getEditionFor(Object object) {
- return (ITypedElement)editions.get(object);
+ return editions.get(object);
}
private static ITypedElement createLocalEdition(IStructureCreator creator, ITypedElement input, Object element) {
@@ -393,8 +385,8 @@ public class EditionHistoryPage extends LocalHistoryPage {
private Object getRevisionFor(Object object) {
if (object == localEdition)
return localFileElement;
- for (Iterator iterator = editions.keySet().iterator(); iterator.hasNext();) {
- IFileRevision revision = (IFileRevision) iterator.next();
+ for (Iterator<IFileRevision> iterator = editions.keySet().iterator(); iterator.hasNext();) {
+ IFileRevision revision = iterator.next();
if (editions.get(revision) == object) {
return revision;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/FileRevisionEditorInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/FileRevisionEditorInput.java
index 5a1820ae4..0751b45e9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/FileRevisionEditorInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/FileRevisionEditorInput.java
@@ -28,7 +28,6 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
import com.ibm.icu.text.DateFormat;
public class FileRevisionEditorInput extends PlatformObject implements IWorkbenchAdapter, IStorageEditorInput {
-
private final Object fileRevision;
private final IStorage storage;
@@ -51,7 +50,7 @@ public class FileRevisionEditorInput extends PlatformObject implements IWorkbenc
if (storage instanceof IFileState) {
return new IFileState() {
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return storage.getAdapter(adapter);
}
@@ -94,7 +93,7 @@ public class FileRevisionEditorInput extends PlatformObject implements IWorkbenc
return new IEncodedStorage() {
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return storage.getAdapter(adapter);
}
@@ -162,10 +161,10 @@ public class FileRevisionEditorInput extends PlatformObject implements IWorkbenc
@Override
public String getName() {
- IFileRevision rev = (IFileRevision)getAdapter(IFileRevision.class);
+ IFileRevision rev = getAdapter(IFileRevision.class);
if (rev != null)
return NLS.bind(TeamUIMessages.nameAndRevision, new String[] { rev.getName(), rev.getContentIdentifier()});
- IFileState state = (IFileState)getAdapter(IFileState.class);
+ IFileState state = getAdapter(IFileState.class);
if (state != null)
return state.getName() + " " + DateFormat.getInstance().format(new Date(state.getModificationTime())) ; //$NON-NLS-1$
return storage.getName();
@@ -184,14 +183,15 @@ public class FileRevisionEditorInput extends PlatformObject implements IWorkbenc
}
@Override
- public Object getAdapter(Class adapter) {
+ @SuppressWarnings("unchecked")
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IWorkbenchAdapter.class)
- return this;
+ return (T) this;
if (adapter == IStorage.class)
- return storage;
+ return (T) storage;
Object object = super.getAdapter(adapter);
if (object != null)
- return object;
+ return (T) object;
return Utils.getAdapter(fileRevision, adapter);
}
@@ -207,7 +207,7 @@ public class FileRevisionEditorInput extends PlatformObject implements IWorkbenc
@Override
public String getLabel(Object o) {
- IFileRevision rev = (IFileRevision)getAdapter(IFileRevision.class);
+ IFileRevision rev = getAdapter(IFileRevision.class);
if (rev != null)
return rev.getName();
return storage.getName();
@@ -246,5 +246,4 @@ public class FileRevisionEditorInput extends PlatformObject implements IWorkbenc
}
return null;
}
-
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryTableProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryTableProvider.java
index 14aafb951..ee4844d35 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryTableProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryTableProvider.java
@@ -39,7 +39,6 @@ import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.internal.ui.TeamUIMessages;
public class GenericHistoryTableProvider {
-
private IFileHistory currentFileHistory;
private IFile currentFile;
private String currentRevision;
@@ -78,8 +77,9 @@ public class GenericHistoryTableProvider {
case COL_COMMENT:
String comment = entry.getComment();
return comment;
+ default:
+ return ""; //$NON-NLS-1$
}
- return ""; //$NON-NLS-1$
}
private synchronized DateFormat getDateFormat() {
@@ -227,14 +227,14 @@ public class GenericHistoryTableProvider {
if (element instanceof IFileRevision) {
entry = (IFileRevision) element;
} else if (element instanceof IAdaptable) {
- entry = (IFileRevision)((IAdaptable)element).getAdapter(IFileRevision.class);
+ entry = ((IAdaptable) element).getAdapter(IFileRevision.class);
}
return entry;
}
/**
* Create a TableViewer that can be used to display a list of IFileRevision instances.
- * Ths method provides the labels and sorter but does not provide a content provider
+ * This method provides the labels and sorter but does not provide a content provider
*
* @param parent
* @return TableViewer
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
index 093dae9d9..c3fd377a1 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
@@ -39,7 +39,6 @@ import com.ibm.icu.text.SimpleDateFormat;
public class GenericHistoryView extends PageBookView implements IHistoryView, IPropertyChangeListener, IShowInTarget {
-
private static final String HISTORY_VIEW_GROUP = "org.eclipse.team.ui.historyView"; //$NON-NLS-1$
private static final String NAVIGATION_GROUP = "org.eclipse.team.ui.navigation"; //$NON-NLS-1$
private static final int MAX_NAVIGATION_HISTORY_ENTRIES = 15;
@@ -70,12 +69,14 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
* The history adds the MRU to the end so basic navigation goes backwards.
*/
class NavigationHistory {
- List history = new ArrayList();
+ List<NavigationHistoryEntry> history = new ArrayList<>();
int position;
private boolean navigating;
+
public int size() {
return history.size();
}
+
public void gotoPreviousEntry() {
if (position > 0) {
position--;
@@ -85,6 +86,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
gotoEntry();
}
}
+
private void gotoEntry() {
try {
navigating = true;
@@ -94,9 +96,11 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
navigating = false;
}
}
+
private NavigationHistoryEntry getCurrentEntry() {
- return (NavigationHistoryEntry)history.get(position);
+ return history.get(position);
}
+
public void addEntry(Object object, String name, IHistoryPageSource source) {
if (!navigating) {
NavigationHistoryEntry navigationHistoryEntry = new NavigationHistoryEntry(object, name, source);
@@ -111,22 +115,27 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
}
navigateAction.update();
}
+
public NavigationHistoryEntry[] getEntries() {
- return (NavigationHistoryEntry[]) history.toArray(new NavigationHistoryEntry[history.size()]);
+ return history.toArray(new NavigationHistoryEntry[history.size()]);
}
+
private NavigationHistoryEntry getEntry(int i) {
- return (NavigationHistoryEntry)history.get(i);
+ return history.get(i);
}
+
public void gotoEntry(NavigationHistoryEntry navigationHistoryEntry) {
position = history.indexOf(navigationHistoryEntry);
gotoEntry();
}
+
public NavigationHistoryEntry getPreviousEntry() {
int next = position - 1;
if (next < 0)
next = size() - 1;
return getEntry(next);
}
+
public void updateName(IHistoryPage historyPage,
IHistoryPageSource pageSource) {
NavigationHistoryEntry[] historyEntries = getEntries();
@@ -143,11 +152,13 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
Object object;
String name;
IHistoryPageSource source;
+
public NavigationHistoryEntry(Object object, String name, IHistoryPageSource source) {
this.object = object;
this.name = name;
this.source = source;
}
+
@Override
public boolean equals(Object obj) {
if (obj instanceof NavigationHistoryEntry) {
@@ -156,11 +167,13 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
}
return false;
}
+
public boolean matches(IHistoryPage historyPage,
IHistoryPageSource pageSource) {
return object.equals(historyPage.getInput())
&& sameSource(source, pageSource);
}
+
@Override
public int hashCode() {
return object.hashCode();
@@ -169,6 +182,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
abstract class MenuCreator implements IMenuCreator {
private MenuManager menuManager;
+
@Override
public void dispose() {
if(menuManager != null) {
@@ -176,6 +190,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
menuManager = null;
}
}
+
@Override
public Menu getMenu(Control parent) {
Menu fMenu = null;
@@ -193,15 +208,19 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
}
return fMenu;
}
+
protected void updateMenuState() {
if (menuManager != null)
menuManager.update(true);
}
+
protected abstract IAction[] getDropDownActions();
+
@Override
public Menu getMenu(Menu parent) {
return null;
}
+
public void rebuildMenu() {
if(menuManager != null) {
menuManager.dispose();
@@ -224,23 +243,27 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
setMenuCreator(menuCreator);
update();
}
+
private IAction[] createActions() {
NavigationHistoryEntry[] entries = getDropDownEntries();
- List actions = new ArrayList();
+ List<NavigationHistoryEntryAction> actions = new ArrayList<NavigationHistoryEntryAction>();
for (int i = 0; i < entries.length; i++) {
NavigationHistoryEntry navigationHistoryEntry = entries[i];
actions.add(new NavigationHistoryEntryAction(navigationHistoryEntry));
}
- return (IAction[]) actions.toArray(new IAction[actions.size()]);
+ return actions.toArray(new IAction[actions.size()]);
}
+
protected NavigationHistoryEntry[] getDropDownEntries() {
return navigationHistory.getEntries();
}
+
@Override
public void run() {
navigationHistory.gotoPreviousEntry();
updateCheckState();
}
+
public void update() {
setEnabled(navigationHistory.size() > 1);
if (isEnabled()) {
@@ -252,6 +275,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
menuCreator.rebuildMenu();
updateCheckState();
}
+
private void updateCheckState() {
IAction[] actions = getActions();
for (int i = 0; i < actions.length; i++) {
@@ -263,9 +287,11 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
}
menuCreator.updateMenuState();
}
+
public void dispose() {
menuCreator.dispose();
}
+
private IAction[] getActions() {
if (actions == null)
actions = createActions();
@@ -274,18 +300,19 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
}
class NavigationHistoryEntryAction extends Action {
-
private final NavigationHistoryEntry navigationHistoryEntry;
public NavigationHistoryEntryAction(NavigationHistoryEntry navigationHistoryEntry) {
super(navigationHistoryEntry.name);
this.navigationHistoryEntry = navigationHistoryEntry;
}
+
@Override
public void run() {
navigationHistory.gotoEntry(navigationHistoryEntry);
navigateAction.updateCheckState();
}
+
public void update() {
setChecked(navigationHistory.getCurrentEntry() == navigationHistoryEntry);
}
@@ -320,7 +347,6 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
}
private ISelectionListener selectionListener = new ISelectionListener() {
-
private boolean isUpdatingSelection = false;
@Override
@@ -335,8 +361,8 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
if (selection instanceof IStructuredSelection) {
IStructuredSelection structSelection = (IStructuredSelection) selection;
- //Always take the first element - this is not intended to work with multiple selection
- //Also, hang on to this selection for future use in case the history view is not visible
+ // Always take the first element - this is not intended to work with multiple selection
+ // Also, hang on to this selection for future use in case the history view is not visible
lastSelectedElement = structSelection.getFirstElement();
if (!isLinkingEnabled() || !checkIfPageIsVisible()) {
@@ -349,19 +375,11 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
isUpdatingSelection = false;
}
}
-
};
private boolean linkingEnabled;
-
private boolean viewPinned;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.part.PageBookView#init(org.eclipse.ui.IViewSite)
- * @since 3.6.300
- */
@Override
public void init(IViewSite site) throws PartInitException {
super.init(site);
@@ -383,13 +401,13 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
this.linkingEnabled = TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_EDITOR_LINKING);
- //Contribute toolbars
+ // Contribute toolbars
configureToolbars(getViewSite().getActionBars());
- //add global action handler
+ // add global action handler
getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
- //initialize the drag and drop
+ // initialize the drag and drop
initDragAndDrop();
// add listener for selections
@@ -397,12 +415,11 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
}
private void configureToolbars(IActionBars actionBars) {
-
pinAction = new Action(TeamUIMessages.GenericHistoryView_PinCurrentHistory, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_PINNED)) {
@Override
public void run() {
if (isChecked()) {
- //uncheck editor linking
+ // uncheck editor linking
linkWithEditorAction.setChecked(false);
setLinkingEnabled(false);
}
@@ -438,7 +455,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
navigateAction = new NavigationHistoryAction();
Utils.initAction(navigateAction, "action.previousHistory."); //$NON-NLS-1$
- //Create the local tool bar
+ // Create the local tool bar
IToolBarManager tbm = actionBars.getToolBarManager();
tbm.add(new Separator(HISTORY_VIEW_GROUP));
tbm.appendToGroup(HISTORY_VIEW_GROUP, refreshAction);
@@ -467,7 +484,6 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
if (enabled) {
showLastSelectedElement();
}
-
}
/**
@@ -517,7 +533,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
showHistoryPageFor(lastSelectedElement, false, false, null);
}
- //reset lastSelectedElement to null to prevent updating history view if it just gets focus
+ // reset lastSelectedElement to null to prevent updating history view if it just gets focus
lastSelectedElement= null;
}
}
@@ -611,11 +627,11 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
return pageSource;
IResource resource = Utils.getResource(object);
if (resource == null) {
- return (IHistoryPageSource) Utils.getAdapter(object, IHistoryPageSource.class);
+ return Utils.getAdapter(object, IHistoryPageSource.class);
} else {
if (resource.getProject() == null)
return null;
- //check to see if resource is managed
+ // check to see if resource is managed
RepositoryProvider teamProvider = RepositoryProvider.getProvider(resource.getProject());
if (teamProvider == null){
// couldn't find a repository provider; try showing it in a local page
@@ -653,7 +669,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
}
private IHistoryPage checkForExistingPage(Object object, boolean refresh, boolean thisViewOnly, IHistoryPageSource pageSource) {
- //first check to see if the main history view contains the current resource
+ // first check to see if the main history view contains the current resource
IHistoryPage tempPage = checkForExistingPage(object, refresh, pageSource);
if (tempPage != null || thisViewOnly)
return tempPage;
@@ -664,7 +680,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
}
private IHistoryPage checkForExistingPage(Object object, boolean refresh, IHistoryPageSource pageSource) {
- //first check to see if the main history view contains the current resource
+ // first check to see if the main history view contains the current resource
if (getCurrentPage() != null) {
if (matches(getCurrentPage(), object, pageSource)) {
//current page contains object, so just refresh it
@@ -772,7 +788,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
protected void editorActivated(IEditorPart editor) {
lastSelectedElement= editor;
- //Only fetch contents if the view is shown in the current page.
+ // Only fetch contents if the view is shown in the current page.
if (editor == null || !isLinkingEnabled() || !checkIfPageIsVisible() || isViewPinned()) {
return;
}
@@ -782,7 +798,7 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
if (file != null) {
showHistory(file); /* don't fetch if already cached */
} else {
- //see if it adapts to an IHistoryPageSource
+ // see if it adapts to an IHistoryPageSource
Object pageSource = Utils.getAdapter(input, IHistoryPageSource.class);
if (pageSource != null)
showHistory(input);
@@ -815,9 +831,6 @@ public class GenericHistoryView extends PageBookView implements IHistoryView, IP
return (IHistoryPage) getCurrentPage();
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getSource() == getCurrentPage()) {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryViewDefaultPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryViewDefaultPage.java
index 3cc4e7f71..776f08a82 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryViewDefaultPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryViewDefaultPage.java
@@ -8,7 +8,6 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-
package org.eclipse.team.internal.ui.history;
import org.eclipse.jface.resource.JFaceColors;
@@ -19,7 +18,6 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.team.ui.history.HistoryPage;
public class GenericHistoryViewDefaultPage extends HistoryPage {
-
private Composite pgComp;
@Override
@@ -46,7 +44,7 @@ public class GenericHistoryViewDefaultPage extends HistoryPage {
@Override
public void refresh() {
- //nothing to refresh
+ // nothing to refresh
}
@Override
@@ -55,7 +53,7 @@ public class GenericHistoryViewDefaultPage extends HistoryPage {
}
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
@@ -74,5 +72,4 @@ public class GenericHistoryViewDefaultPage extends HistoryPage {
//no history to show
return false;
}
-
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/HistoryPageSourceWorkbenchPart.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/HistoryPageSourceWorkbenchPart.java
index ce9ed9685..b84208629 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/HistoryPageSourceWorkbenchPart.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/HistoryPageSourceWorkbenchPart.java
@@ -19,23 +19,16 @@ import org.eclipse.ui.*;
* Fake part to use in page book for the History view
*/
public class HistoryPageSourceWorkbenchPart implements IWorkbenchPart {
-
private Object object;
private IHistoryPageSource source;
private IWorkbenchPartSite site;
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
return (obj instanceof HistoryPageSourceWorkbenchPart) &&
source.equals(((HistoryPageSourceWorkbenchPart)obj).getSource());
}
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
@Override
public int hashCode() {
return source.hashCode();
@@ -57,78 +50,48 @@ public class HistoryPageSourceWorkbenchPart implements IWorkbenchPart {
this.site = site;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(org.eclipse.ui.IPropertyListener)
- */
@Override
public void addPropertyListener(IPropertyListener listener) {
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
@Override
public void createPartControl(Composite parent) {
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#dispose()
- */
@Override
public void dispose() {
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#getSite()
- */
@Override
public IWorkbenchPartSite getSite() {
return site;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#getTitle()
- */
@Override
public String getTitle() {
return ""; //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#getTitleImage()
- */
@Override
public Image getTitleImage() {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip()
- */
@Override
public String getTitleToolTip() {
return ""; //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(org.eclipse.ui.IPropertyListener)
- */
@Override
public void removePropertyListener(IPropertyListener listener) {
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#setFocus()
- */
@Override
public void setFocus() {
}
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java
index bc531e8a0..3789e14fa 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryPage.java
@@ -55,7 +55,6 @@ import com.ibm.icu.text.SimpleDateFormat;
import com.ibm.icu.util.Calendar;
public class LocalHistoryPage extends HistoryPage implements IHistoryCompareAdapter {
-
public static final int ON = 1;
public static final int OFF = 2;
public static final int ALWAYS = 4;
@@ -148,7 +147,7 @@ public class LocalHistoryPage extends HistoryPage implements IHistoryCompareAdap
if (element instanceof IFileRevision) {
entry = (IFileRevision) element;
} else if (element instanceof IAdaptable) {
- entry = (IFileRevision) ((IAdaptable) element).getAdapter(IFileRevision.class);
+ entry = ((IAdaptable) element).getAdapter(IFileRevision.class);
} else if (element instanceof AbstractHistoryCategory){
IFileRevision[] revisions = ((AbstractHistoryCategory) element).getRevisions();
if (revisions.length > 0)
@@ -374,12 +373,12 @@ public class LocalHistoryPage extends HistoryPage implements IHistoryCompareAdap
getContentsAction = getContextMenuAction(TeamUIMessages.LocalHistoryPage_GetContents, true /* needs progress */, new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(null, 100);
+ SubMonitor progress = SubMonitor.convert(monitor, 2);
try {
- if(confirmOverwrite()) {
- IStorage currentStorage = currentSelection.getStorage(new SubProgressMonitor(monitor, 50));
+ if (confirmOverwrite()) {
+ IStorage currentStorage = currentSelection.getStorage(progress.split(1));
InputStream in = currentStorage.getContents();
- (file).setContents(in, false, true, new SubProgressMonitor(monitor, 50));
+ file.setContents(in, false, true, progress.split(1));
}
} catch (TeamException e) {
throw new CoreException(e.getStatus());
@@ -597,9 +596,10 @@ public class LocalHistoryPage extends HistoryPage implements IHistoryCompareAdap
}
@Override
- public Object getAdapter(Class adapter) {
+ @SuppressWarnings("unchecked")
+ public <T> T getAdapter(Class<T> adapter) {
if(adapter == IHistoryCompareAdapter.class) {
- return this;
+ return (T) this;
}
return null;
}
@@ -826,17 +826,17 @@ public class LocalHistoryPage extends HistoryPage implements IHistoryCompareAdap
}
private Object[] mapExpandedElements(AbstractHistoryCategory[] categories, Object[] expandedElements) {
- //store the names of the currently expanded categories in a map
- HashMap elementMap = new HashMap();
- for (int i=0; i<expandedElements.length; i++){
- elementMap.put(((DateHistoryCategory)expandedElements[i]).getName(), null);
+ // Store the names of the currently expanded categories in a set.
+ HashSet<String> names = new HashSet<>();
+ for (int i = 0; i < expandedElements.length; i++){
+ names.add(((DateHistoryCategory) expandedElements[i]).getName());
}
//Go through the new categories and keep track of the previously expanded ones
- ArrayList expandable = new ArrayList();
- for (int i = 0; i<categories.length; i++){
- //check to see if this category is currently expanded
- if (elementMap.containsKey(categories[i].getName())){
+ ArrayList<AbstractHistoryCategory> expandable = new ArrayList<>();
+ for (int i = 0; i < categories.length; i++){
+ // Check to see if this category is currently expanded.
+ if (names.contains(categories[i].getName())){
expandable.add(categories[i]);
}
}
@@ -863,7 +863,7 @@ public class LocalHistoryPage extends HistoryPage implements IHistoryCompareAdap
//Everything before after week is previous
tempCategories[3] = new DateHistoryCategory(TeamUIMessages.HistoryPage_Previous, null, monthCal);
- ArrayList finalCategories = new ArrayList();
+ ArrayList<AbstractHistoryCategory> finalCategories = new ArrayList<AbstractHistoryCategory>();
for (int i = 0; i<tempCategories.length; i++){
tempCategories[i].collectFileRevisions(revisions, false);
if (tempCategories[i].hasRevisions())
@@ -875,7 +875,7 @@ public class LocalHistoryPage extends HistoryPage implements IHistoryCompareAdap
finalCategories.add(getErrorMessage());
}
- return (AbstractHistoryCategory[])finalCategories.toArray(new AbstractHistoryCategory[finalCategories.size()]);
+ return finalCategories.toArray(new AbstractHistoryCategory[finalCategories.size()]);
} finally {
monitor.done();
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java
index c6d484e4d..558ae8f58 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/LocalHistoryTableProvider.java
@@ -32,21 +32,19 @@ import org.eclipse.ui.themes.ITheme;
import com.ibm.icu.text.DateFormat;
public class LocalHistoryTableProvider {
-
/* private */ static final int COL_DATE = 0;
/* private */ TreeViewer viewer;
- private Image localRevImage = null;
+ private Image localRevImage;
private DateFormat dateFormat;
/**
* The Local history label provider.
*/
private class LocalHistoryLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider, IFontProvider {
-
- private Image dateImage = null;
- private Font currentRevisionFont = null;
+ private Image dateImage;
+ private Font currentRevisionFont;
private IPropertyChangeListener themeListener = new IPropertyChangeListener() {
@Override
@@ -55,8 +53,8 @@ public class LocalHistoryTableProvider {
}
};
- public LocalHistoryLabelProvider(){
- PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(themeListener);
+ public LocalHistoryLabelProvider() {
+ PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(themeListener);
}
@Override
@@ -115,9 +113,6 @@ public class LocalHistoryTableProvider {
return ""; //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
@Override
public Color getForeground(Object element) {
if (element instanceof AbstractHistoryCategory){
@@ -133,18 +128,11 @@ public class LocalHistoryTableProvider {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
- */
@Override
public Color getBackground(Object element) {
return null;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
- */
@Override
public Font getFont(Object element) {
if (element instanceof AbstractHistoryCategory) {
@@ -318,7 +306,7 @@ public class LocalHistoryTableProvider {
}
protected long getModificationDate(Object element) {
- IModificationDate md = (IModificationDate)Utils.getAdapter(element, IModificationDate.class);
+ IModificationDate md = Utils.getAdapter(element, IModificationDate.class);
if (md != null)
return md.getModificationDate();
if (element instanceof IFileState) {

Back to the top