Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
StarUML Evológica Plugin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
evologica
StarUML Evológica Plugin
Commits
fc665ea6
Commit
fc665ea6
authored
Oct 28, 2020
by
Jucelino Fonseca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ajustes
parent
3b105274
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
353 additions
and
33 deletions
+353
-33
ituExplorerV2.pas
EvoUMLPlugin/src/ituExplorerV2.pas
+353
-33
No files found.
EvoUMLPlugin/src/ituExplorerV2.pas
View file @
fc665ea6
...
...
@@ -9,10 +9,22 @@ uses
acuObjectExplorer
,
Menus
,
Buttons
,
SynEdit
,
SynHighlighterSQL
,
SynCompletion
,
acuModel
,
acuRepositorySQL
,
SynEditKeyCmds
,
SynHighlighterPython
,
SynFacilHighlighter
,
SynFacilCompletion
,
SynFacilBasic
,
Types
;
const
__WHERE
=
'WHERE'
;
__SELECT
=
'SELECT'
;
__FROM
=
'FROM'
;
__WHERE
=
'WHERE'
;
__SELECT
=
'SELECT'
;
__FROM
=
'FROM'
;
__JOIN
=
'JOIN'
;
__ON
=
'ON'
;
__VIRGULA
=
','
;
__AS
=
'AS'
;
__ORDER
=
'ORDER'
;
__BY
=
'BY'
;
__GROUP
=
'GROUP'
;
__PARENTESES_ABERTO
=
'('
;
__PARENTESES_FECHADO
=
')'
;
__EXISTS
=
'EXISTS'
;
__IN
=
'IN'
;
type
TDLLDialog
=
class
(
TForm
)
...
...
@@ -143,10 +155,19 @@ type
function
BuscaParcialClasse
(
piCLasse
:
string
;
piFiltrar
:
boolean
):
boolean
;
function
BuscarParcialChildClass
(
piClassTicket
:
acClassTicket
;
piFiltrar
:
boolean
):
boolean
;
function
FindParcialNodeClass
(
piClassTicketPai
:
acClassTicket
;
piFiltrar
:
boolean
):
acClassTicket
;
//procedure ExecutarSybCompletion(piSynCompletion : TSynCompletion);
procedure
LoadListCompletion
(
piLinha
:
string
;
piAceitaAtributo
:
boolean
;
piLista
:
TStrings
);
procedure
LoadAliasCompletion
(
piLinha
:
string
);
// procedure PreparaSynCompletion;
//
function
RetirarTextoDepois
(
piTextoEntrada
,
piPalavraRetirar
:
string
;
out
piTextoAntes
:
string
):
string
;
function
RetirarTextoAntes
(
piTextoEntrada
,
piPalavraRetirar
:
string
;
out
piTextoDepois
:
string
;
piSemPalavra
:
boolean
=
true
):
string
;
function
RetirarTextoEntre
(
piTextoEntrada
,
piPalavraInicio
,
piPalavraFim
:
string
;
out
piTextoDepois
:
string
;
piSemPalavraFim
:
boolean
=
true
):
string
;
procedure
LoadAliasOQLEdit
(
piTexto
:
string
;
piAlias
:
TStrings
);
function
ContemPalavra
(
piPalavra
,
piTextoEntrada
:
string
):
boolean
;
function
ContemPalavrasEspeciais
(
piTextoEntrada
:
string
):
boolean
;
procedure
AddAliasListas
(
piLinhas
:
string
;
piAlias
:
TStrings
);
function
LoadAliasBlocoFROMOQLEdit
(
piTexto
:
string
;
piAlias
:
TStrings
):
string
;
function
GetClassTicketByNameRelation
(
piNameObjeto
:
string
)
:
acClassTicket
;
function
GetClassTicketByNameANDAlias
(
piNameObjeto
:
string
)
:
acClassTicket
;
//
function
RetirarPalavraChaveOLQ
(
piSynEdit
:
TSynEdit
):
string
;
function
IsKeyword
(
piItem
:
string
):
boolean
;
...
...
@@ -746,7 +767,8 @@ begin
ls_aux
:=
trim
(
piLinha
);
lClassTicketAux
:=
nil
;
ls_Objeto
:=
trim
(
Copy
(
ls_aux
,
0
,
li_Pos
-
1
));
lClassTicketCurrent
:=
self
.
MetaModel
.
GetClassTicketByName
(
ls_Objeto
);
//lClassTicketCurrent := self.MetaModel.GetClassTicketByName(ls_Objeto);
lClassTicketCurrent
:=
self
.
GetClassTicketByNameANDAlias
(
ls_Objeto
);
while
li_Pos
>
0
do
begin
...
...
@@ -827,42 +849,336 @@ begin
end
;
procedure
TExplorerV2
.
LoadAliasCompletion
(
piLinhas
:
string
);
var
ls_texto
,
ls_espaco
:
string
;
li_Pos
:
integer
;
ls_Alias
:
string
;
ls_classe
:
string
;
function
TExplorerV2
.
RetirarTextoDepois
(
piTextoEntrada
,
piPalavraRetirar
:
string
;
out
piTextoAntes
:
string
):
string
;
var
ls_texto
:
string
;
li_PosInicial
:
integer
;
begin
ls_espaco
:=
' '
;
li_Pos
:=
Pos
(
__FROM
,
uppercase
(
piLinhas
));
if
li_Pos
>
0
then
result
:=
''
;
if
piTextoEntrada
<>
''
then
begin
ls_texto
:=
trim
(
Copy
(
result
,
li_Pos
+
Length
(
__FROM
),
Length
(
piLinhas
)));
ls_texto
:=
UpperCase
(
piTextoEntrada
);
li_PosInicial
:=
Pos
(
piPalavraRetirar
,
ls_texto
);
if
li_PosInicial
>
0
then
begin
if
Length
(
piPalavraRetirar
)
>
1
then
begin
li_PosInicial
:=
li_PosInicial
+
Length
(
piPalavraRetirar
);
piTextoAntes
:=
trim
(
Copy
(
piTextoEntrada
,
0
,
li_PosInicial
-
1
));
end
else
begin
piTextoAntes
:=
trim
(
Copy
(
piTextoEntrada
,
0
,
li_PosInicial
));
end
;
result
:=
trim
(
Copy
(
piTextoEntrada
,
li_PosInicial
+
1
,
Length
(
piTextoEntrada
)));
end
;
end
;
li_Pos
:=
Pos
(
ls_espaco
,
trim
(
ls_texto
));
if
li_Pos
>
0
then
end
;
function
TExplorerV2
.
RetirarTextoAntes
(
piTextoEntrada
,
piPalavraRetirar
:
string
;
out
piTextoDepois
:
string
;
piSemPalavra
:
boolean
):
string
;
var
ls_texto
:
string
;
li_PosFinal
:
integer
;
begin
result
:=
''
;
if
piTextoEntrada
<>
''
then
begin
ls_classe
:=
trim
(
Copy
(
ls_texto
,
0
,
li_Pos
-
1
);
ls_texto
:=
trim
(
Copy
(
ls_texto
,
li_Pos
+
1
,
Length
(
ls_texto
)));
li_Pos
:=
Pos
(
ls_espaco
,
trim
(
ls_texto
));
if
li_Pos
>
0
then
ls_texto
:=
UpperCase
(
piTextoEntrada
);
li_PosFinal
:=
Pos
(
piPalavraRetirar
,
ls_texto
);
if
li_PosFinal
>
0
then
begin
ls_Alias
:=
trim
(
Copy
(
ls_texto
,
0
,
li_Pos
-
1
);
if
UpperCase
(
ls_Alias
)
=
'AS'
then
begin
ls_Alias
:=
trim
(
Copy
(
ls_texto
,
li_Pos
+
1
+
li_Pos
-
1
);
end
else
if
piSemPalavra
then
begin
li_PosFinal
:=
li_PosFinal
-
1
;
end
;
result
:=
trim
(
Copy
(
piTextoEntrada
,
0
,
li_PosFinal
));
piTextoDepois
:=
trim
(
Copy
(
piTextoEntrada
,
li_PosFinal
,
Length
(
piTextoEntrada
)));
if
(
not
piSemPalavra
)
and
(
Length
(
result
)
=
1
)
then
begin
result
:=
''
;
end
;
end
;
end
;
end
;
function
TExplorerV2
.
RetirarTextoEntre
(
piTextoEntrada
,
piPalavraInicio
,
piPalavraFim
:
string
;
out
piTextoDepois
:
string
;
piSemPalavraFim
:
boolean
):
string
;
var
ls_TextoAntes
,
ls_texto
:
string
;
li_PosFinal
:
integer
;
begin
piTextoDepois
:=
piTextoEntrada
;
result
:=
''
;
if
piTextoEntrada
<>
''
then
begin
ls_Texto
:=
RetirarTextoDepois
(
piTextoEntrada
,
piPalavraInicio
,
ls_TextoAntes
);
ls_Texto
:=
RetirarTextoAntes
(
ls_Texto
,
piPalavraFim
,
piTextoDepois
,
piSemPalavraFim
);
if
ls_Texto
<>
''
then
begin
result
:=
trim
(
ls_Texto
);
end
;
end
;
end
;
procedure
TExplorerV2
.
LoadAliasOQLEdit
(
piTexto
:
string
;
piAlias
:
TStrings
);
var
ls_texto
,
ls_TextoDepois
,
ls_textoAntes
,
ls_Entrada
,
ls_saida
:
string
;
lAcheiTexto
:
boolean
;
begin
ls_Entrada
:=
piTexto
;
ls_texto
:=
trim
(
RetirarTextoEntre
(
ls_Entrada
,
__PARENTESES_ABERTO
,
__PARENTESES_FECHADO
,
ls_TextoDepois
,
false
));
if
ls_texto
=
''
then
begin
LoadAliasBlocoFROMOQLEdit
(
ls_Entrada
,
piAlias
);
end
else
begin
ls_textoAntes
:=
RetirarTextoAntes
(
ls_Entrada
,
__PARENTESES_ABERTO
,
ls_saida
,
false
);
ls_textoAntes
:=
ls_textoAntes
+
ls_TextoDepois
;
ls_textoAntes
:=
trim
(
StringReplace
(
ls_textoAntes
,
'()'
,
''
,[
rfReplaceAll
]));
LoadAliasOQLEdit
(
ls_texto
,
piAlias
);
LoadAliasOQLEdit
(
ls_textoAntes
,
piAlias
);
end
;
end
;
function
TExplorerV2
.
ContemPalavra
(
piPalavra
,
piTextoEntrada
:
string
):
boolean
;
var
ls_texto
:
string
;
begin
result
:=
false
;
if
piTextoEntrada
<>
''
then
begin
ls_texto
:=
trim
(
UpperCase
(
piTextoEntrada
));
result
:=
Pos
(
trim
(
UpperCase
(
piPalavra
)),
ls_texto
)
>
0
;
end
;
end
;
function
TExplorerV2
.
ContemPalavrasEspeciais
(
piTextoEntrada
:
string
):
boolean
;
begin
result
:=
ContemPalavra
(
__SELECT
,
piTextoEntrada
)
or
ContemPalavra
(
__WHERE
,
piTextoEntrada
)
or
ContemPalavra
(
__VIRGULA
,
piTextoEntrada
)
or
ContemPalavra
(
__ORDER
,
piTextoEntrada
)
or
ContemPalavra
(
__GROUP
,
piTextoEntrada
)
or
ContemPalavra
(
__BY
,
piTextoEntrada
);
end
;
procedure
TExplorerV2
.
AddAliasListas
(
piLinhas
:
string
;
piAlias
:
TStrings
);
var
ls_texto
,
ls_espaco
:
string
;
li_Pos
:
integer
;
ls_Alias
:
string
;
ls_classe
:
string
;
lClassTicketCurrent
:
acClassTicket
;
begin
ls_Alias
:=
''
;
if
(
piLinhas
<>
''
)
and
(
not
ContemPalavrasEspeciais
(
piLinhas
))
then
begin
ls_espaco
:=
' '
;
ls_texto
:=
LowerCase
(
piLinhas
);
li_Pos
:=
Pos
(
ls_espaco
,
trim
(
ls_texto
));
if
li_Pos
>
0
then
begin
ls_classe
:=
trim
(
Copy
(
ls_texto
,
0
,
li_Pos
-
1
));
ls_Alias
:=
trim
(
Copy
(
ls_texto
,
li_Pos
+
1
,
Length
(
ls_texto
)));
if
ContemPalavra
(
__AS
,
ls_Alias
)
then
begin
ls_texto
:=
trim
(
Copy
(
ls_texto
,
li_Pos
+
1
,
Length
(
ls_texto
)));
li_Pos
:=
Pos
(
ls_espaco
,
trim
(
ls_texto
));
if
li_Pos
>
0
then
begin
ls_Alias
:=
trim
(
Copy
(
ls_texto
,
li_Pos
+
1
,
Length
(
ls_texto
)));
end
;
end
;
li_Pos
:=
Pos
(
ls_espaco
,
ls_texto
);
end
else
begin
ls_classe
:=
ls_texto
;
ls_alias
:=
''
;
end
;
if
(
ls_Alias
<>
''
)
and
(
ls_classe
<>
''
)
then
begin
lClassTicketCurrent
:=
self
.
GetClassTicketByNameRelation
(
ls_classe
);
if
Assigned
(
lClassTicketCurrent
)
then
begin
piAlias
.
AddObject
(
ls_Alias
,
lClassTicketCurrent
);
end
;
end
;
end
;
end
;
function
TExplorerV2
.
LoadAliasBlocoFROMOQLEdit
(
piTexto
:
string
;
piAlias
:
TStrings
):
string
;
var
ls_texto
,
ls_Entrada
,
ls_saida
:
string
;
lAcheiTexto
:
boolean
;
begin
ls_entrada
:=
trim
(
RetirarTextoAntes
(
piTexto
,
__WHERE
,
ls_saida
));
if
ls_entrada
=
''
then
begin
ls_entrada
:=
piTexto
;
end
;
ls_texto
:=
RetirarTextoEntre
(
ls_Entrada
,
__FROM
,
__VIRGULA
,
ls_Saida
);
if
ls_texto
<>
''
then
begin
AddAliasListas
(
ls_texto
,
piAlias
);
ls_Entrada
:=
ls_saida
;
lAcheiTexto
:=
true
;
end
;
while
lAcheiTexto
do
begin
lAcheiTexto
:=
false
;
ls_texto
:=
RetirarTextoEntre
(
ls_Entrada
,
__VIRGULA
,
__VIRGULA
,
ls_Saida
);
if
ls_texto
<>
''
then
begin
AddAliasListas
(
ls_texto
,
piAlias
);
ls_Entrada
:=
ls_saida
;
lAcheiTexto
:=
true
;
end
;
ls_texto
:=
RetirarTextoEntre
(
ls_Entrada
,
__JOIN
,
__ON
,
ls_Saida
);
if
ls_texto
<>
''
then
begin
AddAliasListas
(
ls_texto
,
piAlias
);
ls_Entrada
:=
ls_saida
;
lAcheiTexto
:=
true
;
end
;
end
;
ls_texto
:=
RetirarTextoDepois
(
ls_Entrada
,
__FROM
,
ls_saida
);
if
ls_texto
=
''
then
begin
ls_texto
:=
RetirarTextoDepois
(
ls_Entrada
,
__VIRGULA
,
ls_saida
);
if
ls_texto
=
''
then
begin
ls_texto
:=
ls_Entrada
;
end
;
end
;
if
ls_texto
<>
''
then
begin
if
ContemPalavra
(
__WHERE
,
ls_texto
)
then
begin
ls_texto
:=
RetirarTextoAntes
(
ls_texto
,
__WHERE
,
ls_saida
);
end
else
if
ContemPalavra
(
__GROUP
,
ls_texto
)
then
begin
ls_texto
:=
RetirarTextoAntes
(
ls_texto
,
__GROUP
,
ls_saida
);
end
else
if
ContemPalavra
(
__ORDER
,
ls_texto
)
then
begin
ls_texto
:=
RetirarTextoAntes
(
ls_texto
,
__ORDER
,
ls_saida
);
end
;
if
ContemPalavra
(
__EXISTS
,
ls_texto
)
then
begin
ls_texto
:=
RetirarTextoAntes
(
ls_texto
,
__EXISTS
,
ls_saida
);
end
;
if
ContemPalavra
(
__PARENTESES_ABERTO
,
ls_texto
)
then
begin
ls_texto
:=
trim
(
StringReplace
(
ls_texto
,
'('
,
''
,[
rfReplaceAll
]));
end
;
if
ContemPalavra
(
__PARENTESES_FECHADO
,
ls_texto
)
then
begin
ls_texto
:=
trim
(
StringReplace
(
ls_texto
,
')'
,
''
,[
rfReplaceAll
]));
end
;
AddAliasListas
(
ls_texto
,
piAlias
);
end
;
result
:=
ls_Entrada
;
end
;
function
TExplorerV2
.
GetClassTicketByNameRelation
(
piNameObjeto
:
string
):
acClassTicket
;
var
lClassTicketCurrent
,
lClassTicketAux
:
acClassTicket
;
lEnumerator
:
acEnumerator
;
li
,
li_Pos
:
integer
;
ls_ant_objeto
,
ls_aux
,
ls_Objeto
:
string
;
lRelationTicket
:
acRelationTicket
;
lbAchei
:
boolean
;
begin
li_Pos
:=
Pos
(
'.'
,
piNameObjeto
);
if
li_Pos
<=
0
then
begin
ls_aux
:=
trim
(
piNameObjeto
);
lClassTicketAux
:=
nil
;
ls_Objeto
:=
trim
(
Copy
(
ls_aux
,
0
,
li_Pos
-
1
));
lClassTicketCurrent
:=
self
.
MetaModel
.
GetClassTicketByName
(
ls_Objeto
);
while
li_Pos
>
0
do
begin
ls_aux
:=
trim
(
Copy
(
ls_aux
,
li_Pos
+
1
,
Length
(
ls_aux
)));
ls_ant_objeto
:=
ls_aux
;
li_Pos
:=
Pos
(
'.'
,
ls_aux
);
ls_Objeto
:=
trim
(
Copy
(
ls_aux
,
0
,
li_Pos
-
1
));
if
Assigned
(
lClassTicketCurrent
)
and
(
ls_Objeto
<>
''
)
then
begin
lbAchei
:=
false
;
for
li
:=
0
to
pred
(
lClassTicketCurrent
.
RelationTicketsIn
.
Count
)
do
begin
lRelationTicket
:=
acRelationTicket
(
lClassTicketCurrent
.
RelationTicketsIn
.
Objects
[
li
]);
if
SameText
(
lRelationTicket
.
DestinationPropertyName
,
ls_Objeto
)
then
begin
lClassTicketAux
:=
lRelationTicket
.
OriginClassTicket
;
ls_ant_objeto
:=
''
;
lbAchei
:=
true
;
break
;
end
;
end
;
if
not
lbAchei
then
begin
for
li
:=
0
to
pred
(
lClassTicketCurrent
.
RelationTicketsOut
.
Count
)
do
begin
lRelationTicket
:=
acRelationTicket
(
lClassTicketCurrent
.
RelationTicketsOut
.
Objects
[
li
]);
if
SameText
(
lRelationTicket
.
OriginPropertyName
,
ls_Objeto
)
then
begin
lClassTicketAux
:=
lRelationTicket
.
DestinationClassTicket
;
ls_ant_objeto
:=
''
;
break
;
end
;
end
;
end
;
lClassTicketCurrent
:=
lClassTicketAux
;
end
;
end
;
result
:=
lClassTicketCurrent
;
end
else
begin
result
:=
self
.
MetaModel
.
GetClassTicketByName
(
piNameObjeto
);
end
;
end
;
function
TExplorerV2
.
GetClassTicketByNameANDAlias
(
piNameObjeto
:
string
):
acClassTicket
;
var
li_index
:
integer
;
begin
result
:=
self
.
MetaModel
.
GetClassTicketByName
(
piNameObjeto
);
if
not
Assigned
(
result
)
then
begin
li_index
:=
fAlias
.
IndexOf
(
piNameObjeto
);
if
li_index
>=
0
then
begin
result
:=
acClassTicket
(
fAlias
.
Objects
[
li_index
]);
end
;
end
;
end
;
{
procedure TExplorerV2.PreparaSynCompletion;
var lAceitaAtributo : boolean;
...
...
@@ -994,9 +1310,13 @@ begin
fKeywords
.
Add
(
__SELECT
);
fKeywords
.
Add
(
__FROM
);
fKeywords
.
Add
(
__WHERE
);
fKeywords
.
Add
(
'ORDER'
);
fKeywords
.
Add
(
'BY'
);
fKeywords
.
Add
(
'JOIN'
);
fKeywords
.
Add
(
__ORDER
);
fKeywords
.
Add
(
__BY
);
fKeywords
.
Add
(
__JOIN
);
fKeywords
.
Add
(
__GROUP
);
fKeywords
.
Add
(
__EXISTS
);
fKeywords
.
Add
(
__IN
);
fAlias
:=
TStringList
.
Create
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment