Skip to content

Commit 0aed0bf

Browse files
open in IDE
1 parent 40506ed commit 0aed0bf

3 files changed

Lines changed: 93 additions & 9 deletions

File tree

projectGeneratorElectron/app.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ ipc.on('selectAddons', function(arg) {
293293
//-------------------------------------------
294294
// allow main to send UI messages
295295
ipc.on('sendUIMessage', function(arg) {
296+
297+
// check if it has "success" message:
298+
299+
296300
displayModal(arg);
297301
});
298302

@@ -480,6 +484,11 @@ function setup() {
480484
}
481485
});
482486

487+
$("#IDEButton").on("click", function() {
488+
launchInIDE();
489+
});
490+
491+
483492
$("#verboseOption").checkbox();
484493
$("#verboseOption").on("change", function() {
485494
if ($("#verboseOption").filter(":checked").length > 0) {
@@ -848,6 +857,13 @@ function displayModal(message) {
848857
var shell = require('shell');
849858
shell.openExternal( $(this).prop("href") );
850859
});
860+
861+
if (message.indexOf("Success!") > -1){
862+
$("#IDEButton").show();
863+
} else {
864+
$("#IDEButton").hide();
865+
}
866+
851867
$("#uiModal").modal('show');
852868
}
853869

@@ -913,3 +929,16 @@ function getRandomSketchName(){
913929
ipc.send('getRandomSketchName', path );
914930
}
915931
}
932+
933+
function launchInIDE(){
934+
935+
console.log("sdfsadfasdf?");
936+
var project = {};
937+
project['projectName'] = $("#projectName").val();
938+
project['projectPath'] = $("#projectPath").val();
939+
project['platform'] = defaultSettings['defaultPlatform']; // ignores OS selection
940+
project['ofPath'] = $("#ofPath").val();
941+
942+
ipc.send('launchProjectinIDE', project );
943+
}
944+

projectGeneratorElectron/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@
6767
font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;
6868
font-size: 9px;
6969
white-space: pre;
70-
word-wrap: normal;
71-
overflow-x: scroll;
70+
word-wrap: break-word;
7271
}
7372

7473
</style>
@@ -301,6 +300,7 @@
301300
<p>Sorry, I've got nothing to say...</p>
302301
</div>
303302
<div class="actions">
303+
<div class="ui button" id="IDEButton" style="display: none;">Open in IDE</div>
304304
<div class="ui cancel button">Close</div>
305305
</div>
306306
</div>

projectGeneratorElectron/index.js

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,13 @@ function parseAddonsAndUpdateSelect(arg) {
301301
//path = require('path').resolve(__dirname, defaultOfPath + "/addons");
302302
addons = getDirectories(arg + "/addons","ofx");
303303

304-
addons = addons.filter( function(addon) {
305-
return addonsToSkip.indexOf(addon)==-1;
306-
});
304+
if (addons){
305+
if (addons.length > 0){
306+
addons = addons.filter( function(addon) {
307+
return addonsToSkip.indexOf(addon)==-1;
308+
});
309+
}
310+
}
307311

308312
console.log("Reloading the addons folder, these were found:");
309313
console.log(addons);
@@ -571,15 +575,17 @@ ipc.on('update', function(event, arg) {
571575
'<strong>Success!</strong><br>' +
572576
'Updating your project was successful! <a href="file:///' + update['updatePath'] + '" class="monospace" data-toggle="external_target">' + update['updatePath'] + '</a><br><br>' +
573577
'<button class="btn btn-default console-feature" onclick="$(\'#fullConsoleOutput\').toggle();">Show full log</button><br>' +
574-
'<div id="fullConsoleOutput"><br><textarea class="selectable">' + stdout + '</textarea></div>'
578+
'<div id="fullConsoleOutput"><br><textarea class="selectable">' + stdout + '\n\n\n(command used:' + wholeString + ')\n\n\n</textarea></div>'
575579
);
580+
581+
//
576582
event.sender.send('updateCompleted', true);
577583
} else {
578584
event.sender.send('consoleMessage', "<strong>" + wholeString + "</strong><br>" + error.message);
579585
event.sender.send('sendUIMessage',
580586
'<strong>Error...</strong><br>' +
581587
'There was a problem updating your project... <span class="monospace">' + update['updatePath'] + '</span>' +
582-
'<div id="fullConsoleOutput" class="not-hidden"><br><textarea class="selectable">' + error.message + '</textarea></div>'
588+
'<div id="fullConsoleOutput" class="not-hidden"><br><textarea class="selectable">' + error.message + '\n\n\n(command used:' + wholeString + ')\n\n\n</textarea></div>'
583589
);
584590
}
585591
});
@@ -665,7 +671,7 @@ ipc.on('generate', function(event, arg) {
665671
event.sender.send('sendUIMessage',
666672
'<strong>Success!</strong><br>' +
667673
'Your can now find your project in <a href="file:///' + fullPath + '" data-toggle="external_target" class="monospace">' + fullPath + '</a><br><br>' +
668-
'<div id="fullConsoleOutput" class="not-hidden"><br><textarea class="selectable">' + stdout + '</textarea></div>'
674+
'<div id="fullConsoleOutput" class="not-hidden"><br><textarea class="selectable">' + stdout + '\n\n\n(command used: ' + wholeString + ')\n\n\n</textarea></div>'
669675
);
670676
event.sender.send('generateCompleted', true);
671677
} else if (error !== null) {
@@ -684,7 +690,7 @@ ipc.on('generate', function(event, arg) {
684690
'<strong>Error!</strong><br>' +
685691
'<strong>Error...</strong><br>' +
686692
'There was a problem generating your project... <span class="monospace">' + fullPath + '</span>' +
687-
'<div id="fullConsoleOutput" class="not-hidden"><br><textarea class="selectable">' + stdout + '</textarea></div>'
693+
'<div id="fullConsoleOutput" class="not-hidden"><br><textarea class="selectable">' + stdout + '\n\n\n(command used: ' + wholeString + ')\n\n\n</textarea></div>'
688694

689695
);
690696

@@ -770,6 +776,55 @@ ipc.on('pickProjectImport', function(event, arg) {
770776
});
771777
});
772778

779+
780+
ipc.on('launchProjectinIDE', function(event, arg) {
781+
782+
if( arg.platform != obj.defaultPlatform ){
783+
event.sender.send('projectLaunchCompleted', false);
784+
return;
785+
}
786+
787+
var pathTemp = require('path');
788+
var fsTemp = require('fs');
789+
var fullPath = pathTemp.join(arg['projectPath'], arg['projectName']);
790+
791+
if( fsTemp.statSync(fullPath).isDirectory() == false ){
792+
// project doesn't exist
793+
event.sender.send('projectLaunchCompleted', false );
794+
return;
795+
}
796+
797+
// // launch xcode
798+
if( arg.platform == 'osx' ){
799+
var osxPath = pathTemp.join(fullPath, arg['projectName'] + '.xcodeproj');
800+
console.log( osxPath );
801+
if( fsTemp.statSync(osxPath).isDirectory() == true ){ // note: .xcodeproj is a folder, not a file
802+
var exec = require('child_process').exec;
803+
exec('open ' + osxPath, function callback(error, stdout, stderr){
804+
event.sender.send('projectLaunchCompleted', (error==null) );
805+
return;
806+
});
807+
}
808+
else {
809+
// console.log('OSX project file not found!');
810+
// event.sender.send('projectLaunchCompleted', false );
811+
// return;
812+
}
813+
}
814+
815+
// linux
816+
else if( arg.platform == 'linux' || arg.platform == 'linux64' ){
817+
// xdg-open $DESTINATION_PATH
818+
}
819+
820+
// unknown platform
821+
else {
822+
console.log("Unsupported platform for Launch feature...");
823+
event.sender.send('projectLaunchCompleted', false );
824+
return;
825+
}
826+
});
827+
773828
ipc.on('quit', function(event, arg) {
774829
app.quit();
775830
});

0 commit comments

Comments
 (0)