Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .consulo/runConfigurations/consulo_run_desktop_awt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="consulo:run-desktop-awt" type="MavenRunConfiguration" factoryName="Maven" singleton="true">
<MavenSettings>
<option name="myGeneralSettings" />
<option name="myRunnerSettings">
<MavenRunnerSettings>
<option name="environmentProperties">
<map />
</option>
<option name="jreName" value="21" />
<option name="mavenProperties">
<map />
</option>
<option name="passParentEnv" value="true" />
<option name="runMavenInBackground" value="true" />
<option name="skipTests" value="false" />
<option name="vmOptions" value="--add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.swing=ALL-UNNAMED --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED --add-opens=java.desktop/sun.font=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED" />
</MavenRunnerSettings>
</option>
<option name="myRunnerParameters">
<MavenRunnerParameters>
<option name="profiles">
<set />
</option>
<option name="goals">
<list>
<option value="consulo:run-desktop-awt" />
<option value="-pl" />
<option value=":com.intellij.gwt" />
</list>
</option>
<option name="profilesMap">
<map />
</option>
<option name="resolveToWorkspace" value="true" />
<option name="workingDirPath" value="$PROJECT_DIR$" />
</MavenRunnerParameters>
</option>
</MavenSettings>
<ConfigurationWrapper RunnerId="Debug" />
<method>
<option name="Maven.BeforeRunTask" enabled="true" file="$PROJECT_DIR$/pom.xml" goal="package" />
</method>
</configuration>
</component>
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.consulo/
!/.consulo/codeStyleSettings.xml
!/.consulo/runConfigurations
target/
plugin/sandbox/
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

package consulo.gwt.jakartaee.run;

import com.intellij.gwt.module.GwtModulesManager;
import com.intellij.gwt.module.model.GwtModule;
import com.intellij.gwt.jakartaee.run.GwtRunConfiguration;
import com.intellij.gwt.jakartaee.run.GwtRunConfigurationEditor;
import com.intellij.gwt.jakartaee.run.GwtRunConfigurationType;
import com.intellij.gwt.module.GwtModulesManager;
import com.intellij.gwt.module.model.GwtModule;
import com.intellij.java.language.psi.PsiClass;
import com.intellij.java.language.psi.PsiJavaFile;
import consulo.annotation.component.ExtensionImpl;
Expand All @@ -33,111 +33,97 @@
import consulo.module.Module;
import consulo.util.lang.Comparing;
import consulo.util.lang.Pair;
import consulo.util.lang.ref.Ref;
import consulo.util.lang.ref.SimpleReference;
import consulo.virtualFileSystem.VirtualFile;
import consulo.xml.psi.xml.XmlFile;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

/**
* @author VISTALL
* @since 02-Jun-16
* @since 2016-06-02
*/
@ExtensionImpl
public class GwtRunConfigurationProducer extends RunConfigurationProducer<GwtRunConfiguration>
{
public GwtRunConfigurationProducer()
{
super(GwtRunConfigurationType.getInstance());
}
public class GwtRunConfigurationProducer extends RunConfigurationProducer<GwtRunConfiguration> {
public GwtRunConfigurationProducer() {
super(GwtRunConfigurationType.getInstance());
}

@Override
protected boolean setupConfigurationFromContext(GwtRunConfiguration runConfiguration, ConfigurationContext configurationContext, Ref<PsiElement> ref)
{
Pair<GwtModule, String> pair = findGwtModule(configurationContext.getLocation());
if(pair != null)
{
GwtModule gwtModule = pair.getFirst();
String path = GwtRunConfigurationEditor.getPath(gwtModule, pair.getSecond());
runConfiguration.setModule(gwtModule.getModule());
runConfiguration.setPage(path);
return true;
}
return false;
}
@Override
protected boolean setupConfigurationFromContext(
GwtRunConfiguration runConfiguration,
ConfigurationContext configurationContext,
SimpleReference<PsiElement> ref
) {
Pair<GwtModule, String> pair = findGwtModule(configurationContext.getLocation());
if (pair != null) {
GwtModule gwtModule = pair.getFirst();
String path = GwtRunConfigurationEditor.getPath(gwtModule, pair.getSecond());
runConfiguration.setModule(gwtModule.getModule());
runConfiguration.setPage(path);
return true;
}
return false;
}

@Override
public boolean isConfigurationFromContext(GwtRunConfiguration runConfiguration, ConfigurationContext configurationContext)
{
Pair<GwtModule, String> pair = findGwtModule(configurationContext.getLocation());
if(pair != null)
{
String pagePath1 = runConfiguration.getPage();
Module module1 = runConfiguration.getModule();
@Override
public boolean isConfigurationFromContext(GwtRunConfiguration runConfiguration, ConfigurationContext configurationContext) {
Pair<GwtModule, String> pair = findGwtModule(configurationContext.getLocation());
if (pair != null) {
String pagePath1 = runConfiguration.getPage();
Module module1 = runConfiguration.getModule();

GwtModule gwtModule = pair.getFirst();
String pagePath2 = GwtRunConfigurationEditor.getPath(gwtModule, pair.getSecond());
Module module2 = gwtModule.getModule();
return pagePath2.equals(pagePath1) && Comparing.equal(module1, module2);
}
return false;
}
GwtModule gwtModule = pair.getFirst();
String pagePath2 = GwtRunConfigurationEditor.getPath(gwtModule, pair.getSecond());
Module module2 = gwtModule.getModule();
return pagePath2.equals(pagePath1) && Comparing.equal(module1, module2);
}
return false;
}

@Nullable
private static Pair<GwtModule, String> findGwtModule(Location<?> location)
{
PsiFile psiFile = location.getPsiElement().getContainingFile();
if(psiFile == null)
{
return null;
}
@Nullable
private static Pair<GwtModule, String> findGwtModule(Location<?> location) {
PsiFile psiFile = location.getPsiElement().getContainingFile();
if (psiFile == null) {
return null;
}

VirtualFile file = psiFile.getVirtualFile();
if(file == null || !GwtModuleExtensionUtil.hasModuleExtension(location.getProject(), file))
{
return null;
}
VirtualFile file = psiFile.getVirtualFile();
if (file == null || !GwtModuleExtensionUtil.hasModuleExtension(location.getProject(), file)) {
return null;
}

GwtModulesManager gwtModulesManager = GwtModulesManager.getInstance(location.getProject());
GwtModule gwtModule = gwtModulesManager.getGwtModuleByXmlFile(psiFile);
if(gwtModule != null)
{
return getModuleWithFile(gwtModulesManager, gwtModule);
}
GwtModulesManager gwtModulesManager = GwtModulesManager.getInstance(location.getProject());
GwtModule gwtModule = gwtModulesManager.getGwtModuleByXmlFile(psiFile);
if (gwtModule != null) {
return getModuleWithFile(gwtModulesManager, gwtModule);
}

if(psiFile instanceof PsiJavaFile)
{
PsiClass[] classes = ((PsiJavaFile) psiFile).getClasses();
if(classes.length == 1)
{
PsiClass psiClass = classes[0];
GwtModule module = gwtModulesManager.findGwtModuleByEntryPoint(psiClass);
if(module != null)
{
return getModuleWithFile(gwtModulesManager, module);
}
}
}
return null;
}
if (psiFile instanceof PsiJavaFile javaFile) {
PsiClass[] classes = javaFile.getClasses();
if (classes.length == 1) {
PsiClass psiClass = classes[0];
GwtModule module = gwtModulesManager.findGwtModuleByEntryPoint(psiClass);
if (module != null) {
return getModuleWithFile(gwtModulesManager, module);
}
}
}
return null;
}

@Nullable
private static Pair<GwtModule, String> getModuleWithFile(@Nonnull GwtModulesManager gwtModulesManager, @Nonnull GwtModule gwtModule)
{
XmlFile psiHtmlFile = gwtModulesManager.findHtmlFileByModule(gwtModule);
if(psiHtmlFile != null)
{
VirtualFile htmlFile = psiHtmlFile.getVirtualFile();
if(htmlFile != null)
{
String path = gwtModulesManager.getPathFromPublicRoot(gwtModule, htmlFile);
if(path != null)
{
return Pair.create(gwtModule, path);
}
}
}
return null;
}
@Nullable
private static Pair<GwtModule, String> getModuleWithFile(@Nonnull GwtModulesManager gwtModulesManager, @Nonnull GwtModule gwtModule) {
XmlFile psiHtmlFile = gwtModulesManager.findHtmlFileByModule(gwtModule);
if (psiHtmlFile != null) {
VirtualFile htmlFile = psiHtmlFile.getVirtualFile();
if (htmlFile != null) {
String path = gwtModulesManager.getPathFromPublicRoot(gwtModule, htmlFile);
if (path != null) {
return Pair.create(gwtModule, path);
}
}
}
return null;
}
}
Loading