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
.ui
;
21 import com
.intellij
.openapi
.util
.text
.StringUtil
;
22 import org
.jetbrains
.annotations
.NonNls
;
27 * Thumbnail component.
29 * @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
31 public class ThumbnailComponent
extends JComponent
{
33 private static final String FORMAT_PROP
= "format";
35 private static final String FILE_SIZE_PROP
= "fileSize";
37 private static final String FILE_NAME_PROP
= "fileName";
39 private static final String DIRECTORY_PROP
= "directory";
41 private static final String IMAGES_COUNT_PROP
= "imagesCount";
48 private static final String uiClassID
= "ThumbnailComponentUI";
51 UIManager
.getDefaults().put(uiClassID
, ThumbnailComponentUI
.class.getName());
55 * Image component for rendering thumbnail image.
57 private final ImageComponent imageComponent
= new ImageComponent();
59 private String format
;
60 private long fileSize
;
61 private String fileName
;
62 private boolean directory
;
63 private int imagesCount
;
65 public ThumbnailComponent() {
69 public ImageComponent
getImageComponent() {
70 return imageComponent
;
73 public String
getFormat() {
77 public void setFormat(String format
) {
78 String oldValue
= this.format
;
79 if (oldValue
!= null && !oldValue
.equals(format
) || oldValue
== null && format
!= null) {
81 firePropertyChange(FORMAT_PROP
, oldValue
, this.format
);
85 public long getFileSize() {
89 public void setFileSize(long fileSize
) {
90 long oldValue
= this.fileSize
;
91 if (oldValue
!= fileSize
) {
92 this.fileSize
= fileSize
;
93 firePropertyChange(FILE_SIZE_PROP
, new Long(oldValue
), new Long(this.fileSize
));
97 public String
getFileName() {
101 public void setFileName(String fileName
) {
102 String oldValue
= this.fileName
;
103 if (oldValue
!= null && !oldValue
.equals(fileName
) || oldValue
== null && fileName
!= null) {
104 this.fileName
= fileName
;
105 firePropertyChange(FILE_NAME_PROP
, oldValue
, this.fileName
);
109 public boolean isDirectory() {
113 public void setDirectory(boolean directory
) {
114 boolean oldValue
= this.directory
;
115 if (oldValue
!= directory
) {
116 this.directory
= directory
;
117 firePropertyChange(DIRECTORY_PROP
, oldValue
, this.directory
);
121 public int getImagesCount() {
125 public void setImagesCount(int imagesCount
) {
126 int oldValue
= this.imagesCount
;
127 if (oldValue
!= imagesCount
) {
128 this.imagesCount
= imagesCount
;
129 firePropertyChange(IMAGES_COUNT_PROP
, oldValue
, this.imagesCount
);
133 public String
getFileSizeText() {
134 return StringUtil
.formatFileSize(fileSize
);
137 public void updateUI() {
138 setUI(UIManager
.getUI(this));
141 public String
getUIClassID() {