Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2002-05-17 16:00:31 +0000
committerAndre Weinand2002-05-17 16:00:31 +0000
commitb10cae07f698fbce1ffa2cbe50f0ed94dac7dd68 (patch)
tree845f74ef7accccd56e8356e38f51a37155afdf79 /bundles/org.eclipse.compare/compare/org/eclipse
parent83006a51ed2f621cbd3374f5fab26aab4f1aa27b (diff)
downloadeclipse.platform.team-b10cae07f698fbce1ffa2cbe50f0ed94dac7dd68.tar.gz
eclipse.platform.team-b10cae07f698fbce1ffa2cbe50f0ed94dac7dd68.tar.xz
eclipse.platform.team-b10cae07f698fbce1ffa2cbe50f0ed94dac7dd68.zip
#13606
Diffstat (limited to 'bundles/org.eclipse.compare/compare/org/eclipse')
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java14
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java30
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties2
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java143
4 files changed, 126 insertions, 63 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index 896715c95..ed29402c9 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -2942,16 +2942,10 @@ public class TextMergeViewer extends ContentMergeViewer {
c.getDisplay().beep();
- String title;
- String message;
- if (down) {
- title= CompareMessages.getString("TextMergeViewer.atEnd.title"); //$NON-NLS-1$
- message= CompareMessages.getString("TextMergeViewer.atEnd.message"); //$NON-NLS-1$
- } else {
- title= CompareMessages.getString("TextMergeViewer.atBeginning.title"); //$NON-NLS-1$
- message= CompareMessages.getString("TextMergeViewer.atBeginning.message"); //$NON-NLS-1$
- }
- return MessageDialog.openQuestion(c.getShell(), title, message);
+ String key= down ? "atEnd" : "atBeginning";
+ return MessageDialog.openQuestion(c.getShell(),
+ CompareMessages.getString("TextMergeViewer."+key+".title"), //$NON-NLS-1$
+ CompareMessages.getString("TextMergeViewer."+key+".message")); //$NON-NLS-1$
}
return false;
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java
index 7e8e9f107..b9429f0d2 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.java
@@ -67,12 +67,13 @@ public class AddFromHistoryAction implements IActionDelegate {
if (dialog == null)
dialog= new AddFromHistoryDialog(parentShell, bundle);
- if (dialog.select(container, states)) {
- IFile file= dialog.getSelectedFile();
- IFileState fileState= dialog.getSelectedFileState();
- if (file != null && fileState != null) {
+ if (dialog.select(container, states)) {
+
+ AddFromHistoryDialog.HistoryInput[] selected= dialog.getSelected();
+
+ if (selected != null && selected.length > 0) {
try {
- updateWorkspace(bundle, parentShell, file, fileState);
+ updateWorkspace(bundle, parentShell, selected);
} catch (InterruptedException x) {
// Do nothing. Operation has been canceled by user.
@@ -99,18 +100,27 @@ public class AddFromHistoryAction implements IActionDelegate {
}
private void updateWorkspace(final ResourceBundle bundle, Shell shell,
- final IFile file, final IFileState fileState)
+ final AddFromHistoryDialog.HistoryInput[] selected)
throws InvocationTargetException, InterruptedException {
WorkspaceModifyOperation operation= new WorkspaceModifyOperation() {
public void execute(IProgressMonitor pm) throws InvocationTargetException {
try {
String taskName= Utilities.getString(bundle, "taskName"); //$NON-NLS-1$
- pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
+ pm.beginTask(taskName, selected.length);
- createContainers(file);
- file.create(fileState.getContents(), false, pm);
-
+ for (int i= 0; i < selected.length; i++) {
+ IFile file= selected[i].fFile;
+ IFileState fileState= selected[i].fFileState;
+ createContainers(file);
+
+ SubProgressMonitor subMonitor= new SubProgressMonitor(pm, 1);
+ try {
+ file.create(fileState.getContents(), false, subMonitor);
+ } finally {
+ subMonitor.done();
+ }
+ }
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties
index 21a2bb1f1..9aa1f80ba 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryAction.properties
@@ -30,7 +30,7 @@ dayFormat= {0}
buttonLabel= Add
-noLocalHistoryError= No local history available for selected resource.
+noLocalHistoryError= No deleted resources in local history for selected container.
replaceError=Can''t replace resource (reason: {0}).
taskName=Adding \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
index bac04923c..e4c13002f 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/AddFromHistoryDialog.java
@@ -46,9 +46,55 @@ public class AddFromHistoryDialog extends ResizableDialog {
return fFileState.getModificationTime();
}
}
+
+ static class FileHistory {
+ private IFile fFile;
+ private IFileState[] fStates;
+ private int fSelected;
+
+ FileHistory(IFile file) {
+ fFile= file;
+ }
+
+ IFile getFile() {
+ return fFile;
+ }
+
+ IFileState[] getStates() {
+ if (fStates == null) {
+ try {
+ fStates= fFile.getHistory(new NullProgressMonitor());
+ } catch (CoreException ex) {
+ }
+ }
+ return fStates;
+ }
+
+ IFileState getSelectedState() {
+ return getStates()[fSelected];
+ }
+
+ void setSelected(IFileState state) {
+ for (int i= 0; i < fStates.length; i++) {
+ if (fStates[i] == state) {
+ fSelected= i;
+ return;
+ }
+ }
+ }
+
+ HistoryInput getHistoryInput() {
+ return new HistoryInput(fFile, getSelectedState());
+ }
+
+ boolean isSelected(int index) {
+ return index == fSelected;
+ }
+ }
private CompareConfiguration fCompareConfiguration;
- private HistoryInput fSelectedItem;
+ private ArrayList fArrayList= new ArrayList();
+ private FileHistory fCurrentFileHistory;
// SWT controls
private CompareViewerSwitchingPane fContentPane;
@@ -95,27 +141,25 @@ public class AddFromHistoryDialog extends ResizableDialog {
TableItem ti= new TableItem(fMemberTable, SWT.NONE);
ti.setImage(CompareUI.getImage(file));
ti.setText(path);
- ti.setData(file);
+ ti.setData(new FileHistory(file));
}
}
open();
- return (getReturnCode() == OK) && (fSelectedItem != null);
- }
-
- IFile getSelectedFile() {
- if (fSelectedItem != null)
- return fSelectedItem.fFile;
- return null;
+ return (getReturnCode() == OK) && (fArrayList.size() > 0);
}
-
- IFileState getSelectedFileState() {
- if (fSelectedItem != null)
- return fSelectedItem.fFileState;
- return null;
+
+ HistoryInput[] getSelected() {
+ HistoryInput[] selected= new HistoryInput[fArrayList.size()];
+ Iterator iter= fArrayList.iterator();
+ for (int i= 0; iter.hasNext(); i++) {
+ FileHistory h= (FileHistory) iter.next();
+ selected[i]= h.getHistoryInput();
+ }
+ return selected;
}
-
+
protected synchronized Control createDialogArea(Composite parent) {
getShell().setText(Utilities.getString(fBundle, "title")); //$NON-NLS-1$
@@ -139,20 +183,33 @@ public class AddFromHistoryDialog extends ResizableDialog {
Splitter hsplitter= new Splitter(vsplitter, SWT.HORIZONTAL);
fMemberPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT);
- fMemberTable= new Table(fMemberPane, SWT.H_SCROLL + SWT.V_SCROLL);
+ fMemberTable= new Table(fMemberPane, SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL);
fMemberTable.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- handleMemberSelect(e.item);
+ if (e.detail == SWT.CHECK) {
+ if (e.item instanceof TableItem) {
+ TableItem ti= (TableItem) e.item;
+ if (ti.getChecked())
+ fArrayList.add(ti.getData());
+ else
+ fArrayList.remove(ti.getData());
+
+ if (fCommitButton != null)
+ fCommitButton.setEnabled(fArrayList.size() > 0);
+ }
+ } else {
+ handleMemberSelect(e.item);
+ }
}
}
);
-
+
fMemberPane.setContent(fMemberTable);
fEditionPane= new CompareViewerPane(hsplitter, SWT.BORDER | SWT.FLAT);
- fEditionTree= new Tree(fEditionPane, SWT.H_SCROLL + SWT.V_SCROLL);
+ fEditionTree= new Tree(fEditionPane, SWT.H_SCROLL | SWT.V_SCROLL);
fEditionTree.addSelectionListener(
new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
@@ -177,33 +234,34 @@ public class AddFromHistoryDialog extends ResizableDialog {
*/
private void handleMemberSelect(Widget w) {
Object data= w.getData();
- if (data instanceof IFile) {
- IFile file= (IFile) data;
- IFileState[] states= null;
- try {
- states= file.getHistory(new NullProgressMonitor());
- } catch (CoreException ex) {
- }
+ if (data instanceof FileHistory) {
+
+ FileHistory h= (FileHistory) data;
+ fCurrentFileHistory= h;
+
+ IFile file= h.getFile();
+ IFileState[] states= h.getStates();
fEditionPane.setImage(CompareUI.getImage(file));
String pattern= Utilities.getString(fBundle, "treeTitleFormat"); //$NON-NLS-1$
String title= MessageFormat.format(pattern, new Object[] { file.getName() });
fEditionPane.setText(title);
- if (fEditionTree != null) {
+ if (fEditionTree != null) {
fEditionTree.removeAll();
for (int i= 0; i < states.length; i++) {
- addEdition(new HistoryInput(file, states[i]));
+ addEdition(new HistoryInput(file, states[i]), h.isSelected(i));
}
}
- }
+ } else
+ fCurrentFileHistory= null;
}
/**
* Adds the given Pair to the edition tree.
* It takes care of creating tree nodes for different dates.
*/
- private void addEdition(HistoryInput input) {
+ private void addEdition(HistoryInput input, boolean isSelected) {
if (fEditionTree == null || fEditionTree.isDisposed())
return;
@@ -214,9 +272,7 @@ public class AddFromHistoryDialog extends ResizableDialog {
TreeItem lastDay= null;
if (days.length > 0)
lastDay= days[days.length-1];
-
- boolean first= lastDay == null;
-
+
long ldate= state.getModificationTime();
long day= dayNumber(ldate);
Date date= new Date(ldate);
@@ -243,8 +299,8 @@ public class AddFromHistoryDialog extends ResizableDialog {
ti.setImage(fTimeImage);
ti.setText(DateFormat.getTimeInstance().format(date));
ti.setData(input);
-
- if (first) {
+
+ if (isSelected) {
lastDay.setExpanded(true);
fEditionTree.setSelection(new TreeItem[] { ti });
feedContent(ti);
@@ -263,22 +319,25 @@ public class AddFromHistoryDialog extends ResizableDialog {
return (date + localTimeOffset) / ONE_DAY_MS;
}
-
+
+ /**
+ * Feeds the tree viewer's selection to the contentviewer
+ */
private void feedContent(Widget w) {
if (fContentPane != null && !fContentPane.isDisposed()) {
Object o= w.getData();
if (o instanceof HistoryInput) {
- fSelectedItem= (HistoryInput) o;
- fContentPane.setInput(fSelectedItem);
- fContentPane.setText(getEditionLabel(fSelectedItem));
+ HistoryInput selected= (HistoryInput) o;
+ fContentPane.setInput(selected);
+ fContentPane.setText(getEditionLabel(selected));
fContentPane.setImage(fTimeImage);
+
+ if (fCurrentFileHistory != null)
+ fCurrentFileHistory.setSelected(selected.fFileState);
} else {
- fSelectedItem= null;
fContentPane.setInput(null);
}
}
- if (fCommitButton != null)
- fCommitButton.setEnabled(fSelectedItem != null);
}
protected String getEditionLabel(HistoryInput input) {

Back to the top