Skip to content

Commit

Permalink
initial release of console and separate Debug and Connections pages
Browse files Browse the repository at this point in the history
  • Loading branch information
grant-g authored and skaegi committed Jan 12, 2012
1 parent f58723e commit 49ed34f
Show file tree
Hide file tree
Showing 9 changed files with 635 additions and 355 deletions.
163 changes: 163 additions & 0 deletions bundles/org.eclipse.orion.client.core/web/orion/console.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*******************************************************************************
* @license
* Copyright (c) 2011, 2012 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).
******************************************************************************/

/*global define*/
/*jslint browser:true*/

define(['dojo', 'orion/textview/textView'], function(dojo, mTextView) {

var orion = {};
orion.console = {};

/**
* Constructs a new ConsoleInput object.
*
* @class A ConsoleInput represents a command that is being entered in a Console.
* @name orion.console.ConsoleInput
*/
orion.console.ConsoleInput = (function() {
function ConsoleInput(console, textView) {
this._init(console, textView);
}
ConsoleInput.prototype = /** @lends orion.console.ConsoleInput.prototype */{
/** @private */
_init: function(console, textView) {
if (!console) { throw "no console"; }
if (!textView) { throw "no textView"; }
this._console = console;
this._textView = textView;
this._enabled = true;
var model = textView.getModel();
this._startIndex = model.getCharCount();
model.setText("> ", this._startIndex);
textView.setCaretOffset(this._startIndex + 2, false);
},
getStartIndex: function() {
return this._startIndex;
},
getText: function() {
return this._textView.getModel().getText(this._startIndex + 2);
},
handleVerifyEvent: function(verifyEvent) {
if (verifyEvent.start < this._startIndex + 2) {
return false;
}
if (!this._enabled) {
verifyEvent.text = null;
}
return true;
},
setEnabled: function(value) {
this._enabled = value;
this._textView.redrawRange(this._startIndex);
},
setStartIndex: function(value) {
this._textView.setCaretOffset(this._textView.getCaretOffset() + (value - this._startIndex));
this._startIndex = value;
}
};
return ConsoleInput;
}());

/**
* Constructs a new console.
*
* @param options the view options.
* @param parent the parent element for the console, it can be either a DOM element or an ID for a DOM element.
*
* @class A Console is a user interface that accepts input command lines and displays output.
* @name orion.console.Console
*/
orion.console.Console = (function() {
function Console(parent) {
this._init(parent);
}
Console.prototype = /** @lends orion.console.Console.prototype */{
/** @private */
_init: function(parent) {
if (!parent) { throw "no parent"; }

var textView = new mTextView.TextView({parent: parent});
this._textView = textView;
this._currentInput = new orion.console.ConsoleInput(this, textView);

var self = this;
textView.addEventListener("Verify", function(verifyEvent) {
if (!self._currentInput.handleVerifyEvent(verifyEvent)) {
verifyEvent.text = null;
}
});

this._inputListeners = [];
textView.addEventListener("Modify", function(modelChangedEvent) {
var text = self._currentInput.getText();
var index = text.indexOf("\r\n");
if (index !== -1) {
var value = text.substring(0, index);
for (var i = 0; i < self._inputListeners.length; i++) {
var current = self._inputListeners[i];
current(value);
}
self._currentInput = new orion.console.ConsoleInput(self, textView);
}
});

this._inputStyleListeners = [];
// textView.addEventListener("LineStyle", function(lineStyleEvent) {
// self._currentInput.handleLineStyleEvent(lineStyleEvent);
// if (lineStyleEvent.lineStart !== self._startIndex) {
// return;
// }
// if (!self._enabled) {
// lineStyleEvent.style = {style: {color: "#FF0000"}};
// } else {
// lineStyleEvent.style = {style: {color: "#0000FF"}};
// }
// });
},

appendOutput: function(text) {
var model = this._textView.getModel();
var startIndex = this._currentInput.getStartIndex();
var inputText = model.getText(startIndex);
var length = text.length;
model.setText(text + "\r\n" + inputText, startIndex);
this._currentInput.setStartIndex(this._currentInput.getStartIndex() + 2 + length);
},
addInputListener: function(listener) {
this._inputListeners.push(listener);
},
addInputStyleListener: function(listener) {
this._inputStyleListeners.push(listener);
},
removeInputListener: function(listener) {
for (var i = 0; i < this._inputListeners.length; i++) {
if (this._inputListeners[i] === listener) {
this._inputListeners.splice(i, 1);
return;
}
}
},
removeInputStyleListener: function(listener) {
for (var i = 0; i < this._inputStyleListeners.length; i++) {
if (this._inputStyleListeners[i] === listener) {
this._inputStyleListeners.splice(i, 1);
return;
}
}
},
setAcceptInput: function(value) {
this._currentInput.setEnabled(value);
}
};
return Console;
}());

return orion.console;
});
45 changes: 45 additions & 0 deletions bundles/org.eclipse.orion.client.debug/web/connections.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@import "../org.dojotoolkit/dojo/resources/dojo.css";
@import "../org.dojotoolkit/dijit/themes/nihilo/nihilo.css";
@import "../org.dojotoolkit/dijit/themes/nihilo/Tree.css";
@import "../org.dojotoolkit/dijit/themes/nihilo/layout/BorderContainer.css";
@import "../org.dojotoolkit/dijit/themes/nihilo/form/Common.css";
@import "../org.dojotoolkit/dijit/themes/nihilo/form/Button.css";
@import "../css/ide.css";
@import "../css/commands.css";

html,body {
height: 100%;
}

h1 {
position: relative;
margin-top: 18px;
}

.statusPane {
font-weight: bold;
}

.domCommandToolbar {
padding-left: 8px;
}

tr.treeTableRow td:first-child {
padding-left: 16px !important;
}

.treetable th {
font-weight: bold;
}

.treetable td {
padding: 16px 0 16px 16px;
}

.treetable th {
padding: 16px 0 0 16px;
}

.siteConfigDetails {
padding-left: 16px;
}
55 changes: 55 additions & 0 deletions bundles/org.eclipse.orion.client.debug/web/connections.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2011, 2012." >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Debug Connections</title>
<link rel="stylesheet" type="text/css" href="./connections.css" />
<script src="../requirejs/require.js"></script>
<script src="../orion/plugin.js"></script>
<script src="../org.dojotoolkit/dojo/dojo.js.uncompressed.js"></script>
<script type="text/javascript">
require({
baseUrl: '..',
packages: [
{
name: 'dojo',
location: 'org.dojotoolkit/dojo',
main: 'lib/main-browser',
lib: '.'
},
{
name: 'dijit',
location: 'org.dojotoolkit/dijit',
main: 'lib/main',
lib: '.'
},
{
name: 'dojox',
location: 'org.dojotoolkit/dojox',
main: 'lib/main',
lib: '.'
}
],
paths: {
text: 'requirejs/text',
i18n: 'requirejs/i18n'
}
});
require(["./connections"]);
</script>
</head>

<body style="visibility:hidden;" class="nihilo">
<div id="orion-debugConnections" dojotype="dijit.layout.BorderContainer" design="headline" gutters="false" style="width: 100%; height: 100%;">
<div class="toolbar" id="toolbar" dojotype="dijit.layout.ContentPane" region="top">
</div>
<div id="orion-debugConnectionsMainPane" dojotype="dijit.layout.ContentPane" region="center" class="mainpane">
<div id="orion-debugMessaging"></div>
<div id="debugConnections-table"></div>
</div>
<div class="footer" id="footer" dojotype="dijit.layout.ContentPane" region="bottom" splitter="false">
</div>
</div>
</body>
</html>
Loading

0 comments on commit 49ed34f

Please sign in to comment.