2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.uiDesigner
.editor
;
18 import com
.intellij
.openapi
.application
.ex
.ApplicationManagerEx
;
19 import com
.intellij
.openapi
.diagnostic
.Logger
;
20 import com
.intellij
.openapi
.fileEditor
.FileEditor
;
21 import com
.intellij
.openapi
.fileEditor
.FileEditorPolicy
;
22 import com
.intellij
.openapi
.fileEditor
.FileEditorProvider
;
23 import com
.intellij
.openapi
.fileEditor
.FileEditorState
;
24 import com
.intellij
.openapi
.fileTypes
.FileTypeManager
;
25 import com
.intellij
.openapi
.fileTypes
.StdFileTypes
;
26 import com
.intellij
.openapi
.module
.ModuleUtil
;
27 import com
.intellij
.openapi
.project
.Project
;
28 import com
.intellij
.openapi
.util
.Disposer
;
29 import com
.intellij
.openapi
.vfs
.VirtualFile
;
30 import com
.intellij
.util
.ArrayUtil
;
31 import org
.jdom
.Element
;
32 import org
.jetbrains
.annotations
.NotNull
;
34 public final class UIFormEditorProvider
implements FileEditorProvider
{
35 private static final Logger LOG
= Logger
.getInstance("#com.intellij.uiDesigner.editor.UIFormEditorProvider");
37 public boolean accept(@NotNull final Project project
, @NotNull final VirtualFile file
){
39 FileTypeManager
.getInstance().getFileTypeByFile(file
) == StdFileTypes
.GUI_DESIGNER_FORM
&&
40 !StdFileTypes
.GUI_DESIGNER_FORM
.isBinary() &&
41 ModuleUtil
.findModuleForFile(file
, project
) != null;
44 @NotNull public FileEditor
createEditor(@NotNull final Project project
, @NotNull final VirtualFile file
){
45 LOG
.assertTrue(accept(project
, file
));
46 return new UIFormEditor(project
, file
);
49 public void disposeEditor(@NotNull final FileEditor editor
){
50 Disposer
.dispose(editor
);
54 public FileEditorState
readState(@NotNull final Element element
, @NotNull final Project project
, @NotNull final VirtualFile file
){
55 //TODO[anton,vova] implement
56 return new MyEditorState(-1, ArrayUtil
.EMPTY_STRING_ARRAY
);
59 public void writeState(@NotNull final FileEditorState state
, @NotNull final Project project
, @NotNull final Element element
){
60 //TODO[anton,vova] implement
63 @NotNull public String
getEditorTypeId(){
67 @NotNull public FileEditorPolicy
getPolicy() {
69 ApplicationManagerEx
.getApplicationEx().isInternal() ?
70 FileEditorPolicy
.PLACE_BEFORE_DEFAULT_EDITOR
: FileEditorPolicy
.HIDE_DEFAULT_EDITOR
;