Skip to content

Commit cbe2ba0

Browse files
committed
Merge pull request #73 from openframeworks/openInIDE
open in IDE
2 parents 141f46a + ed6fe73 commit cbe2ba0

File tree

3 files changed

+93
-11
lines changed

3 files changed

+93
-11
lines changed

projectGeneratorElectron/app.js

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

@@ -481,6 +485,11 @@ function setup() {
481485
}
482486
});
483487

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

@@ -914,3 +930,15 @@ function getRandomSketchName(){
914930
ipc.send('getRandomSketchName', path );
915931
}
916932
}
933+
934+
function launchInIDE(){
935+
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 cancel 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: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ var platforms = {
9292
"osx": "OS X (Xcode)",
9393
"vs": "Windows (Visual Studio 2015)",
9494
"ios": "iOS (Xcode)",
95-
"linux": "Linux 32-bit (Code::Blocks)",
96-
"linux64": "Linux 64-bit (Code::Blocks)",
95+
"linux": "Linux 32-bit (qtCreator)",
96+
"linux64": "Linux 64-bit (qtCreator)",
9797
"linuxarmv6l": "Linux ARMv6 (Makefiles)",
9898
"linuxarmv7l": "Linux ARMv7 (Makefiles)"
9999
};
@@ -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,54 @@ 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+
return;
805+
});
806+
}
807+
else {
808+
console.log('OSX project file not found!');
809+
}
810+
} else if( arg.platform == 'linux' || arg.platform == 'linux64' ){
811+
var linuxPath = pathTemp.join(fullPath, arg['projectName'] + '.qbs');
812+
console.log( linuxPath );
813+
var exec = require('child_process').exec;
814+
exec('xdg-open ' + linuxPath, function callback(error, stdout, stderr){
815+
return;
816+
});
817+
} else {
818+
var windowsPath = pathTemp.join(fullPath, arg['projectName'] + '.sln');
819+
console.log( windowsPath );
820+
var exec = require('child_process').exec;
821+
exec('start ' + windowsPath, function callback(error, stdout, stderr){
822+
return;
823+
});
824+
}
825+
});
826+
773827
ipc.on('quit', function(event, arg) {
774828
app.quit();
775829
});

0 commit comments

Comments
 (0)