mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (arrangement; formatting)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,11 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 12-Jul-2007
|
||||
*/
|
||||
package com.intellij.projectImport;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
@@ -38,13 +33,11 @@ import com.intellij.openapi.roots.CompilerProjectExtension;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.newvfs.NewVirtualFile;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -55,8 +48,11 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
* @since 12-Jul-2007
|
||||
*/
|
||||
public abstract class ProjectOpenProcessorBase<T extends ProjectImportBuilder> extends ProjectOpenProcessor {
|
||||
|
||||
private final T myBuilder;
|
||||
|
||||
protected ProjectOpenProcessorBase(@NotNull final T builder) {
|
||||
@@ -176,16 +172,14 @@ public abstract class ProjectOpenProcessorBase<T extends ProjectImportBuilder> e
|
||||
existingName = "'" + projectFile.getName() + "'";
|
||||
pathToOpen = projectFilePath;
|
||||
}
|
||||
int result = Messages.showYesNoCancelDialog(projectToClose,
|
||||
IdeBundle.message("project.import.open.existing",
|
||||
existingName,
|
||||
projectFile.getParent(),
|
||||
virtualFile.getName()),
|
||||
IdeBundle.message("title.open.project"),
|
||||
IdeBundle.message("project.import.open.existing.openExisting"),
|
||||
IdeBundle.message("project.import.open.existing.reimport"),
|
||||
CommonBundle.message("button.cancel"),
|
||||
Messages.getQuestionIcon());
|
||||
int result = Messages.showYesNoCancelDialog(
|
||||
projectToClose,
|
||||
IdeBundle.message("project.import.open.existing", existingName, projectFile.getParent(), virtualFile.getName()),
|
||||
IdeBundle.message("title.open.project"),
|
||||
IdeBundle.message("project.import.open.existing.openExisting"),
|
||||
IdeBundle.message("project.import.open.existing.reimport"),
|
||||
CommonBundle.message("button.cancel"),
|
||||
Messages.getQuestionIcon());
|
||||
if (result == Messages.CANCEL) return null;
|
||||
shouldOpenExisting = result == Messages.YES;
|
||||
}
|
||||
@@ -195,13 +189,7 @@ public abstract class ProjectOpenProcessorBase<T extends ProjectImportBuilder> e
|
||||
try {
|
||||
projectToOpen = ProjectManagerEx.getInstanceEx().loadProject(pathToOpen);
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
catch (JDOMException e) {
|
||||
return null;
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -214,15 +202,20 @@ public abstract class ProjectOpenProcessorBase<T extends ProjectImportBuilder> e
|
||||
|
||||
projectToOpen.save();
|
||||
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Sdk jdk = wizardContext.getProjectJdk();
|
||||
if (jdk != null) NewProjectUtil.applyJdkToProject(projectToOpen, jdk);
|
||||
if (jdk != null) {
|
||||
NewProjectUtil.applyJdkToProject(projectToOpen, jdk);
|
||||
}
|
||||
|
||||
final String projectDirPath = wizardContext.getProjectFileDirectory();
|
||||
CompilerProjectExtension.getInstance(projectToOpen).setCompilerOutputUrl(getUrl(
|
||||
StringUtil.endsWithChar(projectDirPath, '/') ? projectDirPath + "classes" : projectDirPath + "/classes"));
|
||||
String projectDirPath = wizardContext.getProjectFileDirectory();
|
||||
String path = StringUtil.endsWithChar(projectDirPath, '/') ? projectDirPath + "classes" : projectDirPath + "/classes";
|
||||
CompilerProjectExtension extension = CompilerProjectExtension.getInstance(projectToOpen);
|
||||
if (extension != null) {
|
||||
extension.setCompilerOutputUrl(getUrl(path));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -246,9 +239,7 @@ public abstract class ProjectOpenProcessorBase<T extends ProjectImportBuilder> e
|
||||
try {
|
||||
path = FileUtil.resolveShortWindowsName(path);
|
||||
}
|
||||
catch (IOException e) {
|
||||
//file doesn't exist
|
||||
}
|
||||
return VfsUtil.pathToUrl(FileUtil.toSystemIndependentName(path));
|
||||
catch (IOException ignored) { }
|
||||
return VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(path));
|
||||
}
|
||||
}
|
||||
|
||||
+9
-11
@@ -86,11 +86,10 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
public static final int CURRENT_FORMAT_VERSION = 4;
|
||||
|
||||
private static final Key<List<ProjectManagerListener>> LISTENERS_IN_PROJECT_KEY = Key.create("LISTENERS_IN_PROJECT_KEY");
|
||||
@NonNls private static final String ELEMENT_DEFAULT_PROJECT = "defaultProject";
|
||||
private static final String ELEMENT_DEFAULT_PROJECT = "defaultProject";
|
||||
|
||||
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
|
||||
private ProjectImpl myDefaultProject; // Only used asynchronously in save and dispose, which itself are synchronized.
|
||||
|
||||
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
|
||||
private Element myDefaultProjectRootElement; // Only used asynchronously in save and dispose, which itself are synchronized.
|
||||
|
||||
@@ -107,8 +106,6 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
private final Alarm myChangedFilesAlarm = new Alarm();
|
||||
private final List<Pair<VirtualFile, StateStorage>> myChangedApplicationFiles = new ArrayList<Pair<VirtualFile, StateStorage>>();
|
||||
private final AtomicInteger myReloadBlockCount = new AtomicInteger(0);
|
||||
@SuppressWarnings("FieldCanBeLocal") private final Map<Project, String> myProjects = new WeakHashMap<Project, String>();
|
||||
private static final int MAX_LEAKY_PROJECTS = 42;
|
||||
private final ProgressManager myProgressManager;
|
||||
private volatile boolean myDefaultProjectWasDisposed = false;
|
||||
|
||||
@@ -126,8 +123,8 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
myProgressManager = progressManager;
|
||||
Application app = ApplicationManager.getApplication();
|
||||
MessageBus messageBus = app.getMessageBus();
|
||||
MessageBusConnection connection = messageBus.connect(app);
|
||||
connection.subscribe(StateStorage.STORAGE_TOPIC, new StateStorage.Listener() {
|
||||
|
||||
messageBus.connect(app).subscribe(StateStorage.STORAGE_TOPIC, new StateStorage.Listener() {
|
||||
@Override
|
||||
public void storageFileChanged(@NotNull final VirtualFileEvent event, @NotNull final StateStorage storage) {
|
||||
VirtualFile file = event.getFile();
|
||||
@@ -136,8 +133,8 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
}
|
||||
}
|
||||
});
|
||||
final ProjectManagerListener busPublisher = messageBus.syncPublisher(TOPIC);
|
||||
|
||||
final ProjectManagerListener busPublisher = messageBus.syncPublisher(TOPIC);
|
||||
addProjectManagerListener(
|
||||
new ProjectManagerListener() {
|
||||
@Override
|
||||
@@ -191,6 +188,9 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
registerExternalProjectFileListener(virtualFileManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() { }
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
@@ -203,11 +203,9 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
}
|
||||
|
||||
private static final boolean LOG_PROJECT_LEAKAGE_IN_TESTS = false;
|
||||
private static final int MAX_LEAKY_PROJECTS = 42;
|
||||
@SuppressWarnings("FieldCanBeLocal") private final Map<Project, String> myProjects = new WeakHashMap<Project, String>();
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -163,12 +163,13 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor {
|
||||
for (ProjectOpenProcessor processor : ProjectOpenProcessor.EXTENSION_POINT_NAME.getExtensions()) {
|
||||
processor.refreshProjectFiles(projectDir);
|
||||
}
|
||||
|
||||
|
||||
project = projectManager.convertAndLoadProject(baseDir.getPath());
|
||||
if (project == null) {
|
||||
WelcomeFrame.showIfNoProjectOpened();
|
||||
return null;
|
||||
}
|
||||
|
||||
final Module[] modules = ModuleManager.getInstance(project).getModules();
|
||||
if (modules.length > 0) {
|
||||
runConfigurators = false;
|
||||
|
||||
Reference in New Issue
Block a user