Java 类com.intellij.openapi.project.Project 实例源码

项目:educational-plugin    文件:StudyShowHintAction.java   
public void showHint(Project project) {
  Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null) {
    return;
  }
  StudyState studyState = new StudyState(StudyUtils.getSelectedStudyEditor(project));
  if (!studyState.isValid()) {
    return;
  }
  PsiFile file = PsiManager.getInstance(project).findFile(studyState.getVirtualFile());
  final Editor editor = studyState.getEditor();
  int offset = editor.getCaretModel().getOffset();
  AnswerPlaceholder answerPlaceholder = studyState.getTaskFile().getAnswerPlaceholder(offset);
  if (file == null) {
    return;
  }
  EduUsagesCollector.hintShown();

  final StudyToolWindow hintComponent = getHint(project, answerPlaceholder).getStudyToolWindow();
  hintComponent.setPreferredSize(new Dimension(400, 150));
  showHintPopUp(project, studyState, editor, hintComponent);
}
项目:educational-plugin    文件:StudyCheckUtils.java   
public static void showTestResultsToolWindow(@NotNull final Project project, @NotNull final String message) {
  ApplicationManager.getApplication().invokeLater(() -> {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow window = toolWindowManager.getToolWindow(StudyTestResultsToolWindowFactoryKt.ID);
    if (window == null) {
      toolWindowManager.registerToolWindow(StudyTestResultsToolWindowFactoryKt.ID, true, ToolWindowAnchor.BOTTOM);
      window = toolWindowManager.getToolWindow(StudyTestResultsToolWindowFactoryKt.ID);
      new StudyTestResultsToolWindowFactory().createToolWindowContent(project, window);
    }

    final Content[] contents = window.getContentManager().getContents();
    for (Content content : contents) {
      final JComponent component = content.getComponent();
      if (component instanceof ConsoleViewImpl) {
        ((ConsoleViewImpl)component).clear();
        ((ConsoleViewImpl)component).print(message, ConsoleViewContentType.ERROR_OUTPUT);
        window.setAvailable(true,null);
        window.show(null);
      }
    }
  });
}
项目:intellij-idea-plugin-connector-for-aws-lambda    文件:MessageHelper.java   
private static void showMessage(final Project project, final MessageType messageType, final String format, final Object[] args) {
    StatusBar statusBar = windowManager.getStatusBar(project);
    if(statusBar == null || statusBar.getComponent() == null){
        return;
    }
    String message = String.format(format, args);
    jbPopupFactory.createHtmlTextBalloonBuilder(message, messageType, null)
                .setFadeoutTime(7500)
                .createBalloon()
                .show(RelativePoint.getNorthEastOf(statusBar.getComponent()), Balloon.Position.atRight);

    if(messageType == MessageType.INFO){
        log.info(message);
    }
    else if(messageType == MessageType.WARNING) {
        log.warn(message);
    }
    else{
        log.debug(message);
    }
}
项目:intellij-plugin    文件:AggregateNode.java   
@Override
protected MultiMap<PsiFile, ClassNode> computeChildren(@Nullable PsiFile psiFile) {
    MultiMap<PsiFile, ClassNode> children = new MultiMap<>();
    children.putValue(aggregateRoot.getContainingFile(), new AggregateRootNode(this, aggregateRoot));
    Project project = getProject();
    if (project != null) {
        JavaPsiFacade javaPsiFacade = JavaPsiFacade.getInstance(project);
        PsiClass entityInterface = javaPsiFacade.findClass(ENTITY_INTERFACE, GlobalSearchScope.allScope(project));
        PsiClass valueObjectInterface = javaPsiFacade.findClass(VO_INTERFACE, GlobalSearchScope.allScope(project));
        if (entityInterface != null && valueObjectInterface != null) {
            for (PsiClass psiClass : psiPackage.getClasses(GlobalSearchScope.allScope(project))) {
                if (psiClass.isInheritor(entityInterface, true) && !psiClass.equals(aggregateRoot)) {
                    children.putValue(psiClass.getContainingFile(), new EntityNode(this, psiClass));
                } else if (psiClass.isInheritor(valueObjectInterface, true)) {
                    children.putValue(psiClass.getContainingFile(), new ValueObjectNode(this, psiClass));
                }
            }
        }
    }
    return children;
}
项目:hybris-integration-intellij-idea-plugin    文件:HybrisEnumLiteralItemReference.java   
@NotNull
@Override
public ResolveResult[] multiResolve(final boolean incompleteCode) {
    Project project = myElement.getProject();
    final String enumLiteralJavaModelName = myElement.getText().replaceAll("\"", "").toUpperCase();

    final PsiShortNamesCache psiShortNamesCache = PsiShortNamesCache.getInstance(project);
    final PsiField[] javaEnumLiteralFields = psiShortNamesCache.getFieldsByName(
        enumLiteralJavaModelName, GlobalSearchScope.allScope(project)
    );

    final Set<PsiField> enumFields = stream(javaEnumLiteralFields)
        .filter(literal -> literal.getParent() != null)
        .filter(literal -> literal.getParent() instanceof ClsClassImpl)
        .filter(literal -> ((ClsClassImpl) literal.getParent()).isEnum())
        .collect(Collectors.toSet());

    return PsiElementResolveResult.createResults(enumFields);
}
项目:educational-plugin    文件:EduPluginConfiguratorBase.java   
@Override
public PsiDirectory createLessonContent(@NotNull Project project, @NotNull Lesson lesson, @Nullable IdeView view, @NotNull PsiDirectory parentDirectory) {
  NewModuleAction newModuleAction = new NewModuleAction();
  String courseDirPath = parentDirectory.getVirtualFile().getPath();
  Module utilModule = ModuleManager.getInstance(project).findModuleByName(EduIntelliJNames.UTIL);
  if (utilModule == null) {
    return null;
  }
  newModuleAction.createModuleFromWizard(project, null, new AbstractProjectWizard("", project, "") {
    @Override
    public StepSequence getSequence() {
      return null;
    }

    @Override
    public ProjectBuilder getProjectBuilder() {
      return new EduLessonModuleBuilder(courseDirPath, lesson, utilModule);
    }
  });
  return parentDirectory.findSubdirectory(EduNames.LESSON + lesson.getIndex());
}
项目:AppleScript-IDEA    文件:ApplicationDictionaryImpl.java   
public ApplicationDictionaryImpl(@NotNull Project project, @NotNull XmlFile dictionaryXmlFile,
                                 @NotNull String applicationName, @Nullable File applicationBundleFile) {
  this.project = project;
  this.dictionaryFile = dictionaryXmlFile.getVirtualFile();
  readDictionaryFromXmlFile(dictionaryXmlFile);
  this.applicationName = applicationName;
  if (applicationBundleFile != null) {
    this.applicationBundleFile = applicationBundleFile;
    setIconFromBundle(applicationBundleFile);
  }
  if (StringUtil.isEmpty(dictionaryName))
    dictionaryName = this.applicationName;
  LOG.info("Dictionary [" + dictionaryName + "] for application [" + this.applicationName + "] " +
          "initialized In project[" + project.getName() + "] " + " Commands: " + dictionaryCommandMap.size() +
          ". " + "Classes: " + dictionaryClassMap.size());
}
项目:reasonml-idea-plugin    文件:BsToolWindowFactory.java   
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    BsConsole console = new BsConsole(project);
    panel.setContent(console.getComponent());

    ActionToolbar toolbar = console.createToolbar();
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true);
    toolWindow.getContentManager().addContent(content);

    // Start compiler
    BsCompiler bsc = BucklescriptProjectComponent.getInstance(project).getCompiler();
    if (bsc != null) {
        bsc.addListener(new BsOutputListener(project));
        ProcessHandler handler = bsc.getHandler();
        if (handler == null) {
            console.print("Bsb not found, check the event logs.", ERROR_OUTPUT);
        } else {
            console.attachToProcess(handler);
        }
        bsc.startNotify();
    }
}
项目:educational-plugin    文件:StudyUtils.java   
@Nullable
public static StudyToolWindow getStudyToolWindow(@NotNull final Project project) {
  if (project.isDisposed()) return null;

  ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
  if (toolWindow != null) {
    Content[] contents = toolWindow.getContentManager().getContents();
    for (Content content: contents) {
      JComponent component = content.getComponent();
      if (component != null && component instanceof StudyToolWindow) {
        return (StudyToolWindow)component;
      }
    }
  }
  return null;
}
项目:TS-IJ    文件:TSGlobalNSCallCompletionContributor.java   
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    String namespace = parameters.getPosition().getPrevSibling().getPrevSibling().getText();

    Project project = parameters.getOriginalFile().getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);

    for (TSFnDeclStmt function : functions) {
        if (function.getFunctionType() == TSFunctionType.GLOBAL)
            continue;
        if (namespace != null && !function.getNamespace().equalsIgnoreCase(namespace))
            continue;

        result.addElement(
                LookupElementBuilder.create(function.getFunctionName())
                        .withCaseSensitivity(false)
                        .withPresentableText(function.getNamespace() + "::" + function.getFunctionName())
                        .withTailText(function.getArgList())
                        .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
        );
    }
}
项目:intellij-randomness    文件:DataInsertAction.java   
/**
 * Inserts the string generated by {@link #generateString()} at the caret(s) in the editor.
 *
 * @param event the performed action
 */
@Override
public final void actionPerformed(final AnActionEvent event) {
    final Editor editor = event.getData(CommonDataKeys.EDITOR);
    if (editor == null) {
        return;
    }
    final Project project = event.getData(CommonDataKeys.PROJECT);
    final Document document = editor.getDocument();
    final CaretModel caretModel = editor.getCaretModel();

    final Runnable replaceCaretSelections = () -> caretModel.getAllCarets().forEach(caret -> {
        final int start = caret.getSelectionStart();
        final int end = caret.getSelectionEnd();

        final String string = generateString();
        final int newEnd = start + string.length();

        document.replaceString(start, end, string);
        caret.setSelection(start, newEnd);
    });

    WriteCommandAction.runWriteCommandAction(project, replaceCaretSelections);
}
项目:intellij-spring-assistant    文件:SuggestionIndexServiceImpl.java   
@Nullable
@Override
public MetadataNode findDeepestExactMatch(Project project, Module module,
    List<String> containerElements) {
  if (moduleNameToSanitisedRootSearchIndex.containsKey(module.getName())) {
    String[] pathSegments =
        containerElements.stream().flatMap(element -> stream(toPathSegments(element)))
            .toArray(String[]::new);
    MetadataNode searchStartNode = moduleNameToSanitisedRootSearchIndex.get(module.getName())
        .get(MetadataNode.sanitize(pathSegments[0]));
    if (searchStartNode != null) {
      if (pathSegments.length > 1) {
        return searchStartNode.findDeepestMatch(pathSegments, 1, true);
      }
      return searchStartNode;
    }
  }
  return null;
}
项目:idea-php-typo3-plugin    文件:IconIndex.java   
@NotNull
public static PsiElement[] getIconDefinitionElements(@NotNull Project project, @NotNull String identifier) {
    Map<VirtualFile, IconStub> iconDefinitionByIdentifier = getIconDefinitionByIdentifier(project, identifier);
    if (iconDefinitionByIdentifier.size() > 0) {
        return iconDefinitionByIdentifier
                .keySet()
                .stream()
                .map(virtualFile -> {
                    IconStub iconStub = iconDefinitionByIdentifier.get(virtualFile);
                    PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
                    return file != null ? file.findElementAt(iconStub.getTextRange().getStartOffset()) : null;
                })
                .filter(Objects::nonNull)
                .toArray(PsiElement[]::new);
    }

    return new PsiElement[0];
}
项目:Android-ORM-ASPlugin    文件:ClassEntity.java   
public void addAnnotation(Project project) {
    for (FieldEntity entity : getFieldList()) {
        entity.addAnnotation(project);
    }

    editTableAnnotation(project, tablePsiAnnotation, getSelectedEntities().size() == 0);

    PsiJavaFile javaFile = (PsiJavaFile) psiClass.getContainingFile();
    Utils.saveDocument(javaFile);

    Utils.addImport(project, javaFile, null, AormConstants.tableQName, AormConstants.columnQName);
    Utils.optimizeImport(project, psiClass);

    CodeStyleManager.getInstance(project).reformat(psiClass);
    Utils.saveDocument(psiClass.getContainingFile());
}
项目:MultiHighlight    文件:MultiHighlightAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
    final PsiFile psiFile = e.getRequiredData(CommonDataKeys.PSI_FILE);

    CommandProcessor.getInstance().executeCommand(project, () -> {
        try {
            MultiHighlightHandler.invoke(project, editor, psiFile);
        } catch (IndexNotReadyException ex) {
            DumbService.getInstance(project)
                    .showDumbModeNotification("MultiHighlight requires indices "
                            + "and cannot be performed until they are built");
        }
    }, "MultiHighlight", null);
}
项目:ValueClassGenerator    文件:ValueClass.java   
public List<PsiElement> getGeneratedPsiElements(Project project) {
    PsiClass classFromText =
            JavaPsiFacade.getInstance(project).getElementFactory().createClassFromText(
                    new ValueClass(variables, sourceClass).asString(), null);
    classFromText.setName(sourceClass.getName());

    List<PsiElement> result = new ArrayList<>();
    Stream.of(classFromText.getAllFields()).forEach(psiField -> result.add(psiField));
    Stream.of(classFromText.getInnerClasses()).forEach(psiClass -> result.add(psiClass));
    Stream.of(classFromText.getMethods()).forEach(psiClass -> result.add(psiClass)); // getMethod contains all constructors
    return result;
}
项目:json2java4idea    文件:NewClassDialog.java   
private Builder(@NotNull Project project, @Nonnull Json2JavaBundle bundle) {
    this.project = project;
    this.bundle = bundle;
    this.nameValidator = new NullValidator();
    this.jsonValidator = new NullValidator();
    this.actionListener = new ActionListener() {
    };
}
项目:CodeGen    文件:DBGeneratorAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
    Project project = PsiUtil.getProject(e);
    DumbService dumbService = DumbService.getInstance(project);
    if (dumbService.isDumb()) {
        dumbService.showDumbModeNotification(CodeGenBundle.message("codegen.plugin.is.not.available.during.indexing"));
        return;
    }

    Iterator<DbElement> iterator = DatabaseView.getSelectedElements(e.getDataContext(), DbElement.class).iterator();

    List<DbTable> tables = new ArrayList<>();
    while (iterator.hasNext()) {
        DbElement table = iterator.next();
        if (table instanceof DbTable) {
            tables.add((DbTable) table);
        }
    }

    ColumnEditorFrame frame = new ColumnEditorFrame();
    frame.newColumnEditorByDb(new IdeaContext(project), tables);
    frame.setSize(800, 550);
    frame.setLocationRelativeTo(null);
    frame.setAlwaysOnTop(true);
    frame.setResizable(false);
    frame.setVisible(true);
}
项目:IntelliJ-codestyle-sync    文件:OnActionSync.java   
@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null) {
        return;
    }
    new CodeStyleManager(project.getBasePath()).sync();
}
项目:DeBrug    文件:VisualisatieToestanden.java   
void TransformToPng() {
  Project project = MPSDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
  String filegv = ProjectBaseDirectory.getInstance(project).getBaseDir().getCanonicalPath() + "/graphviz/visualiser.gv";
  String filepng = ProjectBaseDirectory.getInstance(project).getBaseDir().getCanonicalPath() + "/graphviz/visualiser.png";
  String[] commandarray = {"/bin/sh", "-c", "neato " + "-Tpng " + filegv + " > " + filepng};
  System.out.println("Running command");
  String result = ExecuteCommand(commandarray);
  System.out.println("Command executed with result" + result);
}
项目:yii2support    文件:UnusedParameterLocalQuickFix.java   
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    PsiElement item = descriptor.getPsiElement();

    PsiElement context = item.getContext();
    if (context instanceof ArrayCreationExpression) {
        ArrayCreationExpression params = (ArrayCreationExpression) item.getParent();

        PsiUtil.deleteArrayElement(item);

        if (!params.getHashElements().iterator().hasNext()) {
            if (params.getPrevSibling() instanceof PsiWhiteSpace) {
                params.getPrevSibling().delete();
            }
            params.getPrevSibling().delete();
            params.delete();
        }
    }
    if (context instanceof ParameterList && context.getParent() instanceof FunctionReference) {
        FunctionReference functionReference = (FunctionReference) context.getParent();
        if (functionReference.getName() != null && functionReference.getName().equals("compact")) {
            PsiUtil.deleteFunctionParam(item);

            if (functionReference.getParameters().length == 0) {
                PsiUtil.deleteFunctionParam(functionReference);
            }
        }
    }
}
项目:jfrog-idea-plugin    文件:SelectAllCheckbox.java   
void setListeners(@NotNull Project project, @NotNull Map<FilterType, Boolean> selectionMap, @NotNull List<SelectionCheckbox> checkBoxMenuItems) {
    removeListeners();
    addItemListener(e -> {
        selectionMap.entrySet().forEach(booleanEntry -> booleanEntry.setValue(isSelected()));

        for (JBCheckBoxMenuItem i : checkBoxMenuItems) {
            if (i.isSelected() != isSelected()) {
                i.doClick(0);
            }
        }
        MessageBus messageBus = project.getMessageBus();
        messageBus.syncPublisher(Events.ON_SCAN_FILTER_CHANGE).update();
    });
}
项目:MultiHighlight    文件:MultiHighlightHandler.java   
private static void searchSelection(Editor editor, Project project) {
    final SelectionModel selectionModel = editor.getSelectionModel();
    if (!selectionModel.hasSelection()) {
        selectionModel.selectWordAtCaret(false);
    }

    final String text = selectionModel.getSelectedText();
    if (text == null) {
        return;
    }

    if (editor instanceof EditorWindow) {
        // highlightUsages selection in the whole editor, not injected fragment only
        editor = ((EditorWindow) editor).getDelegate();
    }

    EditorSearchSession oldSearch = EditorSearchSession.get(editor);
    if (oldSearch != null) {
        if (oldSearch.hasMatches()) {
            String oldText = oldSearch.getTextInField();
            if (!oldSearch.getFindModel().isRegularExpressions()) {
                oldText = StringUtil.escapeToRegexp(oldText);
                oldSearch.getFindModel().setRegularExpressions(true);
            }

            String newText = oldText + '|' + StringUtil.escapeToRegexp(text);
            oldSearch.setTextInField(newText);
            return;
        }
    }

    EditorSearchSession.start(editor, project).getFindModel().setRegularExpressions(false);
}
项目:idea-php-typo3-plugin    文件:NewExtensionFileAction.java   
public void update(AnActionEvent event) {
    Project project = getEventProject(event);
    if (project == null) {
        this.setStatus(event, false);
        return;
    }

    if (DumbService.isDumb(project)) {
        this.setStatus(event, false);
        return;
    }

    this.setStatus(event, ExtensionUtility.getExtensionDirectory(event) != null);
}
项目:educational-plugin    文件:StudyRefreshTaskFileAction.java   
private static void showBalloon(@NotNull final Project project, @NotNull final MessageType messageType) {
  BalloonBuilder balloonBuilder =
    JBPopupFactory.getInstance().createHtmlTextBalloonBuilder("You can start again now", messageType, null);
  final Balloon balloon = balloonBuilder.createBalloon();
  StudyEditor selectedStudyEditor = StudyUtils.getSelectedStudyEditor(project);
  assert selectedStudyEditor != null;
  balloon.show(StudyUtils.computeLocation(selectedStudyEditor.getEditor()), Balloon.Position.above);
  Disposer.register(project, balloon);
}
项目:Android-ORM-ASPlugin    文件:Utils.java   
public static PsiDirectory getSubDir(Project project, VirtualFile vf) {
    if (vf.isDirectory()) {
        return PsiManager.getInstance(project).findDirectory(vf);
    } else {
        return getSubDir(project, vf.getParent());
    }
}
项目:educational-plugin    文件:CCStepicConnector.java   
private static int postModule(int courseId, int position, @NotNull final String title, Project project) {
  final HttpPost request = new HttpPost(EduStepicNames.STEPIC_API_URL + "/sections");
  final StepicWrappers.Section section = new StepicWrappers.Section();
  section.setCourse(courseId);
  section.setTitle(title);
  section.setPosition(position);
  final StepicWrappers.SectionWrapper sectionContainer = new StepicWrappers.SectionWrapper();
  sectionContainer.setSection(section);
  String requestBody = new Gson().toJson(sectionContainer);
  request.setEntity(new StringEntity(requestBody, ContentType.APPLICATION_JSON));

  try {
    final CloseableHttpClient client = EduStepicAuthorizedClient.getHttpClient();
    if (client == null) return -1;
    final CloseableHttpResponse response = client.execute(request);
    final HttpEntity responseEntity = response.getEntity();
    final String responseString = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
    final StatusLine line = response.getStatusLine();
    EntityUtils.consume(responseEntity);
    if (line.getStatusCode() != HttpStatus.SC_CREATED) {
      LOG.error(FAILED_TITLE + responseString);
      showErrorNotification(project, FAILED_TITLE, responseString);
      return -1;
    }
    final StepicWrappers.Section
      postedSection = new Gson().fromJson(responseString, StepicWrappers.SectionContainer.class).getSections().get(0);
    return postedSection.getId();
  }
  catch (IOException e) {
    LOG.error(e.getMessage());
  }
  return -1;
}
项目:educational-plugin    文件:StudyToolWindow.java   
public void setEmptyText(@NotNull Project project) {
  if (StudyTaskManager.getInstance(project).getToolWindowMode() == StudyToolWindowMode.EDITING) {
    mySplitPane.setFirstComponent(myContentPanel);
    StudyTaskManager.getInstance(project).setTurnEditingMode(true);
  }
  setTaskText(EMPTY_TASK_TEXT, project);
}
项目:chocolate-cakephp    文件:PsiUtil.java   
@NotNull
public static Collection<PsiFile> convertVirtualFilesToPsiFiles(@NotNull Project project, @NotNull Collection<VirtualFile> files) {

    Collection<PsiFile> psiFiles = new HashSet<>();
    PsiManager psiManager = PsiManager.getInstance(project);

    for (VirtualFile file : files) {
        PsiFile psiFile = psiManager.findFile(file);
        if(psiFile != null) {
            psiFiles.add(psiFile);
        }
    }

    return psiFiles;
}
项目:educational-plugin    文件:CCCreateLesson.java   
@Override
@Nullable
protected PsiDirectory createItemDir(@NotNull final Project project, @NotNull final StudyItem item,
                                  @Nullable final IdeView view, @NotNull final PsiDirectory parentDirectory,
                                  @NotNull final Course course) {
  EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(course.getLanguageById());
  if (configurator == null) {
    return null;
  }
  return configurator.createLessonContent(project, (Lesson)item, view, parentDirectory);
}
项目:Android-ORM-ASPlugin    文件:Utils.java   
public static PsiJavaDirectoryImpl getJavaDir(Project project, VirtualFile vf) {
    PsiDirectory dir = Utils.getSubDir(project, vf);
    if (dir instanceof PsiJavaDirectoryImpl) {
        return (PsiJavaDirectoryImpl) dir;
    }
    return null;
}
项目:educational-plugin    文件:StudyUtils.java   
@Nullable
public static Editor getSelectedEditor(@NotNull final Project project) {
  final StudyEditor studyEditor = getSelectedStudyEditor(project);
  if (studyEditor != null) {
    return studyEditor.getEditor();
  }
  return null;
}
项目:hybris-integration-intellij-idea-plugin    文件:BpDiagramDataModel.java   
public BpDiagramDataModel(final Project project, final BpGraphNode rootBpGraphNode) {
    super(project, ServiceManager.getService(BpDiagramProvider.class));

    for (BpGraphNode bpGraphNode : rootBpGraphNode.getNodesMap().values()) {
        final BpDiagramFileNode bpDiagramFileNode = new BpDiagramFileNode(bpGraphNode);

        this.nodesMap.put(bpGraphNode.getGenericAction().getId(), bpDiagramFileNode);
    }
}
项目:roc-completion    文件:RocDocumentationProvider.java   
@Nullable
@Override
public String fetchExternalDocumentation(Project project, PsiElement psiElement, List<String> list)
{
    if (!CompletionPreloader.isRocConfigFile(psiElement.getContainingFile()))
    {
        return null;
    }

    String qualifiedName = list.get(0);
    SettingContainer completions = CompletionPreloader.getCompletions();

    Setting setting = completions.getSetting(qualifiedName);

    if (setting == null)
    {
        return "Just a container. Try looking at the sub-nodes instead.";
    }

    String description = escapeHtml(setting.getDescription());
    String descriptionTemplate = "<p>%s</p>";
    String documentation = String.format(descriptionTemplate, description);

    String defaultValue = escapeHtml(setting.getDefaultValue());

    if (defaultValue.length() == 0)
    {
        return documentation;
    }

    String defaultValueTemplate = "<p>Default value: %s</p>";
    String defaultValueDocumentation = String.format(defaultValueTemplate, defaultValue);

    return documentation.concat(defaultValueDocumentation);
}
项目:json2java4idea    文件:PsiTypeConverterTest.java   
@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    final Project project = getProject();
    final PsiManager psiManager = PsiManager.getInstance(project);
    underTest = new PsiTypeConverter(psiManager);
}
项目:educational-plugin    文件:CCSubtaskEditorNotificationProvider.java   
public SwitchSubtaskPopupStep(@Nullable String title,
                              List<Integer> values,
                              @NotNull TaskWithSubtasks task,
                              @NotNull Project project) {
  super(title, values);
  myTask = task;
  myProject = project;
}
项目:json2java4idea    文件:ProjectModule.java   
@Override
public void configure(@Nonnull Binder binder) {
    binder.bind(Project.class)
            .toInstance(project);

    // Binding InputValidator related classes
    binder.bind(InputValidator.class)
            .annotatedWith(Name.NAME_VALIDATOR.annotation())
            .to(NameValidator.class);
    binder.bind(InputValidator.class)
            .annotatedWith(Name.JSON_VALIDATOR.annotation())
            .to(JsonValidator.class);
    binder.bind(InputValidator.class)
            .annotatedWith(Name.CLASS_PREFIX_VALIDATOR.annotation())
            .to(ClassPrefixValidator.class);
    binder.bind(InputValidator.class)
            .annotatedWith(Name.CLASS_SUFFIX_VALIDATOR.annotation())
            .to(ClassSuffixValidator.class);

    // Binding NamePolicy classes
    binder.bind(NamePolicy.class)
            .annotatedWith(Name.CLASS_NAME_POLICY.annotation())
            .to(ClassNamePolicy.class);
    binder.bind(NamePolicy.class)
            .annotatedWith(Name.FIELD_NAME_POLICY.annotation())
            .to(FieldNamePolicy.class);
    binder.bind(NamePolicy.class)
            .annotatedWith(Name.METHOD_NAME_POLICY.annotation())
            .to(MethodNamePolicy.class);
    binder.bind(NamePolicy.class)
            .annotatedWith(Name.PARAMETER_NAME_POLICY.annotation())
            .to(ParameterNamePolicy.class);

    // Binding other classes
    binder.bind(Json2JavaBundle.class)
            .toInstance(Json2JavaBundle.getInstance());

    // Installation factory modules
    binder.install(new FactoryModuleBuilder().build(CommandActionFactory.class));
}
项目:educational-plugin    文件:CCPushLesson.java   
@Override
public void update(@NotNull AnActionEvent e) {
  e.getPresentation().setEnabledAndVisible(false);
  final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
  final Project project = e.getData(CommonDataKeys.PROJECT);
  if (view == null || project == null) {
    return;
  }
  final Course course = StudyTaskManager.getInstance(project).getCourse();
  if (course == null || !(course instanceof RemoteCourse)) {
    return;
  }
  if (!course.getCourseMode().equals(CCUtils.COURSE_MODE)) return;
  final PsiDirectory[] directories = view.getDirectories();
  if (directories.length == 0 || directories.length > 1) {
    return;
  }

  final PsiDirectory lessonDir = directories[0];
  if (lessonDir == null || !lessonDir.getName().contains("lesson")) {
    return;
  }
  final Lesson lesson = course.getLesson(lessonDir.getName());
  if (lesson != null && ((RemoteCourse)course).getId() > 0) {
    e.getPresentation().setEnabledAndVisible(true);
    if (lesson.getId() <= 0) {
      e.getPresentation().setText("Upload Lesson to Stepik");
    }
  }
}
项目:educational-plugin    文件:CCPushCourse.java   
@Override
public void update(@NotNull AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  Project project = e.getProject();
  presentation.setEnabledAndVisible(project != null && CCUtils.isCourseCreator(project));
  if (project != null) {
    final Course course = StudyTaskManager.getInstance(project).getCourse();
    if (course instanceof RemoteCourse) {
      presentation.setText("Update Course on Stepik");
    }
  }
}
项目:AppleScript-IDEA    文件:LoadDictionaryAction.java   
public void actionPerformed(final AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
  if (view == null) return;
  final PsiDirectory[] directories = view.getDirectories();

  PsiDirectory currentDirectory = directories.length > 0 ? directories[0] : null;
  final Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) return;

  VirtualFile directoryFile = currentDirectory != null ? currentDirectory.getVirtualFile() : project.getBaseDir();
  openLoadDirectoryDialog(project, directoryFile, null);
}