Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
gcli orion console
  • Loading branch information
kdvolder committed Mar 6, 2012
1 parent fd7bb95 commit ad86988
Show file tree
Hide file tree
Showing 26 changed files with 1,769 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "bundles/org.eclipse.orion.client.console/submodules/gcli"]
path = bundles/org.eclipse.orion.client.console/submodules/gcli
url = git://github.com/mozilla/gcli.git
23 changes: 23 additions & 0 deletions bundles/org.eclipse.orion.client.console/.project
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.orion.client.console</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,4 @@
#Tue Jan 18 14:23:15 CET 2011
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
8 changes: 8 additions & 0 deletions bundles/org.eclipse.orion.client.console/META-INF/MANIFEST.MF
@@ -0,0 +1,8 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.orion.client.console;singleton:=true
Bundle-Version: 0.0.1.qualifier
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: bundle
29 changes: 29 additions & 0 deletions bundles/org.eclipse.orion.client.console/about.html
@@ -0,0 +1,29 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>

<p>Februari 17, 2011</p>
<h3>License</h3>

<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
<a href="http://www.eclipse.org/legal/epl-v10.html">Eclipse Public License Version 1.0</a>
(&quot;EPL&quot;), and the <a href="http://www.eclipse.org/org/documents/edl-v10.html">
Eclipse Distribution License Version 1.0</a> (&quot;EDL&quot;).
For purposes of the EPL and EDL, &quot;Program&quot; will mean the Content.</p>

<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>

</body>
</html>
23 changes: 23 additions & 0 deletions bundles/org.eclipse.orion.client.console/build.properties
@@ -0,0 +1,23 @@
###############################################################################
# Copyright (c) 2011 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials are made
# available under the terms of the Eclipse Public License v1.0
# (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
# License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
#
# Contributors: IBM Corporation - initial API and implementation
###############################################################################

bin.includes = META-INF/,\
web/,\
bundle.properties,\
about.html,\
submodules/gcli/lib/,\
plugin.xml
src.includes = web/,\
about.html,\
bundle.properties,\
submodules/gcli/lib/gcli/
bin.excludes = submodules/gcli/lib/demo/,\
submodules/gcli/lib/gclitest/,\
submodules/gcli/lib/test/
2 changes: 2 additions & 0 deletions bundles/org.eclipse.orion.client.console/bundle.properties
@@ -0,0 +1,2 @@
Bundle-Vendor = Eclipse.org - Orion
Bundle-Name = Orion Commmand Line UI (Incubation)
30 changes: 30 additions & 0 deletions bundles/org.eclipse.orion.client.console/plugin.xml
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.equinox.http.registry.httpcontexts">
<httpcontext
id="org.eclipse.orion.server.configurator.httpcontext.console">
<resource-mapping
path="/web/console">
</resource-mapping>
</httpcontext>
<httpcontext
id="org.eclipse.orion.server.configurator.httpcontext.console.gcli">
<resource-mapping
path="/submodules/gcli">
</resource-mapping>
</httpcontext>
</extension>
<extension
point="org.eclipse.equinox.http.registry.resources">
<resource
alias="/console"
httpcontextId="org.eclipse.orion.server.configurator.httpcontext.console">
</resource>
<resource
alias="/console/gcli"
httpcontextId="org.eclipse.orion.server.configurator.httpcontext.console.gcli">
</resource>
</extension>
</plugin>
1 change: 1 addition & 0 deletions bundles/org.eclipse.orion.client.console/submodules/gcli
Submodule gcli added at 52e9d9
@@ -0,0 +1,130 @@
/*global require define setTimeout */
/**
* This module provides utility methods to retrieve information about directorie. It also keeps
* track of the 'current' directory state by using the 'dojo.hash()' function to store and retrieve
* the current directory location from the page URL.
*/
define(['dojo', 'orion/bootstrap', 'orion/fileClient'], function (dojo, mBootstrap, mFileClient) {

var fileClient;
var exports = {};

//The current path. I.e. the working dir relative to which we will execute commands on the server.
var currentTreeNode = null;

function withWorkspace(k) {
fileClient.loadWorkspace('').then(k);
}
exports.withWorkspace = withWorkspace;

/**
* Make sure that there is a currentTreeNode and call given callback on the tree node
* as soon as its available.
*/
function withCurrentTreeNode(doit) {
if (currentTreeNode===null) {
var location = dojo.hash() || "";
fileClient.loadWorkspace(location).then(function (node) {
currentTreeNode = node;
doit(node);
});
} else {
//Wrapped in a setTimeout to ensure it always executed as later scheduled event.
//otherwise the execution order will be different depending on whether currentTreeNode==null
setTimeout(function () {
doit(currentTreeNode);
});
}
}
exports.withCurrentTreeNode = withCurrentTreeNode;

/**
* Returns true if string is a string that ends with the string suffix.
*/
function endsWith(string, suffix) {
if (typeof(string)==='string' && typeof(suffix)==='string') {
var loc = string.lastIndexOf(suffix);
return (loc + suffix.length) === string.length;
}
return false;
}

/**
* Get the location of a given node's parent node. May return null if the node is a workspace node
* so it doesn't have a parent.
* <p>
* Warning: a valid parent location is the empty String '' which indicates the 'root' location.
* To check whether a valid parent was returned use 'if (loc!==null)' rather than 'if (loc)'.
* The empty String will count as 'false' in if tests!
*/
function getParentLocation(node) {
if (node.Parents && node.Parents.length>0) {
return node.Parents[0].Location;
} else {
//TODO: Hack allert! Should not be using URL hackery to determine parent location
// but it seems sometimes we don't have a choice because the Parent's attribute is missing.
// Should investigate precisely how breadcrumbs does this.
var location = node.Location;
var parentLocation = null;
if (endsWith(location,'/')) {
location = location.slice(0, location.length-1);
}
if (location) {
var lastSlash = location.lastIndexOf('/');
if (lastSlash>=0) {
parentLocation = location.slice(0, lastSlash+1);
if (parentLocation==='/file/') {
parentLocation = '';
} else if (parentLocation==='/workspace/') {
parentLocation = null;
}
}
}
return parentLocation;
}
}
exports.getParentLocation = getParentLocation;

function setCurrentTreeNode(node) {
currentTreeNode = node;
if (currentTreeNode && currentTreeNode.Location) {
dojo.hash(currentTreeNode.Location);
}
}
exports.setCurrentTreeNode = setCurrentTreeNode;

/**
* Calls the callback function 'k' with the children of a given node.
* If the children are available the callback function is called immediately otherwise
* the children will be retrieved and the callback function called whenever the children
* become available.
*/
function withChildren(node, k) {
if (node.Children) {
k(node.Children);
} else if (node.ChildrenLocation) {
fileClient.fetchChildren(node.ChildrenLocation).then(function (children) {
node.Children = children; // cache for later.
k(children);
});
}
}
exports.withChildren = withChildren;

function withCurrentChildren(k) {
withCurrentTreeNode(function (node) {
withChildren(node, k);
});
}
exports.withCurrentChildren = withCurrentChildren;

dojo.ready(function() {
mBootstrap.startup().then(function(core) {
var serviceRegistry = core.serviceRegistry;
fileClient = new mFileClient.FileClient(serviceRegistry);
});
});

return exports;

});

0 comments on commit ad86988

Please sign in to comment.