Bug 313675 - [sfs] Unification of SFS Resource and Properties Views and migration to CNF: initial implementation
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/DefaultContentProvider.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/DefaultContentProvider.java index 873a77a..2d7d39e 100644 --- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/DefaultContentProvider.java +++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/provider/DefaultContentProvider.java
@@ -35,13 +35,13 @@ import org.eclipse.core.resources.semantic.spi.ISemanticContentProviderFederation; import org.eclipse.core.resources.semantic.spi.ISemanticContentProviderREST; import org.eclipse.core.resources.semantic.spi.ISemanticFileStore; -import org.eclipse.core.resources.semantic.spi.ISemanticFileStore.ResourceType; import org.eclipse.core.resources.semantic.spi.ISemanticResourceRuleFactory; import org.eclipse.core.resources.semantic.spi.ISemanticSpiResourceInfo; import org.eclipse.core.resources.semantic.spi.ISemanticTreeDeepFirstVisitor; import org.eclipse.core.resources.semantic.spi.SemanticSpiResourceInfo; import org.eclipse.core.resources.semantic.spi.SemanticTreeWalker; import org.eclipse.core.resources.semantic.spi.Util; +import org.eclipse.core.resources.semantic.spi.ISemanticFileStore.ResourceType; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -159,29 +159,25 @@ String remoteURI = getURIString(semanticFileStore); - if (remoteURI == null) { - throw new SemanticResourceException(SemanticResourceStatusCode.REMOTE_URI_NOT_FOUND, semanticFileStore.getPath(), NLS.bind( - Messages.DefaultContentProvider_RemotURINotSet_XMSG, semanticFileStore.getPath().toString())); - } + if (remoteURI != null) { + final URI uri = URI.create(remoteURI); - final URI uri = URI.create(remoteURI); - - URL url; - try { - url = uri.toURL(); - InputStream is = null; + URL url; try { - is = url.openConnection().getInputStream(); - existsRemotely = is != null; - } finally { - Util.safeClose(is); + url = uri.toURL(); + InputStream is = null; + try { + is = url.openConnection().getInputStream(); + existsRemotely = is != null; + } finally { + Util.safeClose(is); + } + } catch (MalformedURLException e) { + // $JL-EXC$ ignore and simply return false here + } catch (IOException e) { + // $JL-EXC$ ignore and simply return false here } - } catch (MalformedURLException e) { - // $JL-EXC$ ignore and simply return false here - } catch (IOException e) { - // $JL-EXC$ ignore and simply return false here } - } return new SemanticSpiResourceInfo(options, false, false, readOnly, existsRemotely, uriString, null); }
diff --git a/bundles/org.eclipse.ui.resources.semantic/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.resources.semantic/META-INF/MANIFEST.MF index eaa4676..d48e252 100644 --- a/bundles/org.eclipse.ui.resources.semantic/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.ui.resources.semantic/META-INF/MANIFEST.MF
@@ -13,7 +13,10 @@ org.eclipse.core.filesystem;bundle-version="1.2.0", org.eclipse.team.core;bundle-version="3.4.2", org.eclipse.ui.workbench;bundle-version="3.4.2", - org.eclipse.compare;bundle-version="3.4.1" + org.eclipse.compare;bundle-version="3.4.1", + org.eclipse.ui.navigator, + org.eclipse.ui.views.properties.tabbed, + org.eclipse.ui.editors;bundle-version="3.4.0" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.ui.resources.semantic/plugin.properties b/bundles/org.eclipse.ui.resources.semantic/plugin.properties index 2d68f00..77e4398 100644 --- a/bundles/org.eclipse.ui.resources.semantic/plugin.properties +++ b/bundles/org.eclipse.ui.resources.semantic/plugin.properties
@@ -41,4 +41,6 @@ configwizard.name_XGRP = Semantic File System synchparticipant.name_XGRP = Semantic File System synchwizard.description_XMSG = Semantic File System -synchwizard.name_XGRP = Semantic File System \ No newline at end of file +synchwizard.name_XGRP = Semantic File System +navigatorContent_XGRP = SFS Content +propertyTab_XGRP = Semantic Resource \ No newline at end of file
diff --git a/bundles/org.eclipse.ui.resources.semantic/plugin.xml b/bundles/org.eclipse.ui.resources.semantic/plugin.xml index ae0ba4f..c15a3f6 100644 --- a/bundles/org.eclipse.ui.resources.semantic/plugin.xml +++ b/bundles/org.eclipse.ui.resources.semantic/plugin.xml
@@ -139,7 +139,7 @@ point="org.eclipse.ui.views"> <view category="org.eclipse.core.resources.semantic.category" - class="org.eclipse.core.internal.resources.semantic.ui.SemanticResourcesView" + class="org.eclipse.core.internal.resources.semantic.ui.SFSNavigator" id="org.eclipse.core.resources.semantic.resourceView" name="%view.name_XGRP" restorable="true"> @@ -244,6 +244,88 @@ class="org.eclipse.core.internal.resources.semantic.ui.team.SemanticHistoryPageSource"> </implementation> </extension> + <extension + point="org.eclipse.ui.navigator.viewer"> + <viewerContentBinding + viewerId="org.eclipse.core.resources.semantic.resourceView"> + <includes> + <contentExtension + pattern="org.eclipse.ui.resources.semantic.navigatorContent"> + </contentExtension> + </includes> + </viewerContentBinding> + </extension> + <extension + point="org.eclipse.ui.navigator.navigatorContent"> + <navigatorContent + activeByDefault="true" + contentProvider="org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeContentProvider" + id="org.eclipse.ui.resources.semantic.navigatorContent" + labelProvider="org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeLabelProvider" + name="%navigatorContent_XGRP"> + <triggerPoints> + <instanceof + value="org.eclipse.core.resources.IWorkspaceRoot"> + </instanceof> + </triggerPoints> + <possibleChildren> + <instanceof + value="org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeObject"> + </instanceof> + </possibleChildren> + <actionProvider + class="org.eclipse.core.internal.resources.semantic.ui.SFSBrowserActionProvider"> + </actionProvider> + </navigatorContent> + </extension> + <extension + point="org.eclipse.ui.perspectiveExtensions"> + <perspectiveExtension + targetID="org.eclipse.ui.resourcePerspective"> + <view + id="org.eclipse.core.resources.semantic.resourceView" + minimized="false" + ratio="0.5" + relationship="stack" + relative="org.eclipse.ui.navigator.ProjectExplorer" + visible="false"> + </view> + </perspectiveExtension> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyContributor"> + <propertyContributor + contributorId="org.eclipse.core.resources.semantic.resourceView" + typeMapper="org.eclipse.ui.views.properties.tabbed.AbstractTypeMapper"> + <propertyCategory + category="org.eclipse.ui.resources.semantic.propertyCategory"></propertyCategory> + </propertyContributor> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> + <propertyTabs + contributorId="org.eclipse.core.resources.semantic.resourceView"> + <propertyTab + category="org.eclipse.ui.resources.semantic.propertyCategory" + id="TabResource" + label="%propertyTab_XGRP"> + </propertyTab> + </propertyTabs> + </extension> + <extension + point="org.eclipse.ui.views.properties.tabbed.propertySections"> + <propertySections + contributorId="org.eclipse.core.resources.semantic.resourceView"> + <propertySection + class="org.eclipse.core.internal.resources.semantic.ui.PropertySection" + id="org.eclipse.ui.resources.semantic.propertySection1" + tab="TabResource"> + <input + type="org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeObject"> + </input> + </propertySection> + </propertySections> + </extension> </plugin>
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/BrowseSFSDialog.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/BrowseSFSDialog.java index a72bf3c..969601d 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/BrowseSFSDialog.java +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/BrowseSFSDialog.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 SAP AG. + * Copyright (c) 2010 SAP AG. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,23 +11,39 @@ *******************************************************************************/ package org.eclipse.core.internal.resources.semantic.ui; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileSystem; +import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeContentProvider; +import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeLabelProvider; +import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeObject; import org.eclipse.core.resources.semantic.ISemanticFileSystem; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.layout.GridDataFactory; +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.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; /** * Dialog for browsing the Semantic File System and selecting a path. - * <p> - * Re-uses {@link SemanticResourcesView} in order to create the controls. */ public class BrowseSFSDialog extends Dialog { - private final SemanticResourcesView myView; + String selectedPath; + + private TreeViewer sfsTree; /** * @param parentShell @@ -38,12 +54,11 @@ public BrowseSFSDialog(Shell parentShell, String initialPath) { super(parentShell); setShellStyle(getShellStyle() | SWT.SHELL_TRIM); - this.myView = new SemanticResourcesView(); if (initialPath.startsWith(ISemanticFileSystem.SCHEME)) { String subPath = initialPath.substring(ISemanticFileSystem.SCHEME.length() + 1); - this.myView.setSelectedPath(subPath); + selectedPath = subPath; } else { - this.myView.setSelectedPath(initialPath); + selectedPath = initialPath; } } @@ -57,7 +72,6 @@ * @return the selected path */ public String getSelectedPathString() { - String selectedPath = this.myView.getSelectedPath(); if (selectedPath != null) { return ISemanticFileSystem.SCHEME + ':' + selectedPath; } @@ -68,9 +82,89 @@ protected Control createDialogArea(Composite parent) { Composite main = new Composite(parent, SWT.NONE); - main.setLayout(new GridLayout(1, false)); - GridDataFactory.fillDefaults().grab(true, true).hint(500, 300).applyTo(main); - this.myView.createPartControl(main); + + main.setLayout(new GridLayout(2, false)); + GridDataFactory.fillDefaults().hint(400, 300).grab(true, true).applyTo(main); + + SFSBrowserTreeObject[] input; + try { + input = getRootObjects(); + } catch (CoreException e) { + // for example, the SFS can not be accessed; in this case, we show a + // label with the + // status text and return + Label errorLabel = new Label(main, SWT.NONE); + errorLabel.setText(e.getStatus().getMessage()); + return main; + } + + final Label pathLabel = new Label(main, SWT.NONE); + GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(pathLabel); + pathLabel.setText(Messages.BrowseSFSDialog_Path_XFLD); + + final Text path = new Text(main, SWT.BORDER | SWT.READ_ONLY); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(path); + + this.sfsTree = new TreeViewer(main, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); + + SFSBrowserTreeLabelProvider treeLabelProvider = new SFSBrowserTreeLabelProvider(); + treeLabelProvider.configureTreeColumns(this.sfsTree); + this.sfsTree.setContentProvider(new SFSBrowserTreeContentProvider()); + this.sfsTree.setLabelProvider(treeLabelProvider); + + GridDataFactory.fillDefaults().span(2, 1).grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(this.sfsTree.getTree()); + + this.sfsTree.setInput(input); + + if (this.selectedPath != null && !this.selectedPath.equals("")) { //$NON-NLS-1$ + try { + SFSBrowserTreeObject object = getTreeObject(this.selectedPath); + this.sfsTree.setSelection(new StructuredSelection(object)); + path.setText(object.getPath().toString()); + } catch (CoreException e) { + Platform.getLog(Platform.getBundle(SemanticResourcesUIPlugin.PLUGIN_ID)).log(e.getStatus()); + } + } + + this.sfsTree.addSelectionChangedListener(new ISelectionChangedListener() { + + @SuppressWarnings("synthetic-access") + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection sel = (IStructuredSelection) event.getSelection(); + if (sel.isEmpty()) { + path.setText(""); //$NON-NLS-1$ + selectedPath = null; + } else { + SFSBrowserTreeObject selected = (SFSBrowserTreeObject) sel.getFirstElement(); + selectedPath = selected.getPath().toString(); + path.setText(selectedPath); + } + getButton(OK).setEnabled(selectedPath != null); + } + }); + return main; } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + super.createButtonsForButtonBar(parent); + getButton(OK).setEnabled(!sfsTree.getSelection().isEmpty()); + } + + private SFSBrowserTreeObject[] getRootObjects() throws CoreException { + ISemanticFileSystem fs = (ISemanticFileSystem) EFS.getFileSystem(ISemanticFileSystem.SCHEME); + String[] roots = fs.getRootNames(); + SFSBrowserTreeObject[] paths = new SFSBrowserTreeObject[roots.length]; + for (int i = 0; i < roots.length; i++) { + IPath path = new Path('/' + roots[i]); + paths[i] = new SFSBrowserTreeObject((IFileSystem) fs, path); + } + return paths; + } + + private SFSBrowserTreeObject getTreeObject(String path) throws CoreException { + IFileSystem fs = EFS.getFileSystem(ISemanticFileSystem.SCHEME); + return new SFSBrowserTreeObject(fs, new Path(path)); + } }
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/KeyValuePair.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/KeyValuePair.java new file mode 100644 index 0000000..f8a5325 --- /dev/null +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/KeyValuePair.java
@@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eduard Bartsch (SAP AG) - initial API and implementation + * Mathias Kinzler (SAP AG) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.internal.resources.semantic.ui; + +/** + * Used for the properties display + */ +class KeyValuePair { + + private final String key; + private final String value; + + KeyValuePair(String key, String value) { + super(); + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } +}
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/Messages.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/Messages.java index 767b0e1..efe6d41 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/Messages.java +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/Messages.java
@@ -16,9 +16,24 @@ public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.core.internal.resources.semantic.ui.messages"; //$NON-NLS-1$ public static String BrowseSFSDialog_Browser_XGRP; - public static String BrowseSFSDialog_Hide_XCKL; - public static String BrowseSFSDialog_Refresh_XBUT; - public static String BrowseSFSDialog_RefreshError_XGRP; + public static String BrowseSFSDialog_Path_XFLD; + public static String PropertiesContentProvider_ContentType_XFLD; + public static String PropertiesContentProvider_EffectiveContentProvider_XFLD; + public static String PropertiesContentProvider_ExceptionGettingChildren_XMSG; + public static String PropertiesContentProvider_ExceptionGettingValue_XMSG; + public static String PropertiesContentProvider_ExistsRemotely_XFLD; + public static String PropertiesContentProvider_Key_XGRP; + public static String PropertiesContentProvider_LastModified_XFLD; + public static String PropertiesContentProvider_LocalOnly_XFLD; + public static String PropertiesContentProvider_Locked_XFLD; + public static String PropertiesContentProvider_LockingSupported_XFLD; + public static String PropertiesContentProvider_PersistentProps_XGRP; + public static String PropertiesContentProvider_ProviderID_XFLD; + public static String PropertiesContentProvider_ReadOnly_XFLD; + public static String PropertiesContentProvider_RemoteUri_XFLD; + public static String PropertiesContentProvider_ResInfoAttributes_XGRP; + public static String PropertiesContentProvider_SessionProps_XGRP; + public static String PropertiesContentProvider_Value_XGRP; public static String SemanticFileSystemPreferencePage_Confirm_XGRP; public static String SemanticFileSystemPreferencePage_Confirm_XMSG; public static String SemanticFileSystemPreferencePage_CouldNotDelete_XMSG; @@ -29,37 +44,13 @@ public static String SemanticFileSystemPreferencePage_PathToDb_XFLD; public static String SemanticFileSystemPreferencePage_Restart_XGRP; public static String SemanticFileSystemPreferencePage_Restart_XMSG; - public static String SemanticResourcePropertyPage_ContentProviderId_XFLD; - public static String SemanticResourcePropertyPage_EffContentProv_XFLD; - public static String SemanticResourcePropertyPage_Exception_XMSG; - public static String SemanticResourcePropertyPage_File_XFLD; - public static String SemanticResourcePropertyPage_Folder_XFLD; - public static String SemanticResourcePropertyPage_Key_XGRP; - public static String SemanticResourcePropertyPage_LocalOnly_XFLD; - public static String SemanticResourcePropertyPage_Locked_XFLD; - public static String SemanticResourcePropertyPage_NoEntries_XMSG; - public static String SemanticResourcePropertyPage_Path_XFLD; - public static String SemanticResourcePropertyPage_PersistentProps_XFLD; - public static String SemanticResourcePropertyPage_Project_XFLD; - public static String SemanticResourcePropertyPage_ReadOnly_XFLD; - public static String SemanticResourcePropertyPage_SemResAttr_XFLD; - public static String SemanticResourcePropertyPage_SessionProp_XFLD; - public static String SemanticResourcePropertyPage_SFileAttributes_XFLD; - public static String SemanticResourcePropertyPage_SFolderAttr_XFLD; - public static String SemanticResourcePropertyPage_SFSAttr_XFLD; - public static String SemanticResourcePropertyPage_SRInfo_XFLD; - public static String SemanticResourcePropertyPage_Type_XFLD; - public static String SemanticResourcePropertyPage_Value_XGRP; - public static String SemanticResourcesView_AutoRefresh_XCKL; - public static String SemanticResourcesView_ConfirmDeleteQuestion; - public static String SemanticResourcesView_ConfirmDeleteTitle; - public static String SemanticResourcesView_DeleteMenu; - public static String SemanticResourcesView_Exists_XFLD; - public static String SemanticResourcesView_Path_XFLD; - public static String SemanticResourcesView_PropertiesOf_XGRP; - public static String SemanticResourcesView_RefreshJob_XGRP; - public static String SemanticResourcesView_RefreshRate_XTOL; - public static String SemanticResourcesView_Timestamp_XFLD; + public static String SFSBrowserActionProvider_AutoRefresh_XBUT; + public static String SFSBrowserActionProvider_ConfirmDelete_XGRP; + public static String SFSBrowserActionProvider_ConfirmDelete_XMSG; + public static String SFSBrowserActionProvider_Delete_XMIT; + public static String SFSBrowserActionProvider_DontAskAgain_XMSG; + public static String SFSBrowserActionProvider_OpenInTextEditor_XMIT; + public static String SFSBrowserActionProvider_Refesh_XBUT; static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesContentProvider.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesContentProvider.java new file mode 100644 index 0000000..346e397 --- /dev/null +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesContentProvider.java
@@ -0,0 +1,182 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eduard Bartsch (SAP AG) - initial API and implementation + * Mathias Kinzler (SAP AG) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.internal.resources.semantic.ui; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.internal.resources.semantic.SemanticFileStore; +import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeObject; +import org.eclipse.core.resources.semantic.ISemanticFileSystem; +import org.eclipse.core.resources.semantic.ISemanticResourceInfo; +import org.eclipse.core.resources.semantic.spi.ISemanticFileStore; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeColumn; + +public class PropertiesContentProvider implements ITreeContentProvider { + + private final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss::SSS"); //$NON-NLS-1$ + private SFSBrowserTreeObject treeObject; + + public static void initTree(TreeViewer tv, int width) { + Tree tree = tv.getTree(); + TreeColumn c1 = new TreeColumn(tree, SWT.NONE); + c1.setText(Messages.PropertiesContentProvider_Key_XGRP); + c1.setWidth(width); + + TreeColumn c2 = new TreeColumn(tree, SWT.NONE); + c2.setText(Messages.PropertiesContentProvider_Value_XGRP); + c2.setWidth(width); + + tree.setHeaderVisible(true); + tree.setLinesVisible(true); + } + + public PropertiesContentProvider() { + // nothing + } + + public Object[] getElements(Object inputElement) { + treeObject = (SFSBrowserTreeObject) inputElement; + ISemanticFileStore sfs = (ISemanticFileStore) treeObject.getStore(); + + List<KeyValuePair> props = new ArrayList<KeyValuePair>(); + + Date modified = new Date(sfs.fetchInfo().getLastModified()); + + props.add(new KeyValuePair(Messages.PropertiesContentProvider_LastModified_XFLD, df.format(modified))); + + String contentProvider; + try { + contentProvider = nullToSpace(sfs.getEffectiveContentProvider().getClass().getName()); + } catch (CoreException e) { + contentProvider = Messages.PropertiesContentProvider_ExceptionGettingValue_XMSG; + } + props.add(new KeyValuePair(Messages.PropertiesContentProvider_EffectiveContentProvider_XFLD, contentProvider)); + props.add(new KeyValuePair(Messages.PropertiesContentProvider_ProviderID_XFLD, nullToSpace(sfs.getContentProviderID()))); + String remoteUri; + try { + remoteUri = nullToSpace(sfs.getRemoteURIString()); + } catch (CoreException e) { + remoteUri = Messages.PropertiesContentProvider_ExceptionGettingValue_XMSG; + } + + props.add(new KeyValuePair(Messages.PropertiesContentProvider_RemoteUri_XFLD, remoteUri)); + + List<String> headers = new ArrayList<String>(); + headers.add(Messages.PropertiesContentProvider_ResInfoAttributes_XGRP); + headers.add(Messages.PropertiesContentProvider_PersistentProps_XGRP); + headers.add(Messages.PropertiesContentProvider_SessionProps_XGRP); + + Object[] result = new Object[props.size() + headers.size()]; + System.arraycopy(props.toArray(), 0, result, 0, props.size()); + System.arraycopy(headers.toArray(), 0, result, props.size(), headers.size()); + return result; + } + + private String nullToSpace(String name) { + if (name == null) { + return ""; //$NON-NLS-1$ + } + return name; + } + + public void dispose() { + // nothing to dispose + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + treeObject = (SFSBrowserTreeObject) newInput; + } + + public Object[] getChildren(Object parentElement) { + if (parentElement instanceof String) { + if (Messages.PropertiesContentProvider_PersistentProps_XGRP.equals(parentElement)) { + ISemanticFileStore store = (ISemanticFileStore) treeObject.getStore(); + Map<QualifiedName, String> props; + try { + props = store.getPersistentProperties(); + } catch (CoreException e) { + return getChildExceptionMap(); + } + List<KeyValuePair> resultMap = new ArrayList<KeyValuePair>(); + for (Map.Entry<QualifiedName, String> entry : props.entrySet()) { + resultMap.add(new KeyValuePair(entry.getKey().toString(), entry.getValue())); + } + return resultMap.toArray(); + } + if (Messages.PropertiesContentProvider_SessionProps_XGRP.equals(parentElement)) { + ISemanticFileStore store = (ISemanticFileStore) treeObject.getStore(); + Map<QualifiedName, Object> props; + try { + props = store.getSessionProperties(); + } catch (CoreException e) { + return getChildExceptionMap(); + } + List<KeyValuePair> resultMap = new ArrayList<KeyValuePair>(); + for (Map.Entry<QualifiedName, Object> entry : props.entrySet()) { + resultMap.add(new KeyValuePair(entry.getKey().toString(), String.valueOf(entry.getValue()))); + } + return resultMap.toArray(); + } + if (Messages.PropertiesContentProvider_ResInfoAttributes_XGRP.equals(parentElement)) { + try { + ISemanticResourceInfo info = ((SemanticFileStore) treeObject.getStore()).fetchResourceInfo(ISemanticFileSystem.NONE, + null); + + List<KeyValuePair> resultMap = new ArrayList<KeyValuePair>(); + + resultMap.add(new KeyValuePair(Messages.PropertiesContentProvider_ReadOnly_XFLD, String.valueOf(info.isReadOnly()))); + resultMap.add(new KeyValuePair(Messages.PropertiesContentProvider_LocalOnly_XFLD, String.valueOf(info.isLocalOnly()))); + resultMap.add(new KeyValuePair(Messages.PropertiesContentProvider_LockingSupported_XFLD, String.valueOf(info + .isLockingSupported()))); + resultMap.add(new KeyValuePair(Messages.PropertiesContentProvider_Locked_XFLD, String.valueOf(info.isLocked()))); + resultMap.add(new KeyValuePair(Messages.PropertiesContentProvider_ExistsRemotely_XFLD, String.valueOf(info + .existsRemotely()))); + resultMap + .add(new KeyValuePair(Messages.PropertiesContentProvider_ContentType_XFLD, nullToSpace(info.getContentType()))); + + return resultMap.toArray(); + + } catch (CoreException e) { + return getChildExceptionMap(); + } + + } + } + return null; + } + + private Object[] getChildExceptionMap() { + List<KeyValuePair> result = new ArrayList<KeyValuePair>(); + result.add(new KeyValuePair(Messages.PropertiesContentProvider_ExceptionGettingChildren_XMSG, "")); //$NON-NLS-1$ + return result.toArray(); + } + + public Object getParent(Object element) { + return null; + } + + public boolean hasChildren(Object element) { + return element instanceof String; + } +}
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesLabelProvider.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesLabelProvider.java new file mode 100644 index 0000000..47f56e3 --- /dev/null +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertiesLabelProvider.java
@@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eduard Bartsch (SAP AG) - initial API and implementation + * Mathias Kinzler (SAP AG) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.internal.resources.semantic.ui; + +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.viewers.BaseLabelProvider; +import org.eclipse.jface.viewers.IFontProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.PlatformUI; + +public class PropertiesLabelProvider extends BaseLabelProvider implements ITableLabelProvider, IFontProvider { + + public PropertiesLabelProvider() { + // nothing + } + + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + public String getColumnText(Object element, int columnIndex) { + switch (columnIndex) { + case 0 : + if (element instanceof String) + return (String) element; + if (element instanceof KeyValuePair) { + return String.valueOf(((KeyValuePair) element).getKey()); + } + break; + case 1 : + if (element instanceof KeyValuePair) { + return String.valueOf(((KeyValuePair) element).getValue()); + } + break; + default : + return null; + } + return null; + } + + public Font getFont(Object element) { + if (element instanceof String) { + return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry().getBold(JFaceResources.DEFAULT_FONT); + } + return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry().get(JFaceResources.DEFAULT_FONT); + } +}
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertySection.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertySection.java new file mode 100644 index 0000000..6ffd391 --- /dev/null +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/PropertySection.java
@@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eduard Bartsch (SAP AG) - initial API and implementation + * Mathias Kinzler (SAP AG) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.internal.resources.semantic.ui; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; +import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; + +public class PropertySection extends AbstractPropertySection { + + TreeViewer tv; + + public PropertySection() { + // nothing + } + + @Override + public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) { + super.createControls(parent, aTabbedPropertySheetPage); + tv = new TreeViewer(parent); + PropertiesContentProvider.initTree(tv, 400); + + tv.setLabelProvider(new PropertiesLabelProvider()); + tv.setContentProvider(new PropertiesContentProvider()); + } + + @Override + public void setInput(IWorkbenchPart part, ISelection selection) { + IStructuredSelection ssel = (IStructuredSelection) selection; + // just show nothing in case of multiple selection + if (ssel.size() == 1) { + tv.setInput(ssel.getFirstElement()); + tv.expandAll(); + } else { + tv.setInput(null); + } + } + + @Override + public boolean shouldUseExtraSpace() { + // we are the first and only section + return true; + } + +}
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSBrowserActionProvider.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSBrowserActionProvider.java new file mode 100644 index 0000000..c63f549 --- /dev/null +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSBrowserActionProvider.java
@@ -0,0 +1,248 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eduard Bartsch (SAP AG) - initial API and implementation + * Mathias Kinzler (SAP AG) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.internal.resources.semantic.ui; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeObject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.MessageDialogWithToggle; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.editors.text.EditorsUI; +import org.eclipse.ui.ide.FileStoreEditorInput; +import org.eclipse.ui.ide.IDE; +import org.eclipse.ui.navigator.CommonActionProvider; +import org.eclipse.ui.progress.IProgressService; + +public class SFSBrowserActionProvider extends CommonActionProvider { + + private static final long AUTOREFREH_MILLI = 5000; + + Job autoRefreshJob; + + Action autoRefreshAction; + + boolean autoRefreshActive = false; + + public SFSBrowserActionProvider() { + // empty + } + + @Override + public void fillActionBars(IActionBars actionBars) { + + if (autoRefreshAction != null) + return; + + actionBars.getToolBarManager().add(new Separator()); + + Action refreshAction = new Action(Messages.SFSBrowserActionProvider_Refesh_XBUT) { + + @SuppressWarnings("synthetic-access") + @Override + public void run() { + getActionSite().getStructuredViewer().refresh(); + super.run(); + } + + }; + + actionBars.getToolBarManager().add(refreshAction); + + autoRefreshAction = new Action(Messages.SFSBrowserActionProvider_AutoRefresh_XBUT, IAction.AS_CHECK_BOX) { + + @Override + public void run() { + if (isChecked()) { + if (autoRefreshJob == null) { + autoRefreshJob = new Job("Auto-refesh of SFS Browser") { //$NON-NLS-1$ + + @Override + protected IStatus run(IProgressMonitor monitor) { + Display.getDefault().asyncExec(new Runnable() { + @SuppressWarnings("synthetic-access") + public void run() { + getActionSite().getStructuredViewer().refresh(); + } + }); + schedule(AUTOREFREH_MILLI); + return Status.OK_STATUS; + } + }; + autoRefreshJob.setSystem(true); + } + autoRefreshJob.schedule(); + } else { + if (autoRefreshJob != null) { + autoRefreshJob.cancel(); + autoRefreshJob = null; + } + } + } + + }; + + if (autoRefreshActive) { + autoRefreshAction.setChecked(true); + autoRefreshAction.run(); + } + + actionBars.getToolBarManager().add(autoRefreshAction); + } + + @Override + public void restoreState(IMemento aMemento) { + // keep track of the auto refresh switch + super.restoreState(aMemento); + if (aMemento == null) { + return; + } + autoRefreshActive = aMemento.getBoolean("AutoRefreshActive"); //$NON-NLS-1$ + } + + @Override + public void saveState(IMemento aMemento) { + // keep track of the auto refresh switch + super.saveState(aMemento); + aMemento.putBoolean("AutoRefreshActive", autoRefreshAction.isChecked()); //$NON-NLS-1$ + } + + @Override + public void fillContextMenu(IMenuManager menu) { + super.fillContextMenu(menu); + IStructuredSelection sel = (IStructuredSelection) getContext().getSelection(); + if (sel.isEmpty()) + return; + + final Object[] objects = sel.toArray(); + final Shell shell = getActionSite().getViewSite().getShell(); + + Action deleteAction = new Action(Messages.SFSBrowserActionProvider_Delete_XMIT) { + + @SuppressWarnings("synthetic-access") + @Override + public void run() { + + final boolean[] refresh = new boolean[] {false}; + + boolean dontAskAgain = false; + + for (Object object : objects) { + + final SFSBrowserTreeObject selected = (SFSBrowserTreeObject) object; + + String question = NLS.bind(Messages.SFSBrowserActionProvider_ConfirmDelete_XMSG, selected.getPath().toString()); + + if (objects.length == 1) { + dontAskAgain = MessageDialog.openConfirm(shell, Messages.SFSBrowserActionProvider_ConfirmDelete_XGRP, question); + if (!dontAskAgain) { + return; + } + } + + if (!dontAskAgain) { + MessageDialogWithToggle toggle = new MessageDialogWithToggle(shell, + Messages.SFSBrowserActionProvider_ConfirmDelete_XMSG, null, question, MessageDialog.WARNING, new String[] { + IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0, + Messages.SFSBrowserActionProvider_DontAskAgain_XMSG, false); + int result = toggle.open(); + dontAskAgain = toggle.getToggleState(); + if (result != 0) { + if (dontAskAgain) { + break; + } + continue; + } + } + + IProgressService srv = PlatformUI.getWorkbench().getProgressService(); + + try { + srv.run(true, false, new IRunnableWithProgress() { + + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + selected.getStore().delete(0, monitor); + refresh[0] = true; + } catch (CoreException ce) { + throw new InvocationTargetException(ce); + } + } + }); + } catch (InvocationTargetException e1) { + SemanticResourcesUIPlugin.handleError(e1.getCause().getMessage(), e1.getCause(), true); + } catch (InterruptedException e1) { + // ignore + } + // } + } + + if (refresh[0]) { + getActionSite().getStructuredViewer().refresh(); + } + } + }; + + menu.add(deleteAction); + + if (objects.length == 1) { + final SFSBrowserTreeObject ob = (SFSBrowserTreeObject) objects[0]; + if (!ob.getInfo().isDirectory()) { + + Action showAction = new Action(Messages.SFSBrowserActionProvider_OpenInTextEditor_XMIT) { + + @Override + public void run() { + try { + IEditorInput input = new FileStoreEditorInput(ob.getStore()); + IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), input, + EditorsUI.DEFAULT_TEXT_EDITOR_ID); + } catch (CoreException e) { + SemanticResourcesUIPlugin.handleError(e.getMessage(), e, true); + } + } + + }; + menu.add(showAction); + } + } + + } + + @Override + public void dispose() { + super.dispose(); + if (autoRefreshJob != null) { + autoRefreshJob.cancel(); + autoRefreshJob = null; + } + } + +}
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSNavigator.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSNavigator.java new file mode 100644 index 0000000..43458d8 --- /dev/null +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SFSNavigator.java
@@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eduard Bartsch (SAP AG) - initial API and implementation + * Mathias Kinzler (SAP AG) - initial API and implementation + *******************************************************************************/ +package org.eclipse.core.internal.resources.semantic.ui; + +import org.eclipse.ui.navigator.CommonNavigator; +import org.eclipse.ui.views.properties.IPropertySheetPage; +import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; +import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; + +/** + * + * This sub-class is for {@link ITabbedPropertySheetPageContributor} + * implementation + * + */ +public class SFSNavigator extends CommonNavigator implements ITabbedPropertySheetPageContributor { + + @SuppressWarnings("unchecked") + @Override + public Object getAdapter(Class adapter) { + if (adapter == IPropertySheetPage.class) + return new TabbedPropertySheetPage(this); + return super.getAdapter(adapter); + } + + public String getContributorId() { + return getSite().getId(); + } + +}
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SemanticResourcePropertyPage.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SemanticResourcePropertyPage.java index 693f1e6..343e4c5 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SemanticResourcePropertyPage.java +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SemanticResourcePropertyPage.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 SAP AG. + * Copyright (c) 2010 SAP AG. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,27 +11,14 @@ *******************************************************************************/ package org.eclipse.core.internal.resources.semantic.ui; -import java.util.Map; -import java.util.Map.Entry; - import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.semantic.ISemanticFile; +import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeObject; import org.eclipse.core.resources.semantic.ISemanticFileSystem; -import org.eclipse.core.resources.semantic.ISemanticFolder; -import org.eclipse.core.resources.semantic.ISemanticProject; import org.eclipse.core.resources.semantic.ISemanticResource; -import org.eclipse.core.resources.semantic.ISemanticResourceInfo; -import org.eclipse.core.resources.semantic.spi.ISemanticFileStore; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.swt.SWT; +import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.dialogs.PropertyPage; /** @@ -40,191 +27,35 @@ */ public class SemanticResourcePropertyPage extends PropertyPage { + public SemanticResourcePropertyPage() { + // hide the set default and apply buttons + noDefaultAndApplyButton(); + } + @Override protected Control createContents(Composite parent) { - Tree propsTree = new Tree(parent, SWT.NONE); - - TreeColumn key = new TreeColumn(propsTree, SWT.NONE); - key.setWidth(220); - key.setText(Messages.SemanticResourcePropertyPage_Key_XGRP); - TreeColumn value = new TreeColumn(propsTree, SWT.NONE); - value.setWidth(300); - value.setText(Messages.SemanticResourcePropertyPage_Value_XGRP); - ISemanticResource node = (ISemanticResource) this.getElement().getAdapter(ISemanticResource.class); - IProject project = node.getAdaptedResource().getProject(); - TreeItem infoRoot = new TreeItem(propsTree, SWT.NONE); + TreeViewer tv = new TreeViewer(parent); + + PropertiesContentProvider.initTree(tv, 400); + + tv.setLabelProvider(new PropertiesLabelProvider()); + tv.setContentProvider(new PropertiesContentProvider()); try { - infoRoot.setText(0, Messages.SemanticResourcePropertyPage_SFSAttr_XFLD); - ISemanticFileStore sfs = (ISemanticFileStore) EFS.getStore(node.getAdaptedResource().getLocationURI()); + SFSBrowserTreeObject ob = new SFSBrowserTreeObject(EFS.getFileSystem(ISemanticFileSystem.SCHEME), node.getAdaptedResource() + .getFullPath()); - TreeItem childItem = new TreeItem(infoRoot, SWT.NONE); - - childItem.setText(new String[] { Messages.SemanticResourcePropertyPage_EffContentProv_XFLD, - sfs.getEffectiveContentProvider().getClass().getName() }); - - } catch (Exception e) { - // $JL-EXC$ - infoRoot.setText(1, Messages.SemanticResourcePropertyPage_Exception_XMSG); + tv.setInput(ob); + } catch (CoreException e) { + // we don't use "show" here, as the error popup would be hidden + // behind the properties page + SemanticResourcesUIPlugin.handleError(e.getMessage(), e, false); } + tv.expandAll(); - addResourceInfo(node, propsTree); - - if (node instanceof ISemanticProject) { - // nothing over folder - } else if (node instanceof ISemanticFolder) { - TreeItem folderRoot = new TreeItem(propsTree, SWT.NONE); - folderRoot.setText(0, Messages.SemanticResourcePropertyPage_SFolderAttr_XFLD); - TreeItem it = new TreeItem(folderRoot, SWT.NONE); - it.setText(new String[] { Messages.SemanticResourcePropertyPage_Project_XFLD, project.getName() }); - - IPath path = node.getAdaptedResource().getProjectRelativePath(); - it = new TreeItem(folderRoot, SWT.NONE); - it.setText(new String[] { Messages.SemanticResourcePropertyPage_Path_XFLD, path.toPortableString() }); - - ISemanticFolder folder = (ISemanticFolder) node; - - it = new TreeItem(folderRoot, SWT.NONE); - try { - it.setText(new String[] { Messages.SemanticResourcePropertyPage_ContentProviderId_XFLD, folder.getContentProviderID() }); - } catch (CoreException e) { - // $JL-EXC$ - it.setText(new String[] { Messages.SemanticResourcePropertyPage_ContentProviderId_XFLD, - Messages.SemanticResourcePropertyPage_Exception_XMSG }); - } - } else if (node instanceof ISemanticFile) { - TreeItem fileRoot = new TreeItem(propsTree, SWT.NONE); - fileRoot.setText(0, Messages.SemanticResourcePropertyPage_SFileAttributes_XFLD); - TreeItem it = new TreeItem(fileRoot, SWT.NONE); - it.setText(new String[] { Messages.SemanticResourcePropertyPage_Project_XFLD, project.getName() }); - - IPath path = node.getAdaptedResource().getProjectRelativePath(); - it = new TreeItem(fileRoot, SWT.NONE); - it.setText(new String[] { Messages.SemanticResourcePropertyPage_Path_XFLD, path.toPortableString() }); - - } - - propsTree.setLinesVisible(true); - propsTree.setHeaderVisible(true); - - for (TreeItem item : propsTree.getItems()) { - item.setExpanded(true); - } - - return propsTree; - } - - private void addResourceInfo(ISemanticResource resource, Tree propsTable) { - - TreeItem infoRoot = new TreeItem(propsTable, SWT.NONE); - - try { - infoRoot.setText(0, Messages.SemanticResourcePropertyPage_SRInfo_XFLD); - int options = ISemanticFileSystem.RESOURCE_INFO_LOCAL_ONLY | ISemanticFileSystem.RESOURCE_INFO_LOCKED - | ISemanticFileSystem.RESOURCE_INFO_READ_ONLY; - ISemanticResourceInfo info = resource.fetchResourceInfo(options, null); - - TreeItem childItem = new TreeItem(infoRoot, SWT.NONE); - childItem.setText(new String[] { Messages.SemanticResourcePropertyPage_ReadOnly_XFLD, "" + info.isReadOnly() }); //$NON-NLS-1$ - - if (resource instanceof ISemanticFile) { - childItem = new TreeItem(infoRoot, SWT.NONE); - childItem.setText(new String[] { Messages.SemanticResourcePropertyPage_LocalOnly_XFLD, "" + info.isLocalOnly() }); //$NON-NLS-1$ - } - - childItem = new TreeItem(infoRoot, SWT.NONE); - childItem.setText(new String[] { Messages.SemanticResourcePropertyPage_Locked_XFLD, "" + info.isLocked() }); //$NON-NLS-1$ - - infoRoot.setExpanded(true); - - } catch (Exception e) { - // $JL-EXC$ - infoRoot.setText(1, Messages.SemanticResourcePropertyPage_Exception_XMSG); - } - - TreeItem storeRoot = new TreeItem(propsTable, SWT.NONE); - storeRoot.setText(0, Messages.SemanticResourcePropertyPage_SemResAttr_XFLD); - - try { - - TreeItem childItem = new TreeItem(storeRoot, SWT.NONE); - String typeText = null; - - if (resource instanceof ISemanticFile) { - typeText = Messages.SemanticResourcePropertyPage_File_XFLD; - } - if (resource instanceof ISemanticFolder) { - typeText = Messages.SemanticResourcePropertyPage_Folder_XFLD; - } - if (resource instanceof ISemanticProject) { - typeText = Messages.SemanticResourcePropertyPage_Project_XFLD; - } - if (typeText == null) { - typeText = ""; //$NON-NLS-1$ - } - - childItem.setText(new String[] { Messages.SemanticResourcePropertyPage_Type_XFLD, typeText }); - - } catch (Exception e) { - // $JL-EXC$ - storeRoot.setText(1, Messages.SemanticResourcePropertyPage_Exception_XMSG); - return; - } - { - Map<QualifiedName, String> persistent; - TreeItem persistentRoot = new TreeItem(storeRoot, SWT.NONE); - persistentRoot.setText(0, Messages.SemanticResourcePropertyPage_PersistentProps_XFLD); - - try { - persistent = resource.getPersistentProperties(); - } catch (CoreException e) { - // $JL-EXC$ - persistentRoot.setText(1, Messages.SemanticResourcePropertyPage_Exception_XMSG); - persistent = null; - } - if (persistent != null) { - if (!persistent.isEmpty()) { - - for (Entry<QualifiedName, String> entry : persistent.entrySet()) { - TreeItem childItem = new TreeItem(persistentRoot, SWT.NONE); - childItem.setText(new String[] { entry.getKey().toString(), entry.getValue() }); - } - - persistentRoot.setExpanded(true); - } else { - persistentRoot.setText(1, Messages.SemanticResourcePropertyPage_NoEntries_XMSG); - } - } - } - { - Map<QualifiedName, Object> transientAtts; - TreeItem transientRoot = new TreeItem(storeRoot, SWT.NONE); - transientRoot.setText(0, Messages.SemanticResourcePropertyPage_SessionProp_XFLD); - - try { - transientAtts = resource.getSessionProperties(); - } catch (CoreException e) { - // $JL-EXC$ - transientRoot.setText(1, Messages.SemanticResourcePropertyPage_Exception_XMSG); - transientAtts = null; - } - if (transientAtts != null) { - if (!transientAtts.isEmpty()) { - - for (Entry<QualifiedName, Object> entry : transientAtts.entrySet()) { - TreeItem childItem = new TreeItem(transientRoot, SWT.NONE); - childItem.setText(new String[] { entry.getKey().toString(), String.valueOf(entry.getValue()) }); - } - - transientRoot.setExpanded(true); - } else { - transientRoot.setText(1, Messages.SemanticResourcePropertyPage_NoEntries_XMSG); - } - } - } - + return tv.getTree(); } }
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SemanticResourcesView.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SemanticResourcesView.java deleted file mode 100644 index b616e81..0000000 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/SemanticResourcesView.java +++ /dev/null
@@ -1,492 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 SAP AG. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eduard Bartsch (SAP AG) - initial API and implementation - * Mathias Kinzler (SAP AG) - initial API and implementation - *******************************************************************************/ -package org.eclipse.core.internal.resources.semantic.ui; - -import java.lang.reflect.InvocationTargetException; -import java.text.DateFormat; -import java.text.MessageFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Iterator; - -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileSystem; -import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserPropertiesContentProvider; -import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserPropertiesLabelProvider; -import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeContentProvider; -import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeLabelProvider; -import org.eclipse.core.internal.resources.semantic.ui.util.SFSBrowserTreeObject; -import org.eclipse.core.resources.semantic.ISemanticFileSystem; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.ToolBarManager; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.layout.GridDataFactory; -import org.eclipse.jface.operation.IRunnableWithProgress; -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.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.events.MenuDetectEvent; -import org.eclipse.swt.events.MenuDetectListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -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.Display; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.swt.widgets.ToolItem; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.fileSystem.FileSystemContributor; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.progress.IProgressService; -import org.eclipse.ui.progress.IWorkbenchSiteProgressService; - -/** - * View on the content of the Semantic File System. - * - * Also used in the {@link FileSystemContributor} implementation of - * {@link SemanticFileSystemContributor} which uses the controls here in - * {@link BrowseSFSDialog}. - * <p> - * Depending on whether this is actually used as view or as dialog, the buttons - * will either be implemented as {@link ToolBar} or as {@link Action} - * contributed to the {@link ToolBarManager}; in addition, refresh will behave - * differently (blocking the UI in case of the dialog while working - * asynchronously in view mode. - * - */ -public class SemanticResourcesView extends ViewPart { - - // some required state - String selectedPath; - boolean autoRefresh = false; - Job scheduledJob; - - // controls needed for refresh - - // the hierarchy tree - TreeViewer sfsTree; - // existence check box - Button existsBox; - // last modified time stamp - Text timestampText; - // the properties (session and persistent) - TreeViewer propsTable; - - // refresh rate for auto-refresh - static final int REFRESH_RATE = 5000; - // date format with millisecond resolution - final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss::SSS"); //$NON-NLS-1$ - - @Override - public void createPartControl(Composite parent) { - - Composite main = new Composite(parent, SWT.NONE); - - ToolBar tb; - - if (getViewSite() == null) { - // pop-up mode: we use right-to-left so that this looks more like - // the view tool bar - // manager - tb = new ToolBar(main, SWT.HORIZONTAL | SWT.RIGHT_TO_LEFT); - } else { - // view mode: we don't add a tool bar, as we use the view tool bar - // manager - tb = null; - } - - main.setLayout(new GridLayout(2, false)); - GridDataFactory.fillDefaults().grab(true, true).applyTo(main); - - SFSBrowserTreeObject[] input; - try { - input = getRootObjects(); - } catch (CoreException e) { - // for example, the SFS can not be accessed; in this case, we show a - // label with the - // status text and return - Label errorLabel = new Label(main, SWT.NONE); - errorLabel.setText(e.getStatus().getMessage()); - return; - } - - // pathLabel and path are hidden if nothing is selected - final Label pathLabel = new Label(main, SWT.NONE); - GridDataFactory.fillDefaults().exclude(true).align(SWT.LEFT, SWT.CENTER).applyTo(pathLabel); - pathLabel.setText(Messages.SemanticResourcesView_Path_XFLD); - - final Text path = new Text(main, SWT.BORDER | SWT.READ_ONLY); - GridDataFactory.fillDefaults().grab(true, false).exclude(true).align(SWT.FILL, SWT.CENTER).applyTo(path); - - // left: tree, right: properties (if something is selected in the tree) - final SashForm sf = new SashForm(main, SWT.HORIZONTAL); - GridDataFactory.fillDefaults().span(2, 1).grab(true, true).applyTo(sf); - - this.sfsTree = new TreeViewer(sf); - - SFSBrowserTreeLabelProvider treeLabelProvider = new SFSBrowserTreeLabelProvider(); - treeLabelProvider.configureTreeColumns(this.sfsTree); - this.sfsTree.setContentProvider(new SFSBrowserTreeContentProvider()); - this.sfsTree.setLabelProvider(treeLabelProvider); - - GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(this.sfsTree.getTree()); - - final Group propsMain = new Group(sf, SWT.SHADOW_ETCHED_IN); - sf.setMaximizedControl(this.sfsTree.getTree()); - propsMain.setLayout(new GridLayout(2, false)); - - // exists check box - this.existsBox = new Button(propsMain, SWT.CHECK); - this.existsBox.setText(Messages.SemanticResourcesView_Exists_XFLD); - this.existsBox.setEnabled(false); - GridDataFactory.fillDefaults().span(2, 1).applyTo(this.existsBox); - - Label timestampLabel = new Label(propsMain, SWT.NONE); - timestampLabel.setText(Messages.SemanticResourcesView_Timestamp_XFLD); - - // last modified - this.timestampText = new Text(propsMain, SWT.BORDER); - this.timestampText.setEnabled(false); - GridDataFactory.fillDefaults().grab(true, false).applyTo(this.timestampText); - - // properties (session and persistent) - this.propsTable = new TreeViewer(propsMain); - GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(this.propsTable.getTree()); - - SFSBrowserPropertiesLabelProvider labelProvider = new SFSBrowserPropertiesLabelProvider(); - labelProvider.configureTreeColumns(this.propsTable); - - this.propsTable.setContentProvider(new SFSBrowserPropertiesContentProvider()); - this.propsTable.setLabelProvider(labelProvider); - - if (tb == null) { - // view mode with tool bar manager - IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); - - Action refresh = new Action(Messages.BrowseSFSDialog_Refresh_XBUT, IAction.AS_PUSH_BUTTON) { - - @Override - public void run() { - scheduleRefresh(0); - } - }; - - mgr.add(refresh); - - Action autoRefreshAction = new Action(Messages.SemanticResourcesView_AutoRefresh_XCKL, IAction.AS_CHECK_BOX) { - - @Override - public void run() { - - SemanticResourcesView.this.autoRefresh = isChecked(); - if (isChecked()) { - scheduleRefresh(0); - } - - } - - }; - - ActionContributionItem it = new ActionContributionItem(autoRefreshAction); - mgr.add(it); - - mgr.update(false); - // some trick to add the tool tip text - ToolItem autoRefreshItem = (ToolItem) it.getWidget(); - autoRefreshItem - .setToolTipText(MessageFormat.format(Messages.SemanticResourcesView_RefreshRate_XTOL, new Integer(REFRESH_RATE))); - - } else { - - // pop-up mode with own tool bar - GridDataFactory.fillDefaults().span(2, 1).applyTo(tb); - - // inverse order as we add right-to-left - - ToolItem refresh = new ToolItem(tb, SWT.PUSH); - refresh.setText(Messages.BrowseSFSDialog_Refresh_XBUT); - refresh.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent evt) { - scheduleRefresh(0); - } - - }); - - // no auto-refresh in pop-up mode - - } - - this.sfsTree.setInput(input); - - if (this.selectedPath != null && !this.selectedPath.equals("")) { //$NON-NLS-1$ - try { - SFSBrowserTreeObject object = getTreeObject(this.selectedPath); - this.sfsTree.setSelection(new StructuredSelection(object)); - } catch (CoreException e) { - Platform.getLog(Platform.getBundle(SemanticResourcesUIPlugin.PLUGIN_ID)).log(e.getStatus()); - } - } - - this.sfsTree.addSelectionChangedListener(new ISelectionChangedListener() { - - public void selectionChanged(SelectionChangedEvent event) { - IStructuredSelection sel = (IStructuredSelection) event.getSelection(); - if (sel.isEmpty()) { - path.setText(""); //$NON-NLS-1$ - SemanticResourcesView.this.selectedPath = null; - propsMain.setText(""); //$NON-NLS-1$ - SemanticResourcesView.this.propsTable.setInput(null); - SemanticResourcesView.this.existsBox.setSelection(false); - SemanticResourcesView.this.timestampText.setText(""); //$NON-NLS-1$ - sf.setMaximizedControl(SemanticResourcesView.this.sfsTree.getTree()); - } else { - SFSBrowserTreeObject selected = (SFSBrowserTreeObject) sel.getFirstElement(); - SemanticResourcesView.this.selectedPath = selected.getPath().toString(); - path.setText(SemanticResourcesView.this.selectedPath); - propsMain.setText(MessageFormat.format(Messages.SemanticResourcesView_PropertiesOf_XGRP, selected.getInfo().getName())); - SemanticResourcesView.this.existsBox.setSelection(selected.getInfo().exists()); - SemanticResourcesView.this.timestampText.setText(df.format(new Date(selected.getInfo().getLastModified()))); - SemanticResourcesView.this.propsTable.setInput(selected); - SemanticResourcesView.this.propsTable.expandAll(); - sf.setMaximizedControl(null); - } - - path.setVisible(!sel.isEmpty()); - pathLabel.setVisible(!sel.isEmpty()); - - GridData gd = (GridData) path.getLayoutData(); - gd.exclude = sel.isEmpty(); - - gd = (GridData) pathLabel.getLayoutData(); - gd.exclude = sel.isEmpty(); - - path.getParent().layout(true); - - } - }); - - this.sfsTree.getTree().addMenuDetectListener(new MenuDetectListener() { - - public void menuDetected(MenuDetectEvent e) { - Menu previous = sfsTree.getTree().getMenu(); - if (previous != null) - previous.dispose(); - Menu newMenu = new Menu(sfsTree.getTree()); - - MenuItem delete = new MenuItem(newMenu, SWT.PUSH); - delete.setText(Messages.SemanticResourcesView_DeleteMenu); - delete.addSelectionListener(new SelectionAdapter() { - - @SuppressWarnings("rawtypes") - @Override - public void widgetSelected(SelectionEvent evt) { - IStructuredSelection sel = (IStructuredSelection) sfsTree.getSelection(); - - for (Iterator iter = sel.iterator(); iter.hasNext();) { - final SFSBrowserTreeObject selected = (SFSBrowserTreeObject) iter.next(); - if (MessageDialog.openConfirm(getSite().getShell(), Messages.SemanticResourcesView_ConfirmDeleteTitle, NLS - .bind(Messages.SemanticResourcesView_ConfirmDeleteQuestion, selected.getPath().toString()))) { - IProgressService srv = (IProgressService) getSite().getService(IProgressService.class); - - try { - srv.run(true, false, new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws InvocationTargetException { - try { - selected.getStore().delete(0, monitor); - scheduleRefresh(0); - } catch (CoreException ce) { - throw new InvocationTargetException(ce); - } - } - }); - } catch (InvocationTargetException e1) { - SemanticResourcesUIPlugin.handleError(e1.getCause().getMessage(), e1.getCause(), true); - } catch (InterruptedException e1) { - // ignore - } - } - } - } - - }); - sfsTree.getTree().setMenu(newMenu); - } - }); - - } - - @Override - public void setFocus() { - // nothing to do - } - - /** - * @return the selected path - */ - public String getSelectedPath() { - return this.selectedPath; - } - - /** - * @param path - * the path to select - */ - public void setSelectedPath(String path) { - this.selectedPath = path; - } - - @Override - public void dispose() { - // make sure to cancel the job - if (this.scheduledJob != null) { - this.scheduledJob.cancel(); - this.scheduledJob = null; - } - super.dispose(); - } - - void refreshInternal() throws CoreException { - - final SFSBrowserTreeObject[] newInput = getRootObjects(); - - Display.getDefault().syncExec(new Runnable() { - - public void run() { - Object[] expandedObjects = SemanticResourcesView.this.sfsTree.getExpandedElements(); - SemanticResourcesView.this.sfsTree.setInput(newInput); - SemanticResourcesView.this.sfsTree.setExpandedElements(expandedObjects); - - if (SemanticResourcesView.this.selectedPath != null) { - SFSBrowserTreeObject selected = (SFSBrowserTreeObject) SemanticResourcesView.this.propsTable.getInput(); - SemanticResourcesView.this.propsTable.refresh(); - SemanticResourcesView.this.propsTable.expandAll(); - if (selected != null) { - SemanticResourcesView.this.existsBox.setSelection(selected.getInfo().exists()); - SemanticResourcesView.this.timestampText.setText(df.format(new Date(selected.getInfo().getLastModified()))); - } - } else { - SemanticResourcesView.this.propsTable.setInput(null); - SemanticResourcesView.this.existsBox.setSelection(false); - SemanticResourcesView.this.timestampText.setText(""); //$NON-NLS-1$ - } - - } - }); - - if (this.autoRefresh) { - scheduleRefresh(REFRESH_RATE); - } - - } - - void scheduleRefresh(long delay) { - - if (getSite() == null) { - // pop-up mode: block the UI (we can't display progress in a modal - // dialog) - try { - // cancellation is not supported in the underlying method of SFS - PlatformUI.getWorkbench().getProgressService().run(true, false, new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws InvocationTargetException { - try { - refreshInternal(); - } catch (CoreException e) { - // $JL-EXC$ - throw new InvocationTargetException(e); - } - - } - }); - } catch (InvocationTargetException e1) { - // $JL-EXC$ specific handling - Throwable cause = e1.getCause(); - if (cause instanceof CoreException) { - Platform.getLog(Platform.getBundle(SemanticResourcesUIPlugin.PLUGIN_ID)).log(((CoreException) cause).getStatus()); - } - } catch (InterruptedException e1) { - // $JL-EXC$ ignore here - return; - } - - } else { - // view mode: run asynchronously - Job refreshJob = new Job(Messages.SemanticResourcesView_RefreshJob_XGRP) { - - @Override - public IStatus run(IProgressMonitor monitor) { - try { - refreshInternal(); - } catch (CoreException e) { - return e.getStatus(); - } - return new Status(IStatus.OK, SemanticResourcesUIPlugin.PLUGIN_ID, ""); //$NON-NLS-1$ - } - }; - - // don't show this in the UI - refreshJob.setSystem(true); - - IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) getSite().getService( - IWorkbenchSiteProgressService.class); - // keep track of this job - this.scheduledJob = refreshJob; - // by scheduling with the service, we'll get the italic font in the - // tab - // while the job is running (if it is running long enough for the - // display to update) - service.schedule(refreshJob, delay); - } - } - - SFSBrowserTreeObject[] getRootObjects() throws CoreException { - ISemanticFileSystem fs = (ISemanticFileSystem) EFS.getFileSystem(ISemanticFileSystem.SCHEME); - String[] roots = fs.getRootNames(); - SFSBrowserTreeObject[] paths = new SFSBrowserTreeObject[roots.length]; - for (int i = 0; i < roots.length; i++) { - IPath path = new Path('/' + roots[i]); - paths[i] = new SFSBrowserTreeObject((IFileSystem) fs, path); - } - return paths; - } - - SFSBrowserTreeObject getTreeObject(String path) throws CoreException { - IFileSystem fs = EFS.getFileSystem(ISemanticFileSystem.SCHEME); - return new SFSBrowserTreeObject(fs, new Path(path)); - } -}
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/messages.properties b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/messages.properties index ee3832f..d1e03a1 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/messages.properties +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/messages.properties
@@ -10,9 +10,24 @@ # Mathias Kinzler (SAP AG) - initial API and implementation ############################################################################### BrowseSFSDialog_Browser_XGRP=Browse the Semantic File System -BrowseSFSDialog_Hide_XCKL=Hide non-existing stores -BrowseSFSDialog_Refresh_XBUT=Refresh -BrowseSFSDialog_RefreshError_XGRP=Refresh Error +BrowseSFSDialog_Path_XFLD=Path +PropertiesContentProvider_ContentType_XFLD=Content Type +PropertiesContentProvider_EffectiveContentProvider_XFLD=Effective Content Provider +PropertiesContentProvider_ExceptionGettingChildren_XMSG=<Exception getting the children> +PropertiesContentProvider_ExceptionGettingValue_XMSG=<Exception getting the value> +PropertiesContentProvider_ExistsRemotely_XFLD=Exists remotely +PropertiesContentProvider_Key_XGRP=Key +PropertiesContentProvider_LastModified_XFLD=Last modified +PropertiesContentProvider_LocalOnly_XFLD=Local only +PropertiesContentProvider_Locked_XFLD=Locked +PropertiesContentProvider_LockingSupported_XFLD=Locking supported +PropertiesContentProvider_PersistentProps_XGRP=Persistent Properties +PropertiesContentProvider_ProviderID_XFLD=Content Provider ID +PropertiesContentProvider_ReadOnly_XFLD=Read only +PropertiesContentProvider_RemoteUri_XFLD=Remote URI +PropertiesContentProvider_ResInfoAttributes_XGRP=Semantic Resource Info Attributes +PropertiesContentProvider_SessionProps_XGRP=Session Properties +PropertiesContentProvider_Value_XGRP=Value SemanticFileSystemPreferencePage_Confirm_XGRP=Confirm SemanticFileSystemPreferencePage_Confirm_XMSG=All data in the Semantic File System will be lost, continue? SemanticFileSystemPreferencePage_CouldNotDelete_XMSG=Could not delete the cache file store {0} @@ -23,34 +38,10 @@ SemanticFileSystemPreferencePage_PathToDb_XFLD=Path to Database SemanticFileSystemPreferencePage_Restart_XGRP=Restart the IDE SemanticFileSystemPreferencePage_Restart_XMSG=You must restart the IDE for the changes to take effect -SemanticResourcePropertyPage_EffContentProv_XFLD=Effective content provider -SemanticResourcePropertyPage_Exception_XMSG=Not available due to an Exception -SemanticResourcePropertyPage_File_XFLD=File -SemanticResourcePropertyPage_Folder_XFLD=Folder -SemanticResourcePropertyPage_Key_XGRP=Key -SemanticResourcePropertyPage_LocalOnly_XFLD=Local Only -SemanticResourcePropertyPage_Locked_XFLD=Locked -SemanticResourcePropertyPage_NoEntries_XMSG=No entries found -SemanticResourcePropertyPage_Path_XFLD=Project Relative Path -SemanticResourcePropertyPage_PersistentProps_XFLD=Persistent Properties -SemanticResourcePropertyPage_Project_XFLD=Project -SemanticResourcePropertyPage_ReadOnly_XFLD=Read-only -SemanticResourcePropertyPage_SemResAttr_XFLD=Semantic Rescource Attributes -SemanticResourcePropertyPage_SessionProp_XFLD=Session Properties -SemanticResourcePropertyPage_SFileAttributes_XFLD=Semantic File Attributes -SemanticResourcePropertyPage_SFolderAttr_XFLD=Semantic Folder Attributes -SemanticResourcePropertyPage_SFSAttr_XFLD=Semantic File Store Attributes -SemanticResourcePropertyPage_SRInfo_XFLD=Semantic Resource Info Attributes -SemanticResourcePropertyPage_ContentProviderId_XFLD=Content Provider ID -SemanticResourcePropertyPage_Type_XFLD=Type -SemanticResourcePropertyPage_Value_XGRP=Value -SemanticResourcesView_AutoRefresh_XCKL=Auto-Refresh -SemanticResourcesView_ConfirmDeleteQuestion=Do you want to delete Semantic File Store {0} with all children? -SemanticResourcesView_ConfirmDeleteTitle=Confirm delete -SemanticResourcesView_DeleteMenu=Delete -SemanticResourcesView_Exists_XFLD=Exists -SemanticResourcesView_Path_XFLD=Path -SemanticResourcesView_PropertiesOf_XGRP=Properties of {0} -SemanticResourcesView_RefreshJob_XGRP=Semantic Resources View Refresh Job -SemanticResourcesView_RefreshRate_XTOL=Refresh rate is every {0} milliseconds -SemanticResourcesView_Timestamp_XFLD=Timestamp +SFSBrowserActionProvider_AutoRefresh_XBUT=Auto Refresh +SFSBrowserActionProvider_ConfirmDelete_XGRP=Confirm delete +SFSBrowserActionProvider_ConfirmDelete_XMSG=Do you want to delete Semantic File Store {0} with all children? +SFSBrowserActionProvider_Delete_XMIT=Delete +SFSBrowserActionProvider_DontAskAgain_XMSG=Don't ask again +SFSBrowserActionProvider_OpenInTextEditor_XMIT=Open in Text editor +SFSBrowserActionProvider_Refesh_XBUT=Refresh
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/util/SFSBrowserTreeContentProvider.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/util/SFSBrowserTreeContentProvider.java index bf8f29d..dc361cf 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/util/SFSBrowserTreeContentProvider.java +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/util/SFSBrowserTreeContentProvider.java
@@ -16,9 +16,11 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileSystem; +import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.semantic.ISemanticFileSystem; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; @@ -84,9 +86,28 @@ } public Object[] getElements(Object inputElement) { + if (inputElement instanceof IWorkspaceRoot) { + try { + return getRootObjects(); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } return (Object[]) inputElement; } + private SFSBrowserTreeObject[] getRootObjects() throws CoreException { + ISemanticFileSystem fs = (ISemanticFileSystem) EFS.getFileSystem(ISemanticFileSystem.SCHEME); + String[] roots = fs.getRootNames(); + SFSBrowserTreeObject[] paths = new SFSBrowserTreeObject[roots.length]; + for (int i = 0; i < roots.length; i++) { + IPath path = new Path('/' + roots[i]); + paths[i] = new SFSBrowserTreeObject((IFileSystem) fs, path); + } + return paths; + } + public void dispose() { // nothing
diff --git a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/util/SFSBrowserTreeLabelProvider.java b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/util/SFSBrowserTreeLabelProvider.java index 4b1917a..a5fdc11 100644 --- a/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/util/SFSBrowserTreeLabelProvider.java +++ b/bundles/org.eclipse.ui.resources.semantic/src/org/eclipse/core/internal/resources/semantic/ui/util/SFSBrowserTreeLabelProvider.java
@@ -11,6 +11,7 @@ *******************************************************************************/ package org.eclipse.core.internal.resources.semantic.ui.util; +import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.TreeViewer; @@ -28,7 +29,7 @@ /** * Label provider */ -public class SFSBrowserTreeLabelProvider implements ITableLabelProvider { +public class SFSBrowserTreeLabelProvider implements ITableLabelProvider, ILabelProvider { private final static Image FOLDER = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER); private final static Image FILE = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); @@ -110,4 +111,12 @@ // nothing } + public Image getImage(Object element) { + return getColumnImage(element, 0); + } + + public String getText(Object element) { + return getColumnText(element, 0); + } + }
diff --git a/examples/org.eclipse.core.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/providers/SampleWebDAVContentProvider.java b/examples/org.eclipse.core.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/providers/SampleWebDAVContentProvider.java index 6fcbabd..b62213f 100644 --- a/examples/org.eclipse.core.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/providers/SampleWebDAVContentProvider.java +++ b/examples/org.eclipse.core.resources.semantic.examples/src/org/eclipse/core/resources/semantic/examples/providers/SampleWebDAVContentProvider.java
@@ -38,7 +38,6 @@ import org.eclipse.core.resources.semantic.spi.ISemanticContentProviderREST; import org.eclipse.core.resources.semantic.spi.ISemanticFileHistoryProvider; import org.eclipse.core.resources.semantic.spi.ISemanticFileStore; -import org.eclipse.core.resources.semantic.spi.ISemanticFileStore.ResourceType; import org.eclipse.core.resources.semantic.spi.ISemanticResourceRuleFactory; import org.eclipse.core.resources.semantic.spi.ISemanticSpiResourceInfo; import org.eclipse.core.resources.semantic.spi.ISemanticTreeVisitor; @@ -46,6 +45,7 @@ import org.eclipse.core.resources.semantic.spi.SemanticSpiResourceInfo; import org.eclipse.core.resources.semantic.spi.SemanticTreeWalker; import org.eclipse.core.resources.semantic.spi.Util; +import org.eclipse.core.resources.semantic.spi.ISemanticFileStore.ResourceType; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -626,14 +626,20 @@ boolean existsRemotely = false; if (SemanticSpiResourceInfo.isOptionRequested(ISemanticFileSystem.RESOURCE_INFO_EXISTS_REMOTELY, options)) { - String remoteURI = this.getWebDAVURIForStore(semanticFileStore).toString(); - + String remoteURI; try { - InputStream is = WebDAVUtil.openInputStream(remoteURI, null); - existsRemotely = is != null; - Util.safeClose(is); - } catch (IOException e) { - // $JL-EXC$ ignore and simply return false here + remoteURI = this.getWebDAVURIForStore(semanticFileStore).toString(); + } catch (CoreException ce) { + remoteURI = null; + } + if (remoteURI != null) { + try { + InputStream is = WebDAVUtil.openInputStream(remoteURI, null); + existsRemotely = is != null; + Util.safeClose(is); + } catch (IOException e) { + // $JL-EXC$ ignore and simply return false here + } } }