本文整理匯總了Java中com.intellij.openapi.fileEditor.OpenFileDescriptor類的典型用法代碼示例。如果您正苦於以下問題:Java OpenFileDescriptor類的具體用法?Java OpenFileDescriptor怎麽用?Java OpenFileDescriptor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OpenFileDescriptor類屬於com.intellij.openapi.fileEditor包,在下文中一共展示了OpenFileDescriptor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: openFileInPanel
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
/**
* 打開類文件
*
* @param filePath
* @param project
*/
public static void openFileInPanel(final String filePath, final Project project) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath);
if (file != null && file.isValid()) {
FileEditorProvider[] providers = FileEditorProviderManager.getInstance()
.getProviders(project, file);
if (providers.length != 0) {
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file);
FileEditorManager.getInstance(project).openTextEditor(descriptor, false);
}
}
}
});
}
示例2: generateFactory
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
private void generateFactory() {
String name = interfaceName.getText();
ArrayList<Parameter> parameters = new ArrayList<>();
ListModel<ConstructorParameter> model = factoryParams.getModel();
for (int index : factoryParams.getSelectedIndices()) {
ConstructorParameter parameter = model.getElementAt(index);
parameters.add(parameter.getParameter());
}
FactoryInterfaceGenerator generator = ApplicationManager.getApplication().getComponent(FactoryInterfaceGenerator.class);
PsiFile file = generator.generateFactory(project, psiFile, originalClass, name, parameters);
if (openFile.isSelected()) {
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file.getVirtualFile());
FileEditorManager.getInstance(project).openEditor(descriptor, true);
}
dispose();
}
開發者ID:jiripudil,項目名稱:intellij-nette-factory-generator,代碼行數:21,代碼來源:GenerateFactoryInterfaceDialog.java
示例3: actionPerformed
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
@Override
public void actionPerformed(AnActionEvent event) {
final Project project = event.getProject();
if (project == null) {
return;
}
VirtualFile virtualFile = event.getData(PlatformDataKeys.VIRTUAL_FILE);
if (virtualFile != null && virtualFile.isValid() && !virtualFile.isDirectory()) {
DeltaHexVirtualFile deltaHexVirtualFile = new DeltaHexVirtualFile(virtualFile);
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, deltaHexVirtualFile, 0);
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
List<FileEditor> editors = fileEditorManager.openEditor(descriptor, true);
fileEditorManager.setSelectedEditor(virtualFile, DeltaHexWindowProvider.DELTAHEX_EDITOR_TYPE_ID);
for (FileEditor fileEditor : editors) {
if (fileEditor instanceof DeltaHexFileEditor) {
((DeltaHexFileEditor) fileEditor).openFile(deltaHexVirtualFile);
}
}
}
}
示例4: actionPerformed
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
@Override
public void actionPerformed(AnActionEvent event) {
final Project project = event.getProject();
if (project == null) {
return;
}
FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(true, false, true, false, false, false);
VirtualFile virtualFile = FileChooser.chooseFile(chooserDescriptor, project, null);
if (virtualFile != null && virtualFile.isValid() && !virtualFile.isDirectory()) {
DeltaHexVirtualFile deltaHexVirtualFile = new DeltaHexVirtualFile(virtualFile);
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, deltaHexVirtualFile, 0);
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
List<FileEditor> editors = fileEditorManager.openEditor(descriptor, true);
fileEditorManager.setSelectedEditor(virtualFile, DeltaHexWindowProvider.DELTAHEX_EDITOR_TYPE_ID);
for (FileEditor fileEditor : editors) {
if (fileEditor instanceof DeltaHexFileEditor) {
((DeltaHexFileEditor) fileEditor).openFile(deltaHexVirtualFile);
}
}
}
}
示例5: openEditor
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
@Override
public Editor openEditor(final boolean requestFocus) {
final PsiFile psiFile = getFile();
final Project project = psiFile.getProject();
if (project.isDisposed()) {
return null;
}
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null || !virtualFile.isValid()) {
return null;
}
final int offset = getOffset();
if (offset < 0) {
return null;
}
return FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, virtualFile, offset), requestFocus);
}
示例6: getData
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
@Override
public Object getData(DataProvider dataProvider) {
final Navigatable navigatable = CommonDataKeys.NAVIGATABLE.getData(dataProvider);
if (navigatable != null && navigatable instanceof OpenFileDescriptor) {
final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor)navigatable;
if (openFileDescriptor.getFile().isValid()) {
return openFileDescriptor;
}
}
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataProvider);
if (element instanceof Navigatable) {
return element;
}
if (element != null) {
return EditSourceUtil.getDescriptor(element);
}
final Object selection = PlatformDataKeys.SELECTED_ITEM.getData(dataProvider);
if (selection instanceof Navigatable) {
return selection;
}
return null;
}
示例7: showTemplateBuilder
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
private void showTemplateBuilder(PsiElement initStatement, @NotNull final PsiFile file) {
initStatement = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(initStatement);
if (initStatement instanceof PyAssignmentStatement) {
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(initStatement);
final PyExpression assignedValue = ((PyAssignmentStatement)initStatement).getAssignedValue();
final PyExpression leftExpression = ((PyAssignmentStatement)initStatement).getLeftHandSideExpression();
if (assignedValue != null && leftExpression != null) {
if (replaceInitializer)
builder.replaceElement(assignedValue, myInitializer);
else
builder.replaceElement(leftExpression.getLastChild(), myIdentifier);
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) return;
final Editor editor = FileEditorManager.getInstance(file.getProject()).openTextEditor(
new OpenFileDescriptor(file.getProject(), virtualFile), true);
if (editor == null) return;
builder.run(editor, false);
}
}
}
示例8: overrideOrImplement
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
public static List<PsiGenerationInfo<PsiMethod>> overrideOrImplement(PsiClass psiClass, @NotNull PsiMethod baseMethod) throws IncorrectOperationException {
FileEditorManager fileEditorManager = FileEditorManager.getInstance(baseMethod.getProject());
List<PsiGenerationInfo<PsiMethod>> results = new ArrayList<PsiGenerationInfo<PsiMethod>>();
try {
List<PsiGenerationInfo<PsiMethod>> prototypes = convert2GenerationInfos(overrideOrImplementMethod(psiClass, baseMethod, false));
if (prototypes.isEmpty()) return null;
PsiSubstitutor substitutor = TypeConversionUtil.getSuperClassSubstitutor(baseMethod.getContainingClass(), psiClass, PsiSubstitutor.EMPTY);
PsiElement anchor = getDefaultAnchorToOverrideOrImplement(psiClass, baseMethod, substitutor);
results = GenerateMembersUtil.insertMembersBeforeAnchor(psiClass, anchor, prototypes);
return results;
}
finally {
PsiFile psiFile = psiClass.getContainingFile();
Editor editor = fileEditorManager.openTextEditor(new OpenFileDescriptor(psiFile.getProject(), psiFile.getVirtualFile()), true);
if (editor != null && !results.isEmpty()) {
results.get(0).positionCaret(editor, true);
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
}
}
示例9: invoke
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
@Override
public void invoke(@NotNull Project project, @Nullable Editor editor, @NotNull PsiFile file) {
if (!FileModificationService.getInstance().prepareFileForWrite(myClass.getContainingFile())) return;
PsiDirectory dir = file.getContainingDirectory();
try{
String name = myClass.getName();
JavaDirectoryService directoryService = JavaDirectoryService.getInstance();
PsiClass placeHolder = myClass.isInterface() ? directoryService.createInterface(dir, name) : directoryService.createClass(dir, name);
PsiClass newClass = (PsiClass)placeHolder.replace(myClass);
myClass.delete();
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, newClass.getContainingFile().getVirtualFile(), newClass.getTextOffset());
FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
}
catch(IncorrectOperationException e){
LOG.error(e);
}
}
示例10: getData
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
@Override
public Object getData(final String dataId) {
if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
if (myEditor == null) {
return null;
}
final LogicalPosition pos = myEditor.getCaretModel().getLogicalPosition();
final HyperlinkInfo info = myHyperlinks.getHyperlinkInfoByLineAndCol(pos.line, pos.column);
final OpenFileDescriptor openFileDescriptor = info instanceof FileHyperlinkInfo ? ((FileHyperlinkInfo)info).getDescriptor() : null;
if (openFileDescriptor == null || !openFileDescriptor.getFile().isValid()) {
return null;
}
return openFileDescriptor;
}
if (CommonDataKeys.EDITOR.is(dataId)) {
return myEditor;
}
if (PlatformDataKeys.HELP_ID.is(dataId)) {
return myHelpId;
}
if (LangDataKeys.CONSOLE_VIEW.is(dataId)) {
return this;
}
return null;
}
示例11: invoke
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
public static void invoke(final Project project, final MatchProvider provider) {
final List<Match> duplicates = provider.getDuplicates();
int idx = 0;
final Ref<Boolean> showAll = new Ref<Boolean>();
final String confirmDuplicatePrompt = getConfirmationPrompt(provider, duplicates);
for (final Match match : duplicates) {
final PsiFile file = match.getFile();
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null || !virtualFile.isValid()) return;
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, file)) return;
final Editor editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, virtualFile), false);
LOG.assertTrue(editor != null);
if (!match.getMatchStart().isValid() || !match.getMatchEnd().isValid()) continue;
if (replaceMatch(project, provider, match, editor, ++idx, duplicates.size(), showAll, confirmDuplicatePrompt, false)) return;
}
}
示例12: openEditorFor
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
public static Editor openEditorFor(@NotNull PsiFile file, @NotNull Project project) {
Document document = PsiDocumentManager.getInstance(project).getDocument(file);
// may return editor injected in current selection in the host editor, not for the file passed as argument
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return null;
}
if (virtualFile instanceof VirtualFileWindow) {
virtualFile = ((VirtualFileWindow)virtualFile).getDelegate();
}
Editor editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, virtualFile, -1), false);
if (editor == null || editor instanceof EditorWindow || editor.isDisposed()) return editor;
if (document instanceof DocumentWindowImpl) {
return EditorWindowImpl.create((DocumentWindowImpl)document, (EditorImpl)editor, file);
}
return editor;
}
示例13: getOpenFileDescriptor
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
@CalledInAwt
@Nullable
protected OpenFileDescriptor getOpenFileDescriptor(int offset) {
LogicalPosition position = myEditor.offsetToLogicalPosition(offset);
Pair<int[], Side> pair = transferLineFromOneside(position.line);
int offset1 = DiffUtil.getOffset(getContent1().getDocument(), pair.first[0], position.column);
int offset2 = DiffUtil.getOffset(getContent2().getDocument(), pair.first[1], position.column);
// TODO: issue: non-optimal GoToSource position with caret on deleted block for "Compare with local"
// we should transfer using calculated diff, not jump to "somehow related" position from old content's descriptor
OpenFileDescriptor descriptor1 = getContent1().getOpenFileDescriptor(offset1);
OpenFileDescriptor descriptor2 = getContent2().getOpenFileDescriptor(offset2);
if (descriptor1 == null) return descriptor2;
if (descriptor2 == null) return descriptor1;
return pair.second.select(descriptor1, descriptor2);
}
示例14: getOpenFileDescriptor
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
private static Navigatable getOpenFileDescriptor(final AbstractTestProxy proxy,
final TestConsoleProperties testConsoleProperties,
final boolean openFailureLine) {
final Project project = testConsoleProperties.getProject();
if (proxy != null) {
final Location location = proxy.getLocation(project, testConsoleProperties.getScope());
if (openFailureLine) {
return proxy.getDescriptor(location, testConsoleProperties);
}
final OpenFileDescriptor openFileDescriptor = location == null ? null : location.getOpenFileDescriptor();
if (openFileDescriptor != null && openFileDescriptor.getFile().isValid()) {
return openFileDescriptor;
}
}
return null;
}
示例15: showTemplateBuilder
import com.intellij.openapi.fileEditor.OpenFileDescriptor; //導入依賴的package包/類
private static void showTemplateBuilder(PyFunction method, @NotNull final PsiFile file) {
method = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(method);
final TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(method);
ParamHelper.walkDownParamArray(
method.getParameterList().getParameters(),
new ParamHelper.ParamVisitor() {
public void visitNamedParameter(PyNamedParameter param, boolean first, boolean last) {
builder.replaceElement(param, param.getName());
}
}
);
// TODO: detect expected return type from call site context: PY-1863
builder.replaceElement(method.getStatementList(), "return None");
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) return;
final Editor editor = FileEditorManager.getInstance(file.getProject()).openTextEditor(
new OpenFileDescriptor(file.getProject(), virtualFile), true);
if (editor == null) return;
builder.run(editor, false);
}