mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
images: strip icon information to get clear view
This commit is contained in:
@@ -110,6 +110,18 @@
|
||||
</action>
|
||||
<separator/>
|
||||
<reference id="Images.ToggleTransparencyChessboard"/>
|
||||
<action class="org.intellij.images.thumbnail.actions.ToggleFileSizeAction"
|
||||
id="Images.Thumbnails.ToggleFileSize"
|
||||
text="File Size"
|
||||
description="Toggle whether to show the image size information"
|
||||
icon="AllIcons.FileTypes.Any_type">
|
||||
</action>
|
||||
<action class="org.intellij.images.thumbnail.actions.ToggleFileNameAction"
|
||||
id="Images.Thumbnails.ToggleFileName"
|
||||
text="File Size"
|
||||
description="Toggle whether to show the image name"
|
||||
icon="AllIcons.Actions.ShowImportStatements">
|
||||
</action>
|
||||
<separator/>
|
||||
<action class="org.intellij.images.thumbnail.actions.HideThumbnailsAction"
|
||||
id="Images.Thumbnails.Hide"
|
||||
|
||||
@@ -30,4 +30,12 @@ public interface EditorOptions extends Cloneable {
|
||||
void inject(EditorOptions options);
|
||||
|
||||
boolean setOption(String name, Object value);
|
||||
|
||||
boolean isFileNameVisible();
|
||||
|
||||
void setFileNameVisible(boolean fileNameVisible);
|
||||
|
||||
void setFileSizeVisible(boolean fileSizeVisible);
|
||||
|
||||
boolean isFileSizeVisible();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ final class EditorOptionsImpl implements EditorOptions, JDOMExternalizable {
|
||||
private final GridOptions gridOptions;
|
||||
private final TransparencyChessboardOptions transparencyChessboardOptions;
|
||||
private final ZoomOptions zoomOptions;
|
||||
private boolean fileNameVisible = true;
|
||||
private boolean fileSizeVisible = true;
|
||||
|
||||
EditorOptionsImpl(PropertyChangeSupport propertyChangeSupport) {
|
||||
gridOptions = new GridOptionsImpl(propertyChangeSupport);
|
||||
@@ -70,16 +72,46 @@ final class EditorOptionsImpl implements EditorOptions, JDOMExternalizable {
|
||||
zoomOptions.setOption(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileNameVisible() {
|
||||
return fileNameVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFileNameVisible(boolean fileNameVisible) {
|
||||
this.fileNameVisible = fileNameVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFileSizeVisible(boolean fileSizeVisible) {
|
||||
this.fileSizeVisible = fileSizeVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileSizeVisible() {
|
||||
return fileSizeVisible;
|
||||
}
|
||||
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
((JDOMExternalizable)gridOptions).readExternal(element);
|
||||
((JDOMExternalizable)transparencyChessboardOptions).readExternal(element);
|
||||
((JDOMExternalizable)zoomOptions).readExternal(element);
|
||||
String fileNameVisibleAttr = element.getAttributeValue("fileNameVisible");
|
||||
fileNameVisible = fileNameVisibleAttr == null || Boolean.parseBoolean(fileNameVisibleAttr);
|
||||
String fileSizeVisibleAttr = element.getAttributeValue("fileSizeVisible");
|
||||
fileSizeVisible = fileNameVisibleAttr == null || Boolean.parseBoolean(fileSizeVisibleAttr);
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
((JDOMExternalizable)gridOptions).writeExternal(element);
|
||||
((JDOMExternalizable)transparencyChessboardOptions).writeExternal(element);
|
||||
((JDOMExternalizable)zoomOptions).writeExternal(element);
|
||||
if (!fileNameVisible) {
|
||||
element.setAttribute("fileNameVisible", "false");
|
||||
}
|
||||
if (!fileSizeVisible) {
|
||||
element.setAttribute("fileSizeVisible", "false");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** $Id$ */
|
||||
|
||||
package org.intellij.images.thumbnail.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import org.intellij.images.options.OptionsManager;
|
||||
import org.intellij.images.ui.ImageComponentDecorator;
|
||||
|
||||
public final class ToggleFileNameAction extends ToggleAction {
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
ImageComponentDecorator decorator = ImageComponentDecorator.DATA_KEY.getData(e.getDataContext());
|
||||
return decorator != null && decorator.isEnabledForActionPlace(e.getPlace()) && decorator.isFileNameVisible();
|
||||
}
|
||||
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
ImageComponentDecorator decorator = ImageComponentDecorator.DATA_KEY.getData(e.getDataContext());
|
||||
if (decorator != null && decorator.isEnabledForActionPlace(e.getPlace())) {
|
||||
decorator.setFileNameVisible(state);
|
||||
OptionsManager.getInstance().getOptions().getEditorOptions().setFileNameVisible(state);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(final AnActionEvent e) {
|
||||
super.update(e);
|
||||
ImageComponentDecorator decorator = ImageComponentDecorator.DATA_KEY.getData(e.getDataContext());
|
||||
e.getPresentation().setEnabled(decorator != null && decorator.isEnabledForActionPlace(e.getPlace()));
|
||||
e.getPresentation().setText(isSelected(e) ? "Hide File Name" : "Show File Name");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/** $Id$ */
|
||||
|
||||
package org.intellij.images.thumbnail.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import org.intellij.images.options.OptionsManager;
|
||||
import org.intellij.images.ui.ImageComponentDecorator;
|
||||
|
||||
public final class ToggleFileSizeAction extends ToggleAction {
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
ImageComponentDecorator decorator = ImageComponentDecorator.DATA_KEY.getData(e.getDataContext());
|
||||
return decorator != null && decorator.isEnabledForActionPlace(e.getPlace()) && decorator.isFileSizeVisible();
|
||||
}
|
||||
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
ImageComponentDecorator decorator = ImageComponentDecorator.DATA_KEY.getData(e.getDataContext());
|
||||
if (decorator != null && decorator.isEnabledForActionPlace(e.getPlace())) {
|
||||
decorator.setFileSizeVisible(state);
|
||||
OptionsManager.getInstance().getOptions().getEditorOptions().setFileSizeVisible(state);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(final AnActionEvent e) {
|
||||
super.update(e);
|
||||
ImageComponentDecorator decorator = ImageComponentDecorator.DATA_KEY.getData(e.getDataContext());
|
||||
e.getPresentation().setEnabled(decorator != null && decorator.isEnabledForActionPlace(e.getPlace()));
|
||||
e.getPresentation().setText(isSelected(e) ? "Hide File Size" : "Show File Size");
|
||||
}
|
||||
}
|
||||
@@ -160,6 +160,30 @@ final class ThumbnailViewImpl implements ThumbnailView {
|
||||
return isVisible() && !ImageEditorActions.ACTION_PLACE.equals(place);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileSizeVisible() {
|
||||
return isVisible() && getUI().isFileSizeVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFileSizeVisible(boolean visible) {
|
||||
if (isVisible()) {
|
||||
getUI().setFileSizeVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFileNameVisible() {
|
||||
return isVisible() && getUI().isFileNameVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFileNameVisible(boolean visible) {
|
||||
if (isVisible()) {
|
||||
getUI().setFileNameVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
// Dispose UI
|
||||
Disposer.dispose(getUI());
|
||||
|
||||
@@ -113,6 +113,8 @@ final class ThumbnailViewUI extends JPanel implements DataProvider, Disposable {
|
||||
imageComponent.setTransparencyChessboardCellSize(chessboardOptions.getCellSize());
|
||||
imageComponent.setTransparencyChessboardWhiteColor(chessboardOptions.getWhiteColor());
|
||||
imageComponent.setTransparencyChessboardBlankColor(chessboardOptions.getBlackColor());
|
||||
imageComponent.setFileNameVisible(editorOptions.isFileNameVisible());
|
||||
imageComponent.setFileSizeVisible(editorOptions.isFileSizeVisible());
|
||||
|
||||
options.addPropertyChangeListener(optionsListener);
|
||||
|
||||
@@ -191,6 +193,28 @@ final class ThumbnailViewUI extends JPanel implements DataProvider, Disposable {
|
||||
cellRenderer.getImageComponent().setTransparencyChessboardVisible(visible);
|
||||
list.repaint();
|
||||
}
|
||||
|
||||
public void setFileNameVisible(boolean visible) {
|
||||
createUI();
|
||||
cellRenderer.getImageComponent().setFileNameVisible(visible);
|
||||
list.repaint();
|
||||
}
|
||||
|
||||
public boolean isFileNameVisible() {
|
||||
createUI();
|
||||
return cellRenderer.getImageComponent().isFileNameVisible();
|
||||
}
|
||||
|
||||
public void setFileSizeVisible(boolean visible) {
|
||||
createUI();
|
||||
cellRenderer.getImageComponent().setFileSizeVisible(visible);
|
||||
list.repaint();
|
||||
}
|
||||
|
||||
public boolean isFileSizeVisible() {
|
||||
createUI();
|
||||
return cellRenderer.getImageComponent().isFileSizeVisible();
|
||||
}
|
||||
|
||||
public void setSelected(VirtualFile file, boolean selected) {
|
||||
createUI();
|
||||
|
||||
@@ -53,6 +53,10 @@ public class ImageComponent extends JComponent {
|
||||
private static final String GRID_LINE_COLOR_PROP = "Grid.lineColor";
|
||||
@NonNls
|
||||
private static final String GRID_VISIBLE_PROP = "Grid.visible";
|
||||
@NonNls
|
||||
private static final String FILE_SIZE_VISIBLE_PROP = "FileSize.visible";
|
||||
@NonNls
|
||||
private static final String FILE_NAME_VISIBLE_PROP = "FileName.visible";
|
||||
|
||||
/**
|
||||
* @see #getUIClassID
|
||||
@@ -68,6 +72,8 @@ public class ImageComponent extends JComponent {
|
||||
private final ImageDocument document = new ImageDocumentImpl();
|
||||
private final Grid grid = new Grid();
|
||||
private final Chessboard chessboard = new Chessboard();
|
||||
private boolean myFileSizeVisible = true;
|
||||
private boolean myFileNameVisible = true;
|
||||
|
||||
public ImageComponent() {
|
||||
updateUI();
|
||||
@@ -125,6 +131,26 @@ public class ImageComponent extends JComponent {
|
||||
return chessboard.isVisible();
|
||||
}
|
||||
|
||||
public boolean isFileSizeVisible() {
|
||||
return myFileSizeVisible;
|
||||
}
|
||||
|
||||
public void setFileSizeVisible(boolean fileSizeVisible) {
|
||||
boolean oldValue = myFileSizeVisible;
|
||||
myFileSizeVisible = fileSizeVisible;
|
||||
firePropertyChange(FILE_SIZE_VISIBLE_PROP, oldValue, fileSizeVisible);
|
||||
}
|
||||
|
||||
public boolean isFileNameVisible() {
|
||||
return myFileNameVisible;
|
||||
}
|
||||
|
||||
public void setFileNameVisible(boolean fileNameVisible) {
|
||||
boolean oldValue = myFileNameVisible;
|
||||
myFileNameVisible = fileNameVisible;
|
||||
firePropertyChange(FILE_NAME_VISIBLE_PROP, oldValue, fileNameVisible);
|
||||
}
|
||||
|
||||
public void setGridLineZoomFactor(int lineZoomFactor) {
|
||||
int oldValue = grid.getLineZoomFactor();
|
||||
if (oldValue != lineZoomFactor) {
|
||||
|
||||
@@ -43,4 +43,16 @@ public interface ImageComponentDecorator {
|
||||
void setGridVisible(boolean visible);
|
||||
|
||||
boolean isGridVisible();
|
||||
|
||||
default boolean isFileSizeVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default void setFileSizeVisible(boolean visible) {}
|
||||
|
||||
default boolean isFileNameVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default void setFileNameVisible(boolean visible) {}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ThumbnailComponentUI extends ComponentUI {
|
||||
}
|
||||
|
||||
// File name
|
||||
paintFileName(g, tc);
|
||||
if (tc.isDirectory() || tc.getImageComponent().isFileNameVisible()) paintFileName(g, tc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,10 +92,10 @@ public class ThumbnailComponentUI extends ComponentUI {
|
||||
}
|
||||
|
||||
private void paintImageThumbnail(Graphics g, ThumbnailComponent tc) {
|
||||
// Paint blank
|
||||
ImagesIcons.ThumbnailBlank.paintIcon(tc, g, 5, 5);
|
||||
|
||||
ImageComponent imageComponent = tc.getImageComponent();
|
||||
// Paint blank
|
||||
if (imageComponent.isFileSizeVisible()) ImagesIcons.ThumbnailBlank.paintIcon(tc, g, 5, 5);
|
||||
|
||||
ImageDocument document = imageComponent.getDocument();
|
||||
BufferedImage image = document.getValue();
|
||||
if (image != null) {
|
||||
@@ -104,7 +104,7 @@ public class ThumbnailComponentUI extends ComponentUI {
|
||||
paintError(g, tc);
|
||||
}
|
||||
|
||||
paintFileSize(g, tc);
|
||||
if (imageComponent.isFileSizeVisible()) paintFileSize(g, tc);
|
||||
}
|
||||
|
||||
private void paintBackground(Graphics g, ThumbnailComponent tc) {
|
||||
@@ -119,10 +119,12 @@ public class ThumbnailComponentUI extends ComponentUI {
|
||||
|
||||
int blankHeight = ImagesIcons.ThumbnailBlank.getIconHeight();
|
||||
|
||||
// Paint image info (and reduce height of text from available height)
|
||||
blankHeight -= paintImageCaps(g, image);
|
||||
// Paint image format (and reduce height of text from available height)
|
||||
blankHeight -= paintFormatText(tc, g);
|
||||
if (imageComponent.isFileSizeVisible()) {
|
||||
// Paint image info (and reduce height of text from available height)
|
||||
blankHeight -= paintImageCaps(g, image);
|
||||
// Paint image format (and reduce height of text from available height)
|
||||
blankHeight -= paintFormatText(tc, g);
|
||||
}
|
||||
|
||||
// Paint image
|
||||
paintThumbnail(g, imageComponent, blankHeight);
|
||||
|
||||
Reference in New Issue
Block a user