Search in sources :

Example 1 with ProjectEx

use of com.intellij.openapi.project.ex.ProjectEx in project intellij-community by JetBrains.

the class RenameProjectHandler method invoke.

@Override
public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
    LOG.assertTrue(project instanceof ProjectEx);
    final Module module = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
    LOG.assertTrue(module != null);
    Messages.showInputDialog(project, RefactoringBundle.message("enter.new.project.name"), RefactoringBundle.message("rename.project"), Messages.getQuestionIcon(), module.getName(), new MyInputValidator((ProjectEx) project, module));
}
Also used : ProjectEx(com.intellij.openapi.project.ex.ProjectEx) Module(com.intellij.openapi.module.Module)

Example 2 with ProjectEx

use of com.intellij.openapi.project.ex.ProjectEx in project intellij-community by JetBrains.

the class ProjectConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    final CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(myProject);
    assert compilerProjectExtension != null : myProject;
    if (myProjectName != null && StringUtil.isEmptyOrSpaces(myProjectName.getText())) {
        throw new ConfigurationException("Please, specify project name!");
    }
    ApplicationManager.getApplication().runWriteAction(() -> {
        // set the output path first so that handlers of RootsChanged event sent after JDK is set
        // would see the updated path
        String canonicalPath = myProjectCompilerOutput.getText();
        if (canonicalPath != null && canonicalPath.length() > 0) {
            try {
                canonicalPath = FileUtil.resolveShortWindowsName(canonicalPath);
            } catch (IOException e) {
            //file doesn't exist yet
            }
            canonicalPath = FileUtil.toSystemIndependentName(canonicalPath);
            compilerProjectExtension.setCompilerOutputUrl(VfsUtilCore.pathToUrl(canonicalPath));
        } else {
            compilerProjectExtension.setCompilerOutputPointer(null);
        }
        LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(myProject);
        LanguageLevel level = myLanguageLevelCombo.getSelectedLevel();
        if (level != null) {
            extension.setLanguageLevel(level);
        }
        extension.setDefault(myLanguageLevelCombo.isDefault());
        myProjectJdkConfigurable.apply();
        if (myProjectName != null) {
            ((ProjectEx) myProject).setProjectName(getProjectName());
            if (myDetailsComponent != null)
                myDetailsComponent.setText(getBannerSlogan());
        }
    });
}
Also used : ProjectEx(com.intellij.openapi.project.ex.ProjectEx) ConfigurationException(com.intellij.openapi.options.ConfigurationException) LanguageLevel(com.intellij.pom.java.LanguageLevel) CompilerProjectExtension(com.intellij.openapi.roots.CompilerProjectExtension) IOException(java.io.IOException) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Example 3 with ProjectEx

use of com.intellij.openapi.project.ex.ProjectEx in project intellij-community by JetBrains.

the class RenameProjectAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    LOG.assertTrue(project instanceof ProjectEx);
    final Module[] modules = ModuleManager.getInstance(project).getModules();
    final Module module = ContainerUtil.find(modules, module1 -> project.getName().equals(module1.getName()));
    Messages.showInputDialog(project, RefactoringBundle.message("enter.new.project.name"), RefactoringBundle.message("rename.project"), Messages.getQuestionIcon(), project.getName(), new RenameProjectHandler.MyInputValidator((ProjectEx) project, module));
}
Also used : ProjectEx(com.intellij.openapi.project.ex.ProjectEx) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) Module(com.intellij.openapi.module.Module)

Example 4 with ProjectEx

use of com.intellij.openapi.project.ex.ProjectEx in project intellij-community by JetBrains.

the class MemoryDiskConflictResolver method askReloadFromDisk.

boolean askReloadFromDisk(VirtualFile file, Document document) {
    String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());
    final DialogBuilder builder = new DialogBuilder();
    builder.setCenterPanel(new JLabel(message, Messages.getQuestionIcon(), SwingConstants.CENTER));
    builder.addOkAction().setText(UIBundle.message("file.cache.conflict.load.fs.changes.button"));
    builder.addCancelAction().setText(UIBundle.message("file.cache.conflict.keep.memory.changes.button"));
    builder.addAction(new AbstractAction(UIBundle.message("file.cache.conflict.show.difference.button")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            final ProjectEx project = (ProjectEx) ProjectLocator.getInstance().guessProjectForFile(file);
            FileType fileType = file.getFileType();
            String fsContent = LoadTextUtil.loadText(file).toString();
            DocumentContent content1 = DiffContentFactory.getInstance().create(project, fsContent, fileType);
            DocumentContent content2 = DiffContentFactory.getInstance().create(project, document, file);
            String title = UIBundle.message("file.cache.conflict.for.file.dialog.title", file.getPresentableUrl());
            String title1 = UIBundle.message("file.cache.conflict.diff.content.file.system.content");
            String title2 = UIBundle.message("file.cache.conflict.diff.content.memory.content");
            DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);
            request.putUserData(DiffUserDataKeys.GO_TO_SOURCE_DISABLE, true);
            DialogBuilder diffBuilder = new DialogBuilder(project);
            DiffRequestPanel diffPanel = DiffManager.getInstance().createRequestPanel(project, diffBuilder, diffBuilder.getWindow());
            diffPanel.setRequest(request);
            diffBuilder.setCenterPanel(diffPanel.getComponent());
            diffBuilder.setDimensionServiceKey("FileDocumentManager.FileCacheConflict");
            diffBuilder.addOkAction().setText(UIBundle.message("file.cache.conflict.save.changes.button"));
            diffBuilder.addCancelAction();
            diffBuilder.setTitle(title);
            if (diffBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
                builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
            }
        }
    });
    builder.setTitle(UIBundle.message("file.cache.conflict.dialog.title"));
    builder.setButtonsAlignment(SwingConstants.CENTER);
    builder.setHelpId("reference.dialogs.fileCacheConflict");
    return builder.show() == 0;
}
Also used : ProjectEx(com.intellij.openapi.project.ex.ProjectEx) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) DiffRequestPanel(com.intellij.diff.DiffRequestPanel) FileType(com.intellij.openapi.fileTypes.FileType) ActionEvent(java.awt.event.ActionEvent) DocumentContent(com.intellij.diff.contents.DocumentContent) DiffRequest(com.intellij.diff.requests.DiffRequest) SimpleDiffRequest(com.intellij.diff.requests.SimpleDiffRequest) DialogBuilder(com.intellij.openapi.ui.DialogBuilder)

Aggregations

ProjectEx (com.intellij.openapi.project.ex.ProjectEx)4 Module (com.intellij.openapi.module.Module)2 DiffRequestPanel (com.intellij.diff.DiffRequestPanel)1 DocumentContent (com.intellij.diff.contents.DocumentContent)1 DiffRequest (com.intellij.diff.requests.DiffRequest)1 SimpleDiffRequest (com.intellij.diff.requests.SimpleDiffRequest)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 FileType (com.intellij.openapi.fileTypes.FileType)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Project (com.intellij.openapi.project.Project)1 CompilerProjectExtension (com.intellij.openapi.roots.CompilerProjectExtension)1 LanguageLevelProjectExtension (com.intellij.openapi.roots.LanguageLevelProjectExtension)1 DialogBuilder (com.intellij.openapi.ui.DialogBuilder)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1 ActionEvent (java.awt.event.ActionEvent)1 IOException (java.io.IOException)1