本文整理汇总了Java中com.intellij.openapi.project.impl.ProjectImpl类的典型用法代码示例。如果您正苦于以下问题:Java ProjectImpl类的具体用法?Java ProjectImpl怎么用?Java ProjectImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectImpl类属于com.intellij.openapi.project.impl包,在下文中一共展示了ProjectImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readProjectName
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
private static String readProjectName(@NotNull String path) {
final File file = new File(path);
if (file.isDirectory()) {
final File nameFile = new File(new File(path, Project.DIRECTORY_STORE_FOLDER), ProjectImpl.NAME_FILE);
if (nameFile.exists()) {
try {
final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(nameFile), CharsetToolkit.UTF8_CHARSET));
try {
String name = in.readLine();
if (!StringUtil.isEmpty(name)) {
return name.trim();
}
}
finally {
in.close();
}
}
catch (IOException ignored) { }
}
return file.getName();
}
else {
return FileUtilRt.getNameWithoutExtension(file.getName());
}
}
示例2: documentChanged
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
@Override
public void documentChanged(DocumentEvent event) {
super.documentChanged(event);
// optimisation: avoid documents piling up during batch processing
if (FileDocumentManagerImpl.areTooManyDocumentsInTheQueue(myUncommittedDocuments)) {
if (myUnitTestMode) {
myStopTrackingDocuments = true;
try {
LOG.error("Too many uncommitted documents for " + myProject + ":\n" + StringUtil.join(myUncommittedDocuments, "\n") +
"\n\n Project creation trace: " + myProject.getUserData(ProjectImpl.CREATION_TRACE));
}
finally {
//noinspection TestOnlyProblems
clearUncommittedDocuments();
}
}
// must not commit during document save
if (PomModelImpl.isAllowPsiModification()) {
commitAllDocuments();
}
}
}
示例3: loadProjectFromTemplate
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
@Override
public void loadProjectFromTemplate(@NotNull final ProjectImpl defaultProject) {
final StateStorage stateStorage = getStateStorageManager().getFileStateStorage(DEFAULT_STATE_STORAGE);
assert stateStorage instanceof XmlElementStorage;
XmlElementStorage xmlElementStorage = (XmlElementStorage)stateStorage;
defaultProject.save();
final IProjectStore projectStore = defaultProject.getStateStore();
assert projectStore instanceof DefaultProjectStoreImpl;
DefaultProjectStoreImpl defaultProjectStore = (DefaultProjectStoreImpl)projectStore;
final Element element = defaultProjectStore.getStateCopy();
if (element != null) {
xmlElementStorage.setDefaultState(element);
}
}
示例4: save
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
@NotNull
@Override
public SaveSession save() throws IOException {
final ProjectImpl.UnableToSaveProjectNotification[] notifications =
NotificationsManager.getNotificationsManager().getNotificationsOfType(ProjectImpl.UnableToSaveProjectNotification.class, myProject);
if (notifications.length > 0) throw new SaveCancelledException();
final ReadonlyStatusHandler.OperationStatus operationStatus = ensureConfigFilesWritable();
if (operationStatus == null) {
throw new IOException();
}
else if (operationStatus.hasReadonlyFiles()) {
ProjectImpl.dropUnableToSaveProjectNotification(myProject, operationStatus.getReadonlyFiles());
throw new SaveCancelledException();
}
beforeSave();
super.save();
return this;
}
示例5: readProjectName
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
private static String readProjectName(String path) {
final File file = new File(path);
if (file.isDirectory()) {
final File nameFile = new File(new File(path, Project.DIRECTORY_STORE_FOLDER), ProjectImpl.NAME_FILE);
if (nameFile.exists()) {
try {
final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(nameFile), "UTF-8"));
try {
final String name = in.readLine();
if (name != null && name.length() > 0) return name.trim();
}
finally {
in.close();
}
}
catch (IOException ignored) { }
}
return file.getName();
}
else {
return FileUtil.getNameWithoutExtension(file.getName());
}
}
示例6: closeAndDeleteProject
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
@RequiredWriteAction
public static synchronized void closeAndDeleteProject() {
if (ourProject != null) {
ApplicationManager.getApplication().assertWriteAccessAllowed();
for (Sdk registeredSdk : ourRegisteredSdks) {
SdkTable.getInstance().removeSdk(registeredSdk);
}
((ProjectImpl)ourProject).setTemporarilyDisposed(false);
final VirtualFile projFile = ((ProjectEx)ourProject).getStateStore().getProjectFile();
final File projectFile = projFile == null ? null : VfsUtilCore.virtualToIoFile(projFile);
if (!ourProject.isDisposed()) Disposer.dispose(ourProject);
if (projectFile != null) {
FileUtil.delete(projectFile);
}
ourProject = null;
}
}
示例7: checkProjectLeak
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
@TestOnly
public static void checkProjectLeak() throws Exception {
Processor<Project> isReallyLeak = new Processor<Project>() {
@Override
public boolean process(Project project) {
return !project.isDefault() && !((ProjectImpl)project).isLight();
}
};
Collection<Object> roots = new ArrayList<Object>(Arrays.asList(ApplicationManager.getApplication(), Extensions.getRootArea()));
ClassLoader classLoader = LeakHunter.class.getClassLoader();
Vector<Class> allLoadedClasses = ReflectionUtil.getField(classLoader.getClass(), classLoader, Vector.class, "classes");
roots.addAll(allLoadedClasses); // inspect static fields of all loaded classes
checkLeak(roots, ProjectImpl.class, isReallyLeak);
}
示例8: testContextFileName
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
public void testContextFileName() throws Exception {
ProjectImpl project = (ProjectImpl)getProject();
String name = project.getName();
try {
project.setProjectName("invalid | name");
getContextManager().saveContext("foo", "bar");
}
finally {
project.setProjectName(name);
}
}
示例9: getProject
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
/**
* To support the custom language features, we need a ProjectImpl, and it's not desirable to
* create one from scratch.<br>
*
* @return the current, non-default project, if one exists, else the default project.
*/
public static Project getProject() {
Project project = (Project) DataManager.getInstance().getDataContext().getData("project");
if (project != null && project instanceof ProjectImpl) {
return project;
}
return ProjectManager.getInstance().getDefaultProject();
}
示例10: readJdomExternalizables
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
protected void readJdomExternalizables(final ModuleImpl module) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
final ProjectImpl project = (ProjectImpl)myProject;
project.setOptimiseTestLoadSpeed(false);
final ModuleRootManagerImpl moduleRootManager = (ModuleRootManagerImpl)ModuleRootManager.getInstance(module);
module.getStateStore().initComponent(moduleRootManager, false);
project.setOptimiseTestLoadSpeed(true);
}
});
}
示例11: setUpProject
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
@Override
protected void setUpProject() throws Exception {
String projectPath = PathManagerEx.getTestDataPath() + "/model/model.ipr";
myProject = ProjectManager.getInstance().loadAndOpenProject(projectPath);
MutablePicoContainer container = (MutablePicoContainer)getProject().getPicoContainer();
container.unregisterComponent(FileEditorManager.class.getName());
((ProjectImpl)getProject()).registerComponentImplementation(FileEditorManager.class, FileEditorManagerImpl.class);
}
示例12: closeAndDeleteProject
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
public static synchronized void closeAndDeleteProject() {
if (ourProject != null) {
ApplicationManager.getApplication().assertWriteAccessAllowed();
((ProjectImpl)ourProject).setTemporarilyDisposed(false);
final VirtualFile projFile = ((ProjectEx)ourProject).getStateStore().getProjectFile();
final File projectFile = projFile == null ? null : VfsUtilCore.virtualToIoFile(projFile);
if (!ourProject.isDisposed()) Disposer.dispose(ourProject);
if (projectFile != null) {
FileUtil.delete(projectFile);
}
ourProject = null;
}
}
示例13: readProjectName
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
public static String readProjectName(@Nonnull File file) {
if (file.isDirectory()) {
final File nameFile = new File(new File(file, Project.DIRECTORY_STORE_FOLDER), ProjectImpl.NAME_FILE);
if (nameFile.exists()) {
try {
return FileUtil.loadFile(nameFile, true);
}
catch (IOException ignored) {
}
}
}
return file.getName();
}
示例14: loadProjectFromTemplate
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
@Override
public void loadProjectFromTemplate(@Nonnull ProjectImpl defaultProject) {
defaultProject.save();
Element element = ((DefaultProjectStoreImpl)defaultProject.getStateStore()).getStateCopy();
if (element != null) {
getDefaultFileStorage().setDefaultState(element);
}
}
示例15: doSave
import com.intellij.openapi.project.impl.ProjectImpl; //导入依赖的package包/类
@Override
protected final void doSave(@Nullable List<SaveSession> saveSessions, @Nonnull List<Pair<SaveSession, VirtualFile>> readonlyFiles) {
ProjectImpl.UnableToSaveProjectNotification[] notifications =
NotificationsManager.getNotificationsManager().getNotificationsOfType(ProjectImpl.UnableToSaveProjectNotification.class, myProject);
if (notifications.length > 0) {
throw new SaveCancelledException();
}
beforeSave(readonlyFiles);
super.doSave(saveSessions, readonlyFiles);
if (!readonlyFiles.isEmpty()) {
ReadonlyStatusHandler.OperationStatus status;
AccessToken token = ReadAction.start();
try {
status = ReadonlyStatusHandler.getInstance(myProject).ensureFilesWritable(getFilesList(readonlyFiles));
}
finally {
token.finish();
}
if (status.hasReadonlyFiles()) {
ProjectImpl.dropUnableToSaveProjectNotification(myProject, status.getReadonlyFiles());
throw new SaveCancelledException();
}
else {
List<Pair<SaveSession, VirtualFile>> oldList = new ArrayList<>(readonlyFiles);
readonlyFiles.clear();
for (Pair<SaveSession, VirtualFile> entry : oldList) {
executeSave(entry.first, readonlyFiles);
}
if (!readonlyFiles.isEmpty()) {
ProjectImpl.dropUnableToSaveProjectNotification(myProject, getFilesList(readonlyFiles));
throw new SaveCancelledException();
}
}
}
}