本文整理汇总了Java中com.intellij.openapi.fileEditor.FileEditorStateLevel类的典型用法代码示例。如果您正苦于以下问题:Java FileEditorStateLevel类的具体用法?Java FileEditorStateLevel怎么用?Java FileEditorStateLevel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileEditorStateLevel类属于com.intellij.openapi.fileEditor包,在下文中一共展示了FileEditorStateLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStateImpl
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@Override
protected TextEditorState getStateImpl(final Project project, @NotNull final Editor editor, @NotNull final FileEditorStateLevel level) {
final TextEditorState state = super.getStateImpl(project, editor, level);
// Save folding only on FULL level. It's very expensive to commit document on every
// type (caused by undo).
if(FileEditorStateLevel.FULL == level){
// Folding
if (project != null && !project.isDisposed() && !editor.isDisposed()) {
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
state.setFoldingState(CodeFoldingManager.getInstance(project).saveFoldingState(editor));
}
else {
state.setFoldingState(null);
}
}
return state;
}
示例2: invoke
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
ResourceBundleEditor bundleEditor = ResourceBundleUtil.getEditor(dataContext);
if (bundleEditor == null) {
return;
}
String propertyName = bundleEditor.getState(FileEditorStateLevel.NAVIGATION).getPropertyName();
if (propertyName == null) {
return;
}
ResourceBundle bundle = ResourceBundleUtil.getResourceBundleFromDataContext(dataContext);
if (bundle == null) {
return;
}
Messages.showInputDialog(project, PropertiesBundle.message("rename.bundle.enter.new.resource.bundle.key.name.prompt.text"),
PropertiesBundle.message("rename.resource.bundle.key.dialog.title"), Messages.getQuestionIcon(), propertyName,
new ResourceBundleKeyRenameValidator(project, bundleEditor, bundle, propertyName));
}
示例3: isAvailableOnDataContext
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
public boolean isAvailableOnDataContext(DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return false;
}
final ResourceBundle bundle = ResourceBundleUtil.getResourceBundleFromDataContext(dataContext);
if (bundle == null) {
return false;
}
final VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
ResourceBundleEditor editor = ResourceBundleUtil.getEditor(dataContext);
return (editor == null || editor.getState(FileEditorStateLevel.NAVIGATION).getPropertyName() == null /* user selected non-bundle key element */)
&& bundle.getPropertiesFiles(project).size() > 1 && (virtualFile instanceof ResourceBundleAsVirtualFile || virtualFile == null);
}
示例4: getStateImpl
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@Nonnull
@Override
protected TextEditorState getStateImpl(final Project project, @Nonnull final Editor editor, @Nonnull final FileEditorStateLevel level) {
final TextEditorState state = super.getStateImpl(project, editor, level);
// Save folding only on FULL level. It's very expensive to commit document on every
// type (caused by undo).
if (FileEditorStateLevel.FULL == level) {
// Folding
if (project != null && !project.isDisposed() && !editor.isDisposed() && project.isInitialized()) {
state.setFoldingState(CodeFoldingManager.getInstance(project).saveFoldingState(editor));
}
else {
state.setFoldingState(null);
}
}
return state;
}
示例5: canBeMergedWith
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的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;
}
示例6: currentStateAsHistoryEntry
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的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]);
}
示例7: restore
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的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;
}
示例8: setUp
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
myHistory = new IdeDocumentHistoryImpl(getProject(), EditorFactory.getInstance(), new EditorManager(), VirtualFileManager.getInstance(), CommandProcessor.getInstance(), new Mock.MyToolWindowManager()) {
@Override
protected Pair<FileEditor,FileEditorProvider> getSelectedEditor() {
return Pair.create ((FileEditor)mySelectedEditor, myProvider);
}
@Override
protected void executeCommand(Runnable runnable, String name, Object groupId) {
myHistory.onCommandStarted();
runnable.run();
myHistory.onSelectionChanged();
myHistory.onCommandFinished(groupId);
}
};
mySelectedEditor = new Mock.MyFileEditor() {
@Override
@NotNull
public FileEditorState getState(@NotNull FileEditorStateLevel level) {
return myEditorState;
}
@Override
public void setState(@NotNull FileEditorState state) {
myEditorState = state;
}
};
mySelectedFile = new Mock.MyVirtualFile();
myEditorState = new MyState(false, "start");
myProvider = new Mock.MyFileEditorProvider() {
@Override
@NotNull
public String getEditorTypeId() {
return "EditorType";
}
};
}
示例9: getState
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@NotNull
public FileEditorState getState(@NotNull FileEditorStateLevel level) {
ImageZoomModel zoomModel = imageEditor.getZoomModel();
return new ImageFileEditorState(
imageEditor.isTransparencyChessboardVisible(),
imageEditor.isGridVisible(),
zoomModel.getZoomFactor());
}
示例10: getState
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@NotNull
@Override
public FileEditorState getState(@NotNull FileEditorStateLevel fileEditorStateLevel) {
ThemeEditorStyle theme = myComponent.getSelectedTheme();
ThemeEditorStyle subStyle = myComponent.getCurrentSubStyle();
return new ThemeEditorState(theme == null ? null : theme.getName(),
subStyle == null ? null : subStyle.getName(),
myComponent.getProportion());
}
示例11: currentStateAsHistoryEntry
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
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]);
}
示例12: isAvailableOnDataContext
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@Override
public boolean isAvailableOnDataContext(DataContext dataContext) {
ResourceBundleEditor editor = ResourceBundleUtil.getEditor(dataContext);
if (editor == null) {
return false;
}
return editor.getState(FileEditorStateLevel.NAVIGATION).getPropertyName() != null;
}
示例13: getState
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@Override
@NotNull
public FileEditorState getState(@NotNull final FileEditorStateLevel ignored)
{
final Document document = FileDocumentManager.getInstance().getCachedDocument(myFile);
long modificationStamp = document != null ? document.getModificationStamp() : myFile.getModificationStamp();
final ArrayList<RadComponent> selection = FormEditingUtil.getSelectedComponents(myEditor);
final String[] ids = new String[selection.size()];
for(int i = ids.length - 1; i >= 0; i--)
{
ids[i] = selection.get(i).getId();
}
return new MyEditorState(modificationStamp, ids);
}
示例14: getEditorState
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@Nonnull
TextEditorState getEditorState(@Nonnull FileEditorStateLevel level) {
ApplicationManager.getApplication().assertIsDispatchThread();
TextEditorState state = myProvider.getStateImpl(myProject, myEditor, level);
if (!myLoadingFinished.isDone() && myDelayedState != null) {
state.setDelayedFoldState(myDelayedState::getFoldingState);
}
return state;
}
示例15: currentStateAsHistoryEntry
import com.intellij.openapi.fileEditor.FileEditorStateLevel; //导入依赖的package包/类
@Nonnull
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 HistoryEntry.createLight(getFile(), providers, states, providers[selectedProviderIndex]);
}