mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-140717 Opened form files are not opened in UI designer after restart
This commit is contained in:
@@ -148,7 +148,6 @@
|
||||
<project-components>
|
||||
<component>
|
||||
<implementation-class>com.intellij.uiDesigner.propertyInspector.DesignerToolWindowManager</implementation-class>
|
||||
<headless-implementation-class></headless-implementation-class>
|
||||
<skipForDefaultProject/>
|
||||
</component>
|
||||
<component>
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.fileEditor.*;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.project.PossiblyDumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -42,7 +43,7 @@ import java.util.ArrayList;
|
||||
* @author Anton Katilin
|
||||
* @author Vladimir Kondratyev
|
||||
*/
|
||||
public final class UIFormEditor extends UserDataHolderBase implements /*Navigatable*/FileEditor {
|
||||
public final class UIFormEditor extends UserDataHolderBase implements FileEditor, PossiblyDumbAware {
|
||||
private final VirtualFile myFile;
|
||||
private final GuiEditor myEditor;
|
||||
private UIFormEditor.MyBackgroundEditorHighlighter myBackgroundEditorHighlighter;
|
||||
@@ -156,6 +157,11 @@ public final class UIFormEditor extends UserDataHolderBase implements /*Navigata
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDumbAware() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
public boolean canNavigateTo(@NotNull final Navigatable navigatable) {
|
||||
if (navigatable instanceof ComponentNavigatable) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.fileEditor.FileEditorProvider;
|
||||
import com.intellij.openapi.fileEditor.FileEditorState;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
@@ -29,7 +30,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class UIFormEditorProvider implements FileEditorProvider {
|
||||
public final class UIFormEditorProvider implements FileEditorProvider, DumbAware {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.uiDesigner.editor.UIFormEditorProvider");
|
||||
|
||||
public boolean accept(@NotNull final Project project, @NotNull final VirtualFile file){
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.uiDesigner;
|
||||
|
||||
import com.intellij.openapi.application.PluginPathManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
|
||||
import com.intellij.openapi.fileEditor.impl.EditorWindow;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.DumbServiceImpl;
|
||||
import com.intellij.openapi.project.DumbUnawareHider;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.FileEditorManagerTestCase;
|
||||
import com.intellij.uiDesigner.designSurface.GuiEditor;
|
||||
import com.intellij.uiDesigner.editor.UIFormEditor;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class FormOpeningTest extends FileEditorManagerTestCase {
|
||||
|
||||
public void testOpenInDumbMode() throws Exception {
|
||||
|
||||
FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(getProject());
|
||||
VirtualFile file = myFixture.copyFileToProject("TestBorder.form");
|
||||
DumbServiceImpl dumbService = (DumbServiceImpl)DumbService.getInstance(getProject());
|
||||
dumbService.setDumb(true);
|
||||
try {
|
||||
FileEditor[] editors = editorManager.openFile(file, true);
|
||||
assertEquals(1, editors.length);
|
||||
assertInstanceOf(editors[0], UIFormEditor.class);
|
||||
JComponent component = getEditorComponent();
|
||||
assertInstanceOf(component, DumbUnawareHider.class);
|
||||
assertEquals(2, component.getComponentCount());
|
||||
|
||||
Component editorComponent = component.getComponents()[0];
|
||||
assertInstanceOf(editorComponent, GuiEditor.class);
|
||||
assertFalse(editorComponent.isVisible());
|
||||
|
||||
dumbService.setDumb(false);
|
||||
assertTrue(editorComponent.isVisible());
|
||||
}
|
||||
finally {
|
||||
dumbService.setDumb(false);
|
||||
}
|
||||
}
|
||||
|
||||
private JComponent getEditorComponent() {
|
||||
FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(getProject());
|
||||
EditorWindow window = editorManager.getSplitters().getCurrentWindow();
|
||||
return (JComponent)((JComponent)window.getSelectedEditor().getComponent().getComponents()[0]).getComponents()[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginPathManager.getPluginHomePath("ui-designer") + "/testData";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user