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.
19 package org
.intellij
.images
.options
.impl
;
21 import com
.intellij
.openapi
.util
.JDOMExternalizable
;
22 import com
.intellij
.openapi
.util
.JDOMExternalizer
;
23 import org
.intellij
.images
.options
.ExternalEditorOptions
;
24 import org
.jdom
.Element
;
26 import java
.beans
.PropertyChangeSupport
;
29 * External editor options.
31 * @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
33 final class ExternalEditorOptionsImpl
implements ExternalEditorOptions
, JDOMExternalizable
{
34 private final PropertyChangeSupport propertyChangeSupport
;
35 private String executablePath
;
37 public ExternalEditorOptionsImpl(PropertyChangeSupport propertyChangeSupport
) {
38 this.propertyChangeSupport
= propertyChangeSupport
;
41 public String
getExecutablePath() {
42 return executablePath
;
45 void setExecutablePath(String executablePath
) {
46 String oldValue
= this.executablePath
;
47 if (oldValue
!= null && !oldValue
.equals(executablePath
) || oldValue
== null && executablePath
!= null) {
48 this.executablePath
= executablePath
;
49 propertyChangeSupport
.firePropertyChange(ATTR_EXECUTABLE_PATH
, oldValue
, this.executablePath
);
53 public ExternalEditorOptions
clone() throws CloneNotSupportedException
{
54 return (ExternalEditorOptions
)super.clone();
57 public void inject(ExternalEditorOptions options
) {
58 setExecutablePath(options
.getExecutablePath());
61 public boolean setOption(String name
, Object value
) {
62 if (ATTR_EXECUTABLE_PATH
.equals(name
)) {
63 setExecutablePath((String
) value
);
70 public void readExternal(Element element
) {
71 executablePath
= JDOMExternalizer
.readString(element
, ATTR_EXECUTABLE_PATH
);
74 public void writeExternal(Element element
) {
75 JDOMExternalizer
.write(element
, ATTR_EXECUTABLE_PATH
, executablePath
);
78 public boolean equals(Object o
) {
82 if (!(o
instanceof ExternalEditorOptions
)) {
86 ExternalEditorOptions otherOptions
= (ExternalEditorOptions
) o
;
88 return executablePath
!= null ?
89 executablePath
.equals(otherOptions
.getExecutablePath()) :
90 otherOptions
.getExecutablePath() == null;
94 public int hashCode() {
95 return executablePath
!= null ? executablePath
.hashCode() : 0;