mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-86776 fix filtering of process name, add "show all" checkbox
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.android.actions.AndroidProcessChooserDialog">
|
||||
<grid id="27dc6" binding="myContentPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myContentPanel" layout-manager="GridLayoutManager" row-count="3" 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="20" y="20" width="136" height="400"/>
|
||||
@@ -19,8 +19,8 @@
|
||||
</component>
|
||||
<scrollpane id="4f662" class="com.intellij.ui.components.JBScrollPane">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="250" height="200"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="250" height="300"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
@@ -35,6 +35,14 @@
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<component id="bf4c2" class="com.intellij.ui.components.JBCheckBox" binding="myShowAllProcessesCheckBox">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Show &all processes"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
+36
-10
@@ -39,6 +39,7 @@ import com.intellij.psi.XmlRecursiveElementVisitor;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlElement;
|
||||
import com.intellij.ui.JBDefaultTreeCellRenderer;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
@@ -63,10 +64,7 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -78,12 +76,14 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.actions.AndroidProcessChooserDialog");
|
||||
|
||||
@NonNls private static final String DEBUGGABLE_PROCESS_PROPERTY = "DEBUGGABLE_PROCESS";
|
||||
@NonNls private static final String SHOW_ALL_PROCESSES_PROPERTY = "SHOW_ALL_PROCESSES";
|
||||
@NonNls private static final String DEBUGGABLE_DEVICE_PROPERTY = "DEBUGGABLE_DEVICE";
|
||||
@NonNls private static final String RUN_CONFIGURATION_NAME_PATTERN = "Android Debugger (%s)";
|
||||
|
||||
private final Project myProject;
|
||||
private JPanel myContentPanel;
|
||||
private Tree myProcessTree;
|
||||
private JBCheckBox myShowAllProcessesCheckBox;
|
||||
|
||||
private final MergingUpdateQueue myUpdatesQueue;
|
||||
private final AndroidDebugBridge.IClientChangeListener myClientChangeListener;
|
||||
@@ -97,7 +97,11 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
myUpdatesQueue =
|
||||
new MergingUpdateQueue("AndroidProcessChooserDialogUpdatingQueue", 500, true, MergingUpdateQueue.ANY_COMPONENT, myProject);
|
||||
|
||||
doUpdateTree();
|
||||
final String showAllProcessesStr = PropertiesComponent.getInstance(project).getValue(SHOW_ALL_PROCESSES_PROPERTY);
|
||||
final boolean showAllProcesses = Boolean.parseBoolean(showAllProcessesStr);
|
||||
myShowAllProcessesCheckBox.setSelected(showAllProcesses);
|
||||
|
||||
doUpdateTree(showAllProcesses);
|
||||
|
||||
myClientChangeListener = new AndroidDebugBridge.IClientChangeListener() {
|
||||
@Override
|
||||
@@ -125,6 +129,13 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
};
|
||||
AndroidDebugBridge.addDeviceChangeListener(myDeviceChangeListener);
|
||||
|
||||
myShowAllProcessesCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateTree();
|
||||
}
|
||||
});
|
||||
|
||||
myProcessTree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
@@ -219,6 +230,8 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
}
|
||||
|
||||
private void updateTree() {
|
||||
final boolean showAllProcesses = myShowAllProcessesCheckBox.isSelected();
|
||||
|
||||
myUpdatesQueue.queue(new Update(AndroidProcessChooserDialog.this) {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -234,7 +247,7 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
return;
|
||||
}
|
||||
|
||||
doUpdateTree();
|
||||
doUpdateTree(showAllProcesses);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,7 +257,7 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
});
|
||||
}
|
||||
|
||||
private void doUpdateTree() {
|
||||
private void doUpdateTree(boolean showAllProcesses) {
|
||||
final AndroidDebugBridge debugBridge = AndroidSdkUtils.getDebugBridge(myProject);
|
||||
|
||||
final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
|
||||
@@ -275,7 +288,8 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
for (Client client : device.getClients()) {
|
||||
final String clientDescription = getClientDescription(client);
|
||||
|
||||
if (clientDescription != null && processNames.contains(clientDescription)) {
|
||||
if (clientDescription != null &&
|
||||
(showAllProcesses || isRelatedProcess(processNames, clientDescription))) {
|
||||
final DefaultMutableTreeNode clientNode = new DefaultMutableTreeNode(client);
|
||||
deviceNode.add(clientNode);
|
||||
|
||||
@@ -314,6 +328,17 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isRelatedProcess(Set<String> processNames, String clientDescription) {
|
||||
final String lc = clientDescription.toLowerCase();
|
||||
|
||||
for (String processName : processNames) {
|
||||
if (lc.startsWith(processName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Set<String> collectAllProcessNames(Project project) {
|
||||
final List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
|
||||
@@ -325,7 +350,7 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
|
||||
final String packageName = manifest.getPackage().getValue();
|
||||
if (packageName != null) {
|
||||
result.add(packageName);
|
||||
result.add(packageName.toLowerCase());
|
||||
}
|
||||
|
||||
final XmlElement xmlElement = manifest.getXmlElement();
|
||||
@@ -352,7 +377,7 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
final String value = attribute.getValue();
|
||||
|
||||
if (value != null) {
|
||||
result.add(value);
|
||||
result.add(value.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -382,6 +407,7 @@ public class AndroidProcessChooserDialog extends DialogWrapper {
|
||||
|
||||
properties.setValue(DEBUGGABLE_DEVICE_PROPERTY, getPresentableName(selectedDevice));
|
||||
properties.setValue(DEBUGGABLE_PROCESS_PROPERTY, selectedClient.getClientData().getClientDescription());
|
||||
properties.setValue(SHOW_ALL_PROCESSES_PROPERTY, Boolean.toString(myShowAllProcessesCheckBox.isSelected()));
|
||||
|
||||
final String debugPort = Integer.toString(selectedClient.getDebuggerListenPort());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user