Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9309f1cb authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I37c8daa6,I5a05b65d,If56347fd

* changes:
  Preload2: Add isSingleThreaded
  Preload2: Fix action inheritance
  Preload2: Abstract out UI
parents 0310de11 3bf65c91
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ import com.android.preload.actions.ShowDataAction;
import com.android.preload.classdataretrieval.ClassDataRetriever;
import com.android.preload.classdataretrieval.hprof.Hprof;
import com.android.preload.classdataretrieval.jdwp.JDWPClassDataRetriever;
import com.android.preload.ui.UI;
import com.android.preload.ui.IUI;
import com.android.preload.ui.SwingUI;

import java.util.ArrayList;
import java.util.Collection;
@@ -66,7 +67,7 @@ public class Main {
    private DumpTableModel dataTableModel;
    private DefaultListModel<Client> clientListModel;

    private UI ui;
    private IUI ui;

    // Actions that need to be updated once a device is selected.
    private Collection<DeviceSpecific> deviceSpecificActions;
@@ -89,13 +90,15 @@ public class Main {
     * @param args
     */
    public static void main(String[] args) {
        Main m = new Main();
        Main m = new Main(new SwingUI());
        top = m;

        m.startUp();
    }

    public Main() {
    public Main(IUI ui) {
        this.ui = ui;

        clientListModel = new DefaultListModel<Client>();
        dataTableModel = new DumpTableModel();

@@ -124,11 +127,10 @@ public class Main {
            }
        }

        ui = new UI(clientListModel, dataTableModel, actions);
        ui.setVisible(true);
        ui.prepare(clientListModel, dataTableModel, actions);
    }

    public static UI getUI() {
    public static IUI getUI() {
        return top.ui;
    }

@@ -176,6 +178,7 @@ public class Main {
        new ReloadListAction(clientUtils, getDevice(), clientListModel).run();

        getUI().hideWaitDialog();
        getUI().ready();
    }

    private void initDevice() {
+6 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.preload.actions;

import com.android.preload.Main;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
@@ -28,7 +29,11 @@ public abstract class AbstractThreadedAction extends AbstractAction implements R

    @Override
    public void actionPerformed(ActionEvent e) {
        if (Main.getUI().isSingleThreaded()) {
            run();
        } else {
            new Thread(this).start();
        }
    }

}
+4 −7
Original line number Diff line number Diff line
@@ -32,14 +32,13 @@ import java.util.TreeSet;
import java.util.regex.Pattern;

import javax.swing.AbstractAction;
import javax.swing.JFileChooser;

/**
 * Compute an intersection of classes from the given data. A class is in the intersection if it
 * appears in at least the number of threshold given packages. An optional blacklist can be
 * used to filter classes from the intersection.
 */
public class ComputeThresholdAction extends AbstractAction implements Runnable {
public class ComputeThresholdAction extends AbstractThreadedAction {
    protected int threshold;
    private Pattern blacklist;
    private DumpTableModel dataTableModel;
@@ -72,7 +71,7 @@ public class ComputeThresholdAction extends AbstractAction implements Runnable {
            return;
        }

        new Thread(this).start();
        super.actionPerformed(e);
    }

    @Override
@@ -92,10 +91,8 @@ public class ComputeThresholdAction extends AbstractAction implements Runnable {
        boolean ret = Main.getUI().showConfirmDialog("Computed a set with " + result.size()
                + " classes, would you like to save to disk?", "Save?");
        if (ret) {
            JFileChooser jfc = new JFileChooser();
            int ret2 = jfc.showSaveDialog(Main.getUI());
            if (ret2 == JFileChooser.APPROVE_OPTION) {
                File f = jfc.getSelectedFile();
            File f = Main.getUI().showSaveDialog();
            if (f != null) {
                saveSet(result, f);
            }
        }
+2 −5
Original line number Diff line number Diff line
@@ -19,14 +19,11 @@ package com.android.preload.actions;
import com.android.preload.DumpDataIO;
import com.android.preload.DumpTableModel;
import com.android.preload.Main;

import java.awt.event.ActionEvent;
import java.io.File;
import java.io.PrintWriter;

import javax.swing.AbstractAction;

public class ExportAction extends AbstractAction implements Runnable {
public class ExportAction extends AbstractThreadedAction {
    private File lastSaveFile;
    private DumpTableModel dataTableModel;

@@ -39,7 +36,7 @@ public class ExportAction extends AbstractAction implements Runnable {
    public void actionPerformed(ActionEvent e) {
        lastSaveFile = Main.getUI().showSaveDialog();
        if (lastSaveFile != null) {
            new Thread(this).start();
            super.actionPerformed(e);
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import java.util.Collection;

import javax.swing.AbstractAction;

public class ImportAction extends AbstractAction implements Runnable {
public class ImportAction extends AbstractThreadedAction {
    private File[] lastOpenFiles;
    private DumpTableModel dataTableModel;

@@ -40,7 +40,7 @@ public class ImportAction extends AbstractAction implements Runnable {
    public void actionPerformed(ActionEvent e) {
        lastOpenFiles = Main.getUI().showOpenDialog(true);
        if (lastOpenFiles != null) {
            new Thread(this).start();
            super.actionPerformed(e);
        }
    }

Loading