Settings in the unscrambler API

This commit is contained in:
Pavel Fatin
2016-08-08 14:55:01 +02:00
parent f4510c6c39
commit d0feec3990
4 changed files with 50 additions and 17 deletions
@@ -3,7 +3,7 @@
<grid id="5ad95" binding="myPanel" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="82" y="81" width="527" height="199"/>
<xy x="82" y="81" width="527" height="243"/>
</constraints>
<properties/>
<border type="none"/>
@@ -25,8 +25,8 @@
<text resource-bundle="messages/IdeBundle" key="unscramble.stacktrace.caption"/>
</properties>
</component>
<grid id="26652" binding="myUnscramblePanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<grid id="26652" binding="myUnscramblePanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
@@ -60,7 +60,7 @@
<xy id="c5749" binding="myLogFileChooserPanel" layout-manager="XYLayout" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -75,6 +75,14 @@
<text resource-bundle="messages/IdeBundle" key="unscramble.use.unscrambler.checkbox"/>
</properties>
</component>
<grid id="8ffba" binding="mySettingsPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
<component id="3ac03" class="javax.swing.JCheckBox" binding="myOnTheFly">
@@ -34,12 +34,10 @@ import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.configurable.VcsContentAnnotationConfigurable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.GuiUtils;
import com.intellij.ui.ListCellRendererWrapper;
import com.intellij.ui.TextFieldWithHistory;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.CharArrayUtil;
import org.jetbrains.annotations.NonNls;
@@ -78,6 +76,7 @@ public class UnscrambleDialog extends DialogWrapper {
private JPanel myUnscramblePanel;
private JCheckBox myOnTheFly;
private JPanel myBottomPanel;
private JPanel mySettingsPanel;
protected AnalyzeStacktraceUtil.StacktraceEditorPanel myStacktraceEditorPanel;
private VcsContentAnnotationConfigurable myConfigurable;
@@ -91,6 +90,7 @@ public class UnscrambleDialog extends DialogWrapper {
public void actionPerformed(ActionEvent e) {
UnscrambleSupport unscrambleSupport = getSelectedUnscrambler();
GuiUtils.enableChildren(myLogFileChooserPanel, unscrambleSupport != null);
updateUnscramblerSettings();
}
});
myUseUnscrambler.addActionListener(new ActionListener() {
@@ -117,6 +117,20 @@ public class UnscrambleDialog extends DialogWrapper {
private void useUnscramblerChanged() {
boolean selected = myUseUnscrambler.isSelected();
GuiUtils.enableChildren(myUnscramblePanel, selected, myUseUnscrambler);
if (selected) {
updateUnscramblerSettings();
}
}
private void updateUnscramblerSettings() {
UnscrambleSupport unscrambleSupport = (UnscrambleSupport)myUnscrambleChooser.getSelectedItem();
JComponent settingsComponent = unscrambleSupport == null ? null : unscrambleSupport.createSettingsComponent();
mySettingsPanel.removeAll();
if (settingsComponent != null) {
mySettingsPanel.add(settingsComponent, BorderLayout.CENTER);
}
myUnscramblePanel.validate();
}
private void reset() {
@@ -155,6 +169,7 @@ public class UnscrambleDialog extends DialogWrapper {
}
useUnscramblerChanged();
updateUnscramblerSettings();
myStacktraceEditorPanel.pasteTextFromClipboard();
}
@@ -386,15 +401,17 @@ public class UnscrambleDialog extends DialogWrapper {
private boolean performUnscramble() {
UnscrambleSupport selectedUnscrambler = getSelectedUnscrambler();
return showUnscrambledText(selectedUnscrambler, myLogFile.getText(), myProject, myStacktraceEditorPanel.getText()) != null;
JComponent settings = mySettingsPanel.getComponentCount() == 0 ? null : (JComponent)mySettingsPanel.getComponent(0);
return showUnscrambledText(selectedUnscrambler, myLogFile.getText(), settings, myProject, myStacktraceEditorPanel.getText()) != null;
}
@Nullable
static RunContentDescriptor showUnscrambledText(@Nullable UnscrambleSupport unscrambleSupport,
String logName,
Project project,
String textToUnscramble) {
String unscrambledTrace = unscrambleSupport == null ? textToUnscramble : unscrambleSupport.unscramble(project,textToUnscramble, logName);
static <T extends JComponent> RunContentDescriptor showUnscrambledText(@Nullable UnscrambleSupport<T> unscrambleSupport,
String logName,
@Nullable T settings,
Project project,
String textToUnscramble) {
String unscrambledTrace = unscrambleSupport == null ? textToUnscramble : unscrambleSupport.unscramble(project,textToUnscramble, logName, settings);
if (unscrambledTrace == null) return null;
List<ThreadState> threadStates = ThreadDumpParser.parse(unscrambledTrace);
return addConsole(project, threadStates, unscrambledTrace);
@@ -75,7 +75,7 @@ public class UnscrambleDialogTest extends JavaCodeInsightFixtureTestCase {
}
private void showText(String unscramble) {
RunContentDescriptor descriptor = UnscrambleDialog.showUnscrambledText(null, "foo", getProject(), unscramble);
RunContentDescriptor descriptor = UnscrambleDialog.showUnscrambledText(null, "foo", null, getProject(), unscramble);
assertNotNull(descriptor);
Disposer.register(getTestRootDisposable(), descriptor);
myContent = descriptor;
@@ -15,14 +15,22 @@
*/
package com.intellij.unscramble;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface UnscrambleSupport {
import javax.swing.*;
public interface UnscrambleSupport<T extends JComponent> {
ExtensionPointName<UnscrambleSupport> EP_NAME = ExtensionPointName.create("com.intellij.unscrambleSupport");
@Nullable
String unscramble(Project project, String text, String logName);
@NotNull
String getPresentableName();
@Nullable
T createSettingsComponent();
@Nullable
String unscramble(@NotNull Project project, @NotNull String text, @NotNull String logName, @Nullable T settings);
}