Skip to main content
Jump to: navigation, search

Difference between revisions of "E4/Resources/Semantic File System/GettingStarted"

(Creating a Semantic project)
m
 
(15 intermediate revisions by one other user not shown)
Line 15: Line 15:
 
 [[Image:NewSemanticProjectWizard.jpg]]
 
 [[Image:NewSemanticProjectWizard.jpg]]
  
We use "SemanticProject" both for the project name and the location.
+
We use "SemanticProject" both for the project name and the location. Note that you have to unselect "Default Location" and select "Semantic File System" in the "Choose file system" dropdown.
 +
After the project has been created, it must be shared with the Semantic File System Team provider. Select Team -> Share Project..., then "Semantic File System" and "Finish".
 +
 
 +
 [[Image:SFSShareProjectWizard.jpg]]
  
 
== A short walk-through: some places to know about when working with the Semantic File System  ==
 
== A short walk-through: some places to know about when working with the Semantic File System  ==
Line 21: Line 24:
 
==== Semantic Properties Page  ====
 
==== Semantic Properties Page  ====
  
This can be reached from any Semantic Resource by opening the context menu in the project explorer and selecting Properties. On the left hand side, there should be an entry “Semantic Resource”. If you select this, you can inspect some resource properties specific to Semantic Resources, for example for the new demo project:  
+
This can be reached from any Semantic Resource by opening the context menu in the project explorer and selecting Properties. On the left hand side, there should be an entry “Semantic Resource”. If you select this, you can inspect some resource properties specific to Semantic Resources, for example for the new Semantic Project:  
  
 
[[Image:SFSDemoSFSProperties.jpg]]  
 
[[Image:SFSDemoSFSProperties.jpg]]  
Line 57: Line 60:
 
==== Team Synchronizer UI  ====
 
==== Team Synchronizer UI  ====
  
This is currently not fully supported. Please see the description of the RemoteStoreContentProvider below for more details.<br>
+
This is currently not fully supported. Please see the description of the RemoteStoreContentProvider in http://wiki.eclipse.org/E4/Resources/Semantic_File_System/Demos/Running_SFS_Examples for more details.<br>
  
 
==== Remote History Page  ====
 
==== Remote History Page  ====
Line 63: Line 66:
 
The generic “History” view is found under category “Team”. Depending on whether a certain content provider implements history support, it will show the remote versions for a Semantic File.  
 
The generic “History” view is found under category “Team”. Depending on whether a certain content provider implements history support, it will show the remote versions for a Semantic File.  
  
== Scenarios  ==
+
== The DefaultContentProvider  ==
 
+
The following sections deal with different “scenarios”. Each scenario is used to explain some aspects of the Semantic File System. Technically, these scenarios are realized by different content provider implementations.
+
 
+
== Scenario: DefaultContentProvider  ==
+
  
 
The DefaultContentProvider is used for any resources for which no specific content provider is responsible. This is necessary, since the project itself is a Semantic Resource. In other words, the DefaultContentProvider bridges the Semantic File System world and the Local File System world.<br>In addition, the DefaultContentProvider allows some basic REST-like Resource management.  
 
The DefaultContentProvider is used for any resources for which no specific content provider is responsible. This is necessary, since the project itself is a Semantic Resource. In other words, the DefaultContentProvider bridges the Semantic File System world and the Local File System world.<br>In addition, the DefaultContentProvider allows some basic REST-like Resource management.  
Line 73: Line 72:
 
==== Local File handling  ====
 
==== Local File handling  ====
  
Local files are handled by the DefaultContentProvider in a transparent manner. For example, the “simulatedRemoteContent.xml” file is handled as local file (the blue decorator indicates this). You can also create a local file as usual by selecting a folder and clicking on New -&gt; File in the context menu. The newly created file can be edited and deleted like any other file, even though it is a Semantic Resource (try it and check the Semantic Properties page mentioned above):  
+
Local files are handled by the DefaultContentProvider in a transparent manner. You can create a local file in the Semantic Project by simply selecting the context menu of the project and clicking New -&gt; File. A dialog will be shown asking for a file name. Use "localFile.txt" and hit "Finish". The new file will be shown in an editor. You can edit the file content just like with any file. A blue decorator indicates that the file is local. Still the file is a Semantic Resource (try it and check the Semantic Properties page mentioned above):  
  
 
[[Image:SFSDemosLocalResourceProperties.jpg]]
 
[[Image:SFSDemosLocalResourceProperties.jpg]]
  
==== Remote resource handling—Internet URL  ====
+
==== REST resource handling—Internet URL  ====
 
+
Select the “DefaultContentProvider” folder in your project and open the context menu. You should see a menu entry saying “Add Demo REST Resource”. After selecting this, a dialog will show up requesting a name and a URL for the new resource. Enter some arbitrary name, e.g. and an existing (and accessible) URL, for example “time.html” and “http://www.time.org”:<br>[[Image:SFSDemosNewURLResource.jpg]]<br>
+
 
+
Open the new file with the text editor. You will see some HTML code containing a line like<br>&lt;title&gt;Welcome To The WWW Clock (beta) - Wednesday 16th of December 2009 9:25:39 AM GMT&lt;/title&gt;<br>If you close and re-open the editor, this line will not change. However, you can retrieve the new content using "Team" -&gt; "Synchronize Content with Remote" on the context menu of the new file:<br>[[Image:SFSDemosSyncUrlFromRemote.jpg]]<br>Afterwards, the line above should have changed.<br>The default content provider does not support editing of non-local resources, so you cannot change the content of the file.
+
 
+
==== Remote resource handling—File System URI  ====
+
 
+
The DefaultContentProvider is also able to deal with File URIs. Open the context menu on the folder and select “Add a Local File System Resource”. On the dialog, choose “File” and the path to an existing file, for example “aaa.txt” in the “composites” subfolder of the temporary folder, in our example:<br>[[Image:SFSDemosSelectLocalFile.jpg]]<br>You may or may not change the value of the “Resource Name” field.<br>After completion, you will see a new file under the DefaultContentProvider folder (with the name provided in the “Resource Name” field in the wizard. Similar to the last example, it cannot be edited. However, you could change the file with a text editor in its original location. If you then use Team -&gt; Synchronize Content, the new content will appear in the Semantic File.
+
 
+
== Scenario: Sample SampleWSDLXSDContentProvider  ==
+
 
+
This content provider demonstrates the “Semantic” part of the Semantic File System. When adding a Web Service Description Language (WSDL) file, it will scan the contents and automatically add XML Schema Definition (XSD) files that are referenced in the WDSL.<br>Open the context menu on the SampleWSDLXSDContentProvider folder and select “Add a WSDL Resource”. In the subsequent dialog, select the option “File” and then pick a WSDL file as found in the “mimes” folder, in our example:<br>[[Image:SFSDemosAddSalesOrder.jpg]]<br>After completion, you will not only see this file in the resource tree, but also the required XSDs (address.xsd and customer.xsd). If you have a WSDL editor, you can of course show these files in this editor:<br>[[Image:SFSDemosSalesOrderAdded.jpg]]<br>
+
 
+
== Scenario: SampleCompositeResourceContentProvider  ==
+
 
+
This scenario demonstrates handling of “composite” resources. The underlying content provider considers all files with the same “base name” and extension as part of a composite. The “base name” is extracted from the file name by splitting the name at the underscore character. This is similar to the resource bundle loading behavior.<br>Even though the composite resource consists of several files which can be updated separately, certain operations can only be performed on the composite as a whole, for example, deletion and check-out (thus ensuring consistency between the different parts of the composite).<br>
+
 
+
==== Actions on the composite  ====
+
 
+
In order to demonstrate this, add the “test.txt” file from the “composites” sub-folder of the temporary folder to the “SampleCompositeResourceContentProvider” folder using the context menu&nbsp;-&gt; "Add a Local File System Resource" menu:<br>[[Image:SFSDemosAddComposite.jpg]]<br>Do the same for the files “test_en.txt” and “test_en_US.text”, respectively. You have now three files under the “SampleCompositeResourceContentProvider” folder.<br>Open any of the three files with the text editor and change the text. The content provider will mark all three files as checked-out silently.<br>Once you refresh the project explorer tree, you should see all three files marked as “checked out” (red decorator):<br>[[Image:SFSDemosCompositeCheckedOut.jpg]]<br>You can now store the changes. The “checked-out” state is stored persistently along with the resources in SFS metadata (you can use the Semantic Properties page to verify this (the Read-Only flag is false).
+
 
+
==== Reverting the changes  ====
+
 
+
You can revert the changes (i.e. drop the local changes and re-synchronize with the remote data using “Team -&gt; Revert to Repository State” on the file context menu. The action is available on all three files, but will act on all of them no matter on which of the files it is being called.<br>
+
 
+
==== Removing the files from the workspace  ====
+
 
+
The “normal” delete action is not supported by this content provider. Unfortunately, it is currently not possible to transport a meaningful message through the call stack, so the “normal” delete operation will simply fail.<br>You can still remove the files from the workspace using “Team -&gt; Remove from Workspace”. If the resources are marked as “checked-out”, a popup will be displayed indicating possible data loss (the checked-out resources may not have been synchronized with the remote repository. On confirmation, all three files will be deleted.<br>If the files are not checked-out (for example, because they have been reverted), deletion will happen without the popup.
+
 
+
== Scenario: RemoteStoreContentProvider  ==
+
 
+
This scenario simulates a hierarchical “remote” store which contains files and folders. The content provider can interact with this store to synchronize the file/folder hierarchy and content.<br>The “remote” store is simulated by the XML file named “simulatedRemoteContent.xml” in the demo project. You can use a text or XML editor to inspect the file. It uses a very simple XML schema to store the hierarchy and content.<br>There is also an editor that is able to display and manipulate the “remote” content. Open the context menu on the XML file and select "Open With" -&gt; "Remote Store Editor":<br>[[Image:SFSDemosRemoteStoreEditor.jpg]]<br>You can add and delete folders and files, change file contents or timestamps using this editor (don’t do this yet).
+
 
+
==== Synchronization  ====
+
 
+
In order to start with this scenario, open the context menu on the “RemoteStoreContentProvider” folder and select “Add Resource From Remote”. A dialog should appear offering the top-level elements of the “remote” store for adding. Select one or all and press “Ok”. Upon completion, the selected items should appear under the “RemoteStoreContentProvider” folder.<br>You can repeat this with the newly added “First” folder to add the “Second” folder (this works on single level.<br>In order to add the complete “remote” content, open the context menu on the root folder and select “Team -&gt; Synchronize content with Repository”. This will synchronize all items in the “remote” repository.<br>You can delete the synchronized items and repeat the above.
+
 
+
==== Editing  ====
+
 
+
When you start editing and save a synchronized file, the “local” copy is different from the “remote” copy (you can use the Remote Store Editor mentioned above to inspect the remote content):<br>[[Image:SFSDemosChangedLocally.jpg]]<br>You will also notice a red decorator in the project explorer (you may need to hit “Refresh” to make it visible) indicating that the file is no longer read-only.
+
 
+
==== Synchronization local-&gt;remote  ====
+
 
+
In order to update the “remote” store with the changed content, open the context menu on the file and select “Team -&gt; Synchronize with Repository”. Since the “local” content is newer than the “remote” content, the remote store will be updated (the RemoteStoreEditor should be updated automatically).
+
 
+
==== Synchronization remote-&gt;local  ====
+
 
+
Synchronization can work in both ways: change the file content in the remote store editor (open the context menu on the “File1” tree item and select “Change Content”, enter a new text and save).<br>Then synchronize again using Team -&gt; Synchronize with Repository”. The content of the text editor should be updated automatically, since the timestamp of the “remote” store is newer than the local timestamp.
+
 
+
==== Creating a Remote Resource  ====
+
 
+
This demonstrates creation of new remote content: open the context menu on the “First” folder and select “Create a Remote Resource”. On the dialog, chose “File” and enter some content:<br>[[Image:SFSDemosNewRemoteFile.jpg]]<br>After completion, the “RemoteStoreEditor” should be updated automatically:
+
 
+
[[Image:SFSDemosNewFileCreated.jpg]]
+
 
+
==== Deleting a Remote Resource  ====
+
 
+
This can be done using the context menu on the file. Select “Team -&gt; Delete in Repository”. After completion, the text editor will be closed and the deletion should be reflected in the Remote Store Editor.
+
  
==== Creating and deleting resources in the remote repository  ====
+
Select the project and open the context menu. Select New... -&gt; Other, then Semantic File System -&gt; REST Resource.
 +
A dialog will show up requesting a name and a URL for the new resource. Enter some arbitrary name, and an existing (and accessible) URL, for example “time.html” and “http://www.time.org”:<br>[[Image:SFSDemosNewURLResource.jpg]]<br>
  
If you create files/folders in the remote repository using the Remote Store Editor, you can propagate these changes into the demo project by synchronizing the root folder (“Team -&gt; Synchronize with Repository”, don’t forget to save the XML).  
+
Open the new file with the text editor. You will see some HTML code containing a line like<br>&lt;title&gt;Welcome To The WWW Clock (beta) - Wednesday 16th of December 2009 9:25:39 AM GMT&lt;/title&gt;<br>If you close and re-open the editor, this line will not change. However, you can retrieve the new content using "Team" -&gt; "Synchronize with Repository" on the context menu of the new file:<br>[[Image:SFSDemosSyncUrlFromRemote.jpg]]<br>Afterwards, the line above should have changed.<br>The default content provider does not support editing of non-local resources, so you cannot change the content of the file.
  
==== Comparing the local version against the repository version ====
+
== Using Semantic Resources outside of Semantic Projects ==
  
Save the “First/Second/File1” file again with some changed content. Then open the context menu and select “Team&nbsp;-&gt; Diff against Repository state”. You should see a compare view with the changes:  
+
It is possible to create Semantic Resources outside of Semantic Projects. Technically, this is done by creating a link to a resource in the Semantic File System. A generic UI is provided to add a REST resource using the DefaultContentProvider. You can open this UI using File->New->Other... (or CTRL-N) and then Semantic File System->REST Resource. The action can also be called from the context menu of any resource.
 +
You will see a screen asking for a parent, a name, and a URL. Depending on the context, the parent may be pre-set. Let's assume we have a "General" project called "GeneralProject" and a folder f1 from which we create the resource:
  
[[Image:SFSDemosDiffVsRemote.jpg]]
+
&nbsp;[[Image:NewRestResource.jpg]]
  
==== Team Synchronization support  ====
+
After successful completion of the wizard, the new resource will be shown as linked file under the folder and can be used just like any linked file:
  
Team Synchronization is not yet fully supported. You can, however, get an overview of the resources that require synchronization. Open the “Team Synchronizing” perspective:<br>[[Image:SFSDemosTeamSynchStart.jpg]]<br>Click on the little icon above the “Synchronize” tab, select the “Semantic File System” configuration wizard and complete this wizard (choose two-way compare which is also the default).<br>Upon completion, you should see the file which is out-of-sync with the remote repository. If you double-click it, you will see again the compare view:<br>[[Image:SFSDemosTeamSynchView.jpg]]<br>The synchronization action itself is currently not integrated in the view. However, when you synchronize the file manually (using the “Team -&gt; Synchronize with Repository” context menu, the entry above should disappear from the Team Synchronization view (press F5 on the “Synchronize” tab for refreshing it).
+
&nbsp;[[Image:NewLinkedResource.jpg]]
  
==== History Support, Comparing Versions  ====
+
It will also appear in the Semantic Content View under the same path as the linked resource:
  
The RemoteStoreContentProvider also supports remote versions. Whenever the (remote) content of a file is changed, a copy of this content is stored away with a timestamp.<br>In order to open the history view, open the context menu on the file and select “Team&nbsp;-&gt; Show Remote History” or open View “History” (under the “Team” category). This is a generic view provided by the team plug-in.<br>For the example file, this might look like this:<br>[[Image:SFSDemosHistoryView.jpg]]<br>Using the context menu, you can open a compare view of the file against the locally synchronized version (if you select two entries from this list, you can also do a three-way compare).
+
&nbsp;[[Image:NewLinkedInContentView.jpg]]

Latest revision as of 04:29, 23 August 2010

Prerequisites

You have an Eclipse IDE with the Semantic File System plug-ins running.
The required plug-ins are:

  • org.eclipse.core.resources.semantic
  • org.eclipse.ui.resources.semantic

The IDE used for the below examples was a Helios “Eclipse IDE for RCP and RAP Developers” downloaded from http://www.eclipse.org/downloads. Other Eclipse IDE 3.5 and 3.6 versions using a 5.0 or 6.0 Java runtime should also work.

Creating a Semantic project

Before you can start, you need to create a project located in the Semantic File System (also referred to as "Semantic Project"). Since the "Generic Project" wizard offers to do this in the UI, it can be used to do so. The wizard can be started using New -> Project..., then General -> Project:

 NewSemanticProjectWizard.jpg

We use "SemanticProject" both for the project name and the location. Note that you have to unselect "Default Location" and select "Semantic File System" in the "Choose file system" dropdown. After the project has been created, it must be shared with the Semantic File System Team provider. Select Team -> Share Project..., then "Semantic File System" and "Finish".

 SFSShareProjectWizard.jpg

A short walk-through: some places to know about when working with the Semantic File System

Semantic Properties Page

This can be reached from any Semantic Resource by opening the context menu in the project explorer and selecting Properties. On the left hand side, there should be an entry “Semantic Resource”. If you select this, you can inspect some resource properties specific to Semantic Resources, for example for the new Semantic Project:

SFSDemoSFSProperties.jpg

By right-clicking on any entry, you can copy either the value or the key and the value into the clipboard. If you have selected more than one entry, you can copy all selected entries into the clipboard (keys and values).

Team Provider menu

This can also be reached from any Semantic Resource by opening the context menu and then sub-menu “Team”. The available menu entries depend on the selected resource:

SFSDemosTeamMenu.jpg

Semantic File System Preference Page

This shows the location of the database file and the cache root which may be useful if you want to have a look at the actual data in your workspace.

Semantic Content View

This is a low-level view of the data in the Semantic File System database:
SFSDemosSemanticResourcesView.jpg
It can be reached from any Semantic Resource using Team->Show in Semantic Content View.

The view is refreshed automatically to reflect chnages in the Semantic File System; auto-refresh can be disabled in the view menu.

By right-clicking on a node, you can perform the following actions:

  • Delete the node and it's children (if any)
  • Forcefully delete the node and it's children
  • Open the node in the Properties View
  • Copy the node's path into the clipboard
  • Open the node in a text editor (file nodes only)

The second option can be helpful to cleanup a corrupt SFS database.

When a node is opened in the Properties View, the same information is shown as described above in the section "Semantic Properties Page".

Team Synchronizer UI

This is currently not fully supported. Please see the description of the RemoteStoreContentProvider in http://wiki.eclipse.org/E4/Resources/Semantic_File_System/Demos/Running_SFS_Examples for more details.

Remote History Page

The generic “History” view is found under category “Team”. Depending on whether a certain content provider implements history support, it will show the remote versions for a Semantic File.

The DefaultContentProvider

The DefaultContentProvider is used for any resources for which no specific content provider is responsible. This is necessary, since the project itself is a Semantic Resource. In other words, the DefaultContentProvider bridges the Semantic File System world and the Local File System world.
In addition, the DefaultContentProvider allows some basic REST-like Resource management.

Local File handling

Local files are handled by the DefaultContentProvider in a transparent manner. You can create a local file in the Semantic Project by simply selecting the context menu of the project and clicking New -> File. A dialog will be shown asking for a file name. Use "localFile.txt" and hit "Finish". The new file will be shown in an editor. You can edit the file content just like with any file. A blue decorator indicates that the file is local. Still the file is a Semantic Resource (try it and check the Semantic Properties page mentioned above):

SFSDemosLocalResourceProperties.jpg

REST resource handling—Internet URL

Select the project and open the context menu. Select New... -> Other, then Semantic File System -> REST Resource. A dialog will show up requesting a name and a URL for the new resource. Enter some arbitrary name, and an existing (and accessible) URL, for example “time.html” and “http://www.time.org”:
SFSDemosNewURLResource.jpg

Open the new file with the text editor. You will see some HTML code containing a line like
<title>Welcome To The WWW Clock (beta) - Wednesday 16th of December 2009 9:25:39 AM GMT</title>
If you close and re-open the editor, this line will not change. However, you can retrieve the new content using "Team" -> "Synchronize with Repository" on the context menu of the new file:
SFSDemosSyncUrlFromRemote.jpg
Afterwards, the line above should have changed.
The default content provider does not support editing of non-local resources, so you cannot change the content of the file.

Using Semantic Resources outside of Semantic Projects

It is possible to create Semantic Resources outside of Semantic Projects. Technically, this is done by creating a link to a resource in the Semantic File System. A generic UI is provided to add a REST resource using the DefaultContentProvider. You can open this UI using File->New->Other... (or CTRL-N) and then Semantic File System->REST Resource. The action can also be called from the context menu of any resource. You will see a screen asking for a parent, a name, and a URL. Depending on the context, the parent may be pre-set. Let's assume we have a "General" project called "GeneralProject" and a folder f1 from which we create the resource:

 NewRestResource.jpg

After successful completion of the wizard, the new resource will be shown as linked file under the folder and can be used just like any linked file:

 NewLinkedResource.jpg

It will also appear in the Semantic Content View under the same path as the linked resource:

 NewLinkedInContentView.jpg

Back to the top