Skip to content

Commit

Permalink
Merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Eisenberg committed Apr 3, 2012
2 parents b068afa + 65820e9 commit 2dfac86
Show file tree
Hide file tree
Showing 101 changed files with 5,896 additions and 2,997 deletions.
87 changes: 67 additions & 20 deletions bundles/org.eclipse.orion.client.core/web/content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,33 @@
* Glue code for content.html
*/

define(['require', 'dojo', 'orion/bootstrap', 'orion/status', 'orion/progress', 'orion/commands', 'orion/fileClient', 'orion/operationsClient',
'orion/searchClient', 'orion/dialogs', 'orion/globalCommands', 'orion/breadcrumbs', 'orion/URITemplate', 'orion/PageUtil',
define(['require', 'dojo', 'orion/bootstrap', 'orion/util', 'orion/status', 'orion/progress', 'orion/commands', 'orion/fileClient', 'orion/operationsClient',
'orion/searchClient', 'orion/globalCommands', 'orion/breadcrumbs', 'orion/URITemplate', 'orion/PageUtil',
'dojo/parser', 'dojo/hash', 'dijit/layout/BorderContainer', 'dijit/layout/ContentPane'],
function(require, dojo, mBootstrap, mStatus, mProgress, mCommands, mFileClient, mOperationsClient, mSearchClient, mDialogs,
function(require, dojo, mBootstrap, mUtil, mStatus, mProgress, mCommands, mFileClient, mOperationsClient, mSearchClient,
mGlobalCommands, mBreadcrumbs, URITemplate, PageUtil) {

dojo.addOnLoad(function() {
mBootstrap.startup().then(function(core) {
var serviceRegistry = core.serviceRegistry;
var preferences = core.preferences;
// Register services
var dialogService = new mDialogs.DialogService(serviceRegistry);
var operationsClient = new mOperationsClient.OperationsClient(serviceRegistry);
var statusService = new mStatus.StatusReportingService(serviceRegistry, operationsClient, "statusPane", "notifications", "notificationArea");
var progressService = new mProgress.ProgressService(serviceRegistry, operationsClient);
var commandService = new mCommands.CommandService({serviceRegistry: serviceRegistry});
var fileClient = new mFileClient.FileClient(serviceRegistry);
var searcher = new mSearchClient.Searcher({serviceRegistry: serviceRegistry, commandService: commandService, fileService: fileClient});

var fileMetadata;
var hostName;

function loadContent() {
var foundContent = false;
var params = PageUtil.matchResourceParameters(window.location.href);
var nonHash = window.location.href.split('#')[0];
// TODO: should not be necessary, see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=373450
var hostName = nonHash.substring(0, nonHash.length - window.location.pathname.length);
hostName = nonHash.substring(0, nonHash.length - window.location.pathname.length);
var locationObject = {OrionHome: hostName, Location: params.resource};
if (params.contentProvider) {
// Note that the shape of the "orion.page.content" extension is not in any shape or form that could be considered final.
Expand All @@ -66,28 +68,49 @@ define(['require', 'dojo', 'orion/bootstrap', 'orion/status', 'orion/progress',
info[propertyNames[j]] = contentProviders[i].getProperty(propertyNames[j]);
}
foundContent = true;
locationObject.ExitURL = hostName+"/content/exit.html";
if (info.saveToken) {
// we need to set up a SaveURL for the iframe to use.
locationObject.SaveURL = hostName+"/content/saveHook.html#" + params.resource + ",contentProvider=" + params.contentProvider + ",";
}
var uriTemplate = new URITemplate(info.uriTemplate);
var href = uriTemplate.expand(locationObject);
dojo.place('<iframe id="' + id + '" type="text/html" width="100%" height="100%" frameborder="0" src="'+ href + '"></iframe>', "delegatedContent", "only");
// this is ripe for https://bugs.eclipse.org/bugs/show_bug.cgi?id=349531
document.title = info.name;
fileClient.read(locationObject.Location, true).then(function(metadata) {
dojo.empty("location");
if (metadata) {
mGlobalCommands.setPageTarget(metadata, serviceRegistry, commandService);
searcher.setLocationByMetaData(metadata, {index: "first"});
var root = fileClient.fileServiceName(metadata.Location);
new mBreadcrumbs.BreadCrumbs({
container: "location",
resource: metadata,
firstSegmentName: root

function makeIFrame() {
var uriTemplate = new URITemplate(info.uriTemplate);
var href = uriTemplate.expand(locationObject);
dojo.place('<iframe id="' + id + '" type="text/html" width="100%" height="100%" frameborder="0" src="'+ href + '"></iframe>', "delegatedContent", "only");

}

// TODO should we have the plugin specify whether it needs a Location?
// If there is metadata, we want to fill in the location object with the name.
if (locationObject.Location && locationObject.Location.length > 0) {
fileClient.read(locationObject.Location, true).then(
function(metadata) {
dojo.empty("location");
if (metadata) {
locationObject.Name = metadata.Name;
fileMetadata = metadata;
mGlobalCommands.setPageTarget(metadata, serviceRegistry, commandService);
searcher.setLocationByMetaData(metadata, {index: "first"});
var root = fileClient.fileServiceName(metadata.Location);
new mBreadcrumbs.BreadCrumbs({
container: "location",
resource: metadata,
firstSegmentName: root
});
makeIFrame();
}

},
// TODO couldn't read metadata, try to make iframe anyway.
function() {
makeIFrame();
});
}
});
} else {
makeIFrame();
}
break;
}
}
Expand All @@ -97,6 +120,30 @@ define(['require', 'dojo', 'orion/bootstrap', 'orion/status', 'orion/progress',
}
}

// Listen for events from our internal iframe. This should eventually belong as part of the plugin registry.
// This mechanism should become generalized into a "shell services" API for plugin iframes to contact the outer context.
dojo.connect(window, "message", function(event) {
// For potentially dangerous actions, such as save, we will force the content to be from our domain (internal
// save hook), which we know has given the user the change to look at the data before save.
if (hostName && fileMetadata && event.source.parent === window && event.origin === hostName ) {
if (typeof event.data === "string") {
var data = JSON.parse(event.data);
if (data.shellService) {
if (data.sourceLocation) {
mUtil.saveFileContents(fileClient, fileMetadata, {sourceLocation: data.sourceLocation}, function() {
if (window.confirm("Content has been saved. Click OK to go to the navigator, Cancel to keep editing.")) {
// go to the navigator
window.location.href = hostName + "/navigate/table.html#" + fileMetadata.Parents[0].ChildrenLocation;
} else {
loadContent();
}
});
}
}
}
}
});

dojo.subscribe("/dojo/hashchange", this, function() {
loadContent();
});
Expand Down
27 changes: 27 additions & 0 deletions bundles/org.eclipse.orion.client.core/web/content/exit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="UTF-8">
<title>Plugin Content</title>
<link rel="stylesheet" type="text/css" href="content.css" />
<script type="text/javascript" src="../requirejs/require.js"></script>
<script type="text/javascript">
require({
baseUrl: '..',
packages: [],
paths: {
text: 'requirejs/text',
i18n: 'requirejs/i18n'
}
});

require([]);
</script>
</head>
<body>
<div id="orion.exitContentPlugin" style="margin: 8px;">
<div>Content window has been closed.</div>
</div>

</body>
</html>
31 changes: 14 additions & 17 deletions bundles/org.eclipse.orion.client.core/web/content/saveHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,15 @@
/*jslint browser:true*/

/*
* Glue code for content.html
* Save hook for verifying that the user wants to save the content from a visual plugin.
*/

define(['require', 'dojo', 'orion/bootstrap', 'orion/status', 'orion/progress', 'orion/commands', 'orion/fileClient', 'orion/operationsClient',
'orion/searchClient', 'orion/dialogs', 'orion/globalCommands', 'orion/breadcrumbs', 'orion/URITemplate', 'orion/PageUtil',
'dojo/parser', 'dojo/hash', 'dijit/layout/BorderContainer', 'dijit/layout/ContentPane'],
function(require, dojo, mBootstrap, mStatus, mProgress, mCommands, mFileClient, mOperationsClient, mSearchClient, mDialogs,
mGlobalCommands, mBreadcrumbs, URITemplate, PageUtil) {
define(['require', 'dojo', 'orion/bootstrap', 'orion/PageUtil', 'dojo/parser'],
function(require, dojo, mBootstrap, PageUtil) {

dojo.addOnLoad(function() {
mBootstrap.startup().then(function(core) {
var serviceRegistry = core.serviceRegistry;
var preferences = core.preferences;
// Register services
var dialogService = new mDialogs.DialogService(serviceRegistry);
var operationsClient = new mOperationsClient.OperationsClient(serviceRegistry);
var statusService = new mStatus.StatusReportingService(serviceRegistry, operationsClient, "statusPane", "notifications", "notificationArea");
var progressService = new mProgress.ProgressService(serviceRegistry, operationsClient);
var commandService = new mCommands.CommandService({serviceRegistry: serviceRegistry});
var fileClient = new mFileClient.FileClient(serviceRegistry);
var searcher = new mSearchClient.Searcher({serviceRegistry: serviceRegistry, commandService: commandService, fileService: fileClient});

// parse the URL to determine what should be saved.
var params = PageUtil.matchResourceParameters(window.location.href);
Expand Down Expand Up @@ -76,9 +64,18 @@ define(['require', 'dojo', 'orion/bootstrap', 'orion/status', 'orion/progress',
}
}
if (contentURL && contentURL.length > 0) {
dojo.place("<p>Content plugin <b>" + info.name + "</b> has saved data at <a href='" + contentURL + "'>" + contentURL + "</a>." +
"<p>We will be able to save this back when <a href='https://bugs.eclipse.org/bugs/show_bug.cgi?id=373443'>Bug 373443</a> is implemented.</p>",
dojo.place("<p>Content plugin <b>" + info.name + "</b> has saved data at <a href='" + contentURL + "'>" + contentURL + "</a></p>" +
"<p>Click <b>Save</b> to store this file into Orion.</p>" +
"<button id='saveButton'>Save</button>",
"orion.saveRequest" ,"only");
var button = dojo.byId("saveButton");
var nonHash = window.location.href.split('#')[0];
// TODO: should not be necessary, see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=373450
var hostName = nonHash.substring(0, nonHash.length - window.location.pathname.length);
dojo.connect(button, "onclick", function() {
// post a message to the same domain (intended for our outer window)
window.parent.postMessage(JSON.stringify({shellService: true, sourceLocation: contentURL}), hostName);
});
}
break;
}
Expand Down
1 change: 1 addition & 0 deletions bundles/org.eclipse.orion.client.core/web/css/commands.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
color: black;
font-family: sans-serif;
margin: 0;
outline: none;
}

.nihilo .dijitButtonNode, .nihilo .dijitButtonContentsHover {
Expand Down
51 changes: 49 additions & 2 deletions bundles/org.eclipse.orion.client.core/web/css/ide.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ a:hover {
margin: 0;
}

.spacingLeft {
margin-left: 5px;
}

.spacingRight {
margin-right: 5px;
}

.clear {
clear: both;
}
Expand Down Expand Up @@ -140,8 +148,6 @@ a:hover {
.pageNav {
color: #808080;
font-size: 8pt;
margin-right: 6px;
margin-left: 6px;
}

.pageActions {
Expand Down Expand Up @@ -652,6 +658,7 @@ a:hover {
max-width: 650px;
border: 1px solid #bfbfbf;
padding: 4px;
z-index: 10;
}

.keyAssistFloat {
Expand Down Expand Up @@ -840,3 +847,43 @@ a:hover {
#test-tree {
margin: 8px;
}

.uploadContainer{
padding:20px;
font-weight:bold;
}

.dottedOutline{
border: #DDD 4px dashed;
border-radius: 2px;
padding:50px;
height:300px;
width: 300px;
}

.floatingSection{
color: #DDD;
}

.uploadInstruction{
font-size: 18pt;
color: #CCC;
padding: 0 0 100px;
text-align:center;
}

.tipInstruction{
font-size: 12pt;
color: #CCC;
padding: 0 0 100px;
text-align:center;
}

.uploadBrowser{
left:50px;
}


.targetSelector{

}
38 changes: 38 additions & 0 deletions bundles/org.eclipse.orion.client.core/web/css/sections.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.sectionIcon {
float: left;
position: relative;
height: 16px;
vertical-align: text-top;
width: 16px;
padding-right: 10px;
}

.sectionTable {
padding-top: 10px;
padding-left: 10px;
}

.sectionTableItem {
padding-top: 5px;
padding-bottom: 5px;
width: 100%;
}

.sectionTableItemActions {
float: right;
position: relative;
color: #666;
font-size: 0.9em;
}

.sectionWrapper {
margin-top: 15px;
padding-top: 5px;
padding-left: 5px;
border: 1px solid #e6e6e6;
background: #f8f8f8;
}

.sectionProgress {
text-decoration: blink;
}
Loading

0 comments on commit 2dfac86

Please sign in to comment.