Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-05-31 14:01:36 -0400
committerJean Michel-Lemieux2002-05-31 14:01:36 -0400
commita147ac890588969fb4d93f40683ae69515e8d568 (patch)
tree7b59a59e97ce1ea5c9624f968f2091d6213a89c5
parentb27cbd62b3fd8205f91caf1e141b8c745d996939 (diff)
downloadeclipse.platform.team-a147ac890588969fb4d93f40683ae69515e8d568.tar.gz
eclipse.platform.team-a147ac890588969fb4d93f40683ae69515e8d568.tar.xz
eclipse.platform.team-a147ac890588969fb4d93f40683ae69515e8d568.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java22
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java68
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java49
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java44
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java8
6 files changed, 104 insertions, 92 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java
index 968c8fccd..3e4fce861 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/MappingSelectionPage.java
@@ -10,23 +10,21 @@
******************************************************************************/
package org.eclipse.team.internal.ui.target;
-import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
@@ -79,6 +77,17 @@ public class MappingSelectionPage extends TargetWizardPage {
updateTextPath();
}
});
+
+ // include only folders in view
+ viewer.addFilter(new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if(element instanceof RemoteResourceElement) {
+ return ((RemoteResourceElement)element).getRemoteResource().isContainer();
+ }
+ return false;
+ }
+ });
+
Button newFolderButton = new Button(composite, SWT.PUSH);
newFolderButton.setText(Policy.bind("MappingSelectionPage.newFolderLabel")); //$NON-NLS-1$
newFolderButton.addListener(SWT.Selection, new Listener() {
@@ -97,7 +106,8 @@ public class MappingSelectionPage extends TargetWizardPage {
RemoteResourceElement newFolderUIElement = new RemoteResourceElement(newFolder);
- setViewerInput();
+ ((RemoteResourceElement)currentSelection).setCachedChildren(null);
+ viewer.refresh(currentSelection);
viewer.setExpandedState(currentSelection, true);
viewer.setSelection(new StructuredSelection(newFolderUIElement));
} catch (TeamException e) {
@@ -165,7 +175,7 @@ public class MappingSelectionPage extends TargetWizardPage {
private void setViewerInput() {
if(this.site == null || viewer == null)
return;
- viewer.setInput(new SiteRootsElement(new Site[] {site}, RemoteResourceElement.SHOW_FOLDERS));
+ viewer.setInput(new SiteRootsElement(new Site[] {site}));
}
/**
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java
index 8dce7d0d7..83b3c50ce 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteResourceElement.java
@@ -23,6 +23,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.core.target.IRemoteTargetResource;
+import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -39,20 +40,15 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
* remote servers.</p>
*/
public class RemoteResourceElement implements IWorkbenchAdapter, IAdaptable {
- // mask constants that control the children elements.
- final public static int SHOW_FILES = 1;
- final public static int SHOW_FOLDERS = 2;
// remote resource this element represents
private IRemoteTargetResource remote;
- // cached remote children, if not null then these are the
- // elements returned from getChildre().
- private IRemoteResource[] children;
+ // cache for the remote values
+ private IRemoteResource[] children = null;
+ private int size = 0;
+ private String lastModified = null;
- // mask for this elements
- private int showMask = SHOW_FILES | SHOW_FOLDERS;
-
// embeded progress monitoring support
private Shell shell;
private IProgressMonitor monitor;
@@ -61,11 +57,6 @@ public class RemoteResourceElement implements IWorkbenchAdapter, IAdaptable {
this.remote = remote;
}
- public RemoteResourceElement(IRemoteTargetResource remote, int showMask) {
- this.remote = remote;
- this.showMask = showMask;
- }
-
public IRemoteTargetResource getRemoteResource() {
return remote;
}
@@ -81,23 +72,24 @@ public class RemoteResourceElement implements IWorkbenchAdapter, IAdaptable {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
- monitor.beginTask("Connecting...", IProgressMonitor.UNKNOWN);
+ monitor.beginTask(null, 100);
if(children == null) {
- setCachedChildren(remote.members(monitor));
+ setCachedChildren(remote.members(Policy.subMonitorFor(monitor, 50)));
}
List remoteElements = new ArrayList();
for (int i = 0; i < children.length; i++) {
- IRemoteTargetResource child = (IRemoteTargetResource)children[i];
- RemoteResourceElement element = new RemoteResourceElement(child, showMask);
- element.setShell(shell);
- element.setProgressMonitor(monitor);
- if(child.isContainer()) {
- if((showMask & SHOW_FOLDERS) != 0) {
- remoteElements.add(element);
- }
- } else if((showMask & SHOW_FILES) != 0) {
- remoteElements.add(element);
- }
+ IRemoteTargetResource child = (IRemoteTargetResource)children[i];
+ RemoteResourceElement element = new RemoteResourceElement(child);
+
+ // setup progress monitors
+ element.setShell(shell);
+ element.setProgressMonitor(monitor);
+
+ // decide which children to return based on filter settings
+ element.setLastModified(child.getLastModified(Policy.subMonitorFor(monitor, 25)));
+ // cache size and last modified
+ element.setSize(child.getSize(Policy.subMonitorFor(monitor, 25)));
+ remoteElements.add(element);
}
result[0] = (RemoteResourceElement[])remoteElements.toArray(new RemoteResourceElement[remoteElements.size()]);
} catch (TeamException e) {
@@ -178,4 +170,24 @@ public class RemoteResourceElement implements IWorkbenchAdapter, IAdaptable {
public IProgressMonitor getProgressMonitor() {
return monitor;
}
-}
+
+ public String getLastModified() {
+ return lastModified;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public void setLastModified(String lastModified) {
+ this.lastModified = lastModified;
+ }
+
+ public void setSize(int size) {
+ this.size = size;
+ }
+
+ public String getName() {
+ return remote.getName();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java
index cd17c83a5..91f37eaed 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteElement.java
@@ -40,11 +40,6 @@ public class SiteElement extends RemoteResourceElement {
this.site = site;
}
- public SiteElement(Site site, int showMask) {
- super(null, showMask);
- this.site = site;
- }
-
public Site getSite() {
return site;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java
index 086ec3de9..a5fbb287c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerView.java
@@ -21,7 +21,6 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ColumnLayoutData;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -33,8 +32,8 @@ import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.wizard.ProgressMonitorPart;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -45,7 +44,6 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
@@ -148,17 +146,9 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
return 1;
return compareNames(r1, r2);
case SIZE:
- try {
- return new Integer(r1.getSize(null)).compareTo(new Integer(r2.getSize(null)));
- } catch (TeamException e) {
- return 0;
- }
+ return new Integer(e1.getSize()).compareTo(new Integer(e2.getSize()));
case MODIFIED:
- try {
- return getCollator().compare(r1.getLastModified(null), r2.getLastModified(null));
- } catch (TeamException e) {
- return 0;
- }
+ return getCollator().compare(e1.getLastModified(), e2.getLastModified());
default:
return 0;
}
@@ -265,6 +255,16 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
}
});
+ // show only folders in tree
+ folderTree.addFilter(new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if(element instanceof RemoteResourceElement) {
+ return ((RemoteResourceElement)element).getRemoteResource().isContainer();
+ }
+ return false;
+ }
+ });
+
Table table = new Table(sash, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
TableColumn tableColumn = new TableColumn(table, SWT.NULL);
@@ -370,13 +370,7 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
*/
private void updateFileTable(RemoteResourceElement remoteFolder) {
if(remoteFolder != null && !remoteFolder.equals(folderContentsTable.getInput())) {
- RemoteResourceElement tableFolder = new RemoteResourceElement(
- remoteFolder.getRemoteResource(),
- remoteFolder.SHOW_FILES | remoteFolder.SHOW_FOLDERS);
- tableFolder.setCachedChildren(remoteFolder.getCachedChildren());
- tableFolder.setShell(remoteFolder.getShell());
- tableFolder.setProgressMonitor(remoteFolder.getProgressMonitor());
- folderContentsTable.setInput(tableFolder);
+ folderContentsTable.setInput(remoteFolder);
}
}
@@ -404,8 +398,13 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
IStructuredSelection selection = (IStructuredSelection)folderTree.getSelection();
Object currentSelection = selection.getFirstElement();
- final RemoteResourceElement selectedFolder = getSelectedRemoteFolder(selection)[0];
-
+ RemoteResourceElement selectedFolder;
+ if(selection.isEmpty()) {
+ selectedFolder = getSelectedRemoteFolder(selection)[0];
+ } else {
+ selectedFolder = (RemoteResourceElement)folderContentsTable.getInput();
+ }
+
IRemoteTargetResource newFolder = CreateNewFolderAction.createDir(shell, selectedFolder.getRemoteResource(), Policy.bind("CreateNewFolderAction.newFolderName"));
if (newFolder == null)
return;
@@ -421,8 +420,8 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
}
}
public boolean isEnabled() {
- return getSelectedRemoteFolder((IStructuredSelection)folderTree.getSelection()).length == 1 ||
- getSelectedRemoteFolder((IStructuredSelection)folderContentsTable.getSelection()).length == 1;
+ return folderContentsTable.getInput() != null ||
+ getSelectedRemoteFolder((IStructuredSelection)folderTree.getSelection()).length == 1;
}
};
@@ -484,7 +483,7 @@ public class SiteExplorerView extends ViewPart implements ISiteListener {
}
private void initializeTreeInput() {
- root = new SiteRootsElement(TargetManager.getSites(), RemoteResourceElement.SHOW_FOLDERS);
+ root = new SiteRootsElement(TargetManager.getSites());
folderTree.setInput(root);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java
index 278dd758c..ff79825b9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteExplorerViewLabelProvider.java
@@ -25,31 +25,27 @@ public class SiteExplorerViewLabelProvider extends WorkbenchLabelProvider implem
return null;
}
public String getColumnText(Object element, int columnIndex) {
- try {
- switch (columnIndex) {
- case 0 :
- return super.getText(element);
- case 1 :
- if(element instanceof RemoteResourceElement) {
- int size = ((RemoteResourceElement)element).getRemoteResource().getSize(null);
- int sizeKb = size / 1000;
- if(sizeKb == 0 && size % 1000 > 0) {
- sizeKb = 1;
- }
- return Policy.bind("SiteExplorerViewLabelProvider.fileSize", new Integer(sizeKb).toString()); //$NON-NLS-1$
+ switch (columnIndex) {
+ case 0 :
+ return super.getText(element);
+ case 1 :
+ if(element instanceof RemoteResourceElement) {
+ int size = ((RemoteResourceElement)element).getSize();
+ int sizeKb = size / 1000;
+ if(sizeKb == 0 && size % 1000 > 0) {
+ sizeKb = 1;
}
- case 2 :
- if(element instanceof RemoteResourceElement) {
- return ((RemoteResourceElement)element).getRemoteResource().getLastModified(null);
- }
- case 3 :
- if(element instanceof RemoteResourceElement) {
- return ((RemoteResourceElement)element).getRemoteResource().getURL().toExternalForm();
- }
- }
- return ""; //$NON-NLS-1$
- } catch(TeamException e) {
- return ""; //$NON-NLS-1$
+ return Policy.bind("SiteExplorerViewLabelProvider.fileSize", new Integer(sizeKb).toString()); //$NON-NLS-1$
+ }
+ case 2 :
+ if(element instanceof RemoteResourceElement) {
+ return ((RemoteResourceElement)element).getLastModified();
+ }
+ case 3 :
+ if(element instanceof RemoteResourceElement) {
+ return ((RemoteResourceElement)element).getRemoteResource().getURL().toExternalForm();
+ }
}
+ return ""; //$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java
index d941738cc..0074fdbc9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/SiteRootsElement.java
@@ -23,13 +23,13 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
*/
public class SiteRootsElement implements IWorkbenchAdapter, IAdaptable {
private Site[] sites = null;
- private int showMask = RemoteResourceElement.SHOW_FILES | RemoteResourceElement.SHOW_FOLDERS;
+
+ // progress monitoring support
private IProgressMonitor monitor;
private Shell shell;
- public SiteRootsElement(Site[] sites, int showMask) {
+ public SiteRootsElement(Site[] sites) {
this.sites = sites;
- this.showMask = showMask;
}
public SiteRootsElement() {
@@ -49,7 +49,7 @@ public class SiteRootsElement implements IWorkbenchAdapter, IAdaptable {
}
SiteElement[] siteElements = new SiteElement[childSites.length];
for (int i = 0; i < childSites.length; i++) {
- siteElements[i] = new SiteElement(childSites[i], showMask);
+ siteElements[i] = new SiteElement(childSites[i]);
siteElements[i].setShell(shell);
siteElements[i].setProgressMonitor(monitor);
}

Back to the top