diff options
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal')
179 files changed, 8016 insertions, 8016 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AddToVersionControlDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AddToVersionControlDialog.java index 3e5499027..ec34ce9b9 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AddToVersionControlDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AddToVersionControlDialog.java @@ -57,7 +57,7 @@ public class AddToVersionControlDialog extends DetailsDialog { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - + // add a description label if (unaddedResources.length==1) { createWrappingLabel(composite, NLS.bind(CVSUIMessages.AddToVersionControlDialog_thereIsAnUnaddedResource, new String[] { Integer.valueOf(unaddedResources.length).toString() })); @@ -66,10 +66,10 @@ public class AddToVersionControlDialog extends DetailsDialog { } } - @Override + @Override protected String getHelpContextId() { - return IHelpContextIds.ADD_TO_VERSION_CONTROL_DIALOG; - } + return IHelpContextIds.ADD_TO_VERSION_CONTROL_DIALOG; + } @Override protected Composite createDropDownDialogArea(Composite parent) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AlternateUserValidationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AlternateUserValidationDialog.java index 27f85d95d..647d18e14 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AlternateUserValidationDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/AlternateUserValidationDialog.java @@ -144,7 +144,7 @@ public class AlternateUserValidationDialog extends Dialog { data.widthHint = 70; b.setLayoutData(data); b.addListener(SWT.Selection, event -> cancelPressed()); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); return main; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java index 0727d9a56..029e7ed15 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java @@ -48,7 +48,7 @@ public class CVSCompareEditorInput extends CompareEditorInput { private static final int NODE_UNKNOWN = 2; String toolTipText; - private String title; + private String title; /** * Creates a new CVSCompareEditorInput. @@ -412,52 +412,52 @@ public class CVSCompareEditorInput extends CompareEditorInput { setLabels(cc, event.getStructuredSelection()); }); ((StructuredViewer)viewer).addOpenListener(event -> { - ISelection selection = event.getSelection(); - if (! selection.isEmpty() && selection instanceof IStructuredSelection) { - Object o = ((IStructuredSelection)selection).getFirstElement(); - if (o instanceof DiffNode) { - updateLabelsFor((DiffNode)o); - } - } + ISelection selection = event.getSelection(); + if (! selection.isEmpty() && selection instanceof IStructuredSelection) { + Object o = ((IStructuredSelection)selection).getFirstElement(); + if (o instanceof DiffNode) { + updateLabelsFor((DiffNode)o); + } + } }); - ((StructuredViewer)viewer).addDoubleClickListener(event -> { - ISelection selection = event.getSelection(); - if (! selection.isEmpty() && selection instanceof IStructuredSelection) { - Object o = ((IStructuredSelection)selection).getFirstElement(); - if (o instanceof DiffNode) { - DiffNode diffNode = ((DiffNode)o); - if (diffNode.hasChildren()) { - AbstractTreeViewer atv = ((AbstractTreeViewer)viewer); - atv.setExpandedState(o, !atv.getExpandedState(o)); - } - } - } + ((StructuredViewer)viewer).addDoubleClickListener(event -> { + ISelection selection = event.getSelection(); + if (! selection.isEmpty() && selection instanceof IStructuredSelection) { + Object o = ((IStructuredSelection)selection).getFirstElement(); + if (o instanceof DiffNode) { + DiffNode diffNode = ((DiffNode)o); + if (diffNode.hasChildren()) { + AbstractTreeViewer atv = ((AbstractTreeViewer)viewer); + atv.setExpandedState(o, !atv.getExpandedState(o)); + } + } + } }); return viewer; } /* * Update the labels for the given DiffNode - */ - protected void updateLabelsFor(DiffNode node) { - CompareConfiguration cc = getCompareConfiguration(); - ITypedElement l = node.getLeft(); - if (l == null) { - cc.setLeftLabel(CVSUIMessages.CVSCompareEditorInput_0); - cc.setLeftImage(null); - } else { - cc.setLeftLabel(getLabel(l)); - cc.setLeftImage(l.getImage()); - } - ITypedElement r = node.getRight(); - if (r == null) { - cc.setRightLabel(CVSUIMessages.CVSCompareEditorInput_1); - cc.setRightImage(null); - } else { - cc.setRightLabel(getLabel(r)); - cc.setRightImage(r.getImage()); - } - } + */ + protected void updateLabelsFor(DiffNode node) { + CompareConfiguration cc = getCompareConfiguration(); + ITypedElement l = node.getLeft(); + if (l == null) { + cc.setLeftLabel(CVSUIMessages.CVSCompareEditorInput_0); + cc.setLeftImage(null); + } else { + cc.setLeftLabel(getLabel(l)); + cc.setLeftImage(l.getImage()); + } + ITypedElement r = node.getRight(); + if (r == null) { + cc.setRightLabel(CVSUIMessages.CVSCompareEditorInput_1); + cc.setRightImage(null); + } else { + cc.setRightLabel(getLabel(r)); + cc.setRightImage(r.getImage()); + } + } @Override public String getToolTipText() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java index 93241c352..06fbde3e5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java @@ -271,14 +271,14 @@ public class CVSDecoration { bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, location.getRootDirectory()); bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, repository); - RepositoryManager repositoryManager = CVSUIPlugin.getPlugin().getRepositoryManager(); - RepositoryRoot root = repositoryManager.getRepositoryRootFor(location); - CVSUIPlugin.getPlugin().getRepositoryManager(); - String label = root.getName(); - if (label == null) { - label = location.getLocation(true); - } - bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_LABEL, label); + RepositoryManager repositoryManager = CVSUIPlugin.getPlugin().getRepositoryManager(); + RepositoryRoot root = repositoryManager.getRepositoryRootFor(location); + CVSUIPlugin.getPlugin().getRepositoryManager(); + String label = root.getName(); + if (label == null) { + label = location.getLocation(true); + } + bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_LABEL, label); } CVSDecoratorConfiguration.decorate(this, getTextFormatter(), bindings); } @@ -446,9 +446,9 @@ public class CVSDecoration { public void setStateFlags(int stateFlags) { this.stateFlags = stateFlags; - if ((stateFlags & IThreeWayDiff.OUTGOING) != 0) { - setDirty(true); - } + if ((stateFlags & IThreeWayDiff.OUTGOING) != 0) { + setDirty(true); + } } public TeamStateDescription asTeamStateDescription(String[] properties) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java index 15c6caac1..3ecbab3a8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java @@ -344,8 +344,8 @@ public class CVSDecoratorPreferencesPage extends PreferencePage implements IWork final Composite composite= SWTUtils.createHFillComposite(parent, SWTUtils.MARGINS_DEFAULT); Dialog.applyDialogFont(composite); - SWTUtils.createPreferenceLink((IWorkbenchPreferenceContainer) getContainer(), composite, CVSUIMessages.CVSDecoratorPreferencesPage_36, CVSUIMessages.CVSDecoratorPreferencesPage_37); - + SWTUtils.createPreferenceLink((IWorkbenchPreferenceContainer) getContainer(), composite, CVSUIMessages.CVSDecoratorPreferencesPage_36, CVSUIMessages.CVSDecoratorPreferencesPage_37); + fShowDirty= SWTUtils.createCheckBox(composite, CVSUIMessages.CVSDecoratorPreferencesPage_16); SWTUtils.createLabel(composite, CVSUIMessages.CVSDecoratorPreferencesPage_17); @@ -407,7 +407,7 @@ public class CVSDecoratorPreferencesPage extends PreferencePage implements IWork private final TreeViewer fViewer; public Preview(Composite composite) { - SWTUtils.createLabel(composite, CVSUIMessages.CVSDecoratorPreferencesPage_39); + SWTUtils.createLabel(composite, CVSUIMessages.CVSDecoratorPreferencesPage_39); fImageCache= new LocalResourceManager(JFaceResources.getResources()); fViewer = new TreeViewer(composite); fViewer.getControl().setLayoutData(SWTUtils.createHVFillGridData()); @@ -472,7 +472,7 @@ public class CVSDecoratorPreferencesPage extends PreferencePage implements IWork @Override public void dispose() { - fImageCache.dispose(); + fImageCache.dispose(); } @Override @@ -528,11 +528,11 @@ public class CVSDecoratorPreferencesPage extends PreferencePage implements IWork if (overlay == null) return baseImage; try { - return fImageCache.createImage(new DecorationOverlayIcon(baseImage, overlay, IDecoration.BOTTOM_RIGHT)); - } catch (DeviceResourceException e) { - CVSUIPlugin.log(new Status(IStatus.ERROR, CVSUIPlugin.ID, 0, "Error creating decorator image", e)); //$NON-NLS-1$ - } - return null; + return fImageCache.createImage(new DecorationOverlayIcon(baseImage, overlay, IDecoration.BOTTOM_RIGHT)); + } catch (DeviceResourceException e) { + CVSUIPlugin.log(new Status(IStatus.ERROR, CVSUIPlugin.ID, 0, "Error creating decorator image", e)); //$NON-NLS-1$ + } + return null; } } @@ -570,7 +570,7 @@ public class CVSDecoratorPreferencesPage extends PreferencePage implements IWork FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_USER, CVSUIMessages.CVSDecoratorPreferencesPage_32); FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, CVSUIMessages.CVSDecoratorPreferencesPage_33); FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, CVSUIMessages.CVSDecoratorPreferencesPage_34); - FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_LABEL, CVSUIMessages.CVSDecoratorPreferencesPage_38); + FOLDER_BINDINGS.put(CVSDecoratorConfiguration.REMOTELOCATION_LABEL, CVSUIMessages.CVSDecoratorPreferencesPage_38); FOLDER_BINDINGS.put(CVSDecoratorConfiguration.NEW_DIRTY_FLAG, CVSUIMessages.CVSDecoratorPreferencesPage_35); final PreviewFile project= new PreviewFile("Project", IResource.PROJECT, false, false, false, false, true, null, "v1_0"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -617,7 +617,7 @@ public class CVSDecoratorPreferencesPage extends PreferencePage implements IWork fGeneralTab.addObserver(fPreview); initializeValues(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.DECORATORS_PREFERENCE_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.DECORATORS_PREFERENCE_PAGE); Dialog.applyDialogFont(parent); PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(fThemeListener= new ThemeListener(fPreview)); @@ -629,8 +629,8 @@ public class CVSDecoratorPreferencesPage extends PreferencePage implements IWork public void dispose() { if (fThemeListener != null) PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(fThemeListener); - if (fPreview != null) - fPreview.dispose(); + if (fPreview != null) + fPreview.dispose(); } /** @@ -660,10 +660,10 @@ public class CVSDecoratorPreferencesPage extends PreferencePage implements IWork fTextTab.performOk(store); fIconTab.performOk(store); fGeneralTab.performOk(store); - if (store.needsSaving()) { - CVSUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, CVSUIPlugin.P_DECORATORS_CHANGED, null, null)); - CVSUIPlugin.getPlugin().savePluginPreferences(); - } + if (store.needsSaving()) { + CVSUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, CVSUIPlugin.P_DECORATORS_CHANGED, null, null)); + CVSUIPlugin.getPlugin().savePluginPreferences(); + } return true; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java index 20de8a4c2..751b529bc 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFolderPropertiesPage.java @@ -106,8 +106,8 @@ public class CVSFolderPropertiesPage extends CVSPropertiesPage { // Display error text createLabel(composite, CVSUIMessages.CVSFilePropertiesPage_error, 2); } - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.FOLDER_PROPERTY_PAGE); - Dialog.applyDialogFont(parent); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.FOLDER_PROPERTY_PAGE); + Dialog.applyDialogFont(parent); return composite; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java index 52163627b..5b2485847 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java @@ -305,30 +305,30 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC } private TextViewer createText(SashForm parent) { - SourceViewer result = new SourceViewer(parent, null, null, true, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY); - result.getTextWidget().setIndent(2); - result.configure(new TextSourceViewerConfiguration(EditorsUI.getPreferenceStore()) { - @Override + SourceViewer result = new SourceViewer(parent, null, null, true, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY); + result.getTextWidget().setIndent(2); + result.configure(new TextSourceViewerConfiguration(EditorsUI.getPreferenceStore()) { + @Override protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) { - return Collections.singletonMap("org.eclipse.ui.DefaultTextEditor", //$NON-NLS-1$ - new IAdaptable() { - @Override + return Collections.singletonMap("org.eclipse.ui.DefaultTextEditor", //$NON-NLS-1$ + new IAdaptable() { + @Override public <T> T getAdapter(Class<T> adapter) { - if(adapter==IFile.class && getInput() instanceof IFile) { - return adapter.cast(getInput()); - } else if(adapter==IFileHistory.class && getInput() instanceof IFileHistory) { - return adapter.cast(getInput()); - } - return Platform.getAdapterManager().getAdapter(CVSHistoryPage.this, adapter); - } - }); - } - }); - - result.addSelectionChangedListener(event -> copyAction.update()); - result.setTextDoubleClickStrategy( - new DefaultTextDoubleClickStrategy(), - IDocument.DEFAULT_CONTENT_TYPE); + if(adapter==IFile.class && getInput() instanceof IFile) { + return adapter.cast(getInput()); + } else if(adapter==IFileHistory.class && getInput() instanceof IFileHistory) { + return adapter.cast(getInput()); + } + return Platform.getAdapterManager().getAdapter(CVSHistoryPage.this, adapter); + } + }); + } + }); + + result.addSelectionChangedListener(event -> copyAction.update()); + result.setTextDoubleClickStrategy( + new DefaultTextDoubleClickStrategy(), + IDocument.DEFAULT_CONTENT_TYPE); result.activatePlugins(); return result; } @@ -380,10 +380,10 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC CVSTag tag1 = (CVSTag) e1; CVSTag tag2 = (CVSTag) e2; int type1 = tag1.getType(); - int type2 = tag2.getType(); - if (type1 != type2) { - return type2 - type1; - } + int type2 = tag2.getType(); + if (type1 != type2) { + return type2 - type1; + } if (sortTagsAscending) return super.compare(viewer, tag1, tag2); else @@ -591,7 +591,7 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC monitor.done(); } }); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getContentsAction, IHelpContextIds.GET_FILE_CONTENTS_ACTION); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getContentsAction, IHelpContextIds.GET_FILE_CONTENTS_ACTION); getRevisionAction = getContextMenuAction(CVSUIMessages.HistoryView_getRevisionAction, true /* needs progress */, monitor -> { ICVSRemoteFile remoteFile = (ICVSRemoteFile) CVSWorkspaceRoot.getRemoteResourceFor(((CVSFileRevision) currentSelection).getCVSRemoteFile()); @@ -616,7 +616,7 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC // Cancelled by user } }); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getRevisionAction, IHelpContextIds.GET_FILE_REVISION_ACTION); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getRevisionAction, IHelpContextIds.GET_FILE_REVISION_ACTION); // Override MoveRemoteTagAction to work for log entries final IActionDelegate tagActionDelegate = new MoveRemoteTagAction() { @@ -651,31 +651,31 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC } return resources; } - /* - * Override the creation of the tag operation in order to support - * the refresh of the view after the tag operation completes - */ - @Override + /* + * Override the creation of the tag operation in order to support + * the refresh of the view after the tag operation completes + */ + @Override protected ITagOperation createTagOperation() { - return new TagInRepositoryOperation(getTargetPart(), getSelectedRemoteResources()) { - @Override + return new TagInRepositoryOperation(getTargetPart(), getSelectedRemoteResources()) { + @Override public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - super.execute(monitor); - Display.getDefault().asyncExec(() -> { - if( ! wasCancelled()) { - refresh(); - } + super.execute(monitor); + Display.getDefault().asyncExec(() -> { + if( ! wasCancelled()) { + refresh(); + } }); - }; - }; - } + }; + }; + } }; tagWithExistingAction = getContextMenuAction(CVSUIMessages.HistoryView_tagWithExistingAction, false /* no progress */, monitor -> { tagActionDelegate.selectionChanged(tagWithExistingAction, treeViewer.getSelection()); tagActionDelegate.run(tagWithExistingAction); }); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getRevisionAction, IHelpContextIds.TAG_WITH_EXISTING_ACTION); - + PlatformUI.getWorkbench().getHelpSystem().setHelp(getRevisionAction, IHelpContextIds.TAG_WITH_EXISTING_ACTION); + // Toggle text visible action toggleTextAction = new Action(TeamUIMessages.GenericHistoryView_ShowCommentViewer) { @Override @@ -717,7 +717,7 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC store.setValue(ICVSUIConstants.PREF_SHOW_SEARCH, toggleSearchAction.isChecked()); if (!toggleSearchAction.isChecked()){ if (searchFilter != null) - treeViewer.removeFilter(searchFilter); + treeViewer.removeFilter(searchFilter); } else { searchField.setMessage(CVSUIMessages.CVSHistoryPage_EnterSearchTerm); searchField.selectAll(); @@ -863,7 +863,7 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC manager.add(new Separator("openCompare")); //$NON-NLS-1$ } if (file != null && - !(file instanceof RemoteFile)) { + !(file instanceof RemoteFile)) { // Add the "Add to Workspace" action if 1 revision is selected. ISelection sel = treeViewer.getSelection(); if (!sel.isEmpty()) { @@ -1416,8 +1416,8 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC String searchString = searchField.getText(); if (searchString.equals("") || //$NON-NLS-1$ searchString.equals(CVSUIMessages.CVSHistoryPage_EnterSearchTerm)) { - if (searchFilter != null) - treeViewer.removeFilter(searchFilter); + if (searchFilter != null) + treeViewer.removeFilter(searchFilter); return; } @@ -1698,7 +1698,7 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC message = CVSUIMessages.CVSHistoryPage_NoRevisions; break; } - + MessageHistoryCategory messageCategory = new MessageHistoryCategory(NLS.bind(CVSUIMessages.CVSHistoryPage_NoRevisionsForMode, new String[] { message })); return messageCategory; } @@ -1746,7 +1746,7 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC //Safety check for non-managed files that are added with the CVSHistoryPage //in view if (file == null || file.getIResource() == null) - return; + return; IResourceDelta resourceDelta = root.findMember(((IFile)file.getIResource()).getFullPath()); if (resourceDelta != null){ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryTableProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryTableProvider.java index 39993dfcb..b888c3eb6 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryTableProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryTableProvider.java @@ -726,8 +726,8 @@ public class CVSHistoryTableProvider { treeViewer.getTree().setSortDirection(oldSorter.isReversed() ? SWT.DOWN : SWT.UP); treeViewer.refresh(); } else { - treeViewer.getTree().setSortColumn(treeColumn); - treeViewer.getTree().setSortDirection(SWT.UP); + treeViewer.getTree().setSortColumn(treeColumn); + treeViewer.getTree().setSortDirection(SWT.UP); treeViewer.setComparator(new HistoryComparator(column)); } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java index 1b72d8a43..9a7f7608c 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java @@ -166,12 +166,12 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig } catch(CoreException e) { handleException(element, e); } catch (IllegalStateException e) { - // This is thrown by Core if the workspace is in an illegal state - // If we are not active, ignore it. Otherwise, propagate it. - // (see bug 78303) - if (Platform.getBundle(CVSUIPlugin.ID).getState() == Bundle.ACTIVE) { - throw e; - } + // This is thrown by Core if the workspace is in an illegal state + // If we are not active, ignore it. Otherwise, propagate it. + // (see bug 78303) + if (Platform.getBundle(CVSUIPlugin.ID).getState() == Bundle.ACTIVE) { + throw e; + } } } @@ -185,29 +185,29 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig /* * Return whether any of the projects of the mapping are mapped to CVS */ - private boolean isMappedToCVS(ResourceMapping mapping) { - IProject[] projects = mapping.getProjects(); - boolean foundOne = false; - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - if (project != null) { - RepositoryProvider provider = RepositoryProvider.getProvider(project); + private boolean isMappedToCVS(ResourceMapping mapping) { + IProject[] projects = mapping.getProjects(); + boolean foundOne = false; + for (int i = 0; i < projects.length; i++) { + IProject project = projects[i]; + if (project != null) { + RepositoryProvider provider = RepositoryProvider.getProvider(project); if (provider instanceof CVSTeamProvider) { foundOne = true; - } else if (provider != null) { - return false; - } - } - } - return foundOne; - } - - public static CVSDecoration decorate(Object element, SynchronizationStateTester tester) throws CoreException { - IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); - CVSDecoration result = new CVSDecoration(); - - // First, decorate the synchronization state - int state = IDiff.NO_CHANGE; + } else if (provider != null) { + return false; + } + } + } + return foundOne; + } + + public static CVSDecoration decorate(Object element, SynchronizationStateTester tester) throws CoreException { + IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); + CVSDecoration result = new CVSDecoration(); + + // First, decorate the synchronization state + int state = IDiff.NO_CHANGE; if (isSupervised(element)) { // TODO: Not quite right result.setHasRemote(true); @@ -217,9 +217,9 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig : 0, new NullProgressMonitor()); result.setStateFlags(state); - } else { - result.setIgnored(true); - } + } else { + result.setIgnored(true); + } // Tag if (!result.isIgnored()) { CVSTag tag = getTagToShow(element); @@ -243,9 +243,9 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig decorate(resource, result); } tester.elementDecorated(element, result.asTeamStateDescription(null)); - return result; - } - + return result; + } + private static boolean isSupervised(Object element) throws CoreException { IResource[] resources = getTraversalRoots(element); for (int i = 0; i < resources.length; i++) { @@ -342,13 +342,13 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig } if (!cvsDecoration.isIgnored()) { // Dirty - if (includeDirtyCheck) { - boolean computeDeepDirtyCheck = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY); - int type = resource.getType(); - if (type == IResource.FILE || computeDeepDirtyCheck) { - cvsDecoration.setDirty(CVSLightweightDecorator.isDirty(resource)); - } - } + if (includeDirtyCheck) { + boolean computeDeepDirtyCheck = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY); + int type = resource.getType(); + if (type == IResource.FILE || computeDeepDirtyCheck) { + cvsDecoration.setDirty(CVSLightweightDecorator.isDirty(resource)); + } + } } decorate(resource, cvsDecoration); return cvsDecoration; @@ -462,7 +462,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig /* * Add resource and its parents to the List */ - + private void addWithParents(IResource resource, Set resources) { IResource current = resource; @@ -482,7 +482,7 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig /* * Update the decorators for every resource in project */ - + public void refresh(IProject project) { final List resources = new ArrayList(); try { @@ -597,22 +597,22 @@ public class CVSLightweightDecorator extends LabelProvider implements ILightweig public void propertyChange(PropertyChangeEvent event) { if (isEventOfInterest(event)) { ensureFontAndColorsCreated(fonts, colors); - refresh(); + refresh(); } } - private boolean isEventOfInterest(PropertyChangeEvent event) { - String prop = event.getProperty(); - return prop.equals(TeamUI.GLOBAL_IGNORES_CHANGED) - || prop.equals(TeamUI.GLOBAL_FILE_TYPES_CHANGED) - || prop.equals(CVSUIPlugin.P_DECORATORS_CHANGED) + private boolean isEventOfInterest(PropertyChangeEvent event) { + String prop = event.getProperty(); + return prop.equals(TeamUI.GLOBAL_IGNORES_CHANGED) + || prop.equals(TeamUI.GLOBAL_FILE_TYPES_CHANGED) + || prop.equals(CVSUIPlugin.P_DECORATORS_CHANGED) || prop.equals(CVSDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR) || prop.equals(CVSDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR) || prop.equals(CVSDecoratorConfiguration.OUTGOING_CHANGE_FONT) || prop.equals(CVSDecoratorConfiguration.IGNORED_FOREGROUND_COLOR) || prop.equals(CVSDecoratorConfiguration.IGNORED_BACKGROUND_COLOR) || prop.equals(CVSDecoratorConfiguration.IGNORED_FONT); - } + } private static CVSWorkspaceSubscriber getSubscriber() { return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPerspective.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPerspective.java index 755071061..7c234e2b1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPerspective.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPerspective.java @@ -20,7 +20,7 @@ import org.eclipse.ui.*; public class CVSPerspective implements IPerspectiveFactory { - + public final static String ID = "org.eclipse.team.cvs.ui.cvsPerspective"; //$NON-NLS-1$ @Override diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java index 0156e8466..ea9a9140a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPreferencesPage.java @@ -65,7 +65,7 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref return 0; } } - + private abstract class Field { protected final String fKey; @@ -86,7 +86,7 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref super(key); fCheckbox= new Button(composite, SWT.CHECK); fCheckbox.setText(label); - PlatformUI.getWorkbench().getHelpSystem().setHelp(fCheckbox, helpID); + PlatformUI.getWorkbench().getHelpSystem().setHelp(fCheckbox, helpID); } public void initializeValue(IPreferenceStore store) { @@ -117,7 +117,7 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref label.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, false, false)); } - PlatformUI.getWorkbench().getHelpSystem().setHelp(fCombo, helpID); + PlatformUI.getWorkbench().getHelpSystem().setHelp(fCombo, helpID); } public Combo getCombo() { @@ -191,16 +191,16 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref fButtons[i].setText(labels[i]); } SWTUtils.equalizeControls(SWTUtils.createDialogPixelConverter(composite), fButtons, 0, fButtons.length - 2); - PlatformUI.getWorkbench().getHelpSystem().setHelp(fGroup, helpID); + PlatformUI.getWorkbench().getHelpSystem().setHelp(fGroup, helpID); } public void initializeValue(IPreferenceStore store) { final Object value= loadValue(store, fKey); final int index= fValues.indexOf(value); - for (int i = 0; i < fButtons.length; i++) { - Button b = fButtons[i]; - b.setSelection(index == i); - } + for (int i = 0; i < fButtons.length; i++) { + Button b = fButtons[i]; + b.setSelection(index == i); + } } public void performOk(IPreferenceStore store) { @@ -258,10 +258,10 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref label.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, false, false)); fText= SWTUtils.createText(composite); - fText.addModifyListener(this); + fText.addModifyListener(this); - if (helpID != null) - PlatformUI.getWorkbench().getHelpSystem().setHelp(fText, helpID); + if (helpID != null) + PlatformUI.getWorkbench().getHelpSystem().setHelp(fText, helpID); } public void initializeValue(IPreferenceStore store) { @@ -273,10 +273,10 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref store.setValue(fKey, fText.getText()); } - public void modifyText(ModifyEvent e) { - modifyText(fText); - } - + public void modifyText(ModifyEvent e) { + modifyText(fText); + } + protected abstract void modifyText(Text text); } @@ -334,9 +334,9 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref COMPRESSION_VALUES[i]= Integer.valueOf(i); } - final IPerspectiveDescriptor [] perspectives= PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives(); - PERSPECTIVE_VALUES= new String[perspectives.length + 1]; - PERSPECTIVE_LABELS= new String [perspectives.length + 1]; + final IPerspectiveDescriptor [] perspectives= PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives(); + PERSPECTIVE_VALUES= new String[perspectives.length + 1]; + PERSPECTIVE_LABELS= new String [perspectives.length + 1]; Arrays.sort(perspectives, new PerspectiveDescriptorComparator()); PERSPECTIVE_VALUES[0]= ICVSUIConstants.OPTION_NO_PERSPECTIVE; PERSPECTIVE_LABELS[0]= CVSUIMessages.CVSPreferencesPage_10; @@ -363,7 +363,7 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref Dialog.applyDialogFont(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.GENERAL_PREFERENCE_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.GENERAL_PREFERENCE_PAGE); return tabFolder; } @@ -376,54 +376,54 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref new Checkbox(composite, ICVSUIConstants.PREF_CONFIRM_MOVE_TAG, CVSUIMessages.CVSPreferencesPage_16, IHelpContextIds.PREF_CONFIRM_MOVE_TAG); new Checkbox(composite, ICVSUIConstants.PREF_DEBUG_PROTOCOL, CVSUIMessages.CVSPreferencesPage_17, IHelpContextIds.PREF_DEBUG_PROTOCOL); new Checkbox(composite, ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, CVSUIMessages.CVSPreferencesPage_18, IHelpContextIds.PREF_AUTOREFRESH_TAG); - new Checkbox(composite, ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, CVSUIMessages.CVSPreferencesPage_44, null); - new Checkbox(composite, ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, CVSUIMessages.CVSPreferencesPage_45, null); - - final Composite textComposite= SWTUtils.createHFillComposite(composite, SWTUtils.MARGINS_NONE, 2); - new TextField( - textComposite, - ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, - CVSUIMessages.CVSPreferencesPage_20, - null) { - protected void modifyText(Text text) { - // Parse the timeout value - try { - final int x = Integer.parseInt(text.getText()); - if (x >= 0) { - setErrorMessage(null); - setValid(true); - } else { - setErrorMessage(CVSUIMessages.CVSPreferencesPage_21); - setValid(false); - } - } catch (NumberFormatException ex) { - setErrorMessage(CVSUIMessages.CVSPreferencesPage_22); - setValid(false); - } - } - }; - new TextField( - textComposite, - ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY, - CVSUIMessages.CVSPreferencesPage_47, - null) { - protected void modifyText(Text text) { - try { - final int x = Integer.parseInt(text.getText()); - if (x > 0) { - setErrorMessage(null); - setValid(true); - } else { - setErrorMessage(CVSUIMessages.CVSPreferencesPage_48); - setValid(false); - } - } catch (NumberFormatException ex) { - setErrorMessage(CVSUIMessages.CVSPreferencesPage_49); - setValid(false); - } - } - }; - + new Checkbox(composite, ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, CVSUIMessages.CVSPreferencesPage_44, null); + new Checkbox(composite, ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, CVSUIMessages.CVSPreferencesPage_45, null); + + final Composite textComposite= SWTUtils.createHFillComposite(composite, SWTUtils.MARGINS_NONE, 2); + new TextField( + textComposite, + ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, + CVSUIMessages.CVSPreferencesPage_20, + null) { + protected void modifyText(Text text) { + // Parse the timeout value + try { + final int x = Integer.parseInt(text.getText()); + if (x >= 0) { + setErrorMessage(null); + setValid(true); + } else { + setErrorMessage(CVSUIMessages.CVSPreferencesPage_21); + setValid(false); + } + } catch (NumberFormatException ex) { + setErrorMessage(CVSUIMessages.CVSPreferencesPage_22); + setValid(false); + } + } + }; + new TextField( + textComposite, + ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY, + CVSUIMessages.CVSPreferencesPage_47, + null) { + protected void modifyText(Text text) { + try { + final int x = Integer.parseInt(text.getText()); + if (x > 0) { + setErrorMessage(null); + setValid(true); + } else { + setErrorMessage(CVSUIMessages.CVSPreferencesPage_48); + setValid(false); + } + } catch (NumberFormatException ex) { + setErrorMessage(CVSUIMessages.CVSPreferencesPage_49); + setValid(false); + } + } + }; + return composite; } @@ -531,37 +531,37 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref ICVSUIConstants.PREF_SAVE_DIRTY_EDITORS, CVSUIMessages.CVSPreferencesPage_41, IHelpContextIds.PREF_SAVE_DIRTY_EDITORS, - YES_NO_PROMPT, - new Integer [] { Integer.valueOf(ICVSUIConstants.OPTION_AUTOMATIC), Integer.valueOf(ICVSUIConstants.OPTION_NEVER), Integer.valueOf(ICVSUIConstants.OPTION_PROMPT)}); - - new StringRadioButtons( - composite, - ICVSUIConstants.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT, - CVSUIMessages.CVSPreferencesPage_46, - IHelpContextIds.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT, - YES_NO_PROMPT, - new String [] { MessageDialogWithToggle.ALWAYS, MessageDialogWithToggle.NEVER, MessageDialogWithToggle.PROMPT } - ); - - new StringRadioButtons( - composite, - ICVSUIConstants.PREF_ALLOW_COMMIT_WITH_WARNINGS, - CVSUIMessages.CVSPreferencesPage_50, - IHelpContextIds.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT, - YES_NO_PROMPT, - new String [] { MessageDialogWithToggle.ALWAYS, MessageDialogWithToggle.NEVER, MessageDialogWithToggle.PROMPT } - ); + YES_NO_PROMPT, + new Integer [] { Integer.valueOf(ICVSUIConstants.OPTION_AUTOMATIC), Integer.valueOf(ICVSUIConstants.OPTION_NEVER), Integer.valueOf(ICVSUIConstants.OPTION_PROMPT)}); + + new StringRadioButtons( + composite, + ICVSUIConstants.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT, + CVSUIMessages.CVSPreferencesPage_46, + IHelpContextIds.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT, + YES_NO_PROMPT, + new String [] { MessageDialogWithToggle.ALWAYS, MessageDialogWithToggle.NEVER, MessageDialogWithToggle.PROMPT } + ); + + new StringRadioButtons( + composite, + ICVSUIConstants.PREF_ALLOW_COMMIT_WITH_WARNINGS, + CVSUIMessages.CVSPreferencesPage_50, + IHelpContextIds.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT, + YES_NO_PROMPT, + new String [] { MessageDialogWithToggle.ALWAYS, MessageDialogWithToggle.NEVER, MessageDialogWithToggle.PROMPT } + ); - new StringRadioButtons( - composite, - ICVSUIConstants.PREF_ALLOW_COMMIT_WITH_ERRORS, - CVSUIMessages.CVSPreferencesPage_51, - IHelpContextIds.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT, - YES_NO_PROMPT, - new String [] { MessageDialogWithToggle.ALWAYS, MessageDialogWithToggle.NEVER, MessageDialogWithToggle.PROMPT } - ); - SWTUtils.createPlaceholder(composite, 1); - + new StringRadioButtons( + composite, + ICVSUIConstants.PREF_ALLOW_COMMIT_WITH_ERRORS, + CVSUIMessages.CVSPreferencesPage_51, + IHelpContextIds.PREF_INCLUDE_CHANGE_SETS_IN_COMMIT, + YES_NO_PROMPT, + new String [] { MessageDialogWithToggle.ALWAYS, MessageDialogWithToggle.NEVER, MessageDialogWithToggle.PROMPT } + ); + SWTUtils.createPlaceholder(composite, 1); + return composite; } @@ -597,7 +597,7 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(newKSubst); CVSProviderPlugin.getPlugin().setUsePlatformLineend(store.getBoolean(ICVSUIConstants.PREF_USE_PLATFORM_LINEEND)); CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION)); - CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT)); + CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT)); // changing the default keyword substitution mode for text files may affect // information displayed in the decorators @@ -617,13 +617,13 @@ public class CVSPreferencesPage extends PreferencePage implements IWorkbenchPref } } - /** - * Returns preference store that belongs to the our plugin. - * This is important because we want to store - * our preferences separately from the desktop. - * - * @return the preference store for this plugin - */ + /** + * Returns preference store that belongs to the our plugin. + * This is important because we want to store + * our preferences separately from the desktop. + * + * @return the preference store for this plugin + */ protected IPreferenceStore doGetPreferenceStore() { return CVSUIPlugin.getPlugin().getPreferenceStore(); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectPropertiesPage.java index d942b74c7..6a786d621 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectPropertiesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSProjectPropertiesPage.java @@ -227,8 +227,8 @@ public class CVSProjectPropertiesPage extends CVSPropertiesPage { }); initializeValues(oldLocation); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.PROJECT_PROPERTY_PAGE); - Dialog.applyDialogFont(parent); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.PROJECT_PROPERTY_PAGE); + Dialog.applyDialogFont(parent); return composite; } /** @@ -308,7 +308,7 @@ public class CVSProjectPropertiesPage extends CVSPropertiesPage { hostText.setText(location.getHost()); int port = location.getPort(); if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) { - portText.setText(CVSUIMessages.CVSPropertiesPage_defaultPort); + portText.setText(CVSUIMessages.CVSPropertiesPage_defaultPort); } else { portText.setText("" + port); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceTransfer.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceTransfer.java index 90acf4934..0a2b0192b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceTransfer.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceTransfer.java @@ -28,81 +28,81 @@ import org.eclipse.team.internal.ccvs.core.util.KnownRepositories; * @author Eugene Kuleshov */ public final class CVSResourceTransfer extends ByteArrayTransfer { - - public static final String TYPE_NAME = "CVS-resource-transfer-format"; //$NON-NLS-1$ + + public static final String TYPE_NAME = "CVS-resource-transfer-format"; //$NON-NLS-1$ - public static int TYPE = registerType(TYPE_NAME); + public static int TYPE = registerType(TYPE_NAME); - private static CVSResourceTransfer instance = new CVSResourceTransfer(); + private static CVSResourceTransfer instance = new CVSResourceTransfer(); - - private CVSResourceTransfer() { - } + + private CVSResourceTransfer() { + } - public static CVSResourceTransfer getInstance() { - return instance; - } + public static CVSResourceTransfer getInstance() { + return instance; + } - - @Override + + @Override protected int[] getTypeIds() { - return new int[] { TYPE }; - } + return new int[] { TYPE }; + } - @Override + @Override protected String[] getTypeNames() { - return new String[] { TYPE_NAME }; - } + return new String[] { TYPE_NAME }; + } - @Override + @Override public void javaToNative(Object object, TransferData transferData) { - if (!isSupportedType(transferData)) { - DND.error(DND.ERROR_INVALID_DATA); - } + if (!isSupportedType(transferData)) { + DND.error(DND.ERROR_INVALID_DATA); + } - final byte[] bytes = toByteArray((ICVSRemoteFile) object); - if (bytes != null) { - super.javaToNative(bytes, transferData); - } - } + final byte[] bytes = toByteArray((ICVSRemoteFile) object); + if (bytes != null) { + super.javaToNative(bytes, transferData); + } + } - @Override + @Override protected Object nativeToJava(TransferData transferData) { - byte[] bytes = (byte[]) super.nativeToJava(transferData); - return fromByteArray(bytes); - } - - - public Object fromByteArray(byte[] bytes) { - final DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes)); - - try { - String location = in.readUTF(); - String filePath = in.readUTF(); - String fileRevision = in.readUTF(); - - ICVSRepositoryLocation repositoryLocation = KnownRepositories.getInstance().getRepository(location); - RemoteFile file = RemoteFile.create( filePath, repositoryLocation); - file.setRevision(fileRevision); - file.setReadOnly(true); - return file; - } catch (Exception ex) { - return null; - } - } - - public byte[] toByteArray(ICVSRemoteFile file) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(bos); - try { - dos.writeUTF(file.getRepository().getLocation(false)); - dos.writeUTF(file.getRepositoryRelativePath()); - dos.writeUTF(file.getRevision()); - return bos.toByteArray(); - } catch (Exception ex) { - // ex.printStackTrace(); - return null; - } - } + byte[] bytes = (byte[]) super.nativeToJava(transferData); + return fromByteArray(bytes); + } + + + public Object fromByteArray(byte[] bytes) { + final DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes)); + + try { + String location = in.readUTF(); + String filePath = in.readUTF(); + String fileRevision = in.readUTF(); + + ICVSRepositoryLocation repositoryLocation = KnownRepositories.getInstance().getRepository(location); + RemoteFile file = RemoteFile.create( filePath, repositoryLocation); + file.setRevision(fileRevision); + file.setReadOnly(true); + return file; + } catch (Exception ex) { + return null; + } + } + + public byte[] toByteArray(ICVSRemoteFile file) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(bos); + try { + dos.writeUTF(file.getRepository().getLocation(false)); + dos.writeUTF(file.getRepositoryRelativePath()); + dos.writeUTF(file.getRevision()); + return bos.toByteArray(); + } catch (Exception ex) { + // ex.printStackTrace(); + return null; + } + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java index bab538fa7..fee1372a9 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIMessages.java @@ -198,10 +198,10 @@ public class CVSUIMessages extends NLS { public static String CVSDecoratorPreferencesPage_33; public static String CVSDecoratorPreferencesPage_34; public static String CVSDecoratorPreferencesPage_35; - public static String CVSDecoratorPreferencesPage_36; - public static String CVSDecoratorPreferencesPage_37; - public static String CVSDecoratorPreferencesPage_38; // repository label - public static String CVSDecoratorPreferencesPage_39; + public static String CVSDecoratorPreferencesPage_36; + public static String CVSDecoratorPreferencesPage_37; + public static String CVSDecoratorPreferencesPage_38; // repository label + public static String CVSDecoratorPreferencesPage_39; public static String CVSDecoratorConfiguration_0; public static String CVSDecoratorConfiguration_1; public static String CVSDecoratorConfiguration_2; @@ -278,8 +278,8 @@ public class CVSUIMessages extends NLS { public static String CVSPreferencesPage_39; public static String CVSPreferencesPage_40; public static String CVSPreferencesPage_41; - public static String CVSPreferencesPage_44; - public static String CVSPreferencesPage_45; + public static String CVSPreferencesPage_44; + public static String CVSPreferencesPage_45; public static String CVSPropertiesPage_virtualModule; @@ -680,7 +680,7 @@ public class CVSUIMessages extends NLS { public static String TagConfigurationDialog_20; public static String TagConfigurationDialog_21; public static String TagConfigurationDialog_22; - public static String TagConfigurationDialog_AddDateTag; + public static String TagConfigurationDialog_AddDateTag; public static String ConfigureTagsFromRepoViewConfigure_Tag_Error_1; public static String RemoteRootAction_label; @@ -766,7 +766,7 @@ public class CVSUIMessages extends NLS { public static String WatchEditPreferencePage_checkoutReadOnly; public static String WatchEditPreferencePage_validateEditSaveAction; public static String WatchEditPreferencePage_edit; - public static String WatchEditPreferencePage_editInBackground; + public static String WatchEditPreferencePage_editInBackground; public static String WatchEditPreferencePage_highjack; public static String WatchEditPreferencePage_editPrompt; public static String WatchEditPreferencePage_neverPrompt; @@ -891,21 +891,21 @@ public class CVSUIMessages extends NLS { public static String CommitCommentArea_2; public static String CommitCommentArea_3; public static String CommitCommentArea_4; - public static String CommitCommentArea_5; - public static String CommitCommentArea_6; - - public static String CommentTemplatesPreferencePage_Description; - public static String CommentTemplatesPreferencePage_New; - public static String CommentTemplatesPreferencePage_Edit; - public static String CommentTemplatesPreferencePage_Remove; - public static String CommentTemplatesPreferencePage_Preview; - public static String CommentTemplatesPreferencePage_EditCommentTemplateTitle; - public static String CommentTemplatesPreferencePage_EditCommentTemplateMessage; + public static String CommitCommentArea_5; + public static String CommitCommentArea_6; + + public static String CommentTemplatesPreferencePage_Description; + public static String CommentTemplatesPreferencePage_New; + public static String CommentTemplatesPreferencePage_Edit; + public static String CommentTemplatesPreferencePage_Remove; + public static String CommentTemplatesPreferencePage_Preview; + public static String CommentTemplatesPreferencePage_EditCommentTemplateTitle; + public static String CommentTemplatesPreferencePage_EditCommentTemplateMessage; public static String CheckoutProjectOperation_8; public static String CheckoutProjectOperation_9; public static String CheckoutProjectOperation_0; - public static String CheckoutProjectOperation_1; + public static String CheckoutProjectOperation_1; public static String CVSOperation_0; public static String CVSOperation_1; public static String CVSOperation_2; @@ -970,8 +970,8 @@ public class CVSUIMessages extends NLS { public static String FileModificationValidator_3; public static String FileModificationValidator_4; - public static String FileModificationValidator_5; - public static String FileModificationValidator_6; + public static String FileModificationValidator_5; + public static String FileModificationValidator_6; public static String CVSSynchronizeWizard_0; public static String Participant_comparing; public static String Participant_merging; @@ -998,8 +998,8 @@ public class CVSUIMessages extends NLS { public static String SharingWizardSyncPage_8; public static String SharingWizardSyncPage_9; public static String SharingWizardSyncPage_12; - public static String ShareProjectOperation_2; - public static String ShareProjectOperation_3; + public static String ShareProjectOperation_2; + public static String ShareProjectOperation_3; public static String CVSProjectPropertiesPage_31; public static String CVSProjectPropertiesPage_32; public static String CVSProjectPropertiesPage_33; @@ -1072,9 +1072,9 @@ public class CVSUIMessages extends NLS { public static String ReplaceWithTagAction_2; public static String AddWizard_0; - public static String OpenChangeSetAction_0; - public static String OpenChangeSetAction_1; - + public static String OpenChangeSetAction_0; + public static String OpenChangeSetAction_1; + public static String WorkInProgressPage_0; public static String WorkInProgressPage_1; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java index ab74ecc5d..daf9546f3 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java @@ -163,7 +163,7 @@ public class CVSUIPlugin extends AbstractUIPlugin { * supplied operation will be run again. */ public static void runWithRefresh(Shell parent, IResource[] resources, - IRunnableWithProgress runnable, IProgressMonitor monitor) + IRunnableWithProgress runnable, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { boolean firstTime = true; while(true) { @@ -237,7 +237,7 @@ public class CVSUIPlugin extends AbstractUIPlugin { * @exception InterruptedException when the progress monitor is canceled */ public static void runWithProgress(Shell parent, boolean cancelable, - final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { + final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException { Utils.runWithProgress(parent, cancelable, runnable); } @@ -270,7 +270,7 @@ public class CVSUIPlugin extends AbstractUIPlugin { } return repositoryManager; } - + /** * Initializes the table of images used in this plugin. */ @@ -598,11 +598,11 @@ public class CVSUIPlugin extends AbstractUIPlugin { store.setDefault(ICVSUIConstants.PREF_SHOW_COMPARE_REVISION_IN_DIALOG, false); store.setDefault(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT, false); store.setDefault(ICVSUIConstants.PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG, false); - store.setDefault(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, true); - store.setDefault(ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT, false); - store.setDefault(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, false); - store.setDefault(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, 1000); - store.setDefault(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY, RepositoryManager.DEFAULT_MAX_COMMENTS); + store.setDefault(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT, true); + store.setDefault(ICVSUIConstants.PREF_ENABLE_WATCH_ON_EDIT, false); + store.setDefault(ICVSUIConstants.PREF_USE_PROJECT_NAME_ON_CHECKOUT, false); + store.setDefault(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD, 1000); + store.setDefault(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY, RepositoryManager.DEFAULT_MAX_COMMENTS); PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_COMMAND_COLOR, new RGB(0, 0, 0)); PreferenceConverter.setDefault(store, ICVSUIConstants.PREF_CONSOLE_MESSAGE_COLOR, new RGB(0, 0, 255)); @@ -646,7 +646,7 @@ public class CVSUIPlugin extends AbstractUIPlugin { store.setDefault(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getDefaultBoolean(CVSProviderPlugin.READ_ONLY)); store.setDefault(ICVSUIConstants.PREF_EDIT_ACTION, ICVSUIConstants.PREF_EDIT_IN_BACKGROUND); store.setDefault(ICVSUIConstants.PREF_EDIT_PROMPT, ICVSUIConstants.PREF_EDIT_PROMPT_IF_EDITORS); - store.setDefault(ICVSUIConstants.PREF_UPDATE_PROMPT, ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER); + store.setDefault(ICVSUIConstants.PREF_UPDATE_PROMPT, ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER); // Ensure that the preference values in UI match Core store.setValue(ICVSUIConstants.PREF_CHECKOUT_READ_ONLY, corePrefs.getBoolean(CVSProviderPlugin.READ_ONLY)); @@ -665,15 +665,15 @@ public class CVSUIPlugin extends AbstractUIPlugin { CVSProviderPlugin.getPlugin().setRepositoriesAreBinary(store.getBoolean(ICVSUIConstants.PREF_REPOSITORIES_ARE_BINARY)); CVSProviderPlugin.getPlugin().setDetermineVersionEnabled(store.getBoolean(ICVSUIConstants.PREF_DETERMINE_SERVER_VERSION)); CVSProviderPlugin.getPlugin().setDebugProtocol(CVSProviderPlugin.getPlugin().isDebugProtocol() || store.getBoolean(ICVSUIConstants.PREF_DEBUG_PROTOCOL)); - CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT)); - - // code to transfer CVS preference to Team preference - if (store.getBoolean(ICVSUIConstants.PREF_SHOW_AUTHOR_IN_EDITOR)) { - store.setValue(ICVSUIConstants.PREF_SHOW_AUTHOR_IN_EDITOR, false); - IPreferenceStore teamStore = TeamUIPlugin.getPlugin().getPreferenceStore(); - if (teamStore.isDefault(IPreferenceIds.SHOW_AUTHOR_IN_COMPARE_EDITOR)) - teamStore.setValue(IPreferenceIds.SHOW_AUTHOR_IN_COMPARE_EDITOR, true); - } + CVSProviderPlugin.getPlugin().setAutoshareOnImport(store.getBoolean(ICVSUIConstants.PREF_AUTO_SHARE_ON_IMPORT)); + + // code to transfer CVS preference to Team preference + if (store.getBoolean(ICVSUIConstants.PREF_SHOW_AUTHOR_IN_EDITOR)) { + store.setValue(ICVSUIConstants.PREF_SHOW_AUTHOR_IN_EDITOR, false); + IPreferenceStore teamStore = TeamUIPlugin.getPlugin().getPreferenceStore(); + if (teamStore.isDefault(IPreferenceIds.SHOW_AUTHOR_IN_COMPARE_EDITOR)) + teamStore.setValue(IPreferenceIds.SHOW_AUTHOR_IN_COMPARE_EDITOR, true); + } } @Override @@ -694,11 +694,11 @@ public class CVSUIPlugin extends AbstractUIPlugin { Platform.getAdapterManager().registerAdapters(factory, RepositoryRoot.class); try { - console = new CVSOutputConsole(); - } catch (RuntimeException e) { - // Don't let the console bring down the CVS UI - log(IStatus.ERROR, "Errors occurred starting the CVS console", e); //$NON-NLS-1$ - } + console = new CVSOutputConsole(); + } catch (RuntimeException e) { + // Don't let the console bring down the CVS UI + log(IStatus.ERROR, "Errors occurred starting the CVS console", e); //$NON-NLS-1$ + } IPreferenceStore store = getPreferenceStore(); if (store.getBoolean(ICVSUIConstants.PREF_FIRST_STARTUP)) { @@ -729,7 +729,7 @@ public class CVSUIPlugin extends AbstractUIPlugin { } if (console != null) - console.shutdown(); + console.shutdown(); } finally { super.stop(context); } @@ -741,16 +741,16 @@ public class CVSUIPlugin extends AbstractUIPlugin { public CVSOutputConsole getConsole() { return console; } - - public IEditorPart openEditor(ICVSRemoteFile file, IProgressMonitor monitor) throws InvocationTargetException { - IWorkbench workbench = getWorkbench(); - IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage(); - try { + + public IEditorPart openEditor(ICVSRemoteFile file, IProgressMonitor monitor) throws InvocationTargetException { + IWorkbench workbench = getWorkbench(); + IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage(); + try { return Utils.openEditor(page, file.getAdapter(IFileRevision.class), monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } - } + } /** * Helper method which access the preference store to determine if the diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommentTemplateEditDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommentTemplateEditDialog.java index 2a55ea5b2..29b965052 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommentTemplateEditDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommentTemplateEditDialog.java @@ -28,214 +28,214 @@ import org.eclipse.swt.widgets.*; * </p> */ public class CommentTemplateEditDialog extends Dialog { - /** - * The title of the dialog. - */ - private String title; - - /** - * The message to display, or <code>null</code> if none. - */ - private String message; - - /** - * The input value; the empty string by default. - */ - private String value = "";//$NON-NLS-1$ - - /** - * The input validator, or <code>null</code> if none. - */ - private IInputValidator validator; - - /** - * Ok button widget. - */ - private Button okButton; - - /** - * Input text widget. - */ - private Text text; - - /** - * Error message label widget. - */ - private Text errorMessageText; - - /** - * Creates an input dialog with OK and Cancel buttons. Note that the dialog - * will have no visual representation (no widgets) until it is told to open. - * <p> - * Note that the <code>open</code> method blocks for input dialogs. - * </p> - * - * @param parentShell - * the parent shell, or <code>null</code> to create a top-level - * shell - * @param dialogTitle - * the dialog title, or <code>null</code> if none - * @param dialogMessage - * the dialog message, or <code>null</code> if none - * @param initialValue - * the initial input value, or <code>null</code> if none - * (equivalent to the empty string) - * @param validator - * an input validator, or <code>null</code> if none - */ - public CommentTemplateEditDialog(Shell parentShell, String dialogTitle, - String dialogMessage, String initialValue, IInputValidator validator) { - super(parentShell); - this.title = dialogTitle; - message = dialogMessage; - if (initialValue == null) - value = "";//$NON-NLS-1$ - else - value = initialValue; - this.validator = validator; - } - - @Override + /** + * The title of the dialog. + */ + private String title; + + /** + * The message to display, or <code>null</code> if none. + */ + private String message; + + /** + * The input value; the empty string by default. + */ + private String value = "";//$NON-NLS-1$ + + /** + * The input validator, or <code>null</code> if none. + */ + private IInputValidator validator; + + /** + * Ok button widget. + */ + private Button okButton; + + /** + * Input text widget. + */ + private Text text; + + /** + * Error message label widget. + */ + private Text errorMessageText; + + /** + * Creates an input dialog with OK and Cancel buttons. Note that the dialog + * will have no visual representation (no widgets) until it is told to open. + * <p> + * Note that the <code>open</code> method blocks for input dialogs. + * </p> + * + * @param parentShell + * the parent shell, or <code>null</code> to create a top-level + * shell + * @param dialogTitle + * the dialog title, or <code>null</code> if none + * @param dialogMessage + * the dialog message, or <code>null</code> if none + * @param initialValue + * the initial input value, or <code>null</code> if none + * (equivalent to the empty string) + * @param validator + * an input validator, or <code>null</code> if none + */ + public CommentTemplateEditDialog(Shell parentShell, String dialogTitle, + String dialogMessage, String initialValue, IInputValidator validator) { + super(parentShell); + this.title = dialogTitle; + message = dialogMessage; + if (initialValue == null) + value = "";//$NON-NLS-1$ + else + value = initialValue; + this.validator = validator; + } + + @Override protected void buttonPressed(int buttonId) { - if (buttonId == IDialogConstants.OK_ID) { - value = text.getText(); - } else { - value = null; - } - super.buttonPressed(buttonId); - } - - @Override + if (buttonId == IDialogConstants.OK_ID) { + value = text.getText(); + } else { + value = null; + } + super.buttonPressed(buttonId); + } + + @Override protected void configureShell(Shell shell) { - super.configureShell(shell); - if (title != null) - shell.setText(title); - } + super.configureShell(shell); + if (title != null) + shell.setText(title); + } - @Override + @Override protected void createButtonsForButtonBar(Composite parent) { - // create OK and Cancel buttons by default - okButton = createButton(parent, IDialogConstants.OK_ID, - IDialogConstants.OK_LABEL, true); - createButton(parent, IDialogConstants.CANCEL_ID, - IDialogConstants.CANCEL_LABEL, false); - //do this here because setting the text will set enablement on the ok - // button - text.setFocus(); - if (value != null) { - text.setText(value); - text.selectAll(); - } - } - - @Override + // create OK and Cancel buttons by default + okButton = createButton(parent, IDialogConstants.OK_ID, + IDialogConstants.OK_LABEL, true); + createButton(parent, IDialogConstants.CANCEL_ID, + IDialogConstants.CANCEL_LABEL, false); + //do this here because setting the text will set enablement on the ok + // button + text.setFocus(); + if (value != null) { + text.setText(value); + text.selectAll(); + } + } + + @Override protected Control createDialogArea(Composite parent) { - // create composite - Composite composite = (Composite) super.createDialogArea(parent); - // create message - if (message != null) { - Label label = new Label(composite, SWT.WRAP); - label.setText(message); - GridData data = new GridData(GridData.GRAB_HORIZONTAL - | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL - | GridData.VERTICAL_ALIGN_CENTER); - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - label.setLayoutData(data); - label.setFont(parent.getFont()); - } - text = new Text(composite, SWT.MULTI | SWT.BORDER); - GridData gd = new GridData(GridData.GRAB_HORIZONTAL - | GridData.HORIZONTAL_ALIGN_FILL); + // create composite + Composite composite = (Composite) super.createDialogArea(parent); + // create message + if (message != null) { + Label label = new Label(composite, SWT.WRAP); + label.setText(message); + GridData data = new GridData(GridData.GRAB_HORIZONTAL + | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL + | GridData.VERTICAL_ALIGN_CENTER); + data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); + label.setLayoutData(data); + label.setFont(parent.getFont()); + } + text = new Text(composite, SWT.MULTI | SWT.BORDER); + GridData gd = new GridData(GridData.GRAB_HORIZONTAL + | GridData.HORIZONTAL_ALIGN_FILL); gd.heightHint = convertHeightInCharsToPixels(5); text.setLayoutData(gd); text.addModifyListener(e -> validateInput()); - errorMessageText = new Text(composite, SWT.READ_ONLY); - errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL - | GridData.HORIZONTAL_ALIGN_FILL)); - errorMessageText.setBackground(errorMessageText.getDisplay() - .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); - - applyDialogFont(composite); - return composite; - } - - /** - * Returns the error message label. - * - * @return the error message label - * @deprecated use setErrorMessage(String) instead - */ - @Deprecated + errorMessageText = new Text(composite, SWT.READ_ONLY); + errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL + | GridData.HORIZONTAL_ALIGN_FILL)); + errorMessageText.setBackground(errorMessageText.getDisplay() + .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); + + applyDialogFont(composite); + return composite; + } + + /** + * Returns the error message label. + * + * @return the error message label + * @deprecated use setErrorMessage(String) instead + */ + @Deprecated protected Label getErrorMessageLabel() { - return null; - } - - /** - * Returns the ok button. - * - * @return the ok button - */ - protected Button getOkButton() { - return okButton; - } - - /** - * Returns the text area. - * - * @return the text area - */ - protected Text getText() { - return text; - } - - /** - * Returns the validator. - * - * @return the validator - */ - protected IInputValidator getValidator() { - return validator; - } - - /** - * Returns the string typed into this input dialog. - * - * @return the input string - */ - public String getValue() { - return value; - } - - /** - * Validates the input. - * <p> - * The default implementation of this framework method delegates the request - * to the supplied input validator object; if it finds the input invalid, - * the error message is displayed in the dialog's message line. This hook - * method is called whenever the text changes in the input field. - * </p> - */ - protected void validateInput() { - String errorMessage = null; - if (validator != null) { - errorMessage = validator.isValid(text.getText()); - } - // Bug 16256: important not to treat "" (blank error) the same as null - // (no error) - setErrorMessage(errorMessage); - } - - /** - * Sets or clears the error message. - * If not <code>null</code>, the OK button is disabled. - * - * @param errorMessage - * the error message, or <code>null</code> to clear - * @since 3.0 - */ - public void setErrorMessage(String errorMessage) { - errorMessageText.setText(errorMessage == null ? "" : errorMessage); //$NON-NLS-1$ - okButton.setEnabled(errorMessage == null); - errorMessageText.getParent().update(); - } + return null; + } + + /** + * Returns the ok button. + * + * @return the ok button + */ + protected Button getOkButton() { + return okButton; + } + + /** + * Returns the text area. + * + * @return the text area + */ + protected Text getText() { + return text; + } + + /** + * Returns the validator. + * + * @return the validator + */ + protected IInputValidator getValidator() { + return validator; + } + + /** + * Returns the string typed into this input dialog. + * + * @return the input string + */ + public String getValue() { + return value; + } + + /** + * Validates the input. + * <p> + * The default implementation of this framework method delegates the request + * to the supplied input validator object; if it finds the input invalid, + * the error message is displayed in the dialog's message line. This hook + * method is called whenever the text changes in the input field. + * </p> + */ + protected void validateInput() { + String errorMessage = null; + if (validator != null) { + errorMessage = validator.isValid(text.getText()); + } + // Bug 16256: important not to treat "" (blank error) the same as null + // (no error) + setErrorMessage(errorMessage); + } + + /** + * Sets or clears the error message. + * If not <code>null</code>, the OK button is disabled. + * + * @param errorMessage + * the error message, or <code>null</code> to clear + * @since 3.0 + */ + public void setErrorMessage(String errorMessage) { + errorMessageText.setText(errorMessage == null ? "" : errorMessage); //$NON-NLS-1$ + okButton.setEnabled(errorMessage == null); + errorMessageText.getParent().update(); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java index f8bc0d4d0..11b8a76a2 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CommitCommentArea.java @@ -57,65 +57,65 @@ import org.eclipse.ui.texteditor.*; */ public class CommitCommentArea extends DialogArea { - private class TextBox implements ModifyListener, TraverseListener, FocusListener, Observer, IDocumentListener { - - private final StyledText fTextField; // updated only by modify events - private final String fMessage; - private String fText; - private IDocument fDocument; - - public TextBox(Composite composite, String message, String initialText) { - - fMessage= message; - fText= initialText; - - AnnotationModel annotationModel = new AnnotationModel(); - IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess(); + private class TextBox implements ModifyListener, TraverseListener, FocusListener, Observer, IDocumentListener { + + private final StyledText fTextField; // updated only by modify events + private final String fMessage; + private String fText; + private IDocument fDocument; + + public TextBox(Composite composite, String message, String initialText) { + + fMessage= message; + fText= initialText; + + AnnotationModel annotationModel = new AnnotationModel(); + IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess(); - Composite cc = new Composite(composite, SWT.BORDER); - cc.setLayout(new FillLayout()); - cc.setLayoutData(new GridData(GridData.FILL_BOTH)); - - final SourceViewer sourceViewer = new SourceViewer(cc, null, null, true, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); - fTextField = sourceViewer.getTextWidget(); - fTextField.setIndent(2); - - final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(sourceViewer, null, annotationAccess, EditorsUI.getSharedTextColors()); - - Iterator e= new MarkerAnnotationPreferences().getAnnotationPreferences().iterator(); - while (e.hasNext()) - support.setAnnotationPreference((AnnotationPreference) e.next()); - - support.install(EditorsUI.getPreferenceStore()); - - final IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class); - final IHandlerActivation handlerActivation = installQuickFixActionHandler(handlerService, sourceViewer); - - final TextViewerAction cutAction = new TextViewerAction(sourceViewer, ITextOperationTarget.CUT); - cutAction.setText(CVSUIMessages.CommitCommentArea_7); - cutAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT); - - final TextViewerAction copyAction = new TextViewerAction(sourceViewer, ITextOperationTarget.COPY); - copyAction.setText(CVSUIMessages.CommitCommentArea_8); - copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY); - - final TextViewerAction pasteAction = new TextViewerAction(sourceViewer, ITextOperationTarget.PASTE); - pasteAction.setText(CVSUIMessages.CommitCommentArea_9); - pasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE); - - final TextViewerAction selectAllAction = new TextViewerAction(sourceViewer, ITextOperationTarget.SELECT_ALL); - selectAllAction.setText(CVSUIMessages.CommitCommentArea_10); - selectAllAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL); - - MenuManager contextMenu = new MenuManager(); - contextMenu.add(cutAction); - contextMenu.add(copyAction); - contextMenu.add(pasteAction); - contextMenu.add(selectAllAction); - contextMenu.add(new Separator()); - - final SubMenuManager quickFixMenu = new SubMenuManager(contextMenu); - quickFixMenu.setVisible(true); + Composite cc = new Composite(composite, SWT.BORDER); + cc.setLayout(new FillLayout()); + cc.setLayoutData(new GridData(GridData.FILL_BOTH)); + + final SourceViewer sourceViewer = new SourceViewer(cc, null, null, true, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); + fTextField = sourceViewer.getTextWidget(); + fTextField.setIndent(2); + + final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(sourceViewer, null, annotationAccess, EditorsUI.getSharedTextColors()); + + Iterator e= new MarkerAnnotationPreferences().getAnnotationPreferences().iterator(); + while (e.hasNext()) + support.setAnnotationPreference((AnnotationPreference) e.next()); + + support.install(EditorsUI.getPreferenceStore()); + + final IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class); + final IHandlerActivation handlerActivation = installQuickFixActionHandler(handlerService, sourceViewer); + + final TextViewerAction cutAction = new TextViewerAction(sourceViewer, ITextOperationTarget.CUT); + cutAction.setText(CVSUIMessages.CommitCommentArea_7); + cutAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT); + + final TextViewerAction copyAction = new TextViewerAction(sourceViewer, ITextOperationTarget.COPY); + copyAction.setText(CVSUIMessages.CommitCommentArea_8); + copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY); + + final TextViewerAction pasteAction = new TextViewerAction(sourceViewer, ITextOperationTarget.PASTE); + pasteAction.setText(CVSUIMessages.CommitCommentArea_9); + pasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE); + + final TextViewerAction selectAllAction = new TextViewerAction(sourceViewer, ITextOperationTarget.SELECT_ALL); + selectAllAction.setText(CVSUIMessages.CommitCommentArea_10); + selectAllAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL); + + MenuManager contextMenu = new MenuManager(); + contextMenu.add(cutAction); + contextMenu.add(copyAction); + contextMenu.add(pasteAction); + contextMenu.add(selectAllAction); + contextMenu.add(new Separator()); + + final SubMenuManager quickFixMenu = new SubMenuManager(contextMenu); + quickFixMenu.setVisible(true); quickFixMenu.addMenuListener(manager -> { quickFixMenu.removeAll(); @@ -151,9 +151,9 @@ public class CommitCommentArea extends DialogArea { } } }); - - fTextField.addFocusListener(new FocusListener() { - + + fTextField.addFocusListener(new FocusListener() { + private IHandlerActivation cutHandlerActivation; private IHandlerActivation copyHandlerActivation; private IHandlerActivation pasteHandlerActivation; @@ -165,11 +165,11 @@ public class CommitCommentArea extends DialogArea { copyAction.update(); IHandlerService service = PlatformUI.getWorkbench().getService(IHandlerService.class); this.cutHandlerActivation = service.activateHandler(IWorkbenchCommandConstants.EDIT_CUT, new ActionHandler(cutAction), new ActiveShellExpression(getComposite().getShell())); - this.copyHandlerActivation = service.activateHandler(IWorkbenchCommandConstants.EDIT_COPY, new ActionHandler(copyAction), new ActiveShellExpression(getComposite().getShell())); - this.pasteHandlerActivation = service.activateHandler(IWorkbenchCommandConstants.EDIT_PASTE, new ActionHandler(pasteAction), new ActiveShellExpression(getComposite().getShell())); - this.selectAllHandlerActivation = service.activateHandler(IWorkbenchCommandConstants.EDIT_SELECT_ALL, new ActionHandler(selectAllAction), new ActiveShellExpression(getComposite().getShell())); - - + this.copyHandlerActivation = service.activateHandler(IWorkbenchCommandConstants.EDIT_COPY, new ActionHandler(copyAction), new ActiveShellExpression(getComposite().getShell())); + this.pasteHandlerActivation = service.activateHandler(IWorkbenchCommandConstants.EDIT_PASTE, new ActionHandler(pasteAction), new ActiveShellExpression(getComposite().getShell())); + this.selectAllHandlerActivation = service.activateHandler(IWorkbenchCommandConstants.EDIT_SELECT_ALL, new ActionHandler(selectAllAction), new ActiveShellExpression(getComposite().getShell())); + + } @Override @@ -194,275 +194,275 @@ public class CommitCommentArea extends DialogArea { } }); - + sourceViewer.addSelectionChangedListener(event -> { cutAction.update(); copyAction.update(); }); - + sourceViewer.getTextWidget().addDisposeListener(e1 -> { support.uninstall(); handlerService.deactivateHandler(handlerActivation); }); - - fDocument = new Document(initialText); + + fDocument = new Document(initialText); - // NOTE: Configuration must be applied before the document is set in order for - // Hyperlink coloring to work. (Presenter needs document object up front) - sourceViewer.configure(new TextSourceViewerConfiguration(EditorsUI.getPreferenceStore())); - sourceViewer.setDocument(fDocument, annotationModel); - fDocument.addDocumentListener(this); - fTextField.addTraverseListener(this); - fTextField.addModifyListener(this); - fTextField.addFocusListener(this); - - fTextField.setMenu(contextMenu.createContextMenu(fTextField)); - fTextField.selectAll(); - } - - protected boolean includes(Position position, int caretOffset) { + // NOTE: Configuration must be applied before the document is set in order for + // Hyperlink coloring to work. (Presenter needs document object up front) + sourceViewer.configure(new TextSourceViewerConfiguration(EditorsUI.getPreferenceStore())); + sourceViewer.setDocument(fDocument, annotationModel); + fDocument.addDocumentListener(this); + fTextField.addTraverseListener(this); + fTextField.addModifyListener(this); + fTextField.addFocusListener(this); + + fTextField.setMenu(contextMenu.createContextMenu(fTextField)); + fTextField.selectAll(); + } + + protected boolean includes(Position position, int caretOffset) { return position.includes(caretOffset) || (position.offset + position.length) == caretOffset; } - - /** - * Installs the quick fix action handler - * and returns the handler activation. - * - * @param handlerService the handler service - * @param sourceViewer the source viewer - * @return the handler activation - * @since 3.4 - */ + + /** + * Installs the quick fix action handler + * and returns the handler activation. + * + * @param handlerService the handler service + * @param sourceViewer the source viewer + * @return the handler activation + * @since 3.4 + */ private IHandlerActivation installQuickFixActionHandler(IHandlerService handlerService, SourceViewer sourceViewer) { - return handlerService.activateHandler( - ITextEditorActionDefinitionIds.QUICK_ASSIST, - createQuickFixActionHandler(sourceViewer), - new ActiveShellExpression(sourceViewer.getTextWidget().getShell())); - } - - /** - * Creates and returns a quick fix action handler. - * - * @param textOperationTarget the target for text operations - * @since 3.4 - */ - private ActionHandler createQuickFixActionHandler(final ITextOperationTarget textOperationTarget) { - Action quickFixAction= new Action() { - @Override + return handlerService.activateHandler( + ITextEditorActionDefinitionIds.QUICK_ASSIST, + createQuickFixActionHandler(sourceViewer), + new ActiveShellExpression(sourceViewer.getTextWidget().getShell())); + } + + /** + * Creates and returns a quick fix action handler. + * + * @param textOperationTarget the target for text operations + * @since 3.4 + */ + private ActionHandler createQuickFixActionHandler(final ITextOperationTarget textOperationTarget) { + Action quickFixAction= new Action() { + @Override public void run() { - textOperationTarget.doOperation(ISourceViewer.QUICK_ASSIST); - } - }; - quickFixAction.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST); - return new ActionHandler(quickFixAction); - } + textOperationTarget.doOperation(ISourceViewer.QUICK_ASSIST); + } + }; + quickFixAction.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST); + return new ActionHandler(quickFixAction); + } - @Override + @Override public void modifyText(ModifyEvent e) { - final String old = fText; - fText = fTextField.getText(); - if (!fText.equals(old)) - firePropertyChangeChange(COMMENT_MODIFIED, old, fText); - } - - @Override + final String old = fText; + fText = fTextField.getText(); + if (!fText.equals(old)) + firePropertyChangeChange(COMMENT_MODIFIED, old, fText); + } + + @Override public void keyTraversed(TraverseEvent e) { - if (e.detail == SWT.TRAVERSE_RETURN && (e.stateMask & SWT.CTRL) != 0) { - e.doit = false; - firePropertyChangeChange(OK_REQUESTED, null, null); - } - } - - @Override + if (e.detail == SWT.TRAVERSE_RETURN && (e.stateMask & SWT.CTRL) != 0) { + e.doit = false; + firePropertyChangeChange(OK_REQUESTED, null, null); + } + } + + @Override public void focusGained(FocusEvent e) { - if (fText.length() > 0) - return; - - fTextField.removeModifyListener(this); - fDocument.removeDocumentListener(this); - try { - fTextField.setText(fText); - } finally { - fTextField.addModifyListener(this); - fDocument.addDocumentListener(this); - } - } - - @Override + if (fText.length() > 0) + return; + + fTextField.removeModifyListener(this); + fDocument.removeDocumentListener(this); + try { + fTextField.setText(fText); + } finally { + fTextField.addModifyListener(this); + fDocument.addDocumentListener(this); + } + } + + @Override public void focusLost(FocusEvent e) { - - if (fText.length() > 0) - return; - - fTextField.removeModifyListener(this); - fDocument.removeDocumentListener(this); - try { - fTextField.setText(fMessage); - fTextField.selectAll(); - } finally { - fTextField.addModifyListener(this); - fDocument.addDocumentListener(this); - } - } - - public void setEnabled(boolean enabled) { - fTextField.setEnabled(enabled); - } - - @Override + + if (fText.length() > 0) + return; + + fTextField.removeModifyListener(this); + fDocument.removeDocumentListener(this); + try { + fTextField.setText(fMessage); + fTextField.selectAll(); + } finally { + fTextField.addModifyListener(this); + fDocument.addDocumentListener(this); + } + } + + public void setEnabled(boolean enabled) { + fTextField.setEnabled(enabled); + } + + @Override public void update(Observable o, Object arg) { - if (arg instanceof String) { - setText((String)arg); // triggers a modify event - } - } - - public String getText() { - return fText; - } - - private void setText(String text) { - if (text.length() == 0) { - fTextField.setText(fMessage); - fTextField.selectAll(); - } else - fTextField.setText(text); - } + if (arg instanceof String) { + setText((String)arg); // triggers a modify event + } + } + + public String getText() { + return fText; + } + + private void setText(String text) { + if (text.length() == 0) { + fTextField.setText(fMessage); + fTextField.selectAll(); + } else + fTextField.setText(text); + } - public void setFocus() { - fTextField.setFocus(); - } + public void setFocus() { + fTextField.setFocus(); + } - @Override + @Override public void documentAboutToBeChanged(DocumentEvent event) { - } + } - @Override + @Override public void documentChanged(DocumentEvent event) { - modifyText(null); - } + modifyText(null); + } } - - private static class ComboBox extends Observable implements SelectionListener, FocusListener { - - private final String fMessage; - private final String [] fComments; - private String[] fCommentTemplates; - private final Combo fCombo; - - - public ComboBox(Composite composite, String message, String [] options, - String[] commentTemplates) { - - fMessage= message; - fComments= options; - fCommentTemplates = commentTemplates; - - fCombo = new Combo(composite, SWT.READ_ONLY); - fCombo.setLayoutData(SWTUtils.createHFillGridData()); - fCombo.setVisibleItemCount(20); - - // populate the previous comment list - populateList(); - - // We don't want to have an initial selection - // (see bug 32078: http://bugs.eclipse.org/bugs/show_bug.cgi?id=32078) - fCombo.addFocusListener(this); - fCombo.addSelectionListener(this); - } + + private static class ComboBox extends Observable implements SelectionListener, FocusListener { + + private final String fMessage; + private final String [] fComments; + private String[] fCommentTemplates; + private final Combo fCombo; + + + public ComboBox(Composite composite, String message, String [] options, + String[] commentTemplates) { + + fMessage= message; + fComments= options; + fCommentTemplates = commentTemplates; + + fCombo = new Combo(composite, SWT.READ_ONLY); + fCombo.setLayoutData(SWTUtils.createHFillGridData()); + fCombo.setVisibleItemCount(20); + + // populate the previous comment list + populateList(); + + // We don't want to have an initial selection + // (see bug 32078: http://bugs.eclipse.org/bugs/show_bug.cgi?id=32078) + fCombo.addFocusListener(this); + fCombo.addSelectionListener(this); + } private void populateList() { fCombo.removeAll(); fCombo.add(fMessage); - for (int i = 0; i < fCommentTemplates.length; i++) { - fCombo.add(CVSUIMessages.CommitCommentArea_6 + ": " + //$NON-NLS-1$ - Util.flattenText(fCommentTemplates[i])); - } - for (int i = 0; i < fComments.length; i++) { - fCombo.add(Util.flattenText(fComments[i])); - } - fCombo.setText(fMessage); - } - - @Override + for (int i = 0; i < fCommentTemplates.length; i++) { + fCombo.add(CVSUIMessages.CommitCommentArea_6 + ": " + //$NON-NLS-1$ + Util.flattenText(fCommentTemplates[i])); + } + for (int i = 0; i < fComments.length; i++) { + fCombo.add(Util.flattenText(fComments[i])); + } + fCombo.setText(fMessage); + } + + @Override public void widgetSelected(SelectionEvent e) { - int index = fCombo.getSelectionIndex(); - if (index > 0) { - index--; - setChanged(); - - // map from combo box index to array index - String message; - if (index < fCommentTemplates.length) { - message = fCommentTemplates[index]; - } else { - message = fComments[index - fCommentTemplates.length]; - } - notifyObservers(message); - } - } - - @Override + int index = fCombo.getSelectionIndex(); + if (index > 0) { + index--; + setChanged(); + + // map from combo box index to array index + String message; + if (index < fCommentTemplates.length) { + message = fCommentTemplates[index]; + } else { + message = fComments[index - fCommentTemplates.length]; + } + notifyObservers(message); + } + } + + @Override public void widgetDefaultSelected(SelectionEvent e) { - } - - @Override + } + + @Override public void focusGained(FocusEvent e) { - } - - @Override + } + + @Override public void focusLost(FocusEvent e) { - fCombo.removeSelectionListener(this); - try { - fCombo.setText(fMessage); - } finally { - fCombo.addSelectionListener(this); - } - } - - public void setEnabled(boolean enabled) { - fCombo.setEnabled(enabled); - } - - void setCommentTemplates(String[] templates) { + fCombo.removeSelectionListener(this); + try { + fCombo.setText(fMessage); + } finally { + fCombo.addSelectionListener(this); + } + } + + public void setEnabled(boolean enabled) { + fCombo.setEnabled(enabled); + } + + void setCommentTemplates(String[] templates) { fCommentTemplates = templates; populateList(); } - } - - private static final String EMPTY_MESSAGE= CVSUIMessages.CommitCommentArea_0; - private static final String COMBO_MESSAGE= CVSUIMessages.CommitCommentArea_1; - private static final String CONFIGURE_TEMPLATES_MESSAGE= CVSUIMessages.CommitCommentArea_5; - - public static final String OK_REQUESTED = "OkRequested";//$NON-NLS-1$ - public static final String COMMENT_MODIFIED = "CommentModified";//$NON-NLS-1$ - - private TextBox fTextBox; - private ComboBox fComboBox; - - private IProject fMainProject; - private String fProposedComment; - private Composite fComposite; - - @Override + } + + private static final String EMPTY_MESSAGE= CVSUIMessages.CommitCommentArea_0; + private static final String COMBO_MESSAGE= CVSUIMessages.CommitCommentArea_1; + private static final String CONFIGURE_TEMPLATES_MESSAGE= CVSUIMessages.CommitCommentArea_5; + + public static final String OK_REQUESTED = "OkRequested";//$NON-NLS-1$ + public static final String COMMENT_MODIFIED = "CommentModified";//$NON-NLS-1$ + + private TextBox fTextBox; + private ComboBox fComboBox; + + private IProject fMainProject; + private String fProposedComment; + private Composite fComposite; + + @Override public void createArea(Composite parent) { - Dialog.applyDialogFont(parent); - initializeDialogUnits(parent); - - fComposite = createGrabbingComposite(parent, 1); - initializeDialogUnits(fComposite); - - fTextBox= new TextBox(fComposite, EMPTY_MESSAGE, getInitialComment()); - - final String [] comments = CVSUIPlugin.getPlugin().getRepositoryManager().getPreviousComments(); - final String[] commentTemplates = CVSUIPlugin.getPlugin().getRepositoryManager().getCommentTemplates(); - fComboBox= new ComboBox(fComposite, COMBO_MESSAGE, comments, commentTemplates); - - Link templatesPrefsLink = new Link(fComposite, 0); - templatesPrefsLink.setText("<a href=\"configureTemplates\">" + //$NON-NLS-1$ - CONFIGURE_TEMPLATES_MESSAGE + "</a>"); //$NON-NLS-1$ - templatesPrefsLink.addSelectionListener(new SelectionListener() { + Dialog.applyDialogFont(parent); + initializeDialogUnits(parent); + + fComposite = createGrabbingComposite(parent, 1); + initializeDialogUnits(fComposite); + + fTextBox= new TextBox(fComposite, EMPTY_MESSAGE, getInitialComment()); + + final String [] comments = CVSUIPlugin.getPlugin().getRepositoryManager().getPreviousComments(); + final String[] commentTemplates = CVSUIPlugin.getPlugin().getRepositoryManager().getCommentTemplates(); + fComboBox= new ComboBox(fComposite, COMBO_MESSAGE, comments, commentTemplates); + + Link templatesPrefsLink = new Link(fComposite, 0); + templatesPrefsLink.setText("<a href=\"configureTemplates\">" + //$NON-NLS-1$ + CONFIGURE_TEMPLATES_MESSAGE + "</a>"); //$NON-NLS-1$ + templatesPrefsLink.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { openCommentTemplatesPreferencePage(); @@ -473,11 +473,11 @@ public class CommitCommentArea extends DialogArea { openCommentTemplatesPreferencePage(); } }); - - fComboBox.addObserver(fTextBox); - } - - void openCommentTemplatesPreferencePage() { + + fComboBox.addObserver(fTextBox); + } + + void openCommentTemplatesPreferencePage() { PreferencesUtil.createPreferenceDialogOn( null, "org.eclipse.team.cvs.ui.CommentTemplatesPreferences", //$NON-NLS-1$ @@ -488,17 +488,17 @@ public class CommitCommentArea extends DialogArea { } public String getComment(boolean save) { - final String comment= fTextBox.getText(); - if (comment == null) - return ""; //$NON-NLS-1$ - - final String stripped= strip(comment); - if (save && comment.length() > 0) - CVSUIPlugin.getPlugin().getRepositoryManager().addComment(comment); + final String comment= fTextBox.getText(); + if (comment == null) + return ""; //$NON-NLS-1$ + + final String stripped= strip(comment); + if (save && comment.length() > 0) + CVSUIPlugin.getPlugin().getRepositoryManager().addComment(comment); - return stripped; - } - + return stripped; + } + /** * Calculates a shortened form of the commit message for use as a commit set * title @@ -534,111 +534,111 @@ public class CommitCommentArea extends DialogArea { return comment; } - public String getCommentWithPrompt(Shell shell) { - final String comment= getComment(false); - if (comment.length() == 0) { - final IPreferenceStore store= CVSUIPlugin.getPlugin().getPreferenceStore(); - final String value= store.getString(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); - - if (MessageDialogWithToggle.NEVER.equals(value)) - return null; - - if (MessageDialogWithToggle.PROMPT.equals(value)) { - - final String title= CVSUIMessages.CommitCommentArea_2; - final String message= CVSUIMessages.CommitCommentArea_3; - final String toggleMessage= CVSUIMessages.CommitCommentArea_4; - - final MessageDialogWithToggle dialog= MessageDialogWithToggle.openYesNoQuestion(shell, title, message, toggleMessage, false, store, ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); - if (dialog.getReturnCode() != IDialogConstants.YES_ID) { - fTextBox.setFocus(); - return null; - } - } - } - return getComment(true); - } + public String getCommentWithPrompt(Shell shell) { + final String comment= getComment(false); + if (comment.length() == 0) { + final IPreferenceStore store= CVSUIPlugin.getPlugin().getPreferenceStore(); + final String value= store.getString(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); + + if (MessageDialogWithToggle.NEVER.equals(value)) + return null; + + if (MessageDialogWithToggle.PROMPT.equals(value)) { + + final String title= CVSUIMessages.CommitCommentArea_2; + final String message= CVSUIMessages.CommitCommentArea_3; + final String toggleMessage= CVSUIMessages.CommitCommentArea_4; + + final MessageDialogWithToggle dialog= MessageDialogWithToggle.openYesNoQuestion(shell, title, message, toggleMessage, false, store, ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); + if (dialog.getReturnCode() != IDialogConstants.YES_ID) { + fTextBox.setFocus(); + return null; + } + } + } + return getComment(true); + } - - public void setProject(IProject iProject) { - this.fMainProject = iProject; - } - - public void setFocus() { - if (fTextBox != null) { - fTextBox.setFocus(); - } - } - - public void setProposedComment(String proposedComment) { - if (proposedComment == null || proposedComment.length() == 0) { - this.fProposedComment = null; - } else { - this.fProposedComment = proposedComment; - } - } - - public boolean hasCommitTemplate() { - try { - String commitTemplate = getCommitTemplate(); - return commitTemplate != null && commitTemplate.length() > 0; - } catch (CVSException e) { - CVSUIPlugin.log(e); - return false; - } - } - - public void setEnabled(boolean enabled) { - fTextBox.setEnabled(enabled); - fComboBox.setEnabled(enabled); - } - - public Composite getComposite() { - return fComposite; - } - - @Override + + public void setProject(IProject iProject) { + this.fMainProject = iProject; + } + + public void setFocus() { + if (fTextBox != null) { + fTextBox.setFocus(); + } + } + + public void setProposedComment(String proposedComment) { + if (proposedComment == null || proposedComment.length() == 0) { + this.fProposedComment = null; + } else { + this.fProposedComment = proposedComment; + } + } + + public boolean hasCommitTemplate() { + try { + String commitTemplate = getCommitTemplate(); + return commitTemplate != null && commitTemplate.length() > 0; + } catch (CVSException e) { + CVSUIPlugin.log(e); + return false; + } + } + + public void setEnabled(boolean enabled) { + fTextBox.setEnabled(enabled); + fComboBox.setEnabled(enabled); + } + + public Composite getComposite() { + return fComposite; + } + + @Override protected void firePropertyChangeChange(String property, Object oldValue, Object newValue) { - super.firePropertyChangeChange(property, oldValue, newValue); - } - - private String getInitialComment() { - if (fProposedComment != null) - return fProposedComment; - try { - return getCommitTemplate(); - } catch (CVSException e) { - CVSUIPlugin.log(e); - return ""; //$NON-NLS-1$ - } - } + super.firePropertyChangeChange(property, oldValue, newValue); + } + + private String getInitialComment() { + if (fProposedComment != null) + return fProposedComment; + try { + return getCommitTemplate(); + } catch (CVSException e) { + CVSUIPlugin.log(e); + return ""; //$NON-NLS-1$ + } + } - private String strip(String comment) { - // strip template from the comment entered - try { - final String commitTemplate = getCommitTemplate(); - if (comment.startsWith(commitTemplate)) { - return comment.substring(commitTemplate.length()); - } else if (comment.endsWith(commitTemplate)) { - return comment.substring(0, comment.length() - commitTemplate.length()); - } - } catch (CVSException e) { - // we couldn't get the commit template. Log the error and continue - CVSUIPlugin.log(e); - } - return comment; - } + private String strip(String comment) { + // strip template from the comment entered + try { + final String commitTemplate = getCommitTemplate(); + if (comment.startsWith(commitTemplate)) { + return comment.substring(commitTemplate.length()); + } else if (comment.endsWith(commitTemplate)) { + return comment.substring(0, comment.length() - commitTemplate.length()); + } + } catch (CVSException e) { + // we couldn't get the commit template. Log the error and continue + CVSUIPlugin.log(e); + } + return comment; + } - private CVSTeamProvider getProvider() { - if (fMainProject == null) return null; - return (CVSTeamProvider) RepositoryProvider.getProvider(fMainProject, CVSProviderPlugin.getTypeId()); - } + private CVSTeamProvider getProvider() { + if (fMainProject == null) return null; + return (CVSTeamProvider) RepositoryProvider.getProvider(fMainProject, CVSProviderPlugin.getTypeId()); + } - private String getCommitTemplate() throws CVSException { - CVSTeamProvider provider = getProvider(); - if (provider == null) - return ""; //$NON-NLS-1$ - final String template = provider.getCommitTemplate(); - return template != null ? template : ""; //$NON-NLS-1$ - } + private String getCommitTemplate() throws CVSException { + CVSTeamProvider provider = getProvider(); + if (provider == null) + return ""; //$NON-NLS-1$ + final String template = provider.getCommitTemplate(); + return template != null ? template : ""; //$NON-NLS-1$ + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java index 7afbdffcc..b64c43095 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ComparePreferencePage.java @@ -29,17 +29,17 @@ public class ComparePreferencePage extends CVSFieldEditorPreferencePage { private BooleanFieldEditor contents; private StringFieldEditor regex; - @Override + @Override protected String getPageHelpContextId() { - return IHelpContextIds.COMPARE_PREFERENCE_PAGE; - } + return IHelpContextIds.COMPARE_PREFERENCE_PAGE; + } - @Override + @Override protected String getPageDescription() { - return CVSUIMessages.ComparePreferencePage_0; - } + return CVSUIMessages.ComparePreferencePage_0; + } - @Override + @Override protected void createFieldEditors() { IPreferenceStore store = getPreferenceStore(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DateTagDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DateTagDialog.java index e7e8ac95c..96998e0fe 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DateTagDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/DateTagDialog.java @@ -161,7 +161,7 @@ public class DateTagDialog extends TrayDialog { updateWidgetEnablements(); // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(topLevel, IHelpContextIds.DATE_TAG_DIALOG); + PlatformUI.getWorkbench().getHelpSystem().setHelp(topLevel, IHelpContextIds.DATE_TAG_DIALOG); Dialog.applyDialogFont(parent); return topLevel; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsDialog.java index 0adfb8051..56f1b3e4c 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsDialog.java @@ -54,7 +54,7 @@ public class EditorsDialog extends TrayDialog { editorsView.setInput(editorsInfo); // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.EDITORS_DIALOG); + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.EDITORS_DIALOG); Dialog.applyDialogFont(parent); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java index 158a89372..c9b45d214 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/EditorsView.java @@ -209,7 +209,7 @@ public class EditorsView extends ViewPart { tableViewer.setContentProvider(ArrayContentProvider.getInstance()); tableViewer.setLabelProvider(new EditorsLabelProvider()); // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(tableViewer.getControl(), IHelpContextIds.CVS_EDITORS_VIEW); + PlatformUI.getWorkbench().getHelpSystem().setHelp(tableViewer.getControl(), IHelpContextIds.CVS_EDITORS_VIEW); } public void setInput(EditorsInfo[] infos) { tableViewer.setInput(infos); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java index 5c1a2afa1..2ee5879ef 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ExtMethodPreferencePage.java @@ -105,7 +105,7 @@ public class ExtMethodPreferencePage extends PreferencePage implements IWorkbenc ssh2Link.getControl().setLayoutData(data); initializeDefaults(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.EXT_PREFERENCE_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.EXT_PREFERENCE_PAGE); Dialog.applyDialogFont(parent); return composite; } @@ -192,9 +192,9 @@ public class ExtMethodPreferencePage extends PreferencePage implements IWorkbenc data.horizontalAlignment = GridData.FILL; cvsServer.setLayoutData(data); - PlatformUI.getWorkbench().getHelpSystem().setHelp(cvsRsh, IHelpContextIds.EXT_PREFERENCE_RSH); - PlatformUI.getWorkbench().getHelpSystem().setHelp(cvsRshParameters, IHelpContextIds.EXT_PREFERENCE_PARAM); - PlatformUI.getWorkbench().getHelpSystem().setHelp(cvsServer, IHelpContextIds.EXT_PREFERENCE_SERVER); + PlatformUI.getWorkbench().getHelpSystem().setHelp(cvsRsh, IHelpContextIds.EXT_PREFERENCE_RSH); + PlatformUI.getWorkbench().getHelpSystem().setHelp(cvsRshParameters, IHelpContextIds.EXT_PREFERENCE_PARAM); + PlatformUI.getWorkbench().getHelpSystem().setHelp(cvsServer, IHelpContextIds.EXT_PREFERENCE_SERVER); return composite; } @@ -210,9 +210,9 @@ public class ExtMethodPreferencePage extends PreferencePage implements IWorkbenc /* * Set CVS_RSH program */ - protected void setCvsRshText(String s) { - cvsRsh.setText(s); - } + protected void setCvsRshText(String s) { + cvsRsh.setText(s); + } @Override public void init(IWorkbench workbench) { @@ -238,19 +238,19 @@ public class ExtMethodPreferencePage extends PreferencePage implements IWorkbenc CVSUIPlugin.getPlugin().savePluginPreferences(); return super.performOk(); } - - @Override + + @Override protected void performDefaults() { - IPreferenceStore store = getPreferenceStore(); + IPreferenceStore store = getPreferenceStore(); String rsh = store.getDefaultString(ICVSUIConstants.PREF_CVS_RSH); String parameter = store.getDefaultString(ICVSUIConstants.PREF_CVS_RSH_PARAMETERS); String server = store.getDefaultString(ICVSUIConstants.PREF_CVS_SERVER); String method = store.getDefaultString(ICVSUIConstants.PREF_EXT_CONNECTION_METHOD_PROXY); initializeDefaults(rsh, parameter, server, method); - super.performDefaults(); - } - - private void initializeDefaults(String rsh, String parameters, String server, String method) { + super.performDefaults(); + } + + private void initializeDefaults(String rsh, String parameters, String server, String method) { cvsRsh.setText(rsh); cvsRshParameters.setText(parameters); cvsServer.setText(server); @@ -269,8 +269,8 @@ public class ExtMethodPreferencePage extends PreferencePage implements IWorkbenc useExternal.setSelection(method.equals("ext")); //$NON-NLS-1$ useInternal.setSelection(!method.equals("ext")); //$NON-NLS-1$ updateEnablements(); - } - + } + @Override protected IPreferenceStore doGetPreferenceStore() { return CVSUIPlugin.getPlugin().getPreferenceStore(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java index 1dc8cb7b5..3941ece06 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/FileModificationValidator.java @@ -45,11 +45,11 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator public FileModificationValidator() { } - @Override + @Override protected IStatus edit(IFile[] readOnlyFiles, FileModificationValidationContext context) { - return edit(readOnlyFiles, getShell(context)); - } - + return edit(readOnlyFiles, getShell(context)); + } + private Shell getShell(FileModificationValidationContext context) { if (context == null) return null; @@ -77,24 +77,24 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator throw new InterruptedException(); } - // see if the file is up to date - if (shell != null && promptToUpdateFiles(files, shell)) { - // The user wants to update the file - // Run the update in a runnable in order to get a busy cursor. - // This runnable is syncExeced in order to get a busy cursor + // see if the file is up to date + if (shell != null && promptToUpdateFiles(files, shell)) { + // The user wants to update the file + // Run the update in a runnable in order to get a busy cursor. + // This runnable is syncExeced in order to get a busy cursor IRunnableWithProgress updateRunnable = monitor -> performUpdate(files, monitor); - if (isRunningInUIThread()) { - // Only show a busy cursor if validate edit is blocking the UI - CVSUIPlugin.runWithProgress(shell, false, updateRunnable); - } else { - // We can't show a busy cursor (i.e., run in the UI thread) - // since this thread may hold locks and - // running an edit in the UI thread could try to obtain the - // same locks, resulting in a deadlock. - updateRunnable.run(new NullProgressMonitor()); - } - } - + if (isRunningInUIThread()) { + // Only show a busy cursor if validate edit is blocking the UI + CVSUIPlugin.runWithProgress(shell, false, updateRunnable); + } else { + // We can't show a busy cursor (i.e., run in the UI thread) + // since this thread may hold locks and + // running an edit in the UI thread could try to obtain the + // same locks, resulting in a deadlock. + updateRunnable.run(new NullProgressMonitor()); + } + } + // Run the edit in a runnable in order to get a busy cursor. // This runnable is syncExeced in order to get a busy cursor IRunnableWithProgress editRunnable = monitor -> { @@ -105,14 +105,14 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator } }; if (isRunningInUIThread()) { - // Only show a busy cursor if validate edit is blocking the UI - CVSUIPlugin.runWithProgress(shell, false, editRunnable); + // Only show a busy cursor if validate edit is blocking the UI + CVSUIPlugin.runWithProgress(shell, false, editRunnable); } else { - // We can't show a busy cursor (i.e., run in the UI thread) - // since this thread may hold locks and - // running an edit in the UI thread could try to obtain the - // same locks, resulting in a deadlock. - editRunnable.run(new NullProgressMonitor()); + // We can't show a busy cursor (i.e., run in the UI thread) + // since this thread may hold locks and + // running an edit in the UI thread could try to obtain the + // same locks, resulting in a deadlock. + editRunnable.run(new NullProgressMonitor()); } } catch (InvocationTargetException e) { return getStatus(e); @@ -120,11 +120,11 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator // Must return an error to indicate that it is not OK to edit the files return new Status(IStatus.CANCEL, CVSUIPlugin.ID, 0, CVSUIMessages.FileModificationValidator_vetoMessage, null); //; } - } else if (isPerformEditInBackground()) { - IStatus status = setWritable(files); - if (status.isOK()) - performEdit(files); - return status; + } else if (isPerformEditInBackground()) { + IStatus status = setWritable(files); + if (status.isOK()) + performEdit(files); + return status; } else { // Allow the files to be edited without notifying the server return setWritable(files); @@ -133,23 +133,23 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator return Status.OK_STATUS; } - - @Override + + @Override protected void scheduleEditJob(Job job) { - job.setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE); - job.setProperty(IProgressConstants.ICON_PROPERTY, getOperationIcon()); - super.scheduleEditJob(job); - } - - private URL getOperationIcon() { - return FileLocator.find(CVSUIPlugin.getPlugin().getBundle(), new Path(ICVSUIConstants.ICON_PATH + ICVSUIConstants.IMG_CVS_PERSPECTIVE), null); - } - - private boolean isRunningInUIThread() { - return Display.getCurrent() != null; - } + job.setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE); + job.setProperty(IProgressConstants.ICON_PROPERTY, getOperationIcon()); + super.scheduleEditJob(job); + } + + private URL getOperationIcon() { + return FileLocator.find(CVSUIPlugin.getPlugin().getBundle(), new Path(ICVSUIConstants.ICON_PATH + ICVSUIConstants.IMG_CVS_PERSPECTIVE), null); + } + + private boolean isRunningInUIThread() { + return Display.getCurrent() != null; + } - private boolean promptToEditFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException { + private boolean promptToEditFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException { if (files.length == 0) return true; @@ -167,22 +167,22 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator } } - private boolean promptToUpdateFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException { - if (files.length == 0) - return false; - - if (isNeverUpdate()) - return false; - - // Contact the server to see if the files are up-to-date - if (needsUpdate(files, new NullProgressMonitor())) { - if (isPromptUpdate()) - return (promptUpdate(shell)); - return true; // auto update - } - - return false; - } + private boolean promptToUpdateFiles(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException { + if (files.length == 0) + return false; + + if (isNeverUpdate()) + return false; + + // Contact the server to see if the files are up-to-date + if (needsUpdate(files, new NullProgressMonitor())) { + if (isPromptUpdate()) + return (promptUpdate(shell)); + return true; // auto update + } + + return false; + } private boolean promptEdit(Shell shell) { // Open the dialog using a sync exec (there are no guarantees that we @@ -197,39 +197,39 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator return result[0]; } - private boolean promptUpdate(Shell shell) { - // Open the dialog using a sync exec (there are no guarantees that we - // were called from the UI thread - final boolean[] result = new boolean[] { false }; - int flags = isRunningInUIThread() ? 0 : CVSUIPlugin.PERFORM_SYNC_EXEC; + private boolean promptUpdate(Shell shell) { + // Open the dialog using a sync exec (there are no guarantees that we + // were called from the UI thread + final boolean[] result = new boolean[] { false }; + int flags = isRunningInUIThread() ? 0 : CVSUIPlugin.PERFORM_SYNC_EXEC; CVSUIPlugin .openDialog(shell, shell1 -> result[0] = MessageDialog.openQuestion(shell1, CVSUIMessages.FileModificationValidator_5, CVSUIMessages.FileModificationValidator_6), flags); - return result[0]; - } + return result[0]; + } private boolean isPerformEdit() { return ICVSUIConstants.PREF_EDIT_PROMPT_EDIT.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION)); } - - private boolean isPerformEditInBackground() { - return ICVSUIConstants.PREF_EDIT_IN_BACKGROUND.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION)); - } + + private boolean isPerformEditInBackground() { + return ICVSUIConstants.PREF_EDIT_IN_BACKGROUND.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_ACTION)); + } private EditorsAction fetchEditors(IFile[] files, Shell shell) throws InvocationTargetException, InterruptedException { final EditorsAction editors = new EditorsAction(getProvider(files), files); IRunnableWithProgress runnable = monitor -> editors.run(monitor); if (isRunningInUIThread()) { - // Show a busy cursor if we are running in the UI thread - CVSUIPlugin.runWithProgress(shell, false, runnable); + // Show a busy cursor if we are running in the UI thread + CVSUIPlugin.runWithProgress(shell, false, runnable); } else { - // We can't show a busy cursor (i.e., run in the UI thread) - // since this thread may hold locks and - // running a CVS operation in the UI thread could try to obtain the - // same locks, resulting in a deadlock. - runnable.run(new NullProgressMonitor()); + // We can't show a busy cursor (i.e., run in the UI thread) + // since this thread may hold locks and + // running a CVS operation in the UI thread could try to obtain the + // same locks, resulting in a deadlock. + runnable.run(new NullProgressMonitor()); } return editors; } @@ -241,51 +241,51 @@ public class FileModificationValidator extends CVSCoreFileModificationValidator private boolean isAlwaysPrompt() { return ICVSUIConstants.PREF_EDIT_PROMPT_ALWAYS.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_EDIT_PROMPT)); } - - private boolean needsUpdate(IFile[] files, IProgressMonitor monitor) { - try { - CVSWorkspaceSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); - subscriber.refresh(files, IResource.DEPTH_ZERO, monitor); - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - SyncInfo info = subscriber.getSyncInfo(file); - int direction = info.getKind() & SyncInfo.DIRECTION_MASK; - if (direction == SyncInfo.CONFLICTING || direction == SyncInfo.INCOMING) { - return true; - } - } - } catch (TeamException e) { - // Log the exception and assume we don't need to update it - CVSProviderPlugin.log(e); - } - return false; - } - - private void performUpdate(IFile[] files, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - // TODO: This obtains the project rule which can cause a rule violation - new UpdateOperation(null /* no target part */, files, Command.NO_LOCAL_OPTIONS, null /* no tag */).run(monitor); - } - - private boolean isPromptUpdate() { - return ICVSUIConstants.PREF_UPDATE_PROMPT_IF_OUTDATED.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT)); - } - - private boolean isNeverUpdate() { - return ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT)); - } - - @Override + + private boolean needsUpdate(IFile[] files, IProgressMonitor monitor) { + try { + CVSWorkspaceSubscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); + subscriber.refresh(files, IResource.DEPTH_ZERO, monitor); + for (int i = 0; i < files.length; i++) { + IFile file = files[i]; + SyncInfo info = subscriber.getSyncInfo(file); + int direction = info.getKind() & SyncInfo.DIRECTION_MASK; + if (direction == SyncInfo.CONFLICTING || direction == SyncInfo.INCOMING) { + return true; + } + } + } catch (TeamException e) { + // Log the exception and assume we don't need to update it + CVSProviderPlugin.log(e); + } + return false; + } + + private void performUpdate(IFile[] files, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + // TODO: This obtains the project rule which can cause a rule violation + new UpdateOperation(null /* no target part */, files, Command.NO_LOCAL_OPTIONS, null /* no tag */).run(monitor); + } + + private boolean isPromptUpdate() { + return ICVSUIConstants.PREF_UPDATE_PROMPT_IF_OUTDATED.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT)); + } + + private boolean isNeverUpdate() { + return ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER.equals(CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_PROMPT)); + } + + @Override public ISchedulingRule validateEditRule(CVSResourceRuleFactory factory, IResource[] resources) { - if (!isNeverUpdate()) { - // We may need to perform an update so we need to obtain the lock on each project - Set projects = new HashSet(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (isReadOnly(resource)) - projects.add(resource.getProject()); - } - return createSchedulingRule(projects); - } - return internalValidateEditRule(factory, resources); - } + if (!isNeverUpdate()) { + // We may need to perform an update so we need to obtain the lock on each project + Set projects = new HashSet(); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + if (isReadOnly(resource)) + projects.add(resource.getProject()); + } + return createSchedulingRule(projects); + } + return internalValidateEditRule(factory, resources); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryTableProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryTableProvider.java index 3e43a48e4..30334fc91 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryTableProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/HistoryTableProvider.java @@ -409,7 +409,7 @@ public class HistoryTableProvider { */ private SelectionListener getColumnListener(final TableViewer tableViewer) { /** - * This class handles selections of the column headers. + * This class handles selections of the column headers. * Selection of the column header will cause resorting * of the shown tasks using that column's sorter. * Repeated selection of the header will toggle diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java index 0a3551b83..1d64b5945 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java @@ -48,8 +48,8 @@ public interface ICVSUIConstants { public final String IMG_CHANGELOG = "obj16/changelog_obj.gif"; //$NON-NLS-1$ public final String IMG_LOCALREVISION_TABLE = "obj16/local_entry_tbl.gif"; //$NON-NLS-1$ - public final String IMG_REMOTEREVISION_TABLE = "obj16/remote_entry_tbl.gif"; //$NON-NLS-1$ - + public final String IMG_REMOTEREVISION_TABLE = "obj16/remote_entry_tbl.gif"; //$NON-NLS-1$ + // toolbar public final String IMG_REFRESH = "elcl16/refresh.gif"; //$NON-NLS-1$ public final String IMG_CLEAR = "elcl16/clear_co.gif"; //$NON-NLS-1$ @@ -119,17 +119,17 @@ public interface ICVSUIConstants { public final String PREF_SHOW_AUTHOR_IN_EDITOR = "pref_show_author_in_editor"; //$NON-NLS-1$ public final String PREF_COMMIT_SET_DEFAULT_ENABLEMENT = "pref_enable_commit_sets"; //$NON-NLS-1$ public final String PREF_AUTO_REFRESH_TAGS_IN_TAG_SELECTION_DIALOG = "pref_auto_refresh_tags_in_tag_selection_dialog"; //$NON-NLS-1$ - public final String PREF_COMMIT_FILES_DISPLAY_THRESHOLD = "pref_commit_files_display_threshold"; //$NON-NLS-1$ - public final String PREF_COMMIT_COMMENTS_MAX_HISTORY = "pref_commit_comments_max_history"; //$NON-NLS-1$ - public final String PREF_AUTO_SHARE_ON_IMPORT = "pref_auto_share_on_import"; //$NON-NLS-1$ + public final String PREF_COMMIT_FILES_DISPLAY_THRESHOLD = "pref_commit_files_display_threshold"; //$NON-NLS-1$ + public final String PREF_COMMIT_COMMENTS_MAX_HISTORY = "pref_commit_comments_max_history"; //$NON-NLS-1$ + public final String PREF_AUTO_SHARE_ON_IMPORT = "pref_auto_share_on_import"; //$NON-NLS-1$ public final String PREF_ENABLE_WATCH_ON_EDIT = "pref_enable_watch_on_edit"; //$NON-NLS-1$ - public final String PREF_USE_PROJECT_NAME_ON_CHECKOUT = "pref_use_project_name_on_checkout"; //$NON-NLS-1$ - public final String PREF_INCLUDE_CHANGE_SETS_IN_COMMIT = "pref_include_change_sets"; //$NON-NLS-1$ - public final String PREF_ANNOTATE_PROMPTFORBINARY = "pref_annotate_promptforbinary"; //$NON-NLS-1$ - public final String PREF_ALLOW_COMMIT_WITH_WARNINGS = "pref_commit_with_warning"; //$NON-NLS-1$ - public final String PREF_ALLOW_COMMIT_WITH_ERRORS = "pref_commit_with_errors"; //$NON-NLS-1$ - - + public final String PREF_USE_PROJECT_NAME_ON_CHECKOUT = "pref_use_project_name_on_checkout"; //$NON-NLS-1$ + public final String PREF_INCLUDE_CHANGE_SETS_IN_COMMIT = "pref_include_change_sets"; //$NON-NLS-1$ + public final String PREF_ANNOTATE_PROMPTFORBINARY = "pref_annotate_promptforbinary"; //$NON-NLS-1$ + public final String PREF_ALLOW_COMMIT_WITH_WARNINGS = "pref_commit_with_warning"; //$NON-NLS-1$ + public final String PREF_ALLOW_COMMIT_WITH_ERRORS = "pref_commit_with_errors"; //$NON-NLS-1$ + + // console preferences public final String PREF_CONSOLE_COMMAND_COLOR = "pref_console_command_color"; //$NON-NLS-1$ public final String PREF_CONSOLE_MESSAGE_COLOR = "pref_console_message_color"; //$NON-NLS-1$ @@ -162,17 +162,17 @@ public interface ICVSUIConstants { public final String PREF_EDIT_ACTION = "pref_edit_action"; //$NON-NLS-1$ public final String PREF_EDIT_PROMPT_EDIT = "edit"; //$NON-NLS-1$ public final String PREF_EDIT_PROMPT_HIGHJACK = "highjack"; //$NON-NLS-1$ - public final String PREF_EDIT_IN_BACKGROUND = "editInBackground"; //$NON-NLS-1$ + public final String PREF_EDIT_IN_BACKGROUND = "editInBackground"; //$NON-NLS-1$ public final String PREF_EDIT_PROMPT = "pref_edit_prompt"; //$NON-NLS-1$ public final String PREF_EDIT_PROMPT_NEVER = "never"; //$NON-NLS-1$ public final String PREF_EDIT_PROMPT_ALWAYS = "always"; //$NON-NLS-1$ public final String PREF_EDIT_PROMPT_IF_EDITORS = "only"; //$NON-NLS-1$ - - // update preferences - public final String PREF_UPDATE_PROMPT = "pref_update_prompt"; //$NON-NLS-1$ - public final String PREF_UPDATE_PROMPT_NEVER = "never"; //$NON-NLS-1$ - public final String PREF_UPDATE_PROMPT_AUTO = "auto"; //$NON-NLS-1$ - public final String PREF_UPDATE_PROMPT_IF_OUTDATED = "only"; //$NON-NLS-1$ + + // update preferences + public final String PREF_UPDATE_PROMPT = "pref_update_prompt"; //$NON-NLS-1$ + public final String PREF_UPDATE_PROMPT_NEVER = "never"; //$NON-NLS-1$ + public final String PREF_UPDATE_PROMPT_AUTO = "auto"; //$NON-NLS-1$ + public final String PREF_UPDATE_PROMPT_IF_OUTDATED = "only"; //$NON-NLS-1$ // Repositories view preferences public final String PREF_GROUP_VERSIONS_BY_PROJECT = "pref_group_versions_by_project"; //$NON-NLS-1$ @@ -192,7 +192,7 @@ public interface ICVSUIConstants { public final String PREF_ENABLE_MODEL_SYNC = "enableModelSync"; //$NON-NLS-1$ public final String PREF_OPEN_COMPARE_EDITOR_FOR_SINGLE_FILE = "openCompareEditorForSingleFile"; //$NON-NLS-1$ - + // Wizard banners public final String IMG_WIZBAN_SHARE = "wizban/newconnect_wizban.png"; //$NON-NLS-1$ public final String IMG_WIZBAN_MERGE = "wizban/mergestream_wizban.png"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java index 5d97decff..019345df0 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IHelpContextIds.java @@ -35,9 +35,9 @@ public interface IHelpContextIds { public static final String DATE_TAG_DIALOG = PREFIX + "date_tag_dialog_context"; //$NON-NLS-1$ public static final String KEYBOARD_INTERACTIVE_DIALOG = PREFIX + "keyboard_interactive_dialog_context"; //$NON-NLS-1$ public static final String COMMIT_SET_DIALOG = PREFIX + "commit_set_dialog_context"; //$NON-NLS-1$ - public static final String TAG_UNCOMMITED_PROMPT = PREFIX + "tag_uncommmited_dialog_context"; //$NON-NLS-1$ - public static final String ALTERNATIVE_REPOSITORY_DIALOG = PREFIX + "alternative_repository_dialog_context"; //$NON-NLS-1$ - public static final String REPOSITORY_FILTER_DIALOG = PREFIX + "repository_filter_dialog_context"; //$NON-NLS-1$ + public static final String TAG_UNCOMMITED_PROMPT = PREFIX + "tag_uncommmited_dialog_context"; //$NON-NLS-1$ + public static final String ALTERNATIVE_REPOSITORY_DIALOG = PREFIX + "alternative_repository_dialog_context"; //$NON-NLS-1$ + public static final String REPOSITORY_FILTER_DIALOG = PREFIX + "repository_filter_dialog_context"; //$NON-NLS-1$ // Different uses of the TagSelectionDialog public static final String REPLACE_TAG_SELECTION_DIALOG = PREFIX + "replace_tag_selection_dialog_context"; //$NON-NLS-1$ @@ -64,7 +64,7 @@ public interface IHelpContextIds { public static final String KEYWORD_SUBSTITUTION_PAGE = PREFIX + "keyword_substitution_page_context"; //$NON-NLS-1$ - public static final String MERGE_WIZARD_PAGE = PREFIX + "merge_wizard_page_context"; //$NON-NLS-1$ + public static final String MERGE_WIZARD_PAGE = PREFIX + "merge_wizard_page_context"; //$NON-NLS-1$ public static final String MERGE_START_PAGE = PREFIX + "merge_start_page_context"; //$NON-NLS-1$ public static final String MERGE_END_PAGE = PREFIX + "merge_end_page_context"; //$NON-NLS-1$ @@ -79,9 +79,9 @@ public interface IHelpContextIds { public static final String RESTORE_FROM_REPOSITORY_FILE_SELECTION_PAGE = PREFIX + "restore_from_repository_file_selection_page_context"; //$NON-NLS-1$ public static final String REFRESH_REMOTE_PROJECT_SELECTION_PAGE = PREFIX + "refresh_remote_project_selection_page_context"; //$NON-NLS-1$ - public static final String COMMIT_FILE_TYPES_PAGE = PREFIX + "commit_file_types_page_context"; //$NON-NLS-1$ - public static final String COMMIT_COMMENT_PAGE = PREFIX + "commit_comment_page_context"; //$NON-NLS-1$ - + public static final String COMMIT_FILE_TYPES_PAGE = PREFIX + "commit_file_types_page_context"; //$NON-NLS-1$ + public static final String COMMIT_COMMENT_PAGE = PREFIX + "commit_comment_page_context"; //$NON-NLS-1$ + public static final String CVS_SCM_URL_IMPORT_PAGE = PREFIX + "cvs_scm_url_import_page"; //$NON-NLS-1$ // Preference Pages @@ -104,10 +104,10 @@ public interface IHelpContextIds { public static final String PREF_CONFIRM_MOVE_TAG = PREFIX + "confirm_move_tag"; //$NON-NLS-1$ public static final String PREF_AUTOREFRESH_TAG = PREFIX + "auto_refresh_tag"; //$NON-NLS-1$ - public static final String GENERAL_PREFERENCE_PAGE = PREFIX + "general_preference_page_context"; //$NON-NLS-1$ + public static final String GENERAL_PREFERENCE_PAGE = PREFIX + "general_preference_page_context"; //$NON-NLS-1$ public static final String CONSOLE_PREFERENCE_PAGE = PREFIX + "console_preference_page_context"; //$NON-NLS-1$ public static final String EXT_PREFERENCE_PAGE = PREFIX + "ext_preference_page_context"; //$NON-NLS-1$ - public static final String SSH2_PREFERENCE_PAGE = PREFIX + "ssh2_preference_page_context"; //$NON-NLS-1$ + public static final String SSH2_PREFERENCE_PAGE = PREFIX + "ssh2_preference_page_context"; //$NON-NLS-1$ public static final String EXT_PREFERENCE_RSH = PREFIX + "ext_preference_rsh_context"; //$NON-NLS-1$ public static final String EXT_PREFERENCE_PARAM = PREFIX + "ext_preference_param_context"; //$NON-NLS-1$ public static final String EXT_PREFERENCE_SERVER = PREFIX + "ext_preference_server_context"; //$NON-NLS-1$ @@ -115,9 +115,9 @@ public interface IHelpContextIds { public static final String WATCH_EDIT_PREFERENCE_PAGE = PREFIX + "watch_edit_preference_page_context"; //$NON-NLS-1$ public static final String PASSWORD_MANAGEMENT_PAGE = PREFIX + "password_management_preference_page_context"; //$NON-NLS-1$ public static final String COMPARE_PREFERENCE_PAGE = PREFIX + "cvs_compare_preference_page_context"; //$NON-NLS-1$ - public static final String PROXY_PREFERENCE_PAGE = PREFIX + "proxy_preference_page_context"; //$NON-NLS-1$ - public static final String COMMENT_TEMPLATE_PREFERENCE_PAGE = PREFIX + "comment_template_preference_page_context"; //$NON-NLS-1$ - public static final String UPDATE_MERGE_PREFERENCE_PAGE = PREFIX + "update_merge_preference_page_context"; //$NON-NLS-1$ + public static final String PROXY_PREFERENCE_PAGE = PREFIX + "proxy_preference_page_context"; //$NON-NLS-1$ + public static final String COMMENT_TEMPLATE_PREFERENCE_PAGE = PREFIX + "comment_template_preference_page_context"; //$NON-NLS-1$ + public static final String UPDATE_MERGE_PREFERENCE_PAGE = PREFIX + "update_merge_preference_page_context"; //$NON-NLS-1$ // Views public static final String CONSOLE_VIEW = PREFIX + "console_view_context"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IgnoreResourcesDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IgnoreResourcesDialog.java index d82a0d188..cdc1748cc 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IgnoreResourcesDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IgnoreResourcesDialog.java @@ -50,14 +50,14 @@ public class IgnoreResourcesDialog extends TitleAreaDialog { // layout controls private static final int LABEL_INDENT_WIDTH = 32; - /** - * Image for title area - */ - private Image dlgTitleImage = null; - - // to avoid an error/warning message at startup default values are as below - private boolean resourceWithSpaces = false; - private boolean allResourecesHaveExtensions = true; + /** + * Image for title area + */ + private Image dlgTitleImage = null; + + // to avoid an error/warning message at startup default values are as below + private boolean resourceWithSpaces = false; + private boolean allResourecesHaveExtensions = true; private boolean allResourcesWithSpacesHaveExtensions = true; /** @@ -143,7 +143,7 @@ public class IgnoreResourcesDialog extends TitleAreaDialog { top.setLayout(layout); top.setLayoutData(new GridData(GridData.FILL_BOTH)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(top, IHelpContextIds.ADD_TO_CVSIGNORE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(top, IHelpContextIds.ADD_TO_CVSIGNORE); Listener selectionListener = event -> updateEnablements(); Listener modifyListener = event -> validate(); @@ -202,7 +202,7 @@ public class IgnoreResourcesDialog extends TitleAreaDialog { addCustomEntryButton.setSelection(true); selectedAction = ADD_CUSTOM_ENTRY; } - + } else { customEntryText = createIndentedText(top, resources[0].getName(), LABEL_INDENT_WIDTH); @@ -353,11 +353,11 @@ public class IgnoreResourcesDialog extends TitleAreaDialog { return false; } - @Override + @Override public boolean close() { - if (dlgTitleImage != null) { + if (dlgTitleImage != null) { dlgTitleImage.dispose(); } - return super.close(); - } + return super.close(); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java index ecd1ecc1d..b9c3d6c69 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java @@ -33,65 +33,65 @@ import org.eclipse.ui.PlatformUI; * A dialog for keyboard-interactive authentication for the ssh2 connection. */ public class KeyboardInteractiveDialog extends TrayDialog { - // widgets - private Text[] texts; - protected Image keyLockImage; - protected Button allowCachingButton; - protected Text usernameField; + // widgets + private Text[] texts; + protected Image keyLockImage; + protected Button allowCachingButton; + protected Text usernameField; - protected String userName; - protected String domain; - protected String destination; - protected String name; - protected String instruction; - protected String lang; - protected String[] prompt; - protected boolean[] echo; - private String message; - private String[] result; - protected boolean allowCaching=false; - private boolean cachingDialog=false; - - private boolean isPasswordAuth=false; + protected String userName; + protected String domain; + protected String destination; + protected String name; + protected String instruction; + protected String lang; + protected String[] prompt; + protected boolean[] echo; + private String message; + private String[] result; + protected boolean allowCaching=false; + private boolean cachingDialog=false; + + private boolean isPasswordAuth=false; - /** - * Creates a new KeyboardInteractiveDialog. - * - * @param parentShell the parent shell - * @param destication the location - * @param name the name - * @param instruction the instruction - * @param prompt the titles for text fields - * @param echo '*' should be used or not - */ - public KeyboardInteractiveDialog(Shell parentShell, - String location, - String destination, - String name, - String userName, - String instruction, - String[] prompt, - boolean[] echo, - boolean cachingDialog){ - super(parentShell); - this.domain=location; - this.destination=destination; - this.name=name; - this.userName=userName; - this.instruction=instruction; - this.prompt=prompt; - this.echo=echo; - this.cachingDialog=cachingDialog; - - this.message=NLS.bind(CVSUIMessages.KeyboradInteractiveDialog_message, new String[] { destination+(name!=null && name.length()>0 ? ": "+name : "") }); //NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$ - - if(KeyboardInteractiveDialog.isPasswordAuth(prompt)){ - isPasswordAuth=true; - } - } + /** + * Creates a new KeyboardInteractiveDialog. + * + * @param parentShell the parent shell + * @param destication the location + * @param name the name + * @param instruction the instruction + * @param prompt the titles for text fields + * @param echo '*' should be used or not + */ + public KeyboardInteractiveDialog(Shell parentShell, + String location, + String destination, + String name, + String userName, + String instruction, + String[] prompt, + boolean[] echo, + boolean cachingDialog){ + super(parentShell); + this.domain=location; + this.destination=destination; + this.name=name; + this.userName=userName; + this.instruction=instruction; + this.prompt=prompt; + this.echo=echo; + this.cachingDialog=cachingDialog; + + this.message=NLS.bind(CVSUIMessages.KeyboradInteractiveDialog_message, new String[] { destination+(name!=null && name.length()>0 ? ": "+name : "") }); //NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$ + + if(KeyboardInteractiveDialog.isPasswordAuth(prompt)){ + isPasswordAuth=true; + } + } - @Override + @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); if (isPasswordAuth) { @@ -105,7 +105,7 @@ protected void configureShell(Shell newShell) { IHelpContextIds.KEYBOARD_INTERACTIVE_DIALOG); } - @Override + @Override public void create() { super.create(); @@ -119,7 +119,7 @@ public void create() { } } - @Override + @Override protected Control createDialogArea(Composite parent) { Composite top = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); @@ -209,106 +209,106 @@ protected Control createDialogArea(Composite parent) { Dialog.applyDialogFont(parent); return main; } - - /** - * Creates the three widgets that represent the user name entry area. - * - * @param parent the parent of the widgets - */ - protected void createUsernameFields(Composite parent){ - new Label(parent, SWT.NONE).setText(CVSUIMessages.UserValidationDialog_user); + + /** + * Creates the three widgets that represent the user name entry area. + * + * @param parent the parent of the widgets + */ + protected void createUsernameFields(Composite parent){ + new Label(parent, SWT.NONE).setText(CVSUIMessages.UserValidationDialog_user); - usernameField=new Text(parent, SWT.BORDER); - GridData data=new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan=2; - data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); - usernameField.setLayoutData(data); - } - - /** + usernameField=new Text(parent, SWT.BORDER); + GridData data=new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan=2; + data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); + usernameField.setLayoutData(data); + } + + /** * Creates the widgets that represent the entry area. * * @param parent * the parent of the widgets */ - protected void createPasswordFields(Composite parent) { - texts=new Text[prompt.length]; + protected void createPasswordFields(Composite parent) { + texts=new Text[prompt.length]; - for(int i=0; i<prompt.length; i++){ - new Label(parent, SWT.NONE).setText(prompt[i]); - texts[i]=new Text(parent, SWT.BORDER|SWT.PASSWORD); - GridData data=new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan=2; - data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); - texts[i].setLayoutData(data); - if(!echo[i]){ - texts[i].setEchoChar('*'); - } - } - } - /** - * Returns the entered values, or null - * if the user canceled. - * - * @return the entered values - */ - public String[] getResult() { - return result; - } - - /** - * Returns <code>true</code> if the save password checkbox was selected. - * @return <code>true</code> if the save password checkbox was selected and <code>false</code> - * otherwise. - */ - public boolean getAllowCaching(){ - return allowCaching; - } - - /** - * Notifies that the ok button of this dialog has been pressed. - * <p> - * The default implementation of this framework method sets - * this dialog's return code to <code>Window.OK</code> - * and closes the dialog. Subclasses may override. - * </p> - */ - @Override + for(int i=0; i<prompt.length; i++){ + new Label(parent, SWT.NONE).setText(prompt[i]); + texts[i]=new Text(parent, SWT.BORDER|SWT.PASSWORD); + GridData data=new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan=2; + data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH); + texts[i].setLayoutData(data); + if(!echo[i]){ + texts[i].setEchoChar('*'); + } + } + } + /** + * Returns the entered values, or null + * if the user canceled. + * + * @return the entered values + */ + public String[] getResult() { + return result; + } + + /** + * Returns <code>true</code> if the save password checkbox was selected. + * @return <code>true</code> if the save password checkbox was selected and <code>false</code> + * otherwise. + */ + public boolean getAllowCaching(){ + return allowCaching; + } + + /** + * Notifies that the ok button of this dialog has been pressed. + * <p> + * The default implementation of this framework method sets + * this dialog's return code to <code>Window.OK</code> + * and closes the dialog. Subclasses may override. + * </p> + */ + @Override protected void okPressed() { - result=new String[prompt.length]; - for(int i=0; i<texts.length; i++){ - result[i]=texts[i].getText(); - } - super.okPressed(); - } - /** - * Notifies that the cancel button of this dialog has been pressed. - * <p> - * The default implementation of this framework method sets - * this dialog's return code to <code>Window.CANCEL</code> - * and closes the dialog. Subclasses may override. - * </p> - */ - @Override + result=new String[prompt.length]; + for(int i=0; i<texts.length; i++){ + result[i]=texts[i].getText(); + } + super.okPressed(); + } + /** + * Notifies that the cancel button of this dialog has been pressed. + * <p> + * The default implementation of this framework method sets + * this dialog's return code to <code>Window.CANCEL</code> + * and closes the dialog. Subclasses may override. + * </p> + */ + @Override protected void cancelPressed() { - result=null; - super.cancelPressed(); - } - + result=null; + super.cancelPressed(); + } + @Override - public boolean close(){ - if(keyLockImage!=null){ - keyLockImage.dispose(); - } - return super.close(); - } - - /** - * Guesses if this dialog is used for password authentication. - * @param prompt prompts for keyboard-interactive authentication method. - * @return <code>true</code> if this dialog is used for password authentication. - */ - static boolean isPasswordAuth(String[] prompt) { + public boolean close(){ + if(keyLockImage!=null){ + keyLockImage.dispose(); + } + return super.close(); + } + + /** + * Guesses if this dialog is used for password authentication. + * @param prompt prompts for keyboard-interactive authentication method. + * @return <code>true</code> if this dialog is used for password authentication. + */ + static boolean isPasswordAuth(String[] prompt) { return prompt != null && prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:"); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java index 78b7e90e6..34cbb7403 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ListSelectionArea.java @@ -63,10 +63,10 @@ public class ListSelectionArea extends DialogArea { @Override public void createArea(Composite parent) { - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); - final Composite composite = createComposite(parent, 1, true); - + final Composite composite = createComposite(parent, 1, true); + initializeDialogUnits(composite); if (message != null) @@ -156,7 +156,7 @@ public class ListSelectionArea extends DialogArea { protected List getInitialElementSelections(){ return initialSelections; } - + /** * Returns the listViewer. * @return CheckboxTableViewer diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/Policy.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/Policy.java index 08ac28e5e..2a40ba598 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/Policy.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/Policy.java @@ -21,10 +21,10 @@ import org.eclipse.osgi.service.debug.DebugOptionsListener; import org.eclipse.team.internal.core.InfiniteSubProgressMonitor; public class Policy { - - private static String ACTION_BUNDLE = "org.eclipse.team.internal.ccvs.ui.actions.actions"; //$NON-NLS-1$ - private static ResourceBundle actionBundle = null; - + + private static String ACTION_BUNDLE = "org.eclipse.team.internal.ccvs.ui.actions.actions"; //$NON-NLS-1$ + private static ResourceBundle actionBundle = null; + public static boolean DEBUG_CONSOLE_BUFFERING = false; public static boolean DEBUG_HISTORY = false; @@ -68,9 +68,9 @@ public class Policy { } public static ResourceBundle getActionBundle() { - ResourceBundle tmpBundle = actionBundle; - if (tmpBundle != null) - return tmpBundle; - return actionBundle = ResourceBundle.getBundle(ACTION_BUNDLE); + ResourceBundle tmpBundle = actionBundle; + if (tmpBundle != null) + return tmpBundle; + return actionBundle = ResourceBundle.getBundle(ACTION_BUNDLE); } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java index 885fa480b..6a58398b4 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ReleaseCommentDialog.java @@ -35,7 +35,7 @@ public class ReleaseCommentDialog extends DetailsDialog { // dialogs settings that are persistent between workbench sessions private IDialogSettings settings; - private static final int DEFAULT_WIDTH_IN_CHARS= 80; + private static final int DEFAULT_WIDTH_IN_CHARS= 80; private static final String HEIGHT_KEY = "width-key"; //$NON-NLS-1$ private static final String WIDTH_KEY = "height-key"; //$NON-NLS-1$ @@ -89,23 +89,23 @@ public class ReleaseCommentDialog extends DetailsDialog { } }); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); } @Override - protected String getHelpContextId() { - return IHelpContextIds.RELEASE_COMMENT_DIALOG; - } - + protected String getHelpContextId() { + return IHelpContextIds.RELEASE_COMMENT_DIALOG; + } + @Override protected Point getInitialSize() { try { - return new Point(settings.getInt(WIDTH_KEY), settings.getInt(HEIGHT_KEY)); + return new Point(settings.getInt(WIDTH_KEY), settings.getInt(HEIGHT_KEY)); } catch(NumberFormatException e) { - final Point size= super.getInitialSize(); - size.x= convertWidthInCharsToPixels(DEFAULT_WIDTH_IN_CHARS); - size.y += convertHeightInCharsToPixels(8); - return size; + final Point size= super.getInitialSize(); + size.x= convertWidthInCharsToPixels(DEFAULT_WIDTH_IN_CHARS); + size.y += convertHeightInCharsToPixels(8); + return size; } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteRevisionQuickDiffProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteRevisionQuickDiffProvider.java index 941fe1058..2a82e1676 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteRevisionQuickDiffProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RemoteRevisionQuickDiffProvider.java @@ -93,7 +93,7 @@ public class RemoteRevisionQuickDiffProvider implements IQuickDiffReferenceProvi ISubscriberChangeEvent delta = deltas[i]; IResource resource = delta.getResource(); if(resource.getType() == IResource.FILE && - fLastSyncState != null && resource.equals(fLastSyncState.getLocal())) { + fLastSyncState != null && resource.equals(fLastSyncState.getLocal())) { if(delta.getFlags() == ISubscriberChangeEvent.SYNC_CHANGED) { fetchContentsInJob(); } @@ -143,7 +143,7 @@ public class RemoteRevisionQuickDiffProvider implements IQuickDiffReferenceProvi @Override public void setActiveEditor(ITextEditor targetEditor) { IEditorInput editorInput = targetEditor.getEditorInput(); - if (editorInput == null || ResourceUtil.getFile(editorInput) == null) return; + if (editorInput == null || ResourceUtil.getFile(editorInput) == null) return; fEditor = targetEditor; fDocumentProvider= fEditor.getDocumentProvider(); @@ -318,10 +318,10 @@ public class RemoteRevisionQuickDiffProvider implements IQuickDiffReferenceProvi private IFile getFileFromEditor() { if(fEditor != null) { IEditorInput input= fEditor.getEditorInput(); - if (input != null) { - IFile file = ResourceUtil.getFile(input); - return file; - } + if (input != null) { + IFile file = ResourceUtil.getFile(input); + return file; + } } return null; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java index f1cf28e85..ab46aa943 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ResourcePropertiesPage.java @@ -67,7 +67,7 @@ public class ResourcePropertiesPage extends PropertyPage { } catch (TeamException e) { createPair(composite, CVSUIMessages.ResourcePropertiesPage_error, e.getMessage()); } - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); return composite; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java index b7696be26..8f5e319db 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/UserValidationDialog.java @@ -73,7 +73,7 @@ public class UserValidationDialog extends TrayDialog { */ public UserValidationDialog(Shell parentShell, String location, String defaultName, String message, boolean cachingCheckbox) { super(parentShell); - setShellStyle(getShellStyle() | SWT.RESIZE); + setShellStyle(getShellStyle() | SWT.RESIZE); this.defaultUsername = defaultName; this.domain = location; this.message = message; @@ -85,7 +85,7 @@ public class UserValidationDialog extends TrayDialog { super.configureShell(newShell); newShell.setText(CVSUIMessages.UserValidationDialog_required); // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IHelpContextIds.USER_VALIDATION_DIALOG); + PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IHelpContextIds.USER_VALIDATION_DIALOG); } @Override @@ -171,8 +171,8 @@ public class UserValidationDialog extends TrayDialog { }); } - Dialog.applyDialogFont(parent); - + Dialog.applyDialogFont(parent); + return main; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java index d7ae00144..24c24657b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WatchEditPreferencePage.java @@ -24,7 +24,7 @@ import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage { private RadioGroupFieldEditor promptEditor; - private RadioGroupFieldEditor updateEditor; + private RadioGroupFieldEditor updateEditor; private RadioGroupFieldEditor actionEditor; private IPreferenceStore store; @@ -56,7 +56,7 @@ public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage { CVSUIMessages.WatchEditPreferencePage_validateEditSaveAction, 1, new String[][] {{CVSUIMessages.WatchEditPreferencePage_edit, ICVSUIConstants.PREF_EDIT_PROMPT_EDIT}, - {CVSUIMessages.WatchEditPreferencePage_editInBackground, ICVSUIConstants.PREF_EDIT_IN_BACKGROUND}, + {CVSUIMessages.WatchEditPreferencePage_editInBackground, ICVSUIConstants.PREF_EDIT_IN_BACKGROUND}, {CVSUIMessages.WatchEditPreferencePage_highjack, ICVSUIConstants.PREF_EDIT_PROMPT_HIGHJACK}, }, // getFieldEditorParent(), true); @@ -71,20 +71,20 @@ public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage { {CVSUIMessages.WatchEditPreferencePage_neverPrompt, ICVSUIConstants.PREF_EDIT_PROMPT_NEVER}, }, // getFieldEditorParent(), true); - - updateEditor = new RadioGroupFieldEditor( - ICVSUIConstants.PREF_UPDATE_PROMPT, - CVSUIMessages.WatchEditPreferencePage_updatePrompt, - 1, - new String[][] {{CVSUIMessages.WatchEditPreferencePage_autoUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_AUTO}, - {CVSUIMessages.WatchEditPreferencePage_promptUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_IF_OUTDATED}, - {CVSUIMessages.WatchEditPreferencePage_neverUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER}, - }, // - getFieldEditorParent(), true); - + + updateEditor = new RadioGroupFieldEditor( + ICVSUIConstants.PREF_UPDATE_PROMPT, + CVSUIMessages.WatchEditPreferencePage_updatePrompt, + 1, + new String[][] {{CVSUIMessages.WatchEditPreferencePage_autoUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_AUTO}, + {CVSUIMessages.WatchEditPreferencePage_promptUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_IF_OUTDATED}, + {CVSUIMessages.WatchEditPreferencePage_neverUpdate, ICVSUIConstants.PREF_UPDATE_PROMPT_NEVER}, + }, // + getFieldEditorParent(), true); + store = getCVSPreferenceStore(); addField(promptEditor); - addField(updateEditor); + addField(updateEditor); } private boolean isEditEnabled() { @@ -106,10 +106,10 @@ public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage { @Override public void propertyChange(PropertyChangeEvent event) { if (event.getSource() == actionEditor) { - boolean enabled = event.getNewValue().equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT); + boolean enabled = event.getNewValue().equals(ICVSUIConstants.PREF_EDIT_PROMPT_EDIT); promptEditor.setEnabled(enabled, getFieldEditorParent()); - updateEditor.setEnabled(enabled, getFieldEditorParent()); - } + updateEditor.setEnabled(enabled, getFieldEditorParent()); + } super.propertyChange(event); } @@ -117,6 +117,6 @@ public class WatchEditPreferencePage extends CVSFieldEditorPreferencePage { protected void initialize() { super.initialize(); promptEditor.setEnabled(isEditEnabled(), getFieldEditorParent()); - updateEditor.setEnabled(isEditEnabled(), getFieldEditorParent()); + updateEditor.setEnabled(isEditEnabled(), getFieldEditorParent()); } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java index 03dc364f9..00943a978 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkbenchUserAuthenticator.java @@ -166,24 +166,24 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { */ @Override public String[] promptForKeyboradInteractive(final ICVSRepositoryLocation location, - final String destination, - final String name, - final String instruction, - final String[] prompt, - final boolean[] echo) throws CVSException { - final String[][] result = new String[1][]; - final boolean[] allowCaching=new boolean[1]; - Display display = Display.getCurrent(); - if (display != null) { + final String destination, + final String name, + final String instruction, + final String[] prompt, + final boolean[] echo) throws CVSException { + final String[][] result = new String[1][]; + final boolean[] allowCaching=new boolean[1]; + Display display = Display.getCurrent(); + if (display != null) { result[0]=_promptForUserInteractive(location, destination, name, instruction, prompt, echo, allowCaching); - } - else { - // sync exec in default thread + } + else { + // sync exec in default thread Display.getDefault().syncExec(() -> result[0] = _promptForUserInteractive(location, destination, name, instruction, prompt, echo, allowCaching)); - } - if (result[0] != null && location != null && - KeyboardInteractiveDialog.isPasswordAuth(prompt)) { + } + if (result[0] != null && location != null && + KeyboardInteractiveDialog.isPasswordAuth(prompt)) { location.setPassword(result[0][0]); location.setAllowCaching(allowCaching[0]); } @@ -191,12 +191,12 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { } private String[] _promptForUserInteractive(final ICVSRepositoryLocation location, - final String destination, - final String name, - final String instruction, - final String[] prompt, - final boolean[] echo, - final boolean[] allowCaching) { + final String destination, + final String name, + final String instruction, + final String[] prompt, + final boolean[] echo, + final boolean[] allowCaching) { String domain = location == null ? null : location.getLocation(true); String userName = location == null ? null : location.getUsername(); @@ -233,10 +233,10 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { echo, cachingCheckbox); dialog.open(); - String[] _result=dialog.getResult(); - if(_result!=null) - allowCaching[0]=dialog.getAllowCaching(); - return _result; + String[] _result=dialog.getResult(); + if(_result!=null) + allowCaching[0]=dialog.getAllowCaching(); + return _result; } /** @@ -294,20 +294,20 @@ public class WorkbenchUserAuthenticator implements IUserAuthenticator { }); return retval[0]; } - - @Override + + @Override public boolean promptForHostKeyChange(final ICVSRepositoryLocation location) { - final boolean[] openConfirm = new boolean[] { false }; - final Display display = CVSUIPlugin.getStandardDisplay(); + final boolean[] openConfirm = new boolean[] { false }; + final Display display = CVSUIPlugin.getStandardDisplay(); display.syncExec( () -> openConfirm[0] = MessageDialog.openConfirm(null, CVSUIMessages.WorkbenchUserAuthenticator_1, NLS.bind(CVSUIMessages.WorkbenchUserAuthenticator_2, new String[] { location.getHost() }))); - if (!openConfirm[0]) { - throw new OperationCanceledException(); - } - return openConfirm[0]; - } - + if (!openConfirm[0]) { + throw new OperationCanceledException(); + } + return openConfirm[0]; + } + @Override public Map promptToConfigureRepositoryLocations(final Map alternativeMap) { final Map[] result = new Map[1]; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java index 680c2efc1..29a699e29 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/WorkingSetSelectionArea.java @@ -81,19 +81,19 @@ public class WorkingSetSelectionArea extends DialogArea { } } }; - private final IDialogSettings settings; - private final Shell shell; + private final IDialogSettings settings; + private final Shell shell; public WorkingSetSelectionArea(Shell shell, String noWorkingSetText, String workingSetText, IDialogSettings settings) { this.shell = shell; - this.noWorkingSetText = noWorkingSetText; + this.noWorkingSetText = noWorkingSetText; this.workingSetText = workingSetText; - this.settings = settings; + this.settings = settings; } @Override public void createArea(Composite parent) { - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); final Composite composite = createComposite(parent, 2, false); initializeDialogUnits(composite); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java index 9625232ce..994318bf7 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/AddAction.java @@ -30,19 +30,19 @@ import org.eclipse.team.internal.ccvs.ui.wizards.AddWizard; * container is selected, its children are recursively added. */ public class AddAction extends WorkspaceTraversalAction { - + @Override public void execute(IAction action) throws InterruptedException, InvocationTargetException { - if (!promptForAddOfIgnored()) return; - if (!promptForAdd()) return; - AddOperation op = new AddOperation(getTargetPart(), getCVSResourceMappings()); - AddWizard.run(getShell(), op); + if (!promptForAddOfIgnored()) return; + if (!promptForAdd()) return; + AddOperation op = new AddOperation(getTargetPart(), getCVSResourceMappings()); + AddWizard.run(getShell(), op); } /* * Prompt the user to avoid accidental adding a resource to version control */ - private boolean promptForAdd() { + private boolean promptForAdd() { return MessageDialog.openQuestion(getShell(), CVSUIMessages.AddAction_confirmAddingResourcesTitle, CVSUIMessages.AddAction_confirmAddingResourcesMessage); @@ -52,8 +52,8 @@ public class AddAction extends WorkspaceTraversalAction { * Prompt whether explicitly selected ignored resources should be added */ private boolean promptForAddOfIgnored() { - // Prompt if any of the traversal roots are ignored - // TODO: What about non-root resources that are part of the model but would be ignored? + // Prompt if any of the traversal roots are ignored + // TODO: What about non-root resources that are part of the model but would be ignored? IResource[] resources = getSelectedResourcesWithOverlap(); boolean prompt = false; for (int i = 0; i < resources.length; i++) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java index 01f7cba49..18d5ae8e3 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java @@ -32,30 +32,30 @@ public class BranchAction extends WorkspaceTraversalAction { @Override public void execute(IAction action) throws InvocationTargetException, InterruptedException { ResourceMapping[] resourceMappings = getCVSResourceMappings(); - if (resourceMappings == null || resourceMappings.length == 0) { - // Could be a sync element tat is selected - IResource[] resources = getSelectedResources(); - resourceMappings = getResourceMappings(resources); - } - if (resourceMappings == null || resourceMappings.length == 0) { - // Nothing is select so just return - return; - } - new BranchOperation(getTargetPart(), resourceMappings).run(); + if (resourceMappings == null || resourceMappings.length == 0) { + // Could be a sync element tat is selected + IResource[] resources = getSelectedResources(); + resourceMappings = getResourceMappings(resources); + } + if (resourceMappings == null || resourceMappings.length == 0) { + // Nothing is select so just return + return; + } + new BranchOperation(getTargetPart(), resourceMappings).run(); } private ResourceMapping[] getResourceMappings(IResource[] resources) { List<ResourceMapping> mappings = new ArrayList<>(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - Object o = getAdapter(resource, ResourceMapping.class); - if (o instanceof ResourceMapping) { - ResourceMapping mapping = (ResourceMapping) o; - mappings.add(mapping); - } - } - return mappings.toArray(new ResourceMapping[mappings.size()]); - } + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + Object o = getAdapter(resource, ResourceMapping.class); + if (o instanceof ResourceMapping) { + ResourceMapping mapping = (ResourceMapping) o; + mappings.add(mapping); + } + } + return mappings.toArray(new ResourceMapping[mappings.size()]); + } @Override public String getId() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java index 525167a46..4b1d51fe8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java @@ -166,17 +166,17 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg @Override public void dispose() { super.dispose(); - IWorkbenchWindow window = getWindow(); - if (window != null) { - IPartService partService = window.getPartService(); - if (partService != null) - partService.removePartListener(retargetAction); - } - - if(retargetAction != null) { - retargetAction.dispose(); - retargetAction = null; - } + IWorkbenchWindow window = getWindow(); + if (window != null) { + IPartService partService = window.getPartService(); + if (partService != null) + partService.removePartListener(retargetAction); + } + + if(retargetAction != null) { + retargetAction.dispose(); + retargetAction = null; + } } @Override @@ -593,23 +593,23 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg /* * @see org.eclipse.team.internal.ui.actions.TeamAction#getSelectedResources() */ - protected final IResource[] getSelectedResourcesWithOverlap() { - IStructuredSelection selection = getSelection(); - CVSActionSelectionProperties props = CVSActionSelectionProperties.getProperties(getSelection()); - if (props == null) { - return Utils.getContributedResources(selection.toArray()); - } - return props.getAllSelectedResources(); - } - + protected final IResource[] getSelectedResourcesWithOverlap() { + IStructuredSelection selection = getSelection(); + CVSActionSelectionProperties props = CVSActionSelectionProperties.getProperties(getSelection()); + if (props == null) { + return Utils.getContributedResources(selection.toArray()); + } + return props.getAllSelectedResources(); + } + @Override protected final IResource[] getSelectedResources() { IStructuredSelection selection = getSelection(); - CVSActionSelectionProperties props = CVSActionSelectionProperties.getProperties(getSelection()); - if (props == null) { - return CVSActionSelectionProperties.getNonOverlapping(Utils.getContributedResources(selection.toArray())); - } - return props.getNonoverlappingSelectedResources(); + CVSActionSelectionProperties props = CVSActionSelectionProperties.getProperties(getSelection()); + if (props == null) { + return CVSActionSelectionProperties.getNonOverlapping(Utils.getContributedResources(selection.toArray())); + } + return props.getNonoverlappingSelectedResources(); } @Override @@ -633,16 +633,16 @@ abstract public class CVSAction extends TeamAction implements IEditorActionDeleg public boolean isHandled() { return true; } - - protected final ICVSResource getCVSResourceFor(IResource resource) { - CVSActionSelectionProperties props = CVSActionSelectionProperties.getProperties(getSelection()); - if (props == null) { - return CVSWorkspaceRoot.getCVSResourceFor(resource); - } - return props.getCVSResourceFor(resource); - } + + protected final ICVSResource getCVSResourceFor(IResource resource) { + CVSActionSelectionProperties props = CVSActionSelectionProperties.getProperties(getSelection()); + if (props == null) { + return CVSWorkspaceRoot.getCVSResourceFor(resource); + } + return props.getCVSResourceFor(resource); + } - public static CVSTag getAccurateFileTag(ICVSResource cvsResource) throws CVSException { + public static CVSTag getAccurateFileTag(ICVSResource cvsResource) throws CVSException { CVSTag tag = null; if (cvsResource != null) { return Util.getAccurateFileTag(cvsResource, getTags(cvsResource)); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSActionSelectionProperties.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSActionSelectionProperties.java index efb33606d..15d44ad51 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSActionSelectionProperties.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSActionSelectionProperties.java @@ -26,127 +26,127 @@ import org.eclipse.team.internal.ui.Utils; * This class represents a selection for a set of CVS actions. */ public class CVSActionSelectionProperties { - - // Use a weak hash map so that the properties ae collected when the selection is no longer referenced + + // Use a weak hash map so that the properties ae collected when the selection is no longer referenced private static Map<IStructuredSelection, CVSActionSelectionProperties> selectionProperties = new WeakHashMap<>(); - - private Object[] selection; + + private Object[] selection; private Map<String, Object> properties = new HashMap<>(); - - private static final String SELECTED_RESOURCES = "selectedResources"; //$NON-NLS-1$ - private static final String NONOVERLAPPING_SELECTED_RESOURCES = "nonoverlappingSelectedResources"; //$NON-NLS-1$ - private static final String CVS_RESOURCE_MAP = "cvsResourceMap"; //$NON-NLS-1$ - - public static CVSActionSelectionProperties getProperties(IStructuredSelection selection) { - if (selection == null) return null; - CVSActionSelectionProperties props = selectionProperties.get(selection); - if (props == null) { - props = new CVSActionSelectionProperties(selection); - selectionProperties.put(selection, props); - } - return props; - } - - public CVSActionSelectionProperties(IStructuredSelection selection) { - // Copy the selection so that the WeakHashMap will not think the seleciton used for the key is still in use - this.selection = selection.toArray(); - } + + private static final String SELECTED_RESOURCES = "selectedResources"; //$NON-NLS-1$ + private static final String NONOVERLAPPING_SELECTED_RESOURCES = "nonoverlappingSelectedResources"; //$NON-NLS-1$ + private static final String CVS_RESOURCE_MAP = "cvsResourceMap"; //$NON-NLS-1$ + + public static CVSActionSelectionProperties getProperties(IStructuredSelection selection) { + if (selection == null) return null; + CVSActionSelectionProperties props = selectionProperties.get(selection); + if (props == null) { + props = new CVSActionSelectionProperties(selection); + selectionProperties.put(selection, props); + } + return props; + } + + public CVSActionSelectionProperties(IStructuredSelection selection) { + // Copy the selection so that the WeakHashMap will not think the seleciton used for the key is still in use + this.selection = selection.toArray(); + } - public void put(String key, Object value) { - properties.put(key, value); - } - - public Object get(String key) { - return properties.get(key); - } - - public IResource[] getAllSelectedResources() { - IResource[] resources = (IResource[])get(SELECTED_RESOURCES); - if (resources == null) { - resources = getResources(selection); - put(SELECTED_RESOURCES, resources); - } - return resources; - } + public void put(String key, Object value) { + properties.put(key, value); + } + + public Object get(String key) { + return properties.get(key); + } + + public IResource[] getAllSelectedResources() { + IResource[] resources = (IResource[])get(SELECTED_RESOURCES); + if (resources == null) { + resources = getResources(selection); + put(SELECTED_RESOURCES, resources); + } + return resources; + } - /* - * This method gets the resources from the given objects. - * It does so in a manner that is consistent with how the workbench does it. - * Tha is, it first uses IContributionResourceAdapter, then IResource, - * then ResourceMapping. - */ - private IResource[] getResources(Object[] objects) { - return Utils.getContributedResources(objects); - } - - public IResource[] getNonoverlappingSelectedResources() { - IResource[] resources = (IResource[])get(NONOVERLAPPING_SELECTED_RESOURCES); - if (resources == null) { - resources = getNonOverlapping(getAllSelectedResources()); - put (NONOVERLAPPING_SELECTED_RESOURCES, resources); - } - return resources; - } - - public ICVSResource getCVSResourceFor(IResource resource) { - Map map = (Map)get(CVS_RESOURCE_MAP); - if (map == null) { - map = new HashMap(); - put(CVS_RESOURCE_MAP, map); - } - ICVSResource cvsResource = (ICVSResource)map.get(resource); - if (cvsResource == null) { - cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - map.put(resource, cvsResource); - } - return cvsResource; - } - - /** - * Method getNonOverlapping ensures that a resource is not covered more than once. - * @param resources - * @return IResource[] - */ - public static IResource[] getNonOverlapping(IResource[] resources) { - if (resources == null || resources.length == 0 || resources.length == 1) { - return resources; - } - // Sort the resources so the shortest paths are first + /* + * This method gets the resources from the given objects. + * It does so in a manner that is consistent with how the workbench does it. + * Tha is, it first uses IContributionResourceAdapter, then IResource, + * then ResourceMapping. + */ + private IResource[] getResources(Object[] objects) { + return Utils.getContributedResources(objects); + } + + public IResource[] getNonoverlappingSelectedResources() { + IResource[] resources = (IResource[])get(NONOVERLAPPING_SELECTED_RESOURCES); + if (resources == null) { + resources = getNonOverlapping(getAllSelectedResources()); + put (NONOVERLAPPING_SELECTED_RESOURCES, resources); + } + return resources; + } + + public ICVSResource getCVSResourceFor(IResource resource) { + Map map = (Map)get(CVS_RESOURCE_MAP); + if (map == null) { + map = new HashMap(); + put(CVS_RESOURCE_MAP, map); + } + ICVSResource cvsResource = (ICVSResource)map.get(resource); + if (cvsResource == null) { + cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); + map.put(resource, cvsResource); + } + return cvsResource; + } + + /** + * Method getNonOverlapping ensures that a resource is not covered more than once. + * @param resources + * @return IResource[] + */ + public static IResource[] getNonOverlapping(IResource[] resources) { + if (resources == null || resources.length == 0 || resources.length == 1) { + return resources; + } + // Sort the resources so the shortest paths are first List<IResource> sorted = new ArrayList<>(); - sorted.addAll(Arrays.asList(resources)); + sorted.addAll(Arrays.asList(resources)); Collections.sort(sorted, new Comparator<IResource>() { - @Override + @Override public int compare(IResource resource0, IResource resource1) { - return resource0.getFullPath().segmentCount() - resource1.getFullPath().segmentCount(); - } - @Override + return resource0.getFullPath().segmentCount() - resource1.getFullPath().segmentCount(); + } + @Override public boolean equals(Object arg0) { - return false; - } - }); - // Collect all non-overlapping resources + return false; + } + }); + // Collect all non-overlapping resources List<IPath> coveredPaths = new ArrayList<>(); - for (Iterator iter = sorted.iterator(); iter.hasNext();) { - IResource resource = (IResource) iter.next(); - IPath resourceFullPath = resource.getFullPath(); - boolean covered = false; - for (Iterator it = coveredPaths.iterator(); it.hasNext();) { - IPath path = (IPath) it.next(); - if(path.isPrefixOf(resourceFullPath)) { - covered = true; - } - } - if (covered) { - // if the resource is covered by a parent, remove it - iter.remove(); - } else { - // if the resource is a non-covered folder, add it to the covered paths - if (resource.getType() == IResource.FOLDER) { - coveredPaths.add(resource.getFullPath()); - } - } - } - return sorted.toArray(new IResource[sorted.size()]); - } - + for (Iterator iter = sorted.iterator(); iter.hasNext();) { + IResource resource = (IResource) iter.next(); + IPath resourceFullPath = resource.getFullPath(); + boolean covered = false; + for (Iterator it = coveredPaths.iterator(); it.hasNext();) { + IPath path = (IPath) it.next(); + if(path.isPrefixOf(resourceFullPath)) { + covered = true; + } + } + if (covered) { + // if the resource is covered by a parent, remove it + iter.remove(); + } else { + // if the resource is a non-covered folder, add it to the covered paths + if (resource.getType() == IResource.FOLDER) { + coveredPaths.add(resource.getFullPath()); + } + } + } + return sorted.toArray(new IResource[sorted.size()]); + } + } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java index c24887c25..747e27a74 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CheckoutAction.java @@ -36,19 +36,19 @@ public class CheckoutAction extends CVSAction { } @Override - public boolean isEnabled() { - ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); - if (folders.length == 0) return false; - // only enabled when all folders are in the same repository - ICVSRepositoryLocation location = folders[0].getRepository(); - for (int i = 1; i < folders.length; i++) { - ICVSRemoteFolder folder = folders[i]; - if (!folder.getRepository().equals(location)) { - return false; - } - } - return true; - } + public boolean isEnabled() { + ICVSRemoteFolder[] folders = getSelectedRemoteFolders(); + if (folders.length == 0) return false; + // only enabled when all folders are in the same repository + ICVSRepositoryLocation location = folders[0].getRepository(); + for (int i = 1; i < folders.length; i++) { + ICVSRemoteFolder folder = folders[i]; + if (!folder.getRepository().equals(location)) { + return false; + } + } + return true; + } /** * Get selected CVS remote folders, and add Project Description diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java index b1674e1a5..1ac1bf8b2 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java @@ -73,7 +73,7 @@ public class CommitAction extends WorkspaceTraversalAction { } }, false, PROGRESS_BUSYCURSOR); } - + @Override protected String getErrorTitle() { return CVSUIMessages.CommitAction_commitFailed; @@ -110,7 +110,7 @@ public class CommitAction extends WorkspaceTraversalAction { if (option.equals(MessageDialogWithToggle.NEVER)) return false; // no, never switch - // Ask the user whether to switch + // Ask the user whether to switch final int[] result = new int[] { 0 }; Utils.syncExec((Runnable) () -> { final MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion(shell, @@ -124,10 +124,10 @@ public class CommitAction extends WorkspaceTraversalAction { // yes case IDialogConstants.YES_ID: case IDialogConstants.OK_ID : - return true; + return true; // no case IDialogConstants.NO_ID : - return false; + return false; } return false; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java index 2c8736cac..354a0b7c4 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java @@ -40,8 +40,8 @@ public class CompareWithTagAction extends WorkspaceTraversalAction { @Override public void execute(IAction action) throws InvocationTargetException, InterruptedException { - - // First, determine the tag to compare with + + // First, determine the tag to compare with IResource[] resources = getSelectedResources(); CVSTag tag = promptForTag(resources); if (tag == null) @@ -57,7 +57,7 @@ public class CompareWithTagAction extends WorkspaceTraversalAction { } } - // Create a subscriber that can cover all projects involved + // Create a subscriber that can cover all projects involved if (isShowModelSync()) { final CVSCompareSubscriber compareSubscriber = new CVSCompareSubscriber(getProjects(resources), tag); ResourceMapping[] mappings = getCVSResourceMappings(); @@ -80,12 +80,12 @@ public class CompareWithTagAction extends WorkspaceTraversalAction { participant.run(getTargetPart()); } else { CVSCompareSubscriber compareSubscriber = new CVSCompareSubscriber(getProjects(resources), tag); - ResourceMapping[] resourceMappings = getCVSResourceMappings(); + ResourceMapping[] resourceMappings = getCVSResourceMappings(); if (isLogicalModel(resourceMappings)) { - compareSubscriber = new CVSCompareSubscriber(getProjects(resources), tag); - resources = getResourcesToCompare(compareSubscriber); - compareSubscriber.dispose(); - } + compareSubscriber = new CVSCompareSubscriber(getProjects(resources), tag); + resources = getResourcesToCompare(compareSubscriber); + compareSubscriber.dispose(); + } // create a subscriber specifically for the resources for display to the user compareSubscriber = new CVSCompareSubscriber(resources, tag); try { @@ -104,11 +104,11 @@ public class CompareWithTagAction extends WorkspaceTraversalAction { } } - private boolean isShowModelSync() { + private boolean isShowModelSync() { return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_ENABLE_MODEL_SYNC); } - - protected CVSTag promptForTag(IResource[] resources) { + + protected CVSTag promptForTag(IResource[] resources) { CVSTag tag = TagSelectionDialog.getTagToCompareWith(getShell(), TagSource.create(resources), TagSelectionDialog.INCLUDE_ALL_TAGS); return tag; } @@ -116,5 +116,5 @@ public class CompareWithTagAction extends WorkspaceTraversalAction { @Override protected boolean isEnabledForNonExistantResources() { return true; - } + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java index cf28b19f1..839ada0e8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/GenerateDiffFileAction.java @@ -36,7 +36,7 @@ import org.eclipse.ui.PlatformUI; * by a create patch command in the compare viewer. */ public class GenerateDiffFileAction extends WorkspaceTraversalAction{ - + @Override public void execute(IAction action) { @@ -57,46 +57,46 @@ public class GenerateDiffFileAction extends WorkspaceTraversalAction{ } } - private IResource[] getDeepResourcesToPatch(IProgressMonitor monitor) throws CoreException { - ResourceMapping[] mappings = getCVSResourceMappings(); + private IResource[] getDeepResourcesToPatch(IProgressMonitor monitor) throws CoreException { + ResourceMapping[] mappings = getCVSResourceMappings(); List<IResource> roots = new ArrayList<>(); - for (int i = 0; i < mappings.length; i++) { - ResourceMapping mapping = mappings[i]; - ResourceTraversal[] traversals = mapping.getTraversals( - SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()), - monitor); - for (int j = 0; j < traversals.length; j++) { - ResourceTraversal traversal = traversals[j]; - IResource[] resources = traversal.getResources(); - if (traversal.getDepth() == IResource.DEPTH_INFINITE) { - roots.addAll(Arrays.asList(resources)); - } else if (traversal.getDepth() == IResource.DEPTH_ZERO) { - collectShallowFiles(resources, roots); - } else if (traversal.getDepth() == IResource.DEPTH_ONE) { - collectShallowFiles(resources, roots); - for (int k = 0; k < resources.length; k++) { - IResource resource = resources[k]; - if (resource.getType() != IResource.FILE) { - collectShallowFiles(members(resource), roots); - } - } - } - } - } - return roots.toArray(new IResource[roots.size()]); - } - + for (int i = 0; i < mappings.length; i++) { + ResourceMapping mapping = mappings[i]; + ResourceTraversal[] traversals = mapping.getTraversals( + SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()), + monitor); + for (int j = 0; j < traversals.length; j++) { + ResourceTraversal traversal = traversals[j]; + IResource[] resources = traversal.getResources(); + if (traversal.getDepth() == IResource.DEPTH_INFINITE) { + roots.addAll(Arrays.asList(resources)); + } else if (traversal.getDepth() == IResource.DEPTH_ZERO) { + collectShallowFiles(resources, roots); + } else if (traversal.getDepth() == IResource.DEPTH_ONE) { + collectShallowFiles(resources, roots); + for (int k = 0; k < resources.length; k++) { + IResource resource = resources[k]; + if (resource.getType() != IResource.FILE) { + collectShallowFiles(members(resource), roots); + } + } + } + } + } + return roots.toArray(new IResource[roots.size()]); + } + private void collectShallowFiles(IResource[] resources, List<IResource> roots) { - for (int k = 0; k < resources.length; k++) { - IResource resource = resources[k]; - if (resource.getType() == IResource.FILE) - roots.add(resource); - } - } - - private IResource[] members(IResource resource) throws CoreException { - return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().members(resource); - } + for (int k = 0; k < resources.length; k++) { + IResource resource = resources[k]; + if (resource.getType() == IResource.FILE) + roots.add(resource); + } + } + + private IResource[] members(IResource resource) throws CoreException { + return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().members(resource); + } @Override protected boolean isEnabledForMultipleResources() { return true; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java index c05eec73e..7d6bf572f 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/IgnoreAction.java @@ -30,30 +30,30 @@ import org.eclipse.team.internal.ccvs.ui.operations.RepositoryProviderOperation; import org.eclipse.ui.IWorkbenchPart; public class IgnoreAction extends WorkspaceTraversalAction { - - /** - * Define an operation that can be run in the background. - * We divide the ignores by provider to obtain project - * locks while modifying the .cvsignore files - */ - class IgnoreOperation extends RepositoryProviderOperation { + + /** + * Define an operation that can be run in the background. + * We divide the ignores by provider to obtain project + * locks while modifying the .cvsignore files + */ + class IgnoreOperation extends RepositoryProviderOperation { - private final IgnoreResourcesDialog dialog; + private final IgnoreResourcesDialog dialog; - public IgnoreOperation(IWorkbenchPart part, IResource[] resources, IgnoreResourcesDialog dialog) { - super(part, resources); - this.dialog = dialog; - } + public IgnoreOperation(IWorkbenchPart part, IResource[] resources, IgnoreResourcesDialog dialog) { + super(part, resources); + this.dialog = dialog; + } - @Override + @Override protected String getTaskName(CVSTeamProvider provider) { - return NLS.bind(CVSUIMessages.IgnoreAction_0, new String[] { provider.getProject().getName() }); - } + return NLS.bind(CVSUIMessages.IgnoreAction_0, new String[] { provider.getProject().getName() }); + } - @Override + @Override protected void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { try { - monitor.beginTask(null, resources.length); + monitor.beginTask(null, resources.length); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; String pattern = dialog.getIgnorePatternFor(resource); @@ -65,22 +65,22 @@ public class IgnoreAction extends WorkspaceTraversalAction { collectStatus(e.getStatus()); return; } finally { - monitor.done(); + monitor.done(); } collectStatus(Status.OK_STATUS); - } + } - @Override + @Override protected String getTaskName() { - return CVSUIMessages.IgnoreAction_1; - } - - @Override + return CVSUIMessages.IgnoreAction_1; + } + + @Override public boolean consultModelsForMappings() { - return false; - } - - } + return false; + } + + } @Override protected void execute(final IAction action) throws InvocationTargetException, InterruptedException { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveRemoteTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveRemoteTagAction.java index 6e598a1ba..69d8672d2 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveRemoteTagAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveRemoteTagAction.java @@ -48,13 +48,13 @@ public class MoveRemoteTagAction extends TagInRepositoryAction { return operation; } - private boolean isFolderSelected() { - ICVSResource[] resources = getSelectedCVSResources(); - for (int i = 0; i < resources.length; i++) { - ICVSResource resource = resources[i]; - if (resource.isFolder()) - return true; - } - return false; - } + private boolean isFolderSelected() { + ICVSResource[] resources = getSelectedCVSResources(); + for (int i = 0; i < resources.length; i++) { + ICVSResource resource = resources[i]; + if (resource.isFolder()) + return true; + } + return false; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OutgoingChangesDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OutgoingChangesDialog.java index adc81eeec..b77869aaf 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OutgoingChangesDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OutgoingChangesDialog.java @@ -126,16 +126,16 @@ public class OutgoingChangesDialog extends DetailsDialog { return false; } - @Override + @Override protected void updateEnablements() { - // Can always finish - setPageComplete(true); - } - - @Override + // Can always finish + setPageComplete(true); + } + + @Override protected boolean includeErrorMessage() { - return false; - } + return false; + } public void setHelpContextId(String helpContextId) { this.helpContextId = helpContextId; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java index b2f3ceb76..f8e12c4c6 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java @@ -23,7 +23,7 @@ import org.eclipse.team.internal.ccvs.ui.IHelpContextIds; import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation; public class ReplaceWithRemoteAction extends WorkspaceTraversalAction { - + @Override public void execute(IAction action) throws InvocationTargetException, InterruptedException { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java index ab620823c..4bc233f26 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java @@ -28,7 +28,7 @@ import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation; * Action for replace with tag. */ public abstract class ReplaceWithTagAction extends WorkspaceTraversalAction { - + @Override public void execute(IAction action) throws InterruptedException, InvocationTargetException { final ReplaceOperation replaceOperation= createReplaceOperation(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java index 0186e7612..d450e4cd9 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/RestoreFromRepositoryAction.java @@ -70,51 +70,51 @@ public class RestoreFromRepositoryAction extends WorkspaceTraversalAction { // Extract the file name and path from the RCS path // String filePath = line.substring(index); - // Find all RCS file names that contain "Attic" - int start = line.lastIndexOf(Session.SERVER_SEPARATOR); - if (start != -1) { - String fileName = line.substring(start + 1); - if (fileName.endsWith(RCS_FILE_POSTFIX)) { - fileName = fileName.substring(0, fileName.length() - RCS_FILE_POSTFIX.length()); - } - if (currentFolder != null) { - try { - ICVSFile file = currentFolder.getFile(fileName); - if (!file.exists()) - atticFiles.add(file); - } catch (CVSException e) { - return e.getStatus(); - } - } else { - // Executed for every message line when in quiet mode. - // See bug 238334 - CVSRepositoryLocation repo = (CVSRepositoryLocation)location; - // If exists, remove root directory - if (line.startsWith(repo.getRootDirectory())) { - String repoPath = line.substring(repo.getRootDirectory().length()); - try { - String cmdRootRelativePath = commandRoot.getRepositoryRelativePath(); - // Remove command root path - String path = repoPath.substring(repoPath.indexOf(cmdRootRelativePath) + cmdRootRelativePath.length()); - // Remove filename at the end - String folderPath = path.substring(0, path.indexOf(fileName)); - // The "raw" folderPath contains CVS's 'Attic/' segment when a file has been deleted from cvs. - if (folderPath.endsWith(ATTIC)) { - folderPath = folderPath.substring(0, folderPath.length() - ATTIC_LENGTH); - } - // A separator means the same as "current folder" - if (folderPath.equals(Session.SERVER_SEPARATOR)) - folderPath = Session.CURRENT_LOCAL_FOLDER; - ICVSFolder folder = commandRoot.getFolder(folderPath); - ICVSFile file = folder.getFile(fileName); - if (!file.exists()) - atticFiles.add(file); - } catch (CVSException e) { - return e.getStatus(); - } - } - } - } + // Find all RCS file names that contain "Attic" + int start = line.lastIndexOf(Session.SERVER_SEPARATOR); + if (start != -1) { + String fileName = line.substring(start + 1); + if (fileName.endsWith(RCS_FILE_POSTFIX)) { + fileName = fileName.substring(0, fileName.length() - RCS_FILE_POSTFIX.length()); + } + if (currentFolder != null) { + try { + ICVSFile file = currentFolder.getFile(fileName); + if (!file.exists()) + atticFiles.add(file); + } catch (CVSException e) { + return e.getStatus(); + } + } else { + // Executed for every message line when in quiet mode. + // See bug 238334 + CVSRepositoryLocation repo = (CVSRepositoryLocation)location; + // If exists, remove root directory + if (line.startsWith(repo.getRootDirectory())) { + String repoPath = line.substring(repo.getRootDirectory().length()); + try { + String cmdRootRelativePath = commandRoot.getRepositoryRelativePath(); + // Remove command root path + String path = repoPath.substring(repoPath.indexOf(cmdRootRelativePath) + cmdRootRelativePath.length()); + // Remove filename at the end + String folderPath = path.substring(0, path.indexOf(fileName)); + // The "raw" folderPath contains CVS's 'Attic/' segment when a file has been deleted from cvs. + if (folderPath.endsWith(ATTIC)) { + folderPath = folderPath.substring(0, folderPath.length() - ATTIC_LENGTH); + } + // A separator means the same as "current folder" + if (folderPath.equals(Session.SERVER_SEPARATOR)) + folderPath = Session.CURRENT_LOCAL_FOLDER; + ICVSFolder folder = commandRoot.getFolder(folderPath); + ICVSFile file = folder.getFile(fileName); + if (!file.exists()) + atticFiles.add(file); + } catch (CVSException e) { + return e.getStatus(); + } + } + } + } return OK; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SetKeywordSubstitutionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SetKeywordSubstitutionAction.java index 2ec2dbf3a..60b02bcaf 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SetKeywordSubstitutionAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SetKeywordSubstitutionAction.java @@ -24,7 +24,7 @@ public class SetKeywordSubstitutionAction extends WorkspaceTraversalAction { @Override public void execute(IAction action) { - ModeWizard.run(getShell(), getSelectedResources()); + ModeWizard.run(getShell(), getSelectedResources()); } @Override diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java index 4d44ac5c3..c11210f0b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java @@ -34,9 +34,9 @@ public class ShowAnnotationAction extends WorkspaceAction { * Action to open a CVS Annotate View */ public void execute(IAction action) throws InvocationTargetException, InterruptedException { - final ICVSResource resource= getSingleSelectedCVSResource(); - if (resource == null) - return; + final ICVSResource resource= getSingleSelectedCVSResource(); + if (resource == null) + return; execute(resource); } @@ -52,9 +52,9 @@ public class ShowAnnotationAction extends WorkspaceAction { public void execute(final ICVSResource cvsResource) throws InvocationTargetException, InterruptedException { final String revision= getRevision(cvsResource); if (revision == null) - return; + return; boolean binary = isBinary(cvsResource); - if (binary) { + if (binary) { final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); final String option = store.getString(ICVSUIConstants.PREF_ANNOTATE_PROMPTFORBINARY); if (option.equals(MessageDialogWithToggle.PROMPT)) { @@ -67,24 +67,24 @@ public class ShowAnnotationAction extends WorkspaceAction { } else if (option.equals(MessageDialogWithToggle.NEVER)) return; } - + new ShowAnnotationOperation(getTargetPart(), cvsResource, revision, binary).run(); } - private boolean isBinary(ICVSResource cvsResource) { - if (cvsResource.isFolder()) return false; - - try { - byte[] syncBytes = ((ICVSFile)cvsResource).getSyncBytes(); - if (syncBytes == null) - return false; - return ResourceSyncInfo.isBinary(syncBytes); - } catch (CVSException e) { - return false; - } - } + private boolean isBinary(ICVSResource cvsResource) { + if (cvsResource.isFolder()) return false; + + try { + byte[] syncBytes = ((ICVSFile)cvsResource).getSyncBytes(); + if (syncBytes == null) + return false; + return ResourceSyncInfo.isBinary(syncBytes); + } catch (CVSException e) { + return false; + } + } - /** + /** * Only enabled for single resource selection */ public boolean isEnabled() { @@ -134,7 +134,7 @@ public class ShowAnnotationAction extends WorkspaceAction { return null; } - + /** * Get the revision for the CVS resource. Throws an InvocationTargetException * if the revision could not be determined. @@ -144,16 +144,16 @@ public class ShowAnnotationAction extends WorkspaceAction { * @throws InvocationTargetException */ private String getRevision(ICVSResource cvsResource) throws InvocationTargetException { - final ResourceSyncInfo info; - try { - info= cvsResource.getSyncInfo(); - if (info == null) - throw new CVSException(NLS.bind(CVSUIMessages.ShowAnnotationAction_noSyncInfo, new String[] { cvsResource.getName() })); - } catch (CVSException e) { - throw new InvocationTargetException(e); - } - return info.getRevision(); - } + final ResourceSyncInfo info; + try { + info= cvsResource.getSyncInfo(); + if (info == null) + throw new CVSException(NLS.bind(CVSUIMessages.ShowAnnotationAction_noSyncInfo, new String[] { cvsResource.getName() })); + } catch (CVSException e) { + throw new InvocationTargetException(e); + } + return info.getRevision(); + } public String getId() { return ICVSUIConstants.CMD_ANNOTATE; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java index 8a78ab47b..d94b4948b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/SyncAction.java @@ -65,24 +65,24 @@ public class SyncAction extends WorkspaceTraversalAction { TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant}); participant.run(getTargetPart()); } else { - IResource[] resources = getResourcesToCompare(getWorkspaceSubscriber()); + IResource[] resources = getResourcesToCompare(getWorkspaceSubscriber()); if (resources == null || resources.length == 0) return; // First check if there is an existing matching participant WorkspaceSynchronizeParticipant participant = (WorkspaceSynchronizeParticipant)SubscriberParticipant.getMatchingParticipant(WorkspaceSynchronizeParticipant.ID, resources); // If there isn't, create one and add to the manager if (participant == null) { - ISynchronizeScope scope; - if (includesAllCVSProjects(resources)) { - scope = new WorkspaceScope(); - } else { - IWorkingSet[] sets = getSelectedWorkingSets(); - if (sets != null) { - scope = new WorkingSetScope(sets); - } else { - scope = new ResourceScope(resources); - } - } - participant = new WorkspaceSynchronizeParticipant(scope); + ISynchronizeScope scope; + if (includesAllCVSProjects(resources)) { + scope = new WorkspaceScope(); + } else { + IWorkingSet[] sets = getSelectedWorkingSets(); + if (sets != null) { + scope = new WorkingSetScope(sets); + } else { + scope = new ResourceScope(resources); + } + } + participant = new WorkspaceSynchronizeParticipant(scope); TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant}); } participant.refresh(resources, getTargetPart().getSite()); @@ -98,53 +98,53 @@ public class SyncAction extends WorkspaceTraversalAction { } private IWorkingSet[] getSelectedWorkingSets() { - ResourceMapping[] mappings = getCVSResourceMappings(); + ResourceMapping[] mappings = getCVSResourceMappings(); List<IWorkingSet> sets = new ArrayList<>(); - for (int i = 0; i < mappings.length; i++) { - ResourceMapping mapping = mappings[i]; - if (mapping.getModelObject() instanceof IWorkingSet) { - IWorkingSet set = (IWorkingSet) mapping.getModelObject(); - sets.add(set); - } else { - return null; - } - } - if (sets.isEmpty()) - return null; - return sets.toArray(new IWorkingSet[sets.size()]); - } + for (int i = 0; i < mappings.length; i++) { + ResourceMapping mapping = mappings[i]; + if (mapping.getModelObject() instanceof IWorkingSet) { + IWorkingSet set = (IWorkingSet) mapping.getModelObject(); + sets.add(set); + } else { + return null; + } + } + if (sets.isEmpty()) + return null; + return sets.toArray(new IWorkingSet[sets.size()]); + } - private boolean includesAllCVSProjects(IResource[] resources) { - // First, make sure all the selected thinsg are projects - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (resource.getType() != IResource.PROJECT) - return false; - } - IProject[] cvsProjects = getAllCVSProjects(); - return cvsProjects.length == resources.length; - } + private boolean includesAllCVSProjects(IResource[] resources) { + // First, make sure all the selected thinsg are projects + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + if (resource.getType() != IResource.PROJECT) + return false; + } + IProject[] cvsProjects = getAllCVSProjects(); + return cvsProjects.length == resources.length; + } - private IProject[] getAllCVSProjects() { - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + private IProject[] getAllCVSProjects() { + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); Set<IProject> cvsProjects = new HashSet<>(); - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - if (RepositoryProvider.isShared(project) && RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) != null) { - cvsProjects.add(project); - } - } - return cvsProjects.toArray(new IProject[cvsProjects.size()]); - } + for (int i = 0; i < projects.length; i++) { + IProject project = projects[i]; + if (RepositoryProvider.isShared(project) && RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()) != null) { + cvsProjects.add(project); + } + } + return cvsProjects.toArray(new IProject[cvsProjects.size()]); + } - /** - * Return whether it is OK to open the selected file directly in a compare editor. - * It is not OK to show the single file if the file is part of a logical model element - * that spans files. - * @param file the file - * @return whether it is OK to open the selected file directly in a compare editor - */ - public static boolean isOKToShowSingleFile(IFile file) { + /** + * Return whether it is OK to open the selected file directly in a compare editor. + * It is not OK to show the single file if the file is part of a logical model element + * that spans files. + * @param file the file + * @return whether it is OK to open the selected file directly in a compare editor + */ + public static boolean isOKToShowSingleFile(IFile file) { if (!isShowModelSync()) return true; IModelProviderDescriptor[] descriptors = ModelProvider.getModelProviderDescriptors(); @@ -178,8 +178,8 @@ public class SyncAction extends WorkspaceTraversalAction { } return true; } - - /** + + /** * Refresh the subscriber directly and show the resulting synchronization state in a compare editor. If there * is no difference the user is prompted. * diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java index 22bf5c49b..b6ee44b18 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java @@ -72,7 +72,7 @@ public abstract class TagAction extends WorkspaceTraversalAction { IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); ITagOperation operation = createTagOperation(); if (operation.isEmpty()) { - return null; + return null; } if (!performPrompting(operation)) { return null; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java index b9392b086..442065a13 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagLocalAction.java @@ -25,7 +25,7 @@ import org.eclipse.team.internal.ccvs.ui.operations.TagOperation; * Action that tags the local workspace with a version tag. */ public class TagLocalAction extends TagAction { - + @Override protected boolean performPrompting(ITagOperation operation) { if (operation instanceof TagOperation) { @@ -53,7 +53,7 @@ public class TagLocalAction extends TagAction { return false; } - @Override + @Override protected ITagOperation createTagOperation() { return new TagOperation(getTargetPart(), getCVSResourceMappings()); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java index 5798096c1..4e0d77c11 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UnmanageAction.java @@ -91,7 +91,7 @@ public class UnmanageAction extends WorkspaceAction { radio1.setSelection(deleteContent); radio2.setSelection(!deleteContent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.DISCONNECT_ACTION); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.DISCONNECT_ACTION); return composite; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java index 68699f7c2..2591555b1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java @@ -29,24 +29,24 @@ import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; * @since 3.1 */ public class UpdateSilentAction extends WorkspaceTraversalAction { - + @Override - protected boolean isEnabledForAddedResources() { - return false; - } + protected boolean isEnabledForAddedResources() { + return false; + } @Override - protected boolean isEnabledForNonExistantResources() { - return true; - } - + protected boolean isEnabledForNonExistantResources() { + return true; + } + @Override public void execute(IAction action) throws InterruptedException, InvocationTargetException { if (CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_HANDLING).equals(ICVSUIConstants.PREF_UPDATE_HANDLING_TRADITIONAL)) { new UpdateOperation(getTargetPart(), getCVSResourceMappings(), Command.NO_LOCAL_OPTIONS, null /* no tag */).run(); } else { - new ModelUpdateOperation(getTargetPart(), getSelectedResourceMappings(CVSProviderPlugin.getTypeId())).run(); - } + new ModelUpdateOperation(getTargetPart(), getSelectedResourceMappings(CVSProviderPlugin.getTypeId())).run(); + } } @Override diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java index 7da395b4c..7f64b1dd0 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceAction.java @@ -353,7 +353,7 @@ public abstract class WorkspaceAction extends CVSAction { return true; } - /** + /** * Method isEnabledForCVSResource. * @param cvsResource * @return boolean diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java index 9bdb8d460..31a978cd6 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/WorkspaceTraversalAction.java @@ -41,71 +41,71 @@ import org.eclipse.ui.PlatformUI; */ public abstract class WorkspaceTraversalAction extends WorkspaceAction { - /** - * Return the selected mappings that contain resources - * within a CVS managed project. - * @return the selected mappings that contain resources - * within a CVS managed project - */ - protected ResourceMapping[] getCVSResourceMappings() { - return getSelectedResourceMappings(CVSProviderPlugin.getTypeId()); - } + /** + * Return the selected mappings that contain resources + * within a CVS managed project. + * @return the selected mappings that contain resources + * within a CVS managed project + */ + protected ResourceMapping[] getCVSResourceMappings() { + return getSelectedResourceMappings(CVSProviderPlugin.getTypeId()); + } - private static ResourceTraversal[] getTraversals(IWorkbenchPart part, ISynchronizationScopeManager manager, IProgressMonitor monitor) throws CoreException { - try { - BuildScopeOperation op = new BuildScopeOperation(part, manager); - op.run(monitor); - return manager.getScope().getTraversals(); - } catch (InvocationTargetException e) { + private static ResourceTraversal[] getTraversals(IWorkbenchPart part, ISynchronizationScopeManager manager, IProgressMonitor monitor) throws CoreException { + try { + BuildScopeOperation op = new BuildScopeOperation(part, manager); + op.run(monitor); + return manager.getScope().getTraversals(); + } catch (InvocationTargetException e) { throw TeamException.asTeamException(e); } catch (InterruptedException e) { throw new OperationCanceledException(); } - } - - private static IResource[] getRootTraversalResources(ISynchronizationScopeManager manager, IProgressMonitor monitor) throws CoreException { + } + + private static IResource[] getRootTraversalResources(ISynchronizationScopeManager manager, IProgressMonitor monitor) throws CoreException { Set<IResource> result = new HashSet<>(); - ResourceTraversal[] traversals = getTraversals(null, manager, monitor); - for (int i = 0; i < traversals.length; i++) { + ResourceTraversal[] traversals = getTraversals(null, manager, monitor); + for (int i = 0; i < traversals.length; i++) { ResourceTraversal traversal = traversals[i]; - IResource[] resources = traversal.getResources(); - for (int k = 0; k < resources.length; k++) { - IResource resource = resources[k]; - if (RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) != null) { - result.add(resource); - } - } - } - return result.toArray(new IResource[result.size()]); - } + IResource[] resources = traversal.getResources(); + for (int k = 0; k < resources.length; k++) { + IResource resource = resources[k]; + if (RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) != null) { + result.add(resource); + } + } + } + return result.toArray(new IResource[result.size()]); + } - protected Subscriber getWorkspaceSubscriber() { - return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); - } - + protected Subscriber getWorkspaceSubscriber() { + return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); + } + public static IResource[] getResourcesToCompare(ResourceMapping[] mappings, Subscriber subscriber) throws InvocationTargetException { - ISynchronizationScopeManager manager = new SynchronizationScopeManager("", //$NON-NLS-1$ - mappings, SubscriberResourceMappingContext.createContext(subscriber), true); - try { - return getResourcesToCompare(manager); - } finally { - manager.dispose(); - } + ISynchronizationScopeManager manager = new SynchronizationScopeManager("", //$NON-NLS-1$ + mappings, SubscriberResourceMappingContext.createContext(subscriber), true); + try { + return getResourcesToCompare(manager); + } finally { + manager.dispose(); + } + } + + protected IResource[] getResourcesToCompare(final Subscriber subscriber) throws InvocationTargetException { + return getResourcesToCompare(getCVSResourceMappings(), subscriber); } - protected IResource[] getResourcesToCompare(final Subscriber subscriber) throws InvocationTargetException { - return getResourcesToCompare(getCVSResourceMappings(), subscriber); - } - - protected ResourceMappingContext getResourceMappingContext() { + protected ResourceMappingContext getResourceMappingContext() { return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); } public static IResource[] getResourcesToCompare(final ISynchronizationScopeManager manager) throws InvocationTargetException { - // Determine what resources need to be synchronized. - // Use a resource mapping context to include any relevant remote resources - final IResource[][] resources = new IResource[][] { null }; - try { + // Determine what resources need to be synchronized. + // Use a resource mapping context to include any relevant remote resources + final IResource[][] resources = new IResource[][] { null }; + try { PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { try { resources[0] = getRootTraversalResources(manager, monitor); @@ -113,50 +113,50 @@ public abstract class WorkspaceTraversalAction extends WorkspaceAction { throw new InvocationTargetException(e); } }); - } catch (InterruptedException e) { - // Canceled - return null; - } - return resources[0]; - } - - public static IResource[] getProjects(IResource[] resources) { + } catch (InterruptedException e) { + // Canceled + return null; + } + return resources[0]; + } + + public static IResource[] getProjects(IResource[] resources) { Set<IProject> projects = new HashSet<>(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - projects.add(resource.getProject()); - } - return projects.toArray(new IResource[projects.size()]); - } - - /** - * - * @param mappings - * @return - * - * @deprecated need to find a better way to do this - */ - @Deprecated + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + projects.add(resource.getProject()); + } + return projects.toArray(new IResource[projects.size()]); + } + + /** + * + * @param mappings + * @return + * + * @deprecated need to find a better way to do this + */ + @Deprecated public static boolean isLogicalModel(ResourceMapping[] mappings) { - for (int i = 0; i < mappings.length; i++) { - ResourceMapping mapping = mappings[i]; - if (! (mapping.getModelObject() instanceof IResource) ) { - return true; - } - } - return false; - } - - protected IFile getSelectedFile() { - ResourceMapping[] mappings = getCVSResourceMappings(); - if (mappings.length == 1) { - IResource resource = Utils.getResource(mappings[0].getModelObject()); - if (resource != null && resource.getType() == IResource.FILE) - return (IFile)resource; - } - return null; - } - + for (int i = 0; i < mappings.length; i++) { + ResourceMapping mapping = mappings[i]; + if (! (mapping.getModelObject() instanceof IResource) ) { + return true; + } + } + return false; + } + + protected IFile getSelectedFile() { + ResourceMapping[] mappings = getCVSResourceMappings(); + if (mappings.length == 1) { + IResource resource = Utils.getResource(mappings[0].getModelObject()); + if (resource != null && resource.getType() == IResource.FILE) + return (IFile)resource; + } + return null; + } + protected boolean hasOutgoingChanges(final RepositoryProviderOperation operation) throws InvocationTargetException, InterruptedException { final boolean[] hasChange = new boolean[] { false }; PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> { @@ -198,8 +198,8 @@ public abstract class WorkspaceTraversalAction extends WorkspaceAction { */ protected SynchronizationScopeManager getScopeManager() { return new SynchronizationScopeManager( - "", //$NON-NLS-1$ - getCVSResourceMappings(), - getResourceMappingContext(), true); + "", //$NON-NLS-1$ + getCVSResourceMappings(), + getResourceMappingContext(), true); } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java index 0ac823e15..0ee738a48 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/CVSOutputConsole.java @@ -66,17 +66,17 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener // format for timings printed to console private static final DateFormat TIME_FORMAT; - - static { - DateFormat format; - try { - format = new SimpleDateFormat(CVSUIMessages.Console_resultTimeFormat); - } catch (RuntimeException e) { - // This can happen if the bundle contains an invalid format - format = new SimpleDateFormat("'(took 'm:ss.SSS')')"); //$NON-NLS-1$ - } - TIME_FORMAT = format; - } + + static { + DateFormat format; + try { + format = new SimpleDateFormat(CVSUIMessages.Console_resultTimeFormat); + } catch (RuntimeException e) { + // This can happen if the bundle contains an invalid format + format = new SimpleDateFormat("'(took 'm:ss.SSS')')"); //$NON-NLS-1$ + } + TIME_FORMAT = format; + } // Indicates whether the console is visible in the Console view private boolean visible = false; @@ -86,7 +86,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener /* * Constant used for indenting error status printing */ - private static final String NESTING = " "; //$NON-NLS-1$ + private static final String NESTING = " "; //$NON-NLS-1$ /** * Used to notify this console of lifecycle methods <code>init()</code> @@ -220,7 +220,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener } } - private void showConsole() { + private void showConsole() { show(false); } @@ -255,7 +255,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener @Override public void commandInvoked(Session session, String line) { - if (!session.isOutputToConsole()) return; + if (!session.isOutputToConsole()) return; commandStarted = System.currentTimeMillis(); appendLine(ConsoleDocument.COMMAND, CVSUIMessages.Console_preExecutionDelimiter); appendLine(ConsoleDocument.COMMAND, line); @@ -263,21 +263,21 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener @Override public void messageLineReceived(Session session, String line, IStatus status) { - if (session.isOutputToConsole()) { - appendLine(ConsoleDocument.MESSAGE, " " + line); //$NON-NLS-1$ - } + if (session.isOutputToConsole()) { + appendLine(ConsoleDocument.MESSAGE, " " + line); //$NON-NLS-1$ + } } @Override public void errorLineReceived(Session session, String line, IStatus status) { - if (session.isOutputToConsole()) { - appendLine(ConsoleDocument.ERROR, " " + line); //$NON-NLS-1$ - } + if (session.isOutputToConsole()) { + appendLine(ConsoleDocument.ERROR, " " + line); //$NON-NLS-1$ + } } @Override public void commandCompleted(Session session, IStatus status, Exception exception) { - if (!session.isOutputToConsole()) return; + if (!session.isOutputToConsole()) return; long commandRuntime = System.currentTimeMillis() - commandStarted; String time; try { @@ -288,7 +288,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener } String statusText; if (status != null) { - boolean includeRoot = true; + boolean includeRoot = true; if (status.getCode() == CVSStatus.SERVER_ERROR) { statusText = NLS.bind(CVSUIMessages.Console_resultServerError, new String[] { status.getMessage(), time }); includeRoot = false; @@ -305,7 +305,7 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener } appendLine(ConsoleDocument.COMMAND, statusText); if (exception instanceof CoreException) { - outputStatus(((CoreException)exception).getStatus(), true, 1); + outputStatus(((CoreException)exception).getStatus(), true, 1); } } else { statusText = NLS.bind(CVSUIMessages.Console_resultOk, new String[] { time }); @@ -316,14 +316,14 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener private void outputStatus(IStatus status, boolean includeParent, int nestingLevel) { if (includeParent && !status.isOK()) { - outputStatusMessage(status, nestingLevel); - nestingLevel++; + outputStatusMessage(status, nestingLevel); + nestingLevel++; } // Include a CoreException in the status Throwable t = status.getException(); if (t instanceof CoreException) { - outputStatus(((CoreException)t).getStatus(), true, nestingLevel); + outputStatus(((CoreException)t).getStatus(), true, nestingLevel); } // Include child status @@ -333,14 +333,14 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener } } - private void outputStatusMessage(IStatus status, int nesting) { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < nesting; i++) { - buffer.append(NESTING); - } - buffer.append(messageLineForStatus(status)); - appendLine(ConsoleDocument.COMMAND, buffer.toString()); - } + private void outputStatusMessage(IStatus status, int nesting) { + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < nesting; i++) { + buffer.append(NESTING); + } + buffer.append(messageLineForStatus(status)); + appendLine(ConsoleDocument.COMMAND, buffer.toString()); + } @Override public void propertyChange(PropertyChangeEvent event) { @@ -407,21 +407,21 @@ public class CVSOutputConsole extends MessageConsole implements IConsoleListener return new Color(display, rgb); } - /** - * Show the console. - * @param showNoMatterWhat ignore preferences if <code>true</code> - */ - public void show(boolean showNoMatterWhat) { + /** + * Show the console. + * @param showNoMatterWhat ignore preferences if <code>true</code> + */ + public void show(boolean showNoMatterWhat) { if(showNoMatterWhat || showOnMessage) { if(!visible) CVSConsoleFactory.showConsole(); else consoleManager.showConsoleView(this); } - } - - @Override + } + + @Override public String getHelpContextId() { - return IHelpContextIds.CONSOLE_VIEW; - } + return IHelpContextIds.CONSOLE_VIEW; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsolePreferencesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsolePreferencesPage.java index faefc5641..48a26f229 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsolePreferencesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/console/ConsolePreferencesPage.java @@ -82,7 +82,7 @@ public class ConsolePreferencesPage extends FieldEditorPreferencePage implements addField(errorColorEditor); Dialog.applyDialogFont(composite); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.CONSOLE_PREFERENCE_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.CONSOLE_PREFERENCE_PAGE); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java index 8cfbcd909..38d60aaeb 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractCommitAction.java @@ -42,7 +42,7 @@ public abstract class AbstractCommitAction extends CVSModelProviderAction { @Override public void execute() { - final List resources = new ArrayList(); + final List resources = new ArrayList(); try { final IStructuredSelection selection = getActualSelection(); PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { @@ -61,12 +61,12 @@ public abstract class AbstractCommitAction extends CVSModelProviderAction { Utils.handleError(getConfiguration().getSite().getShell(), e, null, null); } if (!resources.isEmpty() && ((IResource[])resources.get(0)).length > 0) { - Shell shell= getConfiguration().getSite().getShell(); - try { - CommitWizard.run(getConfiguration().getSite().getPart(), shell, ((IResource[])resources.get(0))); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } + Shell shell= getConfiguration().getSite().getShell(); + try { + CommitWizard.run(getConfiguration().getSite().getPart(), shell, ((IResource[])resources.get(0))); + } catch (CVSException e) { + CVSUIPlugin.log(e); + } } } @@ -76,7 +76,7 @@ public abstract class AbstractCommitAction extends CVSModelProviderAction { protected abstract ResourceTraversal[] getCommitTraversals(IStructuredSelection selection, IProgressMonitor monitor) throws CoreException; - public static IResource[] getOutgoingChanges(final IResourceDiffTree tree, ResourceTraversal[] traversals, IProgressMonitor monitor) { + public static IResource[] getOutgoingChanges(final IResourceDiffTree tree, ResourceTraversal[] traversals, IProgressMonitor monitor) { final List<IResource> resources = new ArrayList<>(); IDiff[] diffs = tree.getDiffs(traversals); for (int i = 0; i < diffs.length; i++) { @@ -88,8 +88,8 @@ public abstract class AbstractCommitAction extends CVSModelProviderAction { } } return resources.toArray(new IResource[resources.size()]); - } - + } + public static boolean hasLocalChange(IDiff diff) { if (diff instanceof IThreeWayDiff) { IThreeWayDiff twd = (IThreeWayDiff) diff; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSModelSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSModelSynchronizeParticipant.java index 61169b735..21aebca24 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSModelSynchronizeParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSModelSynchronizeParticipant.java @@ -28,13 +28,13 @@ import org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant; public abstract class CVSModelSynchronizeParticipant extends ModelSynchronizeParticipant { public static PreferencePage[] addCVSPreferencePages(PreferencePage[] inheritedPages) { - PreferencePage[] pages = new PreferencePage[inheritedPages.length + 1]; - for (int i = 0; i < inheritedPages.length; i++) { - pages[i] = inheritedPages[i]; - } - pages[pages.length - 1] = new ComparePreferencePage(); - pages[pages.length - 1].setTitle(CVSUIMessages.CVSParticipant_2); - return pages; + PreferencePage[] pages = new PreferencePage[inheritedPages.length + 1]; + for (int i = 0; i < inheritedPages.length; i++) { + pages[i] = inheritedPages[i]; + } + pages[pages.length - 1] = new ComparePreferencePage(); + pages[pages.length - 1].setTitle(CVSUIMessages.CVSParticipant_2); + return pages; } public CVSModelSynchronizeParticipant() { @@ -46,7 +46,7 @@ public abstract class CVSModelSynchronizeParticipant extends ModelSynchronizePar } public PreferencePage[] getPreferencePages() { - return addCVSPreferencePages(super.getPreferencePages()); + return addCVSPreferencePages(super.getPreferencePages()); } public ModelProvider[] getEnabledModelProviders() { @@ -71,7 +71,7 @@ public abstract class CVSModelSynchronizeParticipant extends ModelSynchronizePar } protected ILabelDecorator getLabelDecorator(ISynchronizePageConfiguration configuration) { - return new CVSParticipantLabelDecorator(configuration); + return new CVSParticipantLabelDecorator(configuration); } protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java index fcb025868..44f22d2d5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetActionProvider.java @@ -69,7 +69,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { } /* package */void createChangeSet(IDiff[] diffs) { - ActiveChangeSet set = getChangeSetCapability().createChangeSet(getConfiguration(), diffs); + ActiveChangeSet set = getChangeSetCapability().createChangeSet(getConfiguration(), diffs); if (set != null) { getActiveChangeSetManager().add(set); } @@ -110,8 +110,8 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { private final ActiveChangeSet set; - public AddToChangeSetAction(ISynchronizePageConfiguration configuration, ActiveChangeSet set, ISelection selection) { - super(set == null ? TeamUIMessages.ChangeSetActionGroup_2 : escapeActionText(set.getTitle()), configuration); + public AddToChangeSetAction(ISynchronizePageConfiguration configuration, ActiveChangeSet set, ISelection selection) { + super(set == null ? TeamUIMessages.ChangeSetActionGroup_2 : escapeActionText(set.getTitle()), configuration); this.set = set; selectionChanged(selection); } @@ -140,7 +140,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { private abstract class ChangeSetAction extends BaseSelectionListenerAction { - public ChangeSetAction(String title, ISynchronizePageConfiguration configuration) { + public ChangeSetAction(String title, ISynchronizePageConfiguration configuration) { super(title); } @@ -172,8 +172,8 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { @Override public void run() { ActiveChangeSet set = getSelectedSet(); - if (set == null) return; - getChangeSetCapability().editChangeSet(internalGetSynchronizePageConfiguration(), set); + if (set == null) return; + getChangeSetCapability().editChangeSet(internalGetSynchronizePageConfiguration(), set); } } @@ -246,7 +246,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { public void run() { int sortCriteria = getSortCriteria(internalGetSynchronizePageConfiguration()); if (isChecked() && sortCriteria != criteria) { - setSortCriteria(internalGetSynchronizePageConfiguration(), criteria); + setSortCriteria(internalGetSynchronizePageConfiguration(), criteria); update(); ((SynchronizePageConfiguration)internalGetSynchronizePageConfiguration()).getPage().getViewer().refresh(); } @@ -257,7 +257,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { } } - public static int getSortCriteria(ISynchronizePageConfiguration configuration) { + public static int getSortCriteria(ISynchronizePageConfiguration configuration) { int sortCriteria = ChangeSetSorter.DATE; if (configuration != null) { Object o = configuration.getProperty(P_LAST_COMMENTSORT); @@ -436,7 +436,7 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { } public ChangeSetCapability getChangeSetCapability() { - ISynchronizeParticipant participant = getSynchronizePageConfiguration().getParticipant(); + ISynchronizeParticipant participant = getSynchronizePageConfiguration().getParticipant(); if (participant instanceof IChangeSetProvider) { IChangeSetProvider provider = (IChangeSetProvider) participant; return provider.getChangeSetCapability(); @@ -602,11 +602,11 @@ public class ChangeSetActionProvider extends ResourceModelActionProvider { super.setContext(context); if (context != null) { if (editChangeSet != null) - editChangeSet.selectionChanged((IStructuredSelection)getContext().getSelection()); + editChangeSet.selectionChanged((IStructuredSelection)getContext().getSelection()); if (removeChangeSet != null) - removeChangeSet.selectionChanged((IStructuredSelection)getContext().getSelection()); + removeChangeSet.selectionChanged((IStructuredSelection)getContext().getSelection()); if (makeDefault != null) - makeDefault.selectionChanged((IStructuredSelection)getContext().getSelection()); + makeDefault.selectionChanged((IStructuredSelection)getContext().getSelection()); } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java index 2149d4548..3f4d38414 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetContentProvider.java @@ -136,21 +136,21 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple private void handleSetChange(final ChangeSet set, final IPath[] paths) { try { getTheRest().beginInput(); - for (int i = 0; i < paths.length; i++) { + for (int i = 0; i < paths.length; i++) { IPath path = paths[i]; - boolean isContained = ((DiffChangeSet)set).contains(path); + boolean isContained = ((DiffChangeSet)set).contains(path); if (isContained) { IDiff diff = ((DiffChangeSet)set).getDiffTree().getDiff(path); if (diff != null) { getTheRest().remove(ResourceDiffTree.getResourceFor(diff)); } } else { - IDiff diff = getContext().getDiffTree().getDiff(path); - if (diff != null && !isContainedInSet(diff)) { - getTheRest().add(diff); - } - } - } + IDiff diff = getContext().getDiffTree().getDiff(path); + if (diff != null && !isContainedInSet(diff)) { + getTheRest().add(diff); + } + } + } } finally { getTheRest().endInput(null); } @@ -738,7 +738,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple } - private ChangeSet[] getSetsShowingPropogatedStateFrom(IPath[] paths) { + private ChangeSet[] getSetsShowingPropogatedStateFrom(IPath[] paths) { Set result = new HashSet(); for (int i = 0; i < paths.length; i++) { IPath path = paths[i]; @@ -750,7 +750,7 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple } return (ChangeSet[]) result.toArray(new ChangeSet[result.size()]); } - + protected DiffChangeSet[] getSetsShowingPropogatedStateFrom(IPath path) { List result = new ArrayList(); DiffChangeSet[] allSets = getAllSets(); @@ -764,13 +764,13 @@ public class ChangeSetContentProvider extends ResourceModelContentProvider imple } public ChangeSetCapability getChangeSetCapability() { - ISynchronizeParticipant participant = getConfiguration().getParticipant(); - if (participant instanceof IChangeSetProvider) { - IChangeSetProvider provider = (IChangeSetProvider) participant; - return provider.getChangeSetCapability(); - } - return null; - } + ISynchronizeParticipant participant = getConfiguration().getParticipant(); + if (participant instanceof IChangeSetProvider) { + IChangeSetProvider provider = (IChangeSetProvider) participant; + return provider.getChangeSetCapability(); + } + return null; + } private Set getVisibleSetsInViewer() { TreeViewer viewer = (TreeViewer)getViewer(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetLabelProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetLabelProvider.java index bed3157bc..a989ed50c 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetLabelProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetLabelProvider.java @@ -205,9 +205,9 @@ public class ChangeSetLabelProvider extends ResourceModelLabelProvider { public Font getFont(Object element) { element = internalGetElement(element); - if (element instanceof ActiveChangeSet && isDefaultActiveSet((ActiveChangeSet)element)) { + if (element instanceof ActiveChangeSet && isDefaultActiveSet((ActiveChangeSet)element)) { return JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); - } + } return super.getFont(element); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetSorter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetSorter.java index ebeb3c0f8..49f69c876 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetSorter.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ChangeSetSorter.java @@ -38,14 +38,14 @@ public class ChangeSetSorter extends ResourceModelSorter { //if one or both objects are not resources, returned a comparison //based on class. if (o1 instanceof ChangeSet && o2 instanceof ChangeSet) { - ChangeSet s1 = (ChangeSet) o1; - ChangeSet s2 = (ChangeSet) o2; - if (s1 instanceof ActiveChangeSet && s2 instanceof ActiveChangeSet) { - return compareNames(((ActiveChangeSet)s1).getTitle(), ((ActiveChangeSet)s2).getTitle()); - } - if (s1 instanceof CVSCheckedInChangeSet && s2 instanceof CVSCheckedInChangeSet) { - CVSCheckedInChangeSet r1 = (CVSCheckedInChangeSet)s1; - CVSCheckedInChangeSet r2 = (CVSCheckedInChangeSet)s2; + ChangeSet s1 = (ChangeSet) o1; + ChangeSet s2 = (ChangeSet) o2; + if (s1 instanceof ActiveChangeSet && s2 instanceof ActiveChangeSet) { + return compareNames(((ActiveChangeSet)s1).getTitle(), ((ActiveChangeSet)s2).getTitle()); + } + if (s1 instanceof CVSCheckedInChangeSet && s2 instanceof CVSCheckedInChangeSet) { + CVSCheckedInChangeSet r1 = (CVSCheckedInChangeSet)s1; + CVSCheckedInChangeSet r2 = (CVSCheckedInChangeSet)s2; if (getCommentCriteria() == DATE) return r1.getDate().compareTo(r2.getDate()); else if (getCommentCriteria() == COMMENT) @@ -54,17 +54,17 @@ public class ChangeSetSorter extends ResourceModelSorter { return compareNames(r1.getAuthor(), r2.getAuthor()); else return 0; - } - if (s1 instanceof ActiveChangeSet) { - return -1; - } else if (s2 instanceof ActiveChangeSet) { - return 1; - } - if (s1 instanceof CVSCheckedInChangeSet) { - return -1; - } else if (s2 instanceof CVSCheckedInChangeSet) { - return 1; - } + } + if (s1 instanceof ActiveChangeSet) { + return -1; + } else if (s2 instanceof ActiveChangeSet) { + return 1; + } + if (s1 instanceof CVSCheckedInChangeSet) { + return -1; + } else if (s2 instanceof CVSCheckedInChangeSet) { + return 1; + } } return super.compare(viewer, o1, o2); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CheckedInChangeSetCollector.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CheckedInChangeSetCollector.java index d5eadefe3..756524d24 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CheckedInChangeSetCollector.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CheckedInChangeSetCollector.java @@ -43,10 +43,10 @@ import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; public class CheckedInChangeSetCollector extends BatchingChangeSetManager implements ILogsFetchedListener { /* - * Constant used to store the log entry handler in the configuration so it can - * be kept around over layout changes - */ - private static final String LOG_ENTRY_HANDLER = CVSUIPlugin.ID + ".LogEntryHandler"; //$NON-NLS-1$ + * Constant used to store the log entry handler in the configuration so it can + * be kept around over layout changes + */ + private static final String LOG_ENTRY_HANDLER = CVSUIPlugin.ID + ".LogEntryHandler"; //$NON-NLS-1$ /* ***************************************************************************** * Special sync info that has its kind already calculated. @@ -71,17 +71,17 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem } @Override public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) { - if (event.getTree().isEmpty()) { - ChangeSet changeSet = getChangeSet(event.getTree()); - if (changeSet != null) { - remove(changeSet); - } - } else { - ChangeSet changeSet = getChangeSet(event.getTree()); - if (changeSet != null) { - fireResourcesChangedEvent(changeSet, getAffectedPaths(event)); - } - } + if (event.getTree().isEmpty()) { + ChangeSet changeSet = getChangeSet(event.getTree()); + if (changeSet != null) { + remove(changeSet); + } + } else { + ChangeSet changeSet = getChangeSet(event.getTree()); + if (changeSet != null) { + fireResourcesChangedEvent(changeSet, getAffectedPaths(event)); + } + } } private IPath[] getAffectedPaths(IDiffChangeEvent event) { Set<IPath> result = new HashSet<>(); @@ -110,115 +110,115 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem private final Subscriber subscriber; private HashSet<ChangeSet> updatedSets; - - public CheckedInChangeSetCollector(ISynchronizePageConfiguration configuration, Subscriber subscriber) { + + public CheckedInChangeSetCollector(ISynchronizePageConfiguration configuration, Subscriber subscriber) { this.configuration = configuration; this.subscriber = subscriber; } - - /** - * Return the configuration for the page that is displaying the model created - * using this collector. - * @return the configuration for the page that is displaying the model created - * using this collector - */ - public final ISynchronizePageConfiguration getConfiguration() { - return configuration; - } - - @Override + + /** + * Return the configuration for the page that is displaying the model created + * using this collector. + * @return the configuration for the page that is displaying the model created + * using this collector + */ + public final ISynchronizePageConfiguration getConfiguration() { + return configuration; + } + + @Override protected void handleSetAdded(ChangeSet set) { - ((DiffChangeSet)set).getDiffTree().addDiffChangeListener(diffTreeListener); - super.handleSetAdded(set); - if (updatedSets != null) { - updatedSets.add(set); - ((DiffTree)((DiffChangeSet)set).getDiffTree()).beginInput(); - } - } - - @Override + ((DiffChangeSet)set).getDiffTree().addDiffChangeListener(diffTreeListener); + super.handleSetAdded(set); + if (updatedSets != null) { + updatedSets.add(set); + ((DiffTree)((DiffChangeSet)set).getDiffTree()).beginInput(); + } + } + + @Override protected void handleSetRemoved(ChangeSet set) { - ((DiffChangeSet)set).getDiffTree().removeDiffChangeListener(diffTreeListener); - super.handleSetRemoved(set); - } - - protected ChangeSet getChangeSet(IDiffTree tree) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet changeSet = sets[i]; - if (((DiffChangeSet)changeSet).getDiffTree() == tree) { - return changeSet; - } - } - return null; - } - - public void handleChange(IDiffChangeEvent event) { + ((DiffChangeSet)set).getDiffTree().removeDiffChangeListener(diffTreeListener); + super.handleSetRemoved(set); + } + + protected ChangeSet getChangeSet(IDiffTree tree) { + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet changeSet = sets[i]; + if (((DiffChangeSet)changeSet).getDiffTree() == tree) { + return changeSet; + } + } + return null; + } + + public void handleChange(IDiffChangeEvent event) { List<IPath> removals = new ArrayList<>(); List<IDiff> additions = new ArrayList<>(); - removals.addAll(Arrays.asList(event.getRemovals())); - additions.addAll(Arrays.asList(event.getAdditions())); - IDiff[] changed = event.getChanges(); - for (int i = 0; i < changed.length; i++) { - IDiff diff = changed[i]; - additions.add(diff); - removals.add(diff.getPath()); - } - if (!removals.isEmpty()) { - remove(removals.toArray(new IPath[removals.size()])); - } - if (!additions.isEmpty()) { - add(additions.toArray(new IDiff[additions.size()])); - } - } - - protected void remove(IPath[] paths) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - DiffChangeSet set = (DiffChangeSet)sets[i]; - set.remove(paths); - } - } - - public synchronized LogEntryCacheUpdateHandler getLogEntryHandler() { - LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)getConfiguration().getProperty(LOG_ENTRY_HANDLER); - if (handler == null) { - handler = initializeLogEntryHandler(getConfiguration()); - } - handler.setListener(this); - return handler; - } - - /* - * Initialize the log entry handler and place it in the configuration - */ - private LogEntryCacheUpdateHandler initializeLogEntryHandler(final ISynchronizePageConfiguration configuration) { - final LogEntryCacheUpdateHandler logEntryHandler = new LogEntryCacheUpdateHandler(configuration); - configuration.setProperty(LOG_ENTRY_HANDLER, logEntryHandler); - // Use an action group to get notified when the configuration is disposed - configuration.addActionContribution(new SynchronizePageActionGroup() { - @Override + removals.addAll(Arrays.asList(event.getRemovals())); + additions.addAll(Arrays.asList(event.getAdditions())); + IDiff[] changed = event.getChanges(); + for (int i = 0; i < changed.length; i++) { + IDiff diff = changed[i]; + additions.add(diff); + removals.add(diff.getPath()); + } + if (!removals.isEmpty()) { + remove(removals.toArray(new IPath[removals.size()])); + } + if (!additions.isEmpty()) { + add(additions.toArray(new IDiff[additions.size()])); + } + } + + protected void remove(IPath[] paths) { + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + DiffChangeSet set = (DiffChangeSet)sets[i]; + set.remove(paths); + } + } + + public synchronized LogEntryCacheUpdateHandler getLogEntryHandler() { + LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)getConfiguration().getProperty(LOG_ENTRY_HANDLER); + if (handler == null) { + handler = initializeLogEntryHandler(getConfiguration()); + } + handler.setListener(this); + return handler; + } + + /* + * Initialize the log entry handler and place it in the configuration + */ + private LogEntryCacheUpdateHandler initializeLogEntryHandler(final ISynchronizePageConfiguration configuration) { + final LogEntryCacheUpdateHandler logEntryHandler = new LogEntryCacheUpdateHandler(configuration); + configuration.setProperty(LOG_ENTRY_HANDLER, logEntryHandler); + // Use an action group to get notified when the configuration is disposed + configuration.addActionContribution(new SynchronizePageActionGroup() { + @Override public void dispose() { - super.dispose(); - LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)configuration.getProperty(LOG_ENTRY_HANDLER); - if (handler != null) { - handler.shutdown(); - configuration.setProperty(LOG_ENTRY_HANDLER, null); - } - } - }); - return logEntryHandler; - } + super.dispose(); + LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)configuration.getProperty(LOG_ENTRY_HANDLER); + if (handler != null) { + handler.shutdown(); + configuration.setProperty(LOG_ENTRY_HANDLER, null); + } + } + }); + return logEntryHandler; + } - protected void add(IDiff[] diffs) { - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) - try { - handler.fetch(getSyncInfos(diffs)); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } + protected void add(IDiff[] diffs) { + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if (handler != null) + try { + handler.fetch(getSyncInfos(diffs)); + } catch (CVSException e) { + CVSUIPlugin.log(e); + } + } private SyncInfo[] getSyncInfos(IDiff[] diffs) { SyncInfoSet set = new SyncInfoSet(); @@ -235,11 +235,11 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem @Override public void dispose() { - // No longer listen for log entry changes - // (The handler is disposed with the page) - disposed = true; - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) handler.setListener(null); + // No longer listen for log entry changes + // (The handler is disposed with the page) + disposed = true; + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if (handler != null) handler.setListener(null); getConfiguration().setProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR, null); logEntryCache = null; super.dispose(); @@ -248,17 +248,17 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem /** * Fetch the log histories for the remote changes and use this information * to add each resource to an appropriate commit set. - */ - private void handleRemoteChanges(final SyncInfo[] infos, final LogEntryCache logEntries, final IProgressMonitor monitor) { - try { - beginSetUpdate(); - addLogEntries(infos, logEntries, monitor); - } finally { - endSetUpdate(monitor); - } - } + */ + private void handleRemoteChanges(final SyncInfo[] infos, final LogEntryCache logEntries, final IProgressMonitor monitor) { + try { + beginSetUpdate(); + addLogEntries(infos, logEntries, monitor); + } finally { + endSetUpdate(monitor); + } + } - private void beginSetUpdate() { + private void beginSetUpdate() { updatedSets = new HashSet<>(); } @@ -299,15 +299,15 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem * @param log the cvs log for this node */ private void addSyncInfoToCommentNode(SyncInfo info, LogEntryCache logs) { - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) { + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if (handler != null) { ICVSRemoteResource remoteResource = handler.getRemoteResource(info); if(handler.getSubscriber() instanceof CVSCompareSubscriber && remoteResource != null) { addMultipleRevisions(info, logs, remoteResource); } else { addSingleRevision(info, logs, remoteResource); } - } + } } /* @@ -319,7 +319,7 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem */ private void addSingleRevision(SyncInfo info, LogEntryCache logs, ICVSRemoteResource remoteResource) { ILogEntry logEntry = logs.getLogEntry(remoteResource); - if (remoteResource != null && !remoteResource.isFolder()) { + if (remoteResource != null && !remoteResource.isFolder()) { // For incoming deletions grab the comment for the latest on the same branch // which is now in the attic. try { @@ -337,11 +337,11 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem } catch (TeamException e) { // continue and skip deletion checks } - } + } addRemoteChange(info, remoteResource, logEntry); } - /* + /* * Add multiple log entries to the model. * * @param info @@ -369,43 +369,43 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem return false; } - /* - * Add the remote change to an incoming commit set - */ - private void addRemoteChange(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { - if (disposed) return; - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if(handler != null && remoteResource != null && logEntry != null && handler.isRemoteChange(info)) { - if(requiresCustomSyncInfo(info, remoteResource, logEntry)) { - info = new CVSUpdatableSyncInfo(info.getKind(), info.getLocal(), info.getBase(), (RemoteResource)logEntry.getRemoteFile(), getSubscriber()); - try { - info.init(); - } catch (TeamException e) { - // this shouldn't happen, we've provided our own calculate kind - } - } - IDiff diff = getConverter().getDeltaFor(info); - // Only add the info if the base and remote differ - IResourceVariant base = info.getBase(); - IResourceVariant remote = info.getRemote(); - if ((base == null && remote != null) || (remote == null && base != null) || (remote != null && base != null && !base.equals(remote))) { - synchronized(this) { - CVSCheckedInChangeSet set = getChangeSetFor(logEntry); - if (set == null) { - set = createChangeSetFor(logEntry); - add(set); - } + /* + * Add the remote change to an incoming commit set + */ + private void addRemoteChange(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { + if (disposed) return; + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if(handler != null && remoteResource != null && logEntry != null && handler.isRemoteChange(info)) { + if(requiresCustomSyncInfo(info, remoteResource, logEntry)) { + info = new CVSUpdatableSyncInfo(info.getKind(), info.getLocal(), info.getBase(), (RemoteResource)logEntry.getRemoteFile(), getSubscriber()); + try { + info.init(); + } catch (TeamException e) { + // this shouldn't happen, we've provided our own calculate kind + } + } + IDiff diff = getConverter().getDeltaFor(info); + // Only add the info if the base and remote differ + IResourceVariant base = info.getBase(); + IResourceVariant remote = info.getRemote(); + if ((base == null && remote != null) || (remote == null && base != null) || (remote != null && base != null && !base.equals(remote))) { + synchronized(this) { + CVSCheckedInChangeSet set = getChangeSetFor(logEntry); + if (set == null) { + set = createChangeSetFor(logEntry); + add(set); + } set.add(diff); - } - } - } else { - // The info was not retrieved for the remote change for some reason. - // Add the node to the root - //addToDefaultSet(DEFAULT_INCOMING_SET_NAME, info); - } - } + } + } + } else { + // The info was not retrieved for the remote change for some reason. + // Add the node to the root + //addToDefaultSet(DEFAULT_INCOMING_SET_NAME, info); + } + } - private SyncInfoToDiffConverter getConverter() { + private SyncInfoToDiffConverter getConverter() { SyncInfoToDiffConverter converter = Adapters.adapt(subscriber, SyncInfoToDiffConverter.class); if (converter == null) converter = SyncInfoToDiffConverter.getDefault(); @@ -414,22 +414,22 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem private CVSCheckedInChangeSet createChangeSetFor(ILogEntry logEntry) { return new CVSCheckedInChangeSet(logEntry); - } + } - private CVSCheckedInChangeSet getChangeSetFor(ILogEntry logEntry) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set instanceof CVSCheckedInChangeSet && - set.getComment().equals(logEntry.getComment()) && - ((CVSCheckedInChangeSet)set).getAuthor().equals(logEntry.getAuthor())) { - return (CVSCheckedInChangeSet)set; - } - } - return null; - } - - private boolean requiresCustomSyncInfo(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { + private CVSCheckedInChangeSet getChangeSetFor(ILogEntry logEntry) { + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; + if (set instanceof CVSCheckedInChangeSet && + set.getComment().equals(logEntry.getComment()) && + ((CVSCheckedInChangeSet)set).getAuthor().equals(logEntry.getAuthor())) { + return (CVSCheckedInChangeSet)set; + } + } + return null; + } + + private boolean requiresCustomSyncInfo(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { // Only interested in non-deletions if (logEntry.isDeletion()) return false; // Only require a custom sync info if the remote of the sync info @@ -438,17 +438,17 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem if (remote == null) return true; return !remote.equals(remoteResource); } - + /* * @see * org.eclipse.team.ui.synchronize.SyncInfoSetChangeSetCollector#waitUntilDone( * org.eclipse.core.runtime.IProgressMonitor) */ - public void waitUntilDone(IProgressMonitor monitor) { + public void waitUntilDone(IProgressMonitor monitor) { monitor.worked(1); // wait for the event handler to process changes. - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) { + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if (handler != null) { while(handler.getEventHandlerJob().getState() != Job.NONE) { monitor.worked(1); try { @@ -457,26 +457,26 @@ public class CheckedInChangeSetCollector extends BatchingChangeSetManager implem } Policy.checkCanceled(monitor); } - } + } monitor.worked(1); - } + } - @Override + @Override public void logEntriesFetched(SyncInfoSet set, LogEntryCache logEntryCache, IProgressMonitor monitor) { - if (disposed) return; - // Hold on to the cache so we can use it while commit sets are visible - this.logEntryCache = logEntryCache; - try { - beginInput(); - handleRemoteChanges(set.getSyncInfos(), logEntryCache, monitor); - } finally { - endInput(monitor); - } - } + if (disposed) return; + // Hold on to the cache so we can use it while commit sets are visible + this.logEntryCache = logEntryCache; + try { + beginInput(); + handleRemoteChanges(set.getSyncInfos(), logEntryCache, monitor); + } finally { + endInput(monitor); + } + } - public ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException { - if (logEntryCache != null) - return logEntryCache.getImmediatePredecessor(file); - return null; - } + public ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException { + if (logEntryCache != null) + return logEntryCache.getImmediatePredecessor(file); + return null; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java index f910d7279..63a741698 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CreatePatchAction.java @@ -50,7 +50,7 @@ public class CreatePatchAction extends CVSModelProviderAction implements IDiffCh } return getSynchronizationContext().getDiffTree().countFor(IThreeWayDiff.CONFLICTING, IThreeWayDiff.DIRECTION_MASK) > 0; } - + private IResource[] getVisibleResources(ResourceTraversal[] traversals) { final Set resources = new HashSet(); final IResourceDiffTree diffTree = getSynchronizationContext().getDiffTree(); @@ -69,14 +69,14 @@ public class CreatePatchAction extends CVSModelProviderAction implements IDiffCh return (IResource[]) resources.toArray(new IResource[resources.size()]); } - @Override + @Override protected String getBundleKeyPrefix() { - return "GenerateDiffFileAction."; //$NON-NLS-1$ - } - - @Override + return "GenerateDiffFileAction."; //$NON-NLS-1$ + } + + @Override public void execute() { - final ResourceTraversal [][] traversals = new ResourceTraversal[][] { null }; + final ResourceTraversal [][] traversals = new ResourceTraversal[][] { null }; try { PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { try { @@ -98,7 +98,7 @@ public class CreatePatchAction extends CVSModelProviderAction implements IDiffCh GenerateDiffFileWizard.run(getConfiguration().getSite().getPart(), resources, false); } } - } + } @Override public void diffsChanged(IDiffChangeEvent event, IProgressMonitor monitor) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java index 476f70639..82f746f13 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java @@ -115,7 +115,7 @@ public class MergeSubscriberContext extends CVSSubscriberMergeContext { boolean equals(IThreeWayDiff currentDiff, IThreeWayDiff diffTreeDiff) { return currentDiff != null - && currentDiff.getKind() == diffTreeDiff.getKind() + && currentDiff.getKind() == diffTreeDiff.getKind() && currentDiff.getDirection() == diffTreeDiff.getDirection(); } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelCompareParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelCompareParticipant.java index 13337f45f..a1fe01b2d 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelCompareParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelCompareParticipant.java @@ -58,9 +58,9 @@ public class ModelCompareParticipant extends CVSModelSynchronizeParticipant impl @Override public ChangeSetCapability getChangeSetCapability() { - if (capability == null) { - capability = new CompareChangeSetCapability(); - } - return capability; + if (capability == null) { + capability = new CompareChangeSetCapability(); + } + return capability; } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelParticipantChangeSetCapability.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelParticipantChangeSetCapability.java index f4c44a78d..3fd2596f9 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelParticipantChangeSetCapability.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelParticipantChangeSetCapability.java @@ -22,7 +22,7 @@ public abstract class ModelParticipantChangeSetCapability extends ChangeSetCapab @Override public boolean enableChangeSetsByDefault() { - return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT); + return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT); } @Override @@ -32,7 +32,7 @@ public abstract class ModelParticipantChangeSetCapability extends ChangeSetCapab @Override public boolean enableCheckedInChangeSetsFor(ISynchronizePageConfiguration configuration) { - return supportsCheckedInChangeSets() && + return supportsCheckedInChangeSets() && configuration.getMode() != ISynchronizePageConfiguration.OUTGOING_MODE; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java index c44647716..a3364b576 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java @@ -84,10 +84,10 @@ public class ModelReplaceOperation extends ModelUpdateOperation { result[0] = dialog.open(); }); - if (result[0] == 2) - throw new OperationCanceledException(); - hasPrompted = true; - return result[0] == 0; + if (result[0] == 2) + throw new OperationCanceledException(); + hasPrompted = true; + return result[0] == 0; } private boolean hasLocalChanges() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelSynchronizeWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelSynchronizeWizard.java index 5e73e6371..13e68b6f7 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelSynchronizeWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelSynchronizeWizard.java @@ -35,10 +35,10 @@ public class ModelSynchronizeWizard extends ParticipantSynchronizeWizard { private GlobalRefreshElementSelectionPage selectionPage; - private boolean isShowModelSync() { + private boolean isShowModelSync() { return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_ENABLE_MODEL_SYNC); } - + @Override protected void createParticipant() { if (isShowModelSync()) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/OpenChangeSetAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/OpenChangeSetAction.java index 7cd2e0035..58b40232e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/OpenChangeSetAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/OpenChangeSetAction.java @@ -45,25 +45,25 @@ import com.ibm.icu.text.DateFormat; class OpenChangeSetAction extends ResourceModelParticipantAction { - protected OpenChangeSetAction(ISynchronizePageConfiguration configuration) { - super(CVSUIMessages.OpenCommitSetAction_20, configuration); + protected OpenChangeSetAction(ISynchronizePageConfiguration configuration) { + super(CVSUIMessages.OpenCommitSetAction_20, configuration); ISelection selection = configuration.getSite().getSelectionProvider().getSelection(); if (selection != null) selectionChanged(selection); - } - - private ChangeSet getChangeSet(IStructuredSelection selection) { - // First, check to see if a change set is selected directly - if (selection.size() == 1) { - Object o = selection.getFirstElement(); - if (o instanceof IAdaptable) { - ChangeSet set = ((IAdaptable)o).getAdapter(ChangeSet.class); - if (set != null) - return set; - } - } - // Failing that, check to see if all the selected elements and their children are in the same change set - if (selection instanceof TreeSelection) { + } + + private ChangeSet getChangeSet(IStructuredSelection selection) { + // First, check to see if a change set is selected directly + if (selection.size() == 1) { + Object o = selection.getFirstElement(); + if (o instanceof IAdaptable) { + ChangeSet set = ((IAdaptable)o).getAdapter(ChangeSet.class); + if (set != null) + return set; + } + } + // Failing that, check to see if all the selected elements and their children are in the same change set + if (selection instanceof TreeSelection) { TreeSelection ts = (TreeSelection) selection; TreePath[] paths = ts.getPaths(); if (paths.length > 0) { @@ -79,8 +79,8 @@ class OpenChangeSetAction extends ResourceModelParticipantAction { return set; } } - return null; - } + return null; + } private ChangeSet getChangeSet(TreePath treePath) { Object test = treePath.getFirstSegment(); @@ -90,70 +90,70 @@ class OpenChangeSetAction extends ResourceModelParticipantAction { } return null; } - + @Override protected boolean isEnabledForSelection(IStructuredSelection selection) { - // The selection only contains appropriate files so - // only enable if the selection is contained within a single change set - ChangeSet set = getChangeSet(selection); - return set != null; + // The selection only contains appropriate files so + // only enable if the selection is contained within a single change set + ChangeSet set = getChangeSet(selection); + return set != null; } - public void openEditor(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { + public void openEditor(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + try { IDiff[] diffs = getSelectedDiffs(monitor); if (diffs.length > 0) { - ICVSRepositoryLocation location = getLocation(diffs[0]); - if (location == null) { - throw new CVSException(CVSUIMessages.OpenCommitSetAction_21); - } - CompareTreeBuilder builder = new CompareTreeBuilder(location, null, null); - if (buildTrees(builder, diffs)) { - builder.cacheContents(monitor); - builder.openCompareEditor(getConfiguration().getSite().getPart().getSite().getPage(), getCompareTitle(), getCompareToolTip()); - } + ICVSRepositoryLocation location = getLocation(diffs[0]); + if (location == null) { + throw new CVSException(CVSUIMessages.OpenCommitSetAction_21); + } + CompareTreeBuilder builder = new CompareTreeBuilder(location, null, null); + if (buildTrees(builder, diffs)) { + builder.cacheContents(monitor); + builder.openCompareEditor(getConfiguration().getSite().getPart().getSite().getPage(), getCompareTitle(), getCompareToolTip()); + } } } catch (CoreException e) { throw new InvocationTargetException(e); } - } - - private IDiff[] getSelectedDiffs(IProgressMonitor monitor) throws CoreException { - ResourceTraversal[] traversals = getResourceTraversals(getStructuredSelection(), monitor); - DiffChangeSet set = (DiffChangeSet)getChangeSet(getStructuredSelection()); + } + + private IDiff[] getSelectedDiffs(IProgressMonitor monitor) throws CoreException { + ResourceTraversal[] traversals = getResourceTraversals(getStructuredSelection(), monitor); + DiffChangeSet set = (DiffChangeSet)getChangeSet(getStructuredSelection()); return set.getDiffTree().getDiffs(traversals); } /* - * Build the trees that will be compared - */ - private boolean buildTrees(CompareTreeBuilder builder, IDiff[] diffs) { - for (int i = 0; i < diffs.length; i++) { + * Build the trees that will be compared + */ + private boolean buildTrees(CompareTreeBuilder builder, IDiff[] diffs) { + for (int i = 0; i < diffs.length; i++) { IDiff diff = diffs[i]; if (isFileChange(diff)) { - IFileRevision remoteRevision = Utils.getRemote(diff); - IResourceVariant remote = SyncInfoToDiffConverter.asResourceVariant(remoteRevision); - if (remote == null) { - IFileRevision predecessorRevision = Utils.getBase(diff); - IResourceVariant predecessor = SyncInfoToDiffConverter.asResourceVariant(predecessorRevision); - if (predecessor instanceof ICVSRemoteFile) { - builder.addToTrees((ICVSRemoteFile)predecessor, null); - } - } else if (remote instanceof ICVSRemoteFile) { - try { - ICVSRemoteFile predecessor = getImmediatePredecessor(remote); - builder.addToTrees(predecessor, (ICVSRemoteFile)remote); - } catch (TeamException e) { - Utils.handle(e); - return false; - } - } + IFileRevision remoteRevision = Utils.getRemote(diff); + IResourceVariant remote = SyncInfoToDiffConverter.asResourceVariant(remoteRevision); + if (remote == null) { + IFileRevision predecessorRevision = Utils.getBase(diff); + IResourceVariant predecessor = SyncInfoToDiffConverter.asResourceVariant(predecessorRevision); + if (predecessor instanceof ICVSRemoteFile) { + builder.addToTrees((ICVSRemoteFile)predecessor, null); + } + } else if (remote instanceof ICVSRemoteFile) { + try { + ICVSRemoteFile predecessor = getImmediatePredecessor(remote); + builder.addToTrees(predecessor, (ICVSRemoteFile)remote); + } catch (TeamException e) { + Utils.handle(e); + return false; + } + } } - } - return true; - } - - private boolean isFileChange(IDiff diff) { + } + return true; + } + + private boolean isFileChange(IDiff diff) { IResource resource = ResourceDiffTree.getResourceFor(diff); if (resource.getType() == IResource.FILE) { if (diff instanceof IThreeWayDiff) { @@ -166,9 +166,9 @@ class OpenChangeSetAction extends ResourceModelParticipantAction { } private ICVSRepositoryLocation getLocation(IDiff diff) { - IResource resource = ResourceDiffTree.getResourceFor(diff); - RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject()); - if (provider instanceof CVSTeamProvider) { + IResource resource = ResourceDiffTree.getResourceFor(diff); + RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject()); + if (provider instanceof CVSTeamProvider) { CVSTeamProvider ctp = (CVSTeamProvider) provider; try { return ctp.getCVSWorkspaceRoot().getRemoteLocation(); @@ -176,46 +176,46 @@ class OpenChangeSetAction extends ResourceModelParticipantAction { CVSUIPlugin.log(e); } } - return null; - } - - private String getCompareTitle() { - ChangeSet set = getChangeSet(getStructuredSelection()); - if (set instanceof CVSCheckedInChangeSet) { - CVSCheckedInChangeSet cics = (CVSCheckedInChangeSet)set; - String date = DateFormat.getDateTimeInstance().format(cics.getDate()); - return NLS.bind(CVSUIMessages.OpenChangeSetAction_0, new String[] {cics.getAuthor(), date}); - } - return CVSUIMessages.OpenChangeSetAction_1; - } - - private String getCompareToolTip() { - ChangeSet set = getChangeSet(getStructuredSelection()); - if (set != null) - return set.getName(); - return null; - } - - private ICVSRemoteFile getImmediatePredecessor(IResourceVariant remote) throws TeamException { - CheckedInChangeSetCollector changeSetCollector = getChangeSetCollector(); - if (changeSetCollector != null) { - return changeSetCollector.getImmediatePredecessor((ICVSRemoteFile)remote); - } - return null; - } + return null; + } + + private String getCompareTitle() { + ChangeSet set = getChangeSet(getStructuredSelection()); + if (set instanceof CVSCheckedInChangeSet) { + CVSCheckedInChangeSet cics = (CVSCheckedInChangeSet)set; + String date = DateFormat.getDateTimeInstance().format(cics.getDate()); + return NLS.bind(CVSUIMessages.OpenChangeSetAction_0, new String[] {cics.getAuthor(), date}); + } + return CVSUIMessages.OpenChangeSetAction_1; + } + + private String getCompareToolTip() { + ChangeSet set = getChangeSet(getStructuredSelection()); + if (set != null) + return set.getName(); + return null; + } + + private ICVSRemoteFile getImmediatePredecessor(IResourceVariant remote) throws TeamException { + CheckedInChangeSetCollector changeSetCollector = getChangeSetCollector(); + if (changeSetCollector != null) { + return changeSetCollector.getImmediatePredecessor((ICVSRemoteFile)remote); + } + return null; + } - private CheckedInChangeSetCollector getChangeSetCollector() { - return (CheckedInChangeSetCollector)getConfiguration().getProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR); - } - - @Override + private CheckedInChangeSetCollector getChangeSetCollector() { + return (CheckedInChangeSetCollector)getConfiguration().getProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR); + } + + @Override public void run() { - try { + try { PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> openEditor(monitor)); } catch (InvocationTargetException e) { Utils.handle(e); } catch (InterruptedException e) { // Ignore } - } + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceChangeSetCapability.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceChangeSetCapability.java index b85167427..19ff7923d 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceChangeSetCapability.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceChangeSetCapability.java @@ -37,44 +37,44 @@ public class WorkspaceChangeSetCapability extends ModelParticipantChangeSetCapab @Override public boolean enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration) { - return supportsActiveChangeSets() && - configuration.getMode() != ISynchronizePageConfiguration.INCOMING_MODE; + return supportsActiveChangeSets() && + configuration.getMode() != ISynchronizePageConfiguration.INCOMING_MODE; } - @Override + @Override public ActiveChangeSet createChangeSet(ISynchronizePageConfiguration configuration, IDiff[] infos) { - ActiveChangeSet set = getActiveChangeSetManager().createSet(CVSUIMessages.WorkspaceChangeSetCapability_1, new IDiff[0]); + ActiveChangeSet set = getActiveChangeSetManager().createSet(CVSUIMessages.WorkspaceChangeSetCapability_1, new IDiff[0]); CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, getResources(infos), CommitSetDialog.NEW); dialog.open(); if (dialog.getReturnCode() != Window.OK) return null; set.add(infos); return set; - } + } - private IResource[] getResources(IDiff[] diffs) { + private IResource[] getResources(IDiff[] diffs) { Set<IResource> result = new HashSet<>(); - for (int i = 0; i < diffs.length; i++) { + for (int i = 0; i < diffs.length; i++) { IDiff diff = diffs[i]; IResource resource = ResourceDiffTree.getResourceFor(diff); if (resource != null) result.add(resource); } - return result.toArray(new IResource[result.size()]); - } - - @Override + return result.toArray(new IResource[result.size()]); + } + + @Override public void editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set) { - CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, set.getResources(), CommitSetDialog.EDIT); + CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, set.getResources(), CommitSetDialog.EDIT); dialog.open(); if (dialog.getReturnCode() != Window.OK) return; // Nothing to do here as the set was updated by the dialog - } + } - @Override + @Override public ActiveChangeSetManager getActiveChangeSetManager() { - return CVSUIPlugin.getPlugin().getChangeSetManager(); - } - + return CVSUIPlugin.getPlugin().getChangeSetManager(); + } + @Override public CheckedInChangeSetCollector createCheckedInChangeSetCollector(ISynchronizePageConfiguration configuration) { return new CheckedInChangeSetCollector(configuration, CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java index b1fd688e4..315f0249b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceModelParticipant.java @@ -238,30 +238,30 @@ public class WorkspaceModelParticipant extends return WorkspaceSubscriberContext.createWorkspaceScopeManager(mappings, true, isConsultChangeSets); } - @Override + @Override public ChangeSetCapability getChangeSetCapability() { - if (capability == null) { - capability = new WorkspaceChangeSetCapability(); - } - return capability; + if (capability == null) { + capability = new WorkspaceChangeSetCapability(); + } + return capability; } - - @Override + + @Override public void saveState(IMemento memento) { - super.saveState(memento); - memento.putString(CTX_CONSULT_CHANGE_SETS, Boolean.toString(isConsultChangeSets)); - } - - @Override + super.saveState(memento); + memento.putString(CTX_CONSULT_CHANGE_SETS, Boolean.toString(isConsultChangeSets)); + } + + @Override public void init(String secondaryId, IMemento memento) throws PartInitException { - try { - String consult = memento.getString(CTX_CONSULT_CHANGE_SETS); - if (consult != null) - isConsultChangeSets = Boolean.valueOf(consult).booleanValue(); - } finally { - super.init(secondaryId, memento); - } - } + try { + String consult = memento.getString(CTX_CONSULT_CHANGE_SETS); + if (consult != null) + isConsultChangeSets = Boolean.valueOf(consult).booleanValue(); + } finally { + super.init(secondaryId, memento); + } + } private boolean isConsultChangeSets(ISynchronizationScopeManager manager) { if (manager instanceof ChangeSetSubscriberScopeManager) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java index 6a076f904..257dc6d4e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java @@ -412,10 +412,10 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { return traversals; } - @Override + @Override public boolean contains(ResourceMapping mapping) { - return false; - } + return false; + } @Override public String getModelProviderId() { return ModelProvider.RESOURCE_MODEL_PROVIDER_ID; @@ -494,12 +494,12 @@ public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext implem IFile file = (IFile) resource; ICVSFile mFile = CVSWorkspaceRoot.getCVSFileFor(file); try { - // The file may have been set as read-only by a previous checkout/update - if (mFile.isReadOnly()) mFile.setReadOnly(false); - } catch (CVSException e) { - // Just log and keep going - CVSProviderPlugin.log(e); - } + // The file may have been set as read-only by a previous checkout/update + if (mFile.isReadOnly()) mFile.setReadOnly(false); + } catch (CVSException e) { + // Just log and keep going + CVSProviderPlugin.log(e); + } } super.performReplace(diff, monitor); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java index 50176435e..15f3d277f 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java @@ -47,11 +47,11 @@ public class CVSAdapterFactory implements IAdapterFactory { } if(IDeferredWorkbenchAdapter.class == adapterType) { - Object o = getWorkbenchAdapter(adaptableObject); - if(o != null && o instanceof IDeferredWorkbenchAdapter) { - return adapterType.cast(o); - } - return null; + Object o = getWorkbenchAdapter(adaptableObject); + if(o != null && o instanceof IDeferredWorkbenchAdapter) { + return adapterType.cast(o); + } + return null; } if (IPropertySource.class == adapterType) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java index 7e2d57212..6936d1296 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSModelElement.java @@ -83,26 +83,26 @@ public abstract class CVSModelElement implements IWorkbenchAdapter, IAdaptable { * @param description the description to be displayed * @param e the exception that occurred */ - protected void handle(final String title, final String description, final Throwable e) { - CVSUIPlugin.openError(null, title, description, e, CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS | CVSUIPlugin.PERFORM_SYNC_EXEC); - } - - /** - * Helper method error handler that displays a generic dialog title and message when displaying an error to the user. - * @param t the exception that occurred. - */ - protected void handle(Throwable t) { - handle(CVSUIMessages.CVSModelElement_0, CVSUIMessages.CVSModelElement_1, t); // - } - - /** - * Handle an exception that occurred while fetching the children for a deferred workbench adapter. - * @param collector the collector for the adapter - * @param e the exception that occurred - */ - protected void handle(IElementCollector collector, Throwable t) { - // TODO: For now, just display a dialog (see bug 65008 and 65741) - handle(t); - } + protected void handle(final String title, final String description, final Throwable e) { + CVSUIPlugin.openError(null, title, description, e, CVSUIPlugin.LOG_NONTEAM_EXCEPTIONS | CVSUIPlugin.PERFORM_SYNC_EXEC); + } + + /** + * Helper method error handler that displays a generic dialog title and message when displaying an error to the user. + * @param t the exception that occurred. + */ + protected void handle(Throwable t) { + handle(CVSUIMessages.CVSModelElement_0, CVSUIMessages.CVSModelElement_1, t); // + } + + /** + * Handle an exception that occurred while fetching the children for a deferred workbench adapter. + * @param collector the collector for the adapter + * @param e the exception that occurred + */ + protected void handle(IElementCollector collector, Throwable t) { + // TODO: For now, just display a dialog (see bug 65008 and 65741) + handle(t); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java index d678a5f06..bfbcca329 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSTagElement.java @@ -169,12 +169,12 @@ public class CVSTagElement extends CVSModelElement implements IDeferredWorkbench try { collector.add(fetchChildren(o, monitor), monitor); } catch (TeamException e) { - handle(collector, e); + handle(collector, e); } } } - public ISchedulingRule getRule(Object element) { + public ISchedulingRule getRule(Object element) { return new RepositoryLocationSchedulingRule(root); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java index 93888a648..7c596c2d1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteContentProvider.java @@ -102,7 +102,7 @@ public class RemoteContentProvider extends WorkbenchContentProvider { //check to see if we already have the children cached in the tree map Object tree = cachedTrees.get(element); if (tree != null) { - return ((RemoteFolderTree) tree).getChildren(); + return ((RemoteFolderTree) tree).getChildren(); } if (manager != null) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFileElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFileElement.java index b388872df..fc9b533ad 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFileElement.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFileElement.java @@ -45,7 +45,7 @@ public class RemoteFileElement extends RemoteResourceElement { try { return NLS.bind(CVSUIMessages.nameAndRevision, new String[] { file.getName(), file.getRevision() }); } catch (TeamException e) { - handle(null, null, e); + handle(null, null, e); return null; } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java index c2c88d737..838df54dd 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java @@ -30,36 +30,36 @@ import org.eclipse.ui.progress.IElementCollector; public class RemoteFolderElement extends RemoteResourceElement implements IDeferredWorkbenchAdapter { - /** - * Overridden to append the version name to remote folders which - * have version tags and are top-level folders. - */ - public String getLabel(Object o) { - if (!(o instanceof ICVSRemoteFolder)) - return null; - ICVSRemoteFolder folder = (ICVSRemoteFolder) o; - CVSTag tag = folder.getTag(); - if (tag != null && tag.getType() != CVSTag.HEAD) { - if (folder.getRemoteParent() == null) { - return NLS.bind(CVSUIMessages.RemoteFolderElement_nameAndTag, new String[] { folder.getName(), tag.getName() }); - } - } - return folder.getName(); - } + /** + * Overridden to append the version name to remote folders which + * have version tags and are top-level folders. + */ + public String getLabel(Object o) { + if (!(o instanceof ICVSRemoteFolder)) + return null; + ICVSRemoteFolder folder = (ICVSRemoteFolder) o; + CVSTag tag = folder.getTag(); + if (tag != null && tag.getType() != CVSTag.HEAD) { + if (folder.getRemoteParent() == null) { + return NLS.bind(CVSUIMessages.RemoteFolderElement_nameAndTag, new String[] { folder.getName(), tag.getName() }); + } + } + return folder.getName(); + } - public ImageDescriptor getImageDescriptor(Object object) { - if (!(object instanceof ICVSRemoteFolder)) - return null; - ICVSRemoteFolder folder = (ICVSRemoteFolder) object; - if (folder.isDefinedModule()) { - return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_MODULE); - } - return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER); - } + public ImageDescriptor getImageDescriptor(Object object) { + if (!(object instanceof ICVSRemoteFolder)) + return null; + ICVSRemoteFolder folder = (ICVSRemoteFolder) object; + if (folder.isDefinedModule()) { + return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_MODULE); + } + return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER); + } - public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { - if (!(o instanceof ICVSRemoteFolder)) - return new Object[0]; + public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { + if (!(o instanceof ICVSRemoteFolder)) + return new Object[0]; try { monitor = Policy.monitorFor(monitor); monitor.beginTask(NLS.bind( @@ -80,8 +80,8 @@ public class RemoteFolderElement extends RemoteResourceElement implements IDefer } } - public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) { - // If it's not a folder, return an empty array + public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) { + // If it's not a folder, return an empty array if (!(o instanceof ICVSRemoteFolder)) { collector.add(new Object[0], monitor); } @@ -104,20 +104,20 @@ public class RemoteFolderElement extends RemoteResourceElement implements IDefer folder, collector); operation.run(Policy.subMonitorFor(monitor, 50)); } catch (InvocationTargetException e) { - handle(collector, e); + handle(collector, e); } catch (InterruptedException e) { // Cancelled by the user; } catch (CVSException e) { handle(collector, e); } finally { - monitor.done(); - } - } + monitor.done(); + } + } - public ISchedulingRule getRule(Object element) { - ICVSRepositoryLocation location = getRepositoryLocation(element); - return new RepositoryLocationSchedulingRule(location); - } + public ISchedulingRule getRule(Object element) { + ICVSRepositoryLocation location = getRepositoryLocation(element); + return new RepositoryLocationSchedulingRule(location); + } private ICVSRepositoryLocation getRepositoryLocation(Object o) { if (!(o instanceof ICVSRemoteFolder)) @@ -126,6 +126,6 @@ public class RemoteFolderElement extends RemoteResourceElement implements IDefer } public boolean isContainer() { - return true; - } + return true; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java index 9509e8991..a52e48c52 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java @@ -32,128 +32,128 @@ import org.eclipse.ui.progress.IElementCollector; * VersionsCategory. */ public class RemoteModule extends CVSModelElement implements IAdaptable, - IDeferredWorkbenchAdapter { - ICVSRemoteFolder folder; + IDeferredWorkbenchAdapter { + ICVSRemoteFolder folder; - VersionCategory parent; + VersionCategory parent; - /** - * RemoteProject constructor. - */ - public RemoteModule(ICVSRemoteFolder folder, VersionCategory parent) { - this.folder = folder; - this.parent = parent; - } + /** + * RemoteProject constructor. + */ + public RemoteModule(ICVSRemoteFolder folder, VersionCategory parent) { + this.folder = folder; + this.parent = parent; + } - /** - * Returns an object which is an instance of the given class associated with - * this object. Returns <code>null</code> if no such object can be found. - */ - @Override + /** + * Returns an object which is an instance of the given class associated with + * this object. Returns <code>null</code> if no such object can be found. + */ + @Override public <T> T getAdapter(Class<T> adapter) { - if (adapter == IWorkbenchAdapter.class) - return adapter.cast(this); - if (adapter == IDeferredWorkbenchAdapter.class) - return adapter.cast(this); - return null; - } + if (adapter == IWorkbenchAdapter.class) + return adapter.cast(this); + if (adapter == IDeferredWorkbenchAdapter.class) + return adapter.cast(this); + return null; + } - /** - * Returns an image to be used for displaying an object in the desktop. - * - * @param object The object to get an image for. - * @param owner The viewer that the image will be used in. The image will be - * disposed when this viewer is closed. If the owner is null, a - * new image is returned, and the caller is responsible for - * disposing it. - */ - @Override + /** + * Returns an image to be used for displaying an object in the desktop. + * + * @param object The object to get an image for. + * @param owner The viewer that the image will be used in. The image will be + * disposed when this viewer is closed. If the owner is null, a + * new image is returned, and the caller is responsible for + * disposing it. + */ + @Override public ImageDescriptor getImageDescriptor(Object object) { - return CVSUIPlugin.getPlugin().getImageDescriptor( - ICVSUIConstants.IMG_PROJECT_VERSION); - } + return CVSUIPlugin.getPlugin().getImageDescriptor( + ICVSUIConstants.IMG_PROJECT_VERSION); + } - /** - * Returns the name of this element. This will typically be used to assign a - * label to this object when displayed in the UI. - */ - @Override + /** + * Returns the name of this element. This will typically be used to assign a + * label to this object when displayed in the UI. + */ + @Override public String getLabel(Object o) { - return folder.getName(); - } + return folder.getName(); + } - /** - * Returns the logical parent of the given object in its tree. - */ - @Override + /** + * Returns the logical parent of the given object in its tree. + */ + @Override public Object getParent(Object o) { - return parent; - } + return parent; + } - /** - * Return the repository the given element belongs to. - */ - public ICVSRepositoryLocation getRepository(Object o) { - return folder.getRepository(); - } + /** + * Return the repository the given element belongs to. + */ + public ICVSRepositoryLocation getRepository(Object o) { + return folder.getRepository(); + } /* * For debugging purposes only. */ - @Override + @Override public String toString() { - return "RemoteModule(" + folder.getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } + return "RemoteModule(" + folder.getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + } - public ICVSRemoteResource getCVSResource() { - return folder; - } + public ICVSRemoteResource getCVSResource() { + return folder; + } - /** - * Returns the children of this object. When this object is displayed in a - * tree, the returned objects will be this element's children. Returns an - * empty enumeration if this object has no children. The children of the - * RemoteModule are the versions for that module. - * - * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#internalGetChildren(java.lang.Object, - * org.eclipse.core.runtime.IProgressMonitor) - */ - @Override + /** + * Returns the children of this object. When this object is displayed in a + * tree, the returned objects will be this element's children. Returns an + * empty enumeration if this object has no children. The children of the + * RemoteModule are the versions for that module. + * + * @see org.eclipse.team.internal.ccvs.ui.model.CVSModelElement#internalGetChildren(java.lang.Object, + * org.eclipse.core.runtime.IProgressMonitor) + */ + @Override public Object[] fetchChildren(Object o, IProgressMonitor monitor) - throws TeamException { - RepositoryManager manager = CVSUIPlugin.getPlugin() - .getRepositoryManager(); - try { - manager.refreshDefinedTags(folder, false /* recurse */, false /* notify */, monitor); - } catch (TeamException e) { - // continue - } - CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager() - .getKnownTags(folder, CVSTag.VERSION); - Object[] versions = new Object[tags.length]; - for (int i = 0; i < versions.length; i++) { - versions[i] = folder.forTag(tags[i]); - } - return versions; - } + throws TeamException { + RepositoryManager manager = CVSUIPlugin.getPlugin() + .getRepositoryManager(); + try { + manager.refreshDefinedTags(folder, false /* recurse */, false /* notify */, monitor); + } catch (TeamException e) { + // continue + } + CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager() + .getKnownTags(folder, CVSTag.VERSION); + Object[] versions = new Object[tags.length]; + for (int i = 0; i < versions.length; i++) { + versions[i] = folder.forTag(tags[i]); + } + return versions; + } - @Override + @Override public void fetchDeferredChildren(Object o, IElementCollector collector, - IProgressMonitor monitor) { - try { - collector.add(fetchChildren(o, monitor), monitor); - } catch (TeamException e) { - handle(collector, e); - } - } + IProgressMonitor monitor) { + try { + collector.add(fetchChildren(o, monitor), monitor); + } catch (TeamException e) { + handle(collector, e); + } + } - @Override + @Override public boolean isContainer() { - return true; - } + return true; + } - @Override + @Override public ISchedulingRule getRule(Object element) { - return new RepositoryLocationSchedulingRule(folder.getRepository()); - } + return new RepositoryLocationSchedulingRule(folder.getRepository()); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java index 7e57022af..2aa65df5f 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/VersionCategory.java @@ -25,132 +25,132 @@ import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; import org.eclipse.ui.progress.IElementCollector; public class VersionCategory extends CVSModelElement implements IAdaptable, - IDeferredWorkbenchAdapter { - private ICVSRepositoryLocation repository; + IDeferredWorkbenchAdapter { + private ICVSRepositoryLocation repository; - /** - * ProjectVersionsCategory constructor. - */ - public VersionCategory(ICVSRepositoryLocation repo) { - super(); - this.repository = repo; - } + /** + * ProjectVersionsCategory constructor. + */ + public VersionCategory(ICVSRepositoryLocation repo) { + super(); + this.repository = repo; + } - /** - * Returns an object which is an instance of the given class associated with - * this object. Returns <code>null</code> if no such object can be found. - */ - public <T> T getAdapter(Class<T> adapter) { - if (adapter == IWorkbenchAdapter.class) - return adapter.cast(this); - if (adapter == IDeferredWorkbenchAdapter.class) - return adapter.cast(this); - return null; - } + /** + * Returns an object which is an instance of the given class associated with + * this object. Returns <code>null</code> if no such object can be found. + */ + public <T> T getAdapter(Class<T> adapter) { + if (adapter == IWorkbenchAdapter.class) + return adapter.cast(this); + if (adapter == IDeferredWorkbenchAdapter.class) + return adapter.cast(this); + return null; + } - /** - * Returns the children of this object. When this object is displayed in a - * tree, the returned objects will be this element's children. Returns an - * empty enumeration if this object has no children. - */ - public Object[] fetchChildren(Object o, IProgressMonitor monitor) - throws TeamException { - if (CVSUIPlugin.getPlugin().getRepositoryManager() - .isDisplayingProjectVersions(repository)) { - return getProjectVersionChildren(o, monitor); - } else { - return getVersionTagChildren(o, monitor); - } - } + /** + * Returns the children of this object. When this object is displayed in a + * tree, the returned objects will be this element's children. Returns an + * empty enumeration if this object has no children. + */ + public Object[] fetchChildren(Object o, IProgressMonitor monitor) + throws TeamException { + if (CVSUIPlugin.getPlugin().getRepositoryManager() + .isDisplayingProjectVersions(repository)) { + return getProjectVersionChildren(o, monitor); + } else { + return getVersionTagChildren(o, monitor); + } + } - /* - * Return the children as a list of versions whose children are projects - */ - private Object[] getVersionTagChildren(Object o, IProgressMonitor monitor) - throws CVSException { - CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager() - .getKnownTags(repository, getWorkingSet(), CVSTag.VERSION, monitor); - CVSTagElement[] versionElements = new CVSTagElement[tags.length]; - for (int i = 0; i < tags.length; i++) { - versionElements[i] = new CVSTagElement(tags[i], repository); - } - return versionElements; - } + /* + * Return the children as a list of versions whose children are projects + */ + private Object[] getVersionTagChildren(Object o, IProgressMonitor monitor) + throws CVSException { + CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager() + .getKnownTags(repository, getWorkingSet(), CVSTag.VERSION, monitor); + CVSTagElement[] versionElements = new CVSTagElement[tags.length]; + for (int i = 0; i < tags.length; i++) { + versionElements[i] = new CVSTagElement(tags[i], repository); + } + return versionElements; + } - /* - * Return the children as a list of projects whose children ar project - * versions - */ - private Object[] getProjectVersionChildren(Object o, - IProgressMonitor monitor) throws TeamException { + /* + * Return the children as a list of projects whose children ar project + * versions + */ + private Object[] getProjectVersionChildren(Object o, + IProgressMonitor monitor) throws TeamException { - ICVSRemoteResource[] resources = CVSUIPlugin.getPlugin() - .getRepositoryManager().getFoldersForTag(repository, - CVSTag.DEFAULT, monitor); - if (getWorkingSet() != null) - resources = CVSUIPlugin.getPlugin().getRepositoryManager() - .filterResources(getWorkingSet(), resources); - Object[] modules = new Object[resources.length]; - for (int i = 0; i < resources.length; i++) { - modules[i] = new RemoteModule((ICVSRemoteFolder) resources[i], - VersionCategory.this); - } - return modules; - } + ICVSRemoteResource[] resources = CVSUIPlugin.getPlugin() + .getRepositoryManager().getFoldersForTag(repository, + CVSTag.DEFAULT, monitor); + if (getWorkingSet() != null) + resources = CVSUIPlugin.getPlugin().getRepositoryManager() + .filterResources(getWorkingSet(), resources); + Object[] modules = new Object[resources.length]; + for (int i = 0; i < resources.length; i++) { + modules[i] = new RemoteModule((ICVSRemoteFolder) resources[i], + VersionCategory.this); + } + return modules; + } - /** - * Returns an image descriptor to be used for displaying an object in the - * workbench. Returns null if there is no appropriate image. - * - * @param object The object to get an image descriptor for. - */ - public ImageDescriptor getImageDescriptor(Object object) { - return CVSUIPlugin.getPlugin().getImageDescriptor( - ICVSUIConstants.IMG_VERSIONS_CATEGORY); - } + /** + * Returns an image descriptor to be used for displaying an object in the + * workbench. Returns null if there is no appropriate image. + * + * @param object The object to get an image descriptor for. + */ + public ImageDescriptor getImageDescriptor(Object object) { + return CVSUIPlugin.getPlugin().getImageDescriptor( + ICVSUIConstants.IMG_VERSIONS_CATEGORY); + } - /** - * Returns the name of this element. This will typically be used to assign a - * label to this object when displayed in the UI. Returns an empty string if - * there is no appropriate name for this object. - * - * @param object The object to get a label for. - */ - public String getLabel(Object o) { - return CVSUIMessages.VersionCategory_Versions_1; - } + /** + * Returns the name of this element. This will typically be used to assign a + * label to this object when displayed in the UI. Returns an empty string if + * there is no appropriate name for this object. + * + * @param object The object to get a label for. + */ + public String getLabel(Object o) { + return CVSUIMessages.VersionCategory_Versions_1; + } - /** - * Returns the logical parent of the given object in its tree. Returns null - * if there is no parent, or if this object doesn't belong to a tree. - * - * @param object The object to get the parent for. - */ - public Object getParent(Object o) { - return repository; - } + /** + * Returns the logical parent of the given object in its tree. Returns null + * if there is no parent, or if this object doesn't belong to a tree. + * + * @param object The object to get the parent for. + */ + public Object getParent(Object o) { + return repository; + } - /** - * Return the repository the given element belongs to. - */ - public ICVSRepositoryLocation getRepository(Object o) { - return repository; - } + /** + * Return the repository the given element belongs to. + */ + public ICVSRepositoryLocation getRepository(Object o) { + return repository; + } - public void fetchDeferredChildren(Object o, IElementCollector collector, - IProgressMonitor monitor) { - try { - collector.add(fetchChildren(o, monitor), monitor); - } catch (TeamException e) { - handle(collector, e); - } - } + public void fetchDeferredChildren(Object o, IElementCollector collector, + IProgressMonitor monitor) { + try { + collector.add(fetchChildren(o, monitor), monitor); + } catch (TeamException e) { + handle(collector, e); + } + } - public boolean isContainer() { - return true; - } + public boolean isContainer() { + return true; + } - public ISchedulingRule getRule(Object element) { - return new RepositoryLocationSchedulingRule(repository); - } + public ISchedulingRule getRule(Object element) { + return new RepositoryLocationSchedulingRule(repository); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java index 1893d642e..7919b5806 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/AddOperation.java @@ -46,18 +46,18 @@ public class AddOperation extends RepositoryProviderOperation { fModesForFiles= Collections.EMPTY_MAP; } - public void addModesForExtensions(Map modes) { + public void addModesForExtensions(Map modes) { fModesForExtensions= modes; - } - - public void addModesForNames(Map modes) { - fModesForFiles= modes; + } + + public void addModesForNames(Map modes) { + fModesForFiles= modes; } @Override protected void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { - if (resources.length == 0) - return; + if (resources.length == 0) + return; add(provider, resources, recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ONE, monitor); } @@ -129,7 +129,7 @@ public class AddOperation extends RepositoryProviderOperation { // added explicitly (is equal currentResource) or is not ignored if (! isManaged(mResource) && (currentResource.equals(resource) || ! mResource.isIgnored())) { if (resource.getType() == IResource.FILE) { - KSubstOption ksubst= getKSubstOption((IFile)resource); + KSubstOption ksubst= getKSubstOption((IFile)resource); Set set = files.get(ksubst); if (set == null) { set = new HashSet(); @@ -148,7 +148,7 @@ public class AddOperation extends RepositoryProviderOperation { } } - }, depth, false); + }, depth, false); if (exception[0] != null) { throw exception[0]; } @@ -208,13 +208,13 @@ public class AddOperation extends RepositoryProviderOperation { } /* - * Return true if the resource is a project that is already a CVS folder - */ - protected boolean isManagedProject(IResource resource, ICVSResource resource2) throws CVSException { - return resource.getType() == IResource.PROJECT && ((ICVSFolder)resource2).isCVSFolder(); - } + * Return true if the resource is a project that is already a CVS folder + */ + protected boolean isManagedProject(IResource resource, ICVSResource resource2) throws CVSException { + return resource.getType() == IResource.PROJECT && ((ICVSFolder)resource2).isCVSFolder(); + } - /* + /* * Consider a folder managed only if it's also a CVS folder */ protected boolean isManaged(ICVSResource cvsResource) throws CVSException { @@ -226,19 +226,19 @@ public class AddOperation extends RepositoryProviderOperation { return CVSUIMessages.AddAction_addFailed; } - protected KSubstOption getKSubstOption(IFile file) { - final String extension= file.getFileExtension(); - final Integer mode; - if (extension == null) { - mode= (Integer)fModesForFiles.get(file.getName()); - } else { - mode= (Integer)fModesForExtensions.get(extension); - } - if (mode != null) { - return mode.intValue() == Team.BINARY ? Command.KSUBST_BINARY : KSubstOption.getDefaultTextMode(); - } else { - return KSubstOption.fromFile(file); - } - } + protected KSubstOption getKSubstOption(IFile file) { + final String extension= file.getFileExtension(); + final Integer mode; + if (extension == null) { + mode= (Integer)fModesForFiles.get(file.getName()); + } else { + mode= (Integer)fModesForExtensions.get(extension); + } + if (mode != null) { + return mode.intValue() == Team.BINARY ? Command.KSUBST_BINARY : KSubstOption.getDefaultTextMode(); + } else { + return KSubstOption.fromFile(file); + } + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java index 071f36568..4e350b773 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/BranchOperation.java @@ -71,8 +71,8 @@ public class BranchOperation extends RepositoryProviderOperation { } catch (InterruptedException e1) { throw new OperationCanceledException(); } - - IResource[] resources = getTraversalRoots(); + + IResource[] resources = getTraversalRoots(); boolean allSticky = areAllResourcesSticky(resources); String initialVersionName = calculateInitialVersionName(resources,allSticky); final BranchPromptDialog dialog = new BranchPromptDialog(getShell(), @@ -134,7 +134,7 @@ public class BranchOperation extends RepositoryProviderOperation { try { // Build the arguments list ICVSResource[] arguments = getCVSArguments(resources); - LocalOption[] localOptions = getLocalOptions(recurse); + LocalOption[] localOptions = getLocalOptions(recurse); // Tag the remote resources IStatus status = null; @@ -176,7 +176,7 @@ public class BranchOperation extends RepositoryProviderOperation { Session session = new Session(getRemoteLocation(provider), getLocalRoot(provider), true /* output to console */); session.open(Policy.subMonitorFor(monitor, 5), true /* open for modification */); try { - status = Command.CUSTOM_TAG.execute( + status = Command.CUSTOM_TAG.execute( session, Command.NO_GLOBAL_OPTIONS, localOptions, diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java index 705564909..5030bfad1 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java @@ -176,7 +176,7 @@ public abstract class CVSOperation extends TeamOperation implements IShellProvid */ protected final void handleErrors(IStatus[] errors) throws CVSException { // We are only concerned with reportable errors. - // Others will appear in the console + // Others will appear in the console List<IStatus> reportableErrors = new ArrayList<>(); for (int i = 0; i < errors.length; i++) { IStatus status = errors[i]; @@ -194,7 +194,7 @@ public abstract class CVSOperation extends TeamOperation implements IShellProvid } } if (!reportableErrors.isEmpty()) - asException(reportableErrors.toArray(new IStatus[reportableErrors.size()])); + asException(reportableErrors.toArray(new IStatus[reportableErrors.size()])); } /** @@ -203,11 +203,11 @@ public abstract class CVSOperation extends TeamOperation implements IShellProvid * @param status an error status * @return whether the status is reportable or should be ignored */ - protected boolean isReportableError(IStatus status) { - return status.getCode() == CVSStatus.SERVER_ERROR || CVSStatus.isInternalError(status) || status.getCode() == TeamException.UNABLE; - } + protected boolean isReportableError(IStatus status) { + return status.getCode() == CVSStatus.SERVER_ERROR || CVSStatus.isInternalError(status) || status.getCode() == TeamException.UNABLE; + } - protected String getErrorMessage(IStatus[] failures, int totalOperations) { + protected String getErrorMessage(IStatus[] failures, int totalOperations) { return NLS.bind(CVSUIMessages.CVSOperation_0, new String[] { String.valueOf(failures.length), String.valueOf(totalOperations) }); } @@ -298,29 +298,29 @@ public abstract class CVSOperation extends TeamOperation implements IShellProvid return true; } - @Override + @Override protected boolean isSameFamilyAs(TeamOperation operation) { - // Trat all CVS operations as a single family - return operation instanceof CVSOperation; - } - - /* - * Action to show the console that can be used by subclasses - * that wish to link the progress service to the console - */ - protected IAction getShowConsoleAction() { - // Show the console as the goto action - return new Action(CVSUIMessages.CVSOperation_1) { - @Override + // Trat all CVS operations as a single family + return operation instanceof CVSOperation; + } + + /* + * Action to show the console that can be used by subclasses + * that wish to link the progress service to the console + */ + protected IAction getShowConsoleAction() { + // Show the console as the goto action + return new Action(CVSUIMessages.CVSOperation_1) { + @Override public void run() { - CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole(); - if (console != null) - console.show(true); - } - @Override + CVSOutputConsole console = CVSUIPlugin.getPlugin().getConsole(); + if (console != null) + console.show(true); + } + @Override public String getToolTipText() { - return CVSUIMessages.CVSOperation_2; - } - }; - } + return CVSUIMessages.CVSOperation_2; + } + }; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java index cd0d15bac..1fc91f696 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java @@ -99,7 +99,7 @@ public class CacheBaseContentsOperation extends CacheTreeContentsOperation { private void performCleanTimestamps(IProject project, final IResource[] resources, IProgressMonitor monitor) throws CVSException { ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); - final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); + final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); folder.run(monitor1 -> { monitor1.beginTask(null, resources.length * 100); for (int i = 0; i < resources.length; i++) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheTreeContentsOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheTreeContentsOperation.java index 9177bbe08..b0955b832 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheTreeContentsOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheTreeContentsOperation.java @@ -129,28 +129,28 @@ public abstract class CacheTreeContentsOperation extends SingleCommandOperation @Override protected ICVSResource[] getCVSArguments(Session session, IResource[] resources) { List<ICVSResource> result = new ArrayList<>(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - try { + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + try { ICVSResource file = session.getLocalRoot().getChild(resource.getProjectRelativePath().toString()); result.add(file); } catch (CVSException e) { // Log and continue CVSUIPlugin.log(e); } - } + } - return result.toArray(new ICVSResource[result.size()]); + return result.toArray(new ICVSResource[result.size()]); } @Override protected IStatus executeCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { return Command.UPDATE.execute( - session, - Command.NO_GLOBAL_OPTIONS, - getLocalOptions(true), - resources, - new UpdateListener(new IUpdateMessageListener() { + session, + Command.NO_GLOBAL_OPTIONS, + getLocalOptions(true), + resources, + new UpdateListener(new IUpdateMessageListener() { @Override public void fileInformation(int type, ICVSFolder parent, String filename) { // Do nothing @@ -169,7 +169,7 @@ public abstract class CacheTreeContentsOperation extends SingleCommandOperation // Do nothing } }), - monitor); + monitor); } @Override diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java index 2337cd727..0eb05d5a5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutIntoOperation.java @@ -250,10 +250,10 @@ public class CheckoutIntoOperation extends CheckoutOperation { FolderSyncInfo info = folder.getFolderSyncInfo(); if (info.isSameMapping(remoteInfo)) { throw new CVSException(NLS.bind(CVSUIMessages.CheckoutIntoOperation_mappingAlreadyExists, (new Object[] { - remoteFolder.getName(), - targetFolder.getIResource().getFullPath().toString(), - resource.getFullPath().toString() - }))); + remoteFolder.getName(), + targetFolder.getIResource().getFullPath().toString(), + resource.getFullPath().toString() + }))); } folder.acceptChildren(this); } @@ -418,9 +418,9 @@ public class CheckoutIntoOperation extends CheckoutOperation { //use the modfiy rule for the time being //TODO: Just lock the project not the entire workspace (so can't use modifyRule) //since the project already exists - IProject tempProject = getLocalFolder().getIResource().getProject(); - IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); - return ruleFactory.modifyRule(tempProject); + IProject tempProject = getLocalFolder().getIResource().getProject(); + IResourceRuleFactory ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory(); + return ruleFactory.modifyRule(tempProject); } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java index 03ce62031..863931ea3 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutOperation.java @@ -69,13 +69,13 @@ public abstract class CheckoutOperation extends RemoteOperation { } @Override - public boolean isKeepOneProgressServiceEntry() { - // Keep the last repository provider operation in the progress service - return true; - } - + public boolean isKeepOneProgressServiceEntry() { + // Keep the last repository provider operation in the progress service + return true; + } + @Override - protected IAction getGotoAction() { - return getShowConsoleAction(); - } + protected IAction getGotoAction() { + return getShowConsoleAction(); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java index 512d8a3b9..c0b093015 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CheckoutToRemoteFolderOperation.java @@ -58,7 +58,7 @@ public class CheckoutToRemoteFolderOperation extends CheckoutOperation { throws CVSException { if (mFile instanceof RemoteFile) { - try { + try { ((RemoteFile)mFile).aboutToReceiveContents(entryLine.getBytes()); super.receiveTargetFile( session, @@ -69,9 +69,9 @@ public class CheckoutToRemoteFolderOperation extends CheckoutOperation { readOnly, executable, monitor); - } finally { - ((RemoteFile)mFile).doneReceivingContents(); - } + } finally { + ((RemoteFile)mFile).doneReceivingContents(); + } } else { super.receiveTargetFile( session, diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java index f7125bee5..a51131f09 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ClipboardDiffOperation.java @@ -29,7 +29,7 @@ public class ClipboardDiffOperation extends DiffOperation { private static final Object DESTINATION_CLIPBOARD = CVSUIMessages.ClipboardDiffOperation_Clipboard; - final ByteArrayOutputStream os = new ByteArrayOutputStream(); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); public ClipboardDiffOperation(IWorkbenchPart part, ResourceMapping[] mappings, LocalOption[] options, boolean isMultiPatch, boolean includeFullPathInformation, IPath patchRoot) { super(part, mappings, options, isMultiPatch, includeFullPathInformation, patchRoot, DESTINATION_CLIPBOARD); @@ -37,24 +37,24 @@ public class ClipboardDiffOperation extends DiffOperation { @Override public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - super.execute(monitor); - - if (os.size() == 0 || - (!patchHasContents && !patchHasNewFiles)) { - reportEmptyDiff(); - } else { - copyToClipboard(os); - } - } + super.execute(monitor); + + if (os.size() == 0 || + (!patchHasContents && !patchHasNewFiles)) { + reportEmptyDiff(); + } else { + copyToClipboard(os); + } + } - private void copyToClipboard(final ByteArrayOutputStream baos) { + private void copyToClipboard(final ByteArrayOutputStream baos) { getShell().getDisplay().syncExec(() -> { TextTransfer plainTextTransfer = TextTransfer.getInstance(); Clipboard clipboard = new Clipboard(getShell().getDisplay()); clipboard.setContents(new String[] { baos.toString() }, new Transfer[] { plainTextTransfer }); clipboard.dispose(); }); - } + } @Override protected PrintStream openStream() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java index 273f7e7a4..9f3bb9757 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java @@ -67,7 +67,7 @@ public class CommitOperation extends SingleCommandOperation { } @Override - protected ResourceMappingContext getResourceMappingContext() { - return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); - } + protected ResourceMappingContext getResourceMappingContext() { + return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java index 71041bbd0..930bc60b8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/DisconnectOperation.java @@ -45,7 +45,7 @@ public class DisconnectOperation extends RepositoryProviderOperation { throws CVSException, InterruptedException { // This method will be invoked for each provider being disconnected - monitor.beginTask(null, IProgressMonitor.UNKNOWN); + monitor.beginTask(null, IProgressMonitor.UNKNOWN); IProject project = provider.getProject(); try { RepositoryProvider.unmap(project); @@ -57,7 +57,7 @@ public class DisconnectOperation extends RepositoryProviderOperation { cvsFolder.unmanage(monitor); EclipseSynchronizer.getInstance().deconfigure(project, Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN)); } - monitor.done(); + monitor.done(); } @Override diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java index a8fea5535..df4b39a09 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FetchAllMembersOperation.java @@ -33,37 +33,37 @@ import org.eclipse.team.internal.ui.Utils; import org.eclipse.ui.IWorkbenchPart; public class FetchAllMembersOperation extends RemoteOperation { - + class RLogTreeBuilder { - - private ICVSRepositoryLocation location; + + private ICVSRepositoryLocation location; private RemoteFolderTree tree; private CVSTag tag; - public RLogTreeBuilder(ICVSRepositoryLocation location, CVSTag tag) { - this.tag = tag; - this.location = location; - reset(); - } + public RLogTreeBuilder(ICVSRepositoryLocation location, CVSTag tag) { + this.tag = tag; + this.location = location; + reset(); + } + + public RemoteFolderTree getTree() { + return tree; + } + + /** + * Reset the builder to prepare for a new build + */ + public void reset() { + tree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, tag); + tree.setChildren(new ICVSRemoteResource[0]); + } - public RemoteFolderTree getTree() { - return tree; - } - - /** - * Reset the builder to prepare for a new build - */ - public void reset() { - tree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, tag); - tree.setChildren(new ICVSRemoteResource[0]); - } - /* * @see * org.eclipse.team.internal.ccvs.core.client.listeners.RDiffSummaryListener. * IFileDiffListener#newFile(java.lang.String, java.lang.String) */ - public void newFile(IPath remoteFilePath, ICVSRemoteFile remoteFile) { + public void newFile(IPath remoteFilePath, ICVSRemoteFile remoteFile) { try { addFile(tree,tag,remoteFile, remoteFilePath); } catch (CVSException e) { @@ -89,7 +89,7 @@ public class FetchAllMembersOperation extends RemoteOperation { tree.setChildren(newChildren); } - /* + /* * Get the folder at the given path in the given tree, creating any missing folders as needed. */ private ICVSRemoteFolder getFolder(RemoteFolderTree tree, CVSTag tag, IPath remoteFolderPath, IPath parentPath) throws CVSException { @@ -130,7 +130,7 @@ public class FetchAllMembersOperation extends RemoteOperation { try { operation.run(monitor); ICVSRemoteResource[] remoteRes = getRemoteResources(); - final ICVSRemoteFolder project = (ICVSRemoteFolder) remoteRes[0]; + final ICVSRemoteFolder project = (ICVSRemoteFolder) remoteRes[0]; //Get the entry paths String[] entry = cache.getCachedFilePaths(); //Strip repo + project info from entries diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FileDiffOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FileDiffOperation.java index 99a818dac..840ec84d5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FileDiffOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/FileDiffOperation.java @@ -42,8 +42,8 @@ public class FileDiffOperation extends DiffOperation { @Override public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - super.execute(monitor); - + super.execute(monitor); + if (tempFile.length() == 0) { tempFile.delete(); reportEmptyDiff(); @@ -57,7 +57,7 @@ public class FileDiffOperation extends DiffOperation { return; } - copyFile(); + copyFile(); } protected void copyFile() throws CVSException { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java index 1e3d76ae7..353b927d4 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ITagOperation.java @@ -23,11 +23,11 @@ public interface ITagOperation { public abstract void setTag(CVSTag tag); public abstract void run() throws InvocationTargetException, InterruptedException; /** - * Return whether the tag operation contains any resource that would be operated on. - * @return whether the tag operation contains any resource that would be operated on + * Return whether the tag operation contains any resource that would be operated on. + * @return whether the tag operation contains any resource that would be operated on */ public abstract boolean isEmpty(); public abstract void moveTag(); public abstract void doNotRecurse(); - public abstract TagSource getTagSource(); + public abstract TagSource getTagSource(); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java index d8b5a6d6b..97d82aeeb 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteCompareOperation.java @@ -36,91 +36,91 @@ import org.eclipse.ui.IWorkbenchPart; * Compare the two versions of given remote folders obtained from the two tags specified. */ public class RemoteCompareOperation extends RemoteOperation { - - private CompareTreeBuilder builder; - private CVSTag left, right; - /** - * Helper class for builder and comparing the resource trees - */ + private CompareTreeBuilder builder; + private CVSTag left, right; + + /** + * Helper class for builder and comparing the resource trees + */ public static class CompareTreeBuilder implements RDiffSummaryListener.IFileDiffListener { - private ICVSRepositoryLocation location; + private ICVSRepositoryLocation location; private RemoteFolderTree leftTree, rightTree; private CVSTag left, right; - public CompareTreeBuilder(ICVSRepositoryLocation location, CVSTag left, CVSTag right) { - this.left = left; - this.right = right; - this.location = location; - reset(); - } + public CompareTreeBuilder(ICVSRepositoryLocation location, CVSTag left, CVSTag right) { + this.left = left; + this.right = right; + this.location = location; + reset(); + } + + public RemoteFolderTree getLeftTree() { + return leftTree; + } + public RemoteFolderTree getRightTree() { + return rightTree; + } - public RemoteFolderTree getLeftTree() { - return leftTree; - } - public RemoteFolderTree getRightTree() { - return rightTree; - } - - /** - * Reset the builder to prepare for a new build - */ - public void reset() { - leftTree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, left); - leftTree.setChildren(new ICVSRemoteResource[0]); - rightTree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, right); - rightTree.setChildren(new ICVSRemoteResource[0]); - } - - /** - * Cache the contents for the files that are about to be compares - * @throws CVSException - */ - public void cacheContents(IProgressMonitor monitor) throws CVSException { + /** + * Reset the builder to prepare for a new build + */ + public void reset() { + leftTree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, left); + leftTree.setChildren(new ICVSRemoteResource[0]); + rightTree = new RemoteFolderTree(null, location, ICVSRemoteFolder.REPOSITORY_ROOT_FOLDER_NAME, right); + rightTree.setChildren(new ICVSRemoteResource[0]); + } + + /** + * Cache the contents for the files that are about to be compares + * @throws CVSException + */ + public void cacheContents(IProgressMonitor monitor) throws CVSException { String[] overlappingFilePaths = getOverlappingFilePaths(); if (overlappingFilePaths.length > 0) { - monitor.beginTask(null, 100); + monitor.beginTask(null, 100); fetchFileContents(leftTree, overlappingFilePaths, Policy.subMonitorFor(monitor, 50)); fetchFileContents(rightTree, overlappingFilePaths, Policy.subMonitorFor(monitor, 50)); monitor.done(); } - } - - /** - * Open the comparison in a compare editor - */ - public void openCompareEditor(final IWorkbenchPage page, final String title, final String toolTip) { + } + + /** + * Open the comparison in a compare editor + */ + public void openCompareEditor(final IWorkbenchPage page, final String title, final String toolTip) { if (leftTree == null || rightTree == null) return; Display.getDefault().asyncExec(() -> CompareUI.openCompareEditorOnPage(new CVSCompareEditorInput(title, toolTip, new ResourceEditionNode(leftTree), new ResourceEditionNode(rightTree)), page)); - } + } - /** - * Add the predecessor to the left tree and the remote to the right tree. - * @param predecessor - * @param remote - */ - public void addToTrees(ICVSRemoteFile predecessor, ICVSRemoteFile remote) { - if (remote != null) { + /** + * Add the predecessor to the left tree and the remote to the right tree. + * @param predecessor + * @param remote + */ + public void addToTrees(ICVSRemoteFile predecessor, ICVSRemoteFile remote) { + if (remote != null) { try { Path filePath = new Path(null, remote.getRepositoryRelativePath()); - addFile(rightTree, right, filePath, remote.getRevision()); + addFile(rightTree, right, filePath, remote.getRevision()); getFolder(leftTree, left, filePath.removeLastSegments(1), Path.EMPTY); } catch (TeamException e) { CVSUIPlugin.log(e); } - } - if (predecessor != null) { + } + if (predecessor != null) { try { Path filePath = new Path(null, predecessor.getRepositoryRelativePath()); - addFile(leftTree, left, filePath, predecessor.getRevision()); + addFile(leftTree, left, filePath, predecessor.getRevision()); getFolder(rightTree, right, filePath.removeLastSegments(1), Path.EMPTY); } catch (TeamException e) { CVSUIPlugin.log(e); } - } - } - + } + } + private void addFile(RemoteFolderTree tree, CVSTag tag, Path filePath, String revision) throws CVSException { RemoteFolderTree parent = (RemoteFolderTree)getFolder(tree, tag, filePath.removeLastSegments(1), Path.EMPTY); String name = filePath.lastSegment(); @@ -128,14 +128,14 @@ public class RemoteCompareOperation extends RemoteOperation { addChild(parent, file); } - private CVSTag getTag(String revision, CVSTag tag) { - if (tag == null) { - tag = new CVSTag(revision, CVSTag.VERSION); - } - return tag; - } + private CVSTag getTag(String revision, CVSTag tag) { + if (tag == null) { + tag = new CVSTag(revision, CVSTag.VERSION); + } + return tag; + } - /* + /* * Get the folder at the given path in the given tree, creating any missing folders as needed. */ private ICVSRemoteFolder getFolder(RemoteFolderTree tree, CVSTag tag, IPath remoteFolderPath, IPath parentPath) throws CVSException { @@ -165,7 +165,7 @@ public class RemoteCompareOperation extends RemoteOperation { } tree.setChildren(newChildren); } - + @Override public void fileDiff(String remoteFilePath, String leftRevision, String rightRevision) { try { @@ -320,7 +320,7 @@ public class RemoteCompareOperation extends RemoteOperation { ICVSRemoteResource resource = getRemoteResource(); IStatus status = buildTrees(resource, Policy.subMonitorFor(monitor, 50)); if (status.isOK() && fetchContents) { - builder.cacheContents(Policy.subMonitorFor(monitor, 100)); + builder.cacheContents(Policy.subMonitorFor(monitor, 100)); } collectStatus(status); openCompareEditor(builder); @@ -330,18 +330,18 @@ public class RemoteCompareOperation extends RemoteOperation { } /** - * This method is here to allow subclasses to override - */ - protected void openCompareEditor(CompareTreeBuilder builder) { - builder.openCompareEditor(getTargetPage(), null, null); - } + * This method is here to allow subclasses to override + */ + protected void openCompareEditor(CompareTreeBuilder builder) { + builder.openCompareEditor(getTargetPage(), null, null); + } - /* + /* * Build the two trees uses the reponses from "cvs rdiff -s ...". */ private IStatus buildTrees(ICVSRemoteResource resource, IProgressMonitor monitor) throws CVSException { // Initialize the resulting trees - builder.reset(); + builder.reset(); Command.QuietOption oldOption= CVSProviderPlugin.getPlugin().getQuietness(); Session session = new Session(resource.getRepository(), builder.getLeftTree(), false); try { @@ -365,7 +365,7 @@ public class RemoteCompareOperation extends RemoteOperation { } } - private LocalOption[] getLocalOptions() { + private LocalOption[] getLocalOptions() { return new LocalOption[] {RDiff.SUMMARY, RDiff.makeTagOption(left), RDiff.makeTagOption(right)}; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java index b9f01201a..8eeb0d664 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RemoteLogOperation.java @@ -46,41 +46,41 @@ public class RemoteLogOperation extends RepositoryLocationOperation { * remote log operation. */ public static class LogEntryCache implements ILogEntryListener { - - /* - * Cache of all log entries - */ + + /* + * Cache of all log entries + */ private Map<String, Map<String, ILogEntry>> entries = new HashMap<>(); /* * Map String:remoteFilePath->Map * (String:revision -> ILogEntry) */ private Map<String, ILogEntry> internalGetLogEntries(String path) { - return entries.get(path); - } - - /** - * Return all the log entries at the given path - * @param path the file path - * @return the log entries for the file - */ - public ILogEntry[] getLogEntries(String path) { + return entries.get(path); + } + + /** + * Return all the log entries at the given path + * @param path the file path + * @return the log entries for the file + */ + public ILogEntry[] getLogEntries(String path) { Map<String, ILogEntry> map = internalGetLogEntries(path); - return map.values().toArray(new ILogEntry[map.values().size()]); - } - - private ILogEntry internalGetLogEntry(String path, String revision) { - Map fileEntries = internalGetLogEntries(path); - if (fileEntries != null) { - return (ILogEntry)fileEntries.get(revision); - } - return null; - } - - public String[] getCachedFilePaths() { - return entries.keySet().toArray(new String[entries.size()]); - } - + return map.values().toArray(new ILogEntry[map.values().size()]); + } + + private ILogEntry internalGetLogEntry(String path, String revision) { + Map fileEntries = internalGetLogEntries(path); + if (fileEntries != null) { + return (ILogEntry)fileEntries.get(revision); + } + return null; + } + + public String[] getCachedFilePaths() { + return entries.keySet().toArray(new String[entries.size()]); + } + /** * Return the log entry that for the given resource * or <code>null</code> if no entry was fetched or the @@ -89,20 +89,20 @@ public class RemoteLogOperation extends RepositoryLocationOperation { * @return the log entry or <code>null</code> */ public synchronized ILogEntry getLogEntry(ICVSRemoteResource resource) { - if (resource instanceof ICVSRemoteFile) { - try { - String path = getFullPath(resource); - String revision = ((ICVSRemoteFile)resource).getRevision(); - return internalGetLogEntry(path, revision); - } catch (TeamException e) { - // Log and return null - CVSUIPlugin.log(e); - } - } - return null; + if (resource instanceof ICVSRemoteFile) { + try { + String path = getFullPath(resource); + String revision = ((ICVSRemoteFile)resource).getRevision(); + return internalGetLogEntry(path, revision); + } catch (TeamException e) { + // Log and return null + CVSUIPlugin.log(e); + } + } + return null; } - /** + /** * Return the log entries that were fetched for the given resource * or an empty list if no entry was fetched. * @param getFullPath(resource) the resource @@ -110,125 +110,125 @@ public class RemoteLogOperation extends RepositoryLocationOperation { */ public synchronized ILogEntry[] getLogEntries(ICVSRemoteResource resource) { Map<String, ILogEntry> fileEntries = internalGetLogEntries(getFullPath(resource)); - if (fileEntries != null) { - return fileEntries.values().toArray(new ILogEntry[fileEntries.size()]); - } - return new ILogEntry[0]; + if (fileEntries != null) { + return fileEntries.values().toArray(new ILogEntry[fileEntries.size()]); + } + return new ILogEntry[0]; } /* - * Return the full path that uniquely identifies the resource - * accross repositories. This path include the repository and - * resource path but does not include the revision so that - * all log entries for a file can be retrieved. - */ - private String getFullPath(ICVSRemoteResource resource) { - return Util.appendPath(resource.getRepository().getLocation(false), resource.getRepositoryRelativePath()); - } + * Return the full path that uniquely identifies the resource + * accross repositories. This path include the repository and + * resource path but does not include the revision so that + * all log entries for a file can be retrieved. + */ + private String getFullPath(ICVSRemoteResource resource) { + return Util.appendPath(resource.getRepository().getLocation(false), resource.getRepositoryRelativePath()); + } public synchronized void clearEntries() { entries.clear(); } - - public synchronized ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException { - ILogEntry[] allLogs = getLogEntries(file); - String revision = file.getRevision(); - // First decrement the last digit and see if that revision exists - String predecessorRevision = getPredecessorRevision(revision); - ICVSRemoteFile predecessor = findRevison(allLogs, predecessorRevision); - // If nothing was found, try to fond the base of a branch - if (predecessor == null && isBrancheRevision(revision)) { - predecessorRevision = getBaseRevision(revision); - predecessor = findRevison(allLogs, predecessorRevision); - } - // If that fails, it is still possible that there is a revision. - // This can happen if the revision has been manually set. - if (predecessor == null) { - // We don't search in this case since this is costly and would be done - // for any file that is new as well. - } - return predecessor; - } - - /* - * Find the given revision in the list of log entries. - * Return null if the revision wasn't found. - */ - private ICVSRemoteFile findRevison(ILogEntry[] allLogs, String predecessorRevision) throws TeamException { - for (int i = 0; i < allLogs.length; i++) { - ILogEntry entry = allLogs[i]; - ICVSRemoteFile file = entry.getRemoteFile(); - if (file.getRevision().equals(predecessorRevision)) { - return file; - } - } - return null; - } - /* - * Decrement the trailing digit by one. - */ - private String getPredecessorRevision(String revision) { - int digits[] = Util.convertToDigits(revision); - digits[digits.length -1]--; - StringBuffer buffer = new StringBuffer(revision.length()); - for (int i = 0; i < digits.length; i++) { - buffer.append(Integer.toString(digits[i])); - if (i < digits.length - 1) { - buffer.append('.'); - } - } - return buffer.toString(); - } - - /* - * Return true if there are more than 2 digits in the revision number - * (i.e. the revision is on a branch) - */ - private boolean isBrancheRevision(String revision) { - return Util.convertToDigits(revision).length > 2; - } - - /* - * Remove the trailing revision digits such that the - * returned revision is shorter than the given revision - * and is an even number of digits long - */ - private String getBaseRevision(String revision) { - int digits[] = Util.convertToDigits(revision); - int length = digits.length - 1; - if (length % 2 == 1) { - length--; - } - StringBuffer buffer = new StringBuffer(revision.length()); - for (int i = 0; i < length; i++) { - buffer.append(Integer.toString(digits[i])); - if (i < length - 1) { - buffer.append('.'); - } - } - return buffer.toString(); - } - /** - * Remove any entries for the remote resources - * @param resource the remote resource - */ - public synchronized void clearEntries(ICVSRemoteResource resource) { - String remotePath = getFullPath(resource); - entries.remove(remotePath); - } + + public synchronized ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException { + ILogEntry[] allLogs = getLogEntries(file); + String revision = file.getRevision(); + // First decrement the last digit and see if that revision exists + String predecessorRevision = getPredecessorRevision(revision); + ICVSRemoteFile predecessor = findRevison(allLogs, predecessorRevision); + // If nothing was found, try to fond the base of a branch + if (predecessor == null && isBrancheRevision(revision)) { + predecessorRevision = getBaseRevision(revision); + predecessor = findRevison(allLogs, predecessorRevision); + } + // If that fails, it is still possible that there is a revision. + // This can happen if the revision has been manually set. + if (predecessor == null) { + // We don't search in this case since this is costly and would be done + // for any file that is new as well. + } + return predecessor; + } + + /* + * Find the given revision in the list of log entries. + * Return null if the revision wasn't found. + */ + private ICVSRemoteFile findRevison(ILogEntry[] allLogs, String predecessorRevision) throws TeamException { + for (int i = 0; i < allLogs.length; i++) { + ILogEntry entry = allLogs[i]; + ICVSRemoteFile file = entry.getRemoteFile(); + if (file.getRevision().equals(predecessorRevision)) { + return file; + } + } + return null; + } + /* + * Decrement the trailing digit by one. + */ + private String getPredecessorRevision(String revision) { + int digits[] = Util.convertToDigits(revision); + digits[digits.length -1]--; + StringBuffer buffer = new StringBuffer(revision.length()); + for (int i = 0; i < digits.length; i++) { + buffer.append(Integer.toString(digits[i])); + if (i < digits.length - 1) { + buffer.append('.'); + } + } + return buffer.toString(); + } + + /* + * Return true if there are more than 2 digits in the revision number + * (i.e. the revision is on a branch) + */ + private boolean isBrancheRevision(String revision) { + return Util.convertToDigits(revision).length > 2; + } + + /* + * Remove the trailing revision digits such that the + * returned revision is shorter than the given revision + * and is an even number of digits long + */ + private String getBaseRevision(String revision) { + int digits[] = Util.convertToDigits(revision); + int length = digits.length - 1; + if (length % 2 == 1) { + length--; + } + StringBuffer buffer = new StringBuffer(revision.length()); + for (int i = 0; i < length; i++) { + buffer.append(Integer.toString(digits[i])); + if (i < length - 1) { + buffer.append('.'); + } + } + return buffer.toString(); + } + /** + * Remove any entries for the remote resources + * @param resource the remote resource + */ + public synchronized void clearEntries(ICVSRemoteResource resource) { + String remotePath = getFullPath(resource); + entries.remove(remotePath); + } - @Override + @Override public void handleLogEntryReceived(ILogEntry entry) { - ICVSRemoteFile file = entry.getRemoteFile(); - String fullPath = getFullPath(file); - String revision = entry.getRevision(); + ICVSRemoteFile file = entry.getRemoteFile(); + String fullPath = getFullPath(file); + String revision = entry.getRevision(); Map<String, ILogEntry> fileEntries = internalGetLogEntries(fullPath); - if (fileEntries == null) { + if (fileEntries == null) { fileEntries = new HashMap<>(); - entries.put(fullPath, fileEntries); - } - fileEntries.put(revision, entry); - } + entries.put(fullPath, fileEntries); + } + fileEntries.put(revision, entry); + } } public RemoteLogOperation(IWorkbenchPart part, ICVSRemoteResource[] remoteResources, CVSTag tag1, CVSTag tag2, LogEntryCache cache) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java index 8fb53734a..0962590cb 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ReplaceOperation.java @@ -44,8 +44,8 @@ public class ReplaceOperation extends UpdateOperation { } public ReplaceOperation(IWorkbenchPart part, ResourceMapping[] mappings, CVSTag tag) { - super(part, mappings, new LocalOption[] { Update.IGNORE_LOCAL_CHANGES }, tag); - } + super(part, mappings, new LocalOption[] { Update.IGNORE_LOCAL_CHANGES }, tag); + } @Override protected String getTaskName() { @@ -60,8 +60,8 @@ public class ReplaceOperation extends UpdateOperation { final boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { - final IStatus[] status = new IStatus[] { Status.OK_STATUS }; - try { + final IStatus[] status = new IStatus[] { Status.OK_STATUS }; + try { ResourcesPlugin.getWorkspace().run((IWorkspaceRunnable) monitor1 -> { try { status[0] = internalExecuteCommand(session, provider, resources, recurse, monitor1); @@ -69,9 +69,9 @@ public class ReplaceOperation extends UpdateOperation { throw new OperationCanceledException(); } }, null, IWorkspace.AVOID_UPDATE, monitor); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } + } catch (CoreException e) { + throw CVSException.wrapException(e); + } return status[0]; } @@ -85,41 +85,41 @@ public class ReplaceOperation extends UpdateOperation { private boolean ignoreResourcesIfTagDoesNotExist; - private IStatus internalExecuteCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { - monitor.beginTask(null, 100); - ICVSResource[] managedResources = getResourcesToUpdate(resources, Policy.subMonitorFor(monitor, 5)); + private IStatus internalExecuteCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException { + monitor.beginTask(null, 100); + ICVSResource[] managedResources = getResourcesToUpdate(resources, Policy.subMonitorFor(monitor, 5)); if (ignoreResourcesIfTagDoesNotExist && managedResources.length == 0) return OK; - try { - // Purge any unmanaged or added files - PrepareForReplaceVisitor pfrv = new PrepareForReplaceVisitor(session, getTag()); - pfrv.visitResources( - provider.getProject(), - resources, - CVSUIMessages.ReplaceOperation_1, - recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ONE, - Policy.subMonitorFor(monitor, 25)); - prepDeletedFiles = pfrv.getDeletedFiles(); - - // Only perform the remote command if some of the resources being replaced were managed - IStatus status = OK; - if (managedResources.length > 0) { - // Perform an update, ignoring any local file modifications - status = super.executeCommand(session, provider, managedResources, recurse, Policy.subMonitorFor(monitor, 70)); - } - - // Prune any empty folders left after the resources were purged. - // This is done to prune any empty folders that contained only unmanaged resources - if (status.isOK() && CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) { - new PruneFolderVisitor().visit(session, resources); - } - - return status; - } finally { - monitor.done(); - } - } + try { + // Purge any unmanaged or added files + PrepareForReplaceVisitor pfrv = new PrepareForReplaceVisitor(session, getTag()); + pfrv.visitResources( + provider.getProject(), + resources, + CVSUIMessages.ReplaceOperation_1, + recurse ? IResource.DEPTH_INFINITE : IResource.DEPTH_ONE, + Policy.subMonitorFor(monitor, 25)); + prepDeletedFiles = pfrv.getDeletedFiles(); + + // Only perform the remote command if some of the resources being replaced were managed + IStatus status = OK; + if (managedResources.length > 0) { + // Perform an update, ignoring any local file modifications + status = super.executeCommand(session, provider, managedResources, recurse, Policy.subMonitorFor(monitor, 70)); + } + + // Prune any empty folders left after the resources were purged. + // This is done to prune any empty folders that contained only unmanaged resources + if (status.isOK() && CVSProviderPlugin.getPlugin().getPruneEmptyDirectories()) { + new PruneFolderVisitor().visit(session, resources); + } + + return status; + } finally { + monitor.done(); + } + } /** * Return the resources that need to be updated from the server. diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java index 12246e034..594210167 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/RepositoryProviderOperation.java @@ -53,255 +53,255 @@ public abstract class RepositoryProviderOperation extends CVSOperation { private ISynchronizationScopeManager manager; private final ResourceMapping[] selectedMappings; - /** - * Interface that is available to subclasses which identifies - * the depth for various resources. The files will be included - * in whichever group (deep or shallow) has resources. - */ - public interface ICVSTraversal { - IResource[] getShallowResources(); - IResource[] getDeepResources(); - IResource[] getNontraversedFolders(); - } - + /** + * Interface that is available to subclasses which identifies + * the depth for various resources. The files will be included + * in whichever group (deep or shallow) has resources. + */ + public interface ICVSTraversal { + IResource[] getShallowResources(); + IResource[] getDeepResources(); + IResource[] getNontraversedFolders(); + } + /* * A map entry for a provider that divides the traversals to be performed by depth. * There are really only */ private static class TraversalMapEntry implements ICVSTraversal { - // The provider for this entry - RepositoryProvider provider; - // Files are always shallow + // The provider for this entry + RepositoryProvider provider; + // Files are always shallow List<IResource> files = new ArrayList<>(); - // Not sure what to do with zero depth folders but we'll record them + // Not sure what to do with zero depth folders but we'll record them List<IResource> zeroFolders = new ArrayList<>(); - // Non-recursive folder (-l) + // Non-recursive folder (-l) List<IResource> shallowFolders = new ArrayList<>(); - // Recursive folders (-R) + // Recursive folders (-R) List<IResource> deepFolders = new ArrayList<>(); - public TraversalMapEntry(RepositoryProvider provider) { - this.provider = provider; - } - /** - * Add the resources from the traversals to the entry - * @param traversals the traversals - */ - public void add(ResourceTraversal[] traversals) { - for (int i = 0; i < traversals.length; i++) { - ResourceTraversal traversal = traversals[i]; - add(traversal); - } - } - /** - * Add the resources from the traversal to the entry - * @param traversal the traversal - */ - public void add(ResourceTraversal traversal) { - IResource[] resources = traversal.getResources(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (resource.getProject().equals(provider.getProject())) { - if (resource.getType() == IResource.FILE) { - files.add(resource); - } else { - switch (traversal.getDepth()) { - case IResource.DEPTH_ZERO: - zeroFolders.add(resource); - break; - case IResource.DEPTH_ONE: - shallowFolders.add(resource); - break; - case IResource.DEPTH_INFINITE: - deepFolders.add(resource); - break; - default: - deepFolders.add(resource); - } - } - } - } - } - /** - * Return the resources that can be included in a shallow operation. - * Include files with the shallow resources if there are shallow folders - * or if there are no shallow or deep folders. - * @return the resources that can be included in a shallow operation - */ - @Override + public TraversalMapEntry(RepositoryProvider provider) { + this.provider = provider; + } + /** + * Add the resources from the traversals to the entry + * @param traversals the traversals + */ + public void add(ResourceTraversal[] traversals) { + for (int i = 0; i < traversals.length; i++) { + ResourceTraversal traversal = traversals[i]; + add(traversal); + } + } + /** + * Add the resources from the traversal to the entry + * @param traversal the traversal + */ + public void add(ResourceTraversal traversal) { + IResource[] resources = traversal.getResources(); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + if (resource.getProject().equals(provider.getProject())) { + if (resource.getType() == IResource.FILE) { + files.add(resource); + } else { + switch (traversal.getDepth()) { + case IResource.DEPTH_ZERO: + zeroFolders.add(resource); + break; + case IResource.DEPTH_ONE: + shallowFolders.add(resource); + break; + case IResource.DEPTH_INFINITE: + deepFolders.add(resource); + break; + default: + deepFolders.add(resource); + } + } + } + } + } + /** + * Return the resources that can be included in a shallow operation. + * Include files with the shallow resources if there are shallow folders + * or if there are no shallow or deep folders. + * @return the resources that can be included in a shallow operation + */ + @Override public IResource[] getShallowResources() { - if (shallowFolders.isEmpty() && deepFolders.isEmpty() && !files.isEmpty()) { - return files.toArray(new IResource[files.size()]); - } - if (!shallowFolders.isEmpty()) { - if (files.isEmpty()) { - return shallowFolders.toArray(new IResource[shallowFolders.size()]); - } + if (shallowFolders.isEmpty() && deepFolders.isEmpty() && !files.isEmpty()) { + return files.toArray(new IResource[files.size()]); + } + if (!shallowFolders.isEmpty()) { + if (files.isEmpty()) { + return shallowFolders.toArray(new IResource[shallowFolders.size()]); + } List<IResource> result = new ArrayList<>(); - result.addAll(shallowFolders); - result.addAll(files); - return result.toArray(new IResource[result.size()]); - } - return new IResource[0]; - } - /** - * Return the resources to be included in a deep operation. - * If there are no shallow folders, this will include any files. - * @return - */ - @Override + result.addAll(shallowFolders); + result.addAll(files); + return result.toArray(new IResource[result.size()]); + } + return new IResource[0]; + } + /** + * Return the resources to be included in a deep operation. + * If there are no shallow folders, this will include any files. + * @return + */ + @Override public IResource[] getDeepResources() { - if (deepFolders.isEmpty()) - return new IResource[0]; - if (!shallowFolders.isEmpty()) - return deepFolders.toArray(new IResource[deepFolders.size()]); + if (deepFolders.isEmpty()) + return new IResource[0]; + if (!shallowFolders.isEmpty()) + return deepFolders.toArray(new IResource[deepFolders.size()]); List<IResource> result = new ArrayList<>(); - result.addAll(deepFolders); - result.addAll(files); - return result.toArray(new IResource[result.size()]); - } - /** - * Return the folders that are depth zero - */ - @Override + result.addAll(deepFolders); + result.addAll(files); + return result.toArray(new IResource[result.size()]); + } + /** + * Return the folders that are depth zero + */ + @Override public IResource[] getNontraversedFolders() { - return zeroFolders.toArray(new IResource[zeroFolders.size()]); - } + return zeroFolders.toArray(new IResource[zeroFolders.size()]); + } } - - /** - * Convert the provided resources to one or more resource mappers - * that traverse the elements deeply. The model element of the resource - * mappers will be an IStructuredSelection. - * @param resources the resources - * @return a resource mappers that traverses the resources - */ - public static ResourceMapping[] asResourceMappers(final IResource[] resources) { - return asResourceMappers(resources, IResource.DEPTH_INFINITE); - } - - /** - * Convert the provided resources to one or more resource mappers - * that traverse the elements deeply. The model element of the resource - * mappers will be an IStructuredSelection. - * @param resources the resources - * @return a resource mappers that traverses the resources - */ - public static ResourceMapping[] asResourceMappers(final IResource[] resources, int depth) { - return WorkspaceResourceMapper.asResourceMappers(resources, depth); - } - + + /** + * Convert the provided resources to one or more resource mappers + * that traverse the elements deeply. The model element of the resource + * mappers will be an IStructuredSelection. + * @param resources the resources + * @return a resource mappers that traverses the resources + */ + public static ResourceMapping[] asResourceMappers(final IResource[] resources) { + return asResourceMappers(resources, IResource.DEPTH_INFINITE); + } + + /** + * Convert the provided resources to one or more resource mappers + * that traverse the elements deeply. The model element of the resource + * mappers will be an IStructuredSelection. + * @param resources the resources + * @return a resource mappers that traverses the resources + */ + public static ResourceMapping[] asResourceMappers(final IResource[] resources, int depth) { + return WorkspaceResourceMapper.asResourceMappers(resources, depth); + } + public RepositoryProviderOperation(IWorkbenchPart part, final IResource[] resources) { this(part, asResourceMappers(resources)); } - public RepositoryProviderOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings) { - super(part); + public RepositoryProviderOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings) { + super(part); this.selectedMappings = selectedMappings; - } + } @Override public void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { try { - monitor.beginTask(null, 100); - buildScope(monitor); - Map table = getProviderTraversalMapping(Policy.subMonitorFor(monitor, 30)); - execute(table, Policy.subMonitorFor(monitor, 30)); - } catch (CoreException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } + monitor.beginTask(null, 100); + buildScope(monitor); + Map table = getProviderTraversalMapping(Policy.subMonitorFor(monitor, 30)); + execute(table, Policy.subMonitorFor(monitor, 30)); + } catch (CoreException e) { + throw CVSException.wrapException(e); + } finally { + monitor.done(); + } } @Override protected void endOperation() throws CVSException { - if (manager != null) { - manager.dispose(); - manager = null; - } + if (manager != null) { + manager.dispose(); + manager = null; + } super.endOperation(); } - public ISynchronizationScope buildScope(IProgressMonitor monitor) throws InterruptedException, CVSException { - if (manager == null) { - manager = createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings()); - BuildScopeOperation op = new BuildScopeOperation(getPart(), manager); + public ISynchronizationScope buildScope(IProgressMonitor monitor) throws InterruptedException, CVSException { + if (manager == null) { + manager = createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings()); + BuildScopeOperation op = new BuildScopeOperation(getPart(), manager); try { op.run(monitor); } catch (InvocationTargetException e) { throw CVSException.wrapException(e); } - } - return manager.getScope(); + } + return manager.getScope(); } - /** - * Create the scope manager to be used by this operation. - * @param consultModels whether models should be consulted to include additional mappings - * @return a scope manager - */ + /** + * Create the scope manager to be used by this operation. + * @param consultModels whether models should be consulted to include additional mappings + * @return a scope manager + */ protected SynchronizationScopeManager createScopeManager(boolean consultModels) { return new SynchronizationScopeManager(getJobName(), getSelectedMappings(), getResourceMappingContext(), consultModels); } private void execute(Map providerTraversal, IProgressMonitor monitor) throws CVSException, InterruptedException { - Set keySet = providerTraversal.keySet(); - monitor.beginTask(null, keySet.size() * 1000); - Iterator iterator = keySet.iterator(); - while (iterator.hasNext()) { - CVSTeamProvider provider = (CVSTeamProvider)iterator.next(); - monitor.setTaskName(getTaskName(provider)); - TraversalMapEntry entry = (TraversalMapEntry)providerTraversal.get(provider); - execute(provider, entry, Policy.subMonitorFor(monitor, 1000)); - } - } + Set keySet = providerTraversal.keySet(); + monitor.beginTask(null, keySet.size() * 1000); + Iterator iterator = keySet.iterator(); + while (iterator.hasNext()) { + CVSTeamProvider provider = (CVSTeamProvider)iterator.next(); + monitor.setTaskName(getTaskName(provider)); + TraversalMapEntry entry = (TraversalMapEntry)providerTraversal.get(provider); + execute(provider, entry, Policy.subMonitorFor(monitor, 1000)); + } + } - /** - * Execute the operation on the given set of traversals - * @param provider - * @param entry - * @param subMonitor - * @throws CVSException - * @throws InterruptedException - */ - protected void execute(CVSTeamProvider provider, ICVSTraversal entry, IProgressMonitor monitor) throws CVSException, InterruptedException { - IResource[] deepResources = entry.getDeepResources(); - IResource[] shallowResources = entry.getShallowResources(); - IResource[] nontraversedFolders = entry.getNontraversedFolders(); - try { - monitor.beginTask(getTaskName(provider), (deepResources.length > 0 ? 100 : 0) + (shallowResources.length > 0 ? 100 : 0) + (nontraversedFolders.length > 0 ? 10 : 0)); - if (deepResources.length == 0 && shallowResources.length == 0 && nontraversedFolders.length == 0) - return; - final ISchedulingRule rule = getSchedulingRule(provider); - try { - Job.getJobManager().beginRule(rule, monitor); - if (deepResources.length > 0) - execute(provider, deepResources, true /* recurse */, Policy.subMonitorFor(monitor, 100)); - if (shallowResources.length > 0) - execute(provider, shallowResources, false /* recurse */, Policy.subMonitorFor(monitor, 100)); - if (nontraversedFolders.length > 0) { - handleNontraversedFolders(provider, nontraversedFolders, Policy.subMonitorFor(monitor, 10)); - } - } finally { - Job.getJobManager().endRule(rule); - } - } finally { - monitor.done(); - } - } + /** + * Execute the operation on the given set of traversals + * @param provider + * @param entry + * @param subMonitor + * @throws CVSException + * @throws InterruptedException + */ + protected void execute(CVSTeamProvider provider, ICVSTraversal entry, IProgressMonitor monitor) throws CVSException, InterruptedException { + IResource[] deepResources = entry.getDeepResources(); + IResource[] shallowResources = entry.getShallowResources(); + IResource[] nontraversedFolders = entry.getNontraversedFolders(); + try { + monitor.beginTask(getTaskName(provider), (deepResources.length > 0 ? 100 : 0) + (shallowResources.length > 0 ? 100 : 0) + (nontraversedFolders.length > 0 ? 10 : 0)); + if (deepResources.length == 0 && shallowResources.length == 0 && nontraversedFolders.length == 0) + return; + final ISchedulingRule rule = getSchedulingRule(provider); + try { + Job.getJobManager().beginRule(rule, monitor); + if (deepResources.length > 0) + execute(provider, deepResources, true /* recurse */, Policy.subMonitorFor(monitor, 100)); + if (shallowResources.length > 0) + execute(provider, shallowResources, false /* recurse */, Policy.subMonitorFor(monitor, 100)); + if (nontraversedFolders.length > 0) { + handleNontraversedFolders(provider, nontraversedFolders, Policy.subMonitorFor(monitor, 10)); + } + } finally { + Job.getJobManager().endRule(rule); + } + } finally { + monitor.done(); + } + } /** - * Handle any non-traversed (depth-zero) folders that were in the logical modle that primed this operation. - * @param provider the repository provider associated with the project containing the folders - * @param nontraversedFolders the folders - * @param monitor a progress monitor - */ - protected void handleNontraversedFolders(CVSTeamProvider provider, IResource[] nontraversedFolders, IProgressMonitor monitor) throws CVSException { - // Default is do nothing - } + * Handle any non-traversed (depth-zero) folders that were in the logical modle that primed this operation. + * @param provider the repository provider associated with the project containing the folders + * @param nontraversedFolders the folders + * @param monitor a progress monitor + */ + protected void handleNontraversedFolders(CVSTeamProvider provider, IResource[] nontraversedFolders, IProgressMonitor monitor) throws CVSException { + // Default is do nothing + } - /** + /** * Return the taskname to be shown in the progress monitor while operating * on the given provider. * @param provider the provider being processed @@ -327,37 +327,37 @@ public abstract class RepositoryProviderOperation extends CVSOperation { Map getProviderTraversalMapping(IProgressMonitor monitor) throws CoreException { Map<RepositoryProvider, TraversalMapEntry> result = new HashMap<>(); ResourceMapping[] mappings = getScope().getMappings(); - for (int j = 0; j < mappings.length; j++) { - ResourceMapping mapping = mappings[j]; - IProject[] projects = mapping.getProjects(); - ResourceTraversal[] traversals = getScope().getTraversals(mapping); - for (int k = 0; k < projects.length; k++) { - IProject project = projects[k]; - RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); - if (provider != null) { - TraversalMapEntry entry = result.get(provider); - if (entry == null) { - entry = new TraversalMapEntry(provider); - result.put(provider, entry); - } - entry.add(traversals); - } - } - } + for (int j = 0; j < mappings.length; j++) { + ResourceMapping mapping = mappings[j]; + IProject[] projects = mapping.getProjects(); + ResourceTraversal[] traversals = getScope().getTraversals(mapping); + for (int k = 0; k < projects.length; k++) { + IProject project = projects[k]; + RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); + if (provider != null) { + TraversalMapEntry entry = result.get(provider); + if (entry == null) { + entry = new TraversalMapEntry(provider); + result.put(provider, entry); + } + entry.add(traversals); + } + } + } return result; } - /** - * Return the resource mapping context that is to be used by this operation. - * By default, <code>null</code> is returned but subclasses may override - * to provide a specific context. - * @return the resource mapping context for this operation - */ + /** + * Return the resource mapping context that is to be used by this operation. + * By default, <code>null</code> is returned but subclasses may override + * to provide a specific context. + * @return the resource mapping context for this operation + */ protected ResourceMappingContext getResourceMappingContext() { - return ResourceMappingContext.LOCAL_CONTEXT; - } + return ResourceMappingContext.LOCAL_CONTEXT; + } - /** + /** * Execute the operation on the resources for the given provider. * @param provider the provider for the project that contains the resources * @param resources the resources to be operated on @@ -368,19 +368,19 @@ public abstract class RepositoryProviderOperation extends CVSOperation { */ protected abstract void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException; - /** - * Return the local options for this operation including the - * option to provide the requested traversal. - * @param recurse deep or shallow - * @return the local options for the operation - */ - protected LocalOption[] getLocalOptions(boolean recurse) { - if (!recurse) { - return new LocalOption[] { Command.DO_NOT_RECURSE }; - } - return Command.NO_LOCAL_OPTIONS; - } - + /** + * Return the local options for this operation including the + * option to provide the requested traversal. + * @param recurse deep or shallow + * @return the local options for the operation + */ + protected LocalOption[] getLocalOptions(boolean recurse) { + if (!recurse) { + return new LocalOption[] { Command.DO_NOT_RECURSE }; + } + return Command.NO_LOCAL_OPTIONS; + } + protected ICVSResource[] getCVSArguments(IResource[] resources) { ICVSResource[] cvsResources = new ICVSResource[resources.length]; for (int i = 0; i < cvsResources.length; i++) { @@ -444,46 +444,46 @@ public abstract class RepositoryProviderOperation extends CVSOperation { } } - @Override + @Override public boolean isKeepOneProgressServiceEntry() { - // Keep the last repository provider operation in the progress service - return true; - } - - @Override + // Keep the last repository provider operation in the progress service + return true; + } + + @Override protected IAction getGotoAction() { - return getShowConsoleAction(); - } - - /** - * Return the root resources for all the traversals of this operation. - * This method may only be invoked after {@link #buildScope(IProgressMonitor) }. - * @return the root resources for all the traversals of this operation - * @throws CoreException - */ - protected IResource[] getTraversalRoots() { + return getShowConsoleAction(); + } + + /** + * Return the root resources for all the traversals of this operation. + * This method may only be invoked after {@link #buildScope(IProgressMonitor) }. + * @return the root resources for all the traversals of this operation + * @throws CoreException + */ + protected IResource[] getTraversalRoots() { List<IResource> result = new ArrayList<>(); - ResourceTraversal[] traversals = getTraversals(); - for (int i = 0; i < traversals.length; i++) { - ResourceTraversal traversal = traversals[i]; - result.addAll(Arrays.asList(traversal.getResources())); - } - return result.toArray(new IResource[result.size()]); - } - - /** - * Return the traversals that will be used by this operation. - * This method can only be called after {@link #buildScope(IProgressMonitor) }. - * @return the traversals that will be used by this operation - * @throws CoreException - */ - public ResourceTraversal[] getTraversals() { - return getScope().getTraversals(); - } - - public boolean consultModelsForMappings() { - return true; - } + ResourceTraversal[] traversals = getTraversals(); + for (int i = 0; i < traversals.length; i++) { + ResourceTraversal traversal = traversals[i]; + result.addAll(Arrays.asList(traversal.getResources())); + } + return result.toArray(new IResource[result.size()]); + } + + /** + * Return the traversals that will be used by this operation. + * This method can only be called after {@link #buildScope(IProgressMonitor) }. + * @return the traversals that will be used by this operation + * @throws CoreException + */ + public ResourceTraversal[] getTraversals() { + return getScope().getTraversals(); + } + + public boolean consultModelsForMappings() { + return true; + } public ResourceMapping[] getSelectedMappings() { return selectedMappings; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java index eebe6925d..af8b6e747 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShareProjectOperation.java @@ -110,7 +110,7 @@ public class ShareProjectOperation extends CVSOperation { monitor.beginTask(null, IProgressMonitor.UNKNOWN); purgeAnyCVSFolders(Policy.subMonitorFor(monitor, IProgressMonitor.UNKNOWN)); // Link the project to the newly created module - monitor.subTask(NLS.bind(CVSUIMessages.ShareProjectOperation_3, new String[] { project.getName(), remote.getRepositoryRelativePath() })); + monitor.subTask(NLS.bind(CVSUIMessages.ShareProjectOperation_3, new String[] { project.getName(), remote.getRepositoryRelativePath() })); ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project); folder.setFolderSyncInfo(remote.getFolderSyncInfo()); //Register it with Team. If it already is, no harm done. @@ -187,7 +187,7 @@ public class ShareProjectOperation extends CVSOperation { */ private void purgeAnyCVSFolders(final IProgressMonitor monitor) { try { - monitor.beginTask(null, IProgressMonitor.UNKNOWN); + monitor.beginTask(null, IProgressMonitor.UNKNOWN); ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); folder.accept(new ICVSResourceVisitor() { @Override @@ -196,7 +196,7 @@ public class ShareProjectOperation extends CVSOperation { } @Override public void visitFolder(ICVSFolder folder) throws CVSException { - monitor.subTask(NLS.bind(CVSUIMessages.ShareProjectOperation_2, new String[] { folder.getIResource().getFullPath().toString() } )); + monitor.subTask(NLS.bind(CVSUIMessages.ShareProjectOperation_2, new String[] { folder.getIResource().getFullPath().toString() } )); if (folder.isCVSFolder()) { // for now, just unmanage folder.unmanage(null); @@ -207,7 +207,7 @@ public class ShareProjectOperation extends CVSOperation { // log the exception and return null CVSUIPlugin.log(e); } finally { - monitor.done(); - } + monitor.done(); + } } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java index 40403b4df..7e043bbe0 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/ShowAnnotationOperation.java @@ -57,21 +57,21 @@ import com.ibm.icu.text.DateFormat; * display them in the annotations view. */ public class ShowAnnotationOperation extends CVSOperation { - - private final ICVSResource fCVSResource; - private final String fRevision; - private final boolean fBinary; + + private final ICVSResource fCVSResource; + private final String fRevision; + private final boolean fBinary; - public ShowAnnotationOperation(IWorkbenchPart part, ICVSResource cvsResource, String revision, boolean binary) { - super(part); - fCVSResource= cvsResource; - fRevision= revision; - fBinary = binary; - } + public ShowAnnotationOperation(IWorkbenchPart part, ICVSResource cvsResource, String revision, boolean binary) { + super(part); + fCVSResource= cvsResource; + fRevision= revision; + fBinary = binary; + } - @Override + @Override protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - + monitor.beginTask(null, 100); // Get the annotations from the repository. @@ -100,35 +100,35 @@ public class ShowAnnotationOperation extends CVSOperation { monitor.done(); } - - /** - * Shows the history view, creating it if necessary, but does not give it focus. - * - * @param page the workbench page to operate in - * @param editor the editor that is showing the file - * @return the history view - * @throws PartInitException - */ - private IHistoryView showHistoryView(IWorkbenchPage page, AbstractDecoratedTextEditor editor) throws PartInitException { - Object object = fCVSResource.getIResource(); - if (object == null) - object = editor.getEditorInput(); + + /** + * Shows the history view, creating it if necessary, but does not give it focus. + * + * @param page the workbench page to operate in + * @param editor the editor that is showing the file + * @return the history view + * @throws PartInitException + */ + private IHistoryView showHistoryView(IWorkbenchPage page, AbstractDecoratedTextEditor editor) throws PartInitException { + Object object = fCVSResource.getIResource(); + if (object == null) + object = editor.getEditorInput(); IHistoryView historyView= TeamUI.showHistoryFor(page, object, null); - IHistoryPage historyPage = historyView.getHistoryPage(); - if (historyPage instanceof CVSHistoryPage){ - CVSHistoryPage cvsHistoryPage = (CVSHistoryPage) historyPage; - cvsHistoryPage.setMode(CVSHistoryPage.REMOTE_MODE); - // We need to call link to ensure that the history page gets linked + IHistoryPage historyPage = historyView.getHistoryPage(); + if (historyPage instanceof CVSHistoryPage){ + CVSHistoryPage cvsHistoryPage = (CVSHistoryPage) historyPage; + cvsHistoryPage.setMode(CVSHistoryPage.REMOTE_MODE); + // We need to call link to ensure that the history page gets linked // even if the page input did not change - cvsHistoryPage.linkWithEditor(); - } - return historyView; - } + cvsHistoryPage.linkWithEditor(); + } + return historyView; + } - @Override + @Override protected String getTaskName() { - return CVSUIMessages.ShowAnnotationOperation_taskName; - } + return CVSUIMessages.ShowAnnotationOperation_taskName; + } protected boolean hasCharset(ICVSResource cvsResource, InputStream contents) { try { @@ -147,45 +147,45 @@ public class ShowAnnotationOperation extends CVSOperation { if (fCVSResource instanceof ICVSRemoteResource) { return RevisionAnnotationController.openEditor(getPart().getSite().getPage(), fCVSResource, new RemoteAnnotationStorage((ICVSRemoteFile)fCVSResource, listener.getContents())); } - return null; + return null; } private void fetchAnnotation(AnnotateListener listener, ICVSResource cvsResource, String revision, IProgressMonitor monitor) throws CVSException { - - monitor = Policy.monitorFor(monitor); - monitor.beginTask(null, 100); - - final ICVSFolder folder = cvsResource.getParent(); - final FolderSyncInfo info = folder.getFolderSyncInfo(); - final ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(info.getRoot()); - - final Session session = new Session(location, folder, true /*output to console*/); - session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */); - try { - final Command.QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness(); - try { - CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE); + + monitor = Policy.monitorFor(monitor); + monitor.beginTask(null, 100); + + final ICVSFolder folder = cvsResource.getParent(); + final FolderSyncInfo info = folder.getFolderSyncInfo(); + final ICVSRepositoryLocation location = KnownRepositories.getInstance().getRepository(info.getRoot()); + + final Session session = new Session(location, folder, true /*output to console*/); + session.open(Policy.subMonitorFor(monitor, 10), false /* read-only */); + try { + final Command.QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness(); + try { + CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE); List<Object> localOptions = new ArrayList<>(); - if (revision != null) { - localOptions.add(Annotate.makeRevisionOption(revision)); - } - if (fBinary) { - localOptions.add(Annotate.FORCE_BINARY_ANNOTATE); - } - final IStatus status = Command.ANNOTATE.execute(session, Command.NO_GLOBAL_OPTIONS, localOptions.toArray(new LocalOption[localOptions.size()]), new ICVSResource[]{cvsResource}, listener, Policy.subMonitorFor(monitor, 90)); - if (status.getCode() == CVSStatus.SERVER_ERROR) { - throw new CVSServerException(status); - } - } finally { - CVSProviderPlugin.getPlugin().setQuietness(quietness); - monitor.done(); - } - } finally { - session.close(); - } - } + if (revision != null) { + localOptions.add(Annotate.makeRevisionOption(revision)); + } + if (fBinary) { + localOptions.add(Annotate.FORCE_BINARY_ANNOTATE); + } + final IStatus status = Command.ANNOTATE.execute(session, Command.NO_GLOBAL_OPTIONS, localOptions.toArray(new LocalOption[localOptions.size()]), new ICVSResource[]{cvsResource}, listener, Policy.subMonitorFor(monitor, 90)); + if (status.getCode() == CVSStatus.SERVER_ERROR) { + throw new CVSServerException(status); + } + } finally { + CVSProviderPlugin.getPlugin().setQuietness(quietness); + monitor.done(); + } + } finally { + session.close(); + } + } - private RevisionInformation createRevisionInformation(final AnnotateListener listener, IProgressMonitor monitor) throws CVSException { + private RevisionInformation createRevisionInformation(final AnnotateListener listener, IProgressMonitor monitor) throws CVSException { Map<String, ILogEntry> logEntriesByRevision = new HashMap<>(); if (fCVSResource instanceof ICVSFile) { try { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java index a2424a47c..31793ce78 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/SingleCommandOperation.java @@ -42,8 +42,8 @@ public abstract class SingleCommandOperation extends RepositoryProviderOperation try { IStatus status = executeCommand(session, provider, getCVSArguments(session, resources), recurse, Policy.subMonitorFor(monitor, 90)); if (isReportableError(status)) { - throw new CVSException(status); - } + throw new CVSException(status); + } } finally { session.close(); } @@ -54,21 +54,21 @@ public abstract class SingleCommandOperation extends RepositoryProviderOperation return super.getCVSArguments(resources); } - protected ICVSResource[] getCVSArguments(Session session, IResource[] resources) { + protected ICVSResource[] getCVSArguments(Session session, IResource[] resources) { return getCVSArguments(resources); } @Override - protected void execute(CVSTeamProvider provider, ICVSTraversal entry, IProgressMonitor monitor) throws CVSException, InterruptedException { - try { - // TODO: This does not properly count the number of operations - // Changing it causes an error in the test cases - super.execute(provider, entry, monitor); - collectStatus(Status.OK_STATUS); - } catch (CVSException e) { - collectStatus(e.getStatus()); - } - } + protected void execute(CVSTeamProvider provider, ICVSTraversal entry, IProgressMonitor monitor) throws CVSException, InterruptedException { + try { + // TODO: This does not properly count the number of operations + // Changing it causes an error in the test cases + super.execute(provider, entry, monitor); + collectStatus(Status.OK_STATUS); + } catch (CVSException e) { + collectStatus(e.getStatus()); + } + } /** * Indicate whether the operation requires write access to the server (i.e. * the operation changes state on the server whether it be to commit, tag, admin, etc). @@ -80,24 +80,24 @@ public abstract class SingleCommandOperation extends RepositoryProviderOperation /** * Method overridden by subclasses to issue the command to the CVS repository using the given session. - * @param session an open session which will be closed by the caller - * @param provider the provider for the project that contains the resources - * @param resources the resources to be operated on - * @param recurse whether the operation is deep or shallow - * @param monitor a progress monitor + * @param session an open session which will be closed by the caller + * @param provider the provider for the project that contains the resources + * @param resources the resources to be operated on + * @param recurse whether the operation is deep or shallow + * @param monitor a progress monitor */ protected abstract IStatus executeCommand(Session session, CVSTeamProvider provider, ICVSResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException; @Override protected LocalOption[] getLocalOptions(boolean recurse) { - LocalOption[] result = options; - if (recurse) { - // For deep operations, we just need to make sure that the -l option isn't present - result = Command.DO_NOT_RECURSE.removeFrom(options); - } else { - result = Command.RECURSE.removeFrom(options); - result = Command.DO_NOT_RECURSE.addTo(options); - } + LocalOption[] result = options; + if (recurse) { + // For deep operations, we just need to make sure that the -l option isn't present + result = Command.DO_NOT_RECURSE.removeFrom(options); + } else { + result = Command.RECURSE.removeFrom(options); + result = Command.DO_NOT_RECURSE.addTo(options); + } return result; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java index 8ac845dbd..3efb9d265 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagInRepositoryOperation.java @@ -104,18 +104,18 @@ public class TagInRepositoryOperation extends RemoteOperation implements ITagOpe } @Override - public TagSource getTagSource() { - return TagSource.create(getCVSResources()); - } - - @Override + public TagSource getTagSource() { + return TagSource.create(getCVSResources()); + } + + @Override protected boolean isReportableError(IStatus status) { - return super.isReportableError(status) - || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS; - } + return super.isReportableError(status) + || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS; + } @Override - public boolean isEmpty() { - return getCVSResources().length == 0; - } + public boolean isEmpty() { + return getCVSResources().length == 0; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java index b9ae57e79..a525ba91e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/TagOperation.java @@ -84,12 +84,12 @@ public class TagOperation extends RepositoryProviderOperation implements ITagOpe public IStatus tag(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor progress) throws CVSException { LocalOption[] commandOptions = localOptions.toArray(new LocalOption[localOptions.size()]); - if (recurse) { - commandOptions = Command.DO_NOT_RECURSE.removeFrom(commandOptions); - } else { - commandOptions = Command.RECURSE.removeFrom(commandOptions); - commandOptions = Command.DO_NOT_RECURSE.addTo(commandOptions); - } + if (recurse) { + commandOptions = Command.DO_NOT_RECURSE.removeFrom(commandOptions); + } else { + commandOptions = Command.RECURSE.removeFrom(commandOptions); + commandOptions = Command.DO_NOT_RECURSE.addTo(commandOptions); + } // Build the arguments list String[] arguments = getStringArguments(resources); @@ -150,21 +150,21 @@ public class TagOperation extends RepositoryProviderOperation implements ITagOpe } } - private ICVSResource[] getCVSResources() { - IResource[] resources = getTraversalRoots(); - ICVSResource[] cvsResources = new ICVSResource[resources.length]; - for (int i = 0; i < resources.length; i++) { - cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(resources[i]); - } - return cvsResources; - } + private ICVSResource[] getCVSResources() { + IResource[] resources = getTraversalRoots(); + ICVSResource[] cvsResources = new ICVSResource[resources.length]; + for (int i = 0; i < resources.length; i++) { + cvsResources[i] = CVSWorkspaceRoot.getCVSResourceFor(resources[i]); + } + return cvsResources; + } - @Override + @Override public TagSource getTagSource() { - return TagSource.create(getProjects()); - } + return TagSource.create(getProjects()); + } - private IProject[] getProjects() { + private IProject[] getProjects() { ResourceMapping[] mappings = getSelectedMappings(); Set<IProject> projects = new HashSet<>(); for (int i = 0; i < mappings.length; i++) { @@ -176,12 +176,12 @@ public class TagOperation extends RepositoryProviderOperation implements ITagOpe @Override protected boolean isReportableError(IStatus status) { - return super.isReportableError(status) - || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS; - } + return super.isReportableError(status) + || status.getCode() == CVSStatus.TAG_ALREADY_EXISTS; + } - @Override + @Override public boolean isEmpty() { - return getSelectedMappings().length == 0; - } + return getSelectedMappings().length == 0; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java index d84d546f2..ef808f6c5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/UpdateOperation.java @@ -48,17 +48,17 @@ public class UpdateOperation extends SingleCommandOperation { this(part, asResourceMappers(resources), options, tag); } - /** - * Create an UpdateOperation that will perform on update on the given resources - * using the given local option. If a tag is provided, it will be added to the - * local options using the appropriate argument (-r or -D). If the tag is <code>null</code> - * then the tag will be omitted from the local options and the tags on the local resources - * will be used. - */ - public UpdateOperation(IWorkbenchPart part, ResourceMapping[] mappings, LocalOption[] options, CVSTag tag) { - super(part, mappings, options); - this.tag = tag; - } + /** + * Create an UpdateOperation that will perform on update on the given resources + * using the given local option. If a tag is provided, it will be added to the + * local options using the appropriate argument (-r or -D). If the tag is <code>null</code> + * then the tag will be omitted from the local options and the tags on the local resources + * will be used. + */ + public UpdateOperation(IWorkbenchPart part, ResourceMapping[] mappings, LocalOption[] options, CVSTag tag) { + super(part, mappings, options); + this.tag = tag; + } @Override protected IStatus executeCommand( @@ -84,19 +84,19 @@ public class UpdateOperation extends SingleCommandOperation { return execute; } - @Override + @Override protected LocalOption[] getLocalOptions(boolean recurse) { - // Build the local options + // Build the local options List<LocalOption> localOptions = new ArrayList<>(); - // Use the appropriate tag options - if (tag != null) { - localOptions.add(Update.makeTagOption(tag)); - } - // Build the arguments list - localOptions.addAll(Arrays.asList(super.getLocalOptions(recurse))); - LocalOption[] commandOptions = localOptions.toArray(new LocalOption[localOptions.size()]); - return commandOptions; - } + // Use the appropriate tag options + if (tag != null) { + localOptions.add(Update.makeTagOption(tag)); + } + // Build the arguments list + localOptions.addAll(Arrays.asList(super.getLocalOptions(recurse))); + LocalOption[] commandOptions = localOptions.toArray(new LocalOption[localOptions.size()]); + return commandOptions; + } protected Update getUpdateCommand() { return Command.UPDATE; @@ -121,23 +121,23 @@ public class UpdateOperation extends SingleCommandOperation { return null; } - @Override + @Override protected boolean isReportableError(IStatus status) { - return super.isReportableError(status) - || status.getCode() == CVSStatus.UNMEGERED_BINARY_CONFLICT - || status.getCode() == CVSStatus.INVALID_LOCAL_RESOURCE_PATH - || status.getCode() == CVSStatus.RESPONSE_HANDLING_FAILURE; - } + return super.isReportableError(status) + || status.getCode() == CVSStatus.UNMEGERED_BINARY_CONFLICT + || status.getCode() == CVSStatus.INVALID_LOCAL_RESOURCE_PATH + || status.getCode() == CVSStatus.RESPONSE_HANDLING_FAILURE; + } @Override protected String getErrorMessage(IStatus[] failures, int totalOperations) { return CVSUIMessages.UpdateAction_update; } - - @Override + + @Override protected ResourceMappingContext getResourceMappingContext() { - return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); - } + return SubscriberResourceMappingContext.createContext(CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber()); + } public CVSTag getTag() { return tag; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java index e57e8454d..e96513200 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java @@ -70,7 +70,7 @@ public class WorkspaceFileDiffOperation extends FileDiffOperation { tempFile.delete(); } } - } + } } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceResourceMapper.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceResourceMapper.java index 4cacf52ec..2ba9ce323 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceResourceMapper.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceResourceMapper.java @@ -33,49 +33,49 @@ import org.eclipse.core.runtime.IProgressMonitor; * @since 3.1 */ public final class WorkspaceResourceMapper extends ResourceMapping { - - private final IResource resource; - private final int depth; - - /** - * Convert the provided resources to one or more resource mappers - * that traverse the elements deeply. The model element of the resource - * mappers will be the workspace root. - * @param resources the resources - * @return a resource mappers that traverses the resources - */ - public static ResourceMapping[] asResourceMappers(final IResource[] resources, int depth) { + + private final IResource resource; + private final int depth; + + /** + * Convert the provided resources to one or more resource mappers + * that traverse the elements deeply. The model element of the resource + * mappers will be the workspace root. + * @param resources the resources + * @return a resource mappers that traverses the resources + */ + public static ResourceMapping[] asResourceMappers(final IResource[] resources, int depth) { List<WorkspaceResourceMapper> result = new ArrayList<>(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - result.add(new WorkspaceResourceMapper(resource, depth)); - } - return result.toArray(new ResourceMapping[result.size()]); - } - - public WorkspaceResourceMapper(IResource resource, int depth) { - this.resource = resource; - this.depth = depth; - } - @Override + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + result.add(new WorkspaceResourceMapper(resource, depth)); + } + return result.toArray(new ResourceMapping[result.size()]); + } + + public WorkspaceResourceMapper(IResource resource, int depth) { + this.resource = resource; + this.depth = depth; + } + @Override public Object getModelObject() { - return resource; - } - @Override + return resource; + } + @Override public IProject[] getProjects() { - return new IProject[] { resource.getProject() }; - } - @Override + return new IProject[] { resource.getProject() }; + } + @Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { - return asTraversal(resource, depth, context); - } - private ResourceTraversal[] asTraversal(IResource resource, final int depth, ResourceMappingContext context) { - return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { resource }, depth, IResource.NONE)} ; - } - @Override + return asTraversal(resource, depth, context); + } + private ResourceTraversal[] asTraversal(IResource resource, final int depth, ResourceMappingContext context) { + return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { resource }, depth, IResource.NONE)} ; + } + @Override public boolean contains(ResourceMapping mapping) { - return false; - } + return false; + } @Override public String getModelProviderId() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java index ff5318b85..ff40e8262 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/CVSRepositoryPropertiesPage.java @@ -170,8 +170,8 @@ public class CVSRepositoryPropertiesPage extends PropertyPage { useCustomPort.addListener(SWT.Selection, connectionInfoChangedListener); pathText.addListener(SWT.Modify, connectionInfoChangedListener); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.REPOSITORY_LOCATION_PROPERTY_PAGE); - Dialog.applyDialogFont(parent); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.REPOSITORY_LOCATION_PROPERTY_PAGE); + Dialog.applyDialogFont(parent); return composite; } @@ -352,7 +352,7 @@ public class CVSRepositoryPropertiesPage extends PropertyPage { } final boolean[] result = new boolean[] { false }; final ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); - progressMonitorDialog.run(false, false, new WorkspaceModifyOperation(null) { + progressMonitorDialog.run(false, false, new WorkspaceModifyOperation(null) { @Override public void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { @@ -376,7 +376,7 @@ public class CVSRepositoryPropertiesPage extends PropertyPage { if (projects.size() > 0) { // To do: warn the user DetailsDialogWithProjects dialog = new DetailsDialogWithProjects( - progressMonitorDialog.getShell(), + progressMonitorDialog.getShell(), CVSUIMessages.CVSRepositoryPropertiesPage_Confirm_Project_Sharing_Changes_1, CVSUIMessages.CVSRepositoryPropertiesPage_There_are_projects_in_the_workspace_shared_with_this_repository_2, NLS.bind(CVSUIMessages.CVSRepositoryPropertiesPage_sharedProject, new String[] { location.toString() }), diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java index 57015f8e7..ce5df81d7 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectSelectionPage.java @@ -39,7 +39,7 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; * refreshed. */ public class RefreshRemoteProjectSelectionPage extends CVSWizardPage { - + private ICVSRemoteResource[] rootFolders; private ListSelectionArea listArea; private WorkingSetSelectionArea workingSetArea; @@ -102,7 +102,7 @@ public class RefreshRemoteProjectSelectionPage extends CVSWizardPage { setControl(composite); // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.REFRESH_REMOTE_PROJECT_SELECTION_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.REFRESH_REMOTE_PROJECT_SELECTION_PAGE); listArea = new ListSelectionArea( new InputElement(), @@ -129,7 +129,7 @@ public class RefreshRemoteProjectSelectionPage extends CVSWizardPage { } }); workingSetArea.createArea(composite); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); } /** diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java index 5677462a3..b6b56db1c 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RefreshRemoteProjectWizard.java @@ -35,11 +35,11 @@ import org.eclipse.team.internal.ccvs.ui.Policy; * Wizard for refreshing the tags for a CVS repository location */ public class RefreshRemoteProjectWizard extends Wizard { - - // The initial size of this wizard. - private final static int INITIAL_WIDTH = 300; - private final static int INITIAL_HEIGHT = 350; - + + // The initial size of this wizard. + private final static int INITIAL_WIDTH = 300; + private final static int INITIAL_HEIGHT = 350; + private ICVSRepositoryLocation root; private ICVSRemoteResource[] rootFolders; private RefreshRemoteProjectSelectionPage projectSelectionPage; @@ -128,27 +128,27 @@ public class RefreshRemoteProjectWizard extends Wizard { /* * Refresh the tags of the given resources and return those for which no tags were found. */ - private ICVSRemoteResource[] internalRefresh(final RepositoryManager manager, final ICVSRemoteResource[] selectedFolders, final boolean recurse, IProgressMonitor monitor) throws InvocationTargetException { - List failedFolders = new ArrayList(); - monitor.beginTask(null, 100 * selectedFolders.length); - for (int i = 0; i < selectedFolders.length; i++) { - try { + private ICVSRemoteResource[] internalRefresh(final RepositoryManager manager, final ICVSRemoteResource[] selectedFolders, final boolean recurse, IProgressMonitor monitor) throws InvocationTargetException { + List failedFolders = new ArrayList(); + monitor.beginTask(null, 100 * selectedFolders.length); + for (int i = 0; i < selectedFolders.length; i++) { + try { ICVSRemoteResource resource = selectedFolders[i]; if (resource instanceof ICVSFolder) { CVSTag[] tags = manager.refreshDefinedTags((ICVSFolder)resource, recurse, true /* notify */, Policy.subMonitorFor(monitor, 100)); if (tags.length == 0) { - failedFolders.add(resource); + failedFolders.add(resource); } } } catch (TeamException e) { CVSUIPlugin.log(IStatus.ERROR, NLS.bind("An error occurred while fetching the tags for {0}", selectedFolders[i].getName()), e); //$NON-NLS-1$ } - } - return (ICVSRemoteResource[]) failedFolders.toArray(new ICVSRemoteResource[failedFolders.size()]); - } + } + return (ICVSRemoteResource[]) failedFolders.toArray(new ICVSRemoteResource[failedFolders.size()]); + } - private boolean promptForDeepRefresh(final ICVSRemoteResource[] folders) { - final boolean[] prompt = new boolean[] { false }; + private boolean promptForDeepRefresh(final ICVSRemoteResource[] folders) { + final boolean[] prompt = new boolean[] { false }; getShell().getDisplay().syncExec(() -> { MessageDialog dialog = new MessageDialog(getShell(), CVSUIMessages.RefreshRemoteProjectWizard_0, null, getNoTagsMessage(folders), MessageDialog.INFORMATION, new String[] { @@ -160,13 +160,13 @@ public class RefreshRemoteProjectWizard extends Wizard { } }); - return prompt[0]; - } + return prompt[0]; + } - private String getNoTagsMessage(ICVSRemoteResource[] folders) { - if (folders.length == 1) { - return NLS.bind(CVSUIMessages.RefreshRemoteProjectWizard_3, new String[] { folders[0].getRepositoryRelativePath() }); - } - return NLS.bind(CVSUIMessages.RefreshRemoteProjectWizard_4, new String[] { Integer.toString(folders.length) }); - } + private String getNoTagsMessage(ICVSRemoteResource[] folders) { + if (folders.length == 1) { + return NLS.bind(CVSUIMessages.RefreshRemoteProjectWizard_3, new String[] { folders[0].getRepositoryRelativePath() }); + } + return NLS.bind(CVSUIMessages.RefreshRemoteProjectWizard_4, new String[] { Integer.toString(folders.length) }); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java index 204e49302..6bdd97b72 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoteViewPart.java @@ -96,7 +96,7 @@ public abstract class RemoteViewPart extends ViewPart implements ISelectionListe // F1 Help String helpID = getHelpContextId(); if (helpID != null) - PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), helpID); + PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), helpID); } @Override @@ -233,23 +233,23 @@ public abstract class RemoteViewPart extends ViewPart implements ISelectionListe bars.updateActionBars(); } - /** - * Returns the action group. - * - * @return the action group - */ - private WorkingSetFilterActionGroup getWorkingSetActionGroup() { - return workingSetActionGroup; - } + /** + * Returns the action group. + * + * @return the action group + */ + private WorkingSetFilterActionGroup getWorkingSetActionGroup() { + return workingSetActionGroup; + } - /** - * Sets the action group. - * - * @param actionGroup the action group - */ - private void setActionGroup(WorkingSetFilterActionGroup actionGroup) { - this.workingSetActionGroup = actionGroup; - } + /** + * Sets the action group. + * + * @param actionGroup the action group + */ + private void setActionGroup(WorkingSetFilterActionGroup actionGroup) { + this.workingSetActionGroup = actionGroup; + } /** * Add the menu actions that were contributed in plugin.xml @@ -286,9 +286,9 @@ public abstract class RemoteViewPart extends ViewPart implements ISelectionListe ((RemoteContentProvider)viewer.getContentProvider()).cancelJobs(CVSUIPlugin.getPlugin().getRepositoryManager().getKnownRepositoryRoots()); ((RemoteContentProvider)viewer.getContentProvider()).purgeCache(); CVSUIPlugin.getPlugin().getRepositoryManager().purgeCache(); - viewer.getControl().setRedraw(false); + viewer.getControl().setRedraw(false); viewer.refresh(); - viewer.getControl().setRedraw(true); + viewer.getControl().setRedraw(true); } public void collapseAll() { @@ -334,9 +334,9 @@ public abstract class RemoteViewPart extends ViewPart implements ISelectionListe @Override public void dispose() { getSite().getWorkbenchWindow().getSelectionService().removePostSelectionListener(this); - if (getWorkingSetActionGroup() != null) { - getWorkingSetActionGroup().dispose(); - } + if (getWorkingSetActionGroup() != null) { + getWorkingSetActionGroup().dispose(); + } super.dispose(); viewer = null; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java index ac21a7266..6b0ad1e5c 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java @@ -88,57 +88,57 @@ public class RepositoriesView extends RemoteViewPart { display.asyncExec(() -> RepositoriesView.this.refreshViewer()); } }; - - private static final class RepositoryDragSourceListener implements DragSourceListener { - private IStructuredSelection selection; + + private static final class RepositoryDragSourceListener implements DragSourceListener { + private IStructuredSelection selection; - @Override + @Override public void dragStart(DragSourceEvent event) { - if(selection!=null) { - final Object[] array = selection.toArray(); - // event.doit = Utils.getResources(array).length > 0; - for (int i = 0; i < array.length; i++) { - if (array[i] instanceof ICVSRemoteFile) { - event.doit = true; - return; - } - } - event.doit = false; - } - } + if(selection!=null) { + final Object[] array = selection.toArray(); + // event.doit = Utils.getResources(array).length > 0; + for (int i = 0; i < array.length; i++) { + if (array[i] instanceof ICVSRemoteFile) { + event.doit = true; + return; + } + } + event.doit = false; + } + } - @Override + @Override public void dragSetData(DragSourceEvent event) { - if (selection!=null && CVSResourceTransfer.getInstance().isSupportedType(event.dataType)) { - final Object[] array = selection.toArray(); - for (int i = 0; i < array.length; i++) { - if (array[i] instanceof ICVSRemoteFile) { - event.data = array[i]; - return; - } - } - } else if (PluginTransfer.getInstance().isSupportedType(event.dataType)) { - final Object[] array = selection.toArray(); - for (int i = 0; i < array.length; i++) { - if (array[i] instanceof ICVSRemoteFile) { - event.data = new PluginTransferData("org.eclipse.team.cvs.ui.cvsRemoteDrop", CVSResourceTransfer.getInstance().toByteArray((ICVSRemoteFile) array[i])); //$NON-NLS-1$ - return; - } - } - - } - } - - @Override + if (selection!=null && CVSResourceTransfer.getInstance().isSupportedType(event.dataType)) { + final Object[] array = selection.toArray(); + for (int i = 0; i < array.length; i++) { + if (array[i] instanceof ICVSRemoteFile) { + event.data = array[i]; + return; + } + } + } else if (PluginTransfer.getInstance().isSupportedType(event.dataType)) { + final Object[] array = selection.toArray(); + for (int i = 0; i < array.length; i++) { + if (array[i] instanceof ICVSRemoteFile) { + event.data = new PluginTransferData("org.eclipse.team.cvs.ui.cvsRemoteDrop", CVSResourceTransfer.getInstance().toByteArray((ICVSRemoteFile) array[i])); //$NON-NLS-1$ + return; + } + } + + } + } + + @Override public void dragFinished( DragSourceEvent event) { - } + } - public void updateSelection( IStructuredSelection selection) { - this.selection = selection; - } - } - - RepositoryDragSourceListener repositoryDragSourceListener; + public void updateSelection( IStructuredSelection selection) { + this.selection = selection; + } + } + + RepositoryDragSourceListener repositoryDragSourceListener; /** * Constructor for RepositoriesView. @@ -190,7 +190,7 @@ public class RepositoriesView extends RemoteViewPart { dialog.open(); } }; - PlatformUI.getWorkbench().getHelpSystem().setHelp(newAction, IHelpContextIds.NEW_REPOSITORY_LOCATION_ACTION); + PlatformUI.getWorkbench().getHelpSystem().setHelp(newAction, IHelpContextIds.NEW_REPOSITORY_LOCATION_ACTION); if (includeAnonConnection()) { newAnonAction = new Action(CVSUIMessages.RepositoriesView_newAnonCVS, CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_NEWLOCATION)) { @@ -207,7 +207,7 @@ public class RepositoriesView extends RemoteViewPart { dialog.open(); } }; - PlatformUI.getWorkbench().getHelpSystem().setHelp(newAnonAction, IHelpContextIds.NEW_DEV_ECLIPSE_REPOSITORY_LOCATION_ACTION); + PlatformUI.getWorkbench().getHelpSystem().setHelp(newAnonAction, IHelpContextIds.NEW_DEV_ECLIPSE_REPOSITORY_LOCATION_ACTION); } // Properties @@ -239,22 +239,22 @@ public class RepositoriesView extends RemoteViewPart { } } }; - PlatformUI.getWorkbench().getHelpSystem().setHelp(removeRootAction, IHelpContextIds.REMOVE_REPOSITORY_LOCATION_ACTION); + PlatformUI.getWorkbench().getHelpSystem().setHelp(removeRootAction, IHelpContextIds.REMOVE_REPOSITORY_LOCATION_ACTION); IActionBars bars = getViewSite().getActionBars(); bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), removeAction); // Sort By action group IPropertyChangeListener comparatorUpdater = event -> { - String property = event.getProperty(); - if (RepositoriesSortingActionGroup.CHANGE_COMPARATOR - .equals(property)) { - Object newValue = event.getNewValue(); - getViewer().refresh(); - saveSelectedComparator((RepositoryComparator) newValue); - } + String property = event.getProperty(); + if (RepositoriesSortingActionGroup.CHANGE_COMPARATOR + .equals(property)) { + Object newValue = event.getNewValue(); + getViewer().refresh(); + saveSelectedComparator((RepositoryComparator) newValue); + } }; - setActionGroup(new RepositoriesSortingActionGroup(shell, - comparatorUpdater)); + setActionGroup(new RepositoriesSortingActionGroup(shell, + comparatorUpdater)); // restore comparator selection getRepositoriesSortingActionGroup().setSelectedComparator( savedComparator); @@ -296,23 +296,23 @@ public class RepositoriesView extends RemoteViewPart { } } - /** - * Returns the action group. - * - * @return the action group - */ - private RepositoriesSortingActionGroup getRepositoriesSortingActionGroup() { - return repositoriesSortingActionGroup; - } + /** + * Returns the action group. + * + * @return the action group + */ + private RepositoriesSortingActionGroup getRepositoriesSortingActionGroup() { + return repositoriesSortingActionGroup; + } - /** - * Sets the action group. - * - * @param actionGroup the action group - */ - private void setActionGroup(RepositoriesSortingActionGroup actionGroup) { - this.repositoriesSortingActionGroup = actionGroup; - } + /** + * Sets the action group. + * + * @param actionGroup the action group + */ + private void setActionGroup(RepositoriesSortingActionGroup actionGroup) { + this.repositoriesSortingActionGroup = actionGroup; + } /** * Method includeEclipseConnection. @@ -367,9 +367,9 @@ public class RepositoriesView extends RemoteViewPart { else dialogSettings.put(FILTER_SHOW_MODULES, (String) null); CVSUIPlugin.getPlugin().getRepositoryManager().removeRepositoryListener(listener); - if (getRepositoriesSortingActionGroup() != null) { - getRepositoriesSortingActionGroup().dispose(); - } + if (getRepositoriesSortingActionGroup() != null) { + getRepositoriesSortingActionGroup().dispose(); + } super.dispose(); } @@ -389,11 +389,11 @@ public class RepositoriesView extends RemoteViewPart { IStructuredSelection selection = (IStructuredSelection)event.getSelection(); handleChange(selection); }); - - repositoryDragSourceListener = new RepositoryDragSourceListener(); - viewer.addDragSupport( DND.DROP_LINK | DND.DROP_DEFAULT, - new Transfer[] { CVSResourceTransfer.getInstance(),PluginTransfer.getInstance()}, - repositoryDragSourceListener); + + repositoryDragSourceListener = new RepositoryDragSourceListener(); + viewer.addDragSupport( DND.DROP_LINK | DND.DROP_DEFAULT, + new Transfer[] { CVSResourceTransfer.getInstance(),PluginTransfer.getInstance()}, + repositoryDragSourceListener); } @Override @@ -414,7 +414,7 @@ public class RepositoriesView extends RemoteViewPart { IStructuredSelection s = (IStructuredSelection)selection; if (s.size() > 1) - return NLS.bind(CVSUIMessages.RepositoriesView_NItemsSelected, new String[] { String.valueOf(s.size()) }); + return NLS.bind(CVSUIMessages.RepositoriesView_NItemsSelected, new String[] { String.valueOf(s.size()) }); Object element = TeamAction.getAdapter(s.getFirstElement(), ICVSResource.class); if (element instanceof ICVSRemoteResource) { ICVSRemoteResource res = (ICVSRemoteResource)element; @@ -464,8 +464,8 @@ public class RepositoriesView extends RemoteViewPart { removeRootAction.updateSelection(selection); removeDateTagAction.updateSelection(selection); removeAction.setEnabled(removeRootAction.isEnabled() || removeDateTagAction.isEnabled()); - - repositoryDragSourceListener.updateSelection(selection); + + repositoryDragSourceListener.updateSelection(selection); } public void showFilter(RepositoriesFilter filter) { @@ -475,5 +475,5 @@ public class RepositoriesView extends RemoteViewPart { getViewer().addFilter(filter); toggleFilterAction.setEnabled(true); } - + } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java index 063302a89..145c0539c 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesViewContentHandler.java @@ -60,7 +60,7 @@ public class RepositoriesViewContentHandler extends DefaultHandler { private List autoRefreshFiles; private boolean ignoreElements; - private long lastAccessTime; + private long lastAccessTime; public RepositoriesViewContentHandler(RepositoryManager manager) { this.manager = manager; @@ -97,7 +97,7 @@ public class RepositoriesViewContentHandler extends DefaultHandler { currentRepositoryRoot.addTags(currentRemotePath, (CVSTag[]) tags.toArray(new CVSTag[tags.size()])); if (lastAccessTime > 0) - currentRepositoryRoot.setLastAccessedTime(currentRemotePath, lastAccessTime); + currentRepositoryRoot.setLastAccessedTime(currentRemotePath, lastAccessTime); currentRepositoryRoot.setAutoRefreshFiles(currentRemotePath, (String[]) autoRefreshFiles.toArray(new String[autoRefreshFiles.size()])); } @@ -171,12 +171,12 @@ public class RepositoriesViewContentHandler extends DefaultHandler { long cachedTime = 0; String cachedTimeString = atts.getValue(LAST_ACCESS_TIME_ATTRIBUTE); if (cachedTimeString != null) { - try { - Long time = Long.valueOf(cachedTimeString); - cachedTime = time.longValue(); - } catch (NumberFormatException e) { - // Ignore - } + try { + Long time = Long.valueOf(cachedTimeString); + cachedTime = time.longValue(); + } catch (NumberFormatException e) { + // Ignore + } } startModule(path, cachedTime); } else if (elementName.equals(TAG_TAG)) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java index 8abe42e71..b573eedd8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryEncodingPropertyPage.java @@ -300,7 +300,7 @@ public class RepositoryEncodingPropertyPage extends PropertyPage implements IPro pageLink.setLayoutData(label.getLayoutData()); pageLink.setText(CVSUIMessages.RepositoryEncodingPropertyPage_4); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.REPOSITORY_ENCODING_PROPERTY_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.REPOSITORY_ENCODING_PROPERTY_PAGE); Dialog.applyDialogFont(parent); return composite; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java index 29814778a..d37c958be 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java @@ -55,10 +55,10 @@ public class RepositoryManager { // new state file private static final String REPOSITORIES_VIEW_FILE = "repositoriesView.xml"; //$NON-NLS-1$ private static final String COMMENT_HIST_FILE = "commitCommentHistory.xml"; //$NON-NLS-1$ - private static final String COMMENT_TEMPLATES_FILE = "commentTemplates.xml"; //$NON-NLS-1$ + private static final String COMMENT_TEMPLATES_FILE = "commentTemplates.xml"; //$NON-NLS-1$ static final String ELEMENT_COMMIT_COMMENT = "CommitComment"; //$NON-NLS-1$ static final String ELEMENT_COMMIT_HISTORY = "CommitComments"; //$NON-NLS-1$ - static final String ELEMENT_COMMENT_TEMPLATES = "CommitCommentTemplates"; //$NON-NLS-1$ + static final String ELEMENT_COMMENT_TEMPLATES = "CommitCommentTemplates"; //$NON-NLS-1$ private Map<String, RepositoryRoot> repositoryRoots = new HashMap<>(); @@ -66,7 +66,7 @@ public class RepositoryManager { // The previously remembered comment static String[] previousComments = new String[0]; - static String[] commentTemplates = new String[0]; + static String[] commentTemplates = new String[0]; public static boolean notifyRepoView = true; @@ -375,7 +375,7 @@ public class RepositoryManager { public void startup() { loadState(); loadCommentHistory(); - loadCommentTemplates(); + loadCommentTemplates(); CVSProviderPlugin.getPlugin().addRepositoryListener(new ICVSListener() { @Override public void repositoryAdded(ICVSRepositoryLocation root) { @@ -406,7 +406,7 @@ public class RepositoryManager { public void shutdown() throws TeamException { saveState(); saveCommentHistory(); - saveCommentTemplates(); + saveCommentTemplates(); } private void loadState() { @@ -463,23 +463,23 @@ public class RepositoryManager { CVSUIPlugin.log(e); } } - private void loadCommentTemplates() { - IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation().append(COMMENT_TEMPLATES_FILE); - File file = pluginStateLocation.toFile(); - if (!file.exists()) return; - try { - BufferedInputStream is = new BufferedInputStream(new FileInputStream(file)); - try { - readCommentTemplates(is); - } finally { - is.close(); - } - } catch (IOException e) { - CVSUIPlugin.log(IStatus.ERROR, CVSUIMessages.RepositoryManager_ioException, e); - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } + private void loadCommentTemplates() { + IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation().append(COMMENT_TEMPLATES_FILE); + File file = pluginStateLocation.toFile(); + if (!file.exists()) return; + try { + BufferedInputStream is = new BufferedInputStream(new FileInputStream(file)); + try { + readCommentTemplates(is); + } finally { + is.close(); + } + } catch (IOException e) { + CVSUIPlugin.log(IStatus.ERROR, CVSUIMessages.RepositoryManager_ioException, e); + } catch (TeamException e) { + CVSUIPlugin.log(e); + } + } protected void saveState() throws TeamException { IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation(); @@ -608,22 +608,22 @@ public class RepositoryManager { File tempFile = pluginStateLocation.append(COMMENT_HIST_FILE + ".tmp").toFile(); //$NON-NLS-1$ File histFile = pluginStateLocation.append(COMMENT_HIST_FILE).toFile(); try { - XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(tempFile))); - try { - writeCommentHistory(writer); - } finally { - writer.close(); - } - if (histFile.exists()) { - histFile.delete(); - } - boolean renamed = tempFile.renameTo(histFile); - if (!renamed) { - throw new TeamException(new Status(IStatus.ERROR, CVSUIPlugin.ID, TeamException.UNABLE, NLS.bind(CVSUIMessages.RepositoryManager_rename, new String[] { tempFile.getAbsolutePath() }), null)); - } - } catch (IOException e) { - throw new TeamException(new Status(IStatus.ERROR, CVSUIPlugin.ID, TeamException.UNABLE, NLS.bind(CVSUIMessages.RepositoryManager_save, new String[] { histFile.getAbsolutePath() }), e)); - } + XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(tempFile))); + try { + writeCommentHistory(writer); + } finally { + writer.close(); + } + if (histFile.exists()) { + histFile.delete(); + } + boolean renamed = tempFile.renameTo(histFile); + if (!renamed) { + throw new TeamException(new Status(IStatus.ERROR, CVSUIPlugin.ID, TeamException.UNABLE, NLS.bind(CVSUIMessages.RepositoryManager_rename, new String[] { tempFile.getAbsolutePath() }), null)); + } + } catch (IOException e) { + throw new TeamException(new Status(IStatus.ERROR, CVSUIPlugin.ID, TeamException.UNABLE, NLS.bind(CVSUIMessages.RepositoryManager_save, new String[] { histFile.getAbsolutePath() }), e)); + } } private void writeCommentHistory(XMLWriter writer) { writer.startTag(ELEMENT_COMMIT_HISTORY, null, false); @@ -631,7 +631,7 @@ public class RepositoryManager { writer.printSimpleTag(ELEMENT_COMMIT_COMMENT, previousComments[i]); writer.endTag(ELEMENT_COMMIT_HISTORY); } - + public void addRepositoryListener(IRepositoryListener listener) { listeners.add(listener); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java index e1e4bc53d..fb73fefcc 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java @@ -74,14 +74,14 @@ public class RepositoryRoot extends PlatformObject { return getTags().isEmpty() && children.isEmpty(); } - public boolean isExpired() { - long currentTime = System.currentTimeMillis(); - long ms = currentTime - lastAccessTime; - int seconds = (int)ms / 1000; - int hours = seconds / 60 / 60; - int days = hours / 24; - return days > CACHE_LIFESPAN_IN_DAYS; - } + public boolean isExpired() { + long currentTime = System.currentTimeMillis(); + long ms = currentTime - lastAccessTime; + int seconds = (int)ms / 1000; + int hours = seconds / 60 / 60; + int days = hours / 24; + return days > CACHE_LIFESPAN_IN_DAYS; + } private void accessed() { lastAccessTime = System.currentTimeMillis(); @@ -421,50 +421,50 @@ public class RepositoryRoot extends PlatformObject { } } - private CVSTag[] fetchTagsUsingLog(ICVSFolder folder, IProgressMonitor monitor) throws CVSException { - LogEntryCache logEntries = new LogEntryCache(); - RemoteLogOperation operation = new RemoteLogOperation(null, new ICVSRemoteResource[] { asRemoteResource(folder) }, null, null, logEntries) { - @Override + private CVSTag[] fetchTagsUsingLog(ICVSFolder folder, IProgressMonitor monitor) throws CVSException { + LogEntryCache logEntries = new LogEntryCache(); + RemoteLogOperation operation = new RemoteLogOperation(null, new ICVSRemoteResource[] { asRemoteResource(folder) }, null, null, logEntries) { + @Override protected Command.LocalOption[] getLocalOptions(CVSTag tag1,CVSTag tag2) { - Command.LocalOption[] options = new Command.LocalOption[] {}; - Command.LocalOption[] newOptions = new Command.LocalOption[options.length + 1]; - System.arraycopy(options, 0, newOptions, 0, options.length); - newOptions[options.length] = Command.DO_NOT_RECURSE; - return newOptions; - } - }; - try { - operation.run(monitor); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - // Ignore; - } - String[] keys = logEntries.getCachedFilePaths(); + Command.LocalOption[] options = new Command.LocalOption[] {}; + Command.LocalOption[] newOptions = new Command.LocalOption[options.length + 1]; + System.arraycopy(options, 0, newOptions, 0, options.length); + newOptions[options.length] = Command.DO_NOT_RECURSE; + return newOptions; + } + }; + try { + operation.run(monitor); + } catch (InvocationTargetException e) { + throw CVSException.wrapException(e); + } catch (InterruptedException e) { + // Ignore; + } + String[] keys = logEntries.getCachedFilePaths(); Set<CVSTag> tags = new HashSet<>(); - for (int i = 0; i < keys.length; i++) { - String key = keys[i]; - ILogEntry[] entries = logEntries.getLogEntries(key); - for (int j = 0; j < entries.length; j++) { - ILogEntry entry = entries[j]; - tags.addAll(Arrays.asList(entry.getTags())); - } - } - return tags.toArray(new CVSTag[tags.size()]); - } - - private ICVSRemoteResource asRemoteResource(ICVSFolder folder) throws CVSException { - if (folder instanceof ICVSRemoteResource) { - return (ICVSRemoteResource)folder; - } - return CVSWorkspaceRoot.getRemoteResourceFor(folder); - } - - /** + for (int i = 0; i < keys.length; i++) { + String key = keys[i]; + ILogEntry[] entries = logEntries.getLogEntries(key); + for (int j = 0; j < entries.length; j++) { + ILogEntry entry = entries[j]; + tags.addAll(Arrays.asList(entry.getTags())); + } + } + return tags.toArray(new CVSTag[tags.size()]); + } + + private ICVSRemoteResource asRemoteResource(ICVSFolder folder) throws CVSException { + if (folder instanceof ICVSRemoteResource) { + return (ICVSRemoteResource)folder; + } + return CVSWorkspaceRoot.getRemoteResourceFor(folder); + } + + /** * Fetches tags from auto-refresh files. */ private CVSTag[] fetchTagsUsingAutoRefreshFiles(ICVSFolder folder, IProgressMonitor monitor) throws TeamException { - String remotePath = getRemotePathFor(folder); + String remotePath = getRemotePathFor(folder); String[] filesToRefresh = getAutoRefreshFiles(remotePath); try { monitor.beginTask(null, filesToRefresh.length * 10); @@ -472,21 +472,21 @@ public class RepositoryRoot extends PlatformObject { for (int i = 0; i < filesToRefresh.length; i++) { ICVSRemoteFile file = root.getRemoteFile(filesToRefresh[i], CVSTag.DEFAULT); try { - tags.addAll(Arrays.asList(fetchTags(file, Policy.subMonitorFor(monitor, 5)))); - } catch (TeamException e) { - IStatus status = e.getStatus(); - boolean doesNotExist = false; - if (status.getCode() == CVSStatus.SERVER_ERROR && status.isMultiStatus()) { - IStatus[] children = status.getChildren(); - if (children.length == 1 && children[0].getCode() == CVSStatus.DOES_NOT_EXIST) { - // Don't throw an exception if the file does no exist - doesNotExist = true; - } - } - if (!doesNotExist) { - throw e; - } - } + tags.addAll(Arrays.asList(fetchTags(file, Policy.subMonitorFor(monitor, 5)))); + } catch (TeamException e) { + IStatus status = e.getStatus(); + boolean doesNotExist = false; + if (status.getCode() == CVSStatus.SERVER_ERROR && status.isMultiStatus()) { + IStatus[] children = status.getChildren(); + if (children.length == 1 && children[0].getCode() == CVSStatus.DOES_NOT_EXIST) { + // Don't throw an exception if the file does no exist + doesNotExist = true; + } + } + if (!doesNotExist) { + throw e; + } + } } return tags.toArray(new CVSTag[tags.size()]); } finally { @@ -634,7 +634,7 @@ public class RepositoryRoot extends PlatformObject { TagCacheEntry entry = getTagCacheEntryFor(path, false); boolean writeOutTags = entry != null && !entry.isExpired(); if (writeOutTags) - attributes.put(RepositoriesViewContentHandler.LAST_ACCESS_TIME_ATTRIBUTE, Long.toString(entry.lastAccessTime)); + attributes.put(RepositoriesViewContentHandler.LAST_ACCESS_TIME_ATTRIBUTE, Long.toString(entry.lastAccessTime)); writer.startTag(RepositoriesViewContentHandler.MODULE_TAG, attributes, true); if (writeOutTags) { Iterator tagIt = entry.getTags().iterator(); @@ -658,7 +658,7 @@ public class RepositoryRoot extends PlatformObject { writer.endTag(RepositoriesViewContentHandler.REPOSITORY_TAG); } - private void writeATag(XMLWriter writer, HashMap attributes, CVSTag tag, String s) { + private void writeATag(XMLWriter writer, HashMap attributes, CVSTag tag, String s) { attributes.clear(); attributes.put(RepositoriesViewContentHandler.NAME_ATTRIBUTE, tag.getName()); attributes.put(RepositoriesViewContentHandler.TYPE_ATTRIBUTE, RepositoriesViewContentHandler.TAG_TYPES[tag.getType()]); @@ -788,15 +788,15 @@ public class RepositoryRoot extends PlatformObject { this.root = root; } - /* - * Set the last access time of the cache entry for the given path - * as it was read from the persistent store. - */ - /* package */ void setLastAccessedTime(String remotePath, long lastAccessTime) { + /* + * Set the last access time of the cache entry for the given path + * as it was read from the persistent store. + */ + /* package */ void setLastAccessedTime(String remotePath, long lastAccessTime) { TagCacheEntry entry = getTagCacheEntryFor(remotePath, false); if(entry != null){ - entry.lastAccessTime = lastAccessTime; + entry.lastAccessTime = lastAccessTime; } - } + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java index d8ed0894d..f20fa53e8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetActionGroup.java @@ -22,8 +22,8 @@ import org.eclipse.team.ui.synchronize.*; */ public class CVSChangeSetActionGroup extends SynchronizePageActionGroup { - private OpenChangeSetAction openCommitSet; - + private OpenChangeSetAction openCommitSet; + @Override public void initialize(ISynchronizePageConfiguration configuration) { super.initialize(configuration); @@ -31,15 +31,15 @@ public class CVSChangeSetActionGroup extends SynchronizePageActionGroup { } @Override - public void fillContextMenu(IMenuManager menu) { - ISynchronizeParticipant participant = getConfiguration().getParticipant(); - if (participant instanceof IChangeSetProvider) { - if (((IChangeSetProvider)participant).getChangeSetCapability().enableCheckedInChangeSetsFor(getConfiguration())) { - appendToGroup( - menu, - ISynchronizePageConfiguration.FILE_GROUP, - openCommitSet); - } - } - } + public void fillContextMenu(IMenuManager menu) { + ISynchronizeParticipant participant = getConfiguration().getParticipant(); + if (participant instanceof IChangeSetProvider) { + if (((IChangeSetProvider)participant).getChangeSetCapability().enableCheckedInChangeSetsFor(getConfiguration())) { + appendToGroup( + menu, + ISynchronizePageConfiguration.FILE_GROUP, + openCommitSet); + } + } + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java index c115f6a5c..de3018981 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCapability.java @@ -24,27 +24,27 @@ import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; public class CVSChangeSetCapability extends ChangeSetCapability { @Override - public boolean supportsCheckedInChangeSets() { - return true; - } + public boolean supportsCheckedInChangeSets() { + return true; + } @Override - public boolean supportsActiveChangeSets() { - return getActiveChangeSetManager() != null; - } + public boolean supportsActiveChangeSets() { + return getActiveChangeSetManager() != null; + } @Override - public SyncInfoSetChangeSetCollector createSyncInfoSetChangeSetCollector(ISynchronizePageConfiguration configuration) { - return new CVSChangeSetCollector(configuration); - } - + public SyncInfoSetChangeSetCollector createSyncInfoSetChangeSetCollector(ISynchronizePageConfiguration configuration) { + return new CVSChangeSetCollector(configuration); + } + @Override - public SynchronizePageActionGroup getActionGroup() { - return new CVSChangeSetActionGroup(); - } - + public SynchronizePageActionGroup getActionGroup() { + return new CVSChangeSetActionGroup(); + } + @Override - public boolean enableChangeSetsByDefault() { - return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT); - } + public boolean enableChangeSetsByDefault() { + return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_COMMIT_SET_DEFAULT_ENABLEMENT); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java index b2a1537c6..a4234e41a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSChangeSetCollector.java @@ -46,24 +46,24 @@ import com.ibm.icu.text.DateFormat; */ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector implements LogEntryCacheUpdateHandler.ILogsFetchedListener { - /* - * Constant used to add the collector to the configuration of a page so - * it can be accessed by the CVS custom actions - */ - public static final String CVS_CHECKED_IN_COLLECTOR = CVSUIPlugin.ID + ".CVSCheckedInCollector"; //$NON-NLS-1$ - - /* - * Constant used to store the log entry handler in the configuration so it can - * be kept around over layout changes - */ - private static final String LOG_ENTRY_HANDLER = CVSUIPlugin.ID + ".LogEntryHandler"; //$NON-NLS-1$ - - private static final String DEFAULT_INCOMING_SET_NAME = CVSUIMessages.CVSChangeSetCollector_0; - - boolean disposed = false; + /* + * Constant used to add the collector to the configuration of a page so + * it can be accessed by the CVS custom actions + */ + public static final String CVS_CHECKED_IN_COLLECTOR = CVSUIPlugin.ID + ".CVSCheckedInCollector"; //$NON-NLS-1$ + + /* + * Constant used to store the log entry handler in the configuration so it can + * be kept around over layout changes + */ + private static final String LOG_ENTRY_HANDLER = CVSUIPlugin.ID + ".LogEntryHandler"; //$NON-NLS-1$ + + private static final String DEFAULT_INCOMING_SET_NAME = CVSUIMessages.CVSChangeSetCollector_0; + + boolean disposed = false; - private LogEntryCache logEntryCache; - + private LogEntryCache logEntryCache; + /* ***************************************************************************** * Special sync info that has its kind already calculated. */ @@ -82,125 +82,125 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme private class DefaultCheckedInChangeSet extends CheckedInChangeSet { - private Date date = new Date(); - - public DefaultCheckedInChangeSet(String name) { - setName(name); - } - @Override + private Date date = new Date(); + + public DefaultCheckedInChangeSet(String name) { + setName(name); + } + @Override public String getAuthor() { - return ""; //$NON-NLS-1$ - } + return ""; //$NON-NLS-1$ + } - @Override + @Override public Date getDate() { - return date; - } + return date; + } - @Override + @Override public String getComment() { - return ""; //$NON-NLS-1$ - } - + return ""; //$NON-NLS-1$ + } + } private class CVSCheckedInChangeSet extends CheckedInChangeSet { - private final ILogEntry entry; + private final ILogEntry entry; - public CVSCheckedInChangeSet(ILogEntry entry) { - this.entry = entry; - Date date = entry.getDate(); - String comment = Util.flattenText(entry.getComment()); - if (date == null) { - setName("["+entry.getAuthor()+ "] " + comment); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - String dateString = DateFormat.getDateTimeInstance().format(date); - setName("["+entry.getAuthor()+ "] (" + dateString +") " + comment); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - } - - @Override + public CVSCheckedInChangeSet(ILogEntry entry) { + this.entry = entry; + Date date = entry.getDate(); + String comment = Util.flattenText(entry.getComment()); + if (date == null) { + setName("["+entry.getAuthor()+ "] " + comment); //$NON-NLS-1$ //$NON-NLS-2$ + } else { + String dateString = DateFormat.getDateTimeInstance().format(date); + setName("["+entry.getAuthor()+ "] (" + dateString +") " + comment); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + } + + @Override public String getAuthor() { - return entry.getAuthor(); - } + return entry.getAuthor(); + } - @Override + @Override public Date getDate() { - return entry.getDate(); - } + return entry.getDate(); + } - @Override + @Override public String getComment() { - return entry.getComment(); - } + return entry.getComment(); + } } - public CVSChangeSetCollector(ISynchronizePageConfiguration configuration) { - super(configuration); - configuration.setProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR, this); - } + public CVSChangeSetCollector(ISynchronizePageConfiguration configuration) { + super(configuration); + configuration.setProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR, this); + } - public synchronized LogEntryCacheUpdateHandler getLogEntryHandler() { - LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)getConfiguration().getProperty(LOG_ENTRY_HANDLER); - if (handler == null) { - handler = initializeLogEntryHandler(getConfiguration()); - } - handler.setListener(this); - return handler; - } - - /* - * Initialize the log entry handler and place it in the configuration - */ - private LogEntryCacheUpdateHandler initializeLogEntryHandler(final ISynchronizePageConfiguration configuration) { - final LogEntryCacheUpdateHandler logEntryHandler = new LogEntryCacheUpdateHandler(configuration); - configuration.setProperty(LOG_ENTRY_HANDLER, logEntryHandler); - // Use an action group to get notified when the configuration is disposed - configuration.addActionContribution(new SynchronizePageActionGroup() { - @Override + public synchronized LogEntryCacheUpdateHandler getLogEntryHandler() { + LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)getConfiguration().getProperty(LOG_ENTRY_HANDLER); + if (handler == null) { + handler = initializeLogEntryHandler(getConfiguration()); + } + handler.setListener(this); + return handler; + } + + /* + * Initialize the log entry handler and place it in the configuration + */ + private LogEntryCacheUpdateHandler initializeLogEntryHandler(final ISynchronizePageConfiguration configuration) { + final LogEntryCacheUpdateHandler logEntryHandler = new LogEntryCacheUpdateHandler(configuration); + configuration.setProperty(LOG_ENTRY_HANDLER, logEntryHandler); + // Use an action group to get notified when the configuration is disposed + configuration.addActionContribution(new SynchronizePageActionGroup() { + @Override public void dispose() { - super.dispose(); - LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)configuration.getProperty(LOG_ENTRY_HANDLER); - if (handler != null) { - handler.shutdown(); - configuration.setProperty(LOG_ENTRY_HANDLER, null); - } - } - }); - // It is possible that the configuration has been disposed concurrently by another thread - // TODO - return logEntryHandler; - } + super.dispose(); + LogEntryCacheUpdateHandler handler = (LogEntryCacheUpdateHandler)configuration.getProperty(LOG_ENTRY_HANDLER); + if (handler != null) { + handler.shutdown(); + configuration.setProperty(LOG_ENTRY_HANDLER, null); + } + } + }); + // It is possible that the configuration has been disposed concurrently by another thread + // TODO + return logEntryHandler; + } - @Override + @Override protected void add(SyncInfo[] infos) { - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) - try { - handler.fetch(infos); - } catch (CVSException e) { - getConfiguration().getSyncInfoSet().addError(new TeamStatus(IStatus.ERROR, CVSUIPlugin.ID, 0, e.getMessage(), e, null)); - } - } + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if (handler != null) + try { + handler.fetch(infos); + } catch (CVSException e) { + getConfiguration().getSyncInfoSet().addError(new TeamStatus(IStatus.ERROR, CVSUIPlugin.ID, 0, e.getMessage(), e, null)); + } + } - @Override + @Override public void reset(SyncInfoSet seedSet) { - // Notify that handler to stop any fetches in progress - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) { - handler.stopFetching(); - } - super.reset(seedSet); - } + // Notify that handler to stop any fetches in progress + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if (handler != null) { + handler.stopFetching(); + } + super.reset(seedSet); + } @Override public void dispose() { - // No longer listen for log entry changes - // (The handler is disposed with the page) - disposed = true; - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) handler.setListener(null); + // No longer listen for log entry changes + // (The handler is disposed with the page) + disposed = true; + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if (handler != null) handler.setListener(null); getConfiguration().setProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR, null); logEntryCache = null; super.dispose(); @@ -209,12 +209,12 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme /** * Fetch the log histories for the remote changes and use this information * to add each resource to an appropriate commit set. - */ - private void handleRemoteChanges(final SyncInfo[] infos, final LogEntryCache logEntries, final IProgressMonitor monitor) { + */ + private void handleRemoteChanges(final SyncInfo[] infos, final LogEntryCache logEntries, final IProgressMonitor monitor) { performUpdate(monitor1 -> addLogEntries(infos, logEntries, monitor1), true /* preserver expansion */, monitor); - } + } - /* + /* * Add the following sync info elements to the viewer. It is assumed that these elements have associated * log entries cached in the log operation. */ @@ -239,15 +239,15 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme * @param log the cvs log for this node */ private void addSyncInfoToCommentNode(SyncInfo info, LogEntryCache logs) { - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) { + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if (handler != null) { ICVSRemoteResource remoteResource = handler.getRemoteResource(info); if(handler.getSubscriber() instanceof CVSCompareSubscriber && remoteResource != null) { addMultipleRevisions(info, logs, remoteResource); } else { addSingleRevision(info, logs, remoteResource); } - } + } } /* @@ -259,7 +259,7 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme */ private void addSingleRevision(SyncInfo info, LogEntryCache logs, ICVSRemoteResource remoteResource) { ILogEntry logEntry = logs.getLogEntry(remoteResource); - if (remoteResource != null && !remoteResource.isFolder()) { + if (remoteResource != null && !remoteResource.isFolder()) { // For incoming deletions grab the comment for the latest on the same branch // which is now in the attic. try { @@ -277,11 +277,11 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme } catch (TeamException e) { // continue and skip deletion checks } - } + } addRemoteChange(info, remoteResource, logEntry); } - /* + /* * Add multiple log entries to the model. * * @param info @@ -309,86 +309,86 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme return false; } - /* - * Add the remote change to an incoming commit set - */ - private void addRemoteChange(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { - if (disposed) return; - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if(handler != null && remoteResource != null && logEntry != null && handler.isRemoteChange(info)) { - if(requiresCustomSyncInfo(info, remoteResource, logEntry)) { - info = new CVSUpdatableSyncInfo(info.getKind(), info.getLocal(), info.getBase(), (RemoteResource)logEntry.getRemoteFile(), ((CVSSyncInfo)info).getSubscriber()); - try { - info.init(); - } catch (TeamException e) { - // this shouldn't happen, we've provided our own calculate kind - } - } - // Only add the info if the base and remote differ - IResourceVariant base = info.getBase(); - IResourceVariant remote = info.getRemote(); - if ((base == null && remote != null) || (remote == null && base != null) || (remote != null && base != null && !base.equals(remote))) { - synchronized(this) { - CheckedInChangeSet set = getChangeSetFor(logEntry); - if (set == null) { - set = createChangeSetFor(logEntry); - add(set); - } - set.add(info); - } - } - } else { - // The info was not retrieved for the remote change for some reason. - // Add the node to the root - addToDefaultSet(DEFAULT_INCOMING_SET_NAME, info); - } - } - - private void addToDefaultSet(String name, SyncInfo info) { - CheckedInChangeSet set; - synchronized(this) { - set = getChangeSetFor(name); - if (set == null) { - set = createDefaultChangeSet(name); - add(set); - } - set.add(info); - } - } - - private CheckedInChangeSet createDefaultChangeSet(String name) { - return new DefaultCheckedInChangeSet(name); - } + /* + * Add the remote change to an incoming commit set + */ + private void addRemoteChange(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { + if (disposed) return; + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if(handler != null && remoteResource != null && logEntry != null && handler.isRemoteChange(info)) { + if(requiresCustomSyncInfo(info, remoteResource, logEntry)) { + info = new CVSUpdatableSyncInfo(info.getKind(), info.getLocal(), info.getBase(), (RemoteResource)logEntry.getRemoteFile(), ((CVSSyncInfo)info).getSubscriber()); + try { + info.init(); + } catch (TeamException e) { + // this shouldn't happen, we've provided our own calculate kind + } + } + // Only add the info if the base and remote differ + IResourceVariant base = info.getBase(); + IResourceVariant remote = info.getRemote(); + if ((base == null && remote != null) || (remote == null && base != null) || (remote != null && base != null && !base.equals(remote))) { + synchronized(this) { + CheckedInChangeSet set = getChangeSetFor(logEntry); + if (set == null) { + set = createChangeSetFor(logEntry); + add(set); + } + set.add(info); + } + } + } else { + // The info was not retrieved for the remote change for some reason. + // Add the node to the root + addToDefaultSet(DEFAULT_INCOMING_SET_NAME, info); + } + } + + private void addToDefaultSet(String name, SyncInfo info) { + CheckedInChangeSet set; + synchronized(this) { + set = getChangeSetFor(name); + if (set == null) { + set = createDefaultChangeSet(name); + add(set); + } + set.add(info); + } + } + + private CheckedInChangeSet createDefaultChangeSet(String name) { + return new DefaultCheckedInChangeSet(name); + } - private CheckedInChangeSet createChangeSetFor(ILogEntry logEntry) { - return new CVSCheckedInChangeSet(logEntry); - } + private CheckedInChangeSet createChangeSetFor(ILogEntry logEntry) { + return new CVSCheckedInChangeSet(logEntry); + } - private CheckedInChangeSet getChangeSetFor(ILogEntry logEntry) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set instanceof CheckedInChangeSet && - set.getComment().equals(logEntry.getComment()) && - ((CheckedInChangeSet)set).getAuthor().equals(logEntry.getAuthor())) { - return (CheckedInChangeSet)set; - } - } - return null; - } + private CheckedInChangeSet getChangeSetFor(ILogEntry logEntry) { + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; + if (set instanceof CheckedInChangeSet && + set.getComment().equals(logEntry.getComment()) && + ((CheckedInChangeSet)set).getAuthor().equals(logEntry.getAuthor())) { + return (CheckedInChangeSet)set; + } + } + return null; + } - private CheckedInChangeSet getChangeSetFor(String name) { - ChangeSet[] sets = getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (set.getName().equals(name)) { - return (CheckedInChangeSet)set; - } - } - return null; - } - - private boolean requiresCustomSyncInfo(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { + private CheckedInChangeSet getChangeSetFor(String name) { + ChangeSet[] sets = getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; + if (set.getName().equals(name)) { + return (CheckedInChangeSet)set; + } + } + return null; + } + + private boolean requiresCustomSyncInfo(SyncInfo info, ICVSRemoteResource remoteResource, ILogEntry logEntry) { // Only interested in non-deletions if (logEntry.isDeletion() || !(info instanceof CVSSyncInfo)) return false; // Only require a custom sync info if the remote of the sync info @@ -397,14 +397,14 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme if (remote == null) return true; return !remote.equals(remoteResource); } - - @Override + + @Override public void waitUntilDone(IProgressMonitor monitor) { - super.waitUntilDone(monitor); + super.waitUntilDone(monitor); monitor.worked(1); // wait for the event handler to process changes. - LogEntryCacheUpdateHandler handler = getLogEntryHandler(); - if (handler != null) { + LogEntryCacheUpdateHandler handler = getLogEntryHandler(); + if (handler != null) { while(handler.getEventHandlerJob().getState() != Job.NONE) { monitor.worked(1); try { @@ -413,23 +413,23 @@ public class CVSChangeSetCollector extends SyncInfoSetChangeSetCollector impleme } Policy.checkCanceled(monitor); } - } + } monitor.worked(1); - } + } - @Override + @Override public void logEntriesFetched(SyncInfoSet set, LogEntryCache logEntryCache, IProgressMonitor monitor) { - if (disposed) return; - // Hold on to the cache so we can use it while commit sets are visible - this.logEntryCache = logEntryCache; - handleRemoteChanges(set.getSyncInfos(), logEntryCache, monitor); - } + if (disposed) return; + // Hold on to the cache so we can use it while commit sets are visible + this.logEntryCache = logEntryCache; + handleRemoteChanges(set.getSyncInfos(), logEntryCache, monitor); + } - public ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException { - if (logEntryCache != null) - return logEntryCache.getImmediatePredecessor(file); - return null; - } + public ICVSRemoteFile getImmediatePredecessor(ICVSRemoteFile file) throws TeamException { + if (logEntryCache != null) + return logEntryCache.getImmediatePredecessor(file); + return null; + } @Override protected void initializeSets() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java index 8050fc515..60e423cab 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipant.java @@ -47,129 +47,129 @@ public class CVSParticipant extends SubscriberParticipant implements IChangeSetP configuration.addLabelDecorator(labelDecorator); } - @Override + @Override public void prepareCompareInput(ISynchronizeModelElement element, CompareConfiguration config, IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, 100); - deriveBaseContentsFromLocal(element, Policy.subMonitorFor(monitor, 10)); - super.prepareCompareInput(element, config, Policy.subMonitorFor(monitor, 80)); - updateLabelsForCVS(element, config, Policy.subMonitorFor(monitor, 10)); - monitor.done(); - } + monitor.beginTask(null, 100); + deriveBaseContentsFromLocal(element, Policy.subMonitorFor(monitor, 10)); + super.prepareCompareInput(element, config, Policy.subMonitorFor(monitor, 80)); + updateLabelsForCVS(element, config, Policy.subMonitorFor(monitor, 10)); + monitor.done(); + } - /** - * Helper method for updating compare editor labels - */ - protected static void updateLabelsForCVS(ISynchronizeModelElement element, CompareConfiguration config, IProgressMonitor monitor) { - // Add the author to the remote or base - if (TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SHOW_AUTHOR_IN_COMPARE_EDITOR)) { - SyncInfo info = getSyncInfo(element); - if (info != null) { - final IResourceVariant remote = info.getRemote(); - final IResourceVariant base = info.getBase(); - String remoteAuthor = null; - if (remote != null && !remote.isContainer()) { - try { - ILogEntry entry = ((ICVSRemoteFile)remote).getLogEntry(monitor); - remoteAuthor = entry.getAuthor(); - config.setRightLabel(NLS.bind(CVSUIMessages.CVSParticipant_0, new String[] { remote.getContentIdentifier(), remoteAuthor })); - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } - if (base != null && !base.isContainer()) { - try { - String baseAuthor; - if (remoteAuthor != null && remote.getContentIdentifier().equals(base.getContentIdentifier())) { - baseAuthor = remoteAuthor; - } else { - ILogEntry entry = ((ICVSRemoteFile)base).getLogEntry(monitor); - baseAuthor = entry.getAuthor(); - } - config.setAncestorLabel(NLS.bind(CVSUIMessages.CVSParticipant_1, new String[] { base.getContentIdentifier(), baseAuthor })); - } catch (TeamException e) { - CVSUIPlugin.log(e); - } - } - } - } - } - + /** + * Helper method for updating compare editor labels + */ + protected static void updateLabelsForCVS(ISynchronizeModelElement element, CompareConfiguration config, IProgressMonitor monitor) { + // Add the author to the remote or base + if (TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IPreferenceIds.SHOW_AUTHOR_IN_COMPARE_EDITOR)) { + SyncInfo info = getSyncInfo(element); + if (info != null) { + final IResourceVariant remote = info.getRemote(); + final IResourceVariant base = info.getBase(); + String remoteAuthor = null; + if (remote != null && !remote.isContainer()) { + try { + ILogEntry entry = ((ICVSRemoteFile)remote).getLogEntry(monitor); + remoteAuthor = entry.getAuthor(); + config.setRightLabel(NLS.bind(CVSUIMessages.CVSParticipant_0, new String[] { remote.getContentIdentifier(), remoteAuthor })); + } catch (TeamException e) { + CVSUIPlugin.log(e); + } + } + if (base != null && !base.isContainer()) { + try { + String baseAuthor; + if (remoteAuthor != null && remote.getContentIdentifier().equals(base.getContentIdentifier())) { + baseAuthor = remoteAuthor; + } else { + ILogEntry entry = ((ICVSRemoteFile)base).getLogEntry(monitor); + baseAuthor = entry.getAuthor(); + } + config.setAncestorLabel(NLS.bind(CVSUIMessages.CVSParticipant_1, new String[] { base.getContentIdentifier(), baseAuthor })); + } catch (TeamException e) { + CVSUIPlugin.log(e); + } + } + } + } + } + protected static SyncInfo getSyncInfo(ISynchronizeModelElement element) { - if (element instanceof IAdaptable) { - return ((IAdaptable)element).getAdapter(SyncInfo.class); - } - return null; + if (element instanceof IAdaptable) { + return ((IAdaptable)element).getAdapter(SyncInfo.class); + } + return null; } - /** - * If the local is not modified and the base matches the local then - * cache the local contents as the contents of the base. - * @param element - * @throws CoreException - * @throws TeamException - */ - public static void deriveBaseContentsFromLocal(ISynchronizeModelElement element, IProgressMonitor monitor) throws TeamException { - SyncInfo info = getSyncInfo(element); - if (info == null) - return; - - // We need a base that is a file and a local that is a file - IResource local = info.getLocal(); - IResourceVariant base = info.getBase(); - if (base == null || base.isContainer() || local.getType() != IResource.FILE || !local.exists()) - return; - - // We can only use the local contents for incoming changes. - // Outgoing or conflicting changes imply that the local has changed - if ((info.getKind() & SyncInfo.DIRECTION_MASK) != SyncInfo.INCOMING) - return; - - try { - RemoteFile remoteFile = (RemoteFile)base; - if (!remoteFile.isContentsCached()) - (remoteFile).setContents((IFile)local, monitor); - } catch (CoreException e) { - if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) { - // The file must have just been deleted - return; - } - throw CVSException.wrapException(e); - } - } - - @Override + /** + * If the local is not modified and the base matches the local then + * cache the local contents as the contents of the base. + * @param element + * @throws CoreException + * @throws TeamException + */ + public static void deriveBaseContentsFromLocal(ISynchronizeModelElement element, IProgressMonitor monitor) throws TeamException { + SyncInfo info = getSyncInfo(element); + if (info == null) + return; + + // We need a base that is a file and a local that is a file + IResource local = info.getLocal(); + IResourceVariant base = info.getBase(); + if (base == null || base.isContainer() || local.getType() != IResource.FILE || !local.exists()) + return; + + // We can only use the local contents for incoming changes. + // Outgoing or conflicting changes imply that the local has changed + if ((info.getKind() & SyncInfo.DIRECTION_MASK) != SyncInfo.INCOMING) + return; + + try { + RemoteFile remoteFile = (RemoteFile)base; + if (!remoteFile.isContentsCached()) + (remoteFile).setContents((IFile)local, monitor); + } catch (CoreException e) { + if (e.getStatus().getCode() == IResourceStatus.RESOURCE_NOT_FOUND) { + // The file must have just been deleted + return; + } + throw CVSException.wrapException(e); + } + } + + @Override public PreferencePage[] getPreferencePages() { - return addCVSPreferencePages(super.getPreferencePages()); - } + return addCVSPreferencePages(super.getPreferencePages()); + } - public static PreferencePage[] addCVSPreferencePages(PreferencePage[] inheritedPages) { - PreferencePage[] pages = new PreferencePage[inheritedPages.length + 1]; - for (int i = 0; i < inheritedPages.length; i++) { - pages[i] = inheritedPages[i]; - } - pages[pages.length - 1] = new ComparePreferencePage(); - pages[pages.length - 1].setTitle(CVSUIMessages.CVSParticipant_2); - return pages; - } - - @Override + public static PreferencePage[] addCVSPreferencePages(PreferencePage[] inheritedPages) { + PreferencePage[] pages = new PreferencePage[inheritedPages.length + 1]; + for (int i = 0; i < inheritedPages.length; i++) { + pages[i] = inheritedPages[i]; + } + pages[pages.length - 1] = new ComparePreferencePage(); + pages[pages.length - 1].setTitle(CVSUIMessages.CVSParticipant_2); + return pages; + } + + @Override public ChangeSetCapability getChangeSetCapability() { - if (capability == null) { - capability = createChangeSetCapability(); - } - return capability; - } + if (capability == null) { + capability = createChangeSetCapability(); + } + return capability; + } - /** - * Create the change set capability for this particpant. - * @return the created capability - */ - protected CVSChangeSetCapability createChangeSetCapability() { - return new CVSChangeSetCapability(); - } - - @Override + /** + * Create the change set capability for this particpant. + * @return the created capability + */ + protected CVSChangeSetCapability createChangeSetCapability() { + return new CVSChangeSetCapability(); + } + + @Override protected boolean isViewerContributionsSupported() { - return true; - } + return true; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java index f74d3d540..1447e6ef7 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java @@ -93,11 +93,11 @@ public class CVSParticipantLabelDecorator extends LabelProvider implements IProp return Utils.getResource(internalGetElement(element)); } - protected CVSDecoration getDecoration(IResource resource) throws CoreException { - return CVSLightweightDecorator.decorate(resource, tester); - } + protected CVSDecoration getDecoration(IResource resource) throws CoreException { + return CVSLightweightDecorator.decorate(resource, tester); + } - public Image decorateImage(Image base, Object element) { + public Image decorateImage(Image base, Object element) { return base; } public void propertyChange(PropertyChangeEvent event) { @@ -110,8 +110,8 @@ public class CVSParticipantLabelDecorator extends LabelProvider implements IProp } protected boolean needsRefresh(PropertyChangeEvent event) { - final String property= event.getProperty(); - return property.equals(CVSUIPlugin.P_DECORATORS_CHANGED) || property.equals(TeamUI.GLOBAL_FILE_TYPES_CHANGED); + final String property= event.getProperty(); + return property.equals(CVSUIPlugin.P_DECORATORS_CHANGED) || property.equals(TeamUI.GLOBAL_FILE_TYPES_CHANGED); } public void dispose() { CVSUIPlugin.removePropertyChangeListener(this); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java index ad35c092f..81ec85208 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CommitSetDialog.java @@ -34,75 +34,75 @@ import org.eclipse.ui.PlatformUI; */ public class CommitSetDialog extends TitleAreaDialog { - public final static short NEW = 0; - public final static short EDIT = 1; - + public final static short NEW = 0; + public final static short EDIT = 1; + private static final int DEFAULT_WIDTH_IN_CHARS= 80; - - private final ActiveChangeSet set; - private CommitCommentArea commitCommentArea; - private Text nameText; - private Button customTitleButton; - private final String title; - private final String description; - private String comment; - private short mode; + + private final ActiveChangeSet set; + private CommitCommentArea commitCommentArea; + private Text nameText; + private Button customTitleButton; + private final String title; + private final String description; + private String comment; + private short mode; protected String customTitle; - public CommitSetDialog(Shell parentShell, ActiveChangeSet set, IResource[] files, short mode) { - super(parentShell); - this.set = set; - this.mode = mode; + public CommitSetDialog(Shell parentShell, ActiveChangeSet set, IResource[] files, short mode) { + super(parentShell); + this.set = set; + this.mode = mode; this.title = mode == NEW ? CVSUIMessages.WorkspaceChangeSetCapability_2 : CVSUIMessages.WorkspaceChangeSetCapability_7; this.description = mode == NEW ? CVSUIMessages.WorkspaceChangeSetCapability_3 : CVSUIMessages.WorkspaceChangeSetCapability_8; - - if (files == null) { - files = set.getResources(); - } - + + if (files == null) { + files = set.getResources(); + } + int shellStyle = getShellStyle(); setShellStyle(shellStyle | SWT.RESIZE | SWT.MAX); commitCommentArea = new CommitCommentArea(); // Get a project from which the commit template can be obtained if (files.length > 0) - commitCommentArea.setProject(files[0].getProject()); - } - - @Override + commitCommentArea.setProject(files[0].getProject()); + } + + @Override protected Control createContents(Composite parent) { - Control contents = super.createContents(parent); - setTitle(title); - setMessage(description); - return contents; - } - - @Override + Control contents = super.createContents(parent); + setTitle(title); + setMessage(description); + return contents; + } + + @Override protected Control createDialogArea(Composite parent) { - Composite parentComposite = (Composite) super.createDialogArea(parent); + Composite parentComposite = (Composite) super.createDialogArea(parent); - // create a composite with standard margins and spacing - Composite composite = new Composite(parentComposite, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setFont(parentComposite.getFont()); + // create a composite with standard margins and spacing + Composite composite = new Composite(parentComposite, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); + layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); + layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); + layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + composite.setFont(parentComposite.getFont()); if (hasCommitTemplate()) { - if (set.hasComment()) { - // Only set the comment if the set has a custom comment. - // Otherwise, the template should be used - comment = set.getComment(); - commitCommentArea.setProposedComment(comment); - } + if (set.hasComment()) { + // Only set the comment if the set has a custom comment. + // Otherwise, the template should be used + comment = set.getComment(); + commitCommentArea.setProposedComment(comment); + } } else { - comment = set.getComment(); - commitCommentArea.setProposedComment(comment); + comment = set.getComment(); + commitCommentArea.setProposedComment(comment); } commitCommentArea.createArea(composite); @@ -124,19 +124,19 @@ public class CommitSetDialog extends TitleAreaDialog { initializeValues(); updateEnablements(); - Dialog.applyDialogFont(parent); - return composite; - } - + Dialog.applyDialogFont(parent); + return composite; + } + @Override protected Point getInitialSize() { - final Point size= super.getInitialSize(); - size.x= convertWidthInCharsToPixels(DEFAULT_WIDTH_IN_CHARS); - size.y += convertHeightInCharsToPixels(8); - return size; + final Point size= super.getInitialSize(); + size.x= convertWidthInCharsToPixels(DEFAULT_WIDTH_IN_CHARS); + size.y += convertHeightInCharsToPixels(8); + return size; } - private void createNameArea(Composite parent) { + private void createNameArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; @@ -158,20 +158,20 @@ public class CommitSetDialog extends TitleAreaDialog { customTitle = nameText.getText(); updateEnablements(); }); - } + } - private void initializeValues() { - String initialText = set.getTitle(); - if (initialText == null) initialText = ""; //$NON-NLS-1$ - nameText.setText(initialText); - nameText.setSelection(0, initialText.length()); - - if (customTitleButton != null) { - customTitleButton.setSelection(!commitCommentArea.getFirstLineOfComment().equals(initialText)); - } - } - - private void createOptionsArea(Composite composite) { + private void initializeValues() { + String initialText = set.getTitle(); + if (initialText == null) initialText = ""; //$NON-NLS-1$ + nameText.setText(initialText); + nameText.setSelection(0, initialText.length()); + + if (customTitleButton != null) { + customTitleButton.setSelection(!commitCommentArea.getFirstLineOfComment().equals(initialText)); + } + } + + private void createOptionsArea(Composite composite) { Composite radioArea = new Composite(composite, SWT.NONE); RowLayout radioAreaLayout = new RowLayout(SWT.VERTICAL); radioAreaLayout.marginLeft = 0; @@ -180,29 +180,29 @@ public class CommitSetDialog extends TitleAreaDialog { radioAreaLayout.marginBottom = 0; radioArea.setLayout(radioAreaLayout); - customTitleButton = createCheckButton(radioArea, CVSUIMessages.CommitSetDialog_2); - SelectionAdapter listener = new SelectionAdapter() { - @Override + customTitleButton = createCheckButton(radioArea, CVSUIMessages.CommitSetDialog_2); + SelectionAdapter listener = new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - if (customTitleButton.getSelection()) { - nameText.setText(customTitle); - } else { - nameText.setText(commitCommentArea.getFirstLineOfComment()); - } - updateEnablements(); - } - }; - customTitleButton.addSelectionListener(listener); - - } - + if (customTitleButton.getSelection()) { + nameText.setText(customTitle); + } else { + nameText.setText(commitCommentArea.getFirstLineOfComment()); + } + updateEnablements(); + } + }; + customTitleButton.addSelectionListener(listener); + + } + private Button createCheckButton(Composite parent, String label) { Button button = new Button(parent, SWT.CHECK); button.setText(label); return button; } - private void updateEnablements() { + private void updateEnablements() { setErrorMessage(null); String name; @@ -218,7 +218,7 @@ public class CommitSetDialog extends TitleAreaDialog { setPageComplete(false); return; } - + // check if the new change set already exists if (mode == NEW && CVSUIPlugin.getPlugin().getChangeSetManager().getSet(name) != null) { @@ -236,36 +236,36 @@ public class CommitSetDialog extends TitleAreaDialog { return; } - - setPageComplete(true); - } - + + setPageComplete(true); + } + final protected void setPageComplete(boolean complete) { - Button okButton = getButton(IDialogConstants.OK_ID); + Button okButton = getButton(IDialogConstants.OK_ID); if(okButton != null ) { okButton.setEnabled(complete); } } - private boolean hasCommitTemplate() { - return commitCommentArea.hasCommitTemplate(); - } - - @Override + private boolean hasCommitTemplate() { + return commitCommentArea.hasCommitTemplate(); + } + + @Override protected void okPressed() { - String title = null; - if (customTitleButton.getSelection()) { + String title = null; + if (customTitleButton.getSelection()) { title= customTitle; } else { title= commitCommentArea.getFirstLineOfComment(); } - - set.setTitle(title); - // Call getComment so the comment gets saved - set.setComment(commitCommentArea.getComment(true)); - - super.okPressed(); - } + + set.setTitle(title); + // Call getComment so the comment gets saved + set.setComment(commitCommentArea.getComment(true)); + + super.okPressed(); + } protected Label createWrappingLabel(Composite parent, String text) { @@ -281,13 +281,13 @@ public class CommitSetDialog extends TitleAreaDialog { return label; } - @Override + @Override protected Control createButtonBar(Composite parent) { - Control control = super.createButtonBar(parent); - updateEnablements(); - return control; - } - + Control control = super.createButtonBar(parent); + updateEnablements(); + return control; + } + @Override protected void configureShell(Shell shell) { super.configureShell(shell); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java index 9faaf017d..7d3e007b4 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CompareParticipant.java @@ -120,7 +120,7 @@ public class CompareParticipant extends CVSParticipant implements IPreferenceCha } public CompareParticipant(CVSCompareSubscriber subscriber) { - setSubscriber(subscriber); + setSubscriber(subscriber); } @Override @@ -152,9 +152,9 @@ public class CompareParticipant extends CVSParticipant implements IPreferenceCha ISynchronizeParticipantReference reference = refs[i]; if (reference.getId().equals(CVSCompareSubscriber.ID)) { try { - CompareParticipant p = (CompareParticipant) reference.getParticipant(); + CompareParticipant p = (CompareParticipant) reference.getParticipant(); if (p.matches(resources, tag)) { - return p; + return p; } } catch (TeamException e) { continue; @@ -188,11 +188,11 @@ public class CompareParticipant extends CVSParticipant implements IPreferenceCha /** * Return the subscriber as an instance of CVSCompareSubscriber. - * @return the subscriber as an instance of CVSCompareSubscriber - */ - public CVSCompareSubscriber getCVSCompareSubscriber() { - return (CVSCompareSubscriber)getSubscriber(); - } + * @return the subscriber as an instance of CVSCompareSubscriber + */ + public CVSCompareSubscriber getCVSCompareSubscriber() { + return (CVSCompareSubscriber)getSubscriber(); + } @Override protected void initializeConfiguration(ISynchronizePageConfiguration configuration) { @@ -235,18 +235,18 @@ public class CompareParticipant extends CVSParticipant implements IPreferenceCha return CVSUIMessages.Participant_comparing; } - @Override + @Override protected CVSChangeSetCapability createChangeSetCapability() { - return new CVSChangeSetCapability() { - @Override + return new CVSChangeSetCapability() { + @Override public ActiveChangeSetManager getActiveChangeSetManager() { - return CVSUIPlugin.getPlugin().getChangeSetManager(); - } - @Override + return CVSUIPlugin.getPlugin().getChangeSetManager(); + } + @Override public boolean enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration) { - return super.enableActiveChangeSetsFor(configuration) || - configuration.getComparisonType() == ISynchronizePageConfiguration.TWO_WAY; - } - }; - } + return super.enableActiveChangeSetsFor(configuration) || + configuration.getComparisonType() == ISynchronizePageConfiguration.TWO_WAY; + } + }; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CreatePatchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CreatePatchAction.java index 7a03054b7..8b738501a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CreatePatchAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CreatePatchAction.java @@ -39,29 +39,29 @@ public class CreatePatchAction extends CVSParticipantAction { @Override public void runOperation() { - final SyncInfoSet set = getSyncInfoSet(); - GenerateDiffFileWizard.run(getConfiguration().getSite().getPart(), set.getResources(), false); - } + final SyncInfoSet set = getSyncInfoSet(); + GenerateDiffFileWizard.run(getConfiguration().getSite().getPart(), set.getResources(), false); + } /* - * Return the selected SyncInfo for which this action is enabled. - * - * @return the selected SyncInfo for which this action is enabled. - */ - private SyncInfoSet getSyncInfoSet() { - IDiffElement [] elements= getFilteredDiffElements(); - SyncInfoSet filtered = new SyncInfoSet(); - for (int i = 0; i < elements.length; i++) { - IDiffElement e = elements[i]; - if (e instanceof SyncInfoModelElement) { - filtered.add(((SyncInfoModelElement)e).getSyncInfo()); - } - } - return filtered; - } - - @Override + * Return the selected SyncInfo for which this action is enabled. + * + * @return the selected SyncInfo for which this action is enabled. + */ + private SyncInfoSet getSyncInfoSet() { + IDiffElement [] elements= getFilteredDiffElements(); + SyncInfoSet filtered = new SyncInfoSet(); + for (int i = 0; i < elements.length; i++) { + IDiffElement e = elements[i]; + if (e instanceof SyncInfoModelElement) { + filtered.add(((SyncInfoModelElement)e).getSyncInfo()); + } + } + return filtered; + } + + @Override protected String getBundleKeyPrefix() { - return "GenerateDiffFileAction."; //$NON-NLS-1$ - } + return "GenerateDiffFileAction."; //$NON-NLS-1$ + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CreatePatchWizardParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CreatePatchWizardParticipant.java index 91bbf51c2..4ce58e99b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CreatePatchWizardParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/CreatePatchWizardParticipant.java @@ -19,26 +19,26 @@ import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; import org.eclipse.team.ui.synchronize.ISynchronizeScope; public class CreatePatchWizardParticipant extends WorkspaceSynchronizeParticipant { - - final GenerateDiffFileWizard fWizard; - - public CreatePatchWizardParticipant(ISynchronizeScope scope, GenerateDiffFileWizard wizard) { - super(scope); - fWizard= wizard; - } + + final GenerateDiffFileWizard fWizard; + + public CreatePatchWizardParticipant(ISynchronizeScope scope, GenerateDiffFileWizard wizard) { + super(scope); + fWizard= wizard; + } @Override - protected void initializeConfiguration( ISynchronizePageConfiguration configuration) { - super.initializeConfiguration(configuration); - configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ISynchronizePageConfiguration.LAYOUT_GROUP}); - configuration.setProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU, ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU); - ((SynchronizePageConfiguration)configuration).setViewerStyle(SynchronizePageConfiguration.CHECKBOX); - configuration.setSupportedModes(ISynchronizePageConfiguration.OUTGOING_MODE); - configuration.setMode(ISynchronizePageConfiguration.OUTGOING_MODE); - } + protected void initializeConfiguration( ISynchronizePageConfiguration configuration) { + super.initializeConfiguration(configuration); + configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ISynchronizePageConfiguration.LAYOUT_GROUP}); + configuration.setProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU, ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU); + ((SynchronizePageConfiguration)configuration).setViewerStyle(SynchronizePageConfiguration.CHECKBOX); + configuration.setSupportedModes(ISynchronizePageConfiguration.OUTGOING_MODE); + configuration.setMode(ISynchronizePageConfiguration.OUTGOING_MODE); + } @Override - public boolean doesSupportSynchronize() { - return false; - } + public boolean doesSupportSynchronize() { + return false; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/LogEntryCacheUpdateHandler.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/LogEntryCacheUpdateHandler.java index 93eb373a0..ff57ec0e4 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/LogEntryCacheUpdateHandler.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/LogEntryCacheUpdateHandler.java @@ -44,265 +44,265 @@ import org.eclipse.team.ui.synchronize.*; * in the subscriber. */ public class LogEntryCacheUpdateHandler extends BackgroundEventHandler { - - private static final int REMOVAL = 1; - private static final int CHANGE = 2; - private static final int FETCH_REQUEST = 3; - private static final int PAUSE = 4; - - /* - * Lock used to ensure that fetches are queued when the job is - * a non-system job. - */ - private final Object queueLock = new Object(); - - /* - * Exception used to stop processing so the job can be restarted as a non-system job - */ - private static final OperationCanceledException PAUSE_EXCEPTION = new OperationCanceledException(); - - /* - * Contants for configuring how long to wait for the job to be paused - * when a fetch is required and the job needs to be converted to a non-system - * job. If the wait time is elapsed, an exception is thrown. - */ - private static final int WAIT_INCREMENT = 10; - private static final int MAX_WAIT = 1000; - - /* - * Set that keeps track of all resource for which we haved fetched log entries - */ - private final SyncInfoTree collectedInfos = new SyncInfoTree(); - - /* - * The cache that hold the log entries while the job is running - */ - //private LogEntryCache logEntriesCache; - - /* - * SoftReference used to hold on to the log entry cache while - * the job is not running so the cache can be cleared if memory is low. - */ - private SoftReference cacheReference; - - /* - * Collector that forewards subscriber changes so that - * stale cache entries can be cleared. - */ - private final LogEntryResourceCollector collector; + + private static final int REMOVAL = 1; + private static final int CHANGE = 2; + private static final int FETCH_REQUEST = 3; + private static final int PAUSE = 4; + + /* + * Lock used to ensure that fetches are queued when the job is + * a non-system job. + */ + private final Object queueLock = new Object(); + + /* + * Exception used to stop processing so the job can be restarted as a non-system job + */ + private static final OperationCanceledException PAUSE_EXCEPTION = new OperationCanceledException(); + + /* + * Contants for configuring how long to wait for the job to be paused + * when a fetch is required and the job needs to be converted to a non-system + * job. If the wait time is elapsed, an exception is thrown. + */ + private static final int WAIT_INCREMENT = 10; + private static final int MAX_WAIT = 1000; + + /* + * Set that keeps track of all resource for which we haved fetched log entries + */ + private final SyncInfoTree collectedInfos = new SyncInfoTree(); + + /* + * The cache that hold the log entries while the job is running + */ + //private LogEntryCache logEntriesCache; + + /* + * SoftReference used to hold on to the log entry cache while + * the job is not running so the cache can be cleared if memory is low. + */ + private SoftReference cacheReference; + + /* + * Collector that forewards subscriber changes so that + * stale cache entries can be cleared. + */ + private final LogEntryResourceCollector collector; - /* - * The subscriber generating the SyncInfo and log entries - */ - private final Subscriber subscriber; - - /* - * The accumulated list of updates that need to be dispatched - * (i.e. the cache should be purged of out-of-date resources). - * This list is only modified and accessed from the event processing - * thread. - */ + /* + * The subscriber generating the SyncInfo and log entries + */ + private final Subscriber subscriber; + + /* + * The accumulated list of updates that need to be dispatched + * (i.e. the cache should be purged of out-of-date resources). + * This list is only modified and accessed from the event processing + * thread. + */ private final List<Event> updates = new ArrayList<>(); - - /* - * The accumulated list of fetches that have been requested - */ + + /* + * The accumulated list of fetches that have been requested + */ private final List<Event> fetches = new ArrayList<>(); - private final ISynchronizePageConfiguration configuration; - - - /* - * Interface for notifying a single client that the infos have been fetched - */ - public interface ILogsFetchedListener { + private final ISynchronizePageConfiguration configuration; + + + /* + * Interface for notifying a single client that the infos have been fetched + */ + public interface ILogsFetchedListener { - void logEntriesFetched(SyncInfoSet set, LogEntryCache logEntryCache, IProgressMonitor monitor); - - } - - /* - * The listener or null if noone is listening - */ - private ILogsFetchedListener listener; - - /* - * Subscriber resource collector that forwards subscriber changes - * through the handler so that stale cache entries can be cleared - */ - private class LogEntryResourceCollector extends SubscriberResourceCollector { + void logEntriesFetched(SyncInfoSet set, LogEntryCache logEntryCache, IProgressMonitor monitor); + + } + + /* + * The listener or null if noone is listening + */ + private ILogsFetchedListener listener; + + /* + * Subscriber resource collector that forwards subscriber changes + * through the handler so that stale cache entries can be cleared + */ + private class LogEntryResourceCollector extends SubscriberResourceCollector { - public LogEntryResourceCollector(Subscriber subscriber) { - super(subscriber); - } + public LogEntryResourceCollector(Subscriber subscriber) { + super(subscriber); + } - @Override + @Override protected void remove(IResource resource) { - queueEvent(new ResourceEvent(resource, REMOVAL, IResource.DEPTH_INFINITE), false /* do not put in on the front of the queue*/); - } + queueEvent(new ResourceEvent(resource, REMOVAL, IResource.DEPTH_INFINITE), false /* do not put in on the front of the queue*/); + } - @Override + @Override protected void change(IResource resource, int depth) { - queueEvent(new ResourceEvent(resource, CHANGE, depth), false /* do not put in on the front of the queue*/); - } + queueEvent(new ResourceEvent(resource, CHANGE, depth), false /* do not put in on the front of the queue*/); + } - @Override + @Override protected boolean hasMembers(IResource resource) { - return collectedInfos.hasMembers(resource); - } - } - - /* - * Custom event for queue a log entry fetch request - */ - private class FetchRequest extends Event { - private final SyncInfo[] infos; - public FetchRequest(SyncInfo[] infos) { - super(FETCH_REQUEST); - this.infos = infos; - } - public SyncInfo[] getInfos() { - return infos; - } - } - - public LogEntryCacheUpdateHandler(ISynchronizePageConfiguration configuration) { - super(CVSUIMessages.LogEntryCacheUpdateHandler_1, CVSUIMessages.LogEntryCacheUpdateHandler_0); // - this.configuration = configuration; - this.subscriber = getSubscriber(configuration); - cacheReference = new SoftReference(new LogEntryCache()); - collector = new LogEntryResourceCollector(subscriber); - } + return collectedInfos.hasMembers(resource); + } + } + + /* + * Custom event for queue a log entry fetch request + */ + private class FetchRequest extends Event { + private final SyncInfo[] infos; + public FetchRequest(SyncInfo[] infos) { + super(FETCH_REQUEST); + this.infos = infos; + } + public SyncInfo[] getInfos() { + return infos; + } + } + + public LogEntryCacheUpdateHandler(ISynchronizePageConfiguration configuration) { + super(CVSUIMessages.LogEntryCacheUpdateHandler_1, CVSUIMessages.LogEntryCacheUpdateHandler_0); // + this.configuration = configuration; + this.subscriber = getSubscriber(configuration); + cacheReference = new SoftReference(new LogEntryCache()); + collector = new LogEntryResourceCollector(subscriber); + } - private Subscriber getSubscriber(ISynchronizePageConfiguration configuration) { - ISynchronizeParticipant participant = configuration.getParticipant(); - if (participant instanceof SubscriberParticipant) { + private Subscriber getSubscriber(ISynchronizePageConfiguration configuration) { + ISynchronizeParticipant participant = configuration.getParticipant(); + if (participant instanceof SubscriberParticipant) { SubscriberParticipant sp = (SubscriberParticipant) participant; return sp.getSubscriber(); } - if (participant instanceof ModelCompareParticipant) { + if (participant instanceof ModelCompareParticipant) { ModelCompareParticipant mcp = (ModelCompareParticipant) participant; return mcp.getSubscriber(); } - return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); - } + return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(); + } - public ISynchronizePageConfiguration getConfiguration() { - return configuration; - } - - public Subscriber getSubscriber() { - return subscriber; - } - - /** - * Set the listener that should receive notification when log entries - * have been fetched and are avalable. - * @param listener the listener or <code>null</code> - */ - public void setListener(ILogsFetchedListener listener) { - this.listener = listener; - } - - @Override + public ISynchronizePageConfiguration getConfiguration() { + return configuration; + } + + public Subscriber getSubscriber() { + return subscriber; + } + + /** + * Set the listener that should receive notification when log entries + * have been fetched and are avalable. + * @param listener the listener or <code>null</code> + */ + public void setListener(ILogsFetchedListener listener) { + this.listener = listener; + } + + @Override protected Object getJobFamiliy() { - return ISynchronizeManager.FAMILY_SYNCHRONIZE_OPERATION; - } - - @Override + return ISynchronizeManager.FAMILY_SYNCHRONIZE_OPERATION; + } + + @Override protected void createEventHandlingJob() { - super.createEventHandlingJob(); - Job job = getEventHandlerJob(); - job.setSystem(false); - job.setUser(false); - } - - @Override + super.createEventHandlingJob(); + Job job = getEventHandlerJob(); + job.setSystem(false); + job.setUser(false); + } + + @Override protected void processEvent(Event event, IProgressMonitor monitor) throws CoreException { - Policy.checkCanceled(monitor); - switch (event.getType()) { - case REMOVAL: - case CHANGE: - updates.add(event); - break; - case FETCH_REQUEST: - fetches.add(event); - break; - case PAUSE: - throw PAUSE_EXCEPTION; - } - - } - - @Override + Policy.checkCanceled(monitor); + switch (event.getType()) { + case REMOVAL: + case CHANGE: + updates.add(event); + break; + case FETCH_REQUEST: + fetches.add(event); + break; + case PAUSE: + throw PAUSE_EXCEPTION; + } + + } + + @Override protected boolean doDispatchEvents(IProgressMonitor monitor) throws TeamException { - Policy.checkCanceled(monitor); - boolean dispatched = false; - monitor.beginTask(null, 50); - dispatched |= updateCache(Policy.subMonitorFor(monitor, 20)); - dispatched |= processQueuedFetches(Policy.subMonitorFor(monitor, 80)); - monitor.done(); - return dispatched; - } - - /* - * Remove any stale or unneeded log entries from the cache. - * Return whether there were any entries to purge. - */ - private boolean updateCache(IProgressMonitor monitor) { - if (updates.isEmpty()) return false; - try { - collectedInfos.beginInput(); - // Cycle through the update events - for (Iterator iter = updates.iterator(); iter.hasNext();) { - Event event = (Event) iter.next(); - Policy.checkCanceled(monitor); - if (event.getType() == REMOVAL) { - remove(event.getResource(), ((ResourceEvent)event).getDepth()); - } else if (event.getType() == CHANGE) { - change(event.getResource(), ((ResourceEvent)event).getDepth()); - } - // Use the iterator to remove so that updates will not be lost - // if the job is cancelled and then restarted. - iter.remove(); - } - } finally { - collectedInfos.endInput(monitor); - } - return true; - } + Policy.checkCanceled(monitor); + boolean dispatched = false; + monitor.beginTask(null, 50); + dispatched |= updateCache(Policy.subMonitorFor(monitor, 20)); + dispatched |= processQueuedFetches(Policy.subMonitorFor(monitor, 80)); + monitor.done(); + return dispatched; + } + + /* + * Remove any stale or unneeded log entries from the cache. + * Return whether there were any entries to purge. + */ + private boolean updateCache(IProgressMonitor monitor) { + if (updates.isEmpty()) return false; + try { + collectedInfos.beginInput(); + // Cycle through the update events + for (Iterator iter = updates.iterator(); iter.hasNext();) { + Event event = (Event) iter.next(); + Policy.checkCanceled(monitor); + if (event.getType() == REMOVAL) { + remove(event.getResource(), ((ResourceEvent)event).getDepth()); + } else if (event.getType() == CHANGE) { + change(event.getResource(), ((ResourceEvent)event).getDepth()); + } + // Use the iterator to remove so that updates will not be lost + // if the job is cancelled and then restarted. + iter.remove(); + } + } finally { + collectedInfos.endInput(monitor); + } + return true; + } - @Override + @Override public void shutdown() { - super.shutdown(); - collector.dispose(); - // Probably not necessary as GC would take care of it but we'll do it anyway - if (cacheReference != null) { - LogEntryCache cache = (LogEntryCache)cacheReference.get(); - if (cache != null) { - cache.clearEntries(); - } - } - collectedInfos.clear(); - - } - - private void remove(IResource resource, int depth) { - collectedInfos.remove(resource, depth); - } + super.shutdown(); + collector.dispose(); + // Probably not necessary as GC would take care of it but we'll do it anyway + if (cacheReference != null) { + LogEntryCache cache = (LogEntryCache)cacheReference.get(); + if (cache != null) { + cache.clearEntries(); + } + } + collectedInfos.clear(); + + } + + private void remove(IResource resource, int depth) { + collectedInfos.remove(resource, depth); + } - private void remove(SyncInfo info) { - if (info != null) { - collectedInfos.remove(info.getLocal()); - LogEntryCache cache = (LogEntryCache)cacheReference.get(); - if (cache != null) { + private void remove(SyncInfo info) { + if (info != null) { + collectedInfos.remove(info.getLocal()); + LogEntryCache cache = (LogEntryCache)cacheReference.get(); + if (cache != null) { ICVSRemoteResource remoteResource = getRemoteResource(info); if (remoteResource != null) cache.clearEntries(remoteResource); } - } - } + } + } - public ICVSRemoteResource getRemoteResource(SyncInfo info) { + public ICVSRemoteResource getRemoteResource(SyncInfo info) { try { ICVSRemoteResource remote = (ICVSRemoteResource) info.getRemote(); ICVSRemoteResource local = CVSWorkspaceRoot.getRemoteResourceFor(info.getLocal()); @@ -330,180 +330,180 @@ public class LogEntryCacheUpdateHandler extends BackgroundEventHandler { } } - private boolean useRemote(String localRevision, String remoteRevision) { - boolean useRemote; - if (remoteRevision == null && localRevision == null) { - useRemote = true; - } else if (localRevision == null) { - useRemote = true; - } else if (remoteRevision == null) { - useRemote = false; - } else { - useRemote = ResourceSyncInfo.isLaterRevision(remoteRevision, localRevision); - } - return useRemote; - } + private boolean useRemote(String localRevision, String remoteRevision) { + boolean useRemote; + if (remoteRevision == null && localRevision == null) { + useRemote = true; + } else if (localRevision == null) { + useRemote = true; + } else if (remoteRevision == null) { + useRemote = false; + } else { + useRemote = ResourceSyncInfo.isLaterRevision(remoteRevision, localRevision); + } + return useRemote; + } - private String getRevisionString(ICVSRemoteResource remoteFile) { + private String getRevisionString(ICVSRemoteResource remoteFile) { if(remoteFile instanceof RemoteFile) { return ((RemoteFile)remoteFile).getRevision(); } return null; } - - private void change(IResource resource, int depth) { - // We only need to remove collected log entries that don't apply - // any longer. They will be refetched when they are required. - SyncInfo[] collected = collectedInfos.getSyncInfos(resource, depth); - change(collected); - } - - private void change(SyncInfo[] collected) { - Subscriber subscriber = getSubscriber(); - for (int i = 0; i < collected.length; i++) { - try { - SyncInfo info = collected[i]; - SyncInfo newInfo = subscriber.getSyncInfo(info.getLocal()); - if (newInfo == null || !newInfo.equals(info)) { - // The cached log entry no longer applies to the new sync info. - // It will be refetched when required. - remove(info); - } - } catch (TeamException e) { - // Log and continue - CVSUIPlugin.log(e); - } - } - } + + private void change(IResource resource, int depth) { + // We only need to remove collected log entries that don't apply + // any longer. They will be refetched when they are required. + SyncInfo[] collected = collectedInfos.getSyncInfos(resource, depth); + change(collected); + } + + private void change(SyncInfo[] collected) { + Subscriber subscriber = getSubscriber(); + for (int i = 0; i < collected.length; i++) { + try { + SyncInfo info = collected[i]; + SyncInfo newInfo = subscriber.getSyncInfo(info.getLocal()); + if (newInfo == null || !newInfo.equals(info)) { + // The cached log entry no longer applies to the new sync info. + // It will be refetched when required. + remove(info); + } + } catch (TeamException e) { + // Log and continue + CVSUIPlugin.log(e); + } + } + } - /** - * Queue a request to fetch log entries for the given SyncInfo nodes. - * The event handler must be a non-system job when revision histories - * are fetched. - * @param infos the nodes whose log entries are to be fetched - */ - public void fetch(SyncInfo[] infos) throws CVSException { - synchronized(queueLock) { - Job job = getEventHandlerJob(); - if (job.isSystem() && job.getState() != Job.NONE) { - // queue an event to pause the processor - super.queueEvent(new Event(PAUSE), true /* put on the front of the queue */); - int count = 0; - while (job.getState() != Job.NONE && count < MAX_WAIT) { - count += WAIT_INCREMENT; - try { - Thread.sleep(WAIT_INCREMENT); // Wait a little while - } catch (InterruptedException e) { - // Ignore - } - } - if (job.getState() != Job.NONE) { - // The job never completed in the time aloted so throw an exception - throw new CVSException(CVSUIMessages.LogEntryCacheUpdateHandler_2); - } - } - // Queue the event even if the job didn't stop in the time aloted - queueEvent(new FetchRequest(infos), false /* don't place at the end */); - } - } - - @Override + /** + * Queue a request to fetch log entries for the given SyncInfo nodes. + * The event handler must be a non-system job when revision histories + * are fetched. + * @param infos the nodes whose log entries are to be fetched + */ + public void fetch(SyncInfo[] infos) throws CVSException { + synchronized(queueLock) { + Job job = getEventHandlerJob(); + if (job.isSystem() && job.getState() != Job.NONE) { + // queue an event to pause the processor + super.queueEvent(new Event(PAUSE), true /* put on the front of the queue */); + int count = 0; + while (job.getState() != Job.NONE && count < MAX_WAIT) { + count += WAIT_INCREMENT; + try { + Thread.sleep(WAIT_INCREMENT); // Wait a little while + } catch (InterruptedException e) { + // Ignore + } + } + if (job.getState() != Job.NONE) { + // The job never completed in the time aloted so throw an exception + throw new CVSException(CVSUIMessages.LogEntryCacheUpdateHandler_2); + } + } + // Queue the event even if the job didn't stop in the time aloted + queueEvent(new FetchRequest(infos), false /* don't place at the end */); + } + } + + @Override protected void queueEvent(Event event, boolean front) { - // Override to snure that queues by this handler are serialized - synchronized(queueLock) { - Job job = getEventHandlerJob(); - if (job.getState() == Job.NONE) { - job.setSystem(event.getType() != FETCH_REQUEST); - } - super.queueEvent(event, front); - } - } - - /* - * Method invoked during event dispatch to fetch log entries - */ - private boolean processQueuedFetches(IProgressMonitor monitor) { - if (fetches.isEmpty()) return false; - try { - // Now perform the fetching - Map projectMapping = getFetchesByProject(); - if (projectMapping.isEmpty()) return true; - LogEntryCache logEntriesCache = (LogEntryCache)cacheReference.get(); - if (logEntriesCache == null) { - logEntriesCache = new LogEntryCache(); - cacheReference = new SoftReference(logEntriesCache); - } - monitor.beginTask(CVSUIMessages.CVSChangeSetCollector_4, 100 * projectMapping.size()); - monitor.setTaskName(CVSUIMessages.CVSChangeSetCollector_4); - for (Iterator iter = projectMapping.values().iterator(); iter.hasNext();) { - SyncInfoSet set = (SyncInfoSet) iter.next(); - Policy.checkCanceled(monitor); - fetchLogEntries(logEntriesCache, set, Policy.subMonitorFor(monitor, 90)); - fireFetchedNotification(logEntriesCache, set, Policy.subMonitorFor(monitor, 10)); - } - } finally { - // Clear the fetches even if we were cancelled. - // Restarting will need to re-request all infos - fetches.clear(); - monitor.done(); - } - return true; - } + // Override to snure that queues by this handler are serialized + synchronized(queueLock) { + Job job = getEventHandlerJob(); + if (job.getState() == Job.NONE) { + job.setSystem(event.getType() != FETCH_REQUEST); + } + super.queueEvent(event, front); + } + } + + /* + * Method invoked during event dispatch to fetch log entries + */ + private boolean processQueuedFetches(IProgressMonitor monitor) { + if (fetches.isEmpty()) return false; + try { + // Now perform the fetching + Map projectMapping = getFetchesByProject(); + if (projectMapping.isEmpty()) return true; + LogEntryCache logEntriesCache = (LogEntryCache)cacheReference.get(); + if (logEntriesCache == null) { + logEntriesCache = new LogEntryCache(); + cacheReference = new SoftReference(logEntriesCache); + } + monitor.beginTask(CVSUIMessages.CVSChangeSetCollector_4, 100 * projectMapping.size()); + monitor.setTaskName(CVSUIMessages.CVSChangeSetCollector_4); + for (Iterator iter = projectMapping.values().iterator(); iter.hasNext();) { + SyncInfoSet set = (SyncInfoSet) iter.next(); + Policy.checkCanceled(monitor); + fetchLogEntries(logEntriesCache, set, Policy.subMonitorFor(monitor, 90)); + fireFetchedNotification(logEntriesCache, set, Policy.subMonitorFor(monitor, 10)); + } + } finally { + // Clear the fetches even if we were cancelled. + // Restarting will need to re-request all infos + fetches.clear(); + monitor.done(); + } + return true; + } - private void fireFetchedNotification(LogEntryCache logEntriesCache, SyncInfoSet set, IProgressMonitor monitor) { - if (listener != null) { - listener.logEntriesFetched(set, logEntriesCache, monitor); - } - } + private void fireFetchedNotification(LogEntryCache logEntriesCache, SyncInfoSet set, IProgressMonitor monitor) { + if (listener != null) { + listener.logEntriesFetched(set, logEntriesCache, monitor); + } + } - /* - * Return a map of IProject to SyncInfoSet as that is how entries are fetched. - * The set for each project includes all infos from the original set. - * This is one so that the completion notification contains all infos - * including those were a fetch was not required either because the - * entry was already cached or the resource has no history. - */ - private Map getFetchesByProject() { + /* + * Return a map of IProject to SyncInfoSet as that is how entries are fetched. + * The set for each project includes all infos from the original set. + * This is one so that the completion notification contains all infos + * including those were a fetch was not required either because the + * entry was already cached or the resource has no history. + */ + private Map getFetchesByProject() { Map<IProject, SyncInfoSet> result = new HashMap<>(); - for (Iterator iter = fetches.iterator(); iter.hasNext();) { - FetchRequest request = (FetchRequest) iter.next(); - SyncInfo[] infos = request.getInfos(); - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - IProject project = info.getLocal().getProject(); - SyncInfoSet infoSet = result.get(project); - if (infoSet == null) { - infoSet = new SyncInfoSet(); - result.put(project, infoSet); - } - infoSet.add(info); - } - } - return result; - } + for (Iterator iter = fetches.iterator(); iter.hasNext();) { + FetchRequest request = (FetchRequest) iter.next(); + SyncInfo[] infos = request.getInfos(); + for (int i = 0; i < infos.length; i++) { + SyncInfo info = infos[i]; + IProject project = info.getLocal().getProject(); + SyncInfoSet infoSet = result.get(project); + if (infoSet == null) { + infoSet = new SyncInfoSet(); + result.put(project, infoSet); + } + infoSet.add(info); + } + } + return result; + } - private boolean isFetchRequired(SyncInfo info) { - // We only need to fetch if we don't have the log entry already - // and the change is a remote change - return info.getLocal().getType() == IResource.FILE && !isLogEntryCached(info) && isRemoteChange(info); - - } - + private boolean isFetchRequired(SyncInfo info) { + // We only need to fetch if we don't have the log entry already + // and the change is a remote change + return info.getLocal().getType() == IResource.FILE && !isLogEntryCached(info) && isRemoteChange(info); + + } + /* - * Return whether the given SyncInfo is cached. If there is - * an info for the resource that does not match the given info, - * it is removed and false is returned. - */ - private boolean isLogEntryCached(SyncInfo info) { - SyncInfo collectedInfo = collectedInfos.getSyncInfo(info.getLocal()); - if (collectedInfo != null && !collectedInfo.equals(info)) { - remove(collectedInfo); - collectedInfo = null; - } - return collectedInfo != null; - } + * Return whether the given SyncInfo is cached. If there is + * an info for the resource that does not match the given info, + * it is removed and false is returned. + */ + private boolean isLogEntryCached(SyncInfo info) { + SyncInfo collectedInfo = collectedInfos.getSyncInfo(info.getLocal()); + if (collectedInfo != null && !collectedInfo.equals(info)) { + remove(collectedInfo); + collectedInfo = null; + } + return collectedInfo != null; + } - /* + /* * Return if this sync info should be considered as part of a remote change * meaning that it can be placed inside an incoming commit set (i.e. the * set is determined using the comments from the log entry of the file). @@ -518,136 +518,136 @@ public class LogEntryCacheUpdateHandler extends BackgroundEventHandler { if (info.getRemote() != null) return true; ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)info.getLocal()); try { - return file.getSyncBytes() != null; - } catch (CVSException e) { - // Log the error and exclude the file from consideration - CVSUIPlugin.log(e); - return false; - } - } - - /* - * Fetch the log entries for the info in the given set - */ - private void fetchLogEntries(LogEntryCache logEntriesCache, SyncInfoSet set, IProgressMonitor monitor) { - try { - if (subscriber instanceof CVSCompareSubscriber) { - CVSCompareSubscriber compareSubscriber = (CVSCompareSubscriber)subscriber; - fetchLogEntries(logEntriesCache, compareSubscriber, set, monitor); - } else { - // Run the log command once with no tags - fetchLogs(logEntriesCache, set, null, null, monitor); - } - } catch (CVSException e) { - handleException(e); - } catch (InterruptedException e) { - throw new OperationCanceledException(); - } - - } - - private void fetchLogEntries(LogEntryCache logEntriesCache, CVSCompareSubscriber compareSubscriber, SyncInfoSet set, IProgressMonitor monitor) throws CVSException, InterruptedException { - Map localTagMap = getLocalTagMap(set); - monitor.beginTask(null, 100 * localTagMap.size()); - for (Iterator iter = localTagMap.keySet().iterator(); iter.hasNext();) { - CVSTag localTag = (CVSTag) iter.next(); - fetchLogEntries(logEntriesCache, compareSubscriber, set, localTag, Policy.subMonitorFor(monitor, 100)); - } - Policy.checkCanceled(monitor); - monitor.done(); - } + return file.getSyncBytes() != null; + } catch (CVSException e) { + // Log the error and exclude the file from consideration + CVSUIPlugin.log(e); + return false; + } + } + + /* + * Fetch the log entries for the info in the given set + */ + private void fetchLogEntries(LogEntryCache logEntriesCache, SyncInfoSet set, IProgressMonitor monitor) { + try { + if (subscriber instanceof CVSCompareSubscriber) { + CVSCompareSubscriber compareSubscriber = (CVSCompareSubscriber)subscriber; + fetchLogEntries(logEntriesCache, compareSubscriber, set, monitor); + } else { + // Run the log command once with no tags + fetchLogs(logEntriesCache, set, null, null, monitor); + } + } catch (CVSException e) { + handleException(e); + } catch (InterruptedException e) { + throw new OperationCanceledException(); + } + + } + + private void fetchLogEntries(LogEntryCache logEntriesCache, CVSCompareSubscriber compareSubscriber, SyncInfoSet set, IProgressMonitor monitor) throws CVSException, InterruptedException { + Map localTagMap = getLocalTagMap(set); + monitor.beginTask(null, 100 * localTagMap.size()); + for (Iterator iter = localTagMap.keySet().iterator(); iter.hasNext();) { + CVSTag localTag = (CVSTag) iter.next(); + fetchLogEntries(logEntriesCache, compareSubscriber, set, localTag, Policy.subMonitorFor(monitor, 100)); + } + Policy.checkCanceled(monitor); + monitor.done(); + } - /* - * Return the resources grouped by the tag found in the - * workspace. The map is CVSTag->SyncInfoSet - */ - private Map getLocalTagMap(SyncInfoSet set) { + /* + * Return the resources grouped by the tag found in the + * workspace. The map is CVSTag->SyncInfoSet + */ + private Map getLocalTagMap(SyncInfoSet set) { Map<CVSTag, SyncInfoSet> result = new HashMap<>(); - for (Iterator iter = set.iterator(); iter.hasNext();) { - SyncInfo info = (SyncInfo) iter.next(); - CVSTag tag = getLocalTag(info); - SyncInfoSet tagSet = result.get(tag); - if (tagSet == null) { - tagSet = new SyncInfoSet(); - result.put(tag, tagSet); - } - tagSet.add(info); - } - return result; - } + for (Iterator iter = set.iterator(); iter.hasNext();) { + SyncInfo info = (SyncInfo) iter.next(); + CVSTag tag = getLocalTag(info); + SyncInfoSet tagSet = result.get(tag); + if (tagSet == null) { + tagSet = new SyncInfoSet(); + result.put(tag, tagSet); + } + tagSet.add(info); + } + return result; + } - private CVSTag getLocalTag(SyncInfo syncInfo) { + private CVSTag getLocalTag(SyncInfo syncInfo) { try { - IResource local = syncInfo.getLocal(); - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(local); - CVSTag tag = null; - if(cvsResource.isFolder()) { - FolderSyncInfo info = ((ICVSFolder)cvsResource).getFolderSyncInfo(); - if(info != null) { - tag = info.getTag(); - } - if (tag != null && tag.getType() == CVSTag.BRANCH) { - tag = Util.getAccurateFolderTag(local, tag); - } - } else { - tag = CVSAction.getAccurateFileTag(cvsResource); - } - if(tag == null) { - tag = new CVSTag(); - } - return tag; - } catch (CVSException e) { - CVSUIPlugin.log(e); - return new CVSTag(); - } - } + IResource local = syncInfo.getLocal(); + ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(local); + CVSTag tag = null; + if(cvsResource.isFolder()) { + FolderSyncInfo info = ((ICVSFolder)cvsResource).getFolderSyncInfo(); + if(info != null) { + tag = info.getTag(); + } + if (tag != null && tag.getType() == CVSTag.BRANCH) { + tag = Util.getAccurateFolderTag(local, tag); + } + } else { + tag = CVSAction.getAccurateFileTag(cvsResource); + } + if(tag == null) { + tag = new CVSTag(); + } + return tag; + } catch (CVSException e) { + CVSUIPlugin.log(e); + return new CVSTag(); + } + } - private void fetchLogEntries(LogEntryCache logEntriesCache, CVSCompareSubscriber compareSubscriber, SyncInfoSet set, CVSTag localTag, IProgressMonitor monitor) throws CVSException, InterruptedException { - if (compareSubscriber.isMultipleTagComparison()) { - Map rootToInfoMap = getRootToInfoMap(compareSubscriber, set); - monitor.beginTask(null, 100 * rootToInfoMap.size()); - for (Iterator iterator = rootToInfoMap.keySet().iterator(); iterator.hasNext();) { - IResource root = (IResource) iterator.next(); - Policy.checkCanceled(monitor); - fetchLogs(logEntriesCache, set, localTag, compareSubscriber.getTag(root), Policy.subMonitorFor(monitor, 100)); - } - monitor.done(); - } else { - Policy.checkCanceled(monitor); - fetchLogs(logEntriesCache, set, localTag, compareSubscriber.getTag(), monitor); - } - } + private void fetchLogEntries(LogEntryCache logEntriesCache, CVSCompareSubscriber compareSubscriber, SyncInfoSet set, CVSTag localTag, IProgressMonitor monitor) throws CVSException, InterruptedException { + if (compareSubscriber.isMultipleTagComparison()) { + Map rootToInfoMap = getRootToInfoMap(compareSubscriber, set); + monitor.beginTask(null, 100 * rootToInfoMap.size()); + for (Iterator iterator = rootToInfoMap.keySet().iterator(); iterator.hasNext();) { + IResource root = (IResource) iterator.next(); + Policy.checkCanceled(monitor); + fetchLogs(logEntriesCache, set, localTag, compareSubscriber.getTag(root), Policy.subMonitorFor(monitor, 100)); + } + monitor.done(); + } else { + Policy.checkCanceled(monitor); + fetchLogs(logEntriesCache, set, localTag, compareSubscriber.getTag(), monitor); + } + } - private Map getRootToInfoMap(CVSCompareSubscriber compareSubscriber, SyncInfoSet set) { + private Map getRootToInfoMap(CVSCompareSubscriber compareSubscriber, SyncInfoSet set) { Map<IResource, SyncInfoSet> rootToInfosMap = new HashMap<>(); - IResource[] roots = compareSubscriber.roots(); - for (Iterator iter = set.iterator(); iter.hasNext();) { - SyncInfo info = (SyncInfo) iter.next(); - IPath localPath = info.getLocal().getFullPath(); - for (int j = 0; j < roots.length; j++) { - IResource resource = roots[j]; - if (resource.getFullPath().isPrefixOf(localPath)) { - SyncInfoSet infoList = rootToInfosMap.get(resource); - if (infoList == null) { - infoList = new SyncInfoSet(); - rootToInfosMap.put(resource, infoList); - } - infoList.add(info); - break; // out of inner loop - } - } - - } - return rootToInfosMap; - } + IResource[] roots = compareSubscriber.roots(); + for (Iterator iter = set.iterator(); iter.hasNext();) { + SyncInfo info = (SyncInfo) iter.next(); + IPath localPath = info.getLocal().getFullPath(); + for (int j = 0; j < roots.length; j++) { + IResource resource = roots[j]; + if (resource.getFullPath().isPrefixOf(localPath)) { + SyncInfoSet infoList = rootToInfosMap.get(resource); + if (infoList == null) { + infoList = new SyncInfoSet(); + rootToInfosMap.put(resource, infoList); + } + infoList.add(info); + break; // out of inner loop + } + } + + } + return rootToInfosMap; + } - private void fetchLogs(LogEntryCache logEntriesCache, SyncInfoSet set, CVSTag localTag, CVSTag remoteTag, IProgressMonitor monitor) throws CVSException, InterruptedException { - ICVSRemoteResource[] remoteResources = getRemotesToFetch(set.getSyncInfos()); - if (remoteResources.length > 0) { + private void fetchLogs(LogEntryCache logEntriesCache, SyncInfoSet set, CVSTag localTag, CVSTag remoteTag, IProgressMonitor monitor) throws CVSException, InterruptedException { + ICVSRemoteResource[] remoteResources = getRemotesToFetch(set.getSyncInfos()); + if (remoteResources.length > 0) { RemoteLogOperation logOperation = new RemoteLogOperation(getConfiguration().getSite().getPart(), remoteResources, localTag, remoteTag, logEntriesCache); logOperation.execute(monitor); - } - collectedInfos.addAll(set); + } + collectedInfos.addAll(set); } private ICVSRemoteResource[] getRemotesToFetch(SyncInfo[] infos) { @@ -664,14 +664,14 @@ public class LogEntryCacheUpdateHandler extends BackgroundEventHandler { return remotes.toArray(new ICVSRemoteResource[remotes.size()]); } - /** - * Stop any current fetch in process. - */ - public void stopFetching() { - try { - getEventHandlerJob().cancel(); - getEventHandlerJob().join(); - } catch (InterruptedException e) { - } - } + /** + * Stop any current fetch in process. + */ + public void stopFetching() { + try { + getEventHandlerJob().cancel(); + getEventHandlerJob().join(); + } catch (InterruptedException e) { + } + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java index e688683da..d8eeee466 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/MergeSynchronizeParticipant.java @@ -266,10 +266,10 @@ public class MergeSynchronizeParticipant extends CVSParticipant { protected String getShortTaskName() { return CVSUIMessages.Participant_merging; } - - @Override + + @Override protected CVSChangeSetCapability createChangeSetCapability() { - // See bug 84561 for a description of the problems with Merge Change Sets - return null; - } + // See bug 84561 for a description of the problems with Merge Change Sets + return null; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java index 0973d88f7..c9a670084 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/OpenChangeSetAction.java @@ -37,181 +37,181 @@ import com.ibm.icu.text.DateFormat; class OpenChangeSetAction extends SynchronizeModelAction { - protected OpenChangeSetAction(ISynchronizePageConfiguration configuration) { - super(CVSUIMessages.OpenCommitSetAction_20, configuration); - } - - @Override + protected OpenChangeSetAction(ISynchronizePageConfiguration configuration) { + super(CVSUIMessages.OpenCommitSetAction_20, configuration); + } + + @Override protected FastSyncInfoFilter getSyncInfoFilter() { - return new AndSyncInfoFilter(new FastSyncInfoFilter[] { - new FastSyncInfoFilter() { - @Override + return new AndSyncInfoFilter(new FastSyncInfoFilter[] { + new FastSyncInfoFilter() { + @Override public boolean select(SyncInfo info) { - return info.getLocal().getType() == IResource.FILE; - } - }, - new OrSyncInfoFilter(new FastSyncInfoFilter[] { - new SyncInfoDirectionFilter(new int[] { SyncInfo.INCOMING, SyncInfo.CONFLICTING }), - new FastSyncInfoFilter() { - @Override + return info.getLocal().getType() == IResource.FILE; + } + }, + new OrSyncInfoFilter(new FastSyncInfoFilter[] { + new SyncInfoDirectionFilter(new int[] { SyncInfo.INCOMING, SyncInfo.CONFLICTING }), + new FastSyncInfoFilter() { + @Override public boolean select(SyncInfo info) { - return !info.getComparator().isThreeWay(); - } - } - }) - }); - } - - private ChangeSet getChangeSet(IStructuredSelection selection) { - // First, check to see if a change set is selected directly - if (selection.size() == 1) { - Object o = selection.getFirstElement(); - if (o instanceof IAdaptable) { - ChangeSet set = ((IAdaptable)o).getAdapter(ChangeSet.class); - if (set != null) - return set; - } - } - // Failing that, check to see if all the selected elements and their childen are in the same change set - return getChangeSet(selection.toArray()); - } - - private ChangeSet getChangeSet(Object[] elements) { - ChangeSet foundSet = null; - for (int i = 0; i < elements.length; i++) { - Object object = elements[i]; - ChangeSet set = getChangeSet((ISynchronizeModelElement)object); - if (set == null) return null; - if (foundSet == null) { - foundSet = set; - } else if (foundSet != set) { - return null; - } - } - return foundSet; - } - - private ChangeSet getChangeSet(ISynchronizeModelElement element) { - if (element == null) return null; - if (element instanceof IAdaptable) { - ChangeSet set = ((IAdaptable)element).getAdapter(ChangeSet.class); - if (set != null) - return set; - } - return getChangeSet((ISynchronizeModelElement)element.getParent()); - } + return !info.getComparator().isThreeWay(); + } + } + }) + }); + } + + private ChangeSet getChangeSet(IStructuredSelection selection) { + // First, check to see if a change set is selected directly + if (selection.size() == 1) { + Object o = selection.getFirstElement(); + if (o instanceof IAdaptable) { + ChangeSet set = ((IAdaptable)o).getAdapter(ChangeSet.class); + if (set != null) + return set; + } + } + // Failing that, check to see if all the selected elements and their childen are in the same change set + return getChangeSet(selection.toArray()); + } + + private ChangeSet getChangeSet(Object[] elements) { + ChangeSet foundSet = null; + for (int i = 0; i < elements.length; i++) { + Object object = elements[i]; + ChangeSet set = getChangeSet((ISynchronizeModelElement)object); + if (set == null) return null; + if (foundSet == null) { + foundSet = set; + } else if (foundSet != set) { + return null; + } + } + return foundSet; + } + + private ChangeSet getChangeSet(ISynchronizeModelElement element) { + if (element == null) return null; + if (element instanceof IAdaptable) { + ChangeSet set = ((IAdaptable)element).getAdapter(ChangeSet.class); + if (set != null) + return set; + } + return getChangeSet((ISynchronizeModelElement)element.getParent()); + } - @Override + @Override protected boolean updateSelection(IStructuredSelection selection) { - boolean enabled = super.updateSelection(selection); - if (enabled) { - // The selection only contains appropriate files so - // only enable if the selection is contained within a single change set - ChangeSet set = getChangeSet(selection); - return set != null; - } - return false; - } + boolean enabled = super.updateSelection(selection); + if (enabled) { + // The selection only contains appropriate files so + // only enable if the selection is contained within a single change set + ChangeSet set = getChangeSet(selection); + return set != null; + } + return false; + } - @Override + @Override protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { - return new SynchronizeModelOperation(configuration, elements) { - @Override + return new SynchronizeModelOperation(configuration, elements) { + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - SyncInfoSet set = getSyncInfoSet(); - SyncInfo[] infos = set.getSyncInfos(); - if (infos.length > 0) { - ICVSRepositoryLocation location = getLocation(infos[0]); - if (location == null) { - handle(new CVSException(CVSUIMessages.OpenCommitSetAction_21)); - return; - } - CompareTreeBuilder builder = new CompareTreeBuilder(location, null, null); - if (buildTrees(builder, infos)) { - try { - builder.cacheContents(monitor); - builder.openCompareEditor(getConfiguration().getSite().getPart().getSite().getPage(), getCompareTitle(), getCompareToolTip()); - } catch (CVSException e) { - handle(e); - return; - } - } - } - } + SyncInfoSet set = getSyncInfoSet(); + SyncInfo[] infos = set.getSyncInfos(); + if (infos.length > 0) { + ICVSRepositoryLocation location = getLocation(infos[0]); + if (location == null) { + handle(new CVSException(CVSUIMessages.OpenCommitSetAction_21)); + return; + } + CompareTreeBuilder builder = new CompareTreeBuilder(location, null, null); + if (buildTrees(builder, infos)) { + try { + builder.cacheContents(monitor); + builder.openCompareEditor(getConfiguration().getSite().getPart().getSite().getPage(), getCompareTitle(), getCompareToolTip()); + } catch (CVSException e) { + handle(e); + return; + } + } + } + } - private String getCompareToolTip() { - IDiffElement[] elements = getSelectedDiffElements(); - for (int i = 0; i < elements.length; i++) { - IDiffElement element = elements[i]; - while (element != null) { - if (element instanceof ChangeSetDiffNode) { - return ((ChangeSetDiffNode)element).getName(); - } - element = element.getParent(); - } - } - return null; - } - - private String getCompareTitle() { - IDiffElement[] elements = getSelectedDiffElements(); - ChangeSet set = getChangeSet(elements); - if (set instanceof CheckedInChangeSet) { - CheckedInChangeSet cics = (CheckedInChangeSet)set; - String date = DateFormat.getDateTimeInstance().format(cics.getDate()); - return NLS.bind(CVSUIMessages.OpenChangeSetAction_0, new String[] {cics.getAuthor(), date}); - } - return CVSUIMessages.OpenChangeSetAction_1; - } + private String getCompareToolTip() { + IDiffElement[] elements = getSelectedDiffElements(); + for (int i = 0; i < elements.length; i++) { + IDiffElement element = elements[i]; + while (element != null) { + if (element instanceof ChangeSetDiffNode) { + return ((ChangeSetDiffNode)element).getName(); + } + element = element.getParent(); + } + } + return null; + } + + private String getCompareTitle() { + IDiffElement[] elements = getSelectedDiffElements(); + ChangeSet set = getChangeSet(elements); + if (set instanceof CheckedInChangeSet) { + CheckedInChangeSet cics = (CheckedInChangeSet)set; + String date = DateFormat.getDateTimeInstance().format(cics.getDate()); + return NLS.bind(CVSUIMessages.OpenChangeSetAction_0, new String[] {cics.getAuthor(), date}); + } + return CVSUIMessages.OpenChangeSetAction_1; + } - private ICVSRepositoryLocation getLocation(SyncInfo info) { - IResourceVariant remote = info.getRemote(); - if (remote == null) { - remote = info.getBase(); - } - if (remote != null) { - return ((ICVSRemoteResource)remote).getRepository(); - } - return null; - } + private ICVSRepositoryLocation getLocation(SyncInfo info) { + IResourceVariant remote = info.getRemote(); + if (remote == null) { + remote = info.getBase(); + } + if (remote != null) { + return ((ICVSRemoteResource)remote).getRepository(); + } + return null; + } - /* - * Build the trees that will be compared - */ - private boolean buildTrees(CompareTreeBuilder builder, SyncInfo[] infos) { - for (int i = 0; i < infos.length; i++) { - SyncInfo info = infos[i]; - IResourceVariant remote = info.getRemote(); - if (remote == null) { - IResourceVariant predecessor = info.getBase(); - if (predecessor instanceof ICVSRemoteFile) { - builder.addToTrees((ICVSRemoteFile)predecessor, null); - } - } else if (remote instanceof ICVSRemoteFile) { - try { - ICVSRemoteFile predecessor = getImmediatePredecessor(remote); - builder.addToTrees(predecessor, (ICVSRemoteFile)remote); - } catch (TeamException e) { - handle(e); - return false; - } - } - } - return true; - } - }; - } + /* + * Build the trees that will be compared + */ + private boolean buildTrees(CompareTreeBuilder builder, SyncInfo[] infos) { + for (int i = 0; i < infos.length; i++) { + SyncInfo info = infos[i]; + IResourceVariant remote = info.getRemote(); + if (remote == null) { + IResourceVariant predecessor = info.getBase(); + if (predecessor instanceof ICVSRemoteFile) { + builder.addToTrees((ICVSRemoteFile)predecessor, null); + } + } else if (remote instanceof ICVSRemoteFile) { + try { + ICVSRemoteFile predecessor = getImmediatePredecessor(remote); + builder.addToTrees(predecessor, (ICVSRemoteFile)remote); + } catch (TeamException e) { + handle(e); + return false; + } + } + } + return true; + } + }; + } - private ICVSRemoteFile getImmediatePredecessor(IResourceVariant remote) throws TeamException { - CVSChangeSetCollector changeSetCollector = getChangeSetCollector(); - if (changeSetCollector != null) { - return changeSetCollector.getImmediatePredecessor((ICVSRemoteFile)remote); - } - return null; - } + private ICVSRemoteFile getImmediatePredecessor(IResourceVariant remote) throws TeamException { + CVSChangeSetCollector changeSetCollector = getChangeSetCollector(); + if (changeSetCollector != null) { + return changeSetCollector.getImmediatePredecessor((ICVSRemoteFile)remote); + } + return null; + } - private CVSChangeSetCollector getChangeSetCollector() { - return (CVSChangeSetCollector)getConfiguration().getProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR); - } + private CVSChangeSetCollector getChangeSetCollector() { + return (CVSChangeSetCollector)getConfiguration().getProperty(CVSChangeSetCollector.CVS_CHECKED_IN_COLLECTOR); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java index 284a1923b..c12a06936 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java @@ -50,15 +50,15 @@ public class RefreshDirtyStateOperation extends CVSSubscriberOperation { protected void runWithProjectRule(IProject project, SyncInfoSet set, IProgressMonitor monitor) throws TeamException { final SyncInfo[] infos = set.getSyncInfos(); if (infos.length == 0) return; - monitor.beginTask(null, 200); - ensureBaseContentsCached(project, infos, Policy.subMonitorFor(monitor, 100)); - performCleanTimestamps(project, infos, monitor); - monitor.done(); + monitor.beginTask(null, 200); + ensureBaseContentsCached(project, infos, Policy.subMonitorFor(monitor, 100)); + performCleanTimestamps(project, infos, monitor); + monitor.done(); } private void performCleanTimestamps(IProject project, final SyncInfo[] infos, IProgressMonitor monitor) throws CVSException { ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); - final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); + final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false); folder.run(monitor1 -> { monitor1.beginTask(null, infos.length * 100); for (int i = 0; i < infos.length; i++) { @@ -116,9 +116,9 @@ public class RefreshDirtyStateOperation extends CVSSubscriberOperation { } catch (InterruptedException e) { throw new OperationCanceledException(); } - } - - @Override + } + + @Override protected String getErrorTitle() { return CVSUIMessages.RefreshDirtyStateOperation_0; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java index 949518018..67f774500 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitAction.java @@ -50,34 +50,34 @@ public class WorkspaceCommitAction extends CVSParticipantAction { protected SynchronizeModelOperation getSubscriberOperation(ISynchronizePageConfiguration configuration, IDiffElement[] elements) { return new WorkspaceCommitOperation(configuration, elements, false /* override */); } - - @Override + + @Override public void runOperation() { - final SyncInfoSet set = getSyncInfoSet(); - final Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - try { - // Include the subscriber operation as a job listener so that the busy feedback for the - // commit will appear in the synchronize view - CommitWizard.run(shell, set, getSubscriberOperation(getConfiguration(), getFilteredDiffElements())); - } catch (CVSException e) { - CVSUIPlugin.log(e); - } - } + final SyncInfoSet set = getSyncInfoSet(); + final Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + try { + // Include the subscriber operation as a job listener so that the busy feedback for the + // commit will appear in the synchronize view + CommitWizard.run(shell, set, getSubscriberOperation(getConfiguration(), getFilteredDiffElements())); + } catch (CVSException e) { + CVSUIPlugin.log(e); + } + } - /* - * Return the selected SyncInfo for which this action is enabled. - * - * @return the selected SyncInfo for which this action is enabled. - */ - private SyncInfoSet getSyncInfoSet() { - IDiffElement [] elements= getFilteredDiffElements(); - SyncInfoSet filtered = new SyncInfoSet(); - for (int i = 0; i < elements.length; i++) { - IDiffElement e = elements[i]; - if (e instanceof SyncInfoModelElement) { - filtered.add(((SyncInfoModelElement)e).getSyncInfo()); - } - } - return filtered; - } + /* + * Return the selected SyncInfo for which this action is enabled. + * + * @return the selected SyncInfo for which this action is enabled. + */ + private SyncInfoSet getSyncInfoSet() { + IDiffElement [] elements= getFilteredDiffElements(); + SyncInfoSet filtered = new SyncInfoSet(); + for (int i = 0; i < elements.length; i++) { + IDiffElement e = elements[i]; + if (e instanceof SyncInfoModelElement) { + filtered.add(((SyncInfoModelElement)e).getSyncInfo()); + } + } + return filtered; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java index 1cb5b6796..87dd5dcc2 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceCommitOperation.java @@ -270,37 +270,37 @@ public class WorkspaceCommitOperation extends CVSSubscriberOperation { * @return the comment, or null to cancel */ protected String promptForComment(RepositoryManager manager, IResource[] resourcesToCommit) { - String proposedComment = getProposedComment(resourcesToCommit); + String proposedComment = getProposedComment(resourcesToCommit); return manager.promptForComment(getShell(), resourcesToCommit, proposedComment); } - private String getProposedComment(IResource[] resourcesToCommit) { - StringBuffer comment = new StringBuffer(); - ChangeSet[] sets = CVSUIPlugin.getPlugin().getChangeSetManager().getSets(); - Arrays.sort(sets, new ChangeSetComparator()); - int numMatchedSets = 0; - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (containsOne(set, resourcesToCommit)) { - if(numMatchedSets > 0) comment.append(System.getProperty("line.separator")); //$NON-NLS-1$ - comment.append(set.getComment()); - numMatchedSets++; - } - } - return comment.toString(); - } - - private boolean containsOne(ChangeSet set, IResource[] resourcesToCommit) { - for (int j = 0; j < resourcesToCommit.length; j++) { - IResource resource = resourcesToCommit[j]; - if (set.contains(resource)) { - return true; - } - } - return false; - } + private String getProposedComment(IResource[] resourcesToCommit) { + StringBuffer comment = new StringBuffer(); + ChangeSet[] sets = CVSUIPlugin.getPlugin().getChangeSetManager().getSets(); + Arrays.sort(sets, new ChangeSetComparator()); + int numMatchedSets = 0; + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; + if (containsOne(set, resourcesToCommit)) { + if(numMatchedSets > 0) comment.append(System.getProperty("line.separator")); //$NON-NLS-1$ + comment.append(set.getComment()); + numMatchedSets++; + } + } + return comment.toString(); + } + + private boolean containsOne(ChangeSet set, IResource[] resourcesToCommit) { + for (int j = 0; j < resourcesToCommit.length; j++) { + IResource resource = resourcesToCommit[j]; + if (set.contains(resource)) { + return true; + } + } + return false; + } - protected IResource[] promptForResourcesToBeAdded(RepositoryManager manager, IResource[] unadded) { + protected IResource[] promptForResourcesToBeAdded(RepositoryManager manager, IResource[] unadded) { return manager.promptForResourcesToBeAdded(getShell(), unadded); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java index ec699627e..e0f53fc75 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/WorkspaceSynchronizeParticipant.java @@ -55,7 +55,7 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa public static final String CONTEXT_MENU_CONTRIBUTION_GROUP_3 = "context_group_3"; //$NON-NLS-1$ public static final String CONTEXT_MENU_CONTRIBUTION_GROUP_4 = "context_group_4"; //$NON-NLS-1$ - private WorkspaceChangeSetCapability capability; + private WorkspaceChangeSetCapability capability; /** * CVS workspace action contribution @@ -145,39 +145,39 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa } public class WorkspaceChangeSetCapability extends CVSChangeSetCapability { - @Override + @Override public ActiveChangeSet createChangeSet(ISynchronizePageConfiguration configuration, IDiff[] infos) { - ActiveChangeSet set = getActiveChangeSetManager().createSet(CVSUIMessages.WorkspaceChangeSetCapability_1, new IDiff[0]); + ActiveChangeSet set = getActiveChangeSetManager().createSet(CVSUIMessages.WorkspaceChangeSetCapability_1, new IDiff[0]); CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, getResources(infos), CommitSetDialog.NEW); dialog.open(); if (dialog.getReturnCode() != Window.OK) return null; set.add(infos); return set; - } + } - private IResource[] getResources(IDiff[] diffs) { + private IResource[] getResources(IDiff[] diffs) { Set<IResource> result = new HashSet<>(); - for (int i = 0; i < diffs.length; i++) { + for (int i = 0; i < diffs.length; i++) { IDiff diff = diffs[i]; IResource resource = ResourceDiffTree.getResourceFor(diff); if (resource != null) result.add(resource); } - return result.toArray(new IResource[result.size()]); - } - - @Override + return result.toArray(new IResource[result.size()]); + } + + @Override public void editChangeSet(ISynchronizePageConfiguration configuration, ActiveChangeSet set) { - CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, set.getResources(), CommitSetDialog.EDIT); + CommitSetDialog dialog = new CommitSetDialog(configuration.getSite().getShell(), set, set.getResources(), CommitSetDialog.EDIT); dialog.open(); if (dialog.getReturnCode() != Window.OK) return; // Nothing to do here as the set was updated by the dialog - } + } - @Override + @Override public ActiveChangeSetManager getActiveChangeSetManager() { - return CVSUIPlugin.getPlugin().getChangeSetManager(); - } + return CVSUIPlugin.getPlugin().getChangeSetManager(); + } } /** @@ -285,7 +285,7 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa } protected ILabelDecorator getLabelDecorator(ISynchronizePageConfiguration configuration) { - return new CVSParticipantLabelDecorator(configuration); + return new CVSParticipantLabelDecorator(configuration); } @Override @@ -293,36 +293,36 @@ public class WorkspaceSynchronizeParticipant extends ScopableSubscriberParticipa return TeamUI.getSynchronizeManager().getParticipantDescriptor(ID); } - @Override + @Override public void prepareCompareInput(ISynchronizeModelElement element, CompareConfiguration config, IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, 100); - CVSParticipant.deriveBaseContentsFromLocal(element, Policy.subMonitorFor(monitor, 10)); - super.prepareCompareInput(element, config, Policy.subMonitorFor(monitor, 80)); - CVSParticipant.updateLabelsForCVS(element, config, Policy.subMonitorFor(monitor, 10)); - monitor.done(); - } - - @Override + monitor.beginTask(null, 100); + CVSParticipant.deriveBaseContentsFromLocal(element, Policy.subMonitorFor(monitor, 10)); + super.prepareCompareInput(element, config, Policy.subMonitorFor(monitor, 80)); + CVSParticipant.updateLabelsForCVS(element, config, Policy.subMonitorFor(monitor, 10)); + monitor.done(); + } + + @Override public PreferencePage[] getPreferencePages() { - return CVSParticipant.addCVSPreferencePages(super.getPreferencePages()); - } - - @Override + return CVSParticipant.addCVSPreferencePages(super.getPreferencePages()); + } + + @Override public ChangeSetCapability getChangeSetCapability() { - if (capability == null) { - capability = new WorkspaceChangeSetCapability(); - } - return capability; - } - - @Override + if (capability == null) { + capability = new WorkspaceChangeSetCapability(); + } + return capability; + } + + @Override protected boolean isViewerContributionsSupported() { - return true; - } + return true; + } - public void refresh(IResource[] resources, IWorkbenchPartSite site) { - refresh(resources, getShortTaskName(), getLongTaskName(resources), site); - } + public void refresh(IResource[] resources, IWorkbenchPartSite site) { + refresh(resources, getShortTaskName(), getLongTaskName(resources), site); + } @Override public void dispose() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/BranchPromptDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/BranchPromptDialog.java index 3ba1123d6..a75a77502 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/BranchPromptDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/BranchPromptDialog.java @@ -44,13 +44,13 @@ public class BranchPromptDialog extends DetailsDialog { private static final int TAG_AREA_HEIGHT_HINT = 200; // widgets; - private TagSource tagSource; - private TagSelectionArea tagArea; - private final IResource[] resources; + private TagSource tagSource; + private TagSelectionArea tagArea; + private final IResource[] resources; public BranchPromptDialog(Shell parentShell, String title, IResource[] resources, boolean allResourcesSticky, String versionName) { super(parentShell, title); - this.resources = resources; + this.resources = resources; this.tagSource = TagSource.create(resources); this.allStickyResources = allResourcesSticky; this.versionName = versionName; @@ -62,14 +62,14 @@ public class BranchPromptDialog extends DetailsDialog { applyDialogFont(composite); initializeDialogUnits(composite); - final int areaWidth= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - - final Label description= SWTUtils.createLabel(composite, allStickyResources ? CVSUIMessages.BranchWizardPage_pageDescriptionVersion : CVSUIMessages.BranchWizardPage_pageDescription); - description.setLayoutData(SWTUtils.createGridData(areaWidth, SWT.DEFAULT, true, false)); - + final int areaWidth= convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); + + final Label description= SWTUtils.createLabel(composite, allStickyResources ? CVSUIMessages.BranchWizardPage_pageDescriptionVersion : CVSUIMessages.BranchWizardPage_pageDescription); + description.setLayoutData(SWTUtils.createGridData(areaWidth, SWT.DEFAULT, true, false)); + final Label name= SWTUtils.createLabel(composite, CVSUIMessages.BranchWizardPage_branchName); - name.setLayoutData(SWTUtils.createGridData(areaWidth, SWT.DEFAULT, true, false)); - + name.setLayoutData(SWTUtils.createGridData(areaWidth, SWT.DEFAULT, true, false)); + branchText = CVSWizardPage.createTextField(composite); branchText.addListener(SWT.Modify, event -> { branchTag = branchText.getText(); @@ -84,11 +84,11 @@ public class BranchPromptDialog extends DetailsDialog { update = true; final Label versionLabel1= SWTUtils.createLabel(composite, CVSUIMessages.BranchWizardPage_specifyVersion); - versionLabel1.setLayoutData(SWTUtils.createGridData(areaWidth, SWT.DEFAULT, true, false)); + versionLabel1.setLayoutData(SWTUtils.createGridData(areaWidth, SWT.DEFAULT, true, false)); final Label versionLabel2= SWTUtils.createLabel(composite, CVSUIMessages.BranchWizardPage_versionName); versionLabel2.setLayoutData(SWTUtils.createGridData(areaWidth, SWT.DEFAULT, true, false)); - + versionText = CVSWizardPage.createTextField(composite); versionText.addListener(SWT.Modify, event -> { versionTag = versionText.getText(); @@ -104,21 +104,21 @@ public class BranchPromptDialog extends DetailsDialog { branchText.setFocus(); } - @Override + @Override protected String getHelpContextId() { - return IHelpContextIds.BRANCH_DIALOG; - } - private void addBranchContentAssist() { - TagSource projectTagSource = LocalProjectTagSource.create(getSeedProject()); - if (projectTagSource != null) - TagContentAssistProcessor.createContentAssistant(branchText, projectTagSource, TagSelectionArea.INCLUDE_BRANCHES); - } + return IHelpContextIds.BRANCH_DIALOG; + } + private void addBranchContentAssist() { + TagSource projectTagSource = LocalProjectTagSource.create(getSeedProject()); + if (projectTagSource != null) + TagContentAssistProcessor.createContentAssistant(branchText, projectTagSource, TagSelectionArea.INCLUDE_BRANCHES); + } - private IProject getSeedProject() { - return resources[0].getProject(); - } + private IProject getSeedProject() { + return resources[0].getProject(); + } - /** + /** * Updates version name */ protected void updateVersionName(String branchName) { @@ -198,9 +198,9 @@ public class BranchPromptDialog extends DetailsDialog { return update; } - @Override + @Override protected boolean isMainGrabVertical() { - return false; - } + return false; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/FilteredTagList.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/FilteredTagList.java index de826969e..1669f2c5e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/FilteredTagList.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/FilteredTagList.java @@ -27,75 +27,75 @@ import org.eclipse.ui.model.IWorkbenchAdapter; */ public class FilteredTagList implements IWorkbenchAdapter, IAdaptable { - private final TagSource tagSource; - private final int[] types; - private StringMatcher matcher; + private final TagSource tagSource; + private final int[] types; + private StringMatcher matcher; - public FilteredTagList(TagSource tagSource, int[] types) { - this.tagSource = tagSource; - this.types = types; - } - - @Override + public FilteredTagList(TagSource tagSource, int[] types) { + this.tagSource = tagSource; + this.types = types; + } + + @Override public Object[] getChildren(Object o) { - CVSTag[] tags = getTags(); + CVSTag[] tags = getTags(); List<TagElement> filtered = new ArrayList<>(); - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - if (select(tag)) { - filtered.add(new TagElement(this, tag)); - } - } - return filtered.toArray(new Object[filtered.size()]); - } + for (int i = 0; i < tags.length; i++) { + CVSTag tag = tags[i]; + if (select(tag)) { + filtered.add(new TagElement(this, tag)); + } + } + return filtered.toArray(new Object[filtered.size()]); + } - private boolean select(CVSTag tag) { - if (matcher == null) return true; - return matcher.match(tag.getName()); - } + private boolean select(CVSTag tag) { + if (matcher == null) return true; + return matcher.match(tag.getName()); + } - private CVSTag[] getTags() { - return tagSource.getTags(types); - } + private CVSTag[] getTags() { + return tagSource.getTags(types); + } - @Override + @Override public ImageDescriptor getImageDescriptor(Object object) { - return null; - } + return null; + } - @Override + @Override public String getLabel(Object o) { - return null; - } + return null; + } - @Override + @Override public Object getParent(Object o) { - return null; - } + return null; + } - @Override + @Override public <T> T getAdapter(Class<T> adapter) { if (adapter == IWorkbenchAdapter.class) return adapter.cast(this); return null; - } - - public void setPattern(String pattern) { - if (!pattern.endsWith("*")) { //$NON-NLS-1$ - pattern += "*"; //$NON-NLS-1$ - } - matcher = new StringMatcher(pattern, true, false); - } + } + + public void setPattern(String pattern) { + if (!pattern.endsWith("*")) { //$NON-NLS-1$ + pattern += "*"; //$NON-NLS-1$ + } + matcher = new StringMatcher(pattern, true, false); + } - public CVSTag[] getMatchingTags() { - CVSTag[] tags = getTags(); + public CVSTag[] getMatchingTags() { + CVSTag[] tags = getTags(); List<CVSTag> filtered = new ArrayList<>(); - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - if (select(tag)) { - filtered.add(tag); - } - } - return filtered.toArray(new CVSTag[filtered.size()]); - } + for (int i = 0; i < tags.length; i++) { + CVSTag tag = tags[i]; + if (select(tag)) { + filtered.add(tag); + } + } + return filtered.toArray(new CVSTag[filtered.size()]); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/LocalProjectTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/LocalProjectTagSource.java index efc2e6e90..b679a7530 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/LocalProjectTagSource.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/LocalProjectTagSource.java @@ -30,96 +30,96 @@ import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; * Tag source that gets its tags from the projects exist in the workspace */ public class LocalProjectTagSource extends TagSource { - - public static TagSource create(IProject seedProject) { - try { - ICVSRemoteFolder seedFolder = ((ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(seedProject)); - ICVSRemoteFolder[] remoteFolders = getProjectRemoteFolders(); - if (remoteFolders.length == 1) { - // There are no other projects to get tags from so return null - return null; - } - return new LocalProjectTagSource(seedFolder, remoteFolders); - } catch (CVSException e) { - // Log and return null - CVSUIPlugin.log(e); - return null; - } - } - - private ICVSRemoteFolder seedFolder; - private ICVSRemoteFolder[] remoteFolders; + + public static TagSource create(IProject seedProject) { + try { + ICVSRemoteFolder seedFolder = ((ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(seedProject)); + ICVSRemoteFolder[] remoteFolders = getProjectRemoteFolders(); + if (remoteFolders.length == 1) { + // There are no other projects to get tags from so return null + return null; + } + return new LocalProjectTagSource(seedFolder, remoteFolders); + } catch (CVSException e) { + // Log and return null + CVSUIPlugin.log(e); + return null; + } + } + + private ICVSRemoteFolder seedFolder; + private ICVSRemoteFolder[] remoteFolders; - private LocalProjectTagSource(ICVSRemoteFolder seedFolder, ICVSRemoteFolder[] remoteFolders) { - this.seedFolder = seedFolder; - this.remoteFolders = remoteFolders; - } + private LocalProjectTagSource(ICVSRemoteFolder seedFolder, ICVSRemoteFolder[] remoteFolders) { + this.seedFolder = seedFolder; + this.remoteFolders = remoteFolders; + } - /* - * Return the list of remote folders for the projects in the workspace mapped to the given repository - */ - private static ICVSRemoteFolder[] getProjectRemoteFolders() { - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + /* + * Return the list of remote folders for the projects in the workspace mapped to the given repository + */ + private static ICVSRemoteFolder[] getProjectRemoteFolders() { + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); List<ICVSRemoteFolder> result = new ArrayList<>(); - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - try { - if (project.isAccessible() && RepositoryProvider.isShared(project)) { - ICVSRemoteFolder remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project); - if (remote != null) { - result.add(remote); - } - } - } catch (CVSException e) { - // Log and continue - CVSUIPlugin.log(e); - } - } - return result.toArray(new ICVSRemoteFolder[result.size()]); - } + for (int i = 0; i < projects.length; i++) { + IProject project = projects[i]; + try { + if (project.isAccessible() && RepositoryProvider.isShared(project)) { + ICVSRemoteFolder remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project); + if (remote != null) { + result.add(remote); + } + } + } catch (CVSException e) { + // Log and continue + CVSUIPlugin.log(e); + } + } + return result.toArray(new ICVSRemoteFolder[result.size()]); + } - @Override + @Override public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - // This tag source should not be refreshed - return new CVSTag[0]; - } + // This tag source should not be refreshed + return new CVSTag[0]; + } - @Override + @Override public ICVSRepositoryLocation getLocation() { - return seedFolder.getRepository(); - } + return seedFolder.getRepository(); + } - @Override + @Override public String getShortDescription() { - return NLS.bind(CVSUIMessages.LocalProjectTagSource_0, new String[] { Integer.toString(remoteFolders.length) }); - } + return NLS.bind(CVSUIMessages.LocalProjectTagSource_0, new String[] { Integer.toString(remoteFolders.length) }); + } - @Override + @Override public void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException { - // Does not commit tags - } + // Does not commit tags + } - @Override + @Override public ICVSResource[] getCVSResources() { - return remoteFolders; - } - - @Override + return remoteFolders; + } + + @Override public CVSTag[] getTags(int type) { - if (type == CVSTag.HEAD || type == BASE) { - return super.getTags(type); - } - // Accumulate the tags for all folders + if (type == CVSTag.HEAD || type == BASE) { + return super.getTags(type); + } + // Accumulate the tags for all folders Set<CVSTag> allTags = new HashSet<>(); - for (int i = 0; i < remoteFolders.length; i++) { - ICVSRemoteFolder folder = remoteFolders[i]; - CVSTag[] tags = SingleFolderTagSource.getTags(folder, type); - allTags.addAll(Arrays.asList(tags)); - } - // Exclude the tags for the seedFolder - CVSTag[] tags = SingleFolderTagSource.getTags(seedFolder, type); - allTags.removeAll(Arrays.asList(tags)); - return allTags.toArray(new CVSTag[allTags.size()]); - } + for (int i = 0; i < remoteFolders.length; i++) { + ICVSRemoteFolder folder = remoteFolders[i]; + CVSTag[] tags = SingleFolderTagSource.getTags(folder, type); + allTags.addAll(Arrays.asList(tags)); + } + // Exclude the tags for the seedFolder + CVSTag[] tags = SingleFolderTagSource.getTags(seedFolder, type); + allTags.removeAll(Arrays.asList(tags)); + return allTags.toArray(new CVSTag[allTags.size()]); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java index 393e4265e..6fd4f1600 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/MultiFolderTagSource.java @@ -32,57 +32,57 @@ import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; */ public class MultiFolderTagSource extends SingleFolderTagSource { - private final ICVSFolder[] folders; + private final ICVSFolder[] folders; - /* package */ MultiFolderTagSource(ICVSFolder[] folders) { - super(folders[0]); - this.folders = folders; - } - - @Override + /* package */ MultiFolderTagSource(ICVSFolder[] folders) { + super(folders[0]); + this.folders = folders; + } + + @Override public String getShortDescription() { - return NLS.bind(CVSUIMessages.MultiFolderTagSource_0, new String[] { Integer.toString(folders.length) }); - } - - @Override + return NLS.bind(CVSUIMessages.MultiFolderTagSource_0, new String[] { Integer.toString(folders.length) }); + } + + @Override public CVSTag[] getTags(int type) { - if (type == CVSTag.HEAD || type == BASE) { - return super.getTags(type); - } + if (type == CVSTag.HEAD || type == BASE) { + return super.getTags(type); + } Set<CVSTag> tags = new HashSet<>(); - for (int i= 0; i < folders.length; i++) { + for (int i= 0; i < folders.length; i++) { tags.addAll(Arrays.asList(getTags(folders[i], type))); } - return tags.toArray(new CVSTag[tags.size()]); - } - - @Override + return tags.toArray(new CVSTag[tags.size()]); + } + + @Override public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { monitor.beginTask("", folders.length); //$NON-NLS-1$ Set<CVSTag> result = new HashSet<>(); - for (int i= 0; i < folders.length; i++) { + for (int i= 0; i < folders.length; i++) { ICVSFolder folder= folders[i]; CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().refreshDefinedTags(folder, bestEffort /* recurse */, true /* notify */, Policy.subMonitorFor(monitor, 1)); result.addAll(Arrays.asList(tags)); } - monitor.done(); - fireChange(); - return result.toArray(new CVSTag[result.size()]); - } - - @Override + monitor.done(); + fireChange(); + return result.toArray(new CVSTag[result.size()]); + } + + @Override public ICVSResource[] getCVSResources() { - return folders; - } - - public ICVSFolder[] getFolders(){ - return folders; - } - - @Override + return folders; + } + + public ICVSFolder[] getFolders(){ + return folders; + } + + @Override public void commit(final CVSTag[] tags, final boolean replace, IProgressMonitor monitor) throws CVSException { try { - final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); + final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); manager.run(monitor1 -> { try { ICVSFolder[] folders = getFolders(); @@ -97,11 +97,11 @@ public class MultiFolderTagSource extends SingleFolderTagSource { throw new InvocationTargetException(e); } }, monitor); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - // Ignore - } - fireChange(); - } + } catch (InvocationTargetException e) { + throw CVSException.wrapException(e); + } catch (InterruptedException e) { + // Ignore + } + fireChange(); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java index 42b58e19d..a469a84b7 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFileTagSource.java @@ -26,7 +26,7 @@ import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; * A tag source for a single ICVSFile */ public class SingleFileTagSource extends TagSource { - + public static CVSTag[] fetchTagsFor(ICVSFile file, IProgressMonitor monitor) throws TeamException { Set<CVSTag> tagSet = new HashSet<>(); ILogEntry[] entries = file.getLogEntries(monitor); @@ -39,51 +39,51 @@ public class SingleFileTagSource extends TagSource { return tagSet.toArray(new CVSTag[tagSet.size()]); } - private ICVSFile file; - private TagSource parentFolderTagSource; - - /* package */ /** - * - */ - public SingleFileTagSource(ICVSFile file) { - this.file = file; - parentFolderTagSource = TagSource.create(new ICVSResource[] { file.getParent() }); - } + private ICVSFile file; + private TagSource parentFolderTagSource; + + /* package */ /** + * + */ + public SingleFileTagSource(ICVSFile file) { + this.file = file; + parentFolderTagSource = TagSource.create(new ICVSResource[] { file.getParent() }); + } - @Override + @Override public CVSTag[] getTags(int type) { - return parentFolderTagSource.getTags(type); - } + return parentFolderTagSource.getTags(type); + } - @Override + @Override public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - CVSTag[] tags = fetchTagsFor(file, monitor); - commit(tags, false, monitor); - fireChange(); - return tags; - } + CVSTag[] tags = fetchTagsFor(file, monitor); + commit(tags, false, monitor); + fireChange(); + return tags; + } - @Override + @Override public ICVSRepositoryLocation getLocation() { RepositoryManager mgr = CVSUIPlugin.getPlugin().getRepositoryManager(); ICVSRepositoryLocation location = mgr.getRepositoryLocationFor(file); return location; - } + } - @Override + @Override public String getShortDescription() { - return file.getName(); - } + return file.getName(); + } - @Override + @Override public void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException { - parentFolderTagSource.commit(tags, replace, monitor); - fireChange(); - } + parentFolderTagSource.commit(tags, replace, monitor); + fireChange(); + } - @Override + @Override public ICVSResource[] getCVSResources() { - return new ICVSResource[] { file }; - } + return new ICVSResource[] { file }; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java index 330ea088f..e9d17f13d 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/SingleFolderTagSource.java @@ -28,57 +28,57 @@ import org.eclipse.ui.PlatformUI; */ public class SingleFolderTagSource extends TagSource { - public static CVSTag[] getTags(ICVSFolder folder, int type) { - if (type == CVSTag.HEAD) - return new CVSTag[] { CVSTag.DEFAULT } ; - return CVSUIPlugin.getPlugin().getRepositoryManager().getKnownTags(folder, type); - } - - private ICVSFolder folder; - - /* package */ SingleFolderTagSource(ICVSFolder folder) { - this.folder = folder; - } + public static CVSTag[] getTags(ICVSFolder folder, int type) { + if (type == CVSTag.HEAD) + return new CVSTag[] { CVSTag.DEFAULT } ; + return CVSUIPlugin.getPlugin().getRepositoryManager().getKnownTags(folder, type); + } + + private ICVSFolder folder; + + /* package */ SingleFolderTagSource(ICVSFolder folder) { + this.folder = folder; + } - @Override + @Override public CVSTag[] getTags(int type) { - if (type == CVSTag.HEAD || type == BASE) { - return super.getTags(type); - } - return getTags(getFolder(), type); - } + if (type == CVSTag.HEAD || type == BASE) { + return super.getTags(type); + } + return getTags(getFolder(), type); + } - /** - * Return the folder the tags are obtained from - * @return the folder the tags are obtained from - */ - public ICVSFolder getFolder() { - return folder; - } + /** + * Return the folder the tags are obtained from + * @return the folder the tags are obtained from + */ + public ICVSFolder getFolder() { + return folder; + } - @Override + @Override public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().refreshDefinedTags(getFolder(), bestEffort /* recurse */, true /* notify */, monitor); - fireChange(); - return tags; - } + CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().refreshDefinedTags(getFolder(), bestEffort /* recurse */, true /* notify */, monitor); + fireChange(); + return tags; + } - @Override + @Override public ICVSRepositoryLocation getLocation() { RepositoryManager mgr = CVSUIPlugin.getPlugin().getRepositoryManager(); ICVSRepositoryLocation location = mgr.getRepositoryLocationFor(getFolder()); return location; - } + } - @Override + @Override public String getShortDescription() { - return getFolder().getName(); - } + return getFolder().getName(); + } - @Override + @Override public void commit(final CVSTag[] tags, final boolean replace, IProgressMonitor monitor) throws CVSException { try { - final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); + final RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); manager.run(monitor1 -> { try { ICVSFolder folder = getFolder(); @@ -91,17 +91,17 @@ public class SingleFolderTagSource extends TagSource { throw new InvocationTargetException(e); } }, monitor); - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } catch (InterruptedException e) { - // Ignore - } - fireChange(); - } + } catch (InvocationTargetException e) { + throw CVSException.wrapException(e); + } catch (InterruptedException e) { + // Ignore + } + fireChange(); + } - @Override + @Override public ICVSResource[] getCVSResources() { - final ICVSResource[][] resources = new ICVSResource[][] { null }; + final ICVSResource[][] resources = new ICVSResource[][] { null }; try { getRunnableContext().run(true, true, monitor -> { try { @@ -112,17 +112,17 @@ public class SingleFolderTagSource extends TagSource { monitor.done(); } }); - return resources[0]; - } catch (InvocationTargetException e) { - CVSUIPlugin.log(CVSException.wrapException(e)); - } catch (InterruptedException e) { - // Ignore - } - return new ICVSResource[] { folder }; - } - - private IRunnableContext getRunnableContext() { - return PlatformUI.getWorkbench().getProgressService(); - } + return resources[0]; + } catch (InvocationTargetException e) { + CVSUIPlugin.log(CVSException.wrapException(e)); + } catch (InterruptedException e) { + // Ignore + } + return new ICVSResource[] { folder }; + } + + private IRunnableContext getRunnableContext() { + return PlatformUI.getWorkbench().getProgressService(); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagAsVersionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagAsVersionDialog.java index 3b46a4526..1aed84c71 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagAsVersionDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagAsVersionDialog.java @@ -33,7 +33,7 @@ import org.eclipse.team.internal.ui.dialogs.DetailsDialog; public class TagAsVersionDialog extends DetailsDialog { - private static final int TAG_AREA_HEIGHT_HINT = 200; + private static final int TAG_AREA_HEIGHT_HINT = 200; private static final int HISTORY_LENGTH = 10; @@ -51,9 +51,9 @@ public class TagAsVersionDialog extends DetailsDialog { private String tagName = ""; //$NON-NLS-1$ private boolean moveTag = false; - private TagSource tagSource; + private TagSource tagSource; - private TagSelectionArea tagArea; + private TagSelectionArea tagArea; public TagAsVersionDialog(Shell parentShell, String title, ITagOperation operation) { super(parentShell, title); @@ -90,10 +90,10 @@ public class TagAsVersionDialog extends DetailsDialog { } - @Override + @Override protected String getHelpContextId() { - return IHelpContextIds.TAG_AS_VERSION_DIALOG; - } + return IHelpContextIds.TAG_AS_VERSION_DIALOG; + } public boolean shouldMoveTag() { return moveTag; @@ -105,11 +105,11 @@ public class TagAsVersionDialog extends DetailsDialog { final PixelConverter converter= SWTUtils.createDialogPixelConverter(parent); final Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DIALOG)); - - final GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.heightHint = TAG_AREA_HEIGHT_HINT; - composite.setLayoutData(gridData); + composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DIALOG)); + + final GridData gridData = new GridData(GridData.FILL_BOTH); + gridData.heightHint = TAG_AREA_HEIGHT_HINT; + composite.setLayoutData(gridData); tagArea = new TagSelectionArea(getShell(), tagSource, TagSelectionArea.INCLUDE_VERSIONS, null); tagArea.setTagAreaLabel(CVSUIMessages.TagAction_existingVersions); @@ -149,7 +149,7 @@ public class TagAsVersionDialog extends DetailsDialog { setPageComplete(message == null); setErrorMessage(message); if (tagArea != null) { - tagArea.setFilter(tagName); + tagArea.setFilter(tagName); } } @@ -171,10 +171,10 @@ public class TagAsVersionDialog extends DetailsDialog { return operation; } - @Override + @Override protected boolean isMainGrabVertical() { - return false; - } + return false; + } protected Combo createDropDownCombo(Composite parent) { Combo combo = new Combo(parent, SWT.DROP_DOWN); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagConfigurationDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagConfigurationDialog.java index cf74e7e98..8ad20ec49 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagConfigurationDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagConfigurationDialog.java @@ -80,9 +80,9 @@ public class TagConfigurationDialog extends TrayDialog { // dialogs settings that are persistent between workbench sessions private IDialogSettings settings; - private final TagSource tagSource; + private final TagSource tagSource; - private final TagSourceWrapper wrappedTagSource; + private final TagSourceWrapper wrappedTagSource; class FileComparator extends ViewerComparator { @Override @@ -103,105 +103,105 @@ public class TagConfigurationDialog extends TrayDialog { */ class TagSourceWrapper extends TagSource { - private final TagSource tagSource; + private final TagSource tagSource; private final List<CVSTag> branches = new ArrayList<>(); private final List<CVSTag> versions = new ArrayList<>(); private final List<CVSTag> dates = new ArrayList<>(); - public TagSourceWrapper(TagSource tagSource) { - this.tagSource = tagSource; - branches.addAll(Arrays.asList(tagSource.getTags(CVSTag.BRANCH))); - versions.addAll(Arrays.asList(tagSource.getTags(CVSTag.VERSION))); - dates.addAll(Arrays.asList(tagSource.getTags(CVSTag.DATE))); - } - - @Override + public TagSourceWrapper(TagSource tagSource) { + this.tagSource = tagSource; + branches.addAll(Arrays.asList(tagSource.getTags(CVSTag.BRANCH))); + versions.addAll(Arrays.asList(tagSource.getTags(CVSTag.VERSION))); + dates.addAll(Arrays.asList(tagSource.getTags(CVSTag.DATE))); + } + + @Override public CVSTag[] getTags(int type) { - if (type == CVSTag.HEAD || type == BASE) { - return super.getTags(type); - } + if (type == CVSTag.HEAD || type == BASE) { + return super.getTags(type); + } List<CVSTag> list = getTagList(type); - if (list != null) - return list.toArray(new CVSTag[list.size()]); - return tagSource.getTags(type); - } + if (list != null) + return list.toArray(new CVSTag[list.size()]); + return tagSource.getTags(type); + } private List<CVSTag> getTagList(int type) { - switch (type) { - case CVSTag.VERSION: - return versions; - case CVSTag.BRANCH: - return branches; - case CVSTag.DATE: - return dates; - } - return null; - } - - @Override + switch (type) { + case CVSTag.VERSION: + return versions; + case CVSTag.BRANCH: + return branches; + case CVSTag.DATE: + return dates; + } + return null; + } + + @Override public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - // The wrapper is never refreshed - return new CVSTag[0]; - } + // The wrapper is never refreshed + return new CVSTag[0]; + } - @Override + @Override public ICVSRepositoryLocation getLocation() { - return tagSource.getLocation(); - } + return tagSource.getLocation(); + } - @Override + @Override public String getShortDescription() { - return tagSource.getShortDescription(); - } + return tagSource.getShortDescription(); + } - public void remove(CVSTag[] tags) { - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - List list = getTagList(tag.getType()); - if (list != null) - list.remove(tag); - } - } + public void remove(CVSTag[] tags) { + for (int i = 0; i < tags.length; i++) { + CVSTag tag = tags[i]; + List list = getTagList(tag.getType()); + if (list != null) + list.remove(tag); + } + } - public void add(CVSTag[] tags) { - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; + public void add(CVSTag[] tags) { + for (int i = 0; i < tags.length; i++) { + CVSTag tag = tags[i]; List<CVSTag> list = getTagList(tag.getType()); - if (list != null) - list.add(tag); - } - } + if (list != null) + list.add(tag); + } + } - public void removeAll() { - versions.clear(); - branches.clear(); - dates.clear(); - } + public void removeAll() { + versions.clear(); + branches.clear(); + dates.clear(); + } - /** - * Remember the state that has been accumulated - * @param monitor - * @throws CVSException - */ - public void commit(IProgressMonitor monitor) throws CVSException { - tagSource.commit(getTags(new int[] { CVSTag.VERSION, CVSTag.BRANCH, CVSTag.DATE }), true /* replace */, monitor); - } + /** + * Remember the state that has been accumulated + * @param monitor + * @throws CVSException + */ + public void commit(IProgressMonitor monitor) throws CVSException { + tagSource.commit(getTags(new int[] { CVSTag.VERSION, CVSTag.BRANCH, CVSTag.DATE }), true /* replace */, monitor); + } - @Override + @Override public void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException { - // Not invoked - } + // Not invoked + } - @Override + @Override public ICVSResource[] getCVSResources() { - return tagSource.getCVSResources(); - } + return tagSource.getCVSResources(); + } } public TagConfigurationDialog(Shell shell, TagSource tagSource) { super(shell); - this.tagSource = tagSource; - wrappedTagSource = new TagSourceWrapper(tagSource); + this.tagSource = tagSource; + wrappedTagSource = new TagSourceWrapper(tagSource); setShellStyle(SWT.CLOSE|SWT.RESIZE|SWT.APPLICATION_MODAL); allowSettingAutoRefreshFiles = getSingleFolder(tagSource, false) != null; IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); @@ -225,8 +225,8 @@ public class TagConfigurationDialog extends TrayDialog { GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; gridLayout.makeColumnsEqualWidth = true; - gridLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - gridLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); + gridLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); + gridLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); shell.setLayout (gridLayout); Composite comp = new Composite(shell, SWT.NULL); @@ -467,7 +467,7 @@ public class TagConfigurationDialog extends TrayDialog { autoRefreshFileList.setFocus(); } }); - PlatformUI.getWorkbench().getHelpSystem().setHelp(autoRefreshFileList, IHelpContextIds.TAG_CONFIGURATION_REFRESHLIST); + PlatformUI.getWorkbench().getHelpSystem().setHelp(autoRefreshFileList, IHelpContextIds.TAG_CONFIGURATION_REFRESHLIST); } Label seperator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); @@ -475,14 +475,14 @@ public class TagConfigurationDialog extends TrayDialog { data.horizontalSpan = 2; seperator.setLayoutData(data); - PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IHelpContextIds.TAG_CONFIGURATION_OVERVIEW); + PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, IHelpContextIds.TAG_CONFIGURATION_OVERVIEW); updateEnablements(); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); return shell; } - private void updateShownTags() { + private void updateShownTags() { final CVSFileElement[] filesSelection = getSelectedFiles(); final Set<CVSTag> tags = new HashSet<>(); if(filesSelection.length!=0) { @@ -576,7 +576,7 @@ public class TagConfigurationDialog extends TrayDialog { tagsToAdd.add(tag); } if (!tagsToAdd.isEmpty()) { - wrappedTagSource.add(tagsToAdd.toArray(new CVSTag[tagsToAdd.size()])); + wrappedTagSource.add(tagsToAdd.toArray(new CVSTag[tagsToAdd.size()])); cvsDefinedTagsTree.refresh(); } } @@ -595,7 +595,7 @@ public class TagConfigurationDialog extends TrayDialog { } } if (!tagsToRemove.isEmpty()) { - wrappedTagSource.remove(tagsToRemove.toArray(new CVSTag[tagsToRemove.size()])); + wrappedTagSource.remove(tagsToRemove.toArray(new CVSTag[tagsToRemove.size()])); cvsDefinedTagsTree.refresh(); cvsDefinedTagsTree.getTree().setFocus(); } @@ -662,16 +662,16 @@ public class TagConfigurationDialog extends TrayDialog { CVSUIPlugin.openError(getShell(), null, null, e); } } - - protected ICVSFolder getSingleFolder(TagSource tagSource, boolean bestEffort) { - if (!bestEffort && tagSource instanceof MultiFolderTagSource) - return null; - if (tagSource instanceof SingleFolderTagSource) - return ((SingleFolderTagSource)tagSource).getFolder(); - return null; - } + + protected ICVSFolder getSingleFolder(TagSource tagSource, boolean bestEffort) { + if (!bestEffort && tagSource instanceof MultiFolderTagSource) + return null; + if (tagSource instanceof SingleFolderTagSource) + return ((SingleFolderTagSource)tagSource).getFolder(); + return null; + } - @Override + @Override protected Point getInitialSize() { int width, height; if(allowSettingAutoRefreshFiles) { @@ -700,7 +700,7 @@ public class TagConfigurationDialog extends TrayDialog { private GridData getStandardButtonData(Button button) { GridData data = new GridData(); data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT); - //don't crop labels with large font + //don't crop labels with large font //int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); //data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); return data; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagContentAssistProcessor.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagContentAssistProcessor.java index 92f71d777..fb8e75424 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagContentAssistProcessor.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagContentAssistProcessor.java @@ -31,16 +31,16 @@ import org.eclipse.ui.contentassist.ContentAssistHandler; */ public class TagContentAssistProcessor implements ISubjectControlContentAssistProcessor { - private FilteredTagList tags; + private FilteredTagList tags; private Map<ImageDescriptor, Image> images = new HashMap<>(); - public static void createContentAssistant(Text text, TagSource tagSource, int includeFlags) { + public static void createContentAssistant(Text text, TagSource tagSource, int includeFlags) { final TagContentAssistProcessor tagContentAssistProcessor = new TagContentAssistProcessor(tagSource, includeFlags); text.addDisposeListener(e -> tagContentAssistProcessor.dispose()); - ContentAssistHandler.createHandlerForText(text, createSubjectContentAssistant(tagContentAssistProcessor)); + ContentAssistHandler.createHandlerForText(text, createSubjectContentAssistant(tagContentAssistProcessor)); } - private static SubjectControlContentAssistant createSubjectContentAssistant(IContentAssistProcessor processor) { + private static SubjectControlContentAssistant createSubjectContentAssistant(IContentAssistProcessor processor) { final SubjectControlContentAssistant contentAssistant= new SubjectControlContentAssistant(); contentAssistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE); @@ -53,86 +53,86 @@ public class TagContentAssistProcessor implements ISubjectControlContentAssistPr return contentAssistant; } - public TagContentAssistProcessor(TagSource tagSource, int includeFlags) { - tags = new FilteredTagList(tagSource, TagSource.convertIncludeFlaqsToTagTypes(includeFlags)); - } - - @Override + public TagContentAssistProcessor(TagSource tagSource, int includeFlags) { + tags = new FilteredTagList(tagSource, TagSource.convertIncludeFlaqsToTagTypes(includeFlags)); + } + + @Override public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) { - Control c = contentAssistSubjectControl.getControl(); - int docLength = contentAssistSubjectControl.getDocument().getLength(); - if (c instanceof Text) { - Text t = (Text)c; - String filter = t.getText(); - tags.setPattern(filter); - CVSTag[] matching = tags.getMatchingTags(); - if (matching.length > 0) { + Control c = contentAssistSubjectControl.getControl(); + int docLength = contentAssistSubjectControl.getDocument().getLength(); + if (c instanceof Text) { + Text t = (Text)c; + String filter = t.getText(); + tags.setPattern(filter); + CVSTag[] matching = tags.getMatchingTags(); + if (matching.length > 0) { List<CompletionProposal> proposals = new ArrayList<>(); - for (int i = 0; i < matching.length; i++) { - CVSTag tag = matching[i]; - String name = tag.getName(); - ImageDescriptor desc = TagElement.getImageDescriptor(tag); - Image image = null; - if (desc != null) { - image = images.get(desc); - if (image == null) { - image = desc.createImage(); - images.put(desc, image); - } - } - CompletionProposal proposal = new CompletionProposal(name, 0, docLength, name.length(), image, name, null, null); - proposals.add(proposal); - } - return proposals.toArray(new ICompletionProposal[proposals.size()]); - } - } - return null; - } + for (int i = 0; i < matching.length; i++) { + CVSTag tag = matching[i]; + String name = tag.getName(); + ImageDescriptor desc = TagElement.getImageDescriptor(tag); + Image image = null; + if (desc != null) { + image = images.get(desc); + if (image == null) { + image = desc.createImage(); + images.put(desc, image); + } + } + CompletionProposal proposal = new CompletionProposal(name, 0, docLength, name.length(), image, name, null, null); + proposals.add(proposal); + } + return proposals.toArray(new ICompletionProposal[proposals.size()]); + } + } + return null; + } - @Override + @Override public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) { - return null; - } + return null; + } - @Override + @Override public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { - Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$ - return null; - } + Assert.isTrue(false, "ITextViewer not supported"); //$NON-NLS-1$ + return null; + } - @Override + @Override public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { - return null; - } + return null; + } - @Override + @Override public char[] getCompletionProposalAutoActivationCharacters() { - return null; - } + return null; + } - @Override + @Override public char[] getContextInformationAutoActivationCharacters() { - return null; - } + return null; + } - @Override + @Override public String getErrorMessage() { - return null; - } + return null; + } - @Override + @Override public IContextInformationValidator getContextInformationValidator() { - return null; - } - + return null; + } + /** - * Dispose of any images created by the assistant - */ - public void dispose() { - for (Iterator iter = images.values().iterator(); iter.hasNext();) { - Image image = (Image) iter.next(); - image.dispose(); - } - } - + * Dispose of any images created by the assistant + */ + public void dispose() { + for (Iterator iter = images.values().iterator(); iter.hasNext();) { + Image image = (Image) iter.next(); + image.dispose(); + } + } + } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagElement.java index 9f7e93454..5604ae0bd 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagElement.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagElement.java @@ -24,18 +24,18 @@ import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement; import org.eclipse.ui.model.IWorkbenchAdapter; public class TagElement implements IWorkbenchAdapter, IAdaptable { - Object parent; + Object parent; CVSTag tag; public static ImageDescriptor getImageDescriptor(CVSTag tag) { - if (tag.getType() == CVSTag.BRANCH || tag.equals(CVSTag.DEFAULT)) { + if (tag.getType() == CVSTag.BRANCH || tag.equals(CVSTag.DEFAULT)) { return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_TAG); } else if (tag.getType() == CVSTag.DATE){ return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_DATE); }else { return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_PROJECT_VERSION); } - } + } /** * @deprecated @@ -46,7 +46,7 @@ public class TagElement implements IWorkbenchAdapter, IAdaptable { this(null, tag); } public TagElement(Object parent, CVSTag tag) { - this.parent = parent; + this.parent = parent; this.tag = tag; } @Override @@ -62,7 +62,7 @@ public class TagElement implements IWorkbenchAdapter, IAdaptable { public ImageDescriptor getImageDescriptor(Object object) { return getImageDescriptor(tag); } - @Override + @Override public String getLabel(Object o) { if(tag.getType() == CVSTag.DATE){ Date date = tag.asDate(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java index 7366075b8..686ffa7ed 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRefreshButtonArea.java @@ -34,69 +34,69 @@ import org.eclipse.ui.PlatformUI; * An area that displays the Refresh and Configure Tags buttons */ public class TagRefreshButtonArea extends DialogArea { - - private TagSource tagSource; - private final Shell shell; - private Button refreshButton; - private IRunnableContext context; + + private TagSource tagSource; + private final Shell shell; + private Button refreshButton; + private IRunnableContext context; private Label fMessageLabel; - private final Listener addDateTagListener; + private final Listener addDateTagListener; - public TagRefreshButtonArea(Shell shell, TagSource tagSource, Listener addDateTagListener) { - this.addDateTagListener = addDateTagListener; - Assert.isNotNull(shell); - Assert.isNotNull(tagSource); - this.shell = shell; - this.tagSource = tagSource; - } - - @Override + public TagRefreshButtonArea(Shell shell, TagSource tagSource, Listener addDateTagListener) { + this.addDateTagListener = addDateTagListener; + Assert.isNotNull(shell); + Assert.isNotNull(tagSource); + this.shell = shell; + this.tagSource = tagSource; + } + + @Override public void createArea(Composite parent) { - - final PixelConverter converter= SWTUtils.createDialogPixelConverter(parent); - - final Composite buttonComp = new Composite(parent, SWT.NONE); - buttonComp.setLayoutData(SWTUtils.createHFillGridData());//SWT.DEFAULT, SWT.DEFAULT, SWT.END, SWT.TOP, false, false)); - buttonComp.setLayout(SWTUtils.createGridLayout(4, converter, SWTUtils.MARGINS_NONE)); - + + final PixelConverter converter= SWTUtils.createDialogPixelConverter(parent); + + final Composite buttonComp = new Composite(parent, SWT.NONE); + buttonComp.setLayoutData(SWTUtils.createHFillGridData());//SWT.DEFAULT, SWT.DEFAULT, SWT.END, SWT.TOP, false, false)); + buttonComp.setLayout(SWTUtils.createGridLayout(4, converter, SWTUtils.MARGINS_NONE)); + fMessageLabel= SWTUtils.createLabel(buttonComp, null); refreshButton = new Button(buttonComp, SWT.PUSH); refreshButton.setText (CVSUIMessages.TagConfigurationDialog_20); final Button configureTagsButton = new Button(buttonComp, SWT.PUSH); configureTagsButton.setText (CVSUIMessages.TagConfigurationDialog_21); - - Button addDateTagButton = null; - int buttonWidth; - if (addDateTagListener != null) { - addDateTagButton = new Button(buttonComp, SWT.PUSH); - addDateTagButton.setText (CVSUIMessages.TagConfigurationDialog_AddDateTag); - Dialog.applyDialogFont(buttonComp); - buttonWidth= SWTUtils.calculateControlSize(converter, new Button [] { addDateTagButton, configureTagsButton, refreshButton }); - addDateTagButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.END, SWT.CENTER, false, false)); - addDateTagButton.addListener(SWT.Selection, addDateTagListener); - } else { - Dialog.applyDialogFont(buttonComp); - buttonWidth= SWTUtils.calculateControlSize(converter, new Button [] { configureTagsButton, refreshButton }); - } + + Button addDateTagButton = null; + int buttonWidth; + if (addDateTagListener != null) { + addDateTagButton = new Button(buttonComp, SWT.PUSH); + addDateTagButton.setText (CVSUIMessages.TagConfigurationDialog_AddDateTag); + Dialog.applyDialogFont(buttonComp); + buttonWidth= SWTUtils.calculateControlSize(converter, new Button [] { addDateTagButton, configureTagsButton, refreshButton }); + addDateTagButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.END, SWT.CENTER, false, false)); + addDateTagButton.addListener(SWT.Selection, addDateTagListener); + } else { + Dialog.applyDialogFont(buttonComp); + buttonWidth= SWTUtils.calculateControlSize(converter, new Button [] { configureTagsButton, refreshButton }); + } refreshButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.END, SWT.CENTER, false, false)); configureTagsButton.setLayoutData(SWTUtils.createGridData(buttonWidth, SWT.DEFAULT, SWT.END, SWT.CENTER, false, false)); refreshButton.addListener(SWT.Selection, event -> refresh(false)); - + configureTagsButton.addListener(SWT.Selection, event -> { TagConfigurationDialog d = new TagConfigurationDialog(shell, tagSource); d.open(); }); - PlatformUI.getWorkbench().getHelpSystem().setHelp(refreshButton, IHelpContextIds.TAG_CONFIGURATION_REFRESHACTION); - PlatformUI.getWorkbench().getHelpSystem().setHelp(configureTagsButton, IHelpContextIds.TAG_CONFIGURATION_OVERVIEW); + PlatformUI.getWorkbench().getHelpSystem().setHelp(refreshButton, IHelpContextIds.TAG_CONFIGURATION_REFRESHACTION); + PlatformUI.getWorkbench().getHelpSystem().setHelp(configureTagsButton, IHelpContextIds.TAG_CONFIGURATION_OVERVIEW); Dialog.applyDialogFont(buttonComp); - } - - - public void refresh(final boolean background) { + } + + + public void refresh(final boolean background) { try { getRunnableContext().run(true, true, monitor -> { try { @@ -128,17 +128,17 @@ public class TagRefreshButtonArea extends DialogArea { CVSUIPlugin.openError(shell, CVSUIMessages.TagConfigurationDialog_14, null, e); } } - - private void setBusy(final boolean busy) { - if (shell != null && !shell.isDisposed()) + + private void setBusy(final boolean busy) { + if (shell != null && !shell.isDisposed()) shell.getDisplay().asyncExec(() -> { if (!refreshButton.isDisposed()) refreshButton.setEnabled(!busy); }); - } + } - private boolean promptForBestEffort() { - final boolean[] prompt = new boolean[] { false }; + private boolean promptForBestEffort() { + final boolean[] prompt = new boolean[] { false }; shell.getDisplay().syncExec(() -> { MessageDialog dialog = new MessageDialog(shell, CVSUIMessages.TagRefreshButtonArea_0, null, getNoTagsFoundMessage(), MessageDialog.INFORMATION, @@ -154,25 +154,25 @@ public class TagRefreshButtonArea extends DialogArea { } }); - return prompt[0]; - } - - private String getNoTagsFoundMessage() { - return NLS.bind(CVSUIMessages.TagRefreshButtonArea_4, new String[] { tagSource.getShortDescription() }); - } - - public void setTagSource(TagSource tagSource) { - Assert.isNotNull(tagSource); - this.tagSource = tagSource; - } + return prompt[0]; + } + + private String getNoTagsFoundMessage() { + return NLS.bind(CVSUIMessages.TagRefreshButtonArea_4, new String[] { tagSource.getShortDescription() }); + } + + public void setTagSource(TagSource tagSource) { + Assert.isNotNull(tagSource); + this.tagSource = tagSource; + } - public IRunnableContext getRunnableContext() { - if (context == null) - return PlatformUI.getWorkbench().getProgressService(); - return context; - } - - public void setRunnableContext(IRunnableContext context) { - this.context = context; - } + public IRunnableContext getRunnableContext() { + if (context == null) + return PlatformUI.getWorkbench().getProgressService(); + return context; + } + + public void setRunnableContext(IRunnableContext context) { + this.context = context; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRootElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRootElement.java index 8b88194d9..a9c48a6cf 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRootElement.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagRootElement.java @@ -26,11 +26,11 @@ import org.eclipse.ui.model.IWorkbenchAdapter; public class TagRootElement implements IWorkbenchAdapter, IAdaptable { private TagSource tagSource; private int typeOfTagRoot; - private final Object parent; + private final Object parent; public TagRootElement(Object parent, TagSource tagSource, int typeOfTagRoot) { this.parent = parent; - this.typeOfTagRoot = typeOfTagRoot; + this.typeOfTagRoot = typeOfTagRoot; this.tagSource = tagSource; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java index 86882b381..c06143fb8 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionArea.java @@ -48,30 +48,30 @@ import org.eclipse.ui.part.PageBook; */ public class TagSelectionArea extends DialogArea { - private static int COLUMN_TRIM = "carbon".equals(SWT.getPlatform()) ? 24 : 3; //$NON-NLS-1$ - - private static int ICON_WIDTH = 40; - - /* - * Please see bug 184660 - */ - private static final int SAFETY_MARGIN = 50; - - /* - * Property constant which identifies the selected tag or - * null if no tag is selected - */ - public static final String SELECTED_TAG = "selectedTag"; //$NON-NLS-1$ - - /* - * Property constant which indicates that a tag has been selected in such - * a way as to indicate that this is the desired tag (e.g double-click) - */ - public static final String OPEN_SELECTED_TAG = "openSelectedTag"; //$NON-NLS-1$ - - /* - * Constants used to configure which tags are shown - */ + private static int COLUMN_TRIM = "carbon".equals(SWT.getPlatform()) ? 24 : 3; //$NON-NLS-1$ + + private static int ICON_WIDTH = 40; + + /* + * Please see bug 184660 + */ + private static final int SAFETY_MARGIN = 50; + + /* + * Property constant which identifies the selected tag or + * null if no tag is selected + */ + public static final String SELECTED_TAG = "selectedTag"; //$NON-NLS-1$ + + /* + * Property constant which indicates that a tag has been selected in such + * a way as to indicate that this is the desired tag (e.g double-click) + */ + public static final String OPEN_SELECTED_TAG = "openSelectedTag"; //$NON-NLS-1$ + + /* + * Constants used to configure which tags are shown + */ public static final int INCLUDE_HEAD_TAG = TagSourceWorkbenchAdapter.INCLUDE_HEAD_TAG; public static final int INCLUDE_BASE_TAG = TagSourceWorkbenchAdapter.INCLUDE_BASE_TAG; public static final int INCLUDE_BRANCHES = TagSourceWorkbenchAdapter.INCLUDE_BRANCHES; @@ -79,56 +79,56 @@ public class TagSelectionArea extends DialogArea { public static final int INCLUDE_DATES = TagSourceWorkbenchAdapter.INCLUDE_DATES; public static final int INCLUDE_ALL_TAGS = TagSourceWorkbenchAdapter.INCLUDE_ALL_TAGS; - private String tagAreaLabel; - private final int includeFlags; - private CVSTag selection; - private String helpContext; - private Text filterText; - private TagSource tagSource; - private final Shell shell; - private TagRefreshButtonArea tagRefreshArea; - private final TagSource.ITagSourceChangeListener listener = source -> { + private String tagAreaLabel; + private final int includeFlags; + private CVSTag selection; + private String helpContext; + private Text filterText; + private TagSource tagSource; + private final Shell shell; + private TagRefreshButtonArea tagRefreshArea; + private final TagSource.ITagSourceChangeListener listener = source -> { Shell shell = getShell(); if (!shell.isDisposed()) { - shell.getDisplay().syncExec(() -> refresh()); + shell.getDisplay().syncExec(() -> refresh()); } }; - private final DisposeListener disposeListener = e -> { - if (tagSource != null) - tagSource.removeListener(listener); + private final DisposeListener disposeListener = e -> { + if (tagSource != null) + tagSource.removeListener(listener); }; - private PageBook switcher; - private TreeViewer tagTree; - private TableViewer tagTable; - private boolean treeVisible = true; - private boolean includeFilterInputArea = true; - private String filterPattern = ""; //$NON-NLS-1$ + private PageBook switcher; + private TreeViewer tagTree; + private TableViewer tagTable; + private boolean treeVisible = true; + private boolean includeFilterInputArea = true; + private String filterPattern = ""; //$NON-NLS-1$ - private IRunnableContext context; - - public TagSelectionArea(Shell shell, TagSource tagSource, int includeFlags, String helpContext) { - this.shell = shell; - this.includeFlags = includeFlags; - this.helpContext = helpContext; - this.tagSource = tagSource; - setSelection(null); - } + private IRunnableContext context; + + public TagSelectionArea(Shell shell, TagSource tagSource, int includeFlags, String helpContext) { + this.shell = shell; + this.includeFlags = includeFlags; + this.helpContext = helpContext; + this.tagSource = tagSource; + setSelection(null); + } - @Override + @Override public void createArea(Composite parent) { - initializeDialogUnits(parent); - Dialog.applyDialogFont(parent); - final PixelConverter converter= new PixelConverter(parent); - - // Create a composite for the entire area - Composite composite= new Composite(parent, SWT.NONE); - composite.setLayoutData(SWTUtils.createHVFillGridData()); - composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); - + initializeDialogUnits(parent); + Dialog.applyDialogFont(parent); + final PixelConverter converter= new PixelConverter(parent); + + // Create a composite for the entire area + Composite composite= new Composite(parent, SWT.NONE); + composite.setLayoutData(SWTUtils.createHVFillGridData()); + composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); + // Add F1 help if (helpContext != null) { - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, helpContext); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, helpContext); } // Create the tree area and refresh buttons with the possibility to add stuff in between @@ -136,209 +136,209 @@ public class TagSelectionArea extends DialogArea { createCustomArea(composite); createRefreshButtons(composite); - Dialog.applyDialogFont(parent); - updateTagDisplay(true); - } + Dialog.applyDialogFont(parent); + updateTagDisplay(true); + } - private void createTagDisplayArea(Composite parent) { - Composite inner = createGrabbingComposite(parent, 1); - if (isIncludeFilterInputArea()) { - createFilterInput(inner); - createWrappingLabel(inner, CVSUIMessages.TagSelectionArea_0, 1); - } else { - createWrappingLabel(inner, NLS.bind(CVSUIMessages.TagSelectionArea_1, new String[] { getTagAreaLabel() }), 1); - } + private void createTagDisplayArea(Composite parent) { + Composite inner = createGrabbingComposite(parent, 1); + if (isIncludeFilterInputArea()) { + createFilterInput(inner); + createWrappingLabel(inner, CVSUIMessages.TagSelectionArea_0, 1); + } else { + createWrappingLabel(inner, NLS.bind(CVSUIMessages.TagSelectionArea_1, new String[] { getTagAreaLabel() }), 1); + } switcher = new PageBook(inner, SWT.NONE); GridData gridData = new GridData(GridData.FILL_BOTH); gridData.heightHint = 0; gridData.widthHint = 0; - switcher.setLayoutData(gridData); + switcher.setLayoutData(gridData); tagTree = createTree(switcher); tagTable = createTable(switcher); - } + } - private void createFilterInput(Composite inner) { - createWrappingLabel(inner, NLS.bind(CVSUIMessages.TagSelectionArea_2, new String[] { getTagAreaLabel() }), 1); - filterText = createText(inner, 1); - filterText.addModifyListener(e -> setFilter(filterText.getText())); - filterText.addKeyListener(new KeyListener() { - @Override + private void createFilterInput(Composite inner) { + createWrappingLabel(inner, NLS.bind(CVSUIMessages.TagSelectionArea_2, new String[] { getTagAreaLabel() }), 1); + filterText = createText(inner, 1); + filterText.addModifyListener(e -> setFilter(filterText.getText())); + filterText.addKeyListener(new KeyListener() { + @Override public void keyPressed(KeyEvent e) { - if (e.keyCode == SWT.ARROW_DOWN && e.stateMask == 0) { - tagTable.getControl().setFocus(); - } - } - @Override + if (e.keyCode == SWT.ARROW_DOWN && e.stateMask == 0) { + tagTable.getControl().setFocus(); + } + } + @Override public void keyReleased(KeyEvent e) { - // Ignore - } - }); - } + // Ignore + } + }); + } - /** - * Return the label that should be used for the tag area. - * It should not have any trailing punctuations as the tag area - * may position it differently depending on whether the filter - * text input is included in the area. - * @return the tag area label - */ - public String getTagAreaLabel() { - if (tagAreaLabel == null) - tagAreaLabel = CVSUIMessages.TagSelectionArea_3; - return tagAreaLabel; - } + /** + * Return the label that should be used for the tag area. + * It should not have any trailing punctuations as the tag area + * may position it differently depending on whether the filter + * text input is included in the area. + * @return the tag area label + */ + public String getTagAreaLabel() { + if (tagAreaLabel == null) + tagAreaLabel = CVSUIMessages.TagSelectionArea_3; + return tagAreaLabel; + } - /** - * Set the label that should be used for the tag area. - * It should not have any trailing punctuations as the tag area - * may position it differently depending on whether the filter - * text input is included in the area. - * @param tagAreaLabel the tag area label - */ - public void setTagAreaLabel(String tagAreaLabel) { - this.tagAreaLabel = tagAreaLabel; - } - - /** - * Update the tag display to show the tags that match the - * include flags and the filter entered by the user. - */ - protected void updateTagDisplay(boolean firstTime) { - String filter = getFilterString(); - if ((filter != null && filter.length() > 0) || isTableOnly()) { - // Show the table and filter it accordingly - try { - switcher.setRedraw(false); - treeVisible = false; - switcher.showPage(tagTable.getControl()); - FilteredTagList list = (FilteredTagList)tagTable.getInput(); - list.setPattern(filter); - tagTable.refresh(); - int maxWidth = getMaxWidth(list.getChildren(null)); - if (maxWidth > 0) { - maxWidth = maxWidth + ICON_WIDTH + COLUMN_TRIM + SAFETY_MARGIN; /* space for the tag icon */ - tagTable.getTable().getColumn(0).setWidth(maxWidth); - } - if (filterText == null || filter == null || filter.length() == 0) { - setSelection(selection); - } else { - // Only set the top selection if there is a filter from the filter text - // of this area. This is done to avoid selection loops - selectTopElement(); - } - } finally { - switcher.setRedraw(true); - } - } else { - // Show the tree - if (!isTreeVisible() || firstTime) { - try { - switcher.setRedraw(false); - treeVisible = true; - switcher.showPage(tagTree.getControl()); - tagTree.refresh(); - setSelection(selection); - } finally { - switcher.setRedraw(true); - } - } - } - } - - private int getMaxWidth(Object[] children) { - PixelConverter converter = new PixelConverter(tagTable.getTable()); - int maxWidth = 0; - for (int i = 0; i < children.length; i++) { - Object object = children[i]; - if (object instanceof TagElement) { - TagElement tag = (TagElement) object; - int width = tag.getTag().getName().length(); - if (width > maxWidth) { - maxWidth = width; - } - } - } - return converter.convertWidthInCharsToPixels(maxWidth); - } + /** + * Set the label that should be used for the tag area. + * It should not have any trailing punctuations as the tag area + * may position it differently depending on whether the filter + * text input is included in the area. + * @param tagAreaLabel the tag area label + */ + public void setTagAreaLabel(String tagAreaLabel) { + this.tagAreaLabel = tagAreaLabel; + } + + /** + * Update the tag display to show the tags that match the + * include flags and the filter entered by the user. + */ + protected void updateTagDisplay(boolean firstTime) { + String filter = getFilterString(); + if ((filter != null && filter.length() > 0) || isTableOnly()) { + // Show the table and filter it accordingly + try { + switcher.setRedraw(false); + treeVisible = false; + switcher.showPage(tagTable.getControl()); + FilteredTagList list = (FilteredTagList)tagTable.getInput(); + list.setPattern(filter); + tagTable.refresh(); + int maxWidth = getMaxWidth(list.getChildren(null)); + if (maxWidth > 0) { + maxWidth = maxWidth + ICON_WIDTH + COLUMN_TRIM + SAFETY_MARGIN; /* space for the tag icon */ + tagTable.getTable().getColumn(0).setWidth(maxWidth); + } + if (filterText == null || filter == null || filter.length() == 0) { + setSelection(selection); + } else { + // Only set the top selection if there is a filter from the filter text + // of this area. This is done to avoid selection loops + selectTopElement(); + } + } finally { + switcher.setRedraw(true); + } + } else { + // Show the tree + if (!isTreeVisible() || firstTime) { + try { + switcher.setRedraw(false); + treeVisible = true; + switcher.showPage(tagTree.getControl()); + tagTree.refresh(); + setSelection(selection); + } finally { + switcher.setRedraw(true); + } + } + } + } + + private int getMaxWidth(Object[] children) { + PixelConverter converter = new PixelConverter(tagTable.getTable()); + int maxWidth = 0; + for (int i = 0; i < children.length; i++) { + Object object = children[i]; + if (object instanceof TagElement) { + TagElement tag = (TagElement) object; + int width = tag.getTag().getName().length(); + if (width > maxWidth) { + maxWidth = width; + } + } + } + return converter.convertWidthInCharsToPixels(maxWidth); + } - /** - * Return whether only a table should be used - * @return whether only a table should be used - */ - protected boolean isTableOnly() { - return (includeFlags == INCLUDE_VERSIONS) || (includeFlags == INCLUDE_BRANCHES); - } + /** + * Return whether only a table should be used + * @return whether only a table should be used + */ + protected boolean isTableOnly() { + return (includeFlags == INCLUDE_VERSIONS) || (includeFlags == INCLUDE_BRANCHES); + } - private String getFilterString() { - return filterPattern; - } + private String getFilterString() { + return filterPattern; + } - /* - * Select the top element in the tag table - */ - private void selectTopElement() { - if (tagTable.getTable().getItemCount() > 0) { - TableItem item = tagTable.getTable().getItem(0); - tagTable.getTable().setSelection(new TableItem[] { item }); - tagTable.setSelection(tagTable.getSelection()); - } - } + /* + * Select the top element in the tag table + */ + private void selectTopElement() { + if (tagTable.getTable().getItemCount() > 0) { + TableItem item = tagTable.getTable().getItem(0); + tagTable.getTable().setSelection(new TableItem[] { item }); + tagTable.setSelection(tagTable.getSelection()); + } + } - private FilteredTagList createFilteredInput() { - return new FilteredTagList(tagSource, TagSource.convertIncludeFlaqsToTagTypes(includeFlags)); - } - - private Text createText(Composite parent, int horizontalSpan) { - Text text = new Text(parent, SWT.SEARCH); + private FilteredTagList createFilteredInput() { + return new FilteredTagList(tagSource, TagSource.convertIncludeFlaqsToTagTypes(includeFlags)); + } + + private Text createText(Composite parent, int horizontalSpan) { + Text text = new Text(parent, SWT.SEARCH); GridData data = new GridData(); data.horizontalSpan = horizontalSpan; data.horizontalAlignment = GridData.FILL; data.grabExcessHorizontalSpace = true; data.widthHint= 0; text.setLayoutData(data); - return text; - } + return text; + } - protected void createRefreshButtons(Composite parent) { - tagSource.addListener(listener); - parent.addDisposeListener(disposeListener); - Listener listener = null; - if ((includeFlags & TagSourceWorkbenchAdapter.INCLUDE_DATES) != 0) { - listener = event -> { - CVSTag dateTag = NewDateTagAction.getDateTag(getShell(), getLocation()); - addDateTag(dateTag); + protected void createRefreshButtons(Composite parent) { + tagSource.addListener(listener); + parent.addDisposeListener(disposeListener); + Listener listener = null; + if ((includeFlags & TagSourceWorkbenchAdapter.INCLUDE_DATES) != 0) { + listener = event -> { + CVSTag dateTag = NewDateTagAction.getDateTag(getShell(), getLocation()); + addDateTag(dateTag); }; - } - tagRefreshArea = new TagRefreshButtonArea(shell, tagSource, listener); - if (context != null) - tagRefreshArea.setRunnableContext(context); - tagRefreshArea.createArea(parent); - } + } + tagRefreshArea = new TagRefreshButtonArea(shell, tagSource, listener); + if (context != null) + tagRefreshArea.setRunnableContext(context); + tagRefreshArea.createArea(parent); + } - protected void createTreeMenu(TreeViewer tagTree) { - if ((includeFlags & TagSourceWorkbenchAdapter.INCLUDE_DATES) != 0) { - // Create the popup menu + protected void createTreeMenu(TreeViewer tagTree) { + if ((includeFlags & TagSourceWorkbenchAdapter.INCLUDE_DATES) != 0) { + // Create the popup menu MenuManager menuMgr = new MenuManager(); Tree tree = tagTree.getTree(); Menu menu = menuMgr.createContextMenu(tree); menuMgr.addMenuListener(manager -> addMenuItemActions(manager)); menuMgr.setRemoveAllWhenShown(true); tree.setMenu(menu); - } - } + } + } - /** - * Create aq custom area that is below the tag selection area but above the refresh busson group - * @param parent - */ + /** + * Create aq custom area that is below the tag selection area but above the refresh busson group + * @param parent + */ protected void createCustomArea(Composite parent) { // No default custom area - } + } - protected TreeViewer createTree(Composite parent) { + protected TreeViewer createTree(Composite parent) { Tree tree = new Tree(parent, SWT.SINGLE | SWT.BORDER); GridData data = new GridData(GridData.FILL_BOTH); - tree.setLayoutData(data); + tree.setLayoutData(data); TreeViewer result = new TreeViewer(tree); initialize(result); result.getControl().addKeyListener(new KeyListener() { @@ -356,7 +356,7 @@ public class TagSelectionArea extends DialogArea { return result; } - protected TableViewer createTable(Composite parent) { + protected TableViewer createTable(Composite parent) { Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); GridData data = new GridData(GridData.FILL_BOTH); table.setLayoutData(data); @@ -371,8 +371,8 @@ public class TagSelectionArea extends DialogArea { } - private void initialize(StructuredViewer viewer) { - viewer.setContentProvider(new WorkbenchContentProvider()); + private void initialize(StructuredViewer viewer) { + viewer.setContentProvider(new WorkbenchContentProvider()); viewer.setLabelProvider(new WorkbenchLabelProvider()); viewer.setComparator(new ProjectElementComparator()); viewer.addSelectionChangedListener(event -> handleSelectionChange()); @@ -381,19 +381,19 @@ public class TagSelectionArea extends DialogArea { viewer.getControl().addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { - CVSTag tag = internalGetSelectedTag(); - if (tag != null) { - firePropertyChangeChange(OPEN_SELECTED_TAG, null, tag); - } + CVSTag tag = internalGetSelectedTag(); + if (tag != null) { + firePropertyChangeChange(OPEN_SELECTED_TAG, null, tag); + } } }); - } + } - private Object createUnfilteredInput() { - return TagSourceWorkbenchAdapter.createInput(tagSource, includeFlags); - } + private Object createUnfilteredInput() { + return TagSourceWorkbenchAdapter.createInput(tagSource, includeFlags); + } - public void handleKeyPressed(KeyEvent event) { + public void handleKeyPressed(KeyEvent event) { if (event.character == SWT.DEL && event.stateMask == 0) { deleteDateTag(); } @@ -443,7 +443,7 @@ public class TagSelectionArea extends DialogArea { ICVSRepositoryLocation location = getLocation(); dateTags.addAll(Arrays.asList(CVSUIPlugin.getPlugin().getRepositoryManager().getDateTags(location))); if(!dateTags.contains( tag)){ - CVSUIPlugin.getPlugin().getRepositoryManager().addDateTag(location, tag); + CVSUIPlugin.getPlugin().getRepositoryManager().addDateTag(location, tag); } try { tagTree.getControl().setRedraw(false); @@ -480,62 +480,62 @@ public class TagSelectionArea extends DialogArea { * (which could be either the table or the tree). */ protected void handleSelectionChange() { - CVSTag newSelection = internalGetSelectedTag(); - if (selection != null && newSelection != null && selection.equals(newSelection)) { - // the selection hasn't change so return - return; - } - CVSTag oldSelection = selection; - selection = newSelection; - firePropertyChangeChange(SELECTED_TAG, oldSelection, selection); + CVSTag newSelection = internalGetSelectedTag(); + if (selection != null && newSelection != null && selection.equals(newSelection)) { + // the selection hasn't change so return + return; + } + CVSTag oldSelection = selection; + selection = newSelection; + firePropertyChangeChange(SELECTED_TAG, oldSelection, selection); } private CVSTag internalGetSelectedTag() { - IStructuredSelection selection; - if (isTreeVisible()) { - selection = tagTree.getStructuredSelection(); - } else { - selection = tagTable.getStructuredSelection(); - } + IStructuredSelection selection; + if (isTreeVisible()) { + selection = tagTree.getStructuredSelection(); + } else { + selection = tagTable.getStructuredSelection(); + } Object o = selection.getFirstElement(); if (o instanceof TagElement) - return ((TagElement)o).getTag(); + return ((TagElement)o).getTag(); return null; } - private boolean isTreeVisible() { - return treeVisible; - } + private boolean isTreeVisible() { + return treeVisible; + } - private ICVSRepositoryLocation getLocation(){ + private ICVSRepositoryLocation getLocation(){ return tagSource.getLocation(); } - public CVSTag getSelection() { - return selection; - } - public Shell getShell() { - return shell; - } + public CVSTag getSelection() { + return selection; + } + public Shell getShell() { + return shell; + } - /** - * Set the focus to the filter text widget - */ - public void setFocus() { - if (filterText != null) - filterText.setFocus(); - else if (switcher != null) - switcher.setFocus(); - - // Refresh in case tags were added since the last time the area had focus - refresh(); - } + /** + * Set the focus to the filter text widget + */ + public void setFocus() { + if (filterText != null) + filterText.setFocus(); + else if (switcher != null) + switcher.setFocus(); + + // Refresh in case tags were added since the last time the area had focus + refresh(); + } - /** - * Select the given tag - * @param selectedTag the tag to be selected - */ - public void setSelection(CVSTag selectedTag) { - if (isTreeVisible()) + /** + * Select the given tag + * @param selectedTag the tag to be selected + */ + public void setSelection(CVSTag selectedTag) { + if (isTreeVisible()) if (tagTree != null && !tagTree.getControl().isDisposed()) { // TODO: Hack to instantiate the model before revealing the selection tagTree.expandToLevel(2); @@ -545,97 +545,97 @@ public class TagSelectionArea extends DialogArea { tagTree.setSelection(new StructuredSelection(new TagElement(selectedTag))); } else - if (tagTable != null && !tagTable.getControl().isDisposed()) { - tagTable.setSelection(new StructuredSelection(new TagElement(selectedTag))); - } - } + if (tagTable != null && !tagTable.getControl().isDisposed()) { + tagTable.setSelection(new StructuredSelection(new TagElement(selectedTag))); + } + } - /** - * Refresh the state of the tag selection area - */ - public void refresh() { - if (isTreeVisible()) { - if (tagTree != null && !tagTree.getControl().isDisposed()) { - tagTree.refresh(); - } - } else { - if (tagTable != null && !tagTable.getControl().isDisposed()) { - tagTable.refresh(); - } - } - } - - public void refreshTagList() { - tagRefreshArea.refresh(true); - } + /** + * Refresh the state of the tag selection area + */ + public void refresh() { + if (isTreeVisible()) { + if (tagTree != null && !tagTree.getControl().isDisposed()) { + tagTree.refresh(); + } + } else { + if (tagTable != null && !tagTable.getControl().isDisposed()) { + tagTable.refresh(); + } + } + } + + public void refreshTagList() { + tagRefreshArea.refresh(true); + } - /** - * Set the enablement state of the area - * @param enabled the enablement state - */ - public void setEnabled(boolean enabled) { - if (filterText != null) - filterText.setEnabled(enabled); - tagTree.getControl().setEnabled(enabled); - tagTable.getControl().setEnabled(enabled); - } - - /** - * Set the tag source from which the displayed tags are determined - * @param tagSource the source of the tags being displayed - */ - public void setTagSource(TagSource tagSource) { - if (this.tagSource != null) { - this.tagSource.removeListener(listener); - } - this.tagSource = tagSource; - this.tagSource.addListener(listener); - tagRefreshArea.setTagSource(this.tagSource); - setTreeAndTableInput(); - } + /** + * Set the enablement state of the area + * @param enabled the enablement state + */ + public void setEnabled(boolean enabled) { + if (filterText != null) + filterText.setEnabled(enabled); + tagTree.getControl().setEnabled(enabled); + tagTable.getControl().setEnabled(enabled); + } + + /** + * Set the tag source from which the displayed tags are determined + * @param tagSource the source of the tags being displayed + */ + public void setTagSource(TagSource tagSource) { + if (this.tagSource != null) { + this.tagSource.removeListener(listener); + } + this.tagSource = tagSource; + this.tagSource.addListener(listener); + tagRefreshArea.setTagSource(this.tagSource); + setTreeAndTableInput(); + } - private void setTreeAndTableInput() { - if (tagTree != null) { - tagTree.setInput(createUnfilteredInput()); - } - if (tagTable != null) { - tagTable.setInput(createFilteredInput()); - } - - } + private void setTreeAndTableInput() { + if (tagTree != null) { + tagTree.setInput(createUnfilteredInput()); + } + if (tagTable != null) { + tagTable.setInput(createFilteredInput()); + } + + } - /** - * Set whether the input filter text is to be included in the tag selection area. - * If excluded, clientscan still set the filter text directly using - * <code>setFilter</code>. - * @param include whether filter text input should be included - */ - public void setIncludeFilterInputArea(boolean include) { - includeFilterInputArea = include; - } - - /** - * Return whether the input filter text is to be included in the tag selection area. - * If excluded, clientscan still set the filter text directly using - * <code>setFilter</code>. - * @return whether filter text input should be included - */ - public boolean isIncludeFilterInputArea() { - return includeFilterInputArea; - } + /** + * Set whether the input filter text is to be included in the tag selection area. + * If excluded, clientscan still set the filter text directly using + * <code>setFilter</code>. + * @param include whether filter text input should be included + */ + public void setIncludeFilterInputArea(boolean include) { + includeFilterInputArea = include; + } + + /** + * Return whether the input filter text is to be included in the tag selection area. + * If excluded, clientscan still set the filter text directly using + * <code>setFilter</code>. + * @return whether filter text input should be included + */ + public boolean isIncludeFilterInputArea() { + return includeFilterInputArea; + } - /** - * Set the text used to filter the tag list. - * @param filter the filter pattern - */ - public void setFilter(String filter) { - this.filterPattern = filter; - updateTagDisplay(false); - } - - public void setRunnableContext(IRunnableContext context) { - this.context = context; - if (tagRefreshArea != null) - tagRefreshArea.setRunnableContext(context); - } + /** + * Set the text used to filter the tag list. + * @param filter the filter pattern + */ + public void setFilter(String filter) { + this.filterPattern = filter; + updateTagDisplay(false); + } + + public void setRunnableContext(IRunnableContext context) { + this.context = context; + if (tagRefreshArea != null) + tagRefreshArea.setRunnableContext(context); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java index 8f3920571..1e23aec62 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java @@ -58,17 +58,17 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis private static final int SIZING_DIALOG_WIDTH = 90; private static final int SIZING_DIALOG_HEIGHT = 25; - private CVSTag selection; + private CVSTag selection; - private TagSource tagSource; + private TagSource tagSource; - private String message; + private String message; - private int includeFlags; + private int includeFlags; - private String helpContext; + private String helpContext; - private boolean showRecurse; + private boolean showRecurse; public static CVSTag getTagToCompareWith(Shell shell, TagSource tagSource, int includeFlags) { TagSelectionDialog dialog = new TagSelectionDialog(shell, tagSource, @@ -107,12 +107,12 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis newShell.setText(title); } - protected Point getInitialSize() { - final Point size= super.getInitialSize(); - size.x= convertWidthInCharsToPixels(SIZING_DIALOG_WIDTH); - size.y= convertHeightInCharsToPixels(SIZING_DIALOG_HEIGHT); - return size; - } + protected Point getInitialSize() { + final Point size= super.getInitialSize(); + size.x= convertWidthInCharsToPixels(SIZING_DIALOG_WIDTH); + size.y= convertHeightInCharsToPixels(SIZING_DIALOG_HEIGHT); + return size; + } /** * Creates this window's widgetry. @@ -164,7 +164,7 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis final Composite top = (Composite)super.createDialogArea(parent); // Delegate most of the dialog to the tag selection area - tagSelectionArea = new TagSelectionArea(getShell(), tagSource, includeFlags, helpContext) { + tagSelectionArea = new TagSelectionArea(getShell(), tagSource, includeFlags, helpContext) { protected void createCustomArea(Composite parent) { if(showRecurse) { final Button recurseCheck = new Button(parent, SWT.CHECK); @@ -172,10 +172,10 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis recurseCheck.addListener(SWT.Selection, event -> recurse = recurseCheck.getSelection()); recurseCheck.setSelection(true); } - } + } }; if (message != null) - tagSelectionArea.setTagAreaLabel(message); + tagSelectionArea.setTagAreaLabel(message); tagSelectionArea.addPropertyChangeListener(this); tagSelectionArea.createArea(top); tagSelectionArea.setRunnableContext(getRunnableContext()); @@ -187,8 +187,8 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis seperator.setLayoutData(data); updateEnablement(); - applyDialogFont(parent); - + applyDialogFont(parent); + return top; } @@ -241,23 +241,23 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis } } - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - if (property.equals(TagSelectionArea.SELECTED_TAG)) { - selection = (CVSTag)event.getNewValue(); - updateEnablement(); - } else if (property.equals(TagSelectionArea.OPEN_SELECTED_TAG)) { - okPressed(); - } - } - - /** - * Creates a runnable context that allows refreshing the tags in the background. - * - * @since 3.1 - */ - private IRunnableContext getRunnableContext() { - return (fork, cancelable, runnable) -> { + public void propertyChange(PropertyChangeEvent event) { + String property = event.getProperty(); + if (property.equals(TagSelectionArea.SELECTED_TAG)) { + selection = (CVSTag)event.getNewValue(); + updateEnablement(); + } else if (property.equals(TagSelectionArea.OPEN_SELECTED_TAG)) { + okPressed(); + } + } + + /** + * Creates a runnable context that allows refreshing the tags in the background. + * + * @since 3.1 + */ + private IRunnableContext getRunnableContext() { + return (fork, cancelable, runnable) -> { final Job refreshJob = new Job(CVSUIMessages.TagSelectionDialog_7) { protected IStatus run(IProgressMonitor monitor) { if (monitor.isCanceled()) @@ -283,19 +283,19 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis getShell().addDisposeListener(e -> refreshJob.cancel()); refreshJob.schedule(); }; - } - - private void setBusy(final boolean busy) { + } + + private void setBusy(final boolean busy) { final Shell shell = getShell(); if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(() -> { - if (!shell.isDisposed()) { + if (!shell.isDisposed()) { Cursor cursor = null; if (busy) { cursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_APPSTARTING); } shell.setCursor(cursor); - } + } }); } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionWizardPage.java index 265bd6fc9..e285cf865 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionWizardPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionWizardPage.java @@ -47,12 +47,12 @@ public class TagSelectionWizardPage extends CVSWizardPage { private Button selectTagButton; private boolean useResourceTag = false; private String helpContextId; - private TagSelectionArea tagArea; - private TagSource tagSource; + private TagSelectionArea tagArea; + private TagSource tagSource; public TagSelectionWizardPage(String pageName, String title, ImageDescriptor titleImage, String description, TagSource tagSource, int includeFlags) { super(pageName, title, titleImage, description); - this.tagSource = tagSource; + this.tagSource = tagSource; this.includeFlags = includeFlags; } @@ -64,7 +64,7 @@ public class TagSelectionWizardPage extends CVSWizardPage { public void setHelpContxtId(String helpContextId) { this.helpContextId = helpContextId; } - + @Override public void createControl(Composite parent) { @@ -77,7 +77,7 @@ public class TagSelectionWizardPage extends CVSWizardPage { // set F1 help if (helpContextId != null) - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, helpContextId); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, helpContextId); if (allowNoTag) { SelectionListener listener = new SelectionAdapter() { @@ -103,29 +103,29 @@ public class TagSelectionWizardPage extends CVSWizardPage { private void createTagArea() { tagArea = new TagSelectionArea(getShell(), tagSource, includeFlags, null); - tagArea.setRunnableContext(getContainer()); + tagArea.setRunnableContext(getContainer()); tagArea.createArea(composite); tagArea.addPropertyChangeListener(new IPropertyChangeListener() { - @Override + @Override public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(TagSelectionArea.SELECTED_TAG)) { - selectedTag = tagArea.getSelection(); - updateEnablement(); - } else if (event.getProperty().equals(TagSelectionArea.OPEN_SELECTED_TAG)) { - if (selectedTag != null) - gotoNextPage(); - } + if (event.getProperty().equals(TagSelectionArea.SELECTED_TAG)) { + selectedTag = tagArea.getSelection(); + updateEnablement(); + } else if (event.getProperty().equals(TagSelectionArea.OPEN_SELECTED_TAG)) { + if (selectedTag != null) + gotoNextPage(); + } - } - }); + } + }); refreshTagArea(); - } + } - private void refreshTagArea() { - if (tagArea != null) { - tagArea.refresh(); - tagArea.setSelection(selectedTag); - } + private void refreshTagArea() { + if (tagArea != null) { + tagArea.refresh(); + tagArea.setSelection(selectedTag); + } } protected void updateEnablement() { @@ -159,26 +159,26 @@ public class TagSelectionWizardPage extends CVSWizardPage { } } - /** - * Set the tag source used by this wizard page - * @param source the tag source - */ - public void setTagSource(TagSource source) { - this.tagSource = source; - tagArea.setTagSource(tagSource); - setSelection(null); - refreshTagArea(); - } + /** + * Set the tag source used by this wizard page + * @param source the tag source + */ + public void setTagSource(TagSource source) { + this.tagSource = source; + tagArea.setTagSource(tagSource); + setSelection(null); + refreshTagArea(); + } - /** - * Set the selection of the page to the given tag - * @param selectedTag - */ - public void setSelection(CVSTag selectedTag) { + /** + * Set the selection of the page to the given tag + * @param selectedTag + */ + public void setSelection(CVSTag selectedTag) { if (selectedTag == null && (includeFlags & TagSelectionArea.INCLUDE_HEAD_TAG) > 0) { this.selectedTag = CVSTag.DEFAULT; } else { - this.selectedTag = selectedTag; + this.selectedTag = selectedTag; } - } + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSource.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSource.java index 303cb4be2..890142793 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSource.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSource.java @@ -27,157 +27,157 @@ import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; * A tag source provides access to a set of tags. */ public abstract class TagSource { - - /* - * Special constant representing the BASE tag - */ - public static final int BASE = -1; - - public static final TagSource EMPTY = new TagSource() { - @Override + + /* + * Special constant representing the BASE tag + */ + public static final int BASE = -1; + + public static final TagSource EMPTY = new TagSource() { + @Override public void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException { - // No-op - } - @Override + // No-op + } + @Override public ICVSRepositoryLocation getLocation() { - // TODO Auto-generated method stub - return null; - } - @Override + // TODO Auto-generated method stub + return null; + } + @Override public String getShortDescription() { - return "Empty"; //$NON-NLS-1$ - } - @Override + return "Empty"; //$NON-NLS-1$ + } + @Override public CVSTag[] getTags(int type) { - return new CVSTag[0]; - } - @Override + return new CVSTag[0]; + } + @Override public CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException { - return new CVSTag[0]; - } - @Override + return new CVSTag[0]; + } + @Override public ICVSResource[] getCVSResources() { - return new ICVSResource[0]; - } - }; - + return new ICVSResource[0]; + } + }; + private ListenerList<ITagSourceChangeListener> listeners = new ListenerList<>(ListenerList.IDENTITY); - - /** - * Simple interface for providing notification when the tags - * for this source have changed. - */ - public interface ITagSourceChangeListener { - void tagsChanged(TagSource source); - } - - public static int[] convertIncludeFlaqsToTagTypes(int includeFlags) { + + /** + * Simple interface for providing notification when the tags + * for this source have changed. + */ + public interface ITagSourceChangeListener { + void tagsChanged(TagSource source); + } + + public static int[] convertIncludeFlaqsToTagTypes(int includeFlags) { List<Integer> types = new ArrayList<>(); - if ((includeFlags & TagSelectionArea.INCLUDE_BRANCHES) > 0) - types.add(Integer.valueOf(CVSTag.BRANCH)); - if ((includeFlags & TagSelectionArea.INCLUDE_VERSIONS) > 0) - types.add(Integer.valueOf(CVSTag.VERSION)); - if ((includeFlags & (TagSelectionArea.INCLUDE_HEAD_TAG)) > 0) - types.add(Integer.valueOf(CVSTag.HEAD)); - if ((includeFlags & (TagSelectionArea.INCLUDE_DATES)) > 0) - types.add(Integer.valueOf(CVSTag.DATE)); - if ((includeFlags & (TagSelectionArea.INCLUDE_BASE_TAG)) > 0) - types.add(Integer.valueOf(BASE)); - int[] result = new int[types.size()]; - for (int i = 0; i < result.length; i++) { - result[i] = types.get(i).intValue(); - - } - return result; - } - - /** - * Create a tag source for the given folders - * @param folders one or more folders - * @return a tag source for the supplied folders - */ - public static TagSource create(ICVSFolder[] folders) { - if (folders.length == 1) { - return new SingleFolderTagSource(folders[0]); - } else { - return new MultiFolderTagSource(folders); - } - } - - /** - * Create a tag source for a list of resources - * @param resources one or more resources - * @return a tag source - */ - public static TagSource create(ICVSResource[] resources) { - if (resources.length == 1 && !resources[0].isFolder()) - return new SingleFileTagSource((ICVSFile)resources[0]); - return create(getFolders(resources)); - } + if ((includeFlags & TagSelectionArea.INCLUDE_BRANCHES) > 0) + types.add(Integer.valueOf(CVSTag.BRANCH)); + if ((includeFlags & TagSelectionArea.INCLUDE_VERSIONS) > 0) + types.add(Integer.valueOf(CVSTag.VERSION)); + if ((includeFlags & (TagSelectionArea.INCLUDE_HEAD_TAG)) > 0) + types.add(Integer.valueOf(CVSTag.HEAD)); + if ((includeFlags & (TagSelectionArea.INCLUDE_DATES)) > 0) + types.add(Integer.valueOf(CVSTag.DATE)); + if ((includeFlags & (TagSelectionArea.INCLUDE_BASE_TAG)) > 0) + types.add(Integer.valueOf(BASE)); + int[] result = new int[types.size()]; + for (int i = 0; i < result.length; i++) { + result[i] = types.get(i).intValue(); + + } + return result; + } + + /** + * Create a tag source for the given folders + * @param folders one or more folders + * @return a tag source for the supplied folders + */ + public static TagSource create(ICVSFolder[] folders) { + if (folders.length == 1) { + return new SingleFolderTagSource(folders[0]); + } else { + return new MultiFolderTagSource(folders); + } + } + + /** + * Create a tag source for a list of resources + * @param resources one or more resources + * @return a tag source + */ + public static TagSource create(ICVSResource[] resources) { + if (resources.length == 1 && !resources[0].isFolder()) + return new SingleFileTagSource((ICVSFile)resources[0]); + return create(getFolders(resources)); + } - private static ICVSFolder[] getFolders(ICVSResource[] resources) { + private static ICVSFolder[] getFolders(ICVSResource[] resources) { HashSet<ICVSFolder> result = new HashSet<>(); - for (int i= 0; i < resources.length; i++) { - result.add(getFirstFolder(resources[i])); + for (int i= 0; i < resources.length; i++) { + result.add(getFirstFolder(resources[i])); } - return result.toArray(new ICVSFolder[result.size()]); - } + return result.toArray(new ICVSFolder[result.size()]); + } - /** - * Create a tag source for a list of resources - * @param resources one or more resources - * @return a tag source - */ - public static TagSource create(IResource[] resources) { - return create(getCVSResources(getProjects(resources))); - } - - /** - * Create a tag source for the given mappers. - * @param mappers the mappers - * @return a tag source - */ - public static TagSource create(ResourceMapping[] mappers) { - return create(getCVSResources(getProjects(mappers))); - } - - private static IResource[] getProjects(ResourceMapping[] mappers) { + /** + * Create a tag source for a list of resources + * @param resources one or more resources + * @return a tag source + */ + public static TagSource create(IResource[] resources) { + return create(getCVSResources(getProjects(resources))); + } + + /** + * Create a tag source for the given mappers. + * @param mappers the mappers + * @return a tag source + */ + public static TagSource create(ResourceMapping[] mappers) { + return create(getCVSResources(getProjects(mappers))); + } + + private static IResource[] getProjects(ResourceMapping[] mappers) { Set<IProject> projects = new HashSet<>(); - for (int i = 0; i < mappers.length; i++) { - ResourceMapping mapper = mappers[i]; - projects.addAll(Arrays.asList(mapper.getProjects())); - } - return projects.toArray(new IResource[projects.size()]); - } + for (int i = 0; i < mappers.length; i++) { + ResourceMapping mapper = mappers[i]; + projects.addAll(Arrays.asList(mapper.getProjects())); + } + return projects.toArray(new IResource[projects.size()]); + } - private static IResource[] getProjects(IResource[] resources) { + private static IResource[] getProjects(IResource[] resources) { Set<IProject> result = new HashSet<>(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - result.add(resource.getProject()); - } - return result.toArray(new IResource[result.size()]); - } + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + result.add(resource.getProject()); + } + return result.toArray(new IResource[result.size()]); + } - /** - * Return a tag source for a single remote folder - * @param remote the remote folder - * @return a tag source for that folder - */ - public static TagSource create(ICVSRemoteFolder remote) { - return new SingleFolderTagSource(remote); - } - - private static ICVSResource[] getCVSResources(IResource[] resources) { + /** + * Return a tag source for a single remote folder + * @param remote the remote folder + * @return a tag source for that folder + */ + public static TagSource create(ICVSRemoteFolder remote) { + return new SingleFolderTagSource(remote); + } + + private static ICVSResource[] getCVSResources(IResource[] resources) { List<ICVSResource> cvsResources = new ArrayList<>(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - cvsResources.add(CVSWorkspaceRoot.getCVSResourceFor(resource)); - } - return cvsResources.toArray(new ICVSResource[cvsResources.size()]); - } + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + cvsResources.add(CVSWorkspaceRoot.getCVSResourceFor(resource)); + } + return cvsResources.toArray(new ICVSResource[cvsResources.size()]); + } - private static ICVSFolder getFirstFolder(ICVSResource resource) { + private static ICVSFolder getFirstFolder(ICVSResource resource) { if (resource.isFolder()) { return (ICVSFolder)resource; } else { @@ -185,84 +185,84 @@ public abstract class TagSource { } } - public CVSTag[] getTags(int type) { - switch (type) { - case BASE: - return new CVSTag[] { CVSTag.BASE }; - case CVSTag.HEAD: - return new CVSTag[] { CVSTag.DEFAULT }; - } - return new CVSTag[0]; - } - - public CVSTag[] getTags(int[] types) { - if (types.length == 0) { - return new CVSTag[0]; - } - if (types.length == 1) { - return getTags(types[0]); - } + public CVSTag[] getTags(int type) { + switch (type) { + case BASE: + return new CVSTag[] { CVSTag.BASE }; + case CVSTag.HEAD: + return new CVSTag[] { CVSTag.DEFAULT }; + } + return new CVSTag[0]; + } + + public CVSTag[] getTags(int[] types) { + if (types.length == 0) { + return new CVSTag[0]; + } + if (types.length == 1) { + return getTags(types[0]); + } List<CVSTag> result = new ArrayList<>(); - for (int i = 0; i < types.length; i++) { - int type = types[i]; - CVSTag[] tags = getTags(type); - result.addAll(Arrays.asList(tags)); - } - return result.toArray(new CVSTag[result.size()]); - } + for (int i = 0; i < types.length; i++) { + int type = types[i]; + CVSTag[] tags = getTags(type); + result.addAll(Arrays.asList(tags)); + } + return result.toArray(new CVSTag[result.size()]); + } - /** - * Refresh the tags by contacting the server if appropriate - * @param monitor a progress monitor - * @param bestEffort if best effort is true, then the whole folder contents may be searched - * @return any discovered tags - */ - public abstract CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException; - - public abstract ICVSRepositoryLocation getLocation(); + /** + * Refresh the tags by contacting the server if appropriate + * @param monitor a progress monitor + * @param bestEffort if best effort is true, then the whole folder contents may be searched + * @return any discovered tags + */ + public abstract CVSTag[] refresh(boolean bestEffort, IProgressMonitor monitor) throws TeamException; + + public abstract ICVSRepositoryLocation getLocation(); - /** - * Return a short description of the tag source for displaying in UI. - * @return a short description of the tag source for displaying in UI. - */ - public abstract String getShortDescription(); + /** + * Return a short description of the tag source for displaying in UI. + * @return a short description of the tag source for displaying in UI. + */ + public abstract String getShortDescription(); - /** - * Commit a set of tag changes to the tag cache - * @param tags the tags that should be cached - * @param replace whether existing tags not in the list should be removed - * @param monitor a progress monitor - * @throws CVSException - */ - public abstract void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException; - - public void addListener(ITagSourceChangeListener listener) { - listeners.add(listener); - } + /** + * Commit a set of tag changes to the tag cache + * @param tags the tags that should be cached + * @param replace whether existing tags not in the list should be removed + * @param monitor a progress monitor + * @throws CVSException + */ + public abstract void commit(CVSTag[] tags, boolean replace, IProgressMonitor monitor) throws CVSException; + + public void addListener(ITagSourceChangeListener listener) { + listeners.add(listener); + } - public void removeListener(ITagSourceChangeListener listener) { - listeners.remove(listener); - } - - /** - * Notify all listeners that the tags from this source may have changed - */ - public void fireChange() { - Object[] list = listeners.getListeners(); - for (int i = 0; i < list.length; i++) { - final ITagSourceChangeListener listener = (ITagSourceChangeListener)list[i]; - SafeRunner.run(new ISafeRunnable() { - @Override + public void removeListener(ITagSourceChangeListener listener) { + listeners.remove(listener); + } + + /** + * Notify all listeners that the tags from this source may have changed + */ + public void fireChange() { + Object[] list = listeners.getListeners(); + for (int i = 0; i < list.length; i++) { + final ITagSourceChangeListener listener = (ITagSourceChangeListener)list[i]; + SafeRunner.run(new ISafeRunnable() { + @Override public void handleException(Throwable exception) { - // logged by run - } - @Override + // logged by run + } + @Override public void run() throws Exception { - listener.tagsChanged(TagSource.this); - } - }); - } - } - - public abstract ICVSResource[] getCVSResources(); + listener.tagsChanged(TagSource.this); + } + }); + } + } + + public abstract ICVSResource[] getCVSResources(); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceResourceAdapter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceResourceAdapter.java index dbdf19a15..744fc482d 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceResourceAdapter.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceResourceAdapter.java @@ -28,55 +28,55 @@ import org.eclipse.ui.model.IWorkbenchAdapter; */ public class TagSourceResourceAdapter implements IAdaptable, IWorkbenchAdapter { - public static Object getViewerInput(TagSource tagSource) { - return new TagSourceResourceAdapter(tagSource); - } - - TagSource tagSource; + public static Object getViewerInput(TagSource tagSource) { + return new TagSourceResourceAdapter(tagSource); + } + + TagSource tagSource; - private TagSourceResourceAdapter(TagSource tagSource) { - this.tagSource = tagSource; - } - - @Override + private TagSourceResourceAdapter(TagSource tagSource) { + this.tagSource = tagSource; + } + + @Override public Object[] getChildren(Object o) { - ICVSResource[] children = tagSource.getCVSResources(); - if (children.length == 0) return new Object[0]; + ICVSResource[] children = tagSource.getCVSResources(); + if (children.length == 0) return new Object[0]; List<CVSResourceElement> result = new ArrayList<>(); - for (int i = 0; i < children.length; i++) { - ICVSResource resource = children[i]; - if (resource.isFolder()) { - result.add(new CVSFolderElement((ICVSFolder)resource, false)); - } else { - result.add(new CVSFileElement((ICVSFile)resource)); - } - } - return result.toArray(new Object[result.size()]); - } + for (int i = 0; i < children.length; i++) { + ICVSResource resource = children[i]; + if (resource.isFolder()) { + result.add(new CVSFolderElement((ICVSFolder)resource, false)); + } else { + result.add(new CVSFileElement((ICVSFile)resource)); + } + } + return result.toArray(new Object[result.size()]); + } - @Override + @Override public ImageDescriptor getImageDescriptor(Object object) { - // No image descriptor - return null; - } + // No image descriptor + return null; + } - @Override + @Override public String getLabel(Object o) { - return tagSource.getShortDescription(); - } + return tagSource.getShortDescription(); + } - @Override + @Override public Object getParent(Object o) { - // No parent - return null; - } + // No parent + return null; + } - @Override + @Override public <T> T getAdapter(Class<T> adapter) { - if (adapter == IWorkbenchAdapter.class) { - return adapter.cast(this); - } - return null; - } + if (adapter == IWorkbenchAdapter.class) { + return adapter.cast(this); + } + return null; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceWorkbenchAdapter.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceWorkbenchAdapter.java index 863d291ce..075e8af25 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceWorkbenchAdapter.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSourceWorkbenchAdapter.java @@ -30,9 +30,9 @@ import org.eclipse.ui.model.IWorkbenchAdapter; */ public class TagSourceWorkbenchAdapter implements IAdaptable, IWorkbenchAdapter { - /** - * Constants for configuring which types of tags should be displayed. - */ + /** + * Constants for configuring which types of tags should be displayed. + */ public static final int INCLUDE_HEAD_TAG = 1; public static final int INCLUDE_BASE_TAG = 2; public static final int INCLUDE_BRANCHES = 4; @@ -86,26 +86,26 @@ public class TagSourceWorkbenchAdapter implements IAdaptable, IWorkbenchAdapter } - /** - * Create a viewer input for the tag source - * @param tagSource the tag source - * @param includeFlags the types of tags to include - * @return a tree viewer input - */ - public static Object createInput(TagSource tagSource, int includeFlags) { - if (includeFlags == INCLUDE_VERSIONS) { - // Versions only is requested by the merge start page. - // Only need to show version tags - return new TagRootElement(null, tagSource, CVSTag.VERSION); - } - return new TagSourceWorkbenchAdapter(tagSource, includeFlags); - } - + /** + * Create a viewer input for the tag source + * @param tagSource the tag source + * @param includeFlags the types of tags to include + * @return a tree viewer input + */ + public static Object createInput(TagSource tagSource, int includeFlags) { + if (includeFlags == INCLUDE_VERSIONS) { + // Versions only is requested by the merge start page. + // Only need to show version tags + return new TagRootElement(null, tagSource, CVSTag.VERSION); + } + return new TagSourceWorkbenchAdapter(tagSource, includeFlags); + } + public TagSourceWorkbenchAdapter(TagSource tagSource, int includeFlags) { this.includeFlags = includeFlags; if (this.includeFlags == 0) this.includeFlags = INCLUDE_ALL_TAGS; if ((includeFlags & INCLUDE_BRANCHES) > 0) { - branches = new TagRootElement(this, tagSource, CVSTag.BRANCH); + branches = new TagRootElement(this, tagSource, CVSTag.BRANCH); } if ((includeFlags & INCLUDE_VERSIONS) > 0) { versions = new TagRootElement(this, tagSource, CVSTag.VERSION); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AddWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AddWizard.java index 7144e81c9..4aa2694ef 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AddWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/AddWizard.java @@ -31,12 +31,12 @@ import org.eclipse.ui.PlatformUI; public class AddWizard extends ResizableWizard { - private final AddOperation op; - private final IFile[] unknowns; - private CommitWizardFileTypePage fFileTypePage; + private final AddOperation op; + private final IFile[] unknowns; + private CommitWizardFileTypePage fFileTypePage; - public static void run(Shell shell, final AddOperation op) throws InvocationTargetException, InterruptedException { - // Prompt if there are files of unknown type being added + public static void run(Shell shell, final AddOperation op) throws InvocationTargetException, InterruptedException { + // Prompt if there are files of unknown type being added PlatformUI.getWorkbench().getProgressService().run(true, true, monitor -> { try { op.buildScope(monitor); @@ -44,17 +44,17 @@ public class AddWizard extends ResizableWizard { throw new InvocationTargetException(e); } }); - - IFile[] unknowns = getUnaddedWithUnknownFileType(op.getTraversals()); - if (unknowns.length == 0) { - op.run(); - } else { - AddWizard wizard = new AddWizard(op, unknowns); - ResizableWizard.open(shell, wizard); - } - } - - private static IFile[] getUnaddedWithUnknownFileType(final ResourceTraversal[] traversals) throws InvocationTargetException, InterruptedException { + + IFile[] unknowns = getUnaddedWithUnknownFileType(op.getTraversals()); + if (unknowns.length == 0) { + op.run(); + } else { + AddWizard wizard = new AddWizard(op, unknowns); + ResizableWizard.open(shell, wizard); + } + } + + private static IFile[] getUnaddedWithUnknownFileType(final ResourceTraversal[] traversals) throws InvocationTargetException, InterruptedException { final List<IResource> unadded = new ArrayList<>(); PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { final IFileContentManager manager = Team.getFileContentManager(); @@ -88,77 +88,77 @@ public class AddWizard extends ResizableWizard { throw new InvocationTargetException(e); } } - } + } }); - return unadded.toArray(new IFile[unadded.size()]); - } - - public AddWizard(AddOperation op, IFile[] unknowns) { - super("AddWizard", CVSUIPlugin.getPlugin().getDialogSettings()); //$NON-NLS-1$ - this.op = op; - this.unknowns = unknowns; - setWindowTitle(CVSUIMessages.AddWizard_0); - setDefaultPageImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); - } - - @Override - public void addPages() { - - final Collection<String> names= new HashSet<String>(); - final Collection<String> extensions= new HashSet<String>(); - getUnknownNamesAndExtension(unknowns, names, extensions); - - if (names.size() + extensions.size() > 0) { - fFileTypePage= new CommitWizardFileTypePage(extensions, names); - addPage(fFileTypePage); - } - - super.addPages(); - } - - private static void getUnknownNamesAndExtension(IFile[] files, Collection<String> names, Collection<String> extensions) { - - final IFileContentManager manager= Team.getFileContentManager(); - - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - - final String extension= file.getFileExtension(); - if (extension != null && !manager.isKnownExtension(extension)) { - extensions.add(extension); - } - - final String name= file.getName(); - if (extension == null && name != null && !manager.isKnownFilename(name)) - names.add(name); - } - } - - @Override + return unadded.toArray(new IFile[unadded.size()]); + } + + public AddWizard(AddOperation op, IFile[] unknowns) { + super("AddWizard", CVSUIPlugin.getPlugin().getDialogSettings()); //$NON-NLS-1$ + this.op = op; + this.unknowns = unknowns; + setWindowTitle(CVSUIMessages.AddWizard_0); + setDefaultPageImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); + } + + @Override + public void addPages() { + + final Collection<String> names= new HashSet<String>(); + final Collection<String> extensions= new HashSet<String>(); + getUnknownNamesAndExtension(unknowns, names, extensions); + + if (names.size() + extensions.size() > 0) { + fFileTypePage= new CommitWizardFileTypePage(extensions, names); + addPage(fFileTypePage); + } + + super.addPages(); + } + + private static void getUnknownNamesAndExtension(IFile[] files, Collection<String> names, Collection<String> extensions) { + + final IFileContentManager manager= Team.getFileContentManager(); + + for (int i = 0; i < files.length; i++) { + IFile file = files[i]; + + final String extension= file.getFileExtension(); + if (extension != null && !manager.isKnownExtension(extension)) { + extensions.add(extension); + } + + final String name= file.getName(); + if (extension == null && name != null && !manager.isKnownFilename(name)) + names.add(name); + } + } + + @Override public boolean performFinish() { - final Map extensionsToSave= new HashMap(); - final Map extensionsNotToSave= new HashMap(); - - fFileTypePage.getModesForExtensions(extensionsToSave, extensionsNotToSave); - CommitWizardFileTypePage.saveExtensionMappings(extensionsToSave); - op.addModesForExtensions(extensionsNotToSave); - - final Map namesToSave= new HashMap(); - final Map namesNotToSave= new HashMap(); - - fFileTypePage.getModesForNames(namesToSave, namesNotToSave); - CommitWizardFileTypePage.saveNameMappings(namesToSave); - op.addModesForNames(namesNotToSave); - - try { - op.run(); - } catch (InvocationTargetException e) { - return false; - } catch (InterruptedException e) { - return false; - } - - return super.performFinish(); - } - + final Map extensionsToSave= new HashMap(); + final Map extensionsNotToSave= new HashMap(); + + fFileTypePage.getModesForExtensions(extensionsToSave, extensionsNotToSave); + CommitWizardFileTypePage.saveExtensionMappings(extensionsToSave); + op.addModesForExtensions(extensionsNotToSave); + + final Map namesToSave= new HashMap(); + final Map namesNotToSave= new HashMap(); + + fFileTypePage.getModesForNames(namesToSave, namesNotToSave); + CommitWizardFileTypePage.saveNameMappings(namesToSave); + op.addModesForNames(namesNotToSave); + + try { + op.run(); + } catch (InvocationTargetException e) { + return false; + } catch (InterruptedException e) { + return false; + } + + return super.performFinish(); + } + } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java index 81076abd3..48d0f85d4 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CVSWizardPage.java @@ -40,7 +40,7 @@ import org.eclipse.ui.views.navigator.ResourceComparator; * for widget creation. */ public abstract class CVSWizardPage extends WizardPage { - + protected static final int LABEL_WIDTH_HINT = 400; protected static final int LABEL_INDENT_WIDTH = 32; protected static final int LIST_HEIGHT_HINT = 100; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java index 060b5b321..111b1ef9d 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsLocationSelectionPage.java @@ -55,12 +55,12 @@ public class CheckoutAsLocationSelectionPage extends CVSWizardPage { // constants private static final int SIZING_TEXT_FIELD_WIDTH = 250; - private static final int COMBO_HISTORY_LENGTH = 5; + private static final int COMBO_HISTORY_LENGTH = 5; + + // store id constants + private static final String STORE_PREVIOUS_LOCATIONS = + "CheckoutAsLocationSelectionPage.STORE_PREVIOUS_LOCATIONS";//$NON-NLS-1$ - // store id constants - private static final String STORE_PREVIOUS_LOCATIONS = - "CheckoutAsLocationSelectionPage.STORE_PREVIOUS_LOCATIONS";//$NON-NLS-1$ - /** * @param pageName * @param title @@ -110,7 +110,7 @@ public class CheckoutAsLocationSelectionPage extends CVSWizardPage { // required in order to use setButtonLayoutData initializeDialogUnits(composite); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CHECKOUT_LOCATION_SELECTION_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CHECKOUT_LOCATION_SELECTION_PAGE); final Button useDefaultsButton = new Button(composite, SWT.CHECK | SWT.RIGHT); @@ -118,7 +118,7 @@ public class CheckoutAsLocationSelectionPage extends CVSWizardPage { useDefaultsButton.setSelection(this.useDefaults); createUserSpecifiedProjectLocationGroup(composite, !this.useDefaults); - initializeValues(); + initializeValues(); SelectionListener listener = new SelectionAdapter() { @Override @@ -132,7 +132,7 @@ public class CheckoutAsLocationSelectionPage extends CVSWizardPage { } }; useDefaultsButton.addSelectionListener(listener); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); } /** @@ -182,77 +182,77 @@ public class CheckoutAsLocationSelectionPage extends CVSWizardPage { return projectGroup; } - /** - * Initializes states of the controls. - */ - private void initializeValues() { - // Set remembered values - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] previouseLocations = settings.getArray(STORE_PREVIOUS_LOCATIONS); - if (previouseLocations != null) { - for (int i = 0; i < previouseLocations.length; i++) { - if(isSingleFolder()) - locationPathField.add(new Path(previouseLocations[i]).append(getSingleProject().getName()).toOSString()); - else - locationPathField.add(previouseLocations[i]); - } - } - } - } - - /** - * Saves the widget values - */ - private void saveWidgetValues() { - // Update history - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - String[] previouseLocations = settings.getArray(STORE_PREVIOUS_LOCATIONS); - if (previouseLocations == null) previouseLocations = new String[0]; - if(isSingleFolder()) - previouseLocations = addToHistory(previouseLocations, new Path(locationPathField.getText()).removeLastSegments(1).toOSString()); - else - previouseLocations = addToHistory(previouseLocations, locationPathField.getText()); - settings.put(STORE_PREVIOUS_LOCATIONS, previouseLocations); - } - } + /** + * Initializes states of the controls. + */ + private void initializeValues() { + // Set remembered values + IDialogSettings settings = getDialogSettings(); + if (settings != null) { + String[] previouseLocations = settings.getArray(STORE_PREVIOUS_LOCATIONS); + if (previouseLocations != null) { + for (int i = 0; i < previouseLocations.length; i++) { + if(isSingleFolder()) + locationPathField.add(new Path(previouseLocations[i]).append(getSingleProject().getName()).toOSString()); + else + locationPathField.add(previouseLocations[i]); + } + } + } + } + + /** + * Saves the widget values + */ + private void saveWidgetValues() { + // Update history + IDialogSettings settings = getDialogSettings(); + if (settings != null) { + String[] previouseLocations = settings.getArray(STORE_PREVIOUS_LOCATIONS); + if (previouseLocations == null) previouseLocations = new String[0]; + if(isSingleFolder()) + previouseLocations = addToHistory(previouseLocations, new Path(locationPathField.getText()).removeLastSegments(1).toOSString()); + else + previouseLocations = addToHistory(previouseLocations, locationPathField.getText()); + settings.put(STORE_PREVIOUS_LOCATIONS, previouseLocations); + } + } - /** - * Adds an entry to a history, while taking care of duplicate history items - * and excessively long histories. The assumption is made that all histories - * should be of length <code>CheckoutAsLocationSelectionPage.COMBO_HISTORY_LENGTH</code>. - * - * @param history the current history - * @param newEntry the entry to add to the history - * @return the history with the new entry appended - */ - private String[] addToHistory(String[] history, String newEntry) { + /** + * Adds an entry to a history, while taking care of duplicate history items + * and excessively long histories. The assumption is made that all histories + * should be of length <code>CheckoutAsLocationSelectionPage.COMBO_HISTORY_LENGTH</code>. + * + * @param history the current history + * @param newEntry the entry to add to the history + * @return the history with the new entry appended + */ + private String[] addToHistory(String[] history, String newEntry) { ArrayList<String> l = new ArrayList<>(Arrays.asList(history)); - addToHistory(l, newEntry); - String[] r = new String[l.size()]; - l.toArray(r); - return r; - } - - /** - * Adds an entry to a history, while taking care of duplicate history items - * and excessively long histories. The assumption is made that all histories - * should be of length <code>CheckoutAsLocationSelectionPage.COMBO_HISTORY_LENGTH</code>. - * - * @param history the current history - * @param newEntry the entry to add to the history - */ + addToHistory(l, newEntry); + String[] r = new String[l.size()]; + l.toArray(r); + return r; + } + + /** + * Adds an entry to a history, while taking care of duplicate history items + * and excessively long histories. The assumption is made that all histories + * should be of length <code>CheckoutAsLocationSelectionPage.COMBO_HISTORY_LENGTH</code>. + * + * @param history the current history + * @param newEntry the entry to add to the history + */ private void addToHistory(List<String> history, String newEntry) { - history.remove(newEntry); - history.add(0,newEntry); - - // since only one new item was added, we can be over the limit - // by at most one item - if (history.size() > COMBO_HISTORY_LENGTH) - history.remove(COMBO_HISTORY_LENGTH); - } - + history.remove(newEntry); + history.add(0,newEntry); + + // since only one new item was added, we can be over the limit + // by at most one item + if (history.size() > COMBO_HISTORY_LENGTH) + history.remove(COMBO_HISTORY_LENGTH); + } + /** * Check if the entry in the widget location is valid. If it is valid return null. Otherwise * return a string that indicates the problem. @@ -384,9 +384,9 @@ public class CheckoutAsLocationSelectionPage extends CVSWizardPage { */ public String getTargetLocation() { if (isCustomLocationSpecified()) { - saveWidgetValues(); - return targetLocation; - } + saveWidgetValues(); + return targetLocation; + } return null; } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java index 4a2dc12ad..69a4a9d5e 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsMainPage.java @@ -74,7 +74,7 @@ public class CheckoutAsMainPage extends CVSWizardPage { Composite composite = createComposite(parent, 1, false); setControl(composite); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CHECKOUT_CONFIGURATION_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CHECKOUT_CONFIGURATION_PAGE); if (isSingleFolder()) { createSingleFolderArea(composite); @@ -83,7 +83,7 @@ public class CheckoutAsMainPage extends CVSWizardPage { } updateEnablements(); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); } /* diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java index a3de224d6..53f47a364 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsProjectSelectionPage.java @@ -87,7 +87,7 @@ public class CheckoutAsProjectSelectionPage extends CVSWizardPage { Composite composite= createComposite(parent, 2, false); setControl(composite); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CHECKOUT_PROJECT_SELECTION_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CHECKOUT_PROJECT_SELECTION_PAGE); if (isSingleFolder()) { createLabel(composite, CVSUIMessages.CheckoutAsProjectSelectionPage_name); @@ -123,7 +123,7 @@ public class CheckoutAsProjectSelectionPage extends CVSWizardPage { initializeValues(); updateWidgetEnablements(); tree.getControl().setFocus(); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); } /** diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java index 0494a1d92..7bae109da 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CheckoutAsWizard.java @@ -70,22 +70,22 @@ public class CheckoutAsWizard extends Wizard { } } - /** - * Return the settings used for all CheckoutAsWizard pages - */ - public static IDialogSettings getCheckoutAsDialogSettings() { - IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); - IDialogSettings section = workbenchSettings.getSection("CheckoutAsWizard");//$NON-NLS-1$ - if (section == null) { - section = workbenchSettings.addNewSection("CheckoutAsWizard");//$NON-NLS-1$ - } - return section; - } - + /** + * Return the settings used for all CheckoutAsWizard pages + */ + public static IDialogSettings getCheckoutAsDialogSettings() { + IDialogSettings workbenchSettings = CVSUIPlugin.getPlugin().getDialogSettings(); + IDialogSettings section = workbenchSettings.getSection("CheckoutAsWizard");//$NON-NLS-1$ + if (section == null) { + section = workbenchSettings.addNewSection("CheckoutAsWizard");//$NON-NLS-1$ + } + return section; + } + public CheckoutAsWizard(IWorkbenchPart part, ICVSRemoteFolder[] remoteFolders, boolean allowProjectConfiguration) { this.part = part; this.remoteFolders = remoteFolders; - setDialogSettings(getCheckoutAsDialogSettings()); + setDialogSettings(getCheckoutAsDialogSettings()); setWindowTitle(CVSUIMessages.CheckoutAsWizard_title); this.allowProjectConfiguration = allowProjectConfiguration; } @@ -105,11 +105,11 @@ public class CheckoutAsWizard extends Wizard { addPage(locationSelectionPage); tagSelectionPage = new TagSelectionWizardPage("tagPage", CVSUIMessages.CheckoutAsWizard_3, substImage, CVSUIMessages.CheckoutAsWizard_4, TagSource.create(remoteFolders), //$NON-NLS-1$ - TagSelectionArea.INCLUDE_HEAD_TAG | - TagSelectionArea.INCLUDE_BRANCHES | - TagSelectionArea.INCLUDE_VERSIONS | - TagSelectionArea.INCLUDE_DATES - ); + TagSelectionArea.INCLUDE_HEAD_TAG | + TagSelectionArea.INCLUDE_BRANCHES | + TagSelectionArea.INCLUDE_VERSIONS | + TagSelectionArea.INCLUDE_DATES + ); if (remoteFolders.length > 0) { try { CVSTag selectedTag = remoteFolders[0].getFolderSyncInfo().getTag(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java index c42d365db..1e98440b5 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizard.java @@ -55,84 +55,84 @@ import org.eclipse.ui.PlatformUI; * of a set of <code>SyncInfo</code>. */ public class CommitWizard extends ResizableWizard { - + public static final String COMMIT_WIZARD_DIALOG_SETTINGS = "CommitWizard"; //$NON-NLS-1$ - /** - * An operation to add and commit resources to a CVS repository. - */ - public static class AddAndCommitOperation extends CVSOperation { - - private final IResource[] fAllResources; - private final String fComment; - - private Map fModesForExtensionsForOneTime; - private Map fModesForNamesForOneTime; - - private IResource[] fNewResources; + /** + * An operation to add and commit resources to a CVS repository. + */ + public static class AddAndCommitOperation extends CVSOperation { + + private final IResource[] fAllResources; + private final String fComment; + + private Map fModesForExtensionsForOneTime; + private Map fModesForNamesForOneTime; + + private IResource[] fNewResources; private IJobChangeListener jobListener; - - public AddAndCommitOperation(IWorkbenchPart part, IResource[] allResources, IResource[] newResources, String comment) { - super(part); - fAllResources = allResources; - fNewResources = newResources; - fModesForExtensionsForOneTime = Collections.EMPTY_MAP; - fModesForNamesForOneTime= Collections.EMPTY_MAP; - fComment = comment; - } - - public void setModesForExtensionsForOneTime(Map modes) { - if (modes != null) - fModesForExtensionsForOneTime= modes; - } - - public void setModesForNamesForOneTime(Map modes) { - if (modes != null) - fModesForNamesForOneTime= modes; - } - - @Override + + public AddAndCommitOperation(IWorkbenchPart part, IResource[] allResources, IResource[] newResources, String comment) { + super(part); + fAllResources = allResources; + fNewResources = newResources; + fModesForExtensionsForOneTime = Collections.EMPTY_MAP; + fModesForNamesForOneTime= Collections.EMPTY_MAP; + fComment = comment; + } + + public void setModesForExtensionsForOneTime(Map modes) { + if (modes != null) + fModesForExtensionsForOneTime= modes; + } + + public void setModesForNamesForOneTime(Map modes) { + if (modes != null) + fModesForNamesForOneTime= modes; + } + + @Override protected void execute(IProgressMonitor monitor) throws CVSException, InterruptedException { - try { - monitor.beginTask(null, (fNewResources.length + fAllResources.length) * 100); - if (fNewResources.length > 0) { - final AddOperation op= new AddOperation(getPart(), RepositoryProviderOperation.asResourceMappers(fNewResources)); - op.addModesForExtensions(fModesForExtensionsForOneTime); - op.addModesForNames(fModesForNamesForOneTime); - op.run(Policy.subMonitorFor(monitor, fNewResources.length * 100)); - } - if (fAllResources.length > 0) { - CommitOperation commitOperation = new CommitOperation(getPart(), RepositoryProviderOperation.asResourceMappers(fAllResources), new Command.LocalOption[0], fComment) { - @Override + try { + monitor.beginTask(null, (fNewResources.length + fAllResources.length) * 100); + if (fNewResources.length > 0) { + final AddOperation op= new AddOperation(getPart(), RepositoryProviderOperation.asResourceMappers(fNewResources)); + op.addModesForExtensions(fModesForExtensionsForOneTime); + op.addModesForNames(fModesForNamesForOneTime); + op.run(Policy.subMonitorFor(monitor, fNewResources.length * 100)); + } + if (fAllResources.length > 0) { + CommitOperation commitOperation = new CommitOperation(getPart(), RepositoryProviderOperation.asResourceMappers(fAllResources), new Command.LocalOption[0], fComment) { + @Override public boolean consultModelsForMappings() { - // Do not consult models from the commit wizard - return false; - } - }; + // Do not consult models from the commit wizard + return false; + } + }; commitOperation.run(Policy.subMonitorFor(monitor, fAllResources.length * 100)); - } - } catch (InvocationTargetException e) { - throw CVSException.wrapException(e); - } finally { - monitor.done(); - } - } - - @Override + } + } catch (InvocationTargetException e) { + throw CVSException.wrapException(e); + } finally { + monitor.done(); + } + } + + @Override protected String getJobName() { - return CVSUIMessages.CommitWizard_0; - } - - @Override + return CVSUIMessages.CommitWizard_0; + } + + @Override protected String getTaskName() { - return CVSUIMessages.CommitWizard_1; - } + return CVSUIMessages.CommitWizard_1; + } - /* - * Set the job listener. It will only recieve scheduled and done - * events as these are what are used by a sync model operation - * to show busy state in the sync view. - */ + /* + * Set the job listener. It will only recieve scheduled and done + * events as these are what are used by a sync model operation + * to show busy state in the sync view. + */ protected void setJobChangeListener(IJobChangeListener jobListener) { this.jobListener = jobListener; } @@ -150,36 +150,36 @@ public class CommitWizard extends ResizableWizard { if (jobListener != null) jobListener.scheduled(event); } - } - - private final IResource[] fResources; - private IResource[] fUnaddedDiffs; - private final ModelSynchronizeParticipant fParticipant; - - private CommitWizardFileTypePage fFileTypePage; - private CommitWizardCommitPage fCommitPage; + } + + private final IResource[] fResources; + private IResource[] fUnaddedDiffs; + private final ModelSynchronizeParticipant fParticipant; + + private CommitWizardFileTypePage fFileTypePage; + private CommitWizardCommitPage fCommitPage; private IJobChangeListener jobListener; private IWorkbenchPart part; - - public CommitWizard(SyncInfoSet infos) throws CVSException { - this(infos.getResources()); - } - - public CommitWizard(final IResource [] resources) throws CVSException { - - super(COMMIT_WIZARD_DIALOG_SETTINGS, CVSUIPlugin.getPlugin().getDialogSettings()); - - setNeedsProgressMonitor(true); - setWindowTitle(CVSUIMessages.CommitWizard_2); - setDefaultPageImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); - - fResources= resources; - ResourceMapping[] mappings = Utils.getResourceMappings(resources); - fParticipant = createWorkspaceParticipant(mappings, getShell()); + + public CommitWizard(SyncInfoSet infos) throws CVSException { + this(infos.getResources()); + } + + public CommitWizard(final IResource [] resources) throws CVSException { + + super(COMMIT_WIZARD_DIALOG_SETTINGS, CVSUIPlugin.getPlugin().getDialogSettings()); + + setNeedsProgressMonitor(true); + setWindowTitle(CVSUIMessages.CommitWizard_2); + setDefaultPageImageDescriptor(CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_NEW_LOCATION)); + + fResources= resources; + ResourceMapping[] mappings = Utils.getResourceMappings(resources); + fParticipant = createWorkspaceParticipant(mappings, getShell()); - getAllOutOfSync(); - fUnaddedDiffs = getUnaddedResources(getDiffTree().getAffectedResources()); - } + getAllOutOfSync(); + fUnaddedDiffs = getUnaddedResources(getDiffTree().getAffectedResources()); + } private ModelSynchronizeParticipant createWorkspaceParticipant(ResourceMapping[] selectedMappings, Shell shell) { ISynchronizationScopeManager manager = WorkspaceSubscriberContext.createWorkspaceScopeManager(selectedMappings, true, CommitAction.isIncludeChangeSets(shell, CVSUIMessages.SyncAction_1)); @@ -202,18 +202,18 @@ public class CommitWizard extends ResizableWizard { } } - public boolean hasOutgoingChanges() { - IResourceDiffTree tree = getDiffTree(); + public boolean hasOutgoingChanges() { + IResourceDiffTree tree = getDiffTree(); return tree != null && tree.hasMatchingDiffs(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), new FastDiffFilter() { @Override public boolean select(IDiff diff) { return AbstractCommitAction.hasLocalChange(diff); } }); - } - - boolean hasConflicts() { - IResourceDiffTree tree = getDiffTree(); + } + + boolean hasConflicts() { + IResourceDiffTree tree = getDiffTree(); return tree != null && tree.hasMatchingDiffs(ResourcesPlugin.getWorkspace().getRoot().getFullPath(), new FastDiffFilter() { @Override public boolean select(IDiff diff) { @@ -225,156 +225,156 @@ public class CommitWizard extends ResizableWizard { } }); } - - public int getHighestProblemSeverity() { + + public int getHighestProblemSeverity() { IResource[] resources = getDiffTree().getAffectedResources(); - int mostSeriousSeverity = -1; - - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - try { - int severity = resource.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_ZERO); - if (severity > mostSeriousSeverity) { + int mostSeriousSeverity = -1; + + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + try { + int severity = resource.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_ZERO); + if (severity > mostSeriousSeverity) { mostSeriousSeverity = severity; } } catch (CoreException e) { } - } - - return mostSeriousSeverity; - } + } + + return mostSeriousSeverity; + } IResourceDiffTree getDiffTree() { return fParticipant.getContext().getDiffTree(); } - public CommitWizardFileTypePage getFileTypePage() { - return fFileTypePage; - } + public CommitWizardFileTypePage getFileTypePage() { + return fFileTypePage; + } - public CommitWizardCommitPage getCommitPage() { - return fCommitPage; - } + public CommitWizardCommitPage getCommitPage() { + return fCommitPage; + } public ModelSynchronizeParticipant getParticipant() { - return fParticipant; - } + return fParticipant; + } - @Override + @Override public boolean canFinish() { - final IWizardPage current= getContainer().getCurrentPage(); - if (current == fFileTypePage && fCommitPage != null) - return false; - return super.canFinish(); - } + final IWizardPage current= getContainer().getCurrentPage(); + if (current == fFileTypePage && fCommitPage != null) + return false; + return super.canFinish(); + } - @Override + @Override public boolean performFinish() { - - final String comment= fCommitPage.getComment(getShell()); - if (comment == null) - return false; - - IResource[] resources = AbstractCommitAction.getOutgoingChanges(getDiffTree(), fCommitPage.getTraversalsToCommit(), null); - if (resources.length == 0) + + final String comment= fCommitPage.getComment(getShell()); + if (comment == null) + return false; + + IResource[] resources = AbstractCommitAction.getOutgoingChanges(getDiffTree(), fCommitPage.getTraversalsToCommit(), null); + if (resources.length == 0) return true; - - final IResource[] unadded; - try { - unadded = getUnaddedResources(resources); - } catch (CVSException e1) { - return false; - } - - final IResource[] files = getFiles(resources); - - final AddAndCommitOperation operation= new AddAndCommitOperation(getPart(), files, unadded, comment); - if (jobListener != null) - operation.setJobChangeListener(jobListener); - - if (fFileTypePage != null) { - final Map extensionsToSave= new HashMap(); - final Map extensionsNotToSave= new HashMap(); - - fFileTypePage.getModesForExtensions(extensionsToSave, extensionsNotToSave); - CommitWizardFileTypePage.saveExtensionMappings(extensionsToSave); - operation.setModesForExtensionsForOneTime(extensionsNotToSave); - - final Map namesToSave= new HashMap(); - final Map namesNotToSave= new HashMap(); - - fFileTypePage.getModesForNames(namesToSave, namesNotToSave); - CommitWizardFileTypePage.saveNameMappings(namesToSave); - operation.setModesForNamesForOneTime(namesNotToSave); - } - - try { - operation.run(); - } catch (InvocationTargetException e) { - return false; - } catch (InterruptedException e) { - return false; - } - - fCommitPage.finish(); - return super.performFinish(); - } - - @Override + + final IResource[] unadded; + try { + unadded = getUnaddedResources(resources); + } catch (CVSException e1) { + return false; + } + + final IResource[] files = getFiles(resources); + + final AddAndCommitOperation operation= new AddAndCommitOperation(getPart(), files, unadded, comment); + if (jobListener != null) + operation.setJobChangeListener(jobListener); + + if (fFileTypePage != null) { + final Map extensionsToSave= new HashMap(); + final Map extensionsNotToSave= new HashMap(); + + fFileTypePage.getModesForExtensions(extensionsToSave, extensionsNotToSave); + CommitWizardFileTypePage.saveExtensionMappings(extensionsToSave); + operation.setModesForExtensionsForOneTime(extensionsNotToSave); + + final Map namesToSave= new HashMap(); + final Map namesNotToSave= new HashMap(); + + fFileTypePage.getModesForNames(namesToSave, namesNotToSave); + CommitWizardFileTypePage.saveNameMappings(namesToSave); + operation.setModesForNamesForOneTime(namesNotToSave); + } + + try { + operation.run(); + } catch (InvocationTargetException e) { + return false; + } catch (InterruptedException e) { + return false; + } + + fCommitPage.finish(); + return super.performFinish(); + } + + @Override public boolean performCancel() { - fCommitPage.finish(); - return super.performCancel(); - } + fCommitPage.finish(); + return super.performCancel(); + } - @Override + @Override public void addPages() { - + final Collection<String> names = new HashSet<>(); final Collection<String> extensions = new HashSet<>(); - getUnknownNamesAndExtension(fUnaddedDiffs, names, extensions); - - if (names.size() + extensions.size() > 0) { - fFileTypePage= new CommitWizardFileTypePage(extensions, names); - addPage(fFileTypePage); - } - - fCommitPage= new CommitWizardCommitPage(fResources, this); - addPage(fCommitPage); - - super.addPages(); - } + getUnknownNamesAndExtension(fUnaddedDiffs, names, extensions); + + if (names.size() + extensions.size() > 0) { + fFileTypePage= new CommitWizardFileTypePage(extensions, names); + addPage(fFileTypePage); + } + + fCommitPage= new CommitWizardCommitPage(fResources, this); + addPage(fCommitPage); + + super.addPages(); + } - @Override + @Override public void dispose() { - fParticipant.dispose(); - super.dispose(); - } - - public static void run(IWorkbenchPart part, Shell shell, IResource [] resources) throws CVSException { - try { + fParticipant.dispose(); + super.dispose(); + } + + public static void run(IWorkbenchPart part, Shell shell, IResource [] resources) throws CVSException { + try { CommitWizard commitWizard = new CommitWizard(resources); commitWizard.setPart(part); run(shell, commitWizard); } catch (OperationCanceledException e) { // Ignore } - } - - private void setPart(IWorkbenchPart part) { + } + + private void setPart(IWorkbenchPart part) { this.part = part; } public static void run(Shell shell, SyncInfoSet infos, IJobChangeListener jobListener) throws CVSException { - try { + try { run(shell, new CommitWizard(infos, jobListener)); } catch (OperationCanceledException e) { // Ignore } - } + } public static void run(IWorkbenchPart part, Shell shell, final ResourceTraversal[] traversals) throws CVSException { - try { - final IResource [][] resources = new IResource[][] { null }; + try { + final IResource [][] resources = new IResource[][] { null }; PlatformUI.getWorkbench().getProgressService().busyCursorWhile(monitor -> { try { resources[0] = getDeepResourcesToCommit(traversals, monitor); @@ -393,17 +393,17 @@ public class CommitWizard extends ResizableWizard { } private IWorkbenchPart getPart() { - if (part != null) - return part; - return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().getActivePart(); - } - - private static void run(Shell shell, CommitWizard wizard) { - if (!wizard.hasOutgoingChanges()) { - MessageDialog.openInformation(shell, CVSUIMessages.CommitWizard_6, CVSUIMessages.CommitWizard_7); // - } else { - int highestProblemSeverity = wizard.getHighestProblemSeverity(); - IPreferenceStore preferenceStore = CVSUIPlugin.getPlugin().getPreferenceStore(); + if (part != null) + return part; + return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().getActivePart(); + } + + private static void run(Shell shell, CommitWizard wizard) { + if (!wizard.hasOutgoingChanges()) { + MessageDialog.openInformation(shell, CVSUIMessages.CommitWizard_6, CVSUIMessages.CommitWizard_7); // + } else { + int highestProblemSeverity = wizard.getHighestProblemSeverity(); + IPreferenceStore preferenceStore = CVSUIPlugin.getPlugin().getPreferenceStore(); switch (highestProblemSeverity) { case IMarker.SEVERITY_WARNING: String allowCommitsWithWarnings = preferenceStore.getString(ICVSUIConstants.PREF_ALLOW_COMMIT_WITH_WARNINGS); @@ -424,37 +424,37 @@ public class CommitWizard extends ResizableWizard { } break; } - open(shell, wizard); - } - } + open(shell, wizard); + } + } - protected static int open(Shell shell, ResizableWizard wizard) { - final WizardDialog dialog= new WizardDialog(shell, wizard); - dialog.setPageSize(wizard.loadSize()); - return dialog.open(); - } - + protected static int open(Shell shell, ResizableWizard wizard) { + final WizardDialog dialog= new WizardDialog(shell, wizard); + dialog.setPageSize(wizard.loadSize()); + return dialog.open(); + } + private void getUnknownNamesAndExtension(IResource[] resources, Collection<String> names, Collection<String> extensions) { - final IFileContentManager manager= Team.getFileContentManager(); + final IFileContentManager manager= Team.getFileContentManager(); - for (int i = 0; i < resources.length; i++) { + for (int i = 0; i < resources.length; i++) { - IResource local = resources[i]; - if (local instanceof IFile && manager.getType((IFile)local) == Team.UNKNOWN) { - final String extension= local.getFileExtension(); - if (extension != null && !manager.isKnownExtension(extension)) { - extensions.add(extension); - } + IResource local = resources[i]; + if (local instanceof IFile && manager.getType((IFile)local) == Team.UNKNOWN) { + final String extension= local.getFileExtension(); + if (extension != null && !manager.isKnownExtension(extension)) { + extensions.add(extension); + } - final String name= local.getName(); - if (extension == null && name != null && !manager.isKnownFilename(name)) - names.add(name); - } - } - } - + final String name= local.getName(); + if (extension == null && name != null && !manager.isKnownFilename(name)) + names.add(name); + } + } + } + private IResource[] getUnaddedResources(IResource[] resources) throws CVSException { List/* <IResource> */<IResource> unadded = new ArrayList<>(); for (int i = 0; i < resources.length; i++) { @@ -474,46 +474,46 @@ public class CommitWizard extends ResizableWizard { return files.toArray(new IResource[0]); } - private static boolean isAdded(IResource resource) throws CVSException { - final ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); - if (cvsResource.isFolder()) { - return ((ICVSFolder)cvsResource).isCVSFolder(); - } - return cvsResource.isManaged(); - } + private static boolean isAdded(IResource resource) throws CVSException { + final ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); + if (cvsResource.isFolder()) { + return ((ICVSFolder)cvsResource).isCVSFolder(); + } + return cvsResource.isManaged(); + } - private static IResource[] getDeepResourcesToCommit(ResourceTraversal[] traversals, IProgressMonitor monitor) throws CoreException { + private static IResource[] getDeepResourcesToCommit(ResourceTraversal[] traversals, IProgressMonitor monitor) throws CoreException { List<IResource> roots = new ArrayList<>(); - for (int j = 0; j < traversals.length; j++) { - ResourceTraversal traversal = traversals[j]; - IResource[] resources = traversal.getResources(); - if (traversal.getDepth() == IResource.DEPTH_INFINITE) { - roots.addAll(Arrays.asList(resources)); - } else if (traversal.getDepth() == IResource.DEPTH_ZERO) { - collectShallowFiles(resources, roots); - } else if (traversal.getDepth() == IResource.DEPTH_ONE) { - collectShallowFiles(resources, roots); - for (int k = 0; k < resources.length; k++) { - IResource resource = resources[k]; - if (resource.getType() != IResource.FILE) { - collectShallowFiles(members(resource), roots); - } - } - } - } - return roots.toArray(new IResource[roots.size()]); - } + for (int j = 0; j < traversals.length; j++) { + ResourceTraversal traversal = traversals[j]; + IResource[] resources = traversal.getResources(); + if (traversal.getDepth() == IResource.DEPTH_INFINITE) { + roots.addAll(Arrays.asList(resources)); + } else if (traversal.getDepth() == IResource.DEPTH_ZERO) { + collectShallowFiles(resources, roots); + } else if (traversal.getDepth() == IResource.DEPTH_ONE) { + collectShallowFiles(resources, roots); + for (int k = 0; k < resources.length; k++) { + IResource resource = resources[k]; + if (resource.getType() != IResource.FILE) { + collectShallowFiles(members(resource), roots); + } + } + } + } + return roots.toArray(new IResource[roots.size()]); + } - private static IResource[] members(IResource resource) throws CoreException { - return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().members(resource); - } + private static IResource[] members(IResource resource) throws CoreException { + return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().members(resource); + } private static void collectShallowFiles(IResource[] resources, List<IResource> roots) { - for (int k = 0; k < resources.length; k++) { - IResource resource = resources[k]; - if (resource.getType() == IResource.FILE) - roots.add(resource); - } - } + for (int k = 0; k < resources.length; k++) { + IResource resource = resources[k]; + if (resource.getType() == IResource.FILE) + roots.add(resource); + } + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java index 353ca068f..1dad2c681 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardCommitPage.java @@ -54,44 +54,44 @@ import org.eclipse.ui.part.PageBook; * a commit comment. */ public class CommitWizardCommitPage extends WizardPage implements IPropertyChangeListener { - - public static final String SHOW_COMPARE = "ShowCompare"; //$NON-NLS-1$ - private static final String H_WEIGHT_1 = "HWeight1"; //$NON-NLS-1$ - private static final String H_WEIGHT_2 = "HWeight2"; //$NON-NLS-1$ - private static final String V_WEIGHT_1 = "VWeight1"; //$NON-NLS-1$ - private static final String V_WEIGHT_2 = "VWeight2"; //$NON-NLS-1$ - + + public static final String SHOW_COMPARE = "ShowCompare"; //$NON-NLS-1$ + private static final String H_WEIGHT_1 = "HWeight1"; //$NON-NLS-1$ + private static final String H_WEIGHT_2 = "HWeight2"; //$NON-NLS-1$ + private static final String V_WEIGHT_1 = "VWeight1"; //$NON-NLS-1$ + private static final String V_WEIGHT_2 = "VWeight2"; //$NON-NLS-1$ + private final CommitCommentArea fCommentArea; - - private ISynchronizePageConfiguration fConfiguration; - - protected final CommitWizard fWizard; - + + private ISynchronizePageConfiguration fConfiguration; + + protected final CommitWizard fWizard; + private ParticipantPagePane fPagePane; - private PageBook bottomChild; + private PageBook bottomChild; private boolean fHasConflicts; private boolean fIsEmpty; - + private SashForm horizontalSash; private SashForm verticalSash; private Splitter placeholder; private boolean showCompare; - public CommitWizardCommitPage(IResource [] resources, CommitWizard wizard) { - - super(CVSUIMessages.CommitWizardCommitPage_0); - setTitle(CVSUIMessages.CommitWizardCommitPage_0); - setDescription(CVSUIMessages.CommitWizardCommitPage_2); - - fWizard= wizard; - fCommentArea= new CommitCommentArea(); - fCommentArea.setProposedComment(getProposedComment(resources)); - if (resources.length > 0) - fCommentArea.setProject(resources[0].getProject()); - fWizard.getDiffTree().addDiffChangeListener(new IDiffChangeListener() { + public CommitWizardCommitPage(IResource [] resources, CommitWizard wizard) { + + super(CVSUIMessages.CommitWizardCommitPage_0); + setTitle(CVSUIMessages.CommitWizardCommitPage_0); + setDescription(CVSUIMessages.CommitWizardCommitPage_2); + + fWizard= wizard; + fCommentArea= new CommitCommentArea(); + fCommentArea.setProposedComment(getProposedComment(resources)); + if (resources.length > 0) + fCommentArea.setProject(resources[0].getProject()); + fWizard.getDiffTree().addDiffChangeListener(new IDiffChangeListener() { @Override public void propertyChanged(IDiffTree tree, int property, IPath[] paths) { // ignore property changes @@ -101,34 +101,34 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang Utils.syncExec((Runnable) () -> updateEnablements(), CommitWizardCommitPage.this.getControl()); } }); - } - - @Override + } + + @Override public void createControl(Composite parent) { - initializeDialogUnits(parent); - Dialog.applyDialogFont(parent); - final PixelConverter converter= new PixelConverter(parent); - - final Composite composite= new Composite(parent, SWT.NONE); - composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DEFAULT)); - // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.COMMIT_COMMENT_PAGE); - - - horizontalSash = new SashForm(composite, SWT.HORIZONTAL); - horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - verticalSash = new SashForm(horizontalSash, SWT.VERTICAL); - verticalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + initializeDialogUnits(parent); + Dialog.applyDialogFont(parent); + final PixelConverter converter= new PixelConverter(parent); + + final Composite composite= new Composite(parent, SWT.NONE); + composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DEFAULT)); + // set F1 help + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.COMMIT_COMMENT_PAGE); + + + horizontalSash = new SashForm(composite, SWT.HORIZONTAL); + horizontalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + verticalSash = new SashForm(horizontalSash, SWT.VERTICAL); + verticalSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - createCommentArea(verticalSash, converter); + createCommentArea(verticalSash, converter); - placeholder = new Splitter(horizontalSash, SWT.VERTICAL /*any*/); - placeholder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + placeholder = new Splitter(horizontalSash, SWT.VERTICAL /*any*/); + placeholder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - createChangesArea(verticalSash, converter); + createChangesArea(verticalSash, converter); - IDialogSettings section = getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); + IDialogSettings section = getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); showCompare = section == null ? false : section.getBoolean(SHOW_COMPARE); int vWeight1 = 50; int vWeight2 = 50; @@ -157,75 +157,75 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang verticalSash.setWeights(new int[] {vWeight1, vWeight2}); horizontalSash.setWeights(new int[] {hWeight1, hWeight2}); - //fSashForm.setWeights(weights); - Dialog.applyDialogFont(parent); - setControl(composite); - - fCommentArea.setFocus(); - - validatePage(false); - } - - private void createCommentArea(Composite parent, PixelConverter converter) { - Composite c = new Composite(parent, SWT.NONE); - c.setLayout(GridLayoutFactory.fillDefaults().margins(0, 0).create()); - - fCommentArea.createArea(c); - GridData gd = SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true); - fCommentArea.getComposite().setLayoutData(gd); - fCommentArea.addPropertyChangeListener(this); - - createPlaceholder(c); - } - - private void createChangesArea(Composite parent, PixelConverter converter) { - - ISynchronizeParticipant participant= fWizard.getParticipant(); - int size = fWizard.getDiffTree().getAffectedResources().length; - if (size > getFileDisplayThreshold()) { - // Create a page book to allow eventual inclusion of changes - bottomChild = new PageBook(parent, SWT.NONE); - bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, false)); - // Create composite for showing the reason for not showing the changes and a button to show them - Composite changeDesc = new Composite(bottomChild, SWT.NONE); - changeDesc.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); - SWTUtils.createLabel(changeDesc, NLS.bind(CVSUIMessages.CommitWizardCommitPage_1, new String[] { Integer.toString(size), Integer.toString(getFileDisplayThreshold()) })); - Button showChanges = new Button(changeDesc, SWT.PUSH); - showChanges.setText(CVSUIMessages.CommitWizardCommitPage_5); - showChanges.addSelectionListener(new SelectionAdapter() { - @Override + //fSashForm.setWeights(weights); + Dialog.applyDialogFont(parent); + setControl(composite); + + fCommentArea.setFocus(); + + validatePage(false); + } + + private void createCommentArea(Composite parent, PixelConverter converter) { + Composite c = new Composite(parent, SWT.NONE); + c.setLayout(GridLayoutFactory.fillDefaults().margins(0, 0).create()); + + fCommentArea.createArea(c); + GridData gd = SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true); + fCommentArea.getComposite().setLayoutData(gd); + fCommentArea.addPropertyChangeListener(this); + + createPlaceholder(c); + } + + private void createChangesArea(Composite parent, PixelConverter converter) { + + ISynchronizeParticipant participant= fWizard.getParticipant(); + int size = fWizard.getDiffTree().getAffectedResources().length; + if (size > getFileDisplayThreshold()) { + // Create a page book to allow eventual inclusion of changes + bottomChild = new PageBook(parent, SWT.NONE); + bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, false)); + // Create composite for showing the reason for not showing the changes and a button to show them + Composite changeDesc = new Composite(bottomChild, SWT.NONE); + changeDesc.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); + SWTUtils.createLabel(changeDesc, NLS.bind(CVSUIMessages.CommitWizardCommitPage_1, new String[] { Integer.toString(size), Integer.toString(getFileDisplayThreshold()) })); + Button showChanges = new Button(changeDesc, SWT.PUSH); + showChanges.setText(CVSUIMessages.CommitWizardCommitPage_5); + showChanges.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - showChangesPane(); - } - }); - showChanges.setLayoutData(new GridData()); - bottomChild.showPage(changeDesc); - // Hide compare pane - horizontalSash.setMaximizedControl(verticalSash); - } else { - final Composite composite= new Composite(parent, SWT.NONE); - composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); - composite.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); - - Control c = createChangesPage(composite, participant); - c.setLayoutData(SWTUtils.createHVFillGridData()); - } - } + showChangesPane(); + } + }); + showChanges.setLayoutData(new GridData()); + bottomChild.showPage(changeDesc); + // Hide compare pane + horizontalSash.setMaximizedControl(verticalSash); + } else { + final Composite composite= new Composite(parent, SWT.NONE); + composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); + composite.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); + + Control c = createChangesPage(composite, participant); + c.setLayoutData(SWTUtils.createHVFillGridData()); + } + } - protected void showChangesPane() { - Control c = createChangesPage(bottomChild, fWizard.getParticipant()); - bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); - bottomChild.showPage(c); - // Restore compare pane. It has been hidden when file display threshold was reached. - if (showCompare) { - horizontalSash.setMaximizedControl(null); - } - Dialog.applyDialogFont(getControl()); - ((Composite)getControl()).layout(); - } + protected void showChangesPane() { + Control c = createChangesPage(bottomChild, fWizard.getParticipant()); + bottomChild.setLayoutData(SWTUtils.createGridData(SWT.DEFAULT, SWT.DEFAULT, SWT.FILL, SWT.FILL, true, true)); + bottomChild.showPage(c); + // Restore compare pane. It has been hidden when file display threshold was reached. + if (showCompare) { + horizontalSash.setMaximizedControl(null); + } + Dialog.applyDialogFont(getControl()); + ((Composite)getControl()).layout(); + } - private Control createChangesPage(final Composite composite, ISynchronizeParticipant participant) { - fConfiguration= participant.createPageConfiguration(); + private Control createChangesPage(final Composite composite, ISynchronizeParticipant participant) { + fConfiguration= participant.createPageConfiguration(); CompareConfiguration cc = new CompareConfiguration(); cc.setLeftEditable(false); cc.setRightEditable(false); @@ -233,8 +233,8 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang Control control = input.createContents(composite); control.setLayoutData(new GridData(GridData.FILL_BOTH)); return control; - } - + } + private class CommitWizardParticipantPageCompareEditorInput extends ParticipantPageCompareEditorInput { public CommitWizardParticipantPageCompareEditorInput( @@ -259,11 +259,11 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang protected void setPageDescription(String title) { super.setPageDescription(TeamUIMessages.ParticipantPageSaveablePart_0); } - } - + } + private int getFileDisplayThreshold() { - return CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD); - } + return CVSUIPlugin.getPlugin().getPreferenceStore().getInt(ICVSUIConstants.PREF_COMMIT_FILES_DISPLAY_THRESHOLD); + } @Override public void dispose() { @@ -273,16 +273,16 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang fPagePane.dispose(); } - private void createPlaceholder(final Composite composite) { - final Composite placeholder= new Composite(composite, SWT.NONE); - placeholder.setLayoutData(new GridData(SWT.DEFAULT, convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_SPACING) /3)); - } - - public String getComment(Shell shell) { - return fCommentArea.getCommentWithPrompt(shell); - } - - @Override + private void createPlaceholder(final Composite composite) { + final Composite placeholder= new Composite(composite, SWT.NONE); + placeholder.setLayoutData(new GridData(SWT.DEFAULT, convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_SPACING) /3)); + } + + public String getComment(Shell shell) { + return fCommentArea.getCommentWithPrompt(shell); + } + + @Override public boolean isPageComplete() { /* if empty comment is not allowed (see bug 114678) */ final IPreferenceStore store = CVSUIPlugin.getPlugin() @@ -298,72 +298,72 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang } return super.isPageComplete(); } - - @Override + + @Override public void setVisible(boolean visible) { - super.setVisible(visible); - expand(); - if (visible && fConfiguration != null) { - final Viewer viewer= fConfiguration.getPage().getViewer(); - viewer.refresh(); - } - updateEnablements(); - setFocus(); - } + super.setVisible(visible); + expand(); + if (visible && fConfiguration != null) { + final Viewer viewer= fConfiguration.getPage().getViewer(); + viewer.refresh(); + } + updateEnablements(); + setFocus(); + } - protected void expand() { - if (fConfiguration != null) { - final Viewer viewer= fConfiguration.getPage().getViewer(); - if (viewer instanceof TreeViewer) { - try { - viewer.getControl().setRedraw(false); - ((TreeViewer)viewer).expandAll(); - } finally { - viewer.getControl().setRedraw(true); - } - } - } - } - + protected void expand() { + if (fConfiguration != null) { + final Viewer viewer= fConfiguration.getPage().getViewer(); + if (viewer instanceof TreeViewer) { + try { + viewer.getControl().setRedraw(false); + ((TreeViewer)viewer).expandAll(); + } finally { + viewer.getControl().setRedraw(true); + } + } + } + } + /* * Expand the sync elements and update the page enablement */ protected void updateForModelChange() { - Control control = getControl(); - if (control == null || control.isDisposed()) return; + Control control = getControl(); + if (control == null || control.isDisposed()) return; expand(); updateEnablements(); } public void updateEnablements() { - if (fConfiguration != null) { - fHasConflicts = false; - fIsEmpty = false; - + if (fConfiguration != null) { + fHasConflicts = false; + fIsEmpty = false; + if (fWizard.hasConflicts()) { - fHasConflicts = true; - } + fHasConflicts = true; + } if (!fWizard.hasOutgoingChanges()) { - fIsEmpty = true; - } - } - + fIsEmpty = true; + } + } + validatePage(false); } boolean validatePage(boolean setMessage) { - if (fCommentArea != null && fCommentArea.getComment(false).length() == 0) { - final IPreferenceStore store= CVSUIPlugin.getPlugin().getPreferenceStore(); - final String value= store.getString(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); - if (MessageDialogWithToggle.NEVER.equals(value)) { - setPageComplete(false); - if (setMessage) - setErrorMessage(CVSUIMessages.CommitWizardCommitPage_3); - return false; - } - } - - if (fHasConflicts) { + if (fCommentArea != null && fCommentArea.getComment(false).length() == 0) { + final IPreferenceStore store= CVSUIPlugin.getPlugin().getPreferenceStore(); + final String value= store.getString(ICVSUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS); + if (MessageDialogWithToggle.NEVER.equals(value)) { + setPageComplete(false); + if (setMessage) + setErrorMessage(CVSUIMessages.CommitWizardCommitPage_3); + return false; + } + } + + if (fHasConflicts) { setErrorMessage(CVSUIMessages.CommitWizardCommitPage_4); setPageComplete(false); return false; @@ -374,67 +374,67 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang setPageComplete(false); return false; } - - setPageComplete(true); - setErrorMessage(null); - return true; - } - - public void setFocus() { - fCommentArea.setFocus(); - validatePage(true); - } - - @Override + + setPageComplete(true); + setErrorMessage(null); + return true; + } + + public void setFocus() { + fCommentArea.setFocus(); + validatePage(true); + } + + @Override protected IWizardContainer getContainer() { - return super.getContainer(); - } + return super.getContainer(); + } ResourceTraversal[] getTraversalsToCommit() { return fWizard.getParticipant().getContext().getScope().getTraversals(); - } + } - @Override + @Override public void propertyChange(PropertyChangeEvent event) { - - if (event.getProperty().equals(CommitCommentArea.OK_REQUESTED)) { - final IWizardContainer container= getContainer(); - if (container instanceof WizardDialog) { - final WizardDialog dialog= (WizardDialog)container; - if (getWizard().canFinish()) { - try { - getWizard().performFinish(); - } finally { - dialog.close(); - } - } - } - } - if (event.getProperty().equals(CommitCommentArea.COMMENT_MODIFIED)) { - validatePage(true); - } - } - + + if (event.getProperty().equals(CommitCommentArea.OK_REQUESTED)) { + final IWizardContainer container= getContainer(); + if (container instanceof WizardDialog) { + final WizardDialog dialog= (WizardDialog)container; + if (getWizard().canFinish()) { + try { + getWizard().performFinish(); + } finally { + dialog.close(); + } + } + } + } + if (event.getProperty().equals(CommitCommentArea.COMMENT_MODIFIED)) { + validatePage(true); + } + } + /* * Get a proposed comment by looking at the active change sets */ - private String getProposedComment(IResource[] resourcesToCommit) { - StringBuffer comment = new StringBuffer(); - ChangeSet[] sets = CVSUIPlugin.getPlugin().getChangeSetManager().getSets(); - Arrays.sort(sets, new ChangeSetComparator()); - int numMatchedSets = 0; - for (int i = 0; i < sets.length; i++) { - ChangeSet set = sets[i]; - if (isUserSet(set) && containsOne(set, resourcesToCommit)) { - if(numMatchedSets > 0) comment.append(System.getProperty("line.separator")); //$NON-NLS-1$ - comment.append(set.getComment()); - numMatchedSets++; - } - } - return comment.toString(); - } - - private boolean isUserSet(ChangeSet set) { + private String getProposedComment(IResource[] resourcesToCommit) { + StringBuffer comment = new StringBuffer(); + ChangeSet[] sets = CVSUIPlugin.getPlugin().getChangeSetManager().getSets(); + Arrays.sort(sets, new ChangeSetComparator()); + int numMatchedSets = 0; + for (int i = 0; i < sets.length; i++) { + ChangeSet set = sets[i]; + if (isUserSet(set) && containsOne(set, resourcesToCommit)) { + if(numMatchedSets > 0) comment.append(System.getProperty("line.separator")); //$NON-NLS-1$ + comment.append(set.getComment()); + numMatchedSets++; + } + } + return comment.toString(); + } + + private boolean isUserSet(ChangeSet set) { if (set instanceof ActiveChangeSet) { ActiveChangeSet acs = (ActiveChangeSet) set; return acs.isUserCreated(); @@ -443,7 +443,7 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang } private boolean containsOne(ChangeSet set, IResource[] resourcesToCommit) { - for (int j = 0; j < resourcesToCommit.length; j++) { + for (int j = 0; j < resourcesToCommit.length; j++) { IResource resource = resourcesToCommit[j]; if (set.contains(resource)) { return true; @@ -455,14 +455,14 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang } } return false; - } + } public void finish() { int[] hWeights = horizontalSash.getWeights(); int[] vWeights = verticalSash.getWeights(); IDialogSettings section = getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); - if (section == null) - section= getDialogSettings().addNewSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); + if (section == null) + section= getDialogSettings().addNewSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); if (showCompare) { section.put(H_WEIGHT_1, hWeights[0]); section.put(H_WEIGHT_2, hWeights[1]); @@ -481,6 +481,6 @@ public class CommitWizardCommitPage extends WizardPage implements IPropertyChang } } - + } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardFileTypePage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardFileTypePage.java index 9b02b25db..0b7ce95ba 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardFileTypePage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardFileTypePage.java @@ -42,116 +42,116 @@ import org.eclipse.ui.PlatformUI; */ public class CommitWizardFileTypePage extends WizardPage { - private final Collection fExtensions; + private final Collection fExtensions; private final Collection<Item> fNames; - - public CommitWizardFileTypePage(Collection unknownExtensions, Collection unknownNames) { - super(CVSUIMessages.CommitWizardFileTypePage_0); - setTitle(CVSUIMessages.CommitWizardFileTypePage_0); - setDescription(CVSUIMessages.CommitWizardFileTypePage_2); - + + public CommitWizardFileTypePage(Collection unknownExtensions, Collection unknownNames) { + super(CVSUIMessages.CommitWizardFileTypePage_0); + setTitle(CVSUIMessages.CommitWizardFileTypePage_0); + setDescription(CVSUIMessages.CommitWizardFileTypePage_2); + fNames = new ArrayList<>(); - for (final Iterator iter = unknownNames.iterator(); iter.hasNext();) { - final String name = (String) iter.next(); - fNames.add(new FileTypeTable.Name(name, false)); - } - - fExtensions= new ArrayList(); - for (final Iterator iter = unknownExtensions.iterator(); iter.hasNext();) { - final String extension= (String)iter.next(); - fExtensions.add(new FileTypeTable.Extension(extension, false)); - } - } - - @Override + for (final Iterator iter = unknownNames.iterator(); iter.hasNext();) { + final String name = (String) iter.next(); + fNames.add(new FileTypeTable.Name(name, false)); + } + + fExtensions= new ArrayList(); + for (final Iterator iter = unknownExtensions.iterator(); iter.hasNext();) { + final String extension= (String)iter.next(); + fExtensions.add(new FileTypeTable.Extension(extension, false)); + } + } + + @Override public void createControl(Composite parent) { - - initializeDialogUnits(parent); - - final Composite composite= new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(1, false)); - // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.COMMIT_FILE_TYPES_PAGE); - - final Label label= new Label(composite, SWT.WRAP); - label.setText(CVSUIMessages.CommitWizardFileTypePage_3); - label.setLayoutData(SWTUtils.createHFillGridData()); - Dialog.applyDialogFont(composite); - - final List items= new ArrayList(); - items.addAll(fNames); - items.addAll(fExtensions); - - new FileTypeTable(composite, items, true); + + initializeDialogUnits(parent); + + final Composite composite= new Composite(parent, SWT.NONE); + composite.setLayout(new GridLayout(1, false)); + // set F1 help + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.COMMIT_FILE_TYPES_PAGE); + + final Label label= new Label(composite, SWT.WRAP); + label.setText(CVSUIMessages.CommitWizardFileTypePage_3); + label.setLayoutData(SWTUtils.createHFillGridData()); + Dialog.applyDialogFont(composite); + + final List items= new ArrayList(); + items.addAll(fNames); + items.addAll(fExtensions); + + new FileTypeTable(composite, items, true); - setControl(composite); - - } + setControl(composite); + + } public void getModesForExtensions(Map toSave, Map notToSave) { - getModes(fExtensions, toSave, notToSave); + getModes(fExtensions, toSave, notToSave); } public void getModesForNames(Map toSave, Map notToSave) { - getModes(fNames, toSave, notToSave); + getModes(fNames, toSave, notToSave); } - private static void getModes(Collection items, Map toSave, Map notToSave) { - for (final Iterator iter = items.iterator(); iter.hasNext();) { - final FileTypeTable.Item item= (FileTypeTable.Item)iter.next(); - final Map destination= item.save ? toSave : notToSave; - destination.put(item.name, Integer.valueOf(item.mode)); - } - } + private static void getModes(Collection items, Map toSave, Map notToSave) { + for (final Iterator iter = items.iterator(); iter.hasNext();) { + final FileTypeTable.Item item= (FileTypeTable.Item)iter.next(); + final Map destination= item.save ? toSave : notToSave; + destination.put(item.name, Integer.valueOf(item.mode)); + } + } - public KSubstOption getOption(IFile file) throws CVSException { - final String extension= file.getFileExtension(); - if (extension != null) { - for (Iterator iter = fExtensions.iterator(); iter.hasNext();) { - final FileTypeTable.Item element = (FileTypeTable.Item) iter.next(); - if (element.name.equals(extension)) { - return element.mode == Team.TEXT ? KSubstOption.getDefaultTextMode() : Command.KSUBST_BINARY; - } - } - } else { - final String name= file.getName(); - for (Iterator iter = fNames.iterator(); iter.hasNext();) { - FileTypeTable.Item item = (FileTypeTable.Item) iter.next(); - if (item.name.equals(name)) { - return item.mode == Team.TEXT ? KSubstOption.getDefaultTextMode() : Command.KSUBST_BINARY; - } - } - } - final ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); + public KSubstOption getOption(IFile file) throws CVSException { + final String extension= file.getFileExtension(); + if (extension != null) { + for (Iterator iter = fExtensions.iterator(); iter.hasNext();) { + final FileTypeTable.Item element = (FileTypeTable.Item) iter.next(); + if (element.name.equals(extension)) { + return element.mode == Team.TEXT ? KSubstOption.getDefaultTextMode() : Command.KSUBST_BINARY; + } + } + } else { + final String name= file.getName(); + for (Iterator iter = fNames.iterator(); iter.hasNext();) { + FileTypeTable.Item item = (FileTypeTable.Item) iter.next(); + if (item.name.equals(name)) { + return item.mode == Team.TEXT ? KSubstOption.getDefaultTextMode() : Command.KSUBST_BINARY; + } + } + } + final ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); ResourceSyncInfo fileInfo = cvsFile.getSyncInfo(); return fileInfo != null ? fileInfo.getKeywordMode() : KSubstOption.fromFile(file); - } - - public static void saveExtensionMappings(Map modesToPersist) { - - final String [] extensions= new String [modesToPersist.size()]; - final int [] modes= new int[modesToPersist.size()]; - - int index= 0; - for (Iterator iter= modesToPersist.keySet().iterator(); iter.hasNext();) { - extensions[index]= (String) iter.next(); - modes[index]= ((Integer)modesToPersist.get(extensions[index])).intValue(); - ++index; - } - Team.getFileContentManager().addExtensionMappings(extensions, modes); - } - - public static void saveNameMappings(Map modesToPersist) { - - final String [] names= new String [modesToPersist.size()]; - final int [] modes= new int[modesToPersist.size()]; - - int index= 0; - for (Iterator iter= modesToPersist.keySet().iterator(); iter.hasNext();) { - names[index]= (String) iter.next(); - modes[index]= ((Integer)modesToPersist.get(names[index])).intValue(); - ++index; - } - Team.getFileContentManager().addNameMappings(names, modes); - } + } + + public static void saveExtensionMappings(Map modesToPersist) { + + final String [] extensions= new String [modesToPersist.size()]; + final int [] modes= new int[modesToPersist.size()]; + + int index= 0; + for (Iterator iter= modesToPersist.keySet().iterator(); iter.hasNext();) { + extensions[index]= (String) iter.next(); + modes[index]= ((Integer)modesToPersist.get(extensions[index])).intValue(); + ++index; + } + Team.getFileContentManager().addExtensionMappings(extensions, modes); + } + + public static void saveNameMappings(Map modesToPersist) { + + final String [] names= new String [modesToPersist.size()]; + final int [] modes= new int[modesToPersist.size()]; + + int index= 0; + for (Iterator iter= modesToPersist.keySet().iterator(); iter.hasNext();) { + names[index]= (String) iter.next(); + modes[index]= ((Integer)modesToPersist.get(names[index])).intValue(); + ++index; + } + Team.getFileContentManager().addNameMappings(names, modes); + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java index 39836e4e4..914b204f2 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/CommitWizardParticipant.java @@ -38,116 +38,116 @@ import org.eclipse.team.ui.synchronize.*; */ public class CommitWizardParticipant extends WorkspaceModelParticipant { - /** - * The actions to be displayed in the context menu. - */ - private class ActionContribution extends SynchronizePageActionGroup { - @Override + /** + * The actions to be displayed in the context menu. + */ + private class ActionContribution extends SynchronizePageActionGroup { + @Override public void modelChanged(final ISynchronizeModelElement root) { - super.modelChanged(root); + super.modelChanged(root); Display.getDefault().asyncExec(() -> { final CommitWizardCommitPage page = fWizard.getCommitPage(); if (page != null) page.updateForModelChange(); }); - } - } - - private WorkspaceChangeSetCapability capability; - - @Override + } + } + + private WorkspaceChangeSetCapability capability; + + @Override public ChangeSetCapability getChangeSetCapability() { - if (capability == null) { - capability = new WorkspaceChangeSetCapability() { - @Override + if (capability == null) { + capability = new WorkspaceChangeSetCapability() { + @Override public boolean supportsCheckedInChangeSets() { - return false; - } - @Override + return false; + } + @Override public boolean enableActiveChangeSetsFor(ISynchronizePageConfiguration configuration) { - return false; - }; - }; - } - return capability; - } + return false; + }; + }; + } + return capability; + } - /** - * An extension of the standard label decorator which configures the keyword substitution - * mode according to the settings on the file type wizard page. - */ - private static class Decorator extends CVSParticipantLabelDecorator { - - private final CommitWizard fWizard; + /** + * An extension of the standard label decorator which configures the keyword substitution + * mode according to the settings on the file type wizard page. + */ + private static class Decorator extends CVSParticipantLabelDecorator { + + private final CommitWizard fWizard; - public Decorator(ISynchronizePageConfiguration configuration, CommitWizard wizard) { - super(configuration); - fWizard= wizard; - } - - @Override + public Decorator(ISynchronizePageConfiguration configuration, CommitWizard wizard) { + super(configuration); + fWizard= wizard; + } + + @Override protected CVSDecoration getDecoration(IResource resource) throws CoreException { - final CVSDecoration decoration= super.getDecoration(resource); - final CommitWizardFileTypePage page= fWizard.getFileTypePage(); - - if (page != null && resource instanceof IFile) - decoration.setKeywordSubstitution(page.getOption((IFile)resource).getShortDisplayText()); - return decoration; - } - } + final CVSDecoration decoration= super.getDecoration(resource); + final CommitWizardFileTypePage page= fWizard.getFileTypePage(); + + if (page != null && resource instanceof IFile) + decoration.setKeywordSubstitution(page.getOption((IFile)resource).getShortDisplayText()); + return decoration; + } + } protected static final String ACTION_GROUP = "org.eclipse.tam.cvs.ui.CommitActions"; //$NON-NLS-1$ - - final CommitWizard fWizard; + + final CommitWizard fWizard; protected Action showComparePaneAction; - - public CommitWizardParticipant(SynchronizationContext context, CommitWizard wizard) { - super(context); - fWizard= wizard; - } - - @Override + + public CommitWizardParticipant(SynchronizationContext context, CommitWizard wizard) { + super(context); + fWizard= wizard; + } + + @Override protected ILabelDecorator getLabelDecorator(ISynchronizePageConfiguration configuration) { - return new Decorator(configuration, fWizard); - } + return new Decorator(configuration, fWizard); + } - @Override + @Override protected void initializeConfiguration(final ISynchronizePageConfiguration configuration) { - super.initializeConfiguration(configuration); - configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ACTION_GROUP, ISynchronizePageConfiguration.NAVIGATE_GROUP}); - configuration.setProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU, ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU); + super.initializeConfiguration(configuration); + configuration.setProperty(ISynchronizePageConfiguration.P_TOOLBAR_MENU, new String[] {ACTION_GROUP, ISynchronizePageConfiguration.NAVIGATE_GROUP}); + configuration.setProperty(ISynchronizePageConfiguration.P_CONTEXT_MENU, ISynchronizePageConfiguration.DEFAULT_CONTEXT_MENU); configuration.addMenuGroup( ISynchronizePageConfiguration.P_CONTEXT_MENU, CONTEXT_MENU_CONTRIBUTION_GROUP_3); - configuration.addActionContribution(new ActionContribution()); + configuration.addActionContribution(new ActionContribution()); - // Wrap the container so that we can update the enablements after the runnable - // (i.e. the container resets the state to what it was at the beginning of the - // run even if the state of the page changed. Remove from View changes the state) + // Wrap the container so that we can update the enablements after the runnable + // (i.e. the container resets the state to what it was at the beginning of the + // run even if the state of the page changed. Remove from View changes the state) configuration.setRunnableContext((fork, cancelable, runnable) -> { fWizard.getContainer().run(fork, cancelable, runnable); final CommitWizardCommitPage page = fWizard.getCommitPage(); if (page != null) page.updateEnablements(); }); - configuration.setSupportedModes(ISynchronizePageConfiguration.OUTGOING_MODE); - configuration.setMode(ISynchronizePageConfiguration.OUTGOING_MODE); - configuration.addActionContribution(new SynchronizePageActionGroup() { - @Override + configuration.setSupportedModes(ISynchronizePageConfiguration.OUTGOING_MODE); + configuration.setMode(ISynchronizePageConfiguration.OUTGOING_MODE); + configuration.addActionContribution(new SynchronizePageActionGroup() { + @Override public void initialize(ISynchronizePageConfiguration configuration) { - super.initialize(configuration); - showComparePaneAction = new Action(null, Action.AS_CHECK_BOX) { - @Override + super.initialize(configuration); + showComparePaneAction = new Action(null, Action.AS_CHECK_BOX) { + @Override public void run() { - fWizard.getCommitPage().showComparePane(this.isChecked()); - } - }; - Utils.initAction(showComparePaneAction, "ComnitWizardComparePaneToggle.", Policy.getActionBundle()); //$NON-NLS-1$ - showComparePaneAction.setChecked(isComparePaneVisible()); - appendToGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ACTION_GROUP, showComparePaneAction); - } + fWizard.getCommitPage().showComparePane(this.isChecked()); + } + }; + Utils.initAction(showComparePaneAction, "ComnitWizardComparePaneToggle.", Policy.getActionBundle()); //$NON-NLS-1$ + showComparePaneAction.setChecked(isComparePaneVisible()); + appendToGroup(ISynchronizePageConfiguration.P_TOOLBAR_MENU, ACTION_GROUP, showComparePaneAction); + } }); - configuration.setProperty(SynchronizePageConfiguration.P_OPEN_ACTION, new Action() { + configuration.setProperty(SynchronizePageConfiguration.P_OPEN_ACTION, new Action() { @Override public void run() { ISelection selection = configuration.getSite().getSelectionProvider().getSelection(); @@ -159,18 +159,18 @@ public class CommitWizardParticipant extends WorkspaceModelParticipant { } } } - }); - } - - @Override + }); + } + + @Override public boolean doesSupportSynchronize() { - return false; - } - - private boolean isComparePaneVisible() { - IDialogSettings section = fWizard.getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); + return false; + } + + private boolean isComparePaneVisible() { + IDialogSettings section = fWizard.getDialogSettings().getSection(CommitWizard.COMMIT_WIZARD_DIALOG_SETTINGS); return section == null ? false : section.getBoolean(CommitWizardCommitPage.SHOW_COMPARE); - } + } @Override protected ModelSynchronizeParticipantActionGroup createMergeActionGroup() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java index 013ee872f..8b521bafc 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ConfigurationWizardAutoconnectPage.java @@ -50,7 +50,7 @@ public class ConfigurationWizardAutoconnectPage extends CVSWizardPage { setControl(composite); // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHARING_AUTOCONNECT_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHARING_AUTOCONNECT_PAGE); Label description = new Label(composite, SWT.WRAP); GridData data = new GridData(); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java index b4410999e..cd22913fa 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java @@ -582,11 +582,11 @@ public class GenerateDiffFileWizard extends Wizard { * Ensure the page is in a valid state. */ /*if (!validatePage()) { - store.storeRadioSelection(CLIPBOARD); - initializeDefaultValues(); - validatePage(); - } - pageValid= true;*/ + store.storeRadioSelection(CLIPBOARD); + initializeDefaultValues(); + validatePage(); + } + pageValid= true;*/ validatePage(); updateEnablements(); @@ -1045,7 +1045,7 @@ public class GenerateDiffFileWizard extends Wizard { public final static int FORMAT_STANDARD = 3; /** - The possible root of the patch + The possible root of the patch */ public final static int ROOT_WORKSPACE = 1; public final static int ROOT_PROJECT = 2; @@ -1303,11 +1303,11 @@ public class GenerateDiffFileWizard extends Wizard { public LocalOption[] getOptions() { List<LocalOption> options = new ArrayList<>(5); /* if(includeNewFilesOptions.getSelection()) { - options.add(Diff.INCLUDE_NEWFILES); - } - if(!recurseOption.getSelection()) { - options.add(Command.DO_NOT_RECURSE); - }*/ + options.add(Diff.INCLUDE_NEWFILES); + } + if(!recurseOption.getSelection()) { + options.add(Command.DO_NOT_RECURSE); + }*/ //Add new files for now options.add(Diff.INCLUDE_NEWFILES); @@ -1545,11 +1545,11 @@ public class GenerateDiffFileWizard extends Wizard { defaultValuesStore.storeLocationSelection(LocationPage.WORKSPACE); defaultValuesStore.storeWorkspacePath(workspaceResource); /* try { - workspaceResource.getParent().refreshLocal(IResource.DEPTH_ONE, null); - } catch(CoreException e) { - CVSUIPlugin.openError(getShell(), CVSUIMessages.GenerateCVSDiff_error, null, e); - return false; - } */ + workspaceResource.getParent().refreshLocal(IResource.DEPTH_ONE, null); + } catch(CoreException e) { + CVSUIPlugin.openError(getShell(), CVSUIMessages.GenerateCVSDiff_error, null, e); + return false; + } */ } else { //Problem with workspace location, open with clipboard next time defaultValuesStore.storeLocationSelection(LocationPage.CLIPBOARD); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java index a23484157..838639e01 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java @@ -39,21 +39,21 @@ import org.eclipse.team.ui.synchronize.ISynchronizeParticipant; import org.eclipse.ui.IWorkbenchPart; public class MergeWizard extends Wizard { - MergeWizardPage page; + MergeWizardPage page; IResource[] resources; - private final IWorkbenchPart part; - private final ResourceMapping[] mappings; - + private final IWorkbenchPart part; + private final ResourceMapping[] mappings; + public MergeWizard(IWorkbenchPart part, IResource[] resources, ResourceMapping[] mappings) { - this.part = part; - this.resources = resources; - this.mappings = mappings; - } + this.part = part; + this.resources = resources; + this.mappings = mappings; + } @Override public void addPages() { - setNeedsProgressMonitor(true); - TagSource tagSource = TagSource.create(resources); + setNeedsProgressMonitor(true); + TagSource tagSource = TagSource.create(resources); setWindowTitle(CVSUIMessages.MergeWizard_title); ImageDescriptor mergeImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_MERGE); page = new MergeWizardPage("mergePage", CVSUIMessages.MergeWizard_0, mergeImage, CVSUIMessages.MergeWizard_1, tagSource); //$NON-NLS-1$ @@ -67,21 +67,21 @@ public class MergeWizard extends Wizard { CVSTag endTag = page.getEndTag(); if (startTag == null || !page.isPreview()) { - // Perform the update (merge) in the background - UpdateOperation op = new UpdateOperation(getPart(), mappings, getLocalOptions(startTag, endTag), null); - try { - op.run(); - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getShell(), null, null, e); - } catch (InterruptedException e) { - // Ignore - } + // Perform the update (merge) in the background + UpdateOperation op = new UpdateOperation(getPart(), mappings, getLocalOptions(startTag, endTag), null); + try { + op.run(); + } catch (InvocationTargetException e) { + CVSUIPlugin.openError(getShell(), null, null, e); + } catch (InterruptedException e) { + // Ignore + } } else { if (isShowModelSync()) { ModelMergeParticipant participant = ModelMergeParticipant.getMatchingParticipant(mappings, startTag, endTag); if(participant == null) { - CVSMergeSubscriber s = new CVSMergeSubscriber(getProjects(resources), startTag, endTag, true); - try { + CVSMergeSubscriber s = new CVSMergeSubscriber(getProjects(resources), startTag, endTag, true); + try { new ModelMergeOperation(getPart(), mappings, s, page.isOnlyPreviewConflicts()).run(); } catch (InvocationTargetException e) { CVSUIPlugin.log(IStatus.ERROR, "Internal error", e.getTargetException()); //$NON-NLS-1$ @@ -93,12 +93,12 @@ public class MergeWizard extends Wizard { } } else { // First check if there is an existing matching participant, if so then re-use it - try { - resources = getAllResources(startTag, endTag); - } catch (InvocationTargetException e) { - // Log and continue with the original resources - CVSUIPlugin.log(IStatus.ERROR, "An error occurred while determining if extra resources should be included in the merge", e.getTargetException()); //$NON-NLS-1$ - } + try { + resources = getAllResources(startTag, endTag); + } catch (InvocationTargetException e) { + // Log and continue with the original resources + CVSUIPlugin.log(IStatus.ERROR, "An error occurred while determining if extra resources should be included in the merge", e.getTargetException()); //$NON-NLS-1$ + } MergeSynchronizeParticipant participant = MergeSynchronizeParticipant.getMatchingParticipant(resources, startTag, endTag); if(participant == null) { CVSMergeSubscriber s = new CVSMergeSubscriber(resources, startTag, endTag, false); @@ -113,19 +113,19 @@ public class MergeWizard extends Wizard { } private IResource[] getAllResources(CVSTag startTag, CVSTag endTag) throws InvocationTargetException { - // Only do the extra work if the model is a logical model (i.e. not IResource) - if (!WorkspaceTraversalAction.isLogicalModel(mappings)) - return resources; - CVSMergeSubscriber s = new CVSMergeSubscriber(WorkspaceTraversalAction.getProjects(resources), startTag, endTag, false); - IResource[] allResources = WorkspaceTraversalAction.getResourcesToCompare(mappings, s); - s.cancel(); - return allResources; - } + // Only do the extra work if the model is a logical model (i.e. not IResource) + if (!WorkspaceTraversalAction.isLogicalModel(mappings)) + return resources; + CVSMergeSubscriber s = new CVSMergeSubscriber(WorkspaceTraversalAction.getProjects(resources), startTag, endTag, false); + IResource[] allResources = WorkspaceTraversalAction.getResourcesToCompare(mappings, s); + s.cancel(); + return allResources; + } - public static boolean isShowModelSync() { + public static boolean isShowModelSync() { return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_ENABLE_MODEL_SYNC); } - + private IResource[] getProjects(IResource[] resources) { Set<IProject> projects = new HashSet<>(); for (int i = 0; i < resources.length; i++) { @@ -135,16 +135,16 @@ public class MergeWizard extends Wizard { return projects.toArray(new IResource[projects.size()]); } - private Command.LocalOption[] getLocalOptions(CVSTag startTag, CVSTag endTag) { + private Command.LocalOption[] getLocalOptions(CVSTag startTag, CVSTag endTag) { List<LocalOption> options = new ArrayList<>(); - if (startTag != null) { - options.add(Command.makeArgumentOption(Update.JOIN, startTag.getName())); - } - options.add(Command.makeArgumentOption(Update.JOIN, endTag.getName())); - return options.toArray(new Command.LocalOption[options.size()]); - } + if (startTag != null) { + options.add(Command.makeArgumentOption(Update.JOIN, startTag.getName())); + } + options.add(Command.makeArgumentOption(Update.JOIN, endTag.getName())); + return options.toArray(new Command.LocalOption[options.size()]); + } - private IWorkbenchPart getPart() { - return part; - } + private IWorkbenchPart getPart() { + return part; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizardPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizardPage.java index 02b52e4c7..b00039397 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizardPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizardPage.java @@ -31,275 +31,275 @@ import org.eclipse.ui.PlatformUI; public class MergeWizardPage extends CVSWizardPage { - private Text endTagField; - private Button endTagBrowseButton; - private TagSource tagSource; - private Text startTagField; - private Button startTagBrowseButton; - private TagRefreshButtonArea tagRefreshArea; - private CVSTag startTag; - private CVSTag endTag; - private Button previewButton; - private Button noPreviewButton; - protected boolean preview = true; + private Text endTagField; + private Button endTagBrowseButton; + private TagSource tagSource; + private Text startTagField; + private Button startTagBrowseButton; + private TagRefreshButtonArea tagRefreshArea; + private CVSTag startTag; + private CVSTag endTag; + private Button previewButton; + private Button noPreviewButton; + protected boolean preview = true; private Button onlyPreviewConflicts; private boolean isOnlyPreviewConflicts = false; - public MergeWizardPage(String pageName, String title, ImageDescriptor titleImage, String description, TagSource tagSource) { - super(pageName, title, titleImage, description); - this.tagSource = tagSource; - } + public MergeWizardPage(String pageName, String title, ImageDescriptor titleImage, String description, TagSource tagSource) { + super(pageName, title, titleImage, description); + this.tagSource = tagSource; + } - @Override + @Override public void createControl(Composite parent) { - - final PixelConverter converter= SWTUtils.createDialogPixelConverter(parent); - - final Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DEFAULT)); - // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.MERGE_WIZARD_PAGE); - - final Composite mainArea = new Composite(composite, SWT.NONE); - mainArea.setLayoutData(SWTUtils.createHFillGridData()); - mainArea.setLayout(SWTUtils.createGridLayout(2, converter, SWTUtils.MARGINS_NONE)); - - createEndTagArea(mainArea); - createStartTagArea(mainArea); - SWTUtils.equalizeControls(converter, new Button [] { endTagBrowseButton, startTagBrowseButton } ); - - createPreviewOptionArea(composite, converter); - createTagRefreshArea(composite); + + final PixelConverter converter= SWTUtils.createDialogPixelConverter(parent); + + final Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_DEFAULT)); + // set F1 help + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.MERGE_WIZARD_PAGE); + + final Composite mainArea = new Composite(composite, SWT.NONE); + mainArea.setLayoutData(SWTUtils.createHFillGridData()); + mainArea.setLayout(SWTUtils.createGridLayout(2, converter, SWTUtils.MARGINS_NONE)); + + createEndTagArea(mainArea); + createStartTagArea(mainArea); + SWTUtils.equalizeControls(converter, new Button [] { endTagBrowseButton, startTagBrowseButton } ); + + createPreviewOptionArea(composite, converter); + createTagRefreshArea(composite); - Dialog.applyDialogFont(composite); - setControl(composite); - } + Dialog.applyDialogFont(composite); + setControl(composite); + } - private void createPreviewOptionArea(Composite parent, PixelConverter converter) { - - final Composite composite= new Composite(parent, SWT.NONE); - composite.setLayoutData(SWTUtils.createHFillGridData()); - composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); - - previewButton = SWTUtils.createRadioButton(composite, CVSUIMessages.MergeWizardPage_0); - if (MergeWizard.isShowModelSync()) { - onlyPreviewConflicts = SWTUtils.createCheckBox(composite, CVSUIMessages.MergeWizardPage_14); - GridData data = SWTUtils.createHFillGridData(1); - data.horizontalIndent = 10; - onlyPreviewConflicts.setLayoutData(data); - } - noPreviewButton = SWTUtils.createRadioButton(composite, CVSUIMessages.MergeWizardPage_1); - SelectionAdapter selectionAdapter = new SelectionAdapter() { - @Override + private void createPreviewOptionArea(Composite parent, PixelConverter converter) { + + final Composite composite= new Composite(parent, SWT.NONE); + composite.setLayoutData(SWTUtils.createHFillGridData()); + composite.setLayout(SWTUtils.createGridLayout(1, converter, SWTUtils.MARGINS_NONE)); + + previewButton = SWTUtils.createRadioButton(composite, CVSUIMessages.MergeWizardPage_0); + if (MergeWizard.isShowModelSync()) { + onlyPreviewConflicts = SWTUtils.createCheckBox(composite, CVSUIMessages.MergeWizardPage_14); + GridData data = SWTUtils.createHFillGridData(1); + data.horizontalIndent = 10; + onlyPreviewConflicts.setLayoutData(data); + } + noPreviewButton = SWTUtils.createRadioButton(composite, CVSUIMessages.MergeWizardPage_1); + SelectionAdapter selectionAdapter = new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - preview = previewButton.getSelection(); - updateEnablements(); - } - }; - previewButton.setSelection(preview); - noPreviewButton.setSelection(!preview); - previewButton.addSelectionListener(selectionAdapter); - noPreviewButton.addSelectionListener(selectionAdapter); - if (onlyPreviewConflicts != null) { - onlyPreviewConflicts.setEnabled(preview); - onlyPreviewConflicts.setSelection(isOnlyPreviewConflicts); - onlyPreviewConflicts.addSelectionListener(new SelectionAdapter() { + preview = previewButton.getSelection(); + updateEnablements(); + } + }; + previewButton.setSelection(preview); + noPreviewButton.setSelection(!preview); + previewButton.addSelectionListener(selectionAdapter); + noPreviewButton.addSelectionListener(selectionAdapter); + if (onlyPreviewConflicts != null) { + onlyPreviewConflicts.setEnabled(preview); + onlyPreviewConflicts.setSelection(isOnlyPreviewConflicts); + onlyPreviewConflicts.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { isOnlyPreviewConflicts = onlyPreviewConflicts.getSelection(); } }); - } - } - private void createTagRefreshArea(Composite composite) { - tagRefreshArea = new TagRefreshButtonArea(getShell(), getTagSource(), null) { - @Override + } + } + private void createTagRefreshArea(Composite composite) { + tagRefreshArea = new TagRefreshButtonArea(getShell(), getTagSource(), null) { + @Override public void refresh(boolean background) { - super.refresh(background); - updateStartTag(startTagField.getText()); - updateEndTag(endTagField.getText()); - }; - }; - tagRefreshArea.setRunnableContext(getContainer()); - tagRefreshArea.createArea(composite); - } + super.refresh(background); + updateStartTag(startTagField.getText()); + updateEndTag(endTagField.getText()); + }; + }; + tagRefreshArea.setRunnableContext(getContainer()); + tagRefreshArea.createArea(composite); + } - private void createEndTagArea(Composite parent) { - SWTUtils.createLabel(parent, CVSUIMessages.MergeWizardPage_2, 2); - - endTagField = SWTUtils.createText(parent); + private void createEndTagArea(Composite parent) { + SWTUtils.createLabel(parent, CVSUIMessages.MergeWizardPage_2, 2); + + endTagField = SWTUtils.createText(parent); endTagField.addModifyListener(e -> updateEndTag(endTagField.getText())); - final int endTagIncludeFlags = TagSelectionArea.INCLUDE_VERSIONS | TagSelectionArea.INCLUDE_BRANCHES | TagSelectionArea.INCLUDE_HEAD_TAG; - TagContentAssistProcessor.createContentAssistant(endTagField, tagSource, endTagIncludeFlags); - endTagBrowseButton = createPushButton(parent, CVSUIMessages.MergeWizardPage_3); - - endTagBrowseButton.addSelectionListener(new SelectionAdapter() { - @Override + final int endTagIncludeFlags = TagSelectionArea.INCLUDE_VERSIONS | TagSelectionArea.INCLUDE_BRANCHES | TagSelectionArea.INCLUDE_HEAD_TAG; + TagContentAssistProcessor.createContentAssistant(endTagField, tagSource, endTagIncludeFlags); + endTagBrowseButton = createPushButton(parent, CVSUIMessages.MergeWizardPage_3); + + endTagBrowseButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - TagSelectionDialog dialog = new TagSelectionDialog(getShell(), getTagSource(), - CVSUIMessages.MergeWizardPage_4, - CVSUIMessages.MergeWizardPage_5, - endTagIncludeFlags, - false, IHelpContextIds.MERGE_END_PAGE); - if (dialog.open() == Window.OK) { - CVSTag selectedTag = dialog.getResult(); - setEndTag(selectedTag); - } - } - }); - } - - private void createStartTagArea(Composite parent) { - - SWTUtils.createLabel(parent, CVSUIMessages.MergeWizardPage_6, 2); + TagSelectionDialog dialog = new TagSelectionDialog(getShell(), getTagSource(), + CVSUIMessages.MergeWizardPage_4, + CVSUIMessages.MergeWizardPage_5, + endTagIncludeFlags, + false, IHelpContextIds.MERGE_END_PAGE); + if (dialog.open() == Window.OK) { + CVSTag selectedTag = dialog.getResult(); + setEndTag(selectedTag); + } + } + }); + } + + private void createStartTagArea(Composite parent) { + + SWTUtils.createLabel(parent, CVSUIMessages.MergeWizardPage_6, 2); - startTagField = SWTUtils.createText(parent); + startTagField = SWTUtils.createText(parent); startTagField.addModifyListener(e -> updateStartTag(startTagField.getText())); - TagContentAssistProcessor.createContentAssistant(startTagField, tagSource, TagSelectionArea.INCLUDE_VERSIONS); + TagContentAssistProcessor.createContentAssistant(startTagField, tagSource, TagSelectionArea.INCLUDE_VERSIONS); - startTagBrowseButton = createPushButton(parent, CVSUIMessages.MergeWizardPage_7); - startTagBrowseButton.addSelectionListener(new SelectionAdapter() { - @Override + startTagBrowseButton = createPushButton(parent, CVSUIMessages.MergeWizardPage_7); + startTagBrowseButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { - TagSelectionDialog dialog = new TagSelectionDialog(getShell(), getTagSource(), - CVSUIMessages.MergeWizardPage_8, - CVSUIMessages.MergeWizardPage_9, - TagSelectionDialog.INCLUDE_VERSIONS | TagSelectionDialog.INCLUDE_DATES, - false, IHelpContextIds.MERGE_START_PAGE); - if (dialog.open() == Window.OK) { - CVSTag selectedTag = dialog.getResult(); - setStartTag(selectedTag); - } - } - }); - } + TagSelectionDialog dialog = new TagSelectionDialog(getShell(), getTagSource(), + CVSUIMessages.MergeWizardPage_8, + CVSUIMessages.MergeWizardPage_9, + TagSelectionDialog.INCLUDE_VERSIONS | TagSelectionDialog.INCLUDE_DATES, + false, IHelpContextIds.MERGE_START_PAGE); + if (dialog.open() == Window.OK) { + CVSTag selectedTag = dialog.getResult(); + setStartTag(selectedTag); + } + } + }); + } - protected void updateEndTag(String text) { - if (endTag == null || !endTag.getName().equals(text)) { - CVSTag tag = getTagFor(text, false); - setEndTag(tag); - } - updateEnablements(); - } - - protected void updateStartTag(String text) { - if (startTag == null || !startTag.getName().equals(text)) { - CVSTag tag = getTagFor(text, true); - setStartTag(tag); - } - updateEnablements(); - } + protected void updateEndTag(String text) { + if (endTag == null || !endTag.getName().equals(text)) { + CVSTag tag = getTagFor(text, false); + setEndTag(tag); + } + updateEnablements(); + } + + protected void updateStartTag(String text) { + if (startTag == null || !startTag.getName().equals(text)) { + CVSTag tag = getTagFor(text, true); + setStartTag(tag); + } + updateEnablements(); + } - private CVSTag getTagFor(String text, boolean versionsOnly) { - if (text.equals(CVSTag.DEFAULT.getName())) { - if (versionsOnly) return null; - return CVSTag.DEFAULT; - } - if (text.equals(CVSTag.BASE.getName())) { - if (versionsOnly) return null; - return CVSTag.BASE; - } - CVSTag[] tags; - if (versionsOnly) { - tags = tagSource.getTags(new int[] { CVSTag.VERSION, CVSTag.DATE }); - } else { - tags = tagSource.getTags(new int[] { CVSTag.VERSION, CVSTag.BRANCH, CVSTag.DATE }); - } - for (int i = 0; i < tags.length; i++) { - CVSTag tag = tags[i]; - if (tag.getName().equals(text)) { - return tag; - } - } - return null; - } + private CVSTag getTagFor(String text, boolean versionsOnly) { + if (text.equals(CVSTag.DEFAULT.getName())) { + if (versionsOnly) return null; + return CVSTag.DEFAULT; + } + if (text.equals(CVSTag.BASE.getName())) { + if (versionsOnly) return null; + return CVSTag.BASE; + } + CVSTag[] tags; + if (versionsOnly) { + tags = tagSource.getTags(new int[] { CVSTag.VERSION, CVSTag.DATE }); + } else { + tags = tagSource.getTags(new int[] { CVSTag.VERSION, CVSTag.BRANCH, CVSTag.DATE }); + } + for (int i = 0; i < tags.length; i++) { + CVSTag tag = tags[i]; + if (tag.getName().equals(text)) { + return tag; + } + } + return null; + } - protected void setEndTag(CVSTag selectedTag) { - if (selectedTag == null || endTag == null || !endTag.equals(selectedTag)) { - endTag = selectedTag; - if (endTagField != null) { - String name = endTagField.getText(); - if (endTag != null) - name = endTag.getName(); - if (!endTagField.getText().equals(name)) - endTagField.setText(name); - if (startTag == null && endTag != null && endTag.getType() == CVSTag.BRANCH) { - CVSTag tag = findCommonBaseTag(endTag); - if (tag != null) { - setStartTag(tag); - } - } - } - updateEnablements(); - } - } + protected void setEndTag(CVSTag selectedTag) { + if (selectedTag == null || endTag == null || !endTag.equals(selectedTag)) { + endTag = selectedTag; + if (endTagField != null) { + String name = endTagField.getText(); + if (endTag != null) + name = endTag.getName(); + if (!endTagField.getText().equals(name)) + endTagField.setText(name); + if (startTag == null && endTag != null && endTag.getType() == CVSTag.BRANCH) { + CVSTag tag = findCommonBaseTag(endTag); + if (tag != null) { + setStartTag(tag); + } + } + } + updateEnablements(); + } + } - protected void setStartTag(CVSTag selectedTag) { - if (selectedTag == null || startTag != null || endTag == null || !endTag.equals(selectedTag)) { - startTag = selectedTag; - if (startTagField != null) { - String name = startTagField.getText(); - if (startTag != null) - name = startTag.getName(); - if (!startTagField.getText().equals(name)) - startTagField.setText(name); - } - updateEnablements(); - } - } - - private CVSTag findCommonBaseTag(CVSTag tag) { - CVSTag[] tags = tagSource.getTags(CVSTag.VERSION); - for (int i = 0; i < tags.length; i++) { - CVSTag potentialMatch = tags[i]; - if (potentialMatch.getName().indexOf(tag.getName()) != -1) { - return potentialMatch; - } - } - return null; - } + protected void setStartTag(CVSTag selectedTag) { + if (selectedTag == null || startTag != null || endTag == null || !endTag.equals(selectedTag)) { + startTag = selectedTag; + if (startTagField != null) { + String name = startTagField.getText(); + if (startTag != null) + name = startTag.getName(); + if (!startTagField.getText().equals(name)) + startTagField.setText(name); + } + updateEnablements(); + } + } + + private CVSTag findCommonBaseTag(CVSTag tag) { + CVSTag[] tags = tagSource.getTags(CVSTag.VERSION); + for (int i = 0; i < tags.length; i++) { + CVSTag potentialMatch = tags[i]; + if (potentialMatch.getName().indexOf(tag.getName()) != -1) { + return potentialMatch; + } + } + return null; + } - private void updateEnablements() { - if (onlyPreviewConflicts != null) - onlyPreviewConflicts.setEnabled(preview); - if (endTag == null && endTagField.getText().length() > 0) { - setErrorMessage(CVSUIMessages.MergeWizardPage_10); - } else if (startTag == null && startTagField.getText().length() > 0) { - setErrorMessage(CVSUIMessages.MergeWizardPage_11); - } else if (endTag != null && startTag != null && startTag.equals(endTag)) { - setErrorMessage(CVSUIMessages.MergeWizardPage_12); - } else if (startTag == null && endTag != null && preview) { - setErrorMessage(CVSUIMessages.MergeWizardPage_13); - } else { - setErrorMessage(null); - } - setPageComplete((startTag != null || !preview) && endTag != null && (startTag == null || !startTag.equals(endTag))); - } + private void updateEnablements() { + if (onlyPreviewConflicts != null) + onlyPreviewConflicts.setEnabled(preview); + if (endTag == null && endTagField.getText().length() > 0) { + setErrorMessage(CVSUIMessages.MergeWizardPage_10); + } else if (startTag == null && startTagField.getText().length() > 0) { + setErrorMessage(CVSUIMessages.MergeWizardPage_11); + } else if (endTag != null && startTag != null && startTag.equals(endTag)) { + setErrorMessage(CVSUIMessages.MergeWizardPage_12); + } else if (startTag == null && endTag != null && preview) { + setErrorMessage(CVSUIMessages.MergeWizardPage_13); + } else { + setErrorMessage(null); + } + setPageComplete((startTag != null || !preview) && endTag != null && (startTag == null || !startTag.equals(endTag))); + } - protected TagSource getTagSource() { - return tagSource; - } + protected TagSource getTagSource() { + return tagSource; + } - private Button createPushButton(Composite parent, String label) { - final Button button = new Button(parent, SWT.PUSH); - button.setText(label); - button.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); - return button; - } + private Button createPushButton(Composite parent, String label) { + final Button button = new Button(parent, SWT.PUSH); + button.setText(label); + button.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); + return button; + } - public CVSTag getStartTag() { - return startTag; - } - - public CVSTag getEndTag() { - return endTag; - } + public CVSTag getStartTag() { + return startTag; + } + + public CVSTag getEndTag() { + return endTag; + } - public boolean isPreview() { - return preview; - } - - public boolean isOnlyPreviewConflicts() { - return isOnlyPreviewConflicts; - } + public boolean isPreview() { + return preview; + } + + public boolean isOnlyPreviewConflicts() { + return isOnlyPreviewConflicts; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizard.java index dfff977c3..fa2e49126 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizard.java @@ -45,94 +45,94 @@ import org.eclipse.team.internal.ccvs.ui.Policy; * 5. Perform the operation on Finish. */ public class ModeWizard extends ResizableWizard { - - public static class ModeChange { - - private final IFile fFile; - private final KSubstOption fMode; - - private KSubstOption fNewMode; - - public ModeChange(IFile file, KSubstOption mode) { - fFile = file; - fMode= mode; - fNewMode= mode; - } - - public IFile getFile() { - return fFile; - } - - public KSubstOption getMode() { - return fMode; - } - - public KSubstOption getNewMode() { - return fNewMode; - } - - public boolean hasChanged() { - return !fMode.equals(fNewMode); - } - - public void setNewMode(KSubstOption mode) { - fNewMode= mode; - } - - public int compareTo(Object o) { - return fFile.getName().compareTo(((ModeChange)o).getFile().getName()); - } - } - - protected List fChanges; - final ModeWizardSelectionPage fPage; - - public static ModeWizard run(final Shell shell, final IResource [] resources) { - - final ModeWizard [] wizard= new ModeWizard[1]; + + public static class ModeChange { + + private final IFile fFile; + private final KSubstOption fMode; + + private KSubstOption fNewMode; + + public ModeChange(IFile file, KSubstOption mode) { + fFile = file; + fMode= mode; + fNewMode= mode; + } + + public IFile getFile() { + return fFile; + } + + public KSubstOption getMode() { + return fMode; + } + + public KSubstOption getNewMode() { + return fNewMode; + } + + public boolean hasChanged() { + return !fMode.equals(fNewMode); + } + + public void setNewMode(KSubstOption mode) { + fNewMode= mode; + } + + public int compareTo(Object o) { + return fFile.getName().compareTo(((ModeChange)o).getFile().getName()); + } + } + + protected List fChanges; + final ModeWizardSelectionPage fPage; + + public static ModeWizard run(final Shell shell, final IResource [] resources) { + + final ModeWizard [] wizard= new ModeWizard[1]; BusyIndicator.showWhile(shell.getDisplay(), () -> wizard[0] = new ModeWizard(shell, resources)); - - open(shell, wizard[0]); - return wizard[0]; - } - - /** - * Creates a wizard to set the keyword substitution mode for the specified resources. - * - * @param resources the resources to alter - * @param depth the recursion depth - * @param defaultOption the keyword substitution option to select by default - */ - - protected ModeWizard(Shell shell, final IResource[] resources) { - super(CVSUIMessages.ModeWizard_0, CVSUIPlugin.getPlugin().getDialogSettings(), 700, 480); - setWindowTitle(CVSUIMessages.ModeWizard_1); - - fChanges= getModeChanges(shell, resources); - fPage= new ModeWizardSelectionPage(fChanges); + + open(shell, wizard[0]); + return wizard[0]; + } + + /** + * Creates a wizard to set the keyword substitution mode for the specified resources. + * + * @param resources the resources to alter + * @param depth the recursion depth + * @param defaultOption the keyword substitution option to select by default + */ + + protected ModeWizard(Shell shell, final IResource[] resources) { + super(CVSUIMessages.ModeWizard_0, CVSUIPlugin.getPlugin().getDialogSettings(), 700, 480); + setWindowTitle(CVSUIMessages.ModeWizard_1); + + fChanges= getModeChanges(shell, resources); + fPage= new ModeWizardSelectionPage(fChanges); // Workbench.getInstance().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - - } - - @Override + + } + + @Override public void addPages() { - addPage(fPage); - } - - @Override + addPage(fPage); + } + + @Override public boolean needsProgressMonitor() { - return true; - } - - protected static List getModeChanges(Shell shell, IResource [] resources) { - + return true; + } + + protected static List getModeChanges(Shell shell, IResource [] resources) { + final ArrayList<ModeChange> changes = new ArrayList<>(); final HashSet<IResource> visited = new HashSet<>(); - - for (int i = 0; i < resources.length; i++) { - final IResource currentResource = resources[i]; - try { + + for (int i = 0; i < resources.length; i++) { + final IResource currentResource = resources[i]; + try { currentResource.accept((IResourceVisitor) resource -> { try { if (visited.contains(resource) || resource.getType() != IResource.FILE || !resource.exists()) @@ -153,117 +153,117 @@ public class ModeWizard extends ResizableWizard { // always return true and let the depth determine if children are visited return true; }, IResource.DEPTH_INFINITE, false); - } catch (CoreException e) { - CVSUIPlugin.openError(shell, CVSUIMessages.ModeWizard_2, null, e); - } - } - return changes; - } - - @Override + } catch (CoreException e) { + CVSUIPlugin.openError(shell, CVSUIMessages.ModeWizard_2, null, e); + } + } + return changes; + } + + @Override public boolean performFinish() { - try { - final List<IStatus> messages = new ArrayList<>(); - final List changes= fPage.getChanges(); - if (changes.size() == 0) - return true; - - final String comment = fPage.getComment(getShell()); - if (comment == null) - return false; - - getContainer().run(false /*fork*/, true /*cancelable*/, new IRunnableWithProgress() { - @Override + try { + final List<IStatus> messages = new ArrayList<>(); + final List changes= fPage.getChanges(); + if (changes.size() == 0) + return true; + + final String comment = fPage.getComment(getShell()); + if (comment == null) + return false; + + getContainer().run(false /*fork*/, true /*cancelable*/, new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - final int totalWork= 10000; - monitor.beginTask(CVSUIMessages.ModeWizard_3, totalWork); - - final Map changesPerProvider= getProviderMapping(changes); - - final int initialWork= totalWork / 10; - monitor.worked(initialWork); - - final int workPerProvider = (totalWork - initialWork) / changesPerProvider.size(); + try { + final int totalWork= 10000; + monitor.beginTask(CVSUIMessages.ModeWizard_3, totalWork); + + final Map changesPerProvider= getProviderMapping(changes); + + final int initialWork= totalWork / 10; + monitor.worked(initialWork); + + final int workPerProvider = (totalWork - initialWork) / changesPerProvider.size(); - for (Iterator iter = changesPerProvider.entrySet().iterator(); iter.hasNext();) { - final Map.Entry entry = (Map.Entry) iter.next(); - final CVSTeamProvider provider = (CVSTeamProvider)entry.getKey(); - final Map providerFiles = (Map) entry.getValue(); + for (Iterator iter = changesPerProvider.entrySet().iterator(); iter.hasNext();) { + final Map.Entry entry = (Map.Entry) iter.next(); + final CVSTeamProvider provider = (CVSTeamProvider)entry.getKey(); + final Map providerFiles = (Map) entry.getValue(); - final IStatus status = provider.setKeywordSubstitution(providerFiles, comment, Policy.subMonitorFor(monitor, workPerProvider)); - if (status.getCode() != IStatus.OK) { - messages.add(status); - } - } - // Broadcast a decorator change so all interested parties will update their labels. - // This is done in particular because the syncview will not see this change - // as a change in state for the resources involved - CVSUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, CVSUIPlugin.P_DECORATORS_CHANGED, null, null)); - } catch (TeamException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); - // Check for any status messages and display them - if (!messages.isEmpty()) { - boolean error = false; - final MultiStatus combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, CVSUIMessages.ModeWizard_4, null); - for (int i = 0; i < messages.size(); i++) { - final IStatus status = messages.get(i); - if (status.getSeverity() == IStatus.ERROR || status.getCode() == CVSStatus.SERVER_ERROR) { - error = true; - } - combinedStatus.merge(status); - } - String message = null; - IStatus statusToDisplay; - if (combinedStatus.getChildren().length == 1) { - message = combinedStatus.getMessage(); - statusToDisplay = combinedStatus.getChildren()[0]; - } else { - statusToDisplay = combinedStatus; - } - final String title= error ? CVSUIMessages.ModeWizard_5 : CVSUIMessages.ModeWizard_6; // - CVSUIPlugin.openError(getShell(), title, message, new CVSException(statusToDisplay)); - } - return super.performFinish(); - } catch (InterruptedException e) { - return true; - } catch (InvocationTargetException e) { - CVSUIPlugin.openError(getShell(), CVSUIMessages.ModeWizard_4, null, e); - return false; - } - } - - /** - * Get a map - * @param changes - * @return - */ - static Map getProviderMapping(Collection changes) { - + final IStatus status = provider.setKeywordSubstitution(providerFiles, comment, Policy.subMonitorFor(monitor, workPerProvider)); + if (status.getCode() != IStatus.OK) { + messages.add(status); + } + } + // Broadcast a decorator change so all interested parties will update their labels. + // This is done in particular because the syncview will not see this change + // as a change in state for the resources involved + CVSUIPlugin.broadcastPropertyChange(new PropertyChangeEvent(this, CVSUIPlugin.P_DECORATORS_CHANGED, null, null)); + } catch (TeamException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }); + // Check for any status messages and display them + if (!messages.isEmpty()) { + boolean error = false; + final MultiStatus combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, CVSUIMessages.ModeWizard_4, null); + for (int i = 0; i < messages.size(); i++) { + final IStatus status = messages.get(i); + if (status.getSeverity() == IStatus.ERROR || status.getCode() == CVSStatus.SERVER_ERROR) { + error = true; + } + combinedStatus.merge(status); + } + String message = null; + IStatus statusToDisplay; + if (combinedStatus.getChildren().length == 1) { + message = combinedStatus.getMessage(); + statusToDisplay = combinedStatus.getChildren()[0]; + } else { + statusToDisplay = combinedStatus; + } + final String title= error ? CVSUIMessages.ModeWizard_5 : CVSUIMessages.ModeWizard_6; // + CVSUIPlugin.openError(getShell(), title, message, new CVSException(statusToDisplay)); + } + return super.performFinish(); + } catch (InterruptedException e) { + return true; + } catch (InvocationTargetException e) { + CVSUIPlugin.openError(getShell(), CVSUIMessages.ModeWizard_4, null, e); + return false; + } + } + + /** + * Get a map + * @param changes + * @return + */ + static Map getProviderMapping(Collection changes) { + final Map<RepositoryProvider, HashMap<?, ?>> table = new HashMap<>(); - - for (Iterator iter = changes.iterator(); iter.hasNext();) { - final ModeChange change= (ModeChange)iter.next(); - - if (!change.hasChanged()) - continue; - - final IFile file = change.getFile(); - final RepositoryProvider provider = RepositoryProvider.getProvider(file.getProject(), CVSProviderPlugin.getTypeId()); - - if (!table.containsKey(provider)) { - table.put(provider, new HashMap()); - } - final Map providerMap = table.get(provider); - providerMap.put(file, change.getNewMode()); - } - return table; - } + + for (Iterator iter = changes.iterator(); iter.hasNext();) { + final ModeChange change= (ModeChange)iter.next(); + + if (!change.hasChanged()) + continue; + + final IFile file = change.getFile(); + final RepositoryProvider provider = RepositoryProvider.getProvider(file.getProject(), CVSProviderPlugin.getTypeId()); + + if (!table.containsKey(provider)) { + table.put(provider, new HashMap()); + } + final Map providerMap = table.get(provider); + providerMap.put(file, change.getNewMode()); + } + return table; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizardSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizardSelectionPage.java index d53b5e8ee..2e9ce65b0 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizardSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModeWizardSelectionPage.java @@ -733,9 +733,9 @@ public class ModeWizardSelectionPage extends WizardPage { * The main composite with the vertical sash */ final Composite mainComposite= SWTUtils.createHVFillComposite(parent, SWTUtils.MARGINS_DEFAULT); - // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(mainComposite, IHelpContextIds.KEYWORD_SUBSTITUTION_PAGE); - + // set F1 help + PlatformUI.getWorkbench().getHelpSystem().setHelp(mainComposite, IHelpContextIds.KEYWORD_SUBSTITUTION_PAGE); + final SashForm mainSash= new SashForm(mainComposite, SWT.VERTICAL); mainSash.setLayoutData(SWTUtils.createHVFillGridData()); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java index 42315700a..e69fa9c04 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ModuleSelectionPage.java @@ -73,7 +73,7 @@ public class ModuleSelectionPage extends CVSWizardPage { Composite composite = createComposite(parent, 2, false); if (helpContextId != null) - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, helpContextId); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, helpContextId); Listener listener = event -> updateEnablements(false); @@ -114,7 +114,7 @@ public class ModuleSelectionPage extends CVSWizardPage { useModuleAndProjectNameButton.setSelection(false); updateEnablements(false); setControl(composite); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); } private void updateText() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java index f0afb980b..5ea822d70 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/NewLocationWizard.java @@ -140,9 +140,9 @@ public class NewLocationWizard extends Wizard implements INewWizard { if (keepLocation) { KnownRepositories.getInstance().addRepository(location[0], true /* let the world know */); if (switchPerspectives) { - final IWorkbench workbench= PlatformUI.getWorkbench(); - final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - + final IWorkbench workbench= PlatformUI.getWorkbench(); + final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + final String defaultPerspectiveID= promptForPerspectiveSwitch(); if (defaultPerspectiveID != null) { @@ -193,7 +193,7 @@ public class NewLocationWizard extends Wizard implements INewWizard { } if (desired != null) { - + String message;; String desc = desired.getDescription(); if (desc == null) { @@ -201,25 +201,25 @@ public class NewLocationWizard extends Wizard implements INewWizard { } else { message = NLS.bind(CVSUIMessages.NewLocationWizard_3, new String[] { desired.getLabel(), desc }); } - // Ask the user whether to switch + // Ask the user whether to switch final MessageDialogWithToggle m = MessageDialogWithToggle.openYesNoQuestion( - Utils.getShell(null), - CVSUIMessages.NewLocationWizard_1, - message, - CVSUIMessages.NewLocationWizard_4, - false /* toggle state */, - store, - ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_NEW_REPOSITORY_LOCATION); + Utils.getShell(null), + CVSUIMessages.NewLocationWizard_1, + message, + CVSUIMessages.NewLocationWizard_4, + false /* toggle state */, + store, + ICVSUIConstants.PREF_CHANGE_PERSPECTIVE_ON_NEW_REPOSITORY_LOCATION); final int result = m.getReturnCode(); switch (result) { // yes case IDialogConstants.YES_ID: case IDialogConstants.OK_ID : - return desiredID; + return desiredID; // no case IDialogConstants.NO_ID : - return null; + return null; } } return null; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RepositorySelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RepositorySelectionPage.java index 42b98226a..1bfdb46a3 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RepositorySelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RepositorySelectionPage.java @@ -86,7 +86,7 @@ public class RepositorySelectionPage extends CVSWizardPage { public void createControl(Composite parent) { Composite composite = createComposite(parent, 1, false); // set F1 help - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHARING_SELECT_REPOSITORY_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHARING_SELECT_REPOSITORY_PAGE); if (extendedDescription == null) { extendedDescription = CVSUIMessages.RepositorySelectionPage_description; } @@ -103,39 +103,39 @@ public class RepositorySelectionPage extends CVSWizardPage { traverseRepositories(e.character); } } - }); + }); table = createTable(composite, 1); table.setContentProvider(new WorkbenchContentProvider()); table.setLabelProvider(new DecoratingRepoLabelProvider()/*WorkbenchLabelProvider()*/); table.setComparator(new RepositoryComparator()); - table.addDoubleClickListener(event -> getContainer().showPage(getNextPage())); - table.getTable().addKeyListener(new KeyAdapter() { + table.addDoubleClickListener(event -> getContainer().showPage(getNextPage())); + table.getTable().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { traverseRepositories(e.character); } - }); + }); setControl(composite); initializeValues(); - Dialog.applyDialogFont(parent); - - table.addSelectionChangedListener(event -> { - result = (ICVSRepositoryLocation)table.getStructuredSelection().getFirstElement(); - setPageComplete(true); + Dialog.applyDialogFont(parent); + + table.addSelectionChangedListener(event -> { + result = (ICVSRepositoryLocation)table.getStructuredSelection().getFirstElement(); + setPageComplete(true); }); - - useExistingRepo.addListener(SWT.Selection, event -> { - if (useNewRepo.getSelection()) { - table.getTable().setEnabled(false); - result = null; - } else { - table.getTable().setEnabled(true); - result = (ICVSRepositoryLocation)table.getStructuredSelection().getFirstElement(); - } - setPageComplete(true); + + useExistingRepo.addListener(SWT.Selection, event -> { + if (useNewRepo.getSelection()) { + table.getTable().setEnabled(false); + result = null; + } else { + table.getTable().setEnabled(true); + result = (ICVSRepositoryLocation)table.getStructuredSelection().getFirstElement(); + } + setPageComplete(true); }); } /** @@ -147,16 +147,16 @@ public class RepositorySelectionPage extends CVSWizardPage { table.setInput(input); if (locations.length == 0) { useNewRepo.setSelection(true); - useExistingRepo.setSelection(false); - table.getTable().setEnabled(false); + useExistingRepo.setSelection(false); + table.getTable().setEnabled(false); } else { - useNewRepo.setSelection(false); + useNewRepo.setSelection(false); useExistingRepo.setSelection(true); - table.getTable().setEnabled(true); - result = locations[0]; + table.getTable().setEnabled(true); + result = locations[0]; table.setSelection(new StructuredSelection(result)); } - setPageComplete(true); + setPageComplete(true); } public ICVSRepositoryLocation getLocation() { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ResizableWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ResizableWizard.java index c794479b0..e377b813f 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ResizableWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/ResizableWizard.java @@ -27,65 +27,65 @@ public class ResizableWizard extends Wizard { private final int DEFAULT_WIDTH; private final int DEFAULT_HEIGHT; - - private static final String BOUNDS_HEIGHT_KEY = "width"; //$NON-NLS-1$ - private static final String BOUNDS_WIDTH_KEY = "height"; //$NON-NLS-1$ - - final String fSectionName; - - public ResizableWizard(String sectionName, IDialogSettings settings) { - this(sectionName, settings, 300, 400); - } - - protected ResizableWizard(String sectionName, IDialogSettings settings, int defaultWidth, int defaultHeight) { - DEFAULT_WIDTH= defaultWidth; - DEFAULT_HEIGHT= defaultHeight; - fSectionName= sectionName; - setDialogSettings(settings); - } - - protected static int open(Shell shell, ResizableWizard wizard) { - final WizardDialog dialog= new WizardDialog(shell, wizard); - dialog.setMinimumPageSize(wizard.loadSize()); - return dialog.open(); - } - - public void saveSize() { - final Rectangle bounds= getContainer().getCurrentPage().getControl().getParent().getClientArea(); - final IDialogSettings settings= getDialogSettings(); - if (settings == null) - return; - - IDialogSettings section= settings.getSection(fSectionName); - if (section == null) - section= settings.addNewSection(fSectionName); - - section.put(BOUNDS_WIDTH_KEY, bounds.width); - section.put(BOUNDS_HEIGHT_KEY, bounds.height); - } - - public Point loadSize() { - final Point size= new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT); - - final IDialogSettings settings= getDialogSettings(); - if (settings == null) - return size; - - final IDialogSettings section= settings.getSection(fSectionName); - if (section == null) - return size; + + private static final String BOUNDS_HEIGHT_KEY = "width"; //$NON-NLS-1$ + private static final String BOUNDS_WIDTH_KEY = "height"; //$NON-NLS-1$ + + final String fSectionName; + + public ResizableWizard(String sectionName, IDialogSettings settings) { + this(sectionName, settings, 300, 400); + } + + protected ResizableWizard(String sectionName, IDialogSettings settings, int defaultWidth, int defaultHeight) { + DEFAULT_WIDTH= defaultWidth; + DEFAULT_HEIGHT= defaultHeight; + fSectionName= sectionName; + setDialogSettings(settings); + } + + protected static int open(Shell shell, ResizableWizard wizard) { + final WizardDialog dialog= new WizardDialog(shell, wizard); + dialog.setMinimumPageSize(wizard.loadSize()); + return dialog.open(); + } + + public void saveSize() { + final Rectangle bounds= getContainer().getCurrentPage().getControl().getParent().getClientArea(); + final IDialogSettings settings= getDialogSettings(); + if (settings == null) + return; + + IDialogSettings section= settings.getSection(fSectionName); + if (section == null) + section= settings.addNewSection(fSectionName); + + section.put(BOUNDS_WIDTH_KEY, bounds.width); + section.put(BOUNDS_HEIGHT_KEY, bounds.height); + } + + public Point loadSize() { + final Point size= new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT); + + final IDialogSettings settings= getDialogSettings(); + if (settings == null) + return size; + + final IDialogSettings section= settings.getSection(fSectionName); + if (section == null) + return size; - try { - size.x= section.getInt(BOUNDS_WIDTH_KEY); - size.y= section.getInt(BOUNDS_HEIGHT_KEY); - } catch (NumberFormatException e) { - } - return size; - } + try { + size.x= section.getInt(BOUNDS_WIDTH_KEY); + size.y= section.getInt(BOUNDS_HEIGHT_KEY); + } catch (NumberFormatException e) { + } + return size; + } - public boolean performFinish() { - saveSize(); - return true; - } + public boolean performFinish() { + saveSize(); + return true; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java index 1e00d3b71..504afc838 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/RestoreFromRepositoryFileSelectionPage.java @@ -126,7 +126,7 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { Composite composite= createComposite(parent, 1, false); setControl(composite); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.RESTORE_FROM_REPOSITORY_FILE_SELECTION_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.RESTORE_FROM_REPOSITORY_FILE_SELECTION_PAGE); // Top and bottom panes: top is the two selection panes, bottom is the file content viewer Splitter vsplitter= new Splitter(composite, SWT.VERTICAL); @@ -165,7 +165,7 @@ public class RestoreFromRepositoryFileSelectionPage extends CVSWizardPage { initializeValues(); updateWidgetEnablements(); - Dialog.applyDialogFont(parent); + Dialog.applyDialogFont(parent); } protected CheckboxTableViewer createRevisionSelectionTable(CompareViewerPane composite, HistoryTableProvider tableProvider) { diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java index 85964f94e..619929cef 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/SharingWizardSyncPage.java @@ -90,7 +90,7 @@ public class SharingWizardSyncPage extends CVSWizardPage implements IDiffChangeL updatePage(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHARING_SYNC_PAGE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHARING_SYNC_PAGE); Dialog.applyDialogFont(parent); } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java index 8bc35262a..dd1f9b330 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/UpdateWizard.java @@ -37,21 +37,21 @@ public class UpdateWizard extends ResizableWizard { private TagSelectionWizardPage tagSelectionPage; public UpdateWizard(IWorkbenchPart part, ResourceMapping[] mappers) { - super("UpdateWizard", CVSUIPlugin.getPlugin().getDialogSettings()); //$NON-NLS-1$ + super("UpdateWizard", CVSUIPlugin.getPlugin().getDialogSettings()); //$NON-NLS-1$ this.part = part; this.mappers = mappers; setWindowTitle(CVSUIMessages.UpdateWizard_title); } - public static void run(IWorkbenchPart part, ResourceMapping[] mappers) { - final UpdateWizard wizard = new UpdateWizard(part, mappers); - open(part.getSite().getShell(), wizard); - } - + public static void run(IWorkbenchPart part, ResourceMapping[] mappers) { + final UpdateWizard wizard = new UpdateWizard(part, mappers); + open(part.getSite().getShell(), wizard); + } + @Override public void addPages() { ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_CHECKOUT); - tagSelectionPage = new TagSelectionWizardPage("tagPage", CVSUIMessages.UpdateWizard_0, substImage, CVSUIMessages.UpdateWizard_1, TagSource.create(mappers), TagSourceWorkbenchAdapter.INCLUDE_ALL_TAGS); //$NON-NLS-1$ + tagSelectionPage = new TagSelectionWizardPage("tagPage", CVSUIMessages.UpdateWizard_0, substImage, CVSUIMessages.UpdateWizard_1, TagSource.create(mappers), TagSourceWorkbenchAdapter.INCLUDE_ALL_TAGS); //$NON-NLS-1$ tagSelectionPage.setAllowNoTag(true); tagSelectionPage.setHelpContxtId(IHelpContextIds.UPDATE_TAG_SELETION_PAGE); CVSTag tag = getInitialSelection(); @@ -62,27 +62,27 @@ public class UpdateWizard extends ResizableWizard { } /** - * @return - */ - private CVSTag getInitialSelection() { - try { - for (int i = 0; i < mappers.length; i++) { - ResourceMapping mapper = mappers[i]; - IProject[] projects = mapper.getProjects(); - for (int k = 0; k < projects.length; k++) { - IProject project = projects[k]; - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); - FolderSyncInfo info = folder.getFolderSyncInfo(); - if (info != null) { - return info.getTag(); - } - } - } - } catch (CoreException e) { - CVSUIPlugin.log(e); - } - return null; - } + * @return + */ + private CVSTag getInitialSelection() { + try { + for (int i = 0; i < mappers.length; i++) { + ResourceMapping mapper = mappers[i]; + IProject[] projects = mapper.getProjects(); + for (int k = 0; k < projects.length; k++) { + IProject project = projects[k]; + ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); + FolderSyncInfo info = folder.getFolderSyncInfo(); + if (info != null) { + return info.getTag(); + } + } + } + } catch (CoreException e) { + CVSUIPlugin.log(e); + } + return null; + } @Override public boolean performFinish() { |