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.
17 package com
.intellij
.execution
.impl
;
19 import com
.intellij
.execution
.BeforeRunTask
;
20 import com
.intellij
.execution
.BeforeRunTaskProvider
;
21 import com
.intellij
.execution
.configurations
.RunConfiguration
;
22 import com
.intellij
.openapi
.actionSystem
.DataContext
;
23 import com
.intellij
.openapi
.util
.JDOMUtil
;
24 import com
.intellij
.openapi
.util
.Key
;
25 import org
.jdom
.Attribute
;
26 import org
.jdom
.Element
;
28 import java
.util
.List
;
31 * @author Eugene Zhuravlev
34 public class UnknownBeforeRunTaskProvider
extends BeforeRunTaskProvider
<UnknownBeforeRunTaskProvider
.UnknownTask
> {
35 private final Key
<UnknownTask
> myId
;
37 public UnknownBeforeRunTaskProvider(String mirrorProviderName
) {
38 myId
= Key
.create(mirrorProviderName
);
41 public Key
<UnknownTask
> getId() {
45 public String
getDescription(RunConfiguration runConfiguration
, UnknownTask task
) {
46 return "Unknown task " + myId
.toString();
49 public boolean configureTask(RunConfiguration runConfiguration
, UnknownTask task
) {
53 public boolean executeTask(DataContext context
, RunConfiguration configuration
, UnknownTask task
) {
57 public boolean hasConfigurationButton() {
61 public UnknownTask
createTask(RunConfiguration runConfiguration
) {
62 return new UnknownTask();
65 public static final class UnknownTask
extends BeforeRunTask
{
66 private Element myConfig
;
68 public UnknownTask() {
71 public void readExternal(Element element
) {
75 public void writeExternal(Element element
) {
76 if (myConfig
!= null) {
77 element
.removeContent();
78 final List attributes
= myConfig
.getAttributes();
79 for (Object attribute
: attributes
) {
80 element
.setAttribute((Attribute
)((Attribute
)attribute
).clone());
82 for (Object child
: myConfig
.getChildren()) {
83 element
.addContent((Element
)((Element
)child
).clone());
88 public BeforeRunTask
clone() {
92 public boolean equals(Object o
) {
93 if (this == o
) return true;
94 if (o
== null || getClass() != o
.getClass()) return false;
95 if (!super.equals(o
)) return false;
97 UnknownTask that
= (UnknownTask
)o
;
99 if (!JDOMUtil
.areElementsEqual(myConfig
, that
.myConfig
)) return false;
104 public int hashCode() {
105 int result
= super.hashCode();
106 result
= 31 * result
+ (myConfig
!= null ? myConfig
.hashCode() : 0);