本文整理匯總了Java中com.intellij.openapi.project.Project類的典型用法代碼示例。如果您正苦於以下問題:Java Project類的具體用法?Java Project怎麽用?Java Project使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Project類屬於com.intellij.openapi.project包,在下文中一共展示了Project類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showHint
import com.intellij.openapi.project.Project; //導入依賴的package包/類
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);
}
示例2: showTestResultsToolWindow
import com.intellij.openapi.project.Project; //導入依賴的package包/類
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);
}
}
});
}
示例3: showMessage
import com.intellij.openapi.project.Project; //導入依賴的package包/類
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);
}
}
示例4: computeChildren
import com.intellij.openapi.project.Project; //導入依賴的package包/類
@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;
}
示例5: multiResolve
import com.intellij.openapi.project.Project; //導入依賴的package包/類
@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);
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:20,代碼來源:HybrisEnumLiteralItemReference.java
示例6: createLessonContent
import com.intellij.openapi.project.Project; //導入依賴的package包/類
@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());
}
示例7: ApplicationDictionaryImpl
import com.intellij.openapi.project.Project; //導入依賴的package包/類
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());
}
示例8: createToolWindowContent
import com.intellij.openapi.project.Project; //導入依賴的package包/類
@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();
}
}
示例9: getStudyToolWindow
import com.intellij.openapi.project.Project; //導入依賴的package包/類
@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;
}
示例10: addCompletions
import com.intellij.openapi.project.Project; //導入依賴的package包/類
@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)
);
}
}
示例11: actionPerformed
import com.intellij.openapi.project.Project; //導入依賴的package包/類
/**
* 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);
}
示例12: findDeepestExactMatch
import com.intellij.openapi.project.Project; //導入依賴的package包/類
@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;
}
示例13: getIconDefinitionElements
import com.intellij.openapi.project.Project; //導入依賴的package包/類
@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];
}
示例14: addAnnotation
import com.intellij.openapi.project.Project; //導入依賴的package包/類
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());
}
示例15: actionPerformed
import com.intellij.openapi.project.Project; //導入依賴的package包/類
@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);
}