mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
OS_TYPE="`uname -s`"
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Locate a JDK installation directory which will be used to ruin the IDE.
|
||||
# Locate a JDK installation directory which will be used to run the IDE.
|
||||
# Try (in order): @@product_uc@@_JDK, JDK_HOME, JAVA_HOME, "java" in PATH.
|
||||
# ---------------------------------------------------------------------
|
||||
if [ -n "$@@product_uc@@_JDK" -a -x "$@@product_uc@@_JDK/bin/java" ]; then
|
||||
|
||||
@@ -5,15 +5,21 @@
|
||||
::----------------------------------------------------------------------
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
:: Locate a JDK installation directory which will be used to ruin the IDE.
|
||||
:: Try (in order): @@product_uc@@_JDK, JDK_HOME, JAVA_HOME.
|
||||
:: Locate a JDK installation directory which will be used to run the IDE.
|
||||
:: Try (in order): @@product_uc@@_JDK, ..\jre, JDK_HOME, JAVA_HOME.
|
||||
:: ---------------------------------------------------------------------
|
||||
SET JDK=%@@product_uc@@_JDK%
|
||||
IF "%JDK%" == "" SET JDK=%JDK_HOME%
|
||||
IF "%JDK%" == "" SET JDK=%JAVA_HOME%
|
||||
IF EXIST "%@@product_uc@@_JDK%" SET JDK=%@@product_uc@@_JDK%
|
||||
IF NOT "%JDK%" == "" GOTO jdk
|
||||
IF EXIST "%~dp0\..\jre" SET JDK=%~dp0\..\jre
|
||||
IF NOT "%JDK%" == "" GOTO jdk
|
||||
IF EXIST "%JDK_HOME%" SET JDK=%JDK_HOME%
|
||||
IF NOT "%JDK%" == "" GOTO jdk
|
||||
IF EXIST "%JAVA_HOME%" SET JDK=%JAVA_HOME%
|
||||
IF "%JDK%" == "" GOTO error
|
||||
|
||||
:jdk
|
||||
SET JAVA_EXE=%JDK%\bin\java.exe
|
||||
IF NOT EXIST "%JAVA_EXE%" SET JAVA_EXE=%JDK%\jre\bin\java.exe
|
||||
IF NOT EXIST "%JAVA_EXE%" GOTO error
|
||||
|
||||
:: ---------------------------------------------------------------------
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -191,6 +191,14 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
sendNotification(paths, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getProjectPath(final Project project) {
|
||||
final String path = project.getPresentableUrl();
|
||||
if (path == null) return path;
|
||||
final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(path);
|
||||
return vFile != null ? vFile.getPath() : null;
|
||||
}
|
||||
|
||||
public void sendReloadRequest(final Project project) {
|
||||
if (!project.isDefault() && project.isOpen()) {
|
||||
myTaskExecutor.submit(new Runnable() {
|
||||
@@ -200,7 +208,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
if (!project.isDisposed()) {
|
||||
final CompileServerClient client = ensureServerRunningAndClientConnected(false);
|
||||
if (client != null) {
|
||||
client.sendProjectReloadRequest(Collections.singletonList(project.getLocation()));
|
||||
client.sendProjectReloadRequest(Collections.singletonList(getProjectPath(project)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,7 +259,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
}
|
||||
for (Project project : openProjects) {
|
||||
try {
|
||||
client.sendFSEvent(project.getLocation(), changed, deleted);
|
||||
client.sendFSEvent(getProjectPath(project), changed, deleted);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.info(e);
|
||||
@@ -317,7 +325,7 @@ public class CompileServerManager implements ApplicationComponent{
|
||||
final Collection<String> modules, final Collection<String> artifacts,
|
||||
final Collection<String> paths,
|
||||
final Map<String, String> userData, final JpsServerResponseHandler handler) {
|
||||
final String projectId = project.getLocation();
|
||||
final String projectId = getProjectPath(project);
|
||||
final Ref<RequestFuture> futureRef = new Ref<RequestFuture>(null);
|
||||
final RunnableFuture future = myTaskExecutor.submit(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -96,13 +96,17 @@ public class CompilerPaths {
|
||||
return new File(getCompilerSystemDirectory(), projectName + "." + project.getLocationHash());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getPresentableName(final Project project) {
|
||||
if (project.isDefault()) {
|
||||
return project.getName();
|
||||
}
|
||||
|
||||
String location = project.getLocation();
|
||||
if (location == null) return null;
|
||||
String location = project.getPresentableUrl();
|
||||
if (location == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String projectName = FileUtil.toSystemIndependentName(location);
|
||||
if (projectName.endsWith("/")) {
|
||||
projectName = projectName.substring(0, projectName.length() - 1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,8 +23,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@State(
|
||||
name = "RecentProjectsManager",
|
||||
roamingType = RoamingType.DISABLED,
|
||||
@@ -39,8 +37,7 @@ public class RecentProjectsManager extends RecentProjectsManagerBase {
|
||||
}
|
||||
|
||||
protected String getProjectPath(Project project) {
|
||||
final String location = project.getLocation();
|
||||
return location == null ? null : location.replace('/', File.separatorChar);
|
||||
return project.getPresentableUrl();
|
||||
}
|
||||
|
||||
protected void doOpenProject(final String projectPath, Project projectToClose, final boolean forceOpenInNewFrame) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,12 +20,14 @@ import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.impl.PlatformFrameTitleBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class IdeaFrameTitleBuilder extends PlatformFrameTitleBuilder {
|
||||
public String getFileTitle(final Project project, final VirtualFile file) {
|
||||
@Override
|
||||
public String getFileTitle(@NotNull final Project project, @NotNull final VirtualFile file) {
|
||||
return ProjectUtil.calcRelativeToProjectPath(file, project, !SystemInfo.isMac);
|
||||
}
|
||||
}
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
// "Change 'new TTT[0][]' to 'new TTT[]'" "true"
|
||||
public class TTT {
|
||||
void f() {
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
// "Change 'new X[42]' to 'new long[]'" "true"
|
||||
|
||||
class X {
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
// "Change 'new X[42]' to 'new long[]'" "true"
|
||||
|
||||
class X {
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
// "Override method 'foo'" "true"
|
||||
class Test {
|
||||
protected void foo(){}
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
// "Override method 'foo'" "false"
|
||||
class Test {
|
||||
private void f<caret>oo(){}
|
||||
|
||||
-16
@@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
// "Override method 'foo'" "true"
|
||||
class Test {
|
||||
protected void f<caret>oo(){}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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 com.intellij.psi.search;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -139,7 +154,8 @@ public class UpdateCacheTest extends PsiTestCase{
|
||||
checkUsages(objectClass, new String[]{});
|
||||
FileBasedIndex.getInstance().getContainingFiles(TodoIndex.NAME, new TodoIndexEntry("todo", true), GlobalSearchScope.allScope(getProject()));
|
||||
|
||||
final String projectLocation = myProject.getLocation();
|
||||
final String projectLocation = myProject.getPresentableUrl();
|
||||
assert projectLocation != null : myProject;
|
||||
myProject.save();
|
||||
final VirtualFile content = ModuleRootManager.getInstance(getModule()).getContentRoots()[0];
|
||||
ProjectUtil.closeAndDispose(myProject);
|
||||
|
||||
@@ -1605,7 +1605,7 @@ public class Mappings {
|
||||
}
|
||||
}
|
||||
|
||||
if (delta.isDifferentiated()) {
|
||||
if (delta.isDifferentiated() && false) {
|
||||
for (DependencyContext.S c : delta.getChangedClasses()) {
|
||||
myClassToSubclasses.remove(c);
|
||||
|
||||
@@ -1651,9 +1651,9 @@ public class Mappings {
|
||||
}
|
||||
}
|
||||
else {
|
||||
mySourceFileToClasses.putAll(delta.mySourceFileToClasses);
|
||||
mySourceFileToUsages.putAll(delta.mySourceFileToUsages);
|
||||
mySourceFileToAnnotationUsages.putAll(delta.mySourceFileToAnnotationUsages);
|
||||
mySourceFileToClasses.replaceAll(delta.mySourceFileToClasses);
|
||||
mySourceFileToUsages.replaceAll(delta.mySourceFileToUsages);
|
||||
mySourceFileToAnnotationUsages.replaceAll(delta.mySourceFileToAnnotationUsages);
|
||||
}
|
||||
|
||||
final Collection<DependencyContext.S> compiledSet = new HashSet<DependencyContext.S>(compiled.size());
|
||||
|
||||
@@ -30,7 +30,8 @@ interface MultiMaplet<K, V> {
|
||||
Collection<V> get(final K key);
|
||||
void put(final K key, final V value);
|
||||
void put(final K key, final Collection<V> value);
|
||||
void putAll(MultiMaplet<K, V> m);
|
||||
void putAll(MultiMaplet<K,V> m);
|
||||
void replaceAll(MultiMaplet<K, V> m);
|
||||
void remove(final K key);
|
||||
void removeFrom(final K key, final V value);
|
||||
void removeAll(final K key, final Collection<V> value);
|
||||
|
||||
@@ -141,6 +141,13 @@ class PersistentMultiMaplet<K, V> implements MultiMaplet<K, V> {
|
||||
|
||||
@Override
|
||||
public void putAll(MultiMaplet<K, V> m) {
|
||||
for (Map.Entry<K, Collection<V>> entry : m.entrySet()) {
|
||||
put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceAll(MultiMaplet<K, V> m) {
|
||||
for (Map.Entry<K, Collection<V>> entry : m.entrySet()) {
|
||||
final K key = entry.getKey();
|
||||
remove(key);
|
||||
|
||||
@@ -54,6 +54,13 @@ class TransientMultiMaplet<K, V> implements MultiMaplet<K, V> {
|
||||
return myMap.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(final MultiMaplet<K, V> m) {
|
||||
for (Map.Entry<K, Collection<V>> e : m.entrySet()) {
|
||||
put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(final K key, final Collection<V> value) {
|
||||
final Collection<V> x = myMap.get(key);
|
||||
@@ -102,7 +109,7 @@ class TransientMultiMaplet<K, V> implements MultiMaplet<K, V> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(MultiMaplet<K, V> m) {
|
||||
public void replaceAll(MultiMaplet<K, V> m) {
|
||||
for (Map.Entry<K, Collection<V>> e : m.entrySet()) {
|
||||
remove(e.getKey());
|
||||
put(e.getKey(), e.getValue());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,38 +22,101 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Project interface class.
|
||||
*/
|
||||
public interface Project extends ComponentManager, AreaInstance {
|
||||
@NonNls String DIRECTORY_STORE_FOLDER = ".idea";
|
||||
|
||||
@Nullable
|
||||
VirtualFile getProjectFile();
|
||||
|
||||
@Nullable
|
||||
VirtualFile getWorkspaceFile();
|
||||
|
||||
@NotNull
|
||||
String getProjectFilePath();
|
||||
|
||||
@Nullable
|
||||
VirtualFile getBaseDir();
|
||||
|
||||
/**
|
||||
* Returns a name ot the project. For a directory-based project it's an arbitrary string specified by user at project creation
|
||||
* or later in a project settings. For a file-based project it's a name of a project file without extension.
|
||||
*
|
||||
* @return project name
|
||||
*/
|
||||
@NotNull
|
||||
@NonNls
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* <p>Returns a project base directory - a parent directory of a <code>.ipr</code> file or <code>.idea</code> directory.<br/>
|
||||
* Returns <code>null</code> for default project.</p>
|
||||
*
|
||||
* <p>Please note that returned file is always de-referenced, so you have to use use {@linkplain #getBasePath()}
|
||||
* if it's desired to keep symlinks in original path.</p>
|
||||
*
|
||||
* @return project base directory, or null for default project
|
||||
*/
|
||||
@Nullable
|
||||
VirtualFile getBaseDir();
|
||||
|
||||
/**
|
||||
* Returns a system-dependent path to a project base directory (see {@linkplain #getBaseDir()}).<br/>
|
||||
* Returns <code>null</code> for default project.
|
||||
*
|
||||
* @return a path to a project base directory, or empty string for default project
|
||||
*/
|
||||
@Nullable
|
||||
@NonNls
|
||||
String getBasePath();
|
||||
|
||||
/**
|
||||
* <p>Returns project descriptor file:
|
||||
* <ul>
|
||||
* <li><code>path/to/project/project.ipr</code> - for file-based projects</li>
|
||||
* <li><code>path/to/project/.idea/misc.xml</code> - for directory-based projects</li>
|
||||
* </ul>
|
||||
* Returns <code>null</code> for default project.</p>
|
||||
*
|
||||
* <p>Please note that returned file is always de-referenced, so you have to use use {@linkplain #getProjectFilePath()}
|
||||
* if it's desired to keep symlinks in original path.</p>
|
||||
*
|
||||
* @return project descriptor file, or null for default project
|
||||
*/
|
||||
@Nullable
|
||||
VirtualFile getProjectFile();
|
||||
|
||||
/**
|
||||
* Returns a system-dependent path to project descriptor file (see {@linkplain #getProjectFile()}).<br/>
|
||||
* Returns empty string (<code>""</code>) for default project.
|
||||
*
|
||||
* @return project descriptor file, or empty string for default project
|
||||
*/
|
||||
@NotNull
|
||||
@NonNls
|
||||
String getProjectFilePath();
|
||||
|
||||
/**
|
||||
* Returns presentable project path:
|
||||
* {@linkplain #getProjectFilePath()} for file-based projects, {@linkplain #getBasePath()} for directory-based ones.<br/>
|
||||
* <b>Note:</b> the word "presentable" here implies file system presentation, not a UI one.
|
||||
*
|
||||
* @return presentable project path
|
||||
*/
|
||||
@Nullable
|
||||
@NonNls
|
||||
String getPresentableUrl();
|
||||
|
||||
/**
|
||||
* <p>Returns a workspace file:
|
||||
* <ul>
|
||||
* <li><code>path/to/project/project.iws</code> - for file-based projects</li>
|
||||
* <li><code>path/to/project/.idea/workspace.xml</code> - for directory-based ones</li>
|
||||
* </ul>
|
||||
* Returns <code>null</code> for default project.
|
||||
*
|
||||
* @return workspace file, or null for default project
|
||||
*/
|
||||
@Nullable
|
||||
VirtualFile getWorkspaceFile();
|
||||
|
||||
@NotNull
|
||||
@NonNls
|
||||
String getLocationHash();
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated please use {@linkplain #getPresentableUrl()} or {@linkplain #getBasePath()} (to remove in IDEA 13).
|
||||
*/
|
||||
@Nullable
|
||||
@NonNls
|
||||
String getLocation();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -117,6 +117,11 @@ public class MockProject extends MockComponentManager implements Project {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -429,15 +429,13 @@ public class AnalysisScope {
|
||||
return AnalysisScopeBundle.message("scope.module.list", modules, Integer.valueOf(myModules.size()));
|
||||
|
||||
case PROJECT:
|
||||
return AnalysisScopeBundle.message("scope.project", pathToName(myProject.getPresentableUrl()));
|
||||
return AnalysisScopeBundle.message("scope.project", myProject.getName());
|
||||
|
||||
case FILE:
|
||||
final VirtualFile virtualFile = ((PsiFileSystemItem)myElement).getVirtualFile();
|
||||
LOG.assertTrue(virtualFile != null);
|
||||
return AnalysisScopeBundle.message("scope.file", virtualFile.getPresentableUrl());
|
||||
return AnalysisScopeBundle.message("scope.file", getPresentableUrl((PsiFileSystemItem)myElement));
|
||||
|
||||
case DIRECTORY:
|
||||
return AnalysisScopeBundle.message("scope.directory", ((PsiFileSystemItem)myElement).getVirtualFile().getPresentableUrl());
|
||||
return AnalysisScopeBundle.message("scope.directory", getPresentableUrl((PsiFileSystemItem)myElement));
|
||||
|
||||
case VIRTUAL_FILES:
|
||||
return AnalysisScopeBundle.message("scope.virtual.files");
|
||||
@@ -446,6 +444,12 @@ public class AnalysisScope {
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String getPresentableUrl(final PsiFileSystemItem element) {
|
||||
final VirtualFile virtualFile = element.getVirtualFile();
|
||||
assert virtualFile != null : element;
|
||||
return virtualFile.getPresentableUrl();
|
||||
}
|
||||
|
||||
public String getShortenName(){
|
||||
switch (myType) {
|
||||
case CUSTOM:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,10 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @author max
|
||||
*/
|
||||
package com.intellij.openapi.project;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
@@ -40,24 +36,29 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ProjectUtil {
|
||||
@NonNls public static final String DIRECTORY_BASED_PROJECT_DIR = ".idea";
|
||||
|
||||
private ProjectUtil() {
|
||||
}
|
||||
private ProjectUtil() { }
|
||||
|
||||
@Nullable
|
||||
public static String getProjectLocationString(@NotNull final Project project) {
|
||||
String projectPath = project.getLocation();
|
||||
return FileUtil.getLocationRelativeToUserHome(projectPath);
|
||||
return FileUtil.getLocationRelativeToUserHome(project.getBasePath());
|
||||
}
|
||||
|
||||
public static String calcRelativeToProjectPath(final VirtualFile file, final Project project, final boolean includeFilePath) {
|
||||
@NotNull
|
||||
public static String calcRelativeToProjectPath(@NotNull final VirtualFile file,
|
||||
@Nullable final Project project,
|
||||
final boolean includeFilePath) {
|
||||
return calcRelativeToProjectPath(file, project, includeFilePath, false);
|
||||
}
|
||||
|
||||
public static String calcRelativeToProjectPath(final VirtualFile file,
|
||||
final Project project,
|
||||
@NotNull
|
||||
public static String calcRelativeToProjectPath(@NotNull final VirtualFile file,
|
||||
@Nullable final Project project,
|
||||
final boolean includeFilePath,
|
||||
final boolean keepModuleAlwaysOnTheLeft) {
|
||||
if (file instanceof VirtualFilePathWrapper) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -389,7 +389,7 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
private static Set<VirtualFile> getIgnoreRoots(@NotNull Project project) {
|
||||
Set<VirtualFile> result = new HashSet<VirtualFile>();
|
||||
|
||||
String location = project.getLocation();
|
||||
String location = project.getBasePath();
|
||||
if (location != null) {
|
||||
File projectDir = new File(location, Project.DIRECTORY_STORE_FOLDER);
|
||||
if (projectDir.isDirectory()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -295,7 +295,9 @@ public class ConversionServiceImpl extends ConversionService {
|
||||
@NotNull
|
||||
public ConversionResult convertModule(@NotNull final Project project, @NotNull final File moduleFile) {
|
||||
final IProjectStore stateStore = ((ProjectImpl)project).getStateStore();
|
||||
String projectPath = FileUtil.toSystemDependentName(stateStore.getLocation());
|
||||
final String url = stateStore.getPresentableUrl();
|
||||
assert url != null : project;
|
||||
final String projectPath = FileUtil.toSystemDependentName(url);
|
||||
|
||||
if (!isConversionNeeded(projectPath, moduleFile)) {
|
||||
return ConversionResultImpl.CONVERSION_NOT_NEEDED;
|
||||
@@ -322,7 +324,7 @@ public class ConversionServiceImpl extends ConversionService {
|
||||
}
|
||||
}
|
||||
context.saveFiles(Collections.singletonList(moduleFile));
|
||||
Messages.showInfoMessage(project, IdeBundle.message("message.your.module.was.succesfully.converted.br.old.version.was.saved.to.0", backupFile.getAbsolutePath()),
|
||||
Messages.showInfoMessage(project, IdeBundle.message("message.your.module.was.successfully.converted.br.old.version.was.saved.to.0", backupFile.getAbsolutePath()),
|
||||
IdeBundle.message("dialog.title.convert.module"));
|
||||
return new ConversionResultImpl(runners);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -75,7 +75,7 @@ public class ConsoleHistoryController {
|
||||
@NotNull final LanguageConsoleImpl console,
|
||||
@NotNull final ConsoleHistoryModel model) {
|
||||
myType = type;
|
||||
myId = StringUtil.isEmpty(persistenceId)? console.getProject().getLocation() : persistenceId;
|
||||
myId = StringUtil.isEmpty(persistenceId)? console.getProject().getPresentableUrl() : persistenceId;
|
||||
myConsole = console;
|
||||
myModel = model;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,6 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
@@ -61,7 +60,6 @@ import com.intellij.openapi.ui.SimpleToolWindowPanel;
|
||||
import com.intellij.openapi.ui.SplitterProportionsData;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -75,6 +73,7 @@ import com.intellij.openapi.wm.impl.content.ToolWindowContentUi;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.file.PsiDirectoryFactory;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.ui.AutoScrollFromSourceHandler;
|
||||
import com.intellij.ui.AutoScrollToSourceHandler;
|
||||
import com.intellij.ui.GuiUtils;
|
||||
@@ -157,7 +156,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
@Deprecated static final String PROJECT_VIEW_DATA_CONSTANT = DATA_KEY.getName();
|
||||
|
||||
private DefaultActionGroup myActionGroup;
|
||||
private final Runnable myTreeChangeListener;
|
||||
private String mySavedPaneId = ProjectViewPane.ID;
|
||||
private String mySavedPaneSubId;
|
||||
//private static final Icon COMPACT_EMPTY_MIDDLE_PACKAGES_ICON = IconLoader.getIcon("/objectBrowser/compactEmptyPackages.png");
|
||||
@@ -200,11 +198,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
|
||||
Disposer.register(myProject, this);
|
||||
myFileEditorManager = fileEditorManager;
|
||||
myTreeChangeListener = new Runnable() {
|
||||
public void run() {
|
||||
updateToolWindowTitle();
|
||||
}
|
||||
};
|
||||
|
||||
myConnection = project.getMessageBus().connect();
|
||||
myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
||||
@@ -474,15 +467,13 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
createToolbarActions();
|
||||
updateTitleActions();
|
||||
|
||||
newPane.setTreeChangeListener(myTreeChangeListener);
|
||||
myAutoScrollToSourceHandler.install(newPane.myTree);
|
||||
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(newPane.getComponentToFocus(), false);
|
||||
updateToolWindowTitle();
|
||||
|
||||
newPane.restoreExpandedPaths();
|
||||
if (selectedPsiElement != null) {
|
||||
final VirtualFile virtualFile = PsiUtilBase.getVirtualFile(selectedPsiElement);
|
||||
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(selectedPsiElement);
|
||||
if (virtualFile != null && ((ProjectViewSelectInTarget)newPane.createSelectInTarget()).isSubIdSelectable(newSubId, new SelectInContext() {
|
||||
@NotNull
|
||||
public Project getProject() {
|
||||
@@ -754,49 +745,6 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
return myCurrentViewId;
|
||||
}
|
||||
|
||||
private void updateToolWindowTitle() {
|
||||
if (true) return;
|
||||
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
|
||||
ToolWindow toolWindow = toolWindowManager == null ? null : toolWindowManager.getToolWindow(ToolWindowId.PROJECT_VIEW);
|
||||
if (toolWindow == null) return;
|
||||
String title = null;
|
||||
final AbstractProjectViewPane pane = getCurrentProjectViewPane();
|
||||
if (pane != null) {
|
||||
final DefaultMutableTreeNode selectedNode = pane.getSelectedNode();
|
||||
if (selectedNode != null) {
|
||||
final Object o = selectedNode.getUserObject();
|
||||
if (o instanceof ProjectViewNode) {
|
||||
title = ((ProjectViewNode)o).getTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (title == null) {
|
||||
if (true) return;
|
||||
|
||||
final PsiElement element = (PsiElement)myDataProvider.getData(LangDataKeys.PSI_ELEMENT.getName());
|
||||
if (element != null) {
|
||||
PsiFile file = element.getContainingFile();
|
||||
if (file != null) {
|
||||
title = FileUtil.getLocationRelativeToUserHome(file.getVirtualFile().getPresentableUrl());
|
||||
}
|
||||
else if (element instanceof PsiDirectory) {
|
||||
title = PsiDirectoryFactory.getInstance(myProject).getQualifiedName((PsiDirectory) element, true);
|
||||
}
|
||||
else {
|
||||
title = element.toString();
|
||||
}
|
||||
}
|
||||
else {
|
||||
title = "";
|
||||
if (myProject != null) {
|
||||
title = FileUtil.getLocationRelativeToUserHome(myProject.getPresentableUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toolWindow.setTitle(title);
|
||||
}
|
||||
|
||||
public PsiElement getParentOfCurrentSelection() {
|
||||
final AbstractProjectViewPane viewPane = getCurrentProjectViewPane();
|
||||
if (viewPane == null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,14 +18,12 @@ package com.intellij.ide.impl;
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.ide.GeneralSettings;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.highlighter.InternalFileType;
|
||||
import com.intellij.ide.highlighter.ProjectFileType;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.components.impl.stores.IProjectStore;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
@@ -53,13 +51,12 @@ import java.io.IOException;
|
||||
public class ProjectUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.impl.ProjectUtil");
|
||||
|
||||
private ProjectUtil() {
|
||||
}
|
||||
private ProjectUtil() { }
|
||||
|
||||
public static void updateLastProjectLocation(final String projectFilePath) {
|
||||
File lastProjectLocation = new File(projectFilePath);
|
||||
if (lastProjectLocation.isFile()) {
|
||||
lastProjectLocation = lastProjectLocation.getParentFile(); //for directory based project storages
|
||||
lastProjectLocation = lastProjectLocation.getParentFile(); // for directory-based project storage
|
||||
}
|
||||
if (lastProjectLocation == null) { // the immediate parent of the ipr file
|
||||
return;
|
||||
@@ -141,7 +138,7 @@ public class ProjectUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Project openProject(final String path, Project projectToClose, boolean forceOpenInNewFrame) {
|
||||
public static Project openProject(final String path, @Nullable Project projectToClose, boolean forceOpenInNewFrame) {
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
Messages.showErrorDialog(IdeBundle.message("error.project.file.does.not.exist", path), CommonBundle.getErrorTitle());
|
||||
@@ -164,7 +161,8 @@ public class ProjectUtil {
|
||||
if (!forceOpenInNewFrame && openProjects.length > 0) {
|
||||
int exitCode = confirmOpenNewProject(false);
|
||||
if (exitCode == GeneralSettings.OPEN_PROJECT_SAME_WINDOW) {
|
||||
if (!closeAndDispose(projectToClose != null ? projectToClose : openProjects[openProjects.length - 1])) return null;
|
||||
final Project toClose = projectToClose != null ? projectToClose : openProjects[openProjects.length - 1];
|
||||
if (!closeAndDispose(toClose)) return null;
|
||||
}
|
||||
else if (exitCode != GeneralSettings.OPEN_PROJECT_NEW_WINDOW) {
|
||||
return null;
|
||||
@@ -205,19 +203,23 @@ public class ProjectUtil {
|
||||
if (confirmOpenNewProject == GeneralSettings.OPEN_PROJECT_ASK) {
|
||||
if (isNewProject) {
|
||||
int exitCode = Messages.showYesNoDialog(IdeBundle.message("prompt.open.project.in.new.frame"),
|
||||
IdeBundle.message("title.new.project"),
|
||||
IdeBundle.message("button.existingframe"),
|
||||
IdeBundle.message("button.newframe"),
|
||||
Messages.getQuestionIcon(), new ProjectNewWindowDoNotAskOption());
|
||||
IdeBundle.message("title.new.project"),
|
||||
IdeBundle.message("button.existingframe"),
|
||||
IdeBundle.message("button.newframe"),
|
||||
Messages.getQuestionIcon(),
|
||||
new ProjectNewWindowDoNotAskOption());
|
||||
return exitCode == 0 ? GeneralSettings.OPEN_PROJECT_SAME_WINDOW : GeneralSettings.OPEN_PROJECT_NEW_WINDOW;
|
||||
}
|
||||
else {
|
||||
int exitCode = Messages.showYesNoCancelDialog(IdeBundle.message("prompt.open.project.in.new.frame"),
|
||||
IdeBundle.message("title.open.project"),
|
||||
IdeBundle.message("button.existingframe"), IdeBundle.message("button.newframe"),
|
||||
CommonBundle.getCancelButtonText(), Messages.getQuestionIcon(),
|
||||
new ProjectNewWindowDoNotAskOption());
|
||||
return exitCode == 0 ? GeneralSettings.OPEN_PROJECT_SAME_WINDOW : exitCode == 1 ? GeneralSettings.OPEN_PROJECT_NEW_WINDOW : Messages.CANCEL;
|
||||
IdeBundle.message("title.open.project"),
|
||||
IdeBundle.message("button.existingframe"),
|
||||
IdeBundle.message("button.newframe"),
|
||||
CommonBundle.getCancelButtonText(),
|
||||
Messages.getQuestionIcon(),
|
||||
new ProjectNewWindowDoNotAskOption());
|
||||
return exitCode == 0 ? GeneralSettings.OPEN_PROJECT_SAME_WINDOW :
|
||||
exitCode == 1 ? GeneralSettings.OPEN_PROJECT_NEW_WINDOW : Messages.CANCEL;
|
||||
}
|
||||
}
|
||||
return confirmOpenNewProject;
|
||||
@@ -265,6 +267,10 @@ public class ProjectUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@linkplain com.intellij.openapi.project.ProjectUtil#isProjectOrWorkspaceFile(com.intellij.openapi.vfs.VirtualFile)} (to remove in IDEA 13)
|
||||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public static boolean isProjectOrWorkspaceFile(final VirtualFile file) {
|
||||
return com.intellij.openapi.project.ProjectUtil.isProjectOrWorkspaceFile(file);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -86,6 +86,11 @@ public class DummyProject extends UserDataHolderBase implements Project {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
}
|
||||
|
||||
|
||||
+7
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.components.impl.stores;
|
||||
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
@@ -28,7 +27,7 @@ import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.options.StreamProvider;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileAdapter;
|
||||
@@ -78,6 +77,7 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
syncRefreshPathRecursively(PathManager.getConfigPath(true), "componentVersions");
|
||||
}
|
||||
finally {
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
myConfigDirectoryRefreshed = true;
|
||||
}
|
||||
}
|
||||
@@ -125,10 +125,6 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isOptionsFile(final String filePath) {
|
||||
return FileUtil.isAncestor(new File(PathManager.getOptionsPath()), new File(filePath), false);
|
||||
}
|
||||
|
||||
protected MySaveSession createSaveSession(final MyExternalizationSession externalizationSession) {
|
||||
return new FileSaveSession(externalizationSession);
|
||||
}
|
||||
@@ -162,7 +158,7 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
|
||||
protected void doSave() throws StateStorageException {
|
||||
if (!myBlockSavingTheContent) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() && myFile != null && myFile.getPath().startsWith("$")) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() && myFile != null && StringUtil.startsWithChar(myFile.getPath(), '$')) {
|
||||
throw new StateStorageException("It seems like some macros were not expanded for path: " + myFile.getPath());
|
||||
}
|
||||
|
||||
@@ -228,9 +224,8 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
return StorageUtil.getVirtualFile(myFile);
|
||||
}
|
||||
|
||||
|
||||
public IFile getFile() {
|
||||
return myFile;
|
||||
public File getFile() {
|
||||
return new File(myFile.getPath());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -254,6 +249,7 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Document processReadException(final Exception e) {
|
||||
myBlockSavingTheContent = isProjectOrModuleFile();
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
|
||||
+7
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,8 +31,6 @@ import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
public interface IProjectStore extends IComponentStore {
|
||||
|
||||
|
||||
boolean checkVersion();
|
||||
|
||||
void setProjectFilePath(final String filePath);
|
||||
@@ -40,6 +38,12 @@ public interface IProjectStore extends IComponentStore {
|
||||
@Nullable
|
||||
VirtualFile getProjectBaseDir();
|
||||
|
||||
@Nullable
|
||||
String getProjectBasePath();
|
||||
|
||||
/**
|
||||
* @deprecated please use {@linkplain #getPresentableUrl()} or {@linkplain #getProjectBasePath()} (to remove in IDEA 13).
|
||||
*/
|
||||
@Nullable
|
||||
String getLocation();
|
||||
|
||||
|
||||
+116
-110
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,10 +35,8 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.util.containers.OrderedSet;
|
||||
import com.intellij.util.io.fs.FileSystem;
|
||||
import com.intellij.util.io.fs.IFile;
|
||||
@@ -46,7 +44,6 @@ import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
@@ -57,30 +54,31 @@ import java.util.Set;
|
||||
|
||||
class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProjectStore {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.components.impl.stores.ProjectStoreImpl");
|
||||
|
||||
@NonNls private static final String OLD_PROJECT_SUFFIX = "_old.";
|
||||
@NonNls static final String OPTION_WORKSPACE = "workspace";
|
||||
|
||||
protected ProjectImpl myProject;
|
||||
|
||||
@NonNls static final String PROJECT_FILE_MACRO = "PROJECT_FILE";
|
||||
@NonNls static final String WS_FILE_MACRO = "WORKSPACE_FILE";
|
||||
@NonNls private static final String PROJECT_CONFIG_DIR = "PROJECT_CONFIG_DIR";
|
||||
|
||||
static final String PROJECT_FILE_STORAGE = "$" + PROJECT_FILE_MACRO + "$";
|
||||
static final String WS_FILE_STORAGE = "$" + WS_FILE_MACRO + "$";
|
||||
static final String DEFAULT_STATE_STORAGE = PROJECT_FILE_STORAGE;
|
||||
@NonNls static final String PROJECT_FILE_STORAGE = "$" + PROJECT_FILE_MACRO + "$";
|
||||
@NonNls static final String WS_FILE_STORAGE = "$" + WS_FILE_MACRO + "$";
|
||||
@NonNls static final String DEFAULT_STATE_STORAGE = PROJECT_FILE_STORAGE;
|
||||
|
||||
static final Storage DEFAULT_STORAGE_ANNOTATION = new MyStorage();
|
||||
private static int originalVersion = -1;
|
||||
|
||||
protected ProjectImpl myProject;
|
||||
private StorageScheme myScheme = StorageScheme.DEFAULT;
|
||||
private String myCachedLocation;
|
||||
private String myPresentableUrl;
|
||||
|
||||
ProjectStoreImpl(final ProjectImpl project) {
|
||||
super(project);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkVersion() {
|
||||
final ApplicationNamesInfo appNamesInfo = ApplicationNamesInfo.getInstance();
|
||||
if (originalVersion >= 0 && originalVersion < ProjectManagerImpl.CURRENT_FORMAT_VERSION) {
|
||||
@@ -130,10 +128,10 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
private void backup(final VirtualFile projectDir, final VirtualFile vile) throws IOException {
|
||||
final String oldName = vile.getNameWithoutExtension() + OLD_PROJECT_SUFFIX + vile.getExtension();
|
||||
VirtualFile oldFile = projectDir.findOrCreateChildData(this, oldName);
|
||||
VfsUtil.saveText(oldFile, VfsUtil.loadText(vile));
|
||||
final VirtualFile oldFile = projectDir.findOrCreateChildData(this, oldName);
|
||||
assert oldFile != null : projectDir + ", " + oldName;
|
||||
VfsUtil.saveText(oldFile, VfsUtilCore.loadText(vile));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -147,6 +145,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackingPathMacroSubstitutor[] getSubstitutors() {
|
||||
return new TrackingPathMacroSubstitutor[] {getStateStorageManager().getMacroSubstitutor()};
|
||||
}
|
||||
@@ -161,79 +160,77 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectFilePath(final String filePath) {
|
||||
if (filePath == null) {
|
||||
return;
|
||||
}
|
||||
final IFile iFile = FileSystem.FILE_SYSTEM.createFile(filePath);
|
||||
|
||||
final StateStorageManager stateStorageManager = getStateStorageManager();
|
||||
|
||||
if (!isIprPath(iFile)) {
|
||||
final IFile dir_store =
|
||||
iFile.isDirectory()
|
||||
? iFile.getChild(Project.DIRECTORY_STORE_FOLDER)
|
||||
: iFile.getParentFile().getChild(Project.DIRECTORY_STORE_FOLDER);
|
||||
|
||||
FileBasedStorage.syncRefreshPathRecursively(dir_store.getPath(), null);
|
||||
final File file = new File(filePath);
|
||||
if (!isIprPath(file)) {
|
||||
final File dirStore = file.isDirectory() ? new File(file, Project.DIRECTORY_STORE_FOLDER)
|
||||
: new File(file.getParentFile(), Project.DIRECTORY_STORE_FOLDER);
|
||||
FileBasedStorage.syncRefreshPathRecursively(dirStore.getPath(), null);
|
||||
|
||||
myScheme = StorageScheme.DIRECTORY_BASED;
|
||||
stateStorageManager.addMacro(PROJECT_FILE_MACRO, new File(dirStore, "misc.xml").getPath());
|
||||
|
||||
stateStorageManager.addMacro(PROJECT_FILE_MACRO, dir_store.getChild("misc.xml").getPath());
|
||||
final IFile ws = dir_store.getChild("workspace.xml");
|
||||
final File ws = new File(dirStore, "workspace.xml");
|
||||
stateStorageManager.addMacro(WS_FILE_MACRO, ws.getPath());
|
||||
|
||||
if (!ws.exists() && !iFile.isDirectory()) {
|
||||
if (!ws.exists() && !file.isDirectory()) {
|
||||
useOldWsContent(filePath, ws);
|
||||
}
|
||||
|
||||
stateStorageManager.addMacro(PROJECT_CONFIG_DIR, dir_store.getPath());
|
||||
} else {
|
||||
stateStorageManager.addMacro(PROJECT_CONFIG_DIR, dirStore.getPath());
|
||||
}
|
||||
else {
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
|
||||
|
||||
myScheme = StorageScheme.DEFAULT;
|
||||
stateStorageManager.addMacro(PROJECT_FILE_MACRO, filePath);
|
||||
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
|
||||
|
||||
int lastDot = filePath.lastIndexOf(".");
|
||||
final String filePathWithoutExt = lastDot > 0 ? filePath.substring(0, lastDot) : filePath;
|
||||
String workspacePath = filePathWithoutExt + WorkspaceFileType.DOT_DEFAULT_EXTENSION;
|
||||
|
||||
final String workspacePath = composeWsPath(filePath);
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByPath(workspacePath);
|
||||
stateStorageManager.addMacro(WS_FILE_MACRO, workspacePath);
|
||||
}
|
||||
|
||||
myCachedLocation = null;
|
||||
}
|
||||
|
||||
private static boolean isIprPath(final IFile file) {
|
||||
return file.getName().indexOf(".") > 0 && ProjectFileType.DEFAULT_EXTENSION.equals(FileUtil.getExtension(file.getName()));
|
||||
myPresentableUrl = null;
|
||||
}
|
||||
|
||||
private static void useOldWsContent(final String filePath, final IFile ws) {
|
||||
int lastDot = filePath.lastIndexOf(".");
|
||||
private static boolean isIprPath(final File file) {
|
||||
final String name = file.getName();
|
||||
return name.indexOf(".") > 0 && ProjectFileType.DEFAULT_EXTENSION.equals(FileUtil.getExtension(name));
|
||||
}
|
||||
|
||||
private static String composeWsPath(String filePath) {
|
||||
final int lastDot = filePath.lastIndexOf(".");
|
||||
final String filePathWithoutExt = lastDot > 0 ? filePath.substring(0, lastDot) : filePath;
|
||||
String workspacePath = filePathWithoutExt + WorkspaceFileType.DOT_DEFAULT_EXTENSION;
|
||||
IFile oldWs = FileSystem.FILE_SYSTEM.createFile(workspacePath);
|
||||
return filePathWithoutExt + WorkspaceFileType.DOT_DEFAULT_EXTENSION;
|
||||
}
|
||||
|
||||
private static void useOldWsContent(final String filePath, final File ws) {
|
||||
final File oldWs = new File(composeWsPath(filePath));
|
||||
if (oldWs.exists()) {
|
||||
try {
|
||||
final InputStream is = oldWs.openInputStream();
|
||||
final byte[] bytes;
|
||||
|
||||
final InputStream is = new FileInputStream(oldWs);
|
||||
try {
|
||||
bytes = FileUtil.loadBytes(is, (int)oldWs.length());
|
||||
final byte[] bytes = FileUtil.loadBytes(is, (int)oldWs.length());
|
||||
|
||||
final OutputStream os = new FileOutputStream(ws);
|
||||
try {
|
||||
os.write(bytes);
|
||||
}
|
||||
finally {
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
|
||||
final OutputStream os = ws.openOutputStream();
|
||||
try {
|
||||
os.write(bytes);
|
||||
}
|
||||
finally {
|
||||
os.close();
|
||||
}
|
||||
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
@@ -241,24 +238,37 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getProjectBaseDir() {
|
||||
final VirtualFile projectFile = getProjectFile();
|
||||
if (projectFile != null) return myScheme == StorageScheme.DEFAULT ? projectFile.getParent() : projectFile.getParent().getParent();
|
||||
if (myProject.isDefault()) return null;
|
||||
|
||||
final String path = getProjectBasePath();
|
||||
if (path == null) return null;
|
||||
|
||||
return LocalFileSystem.getInstance().findFileByPath(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectBasePath() {
|
||||
if (myProject.isDefault()) return null;
|
||||
|
||||
final String path = getProjectFilePath();
|
||||
if (!StringUtil.isEmptyOrSpaces(path)) {
|
||||
return myScheme == StorageScheme.DEFAULT ? new File(path).getParent() : new File(path).getParentFile().getParent();
|
||||
}
|
||||
|
||||
//we are not yet initialized completely ("open directory", etc)
|
||||
final StateStorage s = getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
if (!(s instanceof FileBasedStorage)) return null;
|
||||
final FileBasedStorage storage = (FileBasedStorage)s;
|
||||
|
||||
final IFile file = storage.getFile();
|
||||
final File file = storage.getFile();
|
||||
if (file == null) return null;
|
||||
|
||||
return LocalFileSystem.getInstance()
|
||||
.findFileByIoFile(myScheme == StorageScheme.DEFAULT ? file.getParentFile() : file.getParentFile().getParentFile());
|
||||
return myScheme == StorageScheme.DEFAULT ? file.getParent() : file.getParentFile().getParent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getLocation() {
|
||||
if (myCachedLocation == null) {
|
||||
if (myScheme == StorageScheme.DEFAULT) {
|
||||
@@ -274,79 +284,70 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getProjectName() {
|
||||
if (myScheme == StorageScheme.DIRECTORY_BASED) {
|
||||
final VirtualFile baseDir = getProjectBaseDir();
|
||||
assert baseDir != null : "project file: " + (getProjectFile() == null ? "[NULL]" : getProjectFile().getPath());
|
||||
assert baseDir != null : "project file: " + getProjectFile();
|
||||
|
||||
final VirtualFile ideaDir = baseDir.findChild(".idea");
|
||||
if (ideaDir != null && ideaDir.isValid()) {
|
||||
final VirtualFile nameFile = ideaDir.findChild(".name");
|
||||
if (nameFile != null && nameFile.isValid()) {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), "UTF-8"));
|
||||
final String name = in.readLine();
|
||||
if (name != null && name.length() > 0) return name.trim();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(nameFile.getInputStream(), "UTF-8"));
|
||||
try {
|
||||
final String name = in.readLine();
|
||||
if (name != null && name.length() > 0) {
|
||||
return name.trim();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return baseDir.getName().replace(":", "");
|
||||
}
|
||||
|
||||
String temp = getProjectFileName();
|
||||
FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(temp);
|
||||
if (fileType instanceof ProjectFileType) {
|
||||
temp = temp.substring(0, temp.length() - fileType.getDefaultExtension().length()-1);
|
||||
else {
|
||||
String temp = getProjectFileName();
|
||||
FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(temp);
|
||||
if (fileType instanceof ProjectFileType) {
|
||||
temp = temp.substring(0, temp.length() - fileType.getDefaultExtension().length() - 1);
|
||||
}
|
||||
final int i = temp.lastIndexOf(File.separatorChar);
|
||||
if (i >= 0) {
|
||||
temp = temp.substring(i + 1, temp.length() - i + 1);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
final int i = temp.lastIndexOf(File.separatorChar);
|
||||
if (i >= 0) {
|
||||
temp = temp.substring(i + 1, temp.length() - i + 1);
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public StorageScheme getStorageScheme() {
|
||||
return myScheme;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPresentableUrl() {
|
||||
if (myProject.isDefault()) return null;
|
||||
if (myScheme == StorageScheme.DIRECTORY_BASED) {
|
||||
final VirtualFile baseDir = getProjectBaseDir();
|
||||
return baseDir != null ? baseDir.getPresentableUrl() : null;
|
||||
}
|
||||
else {
|
||||
if (myProject.isDefault()) return null;
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
assert storage != null;
|
||||
return storage.getFilePath().replace('/', File.separatorChar);
|
||||
if (myPresentableUrl == null) {
|
||||
final String url = myScheme == StorageScheme.DIRECTORY_BASED ? getProjectBasePath() : getProjectFilePath();
|
||||
myPresentableUrl = url != null ? FileUtil.toSystemDependentName(url) : url;
|
||||
}
|
||||
return myPresentableUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadProject() throws IOException, JDOMException, InvalidDataException, StateStorageException {
|
||||
//load();
|
||||
myProject.init();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getProjectFile() {
|
||||
if (myProject.isDefault()) return null;
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
@@ -354,7 +355,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return storage.getVirtualFile();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getWorkspaceFile() {
|
||||
if (myProject.isDefault()) return null;
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(WS_FILE_STORAGE);
|
||||
@@ -362,6 +363,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return storage.getVirtualFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadProjectFromTemplate(final ProjectImpl defaultProject) {
|
||||
final StateStorage stateStorage = getStateStorageManager().getFileStateStorage(DEFAULT_STATE_STORAGE);
|
||||
|
||||
@@ -379,6 +381,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getProjectFileName() {
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
assert storage != null;
|
||||
@@ -386,20 +389,22 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getProjectFilePath() {
|
||||
if (myProject.isDefault()) return "";
|
||||
|
||||
final FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getFileStateStorage(PROJECT_FILE_STORAGE);
|
||||
assert storage != null;
|
||||
return storage.getFilePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected XmlElementStorage getMainStorage() {
|
||||
final XmlElementStorage storage = (XmlElementStorage)getStateStorageManager().getFileStateStorage(DEFAULT_STATE_STORAGE);
|
||||
assert storage != null;
|
||||
return storage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StateStorageManager createStateStorageManager() {
|
||||
return new ProjectStateStorageManager(PathMacroManager.getInstance(getComponentManager()).createTrackingSubstitutor(), myProject);
|
||||
}
|
||||
@@ -424,7 +429,6 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
|
||||
static class WsStorageData extends ProjectStorageData {
|
||||
|
||||
WsStorageData(final String rootElementName, final Project project) {
|
||||
super(rootElementName, project);
|
||||
}
|
||||
@@ -449,6 +453,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
protected void load(@NotNull final Element root) throws IOException {
|
||||
final String v = root.getAttributeValue(VERSION_OPTION);
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
originalVersion = v != null ? Integer.parseInt(v) : 0;
|
||||
|
||||
if (originalVersion != ProjectManagerImpl.CURRENT_FORMAT_VERSION) {
|
||||
@@ -466,12 +471,12 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SaveSessionImpl createSaveSession() throws StateStorageException {
|
||||
return new ProjectSaveSession();
|
||||
}
|
||||
|
||||
protected class ProjectSaveSession extends SaveSessionImpl {
|
||||
|
||||
ProjectSaveSession() throws StateStorageException {
|
||||
}
|
||||
|
||||
@@ -533,7 +538,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
List<VirtualFile> readonlyFiles = new ArrayList<VirtualFile>();
|
||||
|
||||
if (((ProjectImpl)myProject).isToSaveProjectName()) {
|
||||
if (myProject.isToSaveProjectName()) {
|
||||
final VirtualFile baseDir = getProjectBaseDir();
|
||||
if (baseDir != null && baseDir.isValid()) {
|
||||
filesToSave.add(FileSystem.FILE_SYSTEM
|
||||
@@ -627,14 +632,15 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected StateStorageChooser getDefaultStateStorageChooser() {
|
||||
return myStateStorageChooser;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected <T> Storage[] getComponentStorageSpecs(@NotNull final PersistentStateComponent<T> persistentStateComponent, final StateStorageOperation operation) throws
|
||||
StateStorageException {
|
||||
@Override
|
||||
protected <T> Storage[] getComponentStorageSpecs(@NotNull final PersistentStateComponent<T> persistentStateComponent,
|
||||
final StateStorageOperation operation) throws StateStorageException {
|
||||
Storage[] result = super.getComponentStorageSpecs(persistentStateComponent, operation);
|
||||
|
||||
if (operation == StateStorageOperation.READ) {
|
||||
@@ -647,6 +653,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ClassExplicitlyAnnotation")
|
||||
private static class MyStorage implements Storage {
|
||||
public String id() {
|
||||
return "___Default___";
|
||||
@@ -716,7 +723,6 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -71,7 +71,6 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
||||
public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.project.impl.ProjectImpl");
|
||||
private static final String PLUGIN_SETTINGS_ERROR = "Plugin Settings Error";
|
||||
@@ -103,10 +102,14 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
myOptimiseTestLoadSpeed = isOptimiseTestLoadSpeed;
|
||||
|
||||
myManager = manager;
|
||||
|
||||
myName = isDefault() ? TEMPLATE_PROJECT_NAME : projectName == null ? getStateStore().getProjectName() : projectName;
|
||||
if (!isDefault() && projectName != null && getStateStore().getStorageScheme().equals(StorageScheme.DIRECTORY_BASED)) myOldName = ""; // new project
|
||||
if (!isDefault() && projectName != null && getStateStore().getStorageScheme().equals(StorageScheme.DIRECTORY_BASED)) {
|
||||
myOldName = ""; // new project
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProjectName(@NotNull String projectName) {
|
||||
if (!projectName.equals(myName)) {
|
||||
myOldName = myName;
|
||||
@@ -175,6 +178,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public synchronized IProjectStore getStateStore() {
|
||||
if (myComponentStore == null) {
|
||||
myComponentStore = (IProjectStore)getPicoContainer().getComponentInstance(IComponentStore.class);
|
||||
@@ -196,10 +200,12 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
getStateStore().initComponent(component, service);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return ProjectManagerEx.getInstanceEx().isProjectOpened(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return isOpen() && !isDisposed() && StartupManagerEx.getInstanceEx(this).startupActivityPassed();
|
||||
}
|
||||
@@ -217,40 +223,49 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
return getStateStore().getProjectFilePath();
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getProjectFile() {
|
||||
return getStateStore().getProjectFile();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VirtualFile getBaseDir() {
|
||||
return getStateStore().getProjectBaseDir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasePath() {
|
||||
return getStateStore().getProjectBasePath();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NonNls
|
||||
@Override
|
||||
public String getPresentableUrl() {
|
||||
if (myName == null) return null; // not yet initialized
|
||||
return getStateStore().getPresentableUrl();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNls
|
||||
@Override
|
||||
public String getLocationHash() {
|
||||
String str = getPresentableUrl();
|
||||
if (str == null) str = getName();
|
||||
|
||||
final String prefix = getStateStore().getStorageScheme() == StorageScheme.DIRECTORY_BASED? "" : getName();
|
||||
final String prefix = getStateStore().getStorageScheme() == StorageScheme.DIRECTORY_BASED ? "" : getName();
|
||||
return prefix + Integer.toHexString(str.hashCode());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Nullable
|
||||
@NonNls
|
||||
@Override
|
||||
public String getLocation() {
|
||||
if (myName == null) return null; // was called before initialized
|
||||
return isDisposed() ? null : getStateStore().getLocation();
|
||||
@@ -261,15 +276,17 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
return getStateStore().getWorkspaceFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOptimiseTestLoadSpeed() {
|
||||
return myOptimiseTestLoadSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptimiseTestLoadSpeed(final boolean optimiseTestLoadSpeed) {
|
||||
myOptimiseTestLoadSpeed = optimiseTestLoadSpeed;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
long start = System.currentTimeMillis();
|
||||
// ProfilingUtil.startCPUProfiling();
|
||||
@@ -297,6 +314,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (ApplicationManagerEx.getApplicationEx().isDoNotSave()) return; //no need to save
|
||||
|
||||
@@ -327,11 +345,14 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
catch (PluginException e) {
|
||||
PluginManager.disablePlugin(e.getPluginId().getIdString());
|
||||
Notifications.Bus.notify(new Notification(PLUGIN_SETTINGS_ERROR, "Unable to save plugin settings!",
|
||||
"<p>The plugin <i>" + e.getPluginId() + "</i> failed to save settings and has been disabled. Please restart" +
|
||||
ApplicationNamesInfo.getInstance().getFullProductName() + "</p>" +
|
||||
(ApplicationManagerEx.getApplicationEx().isInternal() ? "<p>" + StringUtil.getThrowableText(e) + "</p>": ""),
|
||||
NotificationType.ERROR), NotificationDisplayType.BALLOON, this);
|
||||
Notification notification = new Notification(
|
||||
PLUGIN_SETTINGS_ERROR,
|
||||
"Unable to save plugin settings!",
|
||||
"<p>The plugin <i>" + e.getPluginId() + "</i> failed to save settings and has been disabled. Please restart" +
|
||||
ApplicationNamesInfo.getInstance().getFullProductName() + "</p>" +
|
||||
(ApplicationManagerEx.getApplicationEx().isInternal() ? "<p>" + StringUtil.getThrowableText(e) + "</p>" : ""),
|
||||
NotificationType.ERROR);
|
||||
Notifications.Bus.notify(notification, this);
|
||||
LOG.info("Unable to save plugin settings",e);
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -344,6 +365,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void dispose() {
|
||||
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
|
||||
assert application.isWriteAccessAllowed(); // dispose must be under write action
|
||||
@@ -382,7 +404,6 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void projectClosed() {
|
||||
List<ProjectComponent> components = new ArrayList<ProjectComponent>(Arrays.asList(getComponents(ProjectComponent.class)));
|
||||
@@ -397,6 +418,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] getExtensions(final ExtensionPointName<T> extensionPointName) {
|
||||
return Extensions.getArea(this).getExtensionPoint(extensionPointName).getExtensions();
|
||||
}
|
||||
@@ -423,10 +445,12 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
return Extensions.getArea(this).getPicoContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUnknownMacros(final boolean showDialog) {
|
||||
final IProjectStore stateStore = getStateStore();
|
||||
|
||||
@@ -472,7 +496,7 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (Messages.showYesNoDialog(this, "Component could not be reloaded. Reload project?", "Configuration changed",
|
||||
if (Messages.showYesNoDialog(this, "Component could not be reloaded. Reload project?", "Configuration Changed",
|
||||
Messages.getQuestionIcon()) == 0) {
|
||||
ProjectManagerEx.getInstanceEx().reloadProject(this);
|
||||
}
|
||||
@@ -483,13 +507,12 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Project"
|
||||
+ (isDisposed() ? " (Disposed" + (temporarilyDisposed ? " temporarily" : "") + ")"
|
||||
:isDefault() ? "" : " '" + getLocation()+"'")
|
||||
+ (isDefault() ? " (Default)" : "")
|
||||
+ " " + myName
|
||||
;
|
||||
public String toString() {
|
||||
return "Project" +
|
||||
(isDisposed() ? " (Disposed" + (temporarilyDisposed ? " temporarily" : "") + ")"
|
||||
: isDefault() ? "" : " '" + getPresentableUrl() + "'") +
|
||||
(isDefault() ? " (Default)" : "") +
|
||||
" " + myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -918,7 +918,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
ProjectImpl projectImpl = (ProjectImpl)project[0];
|
||||
if (projectImpl.isDisposed()) return;
|
||||
IProjectStore projectStore = projectImpl.getStateStore();
|
||||
final String location = projectImpl.getLocation();
|
||||
final String location = projectImpl.getPresentableUrl();
|
||||
|
||||
final List<IFile> original;
|
||||
try {
|
||||
|
||||
+6
-4
@@ -222,6 +222,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
String childPath = child.getPath();
|
||||
if (child.getFileSystem() == JarFileSystem.getInstance()) {
|
||||
VirtualFile local = JarFileSystem.getInstance().getVirtualFileForJar(child);
|
||||
assert local != null : child;
|
||||
childPath = local.getPath();
|
||||
}
|
||||
if (FileUtil.startsWith(childPath, root)) {
|
||||
@@ -238,13 +239,14 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
|
||||
if (!isUnder) {
|
||||
if (!allowed.isEmpty()) {
|
||||
assert false : "File accessed outside allowed roots: " + child + ";\n Allowed roots: " + new ArrayList(allowed);
|
||||
assert false : "File accessed outside allowed roots: " + child + ";\n Allowed roots: " + allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// null means we were unable to get roots, so do not check access
|
||||
@Nullable
|
||||
private static Set<String> allowedRoots() {
|
||||
if (insideGettingRoots) return null;
|
||||
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
|
||||
@@ -257,8 +259,7 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
String output = new File(outUrl.toURI()).getParentFile().getParentFile().getPath();
|
||||
allowed.add(FileUtil.toSystemIndependentName(output));
|
||||
}
|
||||
catch (URISyntaxException ignored) {
|
||||
}
|
||||
catch (URISyntaxException ignored) { }
|
||||
String javaHome = SystemProperties.getJavaHome();
|
||||
allowed.add(FileUtil.toSystemIndependentName(javaHome));
|
||||
String tempDirectorySpecific = new File(FileUtil.getTempDirectory()).getParent();
|
||||
@@ -277,7 +278,8 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
for (VirtualFile root : getAllRoots(project)) {
|
||||
allowed.add(StringUtil.trimEnd(root.getPath(), JarFileSystem.JAR_SEPARATOR));
|
||||
}
|
||||
String location = project.getLocation();
|
||||
String location = project.getBasePath();
|
||||
assert location != null : project;
|
||||
allowed.add(FileUtil.toSystemIndependentName(location));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.wm.impl;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -27,7 +28,7 @@ public abstract class FrameTitleBuilder {
|
||||
return ServiceManager.getService(FrameTitleBuilder.class);
|
||||
}
|
||||
|
||||
public abstract String getFileTitle(final Project project, final VirtualFile file);
|
||||
public abstract String getProjectTitle(@NotNull final Project project);
|
||||
|
||||
public abstract String getProjectTitle(final Project project);
|
||||
public abstract String getFileTitle(@NotNull final Project project, @NotNull final VirtualFile file);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -256,7 +256,7 @@ public class IdeFrameImpl extends JFrame implements IdeFrame, DataProvider {
|
||||
myUpdatingTitle = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final class Builder {
|
||||
public StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
+20
-13
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,38 +21,45 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFilePathWrapper;
|
||||
import com.intellij.platform.ProjectBaseDirectory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PlatformFrameTitleBuilder extends FrameTitleBuilder {
|
||||
public String getProjectTitle(final Project project) {
|
||||
final VirtualFile baseDir = project.getBaseDir();
|
||||
if (baseDir != null) {
|
||||
if (SystemInfo.isMac && baseDir.getName().equals(project.getName())) {
|
||||
return "[" + FileUtil.getLocationRelativeToUserHome(baseDir.getPresentableUrl()) + "]";
|
||||
}
|
||||
|
||||
return project.getName() + " - [" + FileUtil.getLocationRelativeToUserHome(baseDir.getPresentableUrl()) + "]";
|
||||
@Override
|
||||
public String getProjectTitle(@NotNull final Project project) {
|
||||
final String basePath = project.getBasePath();
|
||||
if (basePath == null) return project.getName();
|
||||
|
||||
if (basePath.equals(project.getName())) {
|
||||
return "[" + FileUtil.getLocationRelativeToUserHome(basePath) + "]";
|
||||
}
|
||||
else {
|
||||
return project.getName() + " - [" + FileUtil.getLocationRelativeToUserHome(basePath) + "]";
|
||||
}
|
||||
return project.getName();
|
||||
}
|
||||
|
||||
public String getFileTitle(final Project project, final VirtualFile file) {
|
||||
@Override
|
||||
public String getFileTitle(@NotNull final Project project, @NotNull final VirtualFile file) {
|
||||
if (SystemInfo.isMac) return file.getName();
|
||||
if (file instanceof VirtualFilePathWrapper) {
|
||||
return ((VirtualFilePathWrapper)file).getPresentablePath();
|
||||
}
|
||||
|
||||
String url = FileUtil.getLocationRelativeToUserHome(file.getPresentableUrl());
|
||||
if (url == null) url = file.getPresentableUrl();
|
||||
|
||||
VirtualFile baseDir = ProjectBaseDirectory.getInstance(project).getBaseDir();
|
||||
if (baseDir == null) baseDir = project.getBaseDir();
|
||||
|
||||
if (baseDir != null) {
|
||||
//noinspection ConstantConditions
|
||||
final String projectHomeUrl = FileUtil.getLocationRelativeToUserHome(baseDir.getPresentableUrl());
|
||||
if (url.startsWith(projectHomeUrl)) {
|
||||
if (projectHomeUrl != null && url.startsWith(projectHomeUrl)) {
|
||||
url = "..." + url.substring(projectHomeUrl.length());
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ProjectWindowAction extends ToggleAction implements DumbAware {
|
||||
public Frame findProjectFrame() {
|
||||
final Project[] projects = ProjectManager.getInstance().getOpenProjects();
|
||||
for (Project project : projects) {
|
||||
if (myProjectLocation.equals(project.getLocation())) {
|
||||
if (myProjectLocation.equals(project.getPresentableUrl())) {
|
||||
final WindowManager windowManager = WindowManager.getInstance();
|
||||
return windowManager.getFrame(project);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class ProjectWindowAction extends ToggleAction implements DumbAware {
|
||||
if (project == null) {
|
||||
return false;
|
||||
}
|
||||
return myProjectLocation.equals(project.getLocation());
|
||||
return myProjectLocation.equals(project.getPresentableUrl());
|
||||
}
|
||||
|
||||
public void setSelected(@Nullable AnActionEvent e, boolean selected) {
|
||||
|
||||
+5
-5
@@ -36,7 +36,7 @@ public class ProjectWindowActionGroup extends DefaultActionGroup {
|
||||
private ProjectWindowAction latest = null;
|
||||
|
||||
public void addProject(@NotNull Project project) {
|
||||
final String projectLocation = project.getLocation();
|
||||
final String projectLocation = project.getPresentableUrl();
|
||||
if (projectLocation == null) {
|
||||
return;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class ProjectWindowActionGroup extends DefaultActionGroup {
|
||||
}
|
||||
|
||||
public void removeProject(@NotNull Project project) {
|
||||
final ProjectWindowAction windowAction = findWindowAction(project.getLocation());
|
||||
final ProjectWindowAction windowAction = findWindowAction(project.getPresentableUrl());
|
||||
if (windowAction == null) {
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class ProjectWindowActionGroup extends DefaultActionGroup {
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
final ProjectWindowAction windowAction = findWindowAction(project.getLocation());
|
||||
final ProjectWindowAction windowAction = findWindowAction(project.getPresentableUrl());
|
||||
if (windowAction == null) {
|
||||
return;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class ProjectWindowActionGroup extends DefaultActionGroup {
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
final ProjectWindowAction windowAction = findWindowAction(project.getLocation());
|
||||
final ProjectWindowAction windowAction = findWindowAction(project.getPresentableUrl());
|
||||
if (windowAction == null) {
|
||||
return;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class ProjectWindowActionGroup extends DefaultActionGroup {
|
||||
final ProjectWindowAction windowAction = (ProjectWindowAction) child;
|
||||
if (projectName.equals(windowAction.getProjectName())) {
|
||||
if (result == null) {
|
||||
result = new ArrayList();
|
||||
result = new ArrayList<ProjectWindowAction>();
|
||||
}
|
||||
result.add(windowAction);
|
||||
}
|
||||
|
||||
@@ -192,24 +192,23 @@ public class MacFileChooserDialogImpl implements PathChooserDialog {
|
||||
}
|
||||
|
||||
static {
|
||||
final ID delegateClass = Foundation.allocateObjcClassPair(Foundation.getObjcClass("NSObject"), "NSOpenPanelDelegate_");
|
||||
if (!Foundation.addMethod(delegateClass, Foundation.createSelector("panel:shouldShowFilename:"), SHOULD_SHOW_FILENAME_CALLBACK, "B*")) {
|
||||
final ID delegate = Foundation.allocateObjcClassPair(Foundation.getObjcClass("NSObject"), "NSOpenPanelDelegate_");
|
||||
if (!Foundation.addMethod(delegate, Foundation.createSelector("panel:shouldShowFilename:"), SHOULD_SHOW_FILENAME_CALLBACK, "B*")) {
|
||||
throw new RuntimeException("Unable to add method to objective-c delegate class!");
|
||||
}
|
||||
if (!Foundation.addMethod(delegateClass, Foundation.createSelector("panel:isValidFilename:"), IS_VALID_FILENAME_CALLBACK, "B*")) {
|
||||
if (!Foundation.addMethod(delegate, Foundation.createSelector("panel:isValidFilename:"), IS_VALID_FILENAME_CALLBACK, "B*")) {
|
||||
throw new RuntimeException("Unable to add method to objective-c delegate class!");
|
||||
}
|
||||
if (!Foundation.addMethod(delegateClass, Foundation.createSelector("showOpenPanel:"), MAIN_THREAD_RUNNABLE, "v*")) {
|
||||
if (!Foundation.addMethod(delegate, Foundation.createSelector("showOpenPanel:"), MAIN_THREAD_RUNNABLE, "v*")) {
|
||||
throw new RuntimeException("Unable to add method to objective-c delegate class!");
|
||||
}
|
||||
if (!Foundation.addMethod(delegateClass, Foundation.createSelector("openPanelDidEnd:returnCode:contextInfo:"), OPEN_PANEL_DID_END,
|
||||
"v*i")) {
|
||||
if (!Foundation.addMethod(delegate, Foundation.createSelector("openPanelDidEnd:returnCode:contextInfo:"), OPEN_PANEL_DID_END, "v*i")) {
|
||||
throw new RuntimeException("Unable to add method to objective-c delegate class!");
|
||||
}
|
||||
if (!Foundation.addMethod(delegateClass, Foundation.createSelector("panel:shouldEnableURL:"), SHOULD_ENABLE_URL, "B@@")) {
|
||||
if (!Foundation.addMethod(delegate, Foundation.createSelector("panel:shouldEnableURL:"), SHOULD_ENABLE_URL, "B@@")) {
|
||||
throw new RuntimeException("Unable to add method to objective-c delegate class!");
|
||||
}
|
||||
Foundation.registerObjcClassPair(delegateClass);
|
||||
Foundation.registerObjcClassPair(delegate);
|
||||
}
|
||||
|
||||
public MacFileChooserDialogImpl(@NotNull FileChooserDescriptor chooserDescriptor, Project project) {
|
||||
|
||||
@@ -708,7 +708,7 @@ prompt.select.module.file.to.import=Select {0} module file (.iml) to import
|
||||
message.module.file.has.an.older.format.do.you.want.to.convert.it=Module file has an older format. Do you want to convert it?
|
||||
dialog.title.convert.module=Convert Module
|
||||
error.message.cannot.modify.file.0=Cannot modify file ''{0}''
|
||||
message.your.module.was.succesfully.converted.br.old.version.was.saved.to.0=<html><body>Your module was successfully converted. <br>\
|
||||
message.your.module.was.successfully.converted.br.old.version.was.saved.to.0=<html><body>Your module was successfully converted. <br>\
|
||||
Old version was saved to ''{0}''</body></html>
|
||||
label.select.module.type=Module type:
|
||||
error.please.specify.path.to.module.file=Please specify path to {0} module file (.iml)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,10 +29,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -64,10 +61,14 @@ public class MockProjectStore implements IProjectStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public VirtualFile getProjectBaseDir() {
|
||||
throw new UnsupportedOperationException("Method getProjectBaseDir is not yet implemented in " + getClass().getName());
|
||||
}//------ This methods should be got rid of
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectBasePath() {
|
||||
throw new UnsupportedOperationException("Method getProjectBasePath is not yet implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
@@ -117,18 +118,7 @@ public class MockProjectStore implements IProjectStore {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getProjectFilePath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setUsedMacros(@NotNull Collection<String> macros) {
|
||||
}
|
||||
|
||||
public Set<String> getMacroTrackingSet() {
|
||||
return new TreeSet<String>();
|
||||
}
|
||||
|
||||
public void initStore() {
|
||||
throw new UnsupportedOperationException("Method initStore is not yet implemented in " + getClass().getName());
|
||||
throw new UnsupportedOperationException("Method getProjectFilePath is not yet implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,20 +139,12 @@ public class MockProjectStore implements IProjectStore {
|
||||
throw new UnsupportedOperationException("Method load is not yet implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
public Collection<String> getUsedMacros() {
|
||||
throw new UnsupportedOperationException("Method getUsedMacros not implemented in " + getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SaveSession startSave() throws IOException {
|
||||
throw new UnsupportedOperationException("Method startSave not implemented in " + getClass());
|
||||
}
|
||||
|
||||
public List<VirtualFile> getAllStorageFilesToSave(final boolean includingSubStructures) {
|
||||
throw new UnsupportedOperationException("Method getAllStorageFilesToSave is not yet implemented in " + getClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getPresentableUrl() {
|
||||
|
||||
+3
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,6 @@ import com.intellij.diagnostic.LogMessageEx;
|
||||
import com.intellij.diagnostic.errordialog.Attachment;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.configurations.RuntimeConfiguration;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.TestFrameworkRunningModel;
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
@@ -28,7 +27,6 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.progress.PerformInBackgroundOption;
|
||||
@@ -142,12 +140,11 @@ public class ExportTestResultsAction extends DumbAwareAction {
|
||||
outputFolder = new File(config.getOutputFolder());
|
||||
}
|
||||
else {
|
||||
outputFolder = new File(new File(project.getLocation()), config.getOutputFolder());
|
||||
outputFolder = new File(new File(project.getBasePath()), config.getOutputFolder());
|
||||
}
|
||||
}
|
||||
else {
|
||||
outputFolder = new File(project.getLocation());
|
||||
|
||||
outputFolder = new File(project.getBasePath());
|
||||
}
|
||||
final File outputFile = new File(outputFolder, filename_);
|
||||
final String outputText;
|
||||
|
||||
@@ -1287,20 +1287,18 @@ public class FileUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getLocationRelativeToUserHome(final String path) {
|
||||
public static String getLocationRelativeToUserHome(@Nullable final String path) {
|
||||
if (path == null) return null;
|
||||
|
||||
String _path = path;
|
||||
|
||||
if (SystemInfo.isLinux || SystemInfo.isMac) {
|
||||
if (SystemInfo.isUnix) {
|
||||
final File projectDir = new File(path);
|
||||
final File userHomeDir = new File(SystemProperties.getUserHome());
|
||||
if (isAncestor(userHomeDir, projectDir, true)) {
|
||||
_path = "~/" + getRelativePath(userHomeDir, projectDir);
|
||||
return "~/" + getRelativePath(userHomeDir, projectDir);
|
||||
}
|
||||
}
|
||||
|
||||
return _path;
|
||||
return path;
|
||||
}
|
||||
|
||||
public static boolean isHashBangLine(CharSequence firstCharsIfText, String marker) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,9 @@ public final class TargetAction extends AnAction {
|
||||
templatePresentation.setDescription(description);
|
||||
myBuildName = buildFile.getPresentableName();
|
||||
myTargets = targets;
|
||||
myDebugString = "Target action: " + displayName+ "; Build: " + buildFile.getPresentableName() + "; Project: " + buildFile.getProject().getLocation();
|
||||
myDebugString = "Target action: " + displayName +
|
||||
"; Build: " + buildFile.getPresentableName() +
|
||||
"; Project: " + buildFile.getProject().getPresentableUrl();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,6 +46,7 @@ import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
|
||||
import com.intellij.openapi.wm.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -63,7 +64,7 @@ public final class ExecutionHandler {
|
||||
*/
|
||||
public static void runBuild(final AntBuildFileBase buildFile,
|
||||
String[] targets,
|
||||
final AntBuildMessageView buildMessageViewToReuse,
|
||||
@Nullable final AntBuildMessageView buildMessageViewToReuse,
|
||||
final DataContext dataContext,
|
||||
List<BuildFileProperty> additionalProperties, @NotNull final AntBuildListener antBuildListener) {
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
@@ -223,7 +224,7 @@ public final class ExecutionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static AntBuildMessageView prepareMessageView(AntBuildMessageView buildMessageViewToReuse,
|
||||
private static AntBuildMessageView prepareMessageView(@Nullable AntBuildMessageView buildMessageViewToReuse,
|
||||
AntBuildFileBase buildFile,
|
||||
String[] targets) throws RunCanceledException {
|
||||
AntBuildMessageView messageView;
|
||||
|
||||
@@ -146,7 +146,7 @@ public class GitContentRevision implements ContentRevision {
|
||||
*/
|
||||
public static ContentRevision createRevision(VirtualFile vcsRoot,
|
||||
String path,
|
||||
VcsRevisionNumber revisionNumber,
|
||||
@Nullable VcsRevisionNumber revisionNumber,
|
||||
Project project,
|
||||
boolean isDeleted, final boolean canBeDeleted, boolean unescapePath) throws VcsException {
|
||||
final FilePath file;
|
||||
|
||||
@@ -26,11 +26,13 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import git4idea.GitBranch;
|
||||
import git4idea.GitExecutionException;
|
||||
import git4idea.GitVcs;
|
||||
import git4idea.NotificationManager;
|
||||
import git4idea.changes.GitChangeUtils;
|
||||
import git4idea.commands.Git;
|
||||
import git4idea.commands.GitCommandResult;
|
||||
import git4idea.commands.GitCompoundResult;
|
||||
@@ -390,10 +392,23 @@ public final class GitBranchOperationsProcessor {
|
||||
GitCommitCompareInfo compareInfo = new GitCommitCompareInfo();
|
||||
for (GitRepository repository : repositories) {
|
||||
compareInfo.put(repository, loadCommitsToCompare(repository, branchName));
|
||||
compareInfo.put(repository, loadTotalDiff(repository, branchName));
|
||||
}
|
||||
return compareInfo;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
private static Collection<Change> loadTotalDiff(@NotNull GitRepository repository, @NotNull String branchName) {
|
||||
try {
|
||||
return GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), null, branchName, null);
|
||||
}
|
||||
catch (VcsException e) {
|
||||
// we treat it as critical and report an error
|
||||
throw new GitExecutionException("Couldn't get [git diff " + branchName + "] on repository [" + repository.getRoot() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Pair<List<GitCommit>, List<GitCommit>> loadCommitsToCompare(@NotNull GitRepository repository, @NotNull final String branchName) {
|
||||
final List<GitCommit> headToBranch;
|
||||
final List<GitCommit> branchToHead;
|
||||
@@ -418,20 +433,21 @@ public final class GitBranchOperationsProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
public void merge(@NotNull final String branchName) {
|
||||
public void merge(@NotNull final String branchName, final boolean localBranch) {
|
||||
new CommonBackgroundTask(myProject, "Merging " + branchName, myCallInAwtAfterExecution) {
|
||||
@Override public void execute(@NotNull ProgressIndicator indicator) {
|
||||
doMerge(branchName, indicator);
|
||||
doMerge(branchName, localBranch, indicator);
|
||||
}
|
||||
}.runInBackground();
|
||||
}
|
||||
|
||||
private void doMerge(@NotNull String branchName, @NotNull ProgressIndicator indicator) {
|
||||
private void doMerge(@NotNull String branchName, boolean localBranch, @NotNull ProgressIndicator indicator) {
|
||||
Map<GitRepository, String> revisions = new HashMap<GitRepository, String>();
|
||||
for (GitRepository repository : myRepositories) {
|
||||
revisions.put(repository, repository.getCurrentRevision());
|
||||
}
|
||||
new GitMergeOperation(myProject, myRepositories, branchName, getCurrentBranchOrRev(), mySelectedRepository, revisions, indicator).execute();
|
||||
new GitMergeOperation(myProject, myRepositories, branchName, localBranch, getCurrentBranchOrRev(),
|
||||
mySelectedRepository, revisions, indicator).execute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,6 +54,7 @@ class GitMergeOperation extends GitBranchOperation {
|
||||
|
||||
@NotNull private final ChangeListManager myChangeListManager;
|
||||
@NotNull private final String myBranchToMerge;
|
||||
private final boolean myLocalBranch;
|
||||
@NotNull private final String myCurrentBranch;
|
||||
@NotNull private final GitRepository myCurrentRepository;
|
||||
@NotNull private final Map<GitRepository, String> myCurrentRevisionsBeforeMerge;
|
||||
@@ -62,12 +63,13 @@ class GitMergeOperation extends GitBranchOperation {
|
||||
@NotNull private final Map<GitRepository, Boolean> myConflictedRepositories = new HashMap<GitRepository, Boolean>();
|
||||
private GitPreservingProcess myPreservingProcess;
|
||||
|
||||
protected GitMergeOperation(@NotNull Project project, @NotNull Collection<GitRepository> repositories,
|
||||
@NotNull String branchToMerge, @NotNull String currentBranch, @NotNull GitRepository currentRepository,
|
||||
@NotNull Map<GitRepository, String> currentRevisionsBeforeMerge,
|
||||
@NotNull ProgressIndicator indicator) {
|
||||
GitMergeOperation(@NotNull Project project, @NotNull Collection<GitRepository> repositories,
|
||||
@NotNull String branchToMerge, boolean localBranch, @NotNull String currentBranch,
|
||||
@NotNull GitRepository currentRepository, @NotNull Map<GitRepository, String> currentRevisionsBeforeMerge,
|
||||
@NotNull ProgressIndicator indicator) {
|
||||
super(project, repositories, currentBranch, indicator);
|
||||
myBranchToMerge = branchToMerge;
|
||||
myLocalBranch = localBranch;
|
||||
myCurrentBranch = currentBranch;
|
||||
myCurrentRepository = currentRepository;
|
||||
myCurrentRevisionsBeforeMerge = currentRevisionsBeforeMerge;
|
||||
@@ -157,20 +159,14 @@ class GitMergeOperation extends GitBranchOperation {
|
||||
|
||||
@Override
|
||||
protected void notifySuccess(@NotNull String message) {
|
||||
String description = message + "<br/><a href='delete'>Delete " + myBranchToMerge + "</a>";
|
||||
NotificationManager.getInstance(myProject).notify(GitVcs.NOTIFICATION_GROUP_ID, "", description, NotificationType.INFORMATION,
|
||||
new NotificationListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification,
|
||||
@NotNull HyperlinkEvent event) {
|
||||
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED &&
|
||||
event.getDescription().equalsIgnoreCase("delete")) {
|
||||
new GitBranchOperationsProcessor(myProject, new ArrayList<GitRepository>(
|
||||
getRepositories()), myCurrentRepository).
|
||||
deleteBranch(myBranchToMerge);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!myLocalBranch) {
|
||||
super.notifySuccess(message);
|
||||
}
|
||||
else {
|
||||
String description = message + "<br/><a href='delete'>Delete " + myBranchToMerge + "</a>";
|
||||
NotificationManager.getInstance(myProject).notify(GitVcs.NOTIFICATION_GROUP_ID, "", description, NotificationType.INFORMATION,
|
||||
new DeleteMergedLocalBranchNotificationListener());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean resolveConflicts() {
|
||||
@@ -369,4 +365,15 @@ class GitMergeOperation extends GitBranchOperation {
|
||||
getResolveLinkListener());
|
||||
}
|
||||
}
|
||||
|
||||
private class DeleteMergedLocalBranchNotificationListener implements NotificationListener {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification,
|
||||
@NotNull HyperlinkEvent event) {
|
||||
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && event.getDescription().equalsIgnoreCase("delete")) {
|
||||
new GitBranchOperationsProcessor(myProject, new ArrayList<GitRepository>(getRepositories()), myCurrentRepository).
|
||||
deleteBranch(myBranchToMerge);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package git4idea.changes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
@@ -113,7 +114,7 @@ public class GitChangeUtils {
|
||||
*/
|
||||
public static void parseChanges(Project project,
|
||||
VirtualFile vcsRoot,
|
||||
GitRevisionNumber thisRevision,
|
||||
@Nullable GitRevisionNumber thisRevision,
|
||||
GitRevisionNumber parentRevision,
|
||||
String s,
|
||||
Collection<Change> changes,
|
||||
@@ -161,7 +162,7 @@ public class GitChangeUtils {
|
||||
*/
|
||||
public static void parseChanges(Project project,
|
||||
VirtualFile vcsRoot,
|
||||
GitRevisionNumber thisRevision,
|
||||
@Nullable GitRevisionNumber thisRevision,
|
||||
GitRevisionNumber parentRevision,
|
||||
StringScanner s,
|
||||
Collection<Change> changes,
|
||||
@@ -444,4 +445,52 @@ public class GitChangeUtils {
|
||||
public static long longForSHAHash(String revisionNumber) {
|
||||
return Long.parseLong(revisionNumber.substring(0, 15), 16) << 4 + Integer.parseInt(revisionNumber.substring(15, 16), 16);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Collection<Change> getDiff(@NotNull Project project, @NotNull VirtualFile root,
|
||||
@Nullable String firstRevision, @NotNull String nextRevision,
|
||||
@Nullable Collection<FilePath> dirtyPaths) throws VcsException {
|
||||
Collection<Change> changes = new ArrayList<Change>();
|
||||
String range = firstRevision == null ? nextRevision : firstRevision + ".." + nextRevision;
|
||||
String output = getDiffOutput(project, root, range, dirtyPaths);
|
||||
GitRevisionNumber thisRevision = firstRevision == null ? null : loadRevision(project, root, firstRevision);
|
||||
parseChanges(project, root, thisRevision, loadRevision(project, root, nextRevision), output, changes, Collections.<String>emptySet());
|
||||
return changes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@code git diff} on the given range.
|
||||
* @param project
|
||||
* @param root
|
||||
* @param diffRange range or just revision (will be compared with current working tree).
|
||||
* @param dirtyPaths limit the command by paths if needed or pass null.
|
||||
* @return output of the 'git diff' command.
|
||||
* @throws VcsException
|
||||
*/
|
||||
@NotNull
|
||||
public static String getDiffOutput(@NotNull Project project, @NotNull VirtualFile root,
|
||||
@NotNull String diffRange, @Nullable Collection<FilePath> dirtyPaths) throws VcsException {
|
||||
GitSimpleHandler handler = getDiffHandler(project, root, diffRange, dirtyPaths);
|
||||
if (handler.isLargeCommandLine()) {
|
||||
// if there are too much files, just get all changes for the project
|
||||
handler = getDiffHandler(project, root, diffRange, null);
|
||||
}
|
||||
return handler.run();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static GitSimpleHandler getDiffHandler(@NotNull Project project, @NotNull VirtualFile root,
|
||||
@NotNull String diffRange, @Nullable Collection<FilePath> dirtyPaths) {
|
||||
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.DIFF);
|
||||
handler.addParameters("--name-status", "--diff-filter=ADCMRUXT", "-M", diffRange);
|
||||
handler.setNoSSH(true);
|
||||
handler.setSilent(true);
|
||||
handler.setStdoutSuppressed(true);
|
||||
handler.endOptions();
|
||||
if (dirtyPaths != null) {
|
||||
handler.addRelativePaths(dirtyPaths);
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -153,24 +153,8 @@ class GitOldChangesCollector extends GitChangesCollector {
|
||||
if (dirtyPaths.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.DIFF);
|
||||
handler.addParameters("--name-status", "--diff-filter=ADCMRUXT", "-M", "HEAD");
|
||||
handler.setNoSSH(true);
|
||||
handler.setSilent(true);
|
||||
handler.setStdoutSuppressed(true);
|
||||
handler.endOptions();
|
||||
handler.addRelativePaths(dirtyPaths);
|
||||
if (handler.isLargeCommandLine()) {
|
||||
// if there are too much files, just get all changes for the project
|
||||
handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.DIFF);
|
||||
handler.addParameters("--name-status", "--diff-filter=ADCMRUXT", "-M", "HEAD");
|
||||
handler.setNoSSH(true);
|
||||
handler.setSilent(true);
|
||||
handler.setStdoutSuppressed(true);
|
||||
handler.endOptions();
|
||||
}
|
||||
try {
|
||||
String output = handler.run();
|
||||
String output = GitChangeUtils.getDiffOutput(myProject, myVcsRoot, "HEAD", dirtyPaths);
|
||||
GitChangeUtils.parseChanges(myProject, myVcsRoot, null, GitChangeUtils.loadRevision(myProject, myVcsRoot, "HEAD"), output, myChanges,
|
||||
myUnmergedNames);
|
||||
}
|
||||
@@ -178,7 +162,7 @@ class GitOldChangesCollector extends GitChangesCollector {
|
||||
if (!GitChangeUtils.isHeadMissing(ex)) {
|
||||
throw ex;
|
||||
}
|
||||
handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
|
||||
GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
|
||||
handler.addParameters("--cached");
|
||||
handler.setNoSSH(true);
|
||||
handler.setSilent(true);
|
||||
|
||||
@@ -197,7 +197,7 @@ class GitBranchPopupActions {
|
||||
new CheckoutAction(myProject, myRepositories, myBranchName, mySelectedRepository),
|
||||
new CheckoutAsNewBranch(myProject, myRepositories, myBranchName, mySelectedRepository),
|
||||
new CompareAction(myProject, myRepositories, myBranchName, mySelectedRepository),
|
||||
new MergeAction(myProject, myRepositories, myBranchName, mySelectedRepository),
|
||||
new MergeAction(myProject, myRepositories, myBranchName, mySelectedRepository, true),
|
||||
new DeleteAction(myProject, myRepositories, myBranchName, mySelectedRepository)
|
||||
};
|
||||
}
|
||||
@@ -298,7 +298,7 @@ class GitBranchPopupActions {
|
||||
return new AnAction[] {
|
||||
new CheckoutRemoteBranchAction(myProject, myRepositories, myBranchName, mySelectedRepository),
|
||||
new CompareAction(myProject, myRepositories, myBranchName, mySelectedRepository),
|
||||
new MergeAction(myProject, myRepositories, myBranchName, mySelectedRepository),
|
||||
new MergeAction(myProject, myRepositories, myBranchName, mySelectedRepository, false),
|
||||
new RemoteDeleteAction(myProject, myRepositories, myBranchName, mySelectedRepository)
|
||||
};
|
||||
}
|
||||
@@ -387,19 +387,21 @@ class GitBranchPopupActions {
|
||||
private final List<GitRepository> myRepositories;
|
||||
private final String myBranchName;
|
||||
private final GitRepository mySelectedRepository;
|
||||
private final boolean myLocalBranch;
|
||||
|
||||
public MergeAction(@NotNull Project project, @NotNull List<GitRepository> repositories, @NotNull String branchName,
|
||||
@NotNull GitRepository selectedRepository) {
|
||||
@NotNull GitRepository selectedRepository, boolean localBranch) {
|
||||
super("Merge");
|
||||
myProject = project;
|
||||
myRepositories = repositories;
|
||||
myBranchName = branchName;
|
||||
mySelectedRepository = selectedRepository;
|
||||
myLocalBranch = localBranch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
new GitBranchOperationsProcessor(myProject, myRepositories, mySelectedRepository).merge(myBranchName);
|
||||
new GitBranchOperationsProcessor(myProject, myRepositories, mySelectedRepository).merge(myBranchName, myLocalBranch);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,28 +17,16 @@ package git4idea.ui.branch;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import git4idea.history.browser.GitCommit;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.components.JBTabbedPane;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryManager;
|
||||
import git4idea.ui.GitCommitListPanel;
|
||||
import git4idea.ui.GitRepositoryComboboxListCellRenderer;
|
||||
import git4idea.util.GitCommitCompareInfo;
|
||||
import git4idea.util.GitUIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* Dialog for comparing two Git branches.
|
||||
@@ -52,11 +40,8 @@ public class GitCompareBranchesDialog extends DialogWrapper {
|
||||
private final GitCommitCompareInfo myCompareInfo;
|
||||
private final GitRepository myInitialRepo;
|
||||
|
||||
private GitCommitListPanel myHeadToBranchListPanel;
|
||||
private GitCommitListPanel myBranchToHeadListPanel;
|
||||
|
||||
public GitCompareBranchesDialog(@NotNull Project project, @NotNull String branchName, @NotNull String currentBranchName, @NotNull GitCommitCompareInfo compareInfo,
|
||||
@NotNull GitRepository initialRepo) {
|
||||
public GitCompareBranchesDialog(@NotNull Project project, @NotNull String branchName, @NotNull String currentBranchName,
|
||||
@NotNull GitCommitCompareInfo compareInfo, @NotNull GitRepository initialRepo) {
|
||||
super(project, false);
|
||||
myCurrentBranchName = currentBranchName;
|
||||
myCompareInfo = compareInfo;
|
||||
@@ -77,93 +62,17 @@ public class GitCompareBranchesDialog extends DialogWrapper {
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
final ChangesBrowser changesBrowser = new ChangesBrowser(myProject, null, Collections.<Change>emptyList(), null, false, true, null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
|
||||
JPanel logPanel = new GitCompareBranchesLogPanel(myProject, myBranchName, myCurrentBranchName, myCompareInfo, myInitialRepo);
|
||||
JPanel diffPanel = new GitCompareBranchesDiffPanel(myProject, myBranchName, myCurrentBranchName, myCompareInfo);
|
||||
|
||||
myHeadToBranchListPanel = new GitCommitListPanel(myProject, getHeadToBranchCommits(myInitialRepo));
|
||||
myBranchToHeadListPanel = new GitCommitListPanel(myProject, getBranchToHeadCommits(myInitialRepo));
|
||||
|
||||
addSelectionListener(myHeadToBranchListPanel, myBranchToHeadListPanel, changesBrowser);
|
||||
addSelectionListener(myBranchToHeadListPanel, myHeadToBranchListPanel, changesBrowser);
|
||||
|
||||
JPanel htb = layoutCommitListPanel(myCurrentBranchName, true);
|
||||
JPanel bth = layoutCommitListPanel(myCurrentBranchName, false);
|
||||
|
||||
Splitter lists = new Splitter(true, 0.5f);
|
||||
lists.setFirstComponent(htb);
|
||||
lists.setSecondComponent(bth);
|
||||
|
||||
Splitter rootPanel = new Splitter(false, 0.7f);
|
||||
rootPanel.setSecondComponent(changesBrowser);
|
||||
rootPanel.setFirstComponent(lists);
|
||||
return rootPanel;
|
||||
JBTabbedPane tabbedPane = new JBTabbedPane();
|
||||
tabbedPane.addTab("Log", IconLoader.getIcon("/icons/branch.png"), logPanel);
|
||||
tabbedPane.setMnemonicAt(0, KeyEvent.VK_L);
|
||||
tabbedPane.addTab("Diff", IconLoader.getIcon("/actions/diff.png"), diffPanel);
|
||||
tabbedPane.setMnemonicAt(1, KeyEvent.VK_D);
|
||||
return tabbedPane;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createNorthPanel() {
|
||||
final JComboBox repoSelector = new JComboBox(ArrayUtil.toObjectArray(myCompareInfo.getRepositories(), GitRepository.class));
|
||||
repoSelector.setRenderer(new GitRepositoryComboboxListCellRenderer(repoSelector));
|
||||
repoSelector.setSelectedItem(myInitialRepo);
|
||||
|
||||
repoSelector.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
GitRepository selectedRepo = (GitRepository)repoSelector.getSelectedItem();
|
||||
myHeadToBranchListPanel.setCommits(getHeadToBranchCommits(selectedRepo));
|
||||
myBranchToHeadListPanel.setCommits(getBranchToHeadCommits(selectedRepo));
|
||||
}
|
||||
});
|
||||
|
||||
JPanel repoSelectorPanel = new JPanel(new BorderLayout());
|
||||
JBLabel label = new JBLabel("Repository: ");
|
||||
label.setLabelFor(repoSelectorPanel);
|
||||
repoSelectorPanel.add(label);
|
||||
repoSelectorPanel.add(repoSelector);
|
||||
|
||||
if (myCompareInfo.getRepositories().size() < 2) {
|
||||
repoSelectorPanel.setVisible(false);
|
||||
}
|
||||
return repoSelectorPanel;
|
||||
}
|
||||
|
||||
private ArrayList<GitCommit> getBranchToHeadCommits(GitRepository selectedRepo) {
|
||||
return new ArrayList<GitCommit>(myCompareInfo.getBranchToHeadCommits(selectedRepo));
|
||||
}
|
||||
|
||||
private ArrayList<GitCommit> getHeadToBranchCommits(GitRepository selectedRepo) {
|
||||
return new ArrayList<GitCommit>(myCompareInfo.getHeadToBranchCommits(selectedRepo));
|
||||
}
|
||||
|
||||
private static void addSelectionListener(@NotNull GitCommitListPanel sourcePanel,
|
||||
@NotNull final GitCommitListPanel otherPanel,
|
||||
@NotNull final ChangesBrowser changesBrowser) {
|
||||
sourcePanel.addListSelectionListener(new Consumer<GitCommit>() {
|
||||
@Override
|
||||
public void consume(GitCommit commit) {
|
||||
changesBrowser.setChangesToDisplay(commit.getChanges());
|
||||
otherPanel.clearSelection();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private JPanel layoutCommitListPanel(@NotNull String currentBranch, boolean forward) {
|
||||
String desc = makeDescription(currentBranch, forward);
|
||||
|
||||
JPanel bth = new JPanel(new BorderLayout());
|
||||
JBLabel descriptionLabel = new JBLabel(desc, UIUtil.ComponentStyle.SMALL);
|
||||
descriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
|
||||
bth.add(descriptionLabel, BorderLayout.NORTH);
|
||||
bth.add(forward ? myHeadToBranchListPanel : myBranchToHeadListPanel);
|
||||
return bth;
|
||||
}
|
||||
|
||||
private String makeDescription(@NotNull String currentBranch, boolean forward) {
|
||||
String firstBranch = forward ? currentBranch : myBranchName;
|
||||
String secondBranch = forward ? myBranchName : currentBranch;
|
||||
return String.format("<html>Commits that exist in <code><b>%s</b></code> but don't exist in <code><b>%s</b></code> (<code>git log %s..%s</code>):</html>",
|
||||
secondBranch, firstBranch, firstBranch, secondBranch);
|
||||
}
|
||||
|
||||
|
||||
// it is information dialog - no need to OK or Cancel. Close the dialog by clicking the cross button or pressing Esc.
|
||||
@Override
|
||||
protected Action[] createActions() {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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 git4idea.ui.branch;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import git4idea.util.GitCommitCompareInfo;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
class GitCompareBranchesDiffPanel extends JPanel {
|
||||
|
||||
private final Project myProject;
|
||||
private final String myBranchName;
|
||||
private final String myCurrentBranchName;
|
||||
private final GitCommitCompareInfo myCompareInfo;
|
||||
|
||||
public GitCompareBranchesDiffPanel(Project project, String branchName, String currentBranchName, GitCommitCompareInfo compareInfo) {
|
||||
super();
|
||||
|
||||
myProject = project;
|
||||
myCurrentBranchName = currentBranchName;
|
||||
myCompareInfo = compareInfo;
|
||||
myBranchName = branchName;
|
||||
|
||||
setLayout(new BorderLayout(UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP));
|
||||
add(createNorthPanel(), BorderLayout.NORTH);
|
||||
add(createCenterPanel());
|
||||
}
|
||||
|
||||
private JComponent createNorthPanel() {
|
||||
return new JBLabel(String.format("<html>Difference between current working tree on <b><code>%s</code></b> " +
|
||||
"and files in <b><code>%s</code></b>:</html>", myCurrentBranchName, myBranchName),
|
||||
UIUtil.ComponentStyle.REGULAR);
|
||||
}
|
||||
|
||||
private JComponent createCenterPanel() {
|
||||
List<Change> diff = myCompareInfo.getTotalDiff();
|
||||
final ChangesBrowser changesBrowser = new ChangesBrowser(myProject, null, diff, null, false, true,
|
||||
null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
|
||||
changesBrowser.setChangesToDisplay(diff);
|
||||
return changesBrowser;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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 git4idea.ui.branch;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import git4idea.history.browser.GitCommit;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.ui.GitCommitListPanel;
|
||||
import git4idea.ui.GitRepositoryComboboxListCellRenderer;
|
||||
import git4idea.util.GitCommitCompareInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author Kirill Likhodedov
|
||||
*/
|
||||
class GitCompareBranchesLogPanel extends JPanel {
|
||||
|
||||
private final Project myProject;
|
||||
private final String myBranchName;
|
||||
private final String myCurrentBranchName;
|
||||
private final GitCommitCompareInfo myCompareInfo;
|
||||
private final GitRepository myInitialRepo;
|
||||
|
||||
private GitCommitListPanel myHeadToBranchListPanel;
|
||||
private GitCommitListPanel myBranchToHeadListPanel;
|
||||
|
||||
GitCompareBranchesLogPanel(@NotNull Project project, @NotNull String branchName, @NotNull String currentBranchName,
|
||||
@NotNull GitCommitCompareInfo compareInfo, @NotNull GitRepository initialRepo) {
|
||||
super(new BorderLayout());
|
||||
myProject = project;
|
||||
myBranchName = branchName;
|
||||
myCurrentBranchName = currentBranchName;
|
||||
myCompareInfo = compareInfo;
|
||||
myInitialRepo = initialRepo;
|
||||
|
||||
add(createNorthPanel(), BorderLayout.NORTH);
|
||||
add(createCenterPanel());
|
||||
}
|
||||
|
||||
private JComponent createCenterPanel() {
|
||||
final ChangesBrowser changesBrowser = new ChangesBrowser(myProject, null, Collections.<Change>emptyList(), null, false, true,
|
||||
null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
|
||||
|
||||
myHeadToBranchListPanel = new GitCommitListPanel(myProject, getHeadToBranchCommits(myInitialRepo));
|
||||
myBranchToHeadListPanel = new GitCommitListPanel(myProject, getBranchToHeadCommits(myInitialRepo));
|
||||
|
||||
addSelectionListener(myHeadToBranchListPanel, myBranchToHeadListPanel, changesBrowser);
|
||||
addSelectionListener(myBranchToHeadListPanel, myHeadToBranchListPanel, changesBrowser);
|
||||
|
||||
JPanel htb = layoutCommitListPanel(myCurrentBranchName, true);
|
||||
JPanel bth = layoutCommitListPanel(myCurrentBranchName, false);
|
||||
|
||||
Splitter lists = new Splitter(true, 0.5f);
|
||||
lists.setFirstComponent(htb);
|
||||
lists.setSecondComponent(bth);
|
||||
|
||||
Splitter rootPanel = new Splitter(false, 0.7f);
|
||||
rootPanel.setSecondComponent(changesBrowser);
|
||||
rootPanel.setFirstComponent(lists);
|
||||
return rootPanel;
|
||||
}
|
||||
|
||||
private JComponent createNorthPanel() {
|
||||
final JComboBox repoSelector = new JComboBox(ArrayUtil.toObjectArray(myCompareInfo.getRepositories(), GitRepository.class));
|
||||
repoSelector.setRenderer(new GitRepositoryComboboxListCellRenderer(repoSelector));
|
||||
repoSelector.setSelectedItem(myInitialRepo);
|
||||
|
||||
repoSelector.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
GitRepository selectedRepo = (GitRepository)repoSelector.getSelectedItem();
|
||||
myHeadToBranchListPanel.setCommits(getHeadToBranchCommits(selectedRepo));
|
||||
myBranchToHeadListPanel.setCommits(getBranchToHeadCommits(selectedRepo));
|
||||
}
|
||||
});
|
||||
|
||||
JPanel repoSelectorPanel = new JPanel(new BorderLayout(UIUtil.DEFAULT_VGAP, UIUtil.DEFAULT_HGAP));
|
||||
JBLabel label = new JBLabel("Repository: ");
|
||||
label.setLabelFor(repoSelectorPanel);
|
||||
repoSelectorPanel.add(label, BorderLayout.WEST);
|
||||
repoSelectorPanel.add(repoSelector);
|
||||
|
||||
if (myCompareInfo.getRepositories().size() < 2) {
|
||||
repoSelectorPanel.setVisible(false);
|
||||
}
|
||||
return repoSelectorPanel;
|
||||
}
|
||||
|
||||
private ArrayList<GitCommit> getBranchToHeadCommits(GitRepository selectedRepo) {
|
||||
return new ArrayList<GitCommit>(myCompareInfo.getBranchToHeadCommits(selectedRepo));
|
||||
}
|
||||
|
||||
private ArrayList<GitCommit> getHeadToBranchCommits(GitRepository selectedRepo) {
|
||||
return new ArrayList<GitCommit>(myCompareInfo.getHeadToBranchCommits(selectedRepo));
|
||||
}
|
||||
|
||||
|
||||
private static void addSelectionListener(@NotNull GitCommitListPanel sourcePanel,
|
||||
@NotNull final GitCommitListPanel otherPanel,
|
||||
@NotNull final ChangesBrowser changesBrowser) {
|
||||
sourcePanel.addListSelectionListener(new Consumer<GitCommit>() {
|
||||
@Override
|
||||
public void consume(GitCommit commit) {
|
||||
changesBrowser.setChangesToDisplay(commit.getChanges());
|
||||
otherPanel.clearSelection();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private JPanel layoutCommitListPanel(@NotNull String currentBranch, boolean forward) {
|
||||
String desc = makeDescription(currentBranch, forward);
|
||||
|
||||
JPanel bth = new JPanel(new BorderLayout());
|
||||
JBLabel descriptionLabel = new JBLabel(desc, UIUtil.ComponentStyle.SMALL);
|
||||
descriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
|
||||
bth.add(descriptionLabel, BorderLayout.NORTH);
|
||||
bth.add(forward ? myHeadToBranchListPanel : myBranchToHeadListPanel);
|
||||
return bth;
|
||||
}
|
||||
|
||||
private String makeDescription(@NotNull String currentBranch, boolean forward) {
|
||||
String firstBranch = forward ? currentBranch : myBranchName;
|
||||
String secondBranch = forward ? myBranchName : currentBranch;
|
||||
return String.format("<html>Commits that exist in <code><b>%s</b></code> but don't exist in <code><b>%s</b></code> (<code>git log %s..%s</code>):</html>",
|
||||
secondBranch, firstBranch, firstBranch, secondBranch);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ package git4idea.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import git4idea.history.browser.GitCommit;
|
||||
import git4idea.repo.GitRepository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -31,11 +32,16 @@ public class GitCommitCompareInfo {
|
||||
private static final Logger LOG = Logger.getInstance(GitCommitCompareInfo.class);
|
||||
|
||||
private final Map<GitRepository, Pair<List<GitCommit>, List<GitCommit>>> myInfo = new HashMap<GitRepository, Pair<List<GitCommit>, List<GitCommit>>>();
|
||||
|
||||
private final Map<GitRepository, Collection<Change>> myTotalDiff = new HashMap<GitRepository, Collection<Change>>();
|
||||
|
||||
public void put(@NotNull GitRepository repository, @NotNull Pair<List<GitCommit>, List<GitCommit>> commits) {
|
||||
myInfo.put(repository, commits);
|
||||
}
|
||||
|
||||
public void put(@NotNull GitRepository repository, @NotNull Collection<Change> totalDiff) {
|
||||
myTotalDiff.put(repository, totalDiff);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<GitCommit> getHeadToBranchCommits(@NotNull GitRepository repo) {
|
||||
return getCompareInfo(repo).getFirst();
|
||||
@@ -64,4 +70,13 @@ public class GitCommitCompareInfo {
|
||||
public boolean isEmpty() {
|
||||
return myInfo.isEmpty();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Change> getTotalDiff() {
|
||||
List<Change> changes = new ArrayList<Change>();
|
||||
for (Collection<Change> changeCollection : myTotalDiff.values()) {
|
||||
changes.addAll(changeCollection);
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
}
|
||||
|
||||
+38
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.editor.actions;
|
||||
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.editorActions.JavaTypedHandler;
|
||||
import com.intellij.codeInsight.editorActions.TypedHandlerDelegate;
|
||||
@@ -23,8 +24,12 @@ import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.highlighter.HighlighterIterator;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
|
||||
@@ -50,10 +55,41 @@ public class GroovyTypedHandler extends TypedHandlerDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
if (c == '@' && file instanceof GroovyFile) {
|
||||
autoPopupMemberLookup(project, editor, new Condition<PsiFile>() {
|
||||
public boolean value(final PsiFile file) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
|
||||
PsiElement lastElement = file.findElementAt(offset - 1);
|
||||
if (lastElement == null) return false;
|
||||
|
||||
final PsiElement prevSibling = PsiTreeUtil.prevVisibleLeaf(lastElement);
|
||||
return prevSibling != null && ".".equals(prevSibling.getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (c == '&' && file instanceof GroovyFile) {
|
||||
autoPopupMemberLookup(project, editor, new Condition<PsiFile>() {
|
||||
public boolean value(final PsiFile file) {
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
|
||||
PsiElement lastElement = file.findElementAt(offset - 1);
|
||||
return lastElement != null && ".&".equals(lastElement.getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Result.CONTINUE;
|
||||
}
|
||||
|
||||
public Result charTyped(final char c, final Project project, final Editor editor, final PsiFile file) {
|
||||
private static void autoPopupMemberLookup(Project project, final Editor editor, Condition<PsiFile> condition) {
|
||||
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, condition);
|
||||
}
|
||||
|
||||
|
||||
public Result charTyped(final char c, final Project project, final Editor editor, @NotNull final PsiFile file) {
|
||||
if (myJavaLTTyped) {
|
||||
myJavaLTTyped = false;
|
||||
JavaTypedHandler.handleAfterJavaLT(editor, GroovyTokenTypes.mLT, GroovyTokenTypes.mGT, INVALID_INSIDE_REFERENCE);
|
||||
|
||||
+21
-12
@@ -50,20 +50,19 @@ public class MixinMemberContributor extends NonCodeMembersContributor {
|
||||
final PsiModifierList modifierList = aClass.getModifierList();
|
||||
if (modifierList == null) return;
|
||||
|
||||
final PsiAnnotation annotation = modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_LANG_MIXIN);
|
||||
if (annotation == null) return;
|
||||
|
||||
final PsiAnnotationMemberValue value = annotation.findAttributeValue("value");
|
||||
|
||||
List<PsiClass> mixins = new ArrayList<PsiClass>();
|
||||
if (value instanceof GrAnnotationArrayInitializer) {
|
||||
final GrAnnotationMemberValue[] initializers = ((GrAnnotationArrayInitializer)value).getInitializers();
|
||||
for (GrAnnotationMemberValue initializer : initializers) {
|
||||
addMixin(initializer, mixins);
|
||||
for (PsiAnnotation annotation : getAllMixins(modifierList)) {
|
||||
final PsiAnnotationMemberValue value = annotation.findAttributeValue("value");
|
||||
|
||||
if (value instanceof GrAnnotationArrayInitializer) {
|
||||
final GrAnnotationMemberValue[] initializers = ((GrAnnotationArrayInitializer)value).getInitializers();
|
||||
for (GrAnnotationMemberValue initializer : initializers) {
|
||||
addMixin(initializer, mixins);
|
||||
}
|
||||
}
|
||||
else if (value instanceof GrExpression) {
|
||||
addMixin((GrExpression)value, mixins);
|
||||
}
|
||||
}
|
||||
else if (value instanceof GrExpression) {
|
||||
addMixin((GrExpression)value, mixins);
|
||||
}
|
||||
|
||||
for (PsiClass mixin : mixins) {
|
||||
@@ -83,6 +82,16 @@ public class MixinMemberContributor extends NonCodeMembersContributor {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<PsiAnnotation> getAllMixins(PsiModifierList modifierList) {
|
||||
final ArrayList<PsiAnnotation> result = new ArrayList<PsiAnnotation>();
|
||||
for (PsiAnnotation annotation : modifierList.getApplicableAnnotations()) {
|
||||
if (GroovyCommonClassNames.GROOVY_LANG_MIXIN.equals(annotation.getQualifiedName())) {
|
||||
result.add(annotation);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean isCategoryMethod(PsiElement element, PsiType qualifierType) {
|
||||
if (!(element instanceof PsiMethod)) return false;
|
||||
if (!((PsiMethod)element).hasModifierProperty(PsiModifier.STATIC)) return false;
|
||||
|
||||
+31
-1
@@ -789,9 +789,39 @@ print new B().f<caret>oo()
|
||||
|
||||
def resolved = ref.resolve()
|
||||
assertInstanceOf(resolved, GrMethod)
|
||||
assertTrue(resolved.isPhysical())
|
||||
assertTrue(resolved.physical)
|
||||
}
|
||||
|
||||
void testTwoMixinsInModifierList() {
|
||||
def ref = configureByText("""
|
||||
class PersonHelper {
|
||||
def useThePerson() {
|
||||
Person person = new Person()
|
||||
|
||||
person.getUsername()
|
||||
person.get<caret>Name()
|
||||
}
|
||||
}
|
||||
|
||||
@Mixin(PersonMixin)
|
||||
@Mixin(OtherPersonMixin)
|
||||
class Person { }
|
||||
|
||||
class PersonMixin {
|
||||
String getUsername() { }
|
||||
}
|
||||
|
||||
class OtherPersonMixin {
|
||||
String getName() { }
|
||||
}
|
||||
""")
|
||||
|
||||
def resolved = ref.resolve()
|
||||
assertInstanceOf(resolved, GrMethod)
|
||||
assertTrue(resolved.physical)
|
||||
}
|
||||
|
||||
|
||||
void testDisjunctionType() {
|
||||
def ref = configureByText ("""
|
||||
import java.sql.SQLException
|
||||
|
||||
+2
-3
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.idea.maven.execution;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -34,8 +33,8 @@ public class EditMavenPropertyDialog extends DialogWrapper {
|
||||
private JTextField myValueField;
|
||||
private final Map<String, String> myAvailableProperties;
|
||||
|
||||
public EditMavenPropertyDialog(Project p, Pair<String, String> value, Map<String, String> availableProperties) {
|
||||
super(p, false);
|
||||
public EditMavenPropertyDialog(Pair<String, String> value, Map<String, String> availableProperties) {
|
||||
super(false);
|
||||
setTitle("Edit Maven Property");
|
||||
|
||||
myAvailableProperties = availableProperties;
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.jetbrains.idea.maven.execution;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.AddEditRemovePanel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public class MavenPropertiesPanel extends AddEditRemovePanel<Pair<String, String>> {
|
||||
private Map<String, String> myAvailableProperties;
|
||||
|
||||
public MavenPropertiesPanel(Map<String, String> availableProperties) {
|
||||
super(new MyPropertiesTableModel(), new ArrayList<Pair<String, String>>(), null);
|
||||
setPreferredSize(new Dimension(100, 100));
|
||||
myAvailableProperties = availableProperties;
|
||||
}
|
||||
|
||||
protected Pair<String, String> addItem() {
|
||||
return doAddOrEdit(new Pair<String, String>("", ""));
|
||||
}
|
||||
|
||||
protected boolean removeItem(Pair<String, String> o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Pair<String, String> editItem(Pair<String, String> o) {
|
||||
return doAddOrEdit(o);
|
||||
}
|
||||
|
||||
private Pair<String, String> doAddOrEdit(Pair<String, String> o) {
|
||||
EditMavenPropertyDialog d = new EditMavenPropertyDialog(o, myAvailableProperties);
|
||||
d.show();
|
||||
if (!d.isOK()) return null;
|
||||
return d.getValue();
|
||||
}
|
||||
|
||||
public Map<String, String> getDataAsMap() {
|
||||
Map<String, String> result = new LinkedHashMap<String, String>();
|
||||
for (Pair<String, String> p : getData()) {
|
||||
result.put(p.getFirst(), p.getSecond());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setDataFromMap(Map<String, String> map) {
|
||||
List<Pair<String, String>> result = new ArrayList<Pair<String, String>>();
|
||||
for (Map.Entry<String, String> e : map.entrySet()) {
|
||||
result.add(new Pair<String, String>(e.getKey(), e.getValue()));
|
||||
}
|
||||
setData(result);
|
||||
}
|
||||
|
||||
private static class MyPropertiesTableModel extends AddEditRemovePanel.TableModel<Pair<String, String>> {
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String getColumnName(int c) {
|
||||
return c == 0 ? "Name" : "Value";
|
||||
}
|
||||
|
||||
public Object getField(Pair<String, String> o, int c) {
|
||||
return c == 0 ? o.getFirst() : o.getSecond();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+8
-67
@@ -21,8 +21,6 @@ import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.AddEditRemovePanel;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.RawCommandLineEditor;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -35,8 +33,9 @@ import org.jetbrains.idea.maven.utils.ComboBoxUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public abstract class MavenRunnerConfigurable implements SearchableConfigurable, Configurable.NoScroll {
|
||||
private final Project myProject;
|
||||
@@ -47,7 +46,7 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
private JComboBox myJdkCombo;
|
||||
private final DefaultComboBoxModel myJdkComboModel = new DefaultComboBoxModel();
|
||||
private JCheckBox mySkipTestsCheckBox;
|
||||
private MyPropertiesPanel myPropertiesPanel;
|
||||
private MavenPropertiesPanel myPropertiesPanel;
|
||||
|
||||
private Map<String, String> myProperties;
|
||||
|
||||
@@ -114,7 +113,9 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
|
||||
propertiesPanel.add(mySkipTestsCheckBox = new JCheckBox("Skip tests"), BorderLayout.NORTH);
|
||||
mySkipTestsCheckBox.setMnemonic('t');
|
||||
propertiesPanel.add(myPropertiesPanel = new MyPropertiesPanel(), BorderLayout.CENTER);
|
||||
|
||||
collectProperties();
|
||||
propertiesPanel.add(myPropertiesPanel = new MavenPropertiesPanel(myProperties), BorderLayout.CENTER);
|
||||
myPropertiesPanel.getEmptyText().setText("No properties defined");
|
||||
|
||||
c.gridx = 0;
|
||||
@@ -124,8 +125,6 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
panel.add(propertiesPanel, c);
|
||||
|
||||
collectProperties();
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
@@ -135,9 +134,7 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
|
||||
for (MavenProject each : s.getProjects()) {
|
||||
Properties properties = each.getProperties();
|
||||
for (Map.Entry p : properties.entrySet()) {
|
||||
result.put((String)p.getKey(), (String)p.getValue());
|
||||
}
|
||||
result.putAll((Map)properties);
|
||||
}
|
||||
|
||||
myProperties = result;
|
||||
@@ -215,60 +212,4 @@ public abstract class MavenRunnerConfigurable implements SearchableConfigurable,
|
||||
|
||||
data.setMavenProperties(myPropertiesPanel.getDataAsMap());
|
||||
}
|
||||
|
||||
private class MyPropertiesPanel extends AddEditRemovePanel<Pair<String, String>> {
|
||||
public MyPropertiesPanel() {
|
||||
super(new MyPropertiesTableModel(), new ArrayList<Pair<String, String>>(), null);
|
||||
setPreferredSize(new Dimension(100, 100));
|
||||
}
|
||||
|
||||
protected Pair<String, String> addItem() {
|
||||
return doAddOrEdit(new Pair<String, String>("", ""));
|
||||
}
|
||||
|
||||
protected boolean removeItem(Pair<String, String> o) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Pair<String, String> editItem(Pair<String, String> o) {
|
||||
return doAddOrEdit(o);
|
||||
}
|
||||
|
||||
private Pair<String, String> doAddOrEdit(Pair<String, String> o) {
|
||||
EditMavenPropertyDialog d = new EditMavenPropertyDialog(myProject, o, myProperties);
|
||||
d.show();
|
||||
if (!d.isOK()) return null;
|
||||
return d.getValue();
|
||||
}
|
||||
|
||||
public Map<String, String> getDataAsMap() {
|
||||
Map<String, String> result = new LinkedHashMap<String, String>();
|
||||
for (Pair<String, String> p : getData()) {
|
||||
result.put(p.getFirst(), p.getSecond());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setDataFromMap(Map<String, String> map) {
|
||||
List<Pair<String, String>> result = new ArrayList<Pair<String, String>>();
|
||||
for (Map.Entry<String, String> e : map.entrySet()) {
|
||||
result.add(new Pair<String, String>(e.getKey(), e.getValue()));
|
||||
}
|
||||
setData(result);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyPropertiesTableModel extends AddEditRemovePanel.TableModel<Pair<String, String>> {
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String getColumnName(int c) {
|
||||
return c == 0 ? "Name" : "Value";
|
||||
}
|
||||
|
||||
public Object getField(Pair<String, String> o, int c) {
|
||||
return c == 0 ? o.getFirst() : o.getSecond();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class MavenFrameworkSupportProvider extends FrameworkSupportProvider {
|
||||
}
|
||||
else {
|
||||
new MavenModuleBuilderHelper(new MavenId("groupId", module.getName(), "1.0-SNAPSHOT"), null, null, false, false, null,
|
||||
"Add Maven Support").configure(model.getProject(), root, true);
|
||||
null, "Add Maven Support").configure(model.getProject(), root, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+29
-2
@@ -33,6 +33,7 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.idea.maven.model.MavenArchetype;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.project.MavenEnvironmentForm;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
import org.jetbrains.idea.maven.utils.MavenUtil;
|
||||
@@ -41,6 +42,7 @@ import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuilder {
|
||||
private static final Icon BIG_ICON = IconLoader.getIcon("/modules/javaModule.png");
|
||||
@@ -54,6 +56,10 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
|
||||
private MavenId myProjectId;
|
||||
private MavenArchetype myArchetype;
|
||||
|
||||
private MavenEnvironmentForm myEnvironmentForm;
|
||||
|
||||
private Map<String, String> myPropertiesToCreateByArtifact;
|
||||
|
||||
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
|
||||
final Project project = rootModel.getProject();
|
||||
|
||||
@@ -64,8 +70,12 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
|
||||
|
||||
MavenUtil.runWhenInitialized(project, new DumbAwareRunnable() {
|
||||
public void run() {
|
||||
if (myEnvironmentForm != null) {
|
||||
myEnvironmentForm.setData(MavenProjectsManager.getInstance(project).getGeneralSettings());
|
||||
}
|
||||
|
||||
new MavenModuleBuilderHelper(myProjectId, myAggregatorProject, myParentProject, myInheritGroupId,
|
||||
myInheritVersion, myArchetype, "Create new Maven module").configure(project, root, false);
|
||||
myInheritVersion, myArchetype, myPropertiesToCreateByArtifact, "Create new Maven module").configure(project, root, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -96,7 +106,8 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
|
||||
|
||||
@Override
|
||||
public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, ModulesProvider modulesProvider) {
|
||||
return new ModuleWizardStep[]{new MavenModuleWizardStep(wizardContext.getProject(), this)};
|
||||
return new ModuleWizardStep[]{new MavenModuleWizardStep(wizardContext.getProject(), this),
|
||||
new SelectPropertiesStep(wizardContext.getProject(), this)};
|
||||
}
|
||||
|
||||
public MavenProject findPotentialParentProject(Project project) {
|
||||
@@ -170,4 +181,20 @@ public class MavenModuleBuilder extends ModuleBuilder implements SourcePathsBuil
|
||||
public MavenArchetype getArchetype() {
|
||||
return myArchetype;
|
||||
}
|
||||
|
||||
public MavenEnvironmentForm getEnvironmentForm() {
|
||||
return myEnvironmentForm;
|
||||
}
|
||||
|
||||
public void setEnvironmentForm(MavenEnvironmentForm environmentForm) {
|
||||
myEnvironmentForm = environmentForm;
|
||||
}
|
||||
|
||||
public Map<String, String> getPropertiesToCreateByArtifact() {
|
||||
return myPropertiesToCreateByArtifact;
|
||||
}
|
||||
|
||||
public void setPropertiesToCreateByArtifact(Map<String, String> propertiesToCreateByArtifact) {
|
||||
myPropertiesToCreateByArtifact = propertiesToCreateByArtifact;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-7
@@ -61,6 +61,7 @@ public class MavenModuleBuilderHelper {
|
||||
private final boolean myInheritVersion;
|
||||
|
||||
private final MavenArchetype myArchetype;
|
||||
private final Map<String, String> myPropertiesToCreateByArtifact;
|
||||
|
||||
private final String myCommandName;
|
||||
|
||||
@@ -70,6 +71,7 @@ public class MavenModuleBuilderHelper {
|
||||
boolean inheritGroupId,
|
||||
boolean inheritVersion,
|
||||
MavenArchetype archetype,
|
||||
Map<String, String> propertiesToCreateByArtifact,
|
||||
String commaneName) {
|
||||
myProjectId = projectId;
|
||||
myAggregatorProject = aggregatorProject;
|
||||
@@ -77,6 +79,8 @@ public class MavenModuleBuilderHelper {
|
||||
myInheritGroupId = inheritGroupId;
|
||||
myInheritVersion = inheritVersion;
|
||||
myArchetype = archetype;
|
||||
myPropertiesToCreateByArtifact = propertiesToCreateByArtifact;
|
||||
assert (archetype == null) == (propertiesToCreateByArtifact == null);
|
||||
myCommandName = commaneName;
|
||||
}
|
||||
|
||||
@@ -194,14 +198,16 @@ public class MavenModuleBuilderHelper {
|
||||
Map<String, String> props = settings.getMavenProperties();
|
||||
|
||||
props.put("interactiveMode", "false");
|
||||
props.put("archetypeGroupId", myArchetype.groupId);
|
||||
props.put("archetypeArtifactId", myArchetype.artifactId);
|
||||
props.put("archetypeVersion", myArchetype.version);
|
||||
if (myArchetype.repository != null) props.put("archetypeRepository", myArchetype.repository);
|
||||
//props.put("archetypeGroupId", myArchetype.groupId);
|
||||
//props.put("archetypeArtifactId", myArchetype.artifactId);
|
||||
//props.put("archetypeVersion", myArchetype.version);
|
||||
//if (myArchetype.repository != null) props.put("archetypeRepository", myArchetype.repository);
|
||||
|
||||
props.put("groupId", myProjectId.getGroupId());
|
||||
props.put("artifactId", myProjectId.getArtifactId());
|
||||
props.put("version", myProjectId.getVersion());
|
||||
//props.put("groupId", myProjectId.getGroupId());
|
||||
//props.put("artifactId", myProjectId.getArtifactId());
|
||||
//props.put("version", myProjectId.getVersion());
|
||||
|
||||
props.putAll(myPropertiesToCreateByArtifact);
|
||||
|
||||
runner.run(params, settings, new Runnable() {
|
||||
public void run() {
|
||||
|
||||
+28
-4
@@ -24,7 +24,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.AbstractLayoutManager;
|
||||
import com.intellij.util.ui.AsyncProcessIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
@@ -45,7 +44,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
private static final Icon WIZARD_ICON = IconLoader.getIcon("/addmodulewizard.png");
|
||||
@@ -91,6 +89,8 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
private Object myCurrentUpdaterMarker;
|
||||
private final AsyncProcessIcon myLoadingIcon = new AsyncProcessIcon.Big(getClass() + ".loading");
|
||||
|
||||
private boolean skipUpdateUI;
|
||||
|
||||
public MavenModuleWizardStep(@Nullable Project project, MavenModuleBuilder builder) {
|
||||
myProjectOrNull = project;
|
||||
myBuilder = builder;
|
||||
@@ -140,6 +140,12 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myInheritVersionCheckBox.addActionListener(updatingListener);
|
||||
|
||||
myUseArchetypeCheckBox.addActionListener(updatingListener);
|
||||
myUseArchetypeCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
archetypeMayBeChanged();
|
||||
}
|
||||
});
|
||||
|
||||
myAddArchetypeButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -155,6 +161,7 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myArchetypesTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
updateArchetypeDescription();
|
||||
archetypeMayBeChanged();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -169,6 +176,20 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myArchetypeDescriptionField.setBackground(UIUtil.getPanelBackground());
|
||||
}
|
||||
|
||||
private void archetypeMayBeChanged() {
|
||||
MavenArchetype selectedArchetype = getSelectedArchetype();
|
||||
if (((myBuilder.getArchetype() == null) != (selectedArchetype == null))) {
|
||||
myBuilder.setArchetype(selectedArchetype);
|
||||
skipUpdateUI = true;
|
||||
try {
|
||||
fireStateChanged();
|
||||
}
|
||||
finally {
|
||||
skipUpdateUI = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
return myGroupIdField;
|
||||
@@ -253,6 +274,8 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
|
||||
@Override
|
||||
public void updateStep() {
|
||||
if (skipUpdateUI) return;
|
||||
|
||||
if (isMavenizedProject()) {
|
||||
MavenProject parent = myBuilder.findPotentialParentProject(myProjectOrNull);
|
||||
myAggregator = parent;
|
||||
@@ -429,7 +452,7 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myArchetypesTree.setBackground(archetypesEnabled ? UIUtil.getListBackground() : UIUtil.getPanelBackground());
|
||||
}
|
||||
|
||||
private String formatProjectString(MavenProject project) {
|
||||
private static String formatProjectString(MavenProject project) {
|
||||
if (project == null) return "<none>";
|
||||
return project.getMavenId().getDisplayString();
|
||||
}
|
||||
@@ -448,12 +471,13 @@ public class MavenModuleWizardStep extends ModuleWizardStep {
|
||||
myBuilder.setArchetype(getSelectedArchetype());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MavenArchetype getSelectedArchetype() {
|
||||
if (!myUseArchetypeCheckBox.isSelected() || myArchetypesTree.isSelectionEmpty()) return null;
|
||||
return getArchetypeInfoFromPathComponent(myArchetypesTree.getLastSelectedPathComponent());
|
||||
}
|
||||
|
||||
private MavenArchetype getArchetypeInfoFromPathComponent(Object sel) {
|
||||
private static MavenArchetype getArchetypeInfoFromPathComponent(Object sel) {
|
||||
return (MavenArchetype)((DefaultMutableTreeNode)sel).getUserObject();
|
||||
}
|
||||
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.wizards.SelectPropertiesStep">
|
||||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="bbb30" binding="myEnvironmentPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="41b57" binding="myPropertiesPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="-1" height="300"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="etched" title="Properties"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<vspacer id="c877e">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.jetbrains.idea.maven.wizards;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.execution.MavenPropertiesPanel;
|
||||
import org.jetbrains.idea.maven.indices.MavenIndex;
|
||||
import org.jetbrains.idea.maven.model.MavenArchetype;
|
||||
import org.jetbrains.idea.maven.model.MavenId;
|
||||
import org.jetbrains.idea.maven.project.MavenEnvironmentForm;
|
||||
import org.jetbrains.idea.maven.project.MavenGeneralSettings;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public class SelectPropertiesStep extends ModuleWizardStep {
|
||||
|
||||
private final Project myProjectOrNull;
|
||||
private final MavenModuleBuilder myBuilder;
|
||||
|
||||
private JPanel myMainPanel;
|
||||
private JPanel myEnvironmentPanel;
|
||||
private JPanel myPropertiesPanel;
|
||||
|
||||
private MavenEnvironmentForm myEnvironmentForm;
|
||||
private MavenPropertiesPanel myMavenPropertiesPanel;
|
||||
|
||||
private Map<String, String> myAvailableProperties = new HashMap<String, String>();
|
||||
|
||||
public SelectPropertiesStep(@Nullable Project project, MavenModuleBuilder builder) {
|
||||
myProjectOrNull = project;
|
||||
myBuilder = builder;
|
||||
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
myEnvironmentForm = new MavenEnvironmentForm();
|
||||
|
||||
Project project = myProjectOrNull == null ? ProjectManager.getInstance().getDefaultProject() : myProjectOrNull;
|
||||
myEnvironmentForm.getData(MavenProjectsManager.getInstance(project).getGeneralSettings().clone());
|
||||
|
||||
myEnvironmentPanel.add(myEnvironmentForm.createComponent(), BorderLayout.CENTER);
|
||||
|
||||
myMavenPropertiesPanel = new MavenPropertiesPanel(myAvailableProperties);
|
||||
myPropertiesPanel.add(myMavenPropertiesPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStep() {
|
||||
MavenArchetype archetype = myBuilder.getArchetype();
|
||||
|
||||
Map<String, String> props = new LinkedHashMap<String, String>();
|
||||
|
||||
MavenId projectId = myBuilder.getProjectId();
|
||||
|
||||
props.put("groupId", projectId.getGroupId());
|
||||
props.put("artifactId", projectId.getArtifactId());
|
||||
props.put("version", projectId.getVersion());
|
||||
|
||||
props.put("archetypeGroupId", archetype.groupId);
|
||||
props.put("archetypeArtifactId", archetype.artifactId);
|
||||
props.put("archetypeVersion", archetype.version);
|
||||
if (archetype.repository != null) props.put("archetypeRepository", archetype.repository);
|
||||
|
||||
myMavenPropertiesPanel.setDataFromMap(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getComponent() {
|
||||
return myMainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStepVisible() {
|
||||
return myBuilder.getArchetype() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDataModel() {
|
||||
myBuilder.setEnvironmentForm(myEnvironmentForm);
|
||||
myBuilder.setPropertiesToCreateByArtifact(myMavenPropertiesPanel.getDataAsMap());
|
||||
}
|
||||
}
|
||||
@@ -134293,6 +134293,8 @@ versifying
|
||||
versing
|
||||
version
|
||||
version's
|
||||
versional
|
||||
versioned
|
||||
versions
|
||||
verso
|
||||
verso's
|
||||
|
||||
Reference in New Issue
Block a user