04.05.2015 Views

Perforce 2013.1 Javascript API for Visual Tools

Perforce 2013.1 Javascript API for Visual Tools

Perforce 2013.1 Javascript API for Visual Tools

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Programming Applets<br />

• message: (text) Description of the problem<br />

• generic: (integer) Server numeric error code<br />

• severity: Severity level associated with the message<br />

• args: An object contain the arguments specified when the command was issued<br />

The following example illustrates the basics of processing command results.<br />

function processP4Result(p4out) {<br />

// Errors, warnings and infos coming from server appear in data[],<br />

// interspersed with real data<br />

// Try to find them and promote to errors.<br />

// Of the statuses that do not represent a valid data returned, map<br />

// the possible properties from P4JsApi output to them<br />

var msgTypeMapNonData = {<br />

'p4ERROR': 'ERROR'<br />

,'p4WARNING': 'WARN'<br />

,'p4INFO': 'INFO'<br />

}<br />

,statuses = []<br />

,data = []<br />

,msgType<br />

,nonDataProperty<br />

,returnObj = {<br />

data: null<br />

,statuses: null<br />

,msgMap: {<br />

errors: []<br />

,warnings: []<br />

,infos: []<br />

,valids: []<br />

}<br />

,hasErrors: function() {return this.msgMap.errors.length>0;}<br />

,hasWarnings: function() {return this.msgMap.warnings.length>0;}<br />

,hasInfos: function() {return this.msgMap.infos.length>0;}<br />

,hasValids: function() {return this.msgMap.valids.length>0;}<br />

};<br />

12 <strong>Per<strong>for</strong>ce</strong> <strong>2013.1</strong> JavaScript <strong>API</strong> <strong>for</strong> <strong>Visual</strong> <strong>Tools</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!