Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gaetan Chaboussie
Plugin-intellij-OFBiz
Commits
6f54d5cd
Commit
6f54d5cd
authored
Aug 20, 2021
by
Marie-Aline Pantais
Browse files
lien vers le target depuis un form. TODO optimiser la recherche du controller
parent
8cf2b3ed
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/apache/ofbiz/dom/OfbizConfigPatterns.java
View file @
6f54d5cd
...
...
@@ -63,6 +63,11 @@ public class OfbizConfigPatterns {
.
withParent
(
XmlPatterns
.
xmlTag
().
withName
(
"include-form"
))
.
withName
(
"name"
);
public
static
final
XmlNamedElementPattern
.
XmlAttributePattern
FORM_TARGET_PATTERN
=
XmlPatterns
.
xmlAttribute
()
.
withParent
(
XmlPatterns
.
xmlTag
().
withName
(
"form"
))
.
withName
(
"target"
);
public
static
final
XmlNamedElementPattern
.
XmlAttributePattern
PROPERTY_ATTR_PATTERN
=
XmlPatterns
.
xmlAttribute
().
withValue
(
XmlPatterns
.
string
().
startsWith
(
"${uiLabelMap."
));
...
...
src/main/java/org/apache/ofbiz/dom/references/ControllerReference.java
0 → 100644
View file @
6f54d5cd
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.ofbiz.dom.references
;
import
com.intellij.openapi.components.ServiceManager
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.PsiReferenceBase
;
import
com.intellij.psi.xml.XmlAttribute
;
import
com.intellij.psi.xml.XmlAttributeValue
;
import
org.apache.ofbiz.dom.controller.tags.RequestMapTag
;
import
org.apache.ofbiz.dom.screen.tags.FormWidgetTag
;
import
org.apache.ofbiz.services.OfbizProjectStructureService
;
import
org.jetbrains.annotations.Nullable
;
public
class
ControllerReference
extends
PsiReferenceBase
<
XmlAttributeValue
>
{
public
ControllerReference
(
XmlAttributeValue
element
,
boolean
soft
)
{
super
(
element
,
soft
);
}
@Nullable
public
PsiElement
resolve
()
{
OfbizProjectStructureService
structureService
=
ServiceManager
.
getService
(
this
.
getElement
().
getProject
(),
OfbizProjectStructureService
.
class
);
RequestMapTag
definition
=
structureService
.
getControllerUri
(
this
.
getValue
());
return
definition
!=
null
?
definition
.
getXmlElement
()
:
null
;
}
public
Object
[]
getVariants
()
{
return
null
;
}
private
String
getControllerComponent
(
PsiElement
element
)
{
XmlAttribute
parent
=
(
XmlAttribute
)
this
.
getElement
().
getParent
();
String
locationName
=
parent
.
getParent
().
getAttributeValue
(
"location"
);
if
(
locationName
==
null
)
{
locationName
=
this
.
getElement
().
getContainingFile
().
getName
();
}
return
locationName
.
substring
(
locationName
.
lastIndexOf
(
47
)
+
1
,
locationName
.
length
());
}
}
src/main/java/org/apache/ofbiz/dom/references/ControllerReferenceProvider.java
0 → 100644
View file @
6f54d5cd
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package
org.apache.ofbiz.dom.references
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.PsiReference
;
import
com.intellij.psi.PsiReferenceProvider
;
import
com.intellij.psi.xml.XmlAttributeValue
;
import
com.intellij.util.ProcessingContext
;
import
org.jetbrains.annotations.NotNull
;
public
class
ControllerReferenceProvider
extends
PsiReferenceProvider
{
public
ControllerReferenceProvider
()
{
}
public
PsiReference
[]
getReferencesByElement
(
@NotNull
PsiElement
element
,
@NotNull
ProcessingContext
context
)
{
return
element
instanceof
XmlAttributeValue
?
new
PsiReference
[]{
new
ControllerReference
((
XmlAttributeValue
)
element
,
true
)}
:
PsiReference
.
EMPTY_ARRAY
;
}
}
src/main/java/org/apache/ofbiz/dom/references/OfbizReferenceContributor.java
View file @
6f54d5cd
...
...
@@ -56,5 +56,8 @@ public class OfbizReferenceContributor extends PsiReferenceContributor {
registrar
.
registerReferenceProvider
(
XmlPatterns
.
xmlAttributeValue
()
.
withParent
(
OfbizConfigPatterns
.
FORM_NAME_ATTR_PATTERN
),
new
FormReferenceProvider
()
);
registrar
.
registerReferenceProvider
(
XmlPatterns
.
xmlAttributeValue
()
.
withParent
(
OfbizConfigPatterns
.
FORM_TARGET_PATTERN
),
new
ControllerReferenceProvider
()
);
}
}
src/main/java/org/apache/ofbiz/services/OfbizProjectStructureService.java
View file @
6f54d5cd
...
...
@@ -24,6 +24,7 @@ import org.apache.ofbiz.dom.build.tags.OfbizClasspathEntry;
import
org.apache.ofbiz.dom.build.tags.OfbizClasspathSpecTag
;
import
org.apache.ofbiz.dom.component.tags.ClasspathTag
;
import
org.apache.ofbiz.dom.component.tags.OfbizComponentTag
;
import
org.apache.ofbiz.dom.controller.tags.RequestMapTag
;
import
org.apache.ofbiz.dom.entity.tags.EntityTag
;
import
org.apache.ofbiz.dom.screen.tags.FormWidgetTag
;
import
org.apache.ofbiz.dom.screen.tags.ScreenTag
;
...
...
@@ -65,6 +66,8 @@ public interface OfbizProjectStructureService {
FormWidgetTag
getFormDefinition
(
String
fileName
,
String
name
);
RequestMapTag
getControllerUri
(
String
name
);
PropertyTag
getPropertyDefinition
(
String
name
);
PropertyTag
getPropertyDefinition
(
String
resource
,
String
name
);
...
...
src/main/java/org/apache/ofbiz/services/OfbizProjectStructureServiceImpl.java
View file @
6f54d5cd
...
...
@@ -41,6 +41,8 @@ import org.apache.ofbiz.dom.build.tags.OfbizClasspathEntry;
import
org.apache.ofbiz.dom.build.tags.OfbizClasspathSpecTag
;
import
org.apache.ofbiz.dom.component.tags.ClasspathTag
;
import
org.apache.ofbiz.dom.component.tags.OfbizComponentTag
;
import
org.apache.ofbiz.dom.controller.tags.OfbizControllerTag
;
import
org.apache.ofbiz.dom.controller.tags.RequestMapTag
;
import
org.apache.ofbiz.dom.entity.tags.EntityModelTag
;
import
org.apache.ofbiz.dom.entity.tags.EntityTag
;
import
org.apache.ofbiz.dom.screen.tags.FormWidgetTag
;
...
...
@@ -397,6 +399,19 @@ public class OfbizProjectStructureServiceImpl implements OfbizProjectStructureSe
return
null
;
}
public
RequestMapTag
getControllerUri
(
String
name
)
{
List
<
DomFileElement
<
OfbizControllerTag
>>
controllerFiles
=
this
.
getControllerFiles
();
for
(
DomFileElement
<
OfbizControllerTag
>
controllerFile:
controllerFiles
)
{
List
<
RequestMapTag
>
requestMaps
=
controllerFile
.
getRootElement
().
getRequestMap
();
for
(
RequestMapTag
request
:
requestMaps
)
{
if
(
request
.
getUri
().
getValue
().
equalsIgnoreCase
(
name
))
return
request
;
}
}
return
null
;
}
private
List
<
DomFileElement
<
OfbizControllerTag
>>
getControllerFiles
()
{
return
DomService
.
getInstance
().
getFileElements
(
OfbizControllerTag
.
class
,
this
.
project
,
GlobalSearchScope
.
allScope
(
this
.
project
));
}
public
void
addOrUpdateProjectLibraries
()
{
DumbService
dumbService
=
DumbService
.
getInstance
(
this
.
project
);
dumbService
.
runWhenSmart
(()
->
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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