Changes related to the following issues:

22 - Reload the project after updating its properties
21 - Bug when dragging the background of the ER Diagram
24 - Fail detecting the end of an instruction when you have an attribute with type wirh .
29 - ER Diagram does not open on Google Chrome

Still under maintance
26 - Some changes... still, more to be done
Esse commit está contido em:
felipenmoura
2010-03-28 05:29:20 +00:00
commit 9b6ddc7786
7 arquivos alterados com 111 adições e 77 exclusões
+80 -27
Ver Arquivo
@@ -1,14 +1,16 @@
<?php
/*
CLass: MindProcessor 1.0
Definition: class used to interpret and generate wml code
Author: Felipe Nascimento
Observations:
* tables without relations (neither pointed by nor pointing to other tables) will not exist
/**
* CLass: MindProcessor 1.0
* @package processor
* Definition: class used to interpret and generate wml code
* Author: Felipe Nascimento
*
* Observations:
* * tables without relations (neither pointed by nor pointing to other tables) will not exist
*/
class MindProcessor
{
// defining properties
public $tables= Array();
public $relations= Array();
public $DDL;
@@ -23,7 +25,9 @@
public $status= 1;
public $debug= Array();
public $subTypes = Array();
public $theWebMindLanguageTempTable = 'theWebMindLanguageTempTable';
// this table will be created, and then discarted
public $theWebMindLanguageTempTable= 'theWebMindLanguageTempTable';
// supported types
public $types = Array('char',
'varchar',
'text',
@@ -33,7 +37,8 @@
'int',
'bigint',
'real',
'time'); // supported types
'time');
// keywords. Mind will match then to force a pattern after dealing with the choosen language
public $verbId = ' ||"||MIND_VERB||"|| ';
public $required = ' ||"||MIND_REQUIRED||"|| ';
public $unique = ' ||"||MIND_UNIQUE||"|| ';
@@ -44,17 +49,24 @@
'max'=>' ||"||MIND_QUANTIFY_MIN_MAX||"|| '),
'max'=> Array('min'=>' ||"||MIND_QUANTIFY_MAX_MIN||"|| ',
'max'=>' ||"||MIND_QUANTIFY_MAX_MAX||"|| '));
/**
* This method receives the text and parses it into an Array with all the expressions, separeted by "." or ";"
* @name parse
* @param String $str
* @return numeric Array
*/
private function parse($str)
{
$expressions= Array();
$sep= Array('.', ';');
$str= preg_split('//', trim($str));
$expressions= Array(); // will have all the expressions to be interpreted
$sep= Array('.', ';'); // expression separator
$str= preg_split('//', trim($str)); // separing comments
$str[]= $sep[0];
$iside= false;
$inside= false;
$comment= false;
$allow= false;
$insideAtt= false;
$currentExpression= '';
for($i=0, $j= sizeof($str); $i<$j; $i++)
{
$letter= $str[$i];
@@ -74,6 +86,7 @@
}
}
}
if($comment)
continue;
if($i>0 && $str[$i-1] == '\\')
@@ -81,29 +94,45 @@
$currentExpression.= $str[$i];
continue;
}
if(!$iside && $letter == '[' || $letter == '{')
// checks whether it is opening a mask or option and if it is NOT inside the default value identification
if(!$inside && $letter == '[' || $letter == '{')
{
$allow= true;
}
if(!$iside && $letter == ']' || $letter == '}')
if(!$inside && $letter == ']' || $letter == '}')
{
$allow= false;
}
if(!$allow && !$iside && in_array($letter, $sep))
// checking if it is inside the attribute properties
if(!$inside && !$allow && $letter == '(')
$insideAtt= true;
if(!$inside && !$allow && $letter == ')')
$insideAtt= false;
// if the current letter identifies an end of command and it is neither inside a string
// not a mask/option identifier
if(!$allow && !$inside && !$insideAtt && in_array($letter, $sep))
{
$expressions[]= trim($currentExpression);
// add the current expression to the list of expressions
$expressions[]= trim(stripslashes($currentExpression));
$currentExpression= '';
}else{
if($letter == '"')
$iside= !$iside;
$inside= !$inside;
$currentExpression.= $letter;
}
}
return $expressions;
}
/**
* This is the constructor
* if it receives a project object by parameter, it processes this project, otherwise, it simply returns itself
* with its current properties
* @author Felipe Nascimento
* @name __construct
* @param [Project Object]
* @return void
*/
public function __construct($project=false) // obj of project
{
if(!$project){
@@ -498,11 +527,23 @@
$this->debug['messages']= $this->messages;
return $this;
}
/**
* Get method to return the list of currently supported types
* @author Felipe Nascimento
* @name getSupportedTypes
* @return numeric Array
*/
public function getSupportedTypes(){
return $this->types;
}
/**
* This function is used only to show a list of the current entities
* use it only for debug
* @author Felipe Nascimento
* @name showTables
* @return void
*/
public function showTables()
{
echo '<pre>';
@@ -521,6 +562,13 @@
echo '</pre>';
}
/**
* This function is used to filter data, replacing special chars (specified in the Language Object)
* @author Felipe Nascimento
* @name filter
* @param String $text
* @return String
*/
public function filter($text)
{
$size= sizeof($this->especialChars);
@@ -531,9 +579,14 @@
$text= preg_replace('/\.$|;$|,$/', '', $text);
return strtolower($text);
}
private function proccessExpression($mindExp)
{
}
/**
* Interprets the expression and sets the its properties, applying the rules
* @author Felipe Nascimento
* @name execExpression
* @param String $mindExp
* @return void
*/
private function execExpression($mindExp)
{
GLOBAL $_MIND;
@@ -753,4 +806,4 @@
}
}
}
?>
?>
@@ -22,7 +22,7 @@
$_POST = $p->preparePost($_POST);
$p->populate($_POST);
if($p->save())
echo "Saved";
echo $_GET["code"];
else
echo "Error";
exit;
@@ -59,4 +59,4 @@
</table>
<script>
Mind.View.Project.Manage();
</script>
</script>
+22 -46
Ver Arquivo
@@ -18,7 +18,9 @@ Mind.ERD= {
$(Mind.ERD.mapAreaContainer).bind('mousedown', function(){this.style.cursor= 'move';});
$(Mind.ERD.mapAreaContainer).draggable({});
$(Mind.ERD.mapAreaContainer).bind('mouseup', function(){this.style.cursor= 'default';});
$(Mind.ERD.mapAreaContainer).bind('mousedown', Mind.ERD.ResetZoom);
$(Mind.ERD.mapAreaContainer).bind('mousedown', function(){
Mind.ERD.currentScale= Mind.ERD.mapAreaContainer.getAttribute('currentScale');
});
Mind.ERD.mapAreaContainer.style.position= 'absolute';
Mind.ERD.mapAreaContainer.style.top= -4555;
@@ -111,7 +113,6 @@ Mind.ERD= {
str+= "<textarea readonly='readonly'>"+qrD+'</textarea>';
str+= "</div>";
Mind.Dialog.ShowData(str, 'SQL Commands for '+obj.name, 500, 400, true);
//Mind.Dialog.OpenModal(str, 'SQL Commands for '+obj.name, 500, 400, true);
var div= $('#tmpSQLTabContainer_'+obj.name+rand);
div.tabs();
},
@@ -119,8 +120,6 @@ Mind.ERD= {
if(Mind.ERD.shownTables[table.name])
return false;
//alert(table.extends)
var tb= document.createElement('TABLE');
tb.className= 'der_table';
tb.id= 'der_table_id_'+table.name;
@@ -247,9 +246,12 @@ Mind.ERD= {
drag:function(){
Mind.ERD.ReDraw();
},
start: Mind.ERD.ResetZoom,
start: function(){
},
stop:function(){
Mind.ERD.ReDraw();
Mind.ERD.ApplyZoom(Mind.ERD.currentScale, true);
},
scrollSensitivity: tb.offsetWidth/2
});
@@ -300,8 +302,6 @@ Mind.ERD= {
if(table.extends)
{
//alert(table.extends);
//Mind.ERD.shownTables[table.name]
Mind.ERD.generalization[table.extends]= table;
}
@@ -549,13 +549,11 @@ Mind.ERD= {
}else{
except= true;
}
//document.getElementById('DDRLoadList').style.display= 'none';
}
if(except)
{
Mind.Dialog.ShowData('Some tables do not exist anymore and will not be added to the current diagram', 'Error');
}
//Mind.ERD.ShowToolBar();
}
);
},
@@ -563,7 +561,6 @@ Mind.ERD= {
this.shownTables= Array();
this.relations= Array();
Mind.ERD.mapAreaContainer.innerHTML= '';
//document.getElementById('saveCurrentDERName').value= '';
$('#outputPanel_der_listContainer [tableName]').removeClass('der_list_table_');
},
showBallon:function(o, flag){
@@ -649,21 +646,25 @@ Mind.ERD= {
o.style.MozTransform= 'scale(1)';
o.style.webkitTransform= 'scale(1)';
},
ApplyZoom: function(v){
ApplyZoom: function(v, force){
var o= Mind.ERD.mapAreaContainer;
if(!o.getAttribute('currentScale'))
o.setAttribute('currentScale', 1.0);
var s= o.getAttribute('currentScale');
if(v>0)
if(!force)
{
if(s > 1.3)
return false;
s= 0.1 - (s*-1);
}else{
if(s < 0.7)
if(v>0)
{
if(s > 1.3)
return false;
s= s-0.1;
}
s= 0.1 - (s*-1);
}else{
if(s < 0.7)
return false;
s= s-0.1;
}
}else
s= v;
o.setAttribute('currentScale', s);
o.style.MozTransform= 'scale('+s+')';
o.style.webkitTransform= 'scale('+s+')';
@@ -734,7 +735,6 @@ Mind.ERD= {
obj= Mind.Project.knowledge.tables[this.shownTables[i].name];
ctx.textAlign= 'left';
t+= 2;
if(obj.attributes)
{
@@ -747,7 +747,7 @@ Mind.ERD= {
for(var att in obj.attributes)
{
c+= 22;
ctx.fillText(obj.attributes[att].name, l+3, t+10+c);
ctx.fillText(obj.attributes[att].name, l+3, t+9+c);
}
}
if(obj.foreignKeys.length > 0)
@@ -758,34 +758,10 @@ Mind.ERD= {
for(fk in obj.foreignKeys)
{
c+= 22;
ctx.fillText(obj.foreignKeys[fk][0], l+3, t+10+c);
ctx.fillText(obj.foreignKeys[fk][0], l+3, t+9+c);
}
}
}
//alert(links.length);
//ctx.fillText(leftEst+' : '+toppEst, 10, 10);
/*
ctx.clearRect(0,0,1024,768);
ctx.fillRect(25,25,100,100);
ctx.fillRect(500,500,100,100);
ctx.strokeStyle = "red";
ctx.beginPath();
ctx.moveTo(75,75);
ctx.lineTo(275,75);
ctx.stroke();
ctx.moveTo(275,550);
ctx.lineTo(550,550);
ctx.stroke();
ctx.moveTo(275,75);
ctx.lineTo(275,550);
ctx.stroke();
ctx.fillText("Sample String", 400, 50);
*/
if(document.getElementById('tmpCanvas'))
document.getElementById('tmpCanvas').parentNode.removeChild(document.getElementById('tmpCanvas'));
+6 -1
Ver Arquivo
@@ -1457,8 +1457,13 @@ Mind.View.Project = {
success: function(msg){
if(msg=="error"){
$("#mind_manage_project_label_message").html("<span style='font-weight:bold;color:red'>Error</span>");
}else{
}else{
Mind.Utils.SetLoad(false);
if(msg == Mind.Project.attributes.name)
{
Mind.Project.Close();
Mind.Project.Load(msg);
}
}
},
error : function(XMLHttpRequest, textStatus, errorThrown){
Ver Arquivo

Antes

Largura:  |  Altura:  |  Tamanho: 2.8 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 2.8 KiB

Ver Arquivo

Antes

Largura:  |  Altura:  |  Tamanho: 2.8 KiB

Depois

Largura:  |  Altura:  |  Tamanho: 2.8 KiB

+1 -1
Ver Arquivo
@@ -17,7 +17,7 @@
<verb value="usa"/>
<verb value="usam"/>
<verb value="pertence a"/>
</verbs>
<verb value="ganha"/></verbs>
<belongs>
<verb value="pode ser"/>
<verb value="pode ter"/>