update copyrights
[fedora-idea.git] / platform / lang-impl / src / com / intellij / execution / impl / UnknownBeforeRunTaskProvider.java
blob3eb2f80d7b3753c89c0f35f1e8abbd5040792147
1 /*
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;
30 /**
31 * @author Eugene Zhuravlev
32 * Date: Sep 15, 2009
34 public class UnknownBeforeRunTaskProvider implements BeforeRunTaskProvider<UnknownBeforeRunTaskProvider.UnknownTask>{
35 private final Key<UnknownTask> myId;
37 public UnknownBeforeRunTaskProvider(String mirrorProviderName) {
38 myId = Key.create(mirrorProviderName);
41 public Key<UnknownTask> getId() {
42 return myId;
45 public String getDescription(RunConfiguration runConfiguration, UnknownTask task) {
46 return "Unknown task " + myId.toString();
49 public void configureTask(RunConfiguration runConfiguration, UnknownTask task) {
52 public boolean executeTask(DataContext context, RunConfiguration configuration, UnknownTask task) {
53 return true;
56 public boolean hasConfigurationButton() {
57 return false;
60 public UnknownTask createTask(RunConfiguration runConfiguration) {
61 return new UnknownTask();
64 public static final class UnknownTask extends BeforeRunTask {
65 private Element myConfig;
67 public UnknownTask() {
70 public void readExternal(Element element) {
71 myConfig = element;
74 public void writeExternal(Element element) {
75 if (myConfig != null) {
76 element.removeContent();
77 final List attributes = myConfig.getAttributes();
78 for (Object attribute : attributes) {
79 element.setAttribute((Attribute)((Attribute)attribute).clone());
81 for (Object child : myConfig.getChildren()) {
82 element.addContent((Element)((Element)child).clone());
87 public BeforeRunTask clone() {
88 return super.clone();
91 public boolean equals(Object o) {
92 if (this == o) return true;
93 if (o == null || getClass() != o.getClass()) return false;
94 if (!super.equals(o)) return false;
96 UnknownTask that = (UnknownTask)o;
98 if (!JDOMUtil.areElementsEqual(myConfig, that.myConfig)) return false;
100 return true;
103 public int hashCode() {
104 int result = super.hashCode();
105 result = 31 * result + (myConfig != null ? myConfig.hashCode() : 0);
106 return result;