mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
make server compilation happy
This commit is contained in:
@@ -70,6 +70,8 @@ gradle.action.link.project.text=Link gradle project
|
||||
gradle.action.link.project.description=Allows to link any gradle project to the current IDE project
|
||||
gradle.action.refresh.project.text=Refresh gradle project
|
||||
gradle.action.refresh.project.description=Allows to force linked gradle project refresh
|
||||
gradle.action.open.script.text=Open linked gradle project
|
||||
gradle.action.open.script.description=Allows to open project file of the linked gradle project at the editor
|
||||
|
||||
gradle.settings.color.text.sample.conflict.node.name=node-with-conflicting-setup
|
||||
gradle.settings.color.text.sample.node.sync.name=node-with-same-setup
|
||||
|
||||
@@ -67,9 +67,10 @@
|
||||
<actions>
|
||||
<action id="Gradle.LinkToProject" class="org.jetbrains.plugins.gradle.action.GradleLinkToProjectAction" icon="/general/add.png"/>
|
||||
<action id="Gradle.RefreshProject" class="org.jetbrains.plugins.gradle.action.GradleRefreshProjectAction" icon="/actions/sync.png"/>
|
||||
<action id="Gradle.OpenScript" class="org.jetbrains.plugins.gradle.action.GradleOpenScriptAction" icon="/icons/gradle.png"/>
|
||||
<group id="Gradle.ChangeActionsToolbar">
|
||||
<reference id="Gradle.LinkToProject"/>
|
||||
<reference id="Gradle.RefreshProject"/>
|
||||
<reference id="Gradle.OpenScript"/>
|
||||
</group>
|
||||
</actions>
|
||||
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package org.jetbrains.plugins.gradle.action;
|
||||
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.config.GradleSettings;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Common super class for gradle actions that require {@link GradleSettings#LINKED_PROJECT_FILE_PATH linked project}.
|
||||
* <p/>
|
||||
* Not thread-safe.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 1/31/12 5:36 PM
|
||||
*/
|
||||
public abstract class AbstractGradleLinkedProjectAction extends AnAction {
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final String path = getLinkedProjectPath(e.getDataContext());
|
||||
final boolean visible = path != null;
|
||||
e.getPresentation().setVisible(visible);
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
doUpdate(e.getPresentation(), path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
final String path = getLinkedProjectPath(e.getDataContext());
|
||||
if (path == null) {
|
||||
e.getPresentation().setVisible(false);
|
||||
return;
|
||||
}
|
||||
doActionPerformed(project, path);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static String getLinkedProjectPath(@Nullable DataContext context) {
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(context);
|
||||
if (project == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String path = GradleSettings.getInstance(project).LINKED_PROJECT_FILE_PATH;
|
||||
return (StringUtil.isEmpty(path) || !new File(path).isFile()) ? null : path;
|
||||
}
|
||||
|
||||
protected abstract void doUpdate(@NotNull Presentation presentation, @NotNull String linkedProjectPath);
|
||||
protected abstract void doActionPerformed(@NotNull Project project, @NotNull String linkedProjectPath);
|
||||
}
|
||||
@@ -11,8 +11,6 @@ import org.jetbrains.plugins.gradle.config.GradleSettings;
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle;
|
||||
import org.jetbrains.plugins.gradle.util.GradleUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Allows to link gradle project to the current IntelliJ IDEA project.
|
||||
* <p/>
|
||||
@@ -28,17 +26,6 @@ public class GradleLinkToProjectAction extends AnAction implements DumbAware {
|
||||
getTemplatePresentation().setDescription(GradleBundle.message("gradle.action.link.project.description"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project == null) {
|
||||
e.getPresentation().setVisible(false);
|
||||
return;
|
||||
}
|
||||
final String path = GradleSettings.getInstance(project).LINKED_PROJECT_FILE_PATH;
|
||||
e.getPresentation().setVisible(path == null || !new File(path).isFile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.jetbrains.plugins.gradle.action;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.config.GradleSettings;
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle;
|
||||
|
||||
/**
|
||||
* Forces the IntelliJ IDEA to open {@link GradleSettings#LINKED_PROJECT_FILE_PATH linked gradle project} at the editor
|
||||
* <p/>
|
||||
* Not thread-safe.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 1/31/12 5:16 PM
|
||||
*/
|
||||
public class GradleOpenScriptAction extends AbstractGradleLinkedProjectAction implements DumbAware {
|
||||
|
||||
public GradleOpenScriptAction() {
|
||||
getTemplatePresentation().setText(GradleBundle.message("gradle.action.open.script.text"));
|
||||
getTemplatePresentation().setDescription(GradleBundle.message("gradle.action.open.script.description"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doUpdate(@NotNull Presentation presentation, @NotNull String linkedProjectPath) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doActionPerformed(@NotNull Project project, @NotNull String linkedProjectPath) {
|
||||
// TODO den implement
|
||||
}
|
||||
}
|
||||
+7
-25
@@ -1,8 +1,6 @@
|
||||
package org.jetbrains.plugins.gradle.action;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -13,7 +11,6 @@ import org.jetbrains.plugins.gradle.config.GradleSettings;
|
||||
import org.jetbrains.plugins.gradle.task.GradleResolveProjectTask;
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
@@ -24,7 +21,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* @author Denis Zhdanov
|
||||
* @since 1/23/12 3:48 PM
|
||||
*/
|
||||
public class GradleRefreshProjectAction extends AnAction implements DumbAware {
|
||||
public class GradleRefreshProjectAction extends AbstractGradleLinkedProjectAction implements DumbAware {
|
||||
|
||||
private final AtomicBoolean myInProgress = new AtomicBoolean();
|
||||
|
||||
@@ -34,39 +31,24 @@ public class GradleRefreshProjectAction extends AnAction implements DumbAware {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project == null) {
|
||||
e.getPresentation().setVisible(false);
|
||||
return;
|
||||
}
|
||||
final String path = GradleSettings.getInstance(project).LINKED_PROJECT_FILE_PATH;
|
||||
final boolean visible = path != null && new File(path).isFile();
|
||||
e.getPresentation().setVisible(visible);
|
||||
e.getPresentation().setEnabled(!myInProgress.get());
|
||||
protected void doUpdate(@NotNull Presentation presentation, @NotNull String linkedProjectPath) {
|
||||
presentation.setEnabled(!myInProgress.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
|
||||
if (project == null) {
|
||||
e.getPresentation().setVisible(false);
|
||||
return;
|
||||
}
|
||||
// Assuming that the linked project is available if this action is called (update() is successful)
|
||||
final String projectPath = GradleSettings.getInstance(project).LINKED_PROJECT_FILE_PATH;
|
||||
protected void doActionPerformed(@NotNull final Project project, @NotNull final String linkedProjectPath) {
|
||||
myInProgress.set(true);
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(project, GradleBundle.message("gradle.sync.progress.text")) {
|
||||
@Override
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
try {
|
||||
GradleResolveProjectTask task = new GradleResolveProjectTask(project, projectPath, true);
|
||||
GradleResolveProjectTask task = new GradleResolveProjectTask(project, linkedProjectPath, true);
|
||||
task.execute(indicator);
|
||||
}
|
||||
finally {
|
||||
myInProgress.set(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public class GradleProjectStructureChangesModelTest {
|
||||
treeModel = container.getComponentInstance(GradleProjectStructureTreeModel) as GradleProjectStructureTreeModel
|
||||
changesModel.addListener({ old, current ->
|
||||
treeModel.update(current)
|
||||
treeModel.pruneObsoleteNodes(ContainerUtil.<GradleProjectStructureChange>subtract(old, current));
|
||||
treeModel.pruneObsoleteNodes(ContainerUtil.subtract(old, current));
|
||||
} as GradleProjectStructureChangeListener)
|
||||
changesModel.update(gradle.project)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user