当前位置: 首页>>代码示例>>Java>>正文


Java FileEditorState类代码示例

本文整理汇总了Java中com.intellij.openapi.fileEditor.FileEditorState的典型用法代码示例。如果您正苦于以下问题:Java FileEditorState类的具体用法?Java FileEditorState怎么用?Java FileEditorState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileEditorState类属于com.intellij.openapi.fileEditor包,在下文中一共展示了FileEditorState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: HistoryEntry

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
public HistoryEntry(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
  myFile = getVirtualFile(e);
  myProvider2State = new HashMap<FileEditorProvider, FileEditorState>();

  List providers = e.getChildren(PROVIDER_ELEMENT);
  for (final Object provider1 : providers) {
    Element _e = (Element)provider1;

    String typeId = _e.getAttributeValue(EDITOR_TYPE_ID_ATTR);
    FileEditorProvider provider = FileEditorProviderManager.getInstance().getProvider(typeId);
    if (provider == null) {
      continue;
    }
    if (Boolean.valueOf(_e.getAttributeValue(SELECTED_ATTR_VALUE))) {
      mySelectedProvider = provider;
    }

    Element stateElement = _e.getChild(STATE_ELEMENT);
    if (stateElement == null) {
      throw new InvalidDataException();
    }

    FileEditorState state = provider.readState(stateElement, project, myFile);
    putState(provider, state);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:HistoryEntry.java

示例2: writeExternal

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
/**
 * @return element that was added to the <code>element</code>.
 * Returned element has tag {@link #TAG}. Never null.
 */
public Element writeExternal(Element element, Project project) {
  Element e = new Element(TAG);
  element.addContent(e);
  e.setAttribute(FILE_ATTR, myFile.getUrl());

  for (final Map.Entry<FileEditorProvider, FileEditorState> entry : myProvider2State.entrySet()) {
    FileEditorProvider provider = entry.getKey();

    Element providerElement = new Element(PROVIDER_ELEMENT);
    if (provider.equals(mySelectedProvider)) {
      providerElement.setAttribute(SELECTED_ATTR_VALUE, Boolean.TRUE.toString());
    }
    providerElement.setAttribute(EDITOR_TYPE_ID_ATTR, provider.getEditorTypeId());
    Element stateElement = new Element(STATE_ELEMENT);
    providerElement.addContent(stateElement);
    provider.writeState(entry.getValue(), project, stateElement);

    e.addContent(providerElement);
  }

  return e;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:HistoryEntry.java

示例3: readState

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@NotNull
@Override
public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
  String themeName = sourceElement.getAttributeValue(THEME_NAME);
  String styleName = sourceElement.getAttributeValue(STYLE_NAME);

  Float proportion = null;
  try {
    String proportionString = sourceElement.getAttributeValue(PROPORTION);
    if (proportionString != null) {
      proportion = Float.parseFloat(proportionString);
    }
  } catch (NumberFormatException e) {
    // ignore
  }

  return new ThemeEditorState(themeName, styleName, proportion);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ThemeEditorProvider.java

示例4: writeState

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@Override
public void writeState(@NotNull FileEditorState state, @NotNull Project project, @NotNull Element targetElement) {
  if (!(state instanceof ThemeEditorState)) {
    return;
  }

  ThemeEditorState editorState = (ThemeEditorState) state;
  if (editorState.getThemeName() != null) {
    targetElement.setAttribute(THEME_NAME, editorState.getThemeName());
  }

  if (editorState.getSubStyleName() != null) {
    targetElement.setAttribute(STYLE_NAME, editorState.getSubStyleName());
  }

  targetElement.setAttribute(PROPORTION, Float.toString(editorState.getProportion()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ThemeEditorProvider.java

示例5: writeState

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@Override
public void writeState(@NotNull final FileEditorState _state, @NotNull final Project project, @NotNull final Element element) {
  super.writeState(_state, project, element);

  TextEditorState state = (TextEditorState)_state;

  // Foldings
  CodeFoldingState foldingState = state.getFoldingState();
  if (foldingState != null) {
    Element e = new Element(FOLDING_ELEMENT);
    try {
      CodeFoldingManager.getInstance(project).writeFoldingState(foldingState, e);
    }
    catch (WriteExternalException e1) {
      //ignore
    }
    element.addContent(e);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:PsiAwareTextEditorProvider.java

示例6: readState

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@NotNull
@Override
public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
  Element child = sourceElement.getChild(FIRST_EDITOR);
  FileEditorState firstState = null;
  if (child != null) {
    firstState = myFirstProvider.readState(child, project, file);
  }
  child = sourceElement.getChild(SECOND_EDITOR);
  FileEditorState secondState = null;
  if (child != null) {
    secondState = mySecondProvider.readState(child, project, file);
  }

  final Attribute attribute = sourceElement.getAttribute(SPLIT_LAYOUT);

  final String layoutName;
  if (attribute != null) {
    layoutName = attribute.getValue();
  }
  else {
    layoutName = null;
  }

  return new SplitFileEditor.MyFileEditorState(layoutName, firstState, secondState);
}
 
开发者ID:asciidoctor,项目名称:asciidoctor-intellij-plugin,代码行数:27,代码来源:SplitTextEditorProvider.java

示例7: writeState

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@Override
public void writeState(@NotNull FileEditorState state, @NotNull Project project, @NotNull Element targetElement) {
  if (!(state instanceof SplitFileEditor.MyFileEditorState)) {
    return;
  }
  final SplitFileEditor.MyFileEditorState compositeState = (SplitFileEditor.MyFileEditorState)state;

  Element child = new Element(FIRST_EDITOR);
  if (compositeState.getFirstState() != null) {
    myFirstProvider.writeState(compositeState.getFirstState(), project, child);
    targetElement.addContent(child);
  }

  child = new Element(SECOND_EDITOR);
  if (compositeState.getSecondState() != null) {
    mySecondProvider.writeState(compositeState.getSecondState(), project, child);
    targetElement.addContent(child);
  }

  if (compositeState.getSplitLayout() != null) {
    targetElement.setAttribute(SPLIT_LAYOUT, compositeState.getSplitLayout());
  }
}
 
开发者ID:asciidoctor,项目名称:asciidoctor-intellij-plugin,代码行数:24,代码来源:SplitTextEditorProvider.java

示例8: createHeavy

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@Nonnull
public static HistoryEntry createHeavy(@Nonnull Project project,
                                       @Nonnull VirtualFile file,
                                       @Nonnull FileEditorProvider[] providers,
                                       @Nonnull FileEditorState[] states,
                                       @Nonnull FileEditorProvider selectedProvider) {
  if (project.isDisposed()) return createLight(file, providers, states, selectedProvider);

  Disposable disposable = Disposer.newDisposable();
  VirtualFilePointer pointer = VirtualFilePointerManager.getInstance().create(file, disposable, null);

  HistoryEntry entry = new HistoryEntry(pointer, selectedProvider, disposable);
  for (int i = 0; i < providers.length; i++) {
    FileEditorProvider provider = providers[i];
    FileEditorState state = states[i];
    if (provider != null && state != null) {
      entry.putState(provider, state);
    }
  }
  return entry;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:HistoryEntry.java

示例9: writeExternal

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
/**
 * @return element that was added to the <code>element</code>.
 * Returned element has tag {@link #TAG}. Never null.
 */
public Element writeExternal(Element element, Project project) {
  Element e = new Element(TAG);
  element.addContent(e);
  e.setAttribute(FILE_ATTR, myFilePointer.getUrl());

  for (final Map.Entry<FileEditorProvider, FileEditorState> entry : myProvider2State.entrySet()) {
    FileEditorProvider provider = entry.getKey();

    Element providerElement = new Element(PROVIDER_ELEMENT);
    if (provider.equals(mySelectedProvider)) {
      providerElement.setAttribute(SELECTED_ATTR_VALUE, Boolean.TRUE.toString());
    }
    providerElement.setAttribute(EDITOR_TYPE_ID_ATTR, provider.getEditorTypeId());
    Element stateElement = new Element(STATE_ELEMENT);
    providerElement.addContent(stateElement);
    provider.writeState(entry.getValue(), project, stateElement);

    e.addContent(providerElement);
  }

  return e;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:HistoryEntry.java

示例10: readState

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@Override
@Nonnull
public FileEditorState readState(@Nonnull final Element element, @Nonnull final Project project, @Nonnull final VirtualFile file) {
  final TextEditorState state = (TextEditorState)super.readState(element, project, file);

  // Foldings
  Element child = element.getChild(FOLDING_ELEMENT);
  Document document = FileDocumentManager.getInstance().getCachedDocument(file);
  if (child != null) {
    if (document == null) {
      final Element detachedStateCopy = child.clone();
      state.setDelayedFoldState(() -> {
        Document document1 = FileDocumentManager.getInstance().getCachedDocument(file);
        return document1 == null ? null : CodeFoldingManager.getInstance(project).readFoldingState(detachedStateCopy, document1);
      });
    }
    else {
      //PsiDocumentManager.getInstance(project).commitDocument(document);
      state.setFoldingState(CodeFoldingManager.getInstance(project).readFoldingState(child, document));
    }
  }
  return state;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:PsiAwareTextEditorProvider.java

示例11: writeState

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@Override
public void writeState(@Nonnull final FileEditorState _state, @Nonnull final Project project, @Nonnull final Element element) {
  super.writeState(_state, project, element);

  TextEditorState state = (TextEditorState)_state;

  // Foldings
  CodeFoldingState foldingState = state.getFoldingState();
  if (foldingState != null) {
    Element e = new Element(FOLDING_ELEMENT);
    try {
      CodeFoldingManager.getInstance(project).writeFoldingState(foldingState, e);
    }
    catch (WriteExternalException e1) {
      //ignore
    }
    element.addContent(e);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:PsiAwareTextEditorProvider.java

示例12: canBeMergedWith

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@Override
public boolean canBeMergedWith(FileEditorState otherState, FileEditorStateLevel level) {
  if (!(otherState instanceof TextEditorState)) return false;
  TextEditorState other = (TextEditorState)otherState;
  return level == FileEditorStateLevel.NAVIGATION
         && CARETS != null && CARETS.length == 1
         && other.CARETS != null && other.CARETS.length == 1
         && Math.abs(CARETS[0].LINE - other.CARETS[0].LINE) < MIN_CHANGE_DISTANCE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:TextEditorState.java

示例13: currentStateAsHistoryEntry

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@NotNull
public HistoryEntry currentStateAsHistoryEntry() {
  final FileEditor[] editors = getEditors();
  final FileEditorState[] states = new FileEditorState[editors.length];
  for (int j = 0; j < states.length; j++) {
    states[j] = editors[j].getState(FileEditorStateLevel.FULL);
    LOG.assertTrue(states[j] != null);
  }
  final int selectedProviderIndex = ArrayUtil.find(editors, getSelectedEditor());
  LOG.assertTrue(selectedProviderIndex != -1);
  final FileEditorProvider[] providers = getProviders();
  return new HistoryEntry(getFile(), providers, states, providers[selectedProviderIndex]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:EditorWithProviderComposite.java

示例14: setState

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
@Override
public void setState(@NotNull FileEditorState state) {
  TextEditor textEditor = getTextEditor();
  if (textEditor != null && state instanceof TextEditorState) {
    textEditor.setState(state);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:BaseRemoteFileEditor.java

示例15: restore

import com.intellij.openapi.fileEditor.FileEditorState; //导入依赖的package包/类
private boolean restore(EditorAndState pair) {
  if (myEditor == null || pair == null || pair.getEditor() == null) {
    return false;
  }

  // we cannot simply compare editors here because of the following scenario:
  // 1. make changes in editor for file A
  // 2. move caret
  // 3. close editor
  // 4. re-open editor for A via Ctrl-E
  // 5. undo -> position is not affected, because instance created in step 4 is not the same!!!
  if (!myEditor.getClass().equals(pair.getEditor().getClass())) {
    return false;
  }

  // If current editor state isn't equals to remembered state then
  // we have to try to restore previous state. But sometime it's
  // not possible to restore it. For example, it's not possible to
  // restore scroll proportion if editor doesn not have scrolling any more.
  FileEditorState currentState = myEditor.getState(FileEditorStateLevel.UNDO);
  if (currentState.equals(pair.getState())) {
    return false;
  }

  myEditor.setState(pair.getState());
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:UndoRedo.java


注:本文中的com.intellij.openapi.fileEditor.FileEditorState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。