From e86bc7cdfbcbfc024e37c810dc7d96ff3c46b62e Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 28 Oct 2016 15:13:48 +0300 Subject: [PATCH] cleanup --- .../vfs/encoding/EncodingFileTreeTable.java | 25 ++++++++++--------- .../openapi/wm/impl/status/EncodingPanel.java | 13 +++------- .../com/intellij/diagnostic/ThreadDump.java | 7 +++--- .../util/concurrency/EdtExecutorService.java | 4 +-- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/EncodingFileTreeTable.java b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/EncodingFileTreeTable.java index 3b52f3c54882..c5106b7ae45b 100644 --- a/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/EncodingFileTreeTable.java +++ b/platform/lang-impl/src/com/intellij/openapi/vfs/encoding/EncodingFileTreeTable.java @@ -50,7 +50,7 @@ class EncodingFileTreeTable extends AbstractFileTreeTable { super(project, Charset.class, "Default Encoding", VirtualFileFilter.ALL, false); Map mappings = FileEncodingConfigurable.getExistingMappingIncludingDefault(project); reset(mappings); - getValueColumn().setCellRenderer(new DefaultTableCellRenderer(){ + getValueColumn().setCellRenderer(new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { @@ -60,7 +60,6 @@ class EncodingFileTreeTable extends AbstractFileTreeTable { final VirtualFile file = userObject instanceof VirtualFile ? (VirtualFile)userObject : null; Pair check = file == null || file.isDirectory() ? null : EncodingUtil.checkSomeActionEnabled(file); String failReason = check == null ? null : check.second; - boolean enabled = failReason == null; // show existing encoding only if it was specified explicitly or it is unchangeable (with reason) boolean toShow = t != null || failReason != null; @@ -71,24 +70,26 @@ class EncodingFileTreeTable extends AbstractFileTreeTable { setText(encodingText + (failReason == null ? "" : " (" + failReason + ")")); } + boolean enabled = failReason == null; setEnabled(enabled || isSelected); // do not use grayed text on selected row return this; } }); - getValueColumn().setCellEditor(new DefaultCellEditor(new JComboBox()){ + getValueColumn().setCellEditor(new DefaultCellEditor(new JComboBox()) { private VirtualFile myVirtualFile; + { delegate = new EditorDelegate() { - @Override - public void setValue(Object value) { - getTableModel().setValueAt(value, new DefaultMutableTreeNode(myVirtualFile), -1); - } + @Override + public void setValue(Object value) { + getTableModel().setValueAt(value, new DefaultMutableTreeNode(myVirtualFile), -1); + } - @Override - public Object getCellEditorValue() { - return getTableModel().getValueAt(new DefaultMutableTreeNode(myVirtualFile), 1); - } + @Override + public Object getCellEditorValue() { + return getTableModel().getValueAt(new DefaultMutableTreeNode(myVirtualFile), 1); + } }; } @@ -124,7 +125,7 @@ class EncodingFileTreeTable extends AbstractFileTreeTable { } }; DataContext dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.VIRTUAL_FILE.getName(), myVirtualFile, - SimpleDataContext.getProjectContext(getProject())); + SimpleDataContext.getProjectContext(getProject())); AnActionEvent event = AnActionEvent.createFromAnAction(changeAction, null, ActionPlaces.UNKNOWN, dataContext); Presentation presentation = event.getPresentation(); JComponent comboComponent = changeAction.createCustomComponent(presentation); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java index e7683c90d142..734c23a3dc36 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java @@ -56,8 +56,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.nio.charset.Charset; @@ -147,13 +145,10 @@ public class EncodingPanel extends EditorBasedWidget implements StatusBarWidget. public void install(@NotNull StatusBar statusBar) { super.install(statusBar); // should update to reflect encoding-from-content - EncodingManager.getInstance().addPropertyChangeListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getPropertyName().equals(EncodingManagerImpl.PROP_CACHED_ENCODING_CHANGED)) { - Document document = evt.getSource() instanceof Document ? (Document)evt.getSource() : null; - updateForDocument(document); - } + EncodingManager.getInstance().addPropertyChangeListener(evt -> { + if (evt.getPropertyName().equals(EncodingManagerImpl.PROP_CACHED_ENCODING_CHANGED)) { + Document document = evt.getSource() instanceof Document ? (Document)evt.getSource() : null; + updateForDocument(document); } }, this); ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(VirtualFileManager.VFS_CHANGES, new BulkVirtualFileListenerAdapter(new VirtualFileAdapter() { diff --git a/platform/util/src/com/intellij/diagnostic/ThreadDump.java b/platform/util/src/com/intellij/diagnostic/ThreadDump.java index 87e7ba877e54..07059efccba2 100644 --- a/platform/util/src/com/intellij/diagnostic/ThreadDump.java +++ b/platform/util/src/com/intellij/diagnostic/ThreadDump.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; /** * Represents thread dump of the IDE captured by its performance diagnostic tool. */ -public class ThreadDump { +class ThreadDump { private final String myRawDump; private final StackTraceElement[] myEdtStack; @@ -34,7 +34,7 @@ public class ThreadDump { * @return full thread dump as a string */ @NotNull - public String getRawDump() { + String getRawDump() { return myRawDump; } @@ -42,8 +42,7 @@ public class ThreadDump { * @return state of the AWT thread from the dump */ @Nullable - public StackTraceElement[] getEDTStackTrace() { + StackTraceElement[] getEDTStackTrace() { return myEdtStack; } - } diff --git a/platform/util/src/com/intellij/util/concurrency/EdtExecutorService.java b/platform/util/src/com/intellij/util/concurrency/EdtExecutorService.java index 61c81e4c10e7..f77bae0a5025 100644 --- a/platform/util/src/com/intellij/util/concurrency/EdtExecutorService.java +++ b/platform/util/src/com/intellij/util/concurrency/EdtExecutorService.java @@ -25,7 +25,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; /** - * ExecutorService implementation which delegates tasks for execution to the SwingUtilities.invokeLater(task) + * {@link java.util.concurrent.ExecutorService} implementation which delegates tasks for execution to the {@link javax.swing.SwingUtilities#invokeLater(Runnable)} */ public class EdtExecutorService extends AbstractExecutorService { @NotNull @@ -84,7 +84,7 @@ public class EdtExecutorService extends AbstractExecutorService { } @Override - public boolean awaitTermination(long timeout, @NotNull TimeUnit unit) throws InterruptedException { + public boolean awaitTermination(long timeout, @NotNull TimeUnit unit) { AppScheduledExecutorService.error(); return false; }