Skip to content

Commit

Permalink
Issue umple#411 Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
akereliuk committed Oct 15, 2015
1 parent 884bc6b commit d93ae9a
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 15 deletions.
8 changes: 5 additions & 3 deletions cruise.umple/src/Main_Code.ump
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class UmpleConsoleMain

optparser.acceptsAll(Arrays.asList("version", "v"), "Print out the current Umple version number");
optparser.acceptsAll(Arrays.asList("help"), "Display the help message");
optparser.acceptsAll(Arrays.asList("g", "generate"), "Specify the output language: Java,Cpp,RTCpp,SimpleCpp,Php,Ruby,SQL,Json,Ecore,TextUml,GvStateDiagram,StructureDiagram,GvClassDiagram,GvClassTraitDiagram,GvEntityRelationshipDiagram,Alloy,NuSMV,Yuml,SimpleMetrics,Uigu2").withRequiredArg().ofType(String.class);
optparser.acceptsAll(Arrays.asList("g", "generate"), "Specify the output language: Java,Cpp,RTCpp,SimpleCpp,Php,Ruby,SQL,Ruby,Json,Ecore,TextUml,GvStateDiagram,StructureDiagram,GvClassDiagram,GvClassTraitDiagram,GvEntityRelationshipDiagram,Alloy,NuSMV,Yuml,SimpleMetrics,Uigu2").withRequiredArg().ofType(String.class);
optparser.acceptsAll(Arrays.asList("override"), "If a output language <lang> is specified using option -g, output will only generate language <lang>");
optparser.acceptsAll(Arrays.asList("path"), "If a output language is specified using option -g, output source code will be placed to path").withRequiredArg().ofType(String.class);
optparser.acceptsAll(Arrays.asList("c","compile"), "Indicate to the entry class to compile, or with argument - to compile all outputfiles").withRequiredArg().ofType(String.class);
Expand Down Expand Up @@ -433,6 +433,7 @@ class PlaygroundMain
depend cruise.umple.compiler.exceptions.*;
depend cruise.umple.util.*;
depend java.io.*;
depend java.util.*;

public static void main(String[] args)
{
Expand Down Expand Up @@ -527,12 +528,13 @@ class PlaygroundMain
}
else if ("-source".equals(args[0]))
{
for (String generatedCode : model.getGeneratedCode().values()) {
for (Map.Entry<String, String> generatedCode : model.getGeneratedCode().entrySet()) {
if (answer.length() > 0)
{
answer += "\n\n\n\n";
}
answer += generatedCode;
answer += "//%% NEW FILE " + generatedCode.getKey() + " BEGINS HERE %%\n\n";
answer += generatedCode.getValue();
}
}
else if ("-generate".equals(args[0]))
Expand Down
8 changes: 2 additions & 6 deletions umpleonline/scripts/compiler_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,7 @@ function extractFilename()
{
file_put_contents($destfile, file_get_contents("http://" . $_REQUEST["filename"]));
if(substr($http_response_header[0],-2)!="OK") {
// try https
file_put_contents($destfile, file_get_contents("https://" . $_REQUEST["filename"]));
if(substr($http_response_header[0],-2)!="OK") {
file_put_contents($destfile, "// URL of the Umple file to be loaded in the URL after ?filename= must omit the initial http:// and end with .ump.\n// The file must be accessible from our server.\n// Could not load http://" . $_REQUEST["filename"]);
}
file_put_contents($destfile, "// URL of the Umple file to be loaded in the URL after ?filename= must omit the initial http:// and end with .ump.\n// The file must be accessible from our server.\n// Could not load http://" . $_REQUEST["filename"]);
}
}
}
Expand Down Expand Up @@ -572,4 +568,4 @@ function emptyDir($dir) {
}

closedir($handle);
}
}
82 changes: 82 additions & 0 deletions umpleonline/scripts/umple_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ Action.clicked = function(event)
{
Action.generateStructureDiagramFile();
}
else if(action == "TabsCheckbox")
{
Action.toggleTabs();
}
}

Action.focusOn = function(id, gained)
Expand Down Expand Up @@ -681,6 +685,8 @@ Action.generateCode = function(languageStyle, languageName)
format("language={0}&languageStyle={1}", actualLanguage, languageStyle),
"true"
);
jQuery("#buttonTabsCheckbox").prop('checked', false);
jQuery("#tabRow").hide();
}

Action.photoReady = function()
Expand Down Expand Up @@ -2055,3 +2061,79 @@ Mousetrap.bind(['c'], function(e){
}
});

// Function for splitting code into tabs for every new file, activated when checking the Show Tabs checkbox
Action.toggleTabs = function()
{
// Checking on the checkbox
if(jQuery('#buttonTabsCheckbox').is(':checked')){

// Show row with buttons for each filename
jQuery('#tabRow').html('');
jQuery('#tabRow').show();

// Hide main code window with glommed files
jQuery('#innerGeneratedCodeRow').nextAll().remove();
jQuery('#innerGeneratedCodeRow').hide();

var arrCodeFiles = [];
var intFileCounter = 0;
var strFileContents = "";
var arrFileNames = [];

// Read full code output line by line
jQuery('.content').each(function(){

// If New File Beginning
if(jQuery(this).text().indexOf("//%%") >= 0){
strFileName = jQuery(this).text().slice(14);
strFileName = strFileName.substr(0, strFileName.indexOf(' '));
arrFileNames[intFileCounter] = strFileName;
arrCodeFiles[intFileCounter] = strFileContents;
intFileCounter++;
jQuery('#generatedCodeRow').append("<div id='innerGeneratedCodeRow" + intFileCounter + "'></div>");
strFileContents = "";
strFileContents += "<a href=\"umpleonline/../ump/tmp238804/JavaFromUmple.zip\" class=\"zipDownloadLink\">Download the following as a zip file</a>&nbsp;<p>URL_SPLIT";
strFileContents += jQuery(this).text() + "\n";
}
else{
strFileContents += jQuery(this).text() + "\n";
}

});

// Output buttons for number of files found
for (i=1; i < intFileCounter; i++){
jQuery('#tabRow').append("<button type='button' id='tabButton" + i + "'>" + arrFileNames[i-1] + "</button>");
jQuery('#tabButton' + i).click({code: arrCodeFiles[i], tabnumber: i}, showTab);
}

}
// Checking off the checkbox
else{
// Hide row with buttons
jQuery('#tabRow').html('');

// Show main code window with glommed files
jQuery('#innerGeneratedCodeRow').show();

// Hide all file codeblocks
jQuery('#innerGeneratedCodeRow').nextAll().remove();
}
}

function showTab(event)
{
// Hide all file codeblocks
jQuery('#innerGeneratedCodeRow').nextAll().hide();

// Show only relevant file codeblock
jQuery('#innerGeneratedCodeRow' + event.data.tabnumber).show();

// Generate code for specific file only
Page.showGeneratedCode(event.data.code, $("inputGenerateCode").value.split(":")[0], event.data.tabnumber);
jQuery('.line').last().hide();

// Hide main code window with glommed files
jQuery('#innerGeneratedCodeRow').hide();
}

17 changes: 11 additions & 6 deletions umpleonline/scripts/umple_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Page.initPaletteArea = function()
Page.initAction("buttonUigu");
Page.initAction("buttonStartOver");
Page.initAction("buttonGenerateCode");
Page.initAction("buttonTabsCheckbox");
Page.initAction("buttonSmaller");
Page.initAction("buttonLarger");
Page.initAction("buttonSyncCode");
Expand Down Expand Up @@ -195,6 +196,7 @@ Page.initOptions = function()
jQuery("#buttonShowHideLayoutEditor").prop('checked', Layout.isLayoutVisible);
jQuery("#buttonShowHideTextEditor").prop('checked', Layout.isTextVisible);
jQuery("#buttonShowHideCanvas").prop('checked', Layout.isDiagramVisible);
jQuery("#buttonTabsCheckbox").prop('checked', false);
jQuery("#buttonToggleAttributes").prop('checked',true);
jQuery("#buttonToggleActions").prop('checked',true);
jQuery("#buttonToggleTraits").prop('checked',false);
Expand Down Expand Up @@ -813,8 +815,11 @@ Page.showViewDone = function()
setTimeout(function() {jQuery(selector).dialog("close");}, 2000);
}

Page.showGeneratedCode = function(code,language)
Page.showGeneratedCode = function(code,language,tabnumber)
{
// Default "tabnumber" parameter to null, ie. only output to the main codeblock
if (typeof(tabnumber)==='undefined') tabnumber = "";

Page.applyGeneratedCodeAreaStyles(language);

var errorMarkup = Page.getErrorMarkup(code, language);
Expand All @@ -827,9 +832,9 @@ Page.showGeneratedCode = function(code,language)
if(language == "java" || language == "php" || language == "cpp"
|| language == "ruby" || language == "xml" || language == "sql")
{
jQuery("#innerGeneratedCodeRow").html(
formatOnce('<pre class="brush: {1};">{0}</pre>',generatedMarkup,language)
)
jQuery("#innerGeneratedCodeRow" + tabnumber).html(
formatOnce('<pre class="brush: {1};">{0}</pre>',generatedMarkup,language)
)
SyntaxHighlighter.highlight("code");
}
else if(language == "structureDiagram")
Expand All @@ -847,7 +852,7 @@ Page.showGeneratedCode = function(code,language)
}
else
{
jQuery("#innerGeneratedCodeRow").html(generatedMarkup);
jQuery("#innerGeneratedCodeRow" + tabnumber).html(generatedMarkup);
}
}

Expand Down Expand Up @@ -1017,4 +1022,4 @@ jQuery.fn.selectRange = function(start, end) {
range.select();
}
});
}
}
5 changes: 5 additions & 0 deletions umpleonline/umple.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,12 @@
</div>

<div id="generatedCodeRow" class="row">
<li id="ttTabsCheckbox">
<input id="buttonTabsCheckbox" type="checkbox" class="checkbox" name="buttonTabsCheckbox" value="buttonTabsCheckbox"/>
<a id="labelTabsCheckbox" class="buttonExtend">Show Files in Separate Tabs</a>
</li>
<div id="messageArea"></div>
<div id="tabRow"></div>
<div id="innerGeneratedCodeRow"></div>
</div>

Expand Down

0 comments on commit d93ae9a

Please sign in to comment.