Skip to content

Commit

Permalink
Merge pull request #78 from Grigory-Rylov/non_modal_dialogs
Browse files Browse the repository at this point in the history
v29.03.22.0
  • Loading branch information
Grigory-Rylov committed Mar 29, 2022
2 parents e05ab25 + 4cbaf71 commit 61aa8c4
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class StandaloneAppDialogFactory(
override val shouldShowSetAdbMenu = true

override fun createHighlightDialog(owner: JFrame): HighlightDialog {
return HighlightDialog(owner, methodsColorRepository, this)
return HighlightDialog(owner, methodsColorRepository, this, true)
}

override fun createElementWithColorDialog(owner: Dialog, title: String): ElementWithColorDialog {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class StandaloneAppFramesManagerFramesManager(
urlOpener,
iconDelegate,
methodsColorRepository,
APP_FILES_DIR
APP_FILES_DIR,
true
)
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ allprojects {
subprojects {
apply plugin: 'idea'
ext {
productVersion = '22.02.22.0'
productVersion = '29.03.22.0'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class ThreadsViewDialog(
private val frame: Frame,
private val controller: ThreadsSelectionController,
private val previewImageRepository: PreviewImageRepository,
private val logger: AppLogger
) : CloseByEscapeDialog(frame, "Select thread", true), ThreadsSelectionView {
private val logger: AppLogger,
modal: Boolean,
) : CloseByEscapeDialog(frame, "Select thread", modal), ThreadsSelectionView {

private val model = ThreadListModel(previewImageRepository)
var selectedThreadItem: ThreadItem? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ private const val removeString = "-"
class GenerateStagesDialog(
owner: Dialog,
methods: List<ProfileData>,
logger: AppLogger
) : CloseByEscapeDialog(owner, "Packages filter", true), ListSelectionListener {
logger: AppLogger,
modal: Boolean,
) : CloseByEscapeDialog(owner, "Packages filter", modal), ListSelectionListener {
private val packageTextField =
JTextField(20).apply { toolTipText = "Enter package prefix to filter from trace methods" }
private val addButton = JButton(addString)
Expand Down
17 changes: 10 additions & 7 deletions core/src/main/java/com/github/grishberg/profiler/ui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public enum StartMode {
private String appFilesDir;
private final MethodsColorImpl methodsColor;
private JToolBar toolBar = new JToolBar();
private boolean allowModalDialogs;

@Nullable
private TraceContainer resultContainer;
Expand All @@ -156,13 +157,15 @@ public Main(StartMode startMode,
UrlOpener urlOpener,
AppIconDelegate appIconDelegate,
MethodsColorRepository methodsColorRepository,
String appFilesDir) {
String appFilesDir,
boolean allowModalDialogs) {
this.settings = settings;
this.log = log;
this.framesManager = framesManager;
this.dialogFactory = viewFactory;
this.urlOpener = urlOpener;
this.appFilesDir = appFilesDir;
this.allowModalDialogs = allowModalDialogs;
themeController.applyTheme();

String title = viewFactory.getTitle();
Expand Down Expand Up @@ -311,16 +314,16 @@ public void focusProfileElement(@NotNull ProfileData selectedElement) {
chart.setRightClickListener(this);
chart.setGridEnabled(true);

newBookmarkDialog = new NewBookmarkDialog(frame);
newBookmarkDialog = new NewBookmarkDialog(frame, allowModalDialogs);
newBookmarkDialog.pack();

loadingDialog = new LoadingDialog(frame, appIconDelegate);
loadingDialog = new LoadingDialog(frame, appIconDelegate, allowModalDialogs);
loadingDialog.pack();

methodTraceRecordDialog = viewFactory.createJavaMethodsRecorderDialog(
coroutineScope, coroutinesDispatchers, frame, settings, log);

scaleRangeDialog = new ScaleRangeDialog(frame);
scaleRangeDialog = new ScaleRangeDialog(frame, allowModalDialogs);

flameChartController = new FlameChartController(methodsColor, settings, log,
coroutineScope, coroutinesDispatchers);
Expand Down Expand Up @@ -692,7 +695,7 @@ public void showThreadsDialog() {
}

ThreadsSelectionController controller = new ThreadsSelectionController();
ThreadsViewDialog dialog = new ThreadsViewDialog(frame, controller, previewImageRepository, log);
ThreadsViewDialog dialog = new ThreadsViewDialog(frame, controller, previewImageRepository, log, allowModalDialogs);
dialog.showThreads(resultContainer.getResult().getThreads());
dialog.setLocationRelativeTo(chart);
dialog.setVisible(true);
Expand Down Expand Up @@ -761,7 +764,7 @@ private JMenu createSettingsMenu(UpdatesChecker updatesChecker) {
}

private void setupAndroidHome() {
SetAndroidHomeDialog dialog = new SetAndroidHomeDialog(frame, settings);
SetAndroidHomeDialog dialog = new SetAndroidHomeDialog(frame, settings, allowModalDialogs);
dialog.setLocationRelativeTo(frame);
dialog.setVisible(true);
}
Expand Down Expand Up @@ -1011,7 +1014,7 @@ public void showReportsDialog() {
hoverInfoPanel.hidePanel();

FlatMethodsReportGenerator generator = new FlatMethodsReportGenerator(chart.getData());
ReportsGeneratorDialog reportsGeneratorDialog = new ReportsGeneratorDialog(frame, settings, generator);
ReportsGeneratorDialog reportsGeneratorDialog = new ReportsGeneratorDialog(frame, settings, generator, allowModalDialogs);
reportsGeneratorDialog.pack();

reportsGeneratorDialog.setLocationRelativeTo(frame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import javax.swing.WindowConstants

class LoadingDialog(
owner: Frame,
appIconDelegate: AppIconDelegate
) : JDialog(owner, true) {
appIconDelegate: AppIconDelegate,
allowModalDialogs: Boolean,
) : JDialog(owner, allowModalDialogs) {

init {
val panel = JPanel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class NewBookmarkDialog extends CloseByEscapeDialog implements ChangeList
@Nullable
private BookMarkInfo result;

public NewBookmarkDialog(Frame owner) {
super(owner, "New Bookmark", true);
public NewBookmarkDialog(Frame owner, boolean allowModalDialogs) {
super(owner, "New Bookmark", allowModalDialogs);
JPanel content = new JPanel();
content.setBorder(new EmptyBorder(4, 4, 4, 4));
content.setLayout(new BorderLayout());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import javax.swing.filechooser.FileNameExtensionFilter
class ReportsGeneratorDialog(
owner: Frame,
private val settings: SettingsFacade,
private val reportsGeneratorDelegate: ReportGenerator
) : CloseByEscapeDialog(owner, "Generate methods report", true), ActionListener {
private val reportsGeneratorDelegate: ReportGenerator,
modal: Boolean,
) : CloseByEscapeDialog(owner, "Generate methods report", modal), ActionListener {

private val constructorsCheckbox: JCheckBox
private val durationLimit: JNumberField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import javax.swing.JOptionPane


class ScaleRangeDialog(
owner: Frame
) : CloseByEscapeDialog(owner, "Set view range", true) {
owner: Frame,
modal: Boolean,
) : CloseByEscapeDialog(owner, "Set view range", modal) {
private val startRangeField: JNumberField
private val endRangeField: JNumberField
var result: Range? = null
Expand Down Expand Up @@ -55,4 +56,4 @@ class ScaleRangeDialog(
}

data class Range(val start: Double, val end: Double)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import javax.swing.*
*/
class SetAndroidHomeDialog(
owner: JFrame,
private val settings: SettingsFacade
) : CloseByEscapeDialog(owner, "Set path to Android SDK", true) {
private val settings: SettingsFacade,
modal: Boolean,
) : CloseByEscapeDialog(owner, "Set path to Android SDK", modal) {
private val androidHomeField = JTextField(25)

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ private const val BUTTON_TITLE_DOWN = "Down"
class HighlightDialog(
owner: Frame,
methodsColorRepository: MethodsColorRepository,
private val dialogFactory: ElementWithColorDialogFactory
private val dialogFactory: ElementWithColorDialogFactory,
allowModalDialogs: Boolean,
) : CloseByEscapeDialog(
owner,
"Highlight settings",
true
allowModalDialogs
), HighlightDialogView {
private val logic = HighlightListDialogLogic(methodsColorRepository)
private val listModel = DefaultListModel<ColorInfo>()
Expand Down
2 changes: 1 addition & 1 deletion plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ task(verifySetup) {

patchPluginXml {
changeNotes """
Added case insensitive methods searching in main screen.<br>
Make all dialogs non-modal.<br>
"""
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class PluginDialogFactory(
adbWrapper,
coroutineScope, coroutinesDispatchers,
frame, settings, log,
projectInfoProvider
projectInfoProvider,
false,
)
}

Expand All @@ -56,14 +57,14 @@ class PluginDialogFactory(


override fun createHighlightDialog(owner: JFrame): HighlightDialog {
return HighlightDialog(owner, methodsColorRepository, this)
return HighlightDialog(owner, methodsColorRepository, this, false)
}

override fun createElementWithColorDialog(owner: Dialog, title: String): ElementWithColorDialog {
return ElementWithColorDialog(owner, title, true)
return ElementWithColorDialog(owner, title, false)
}

override fun createElementWithColorDialog(owner: JFrame, title: String): ElementWithColorDialog {// not used
return ElementWithColorDialog(owner, title, true)
override fun createElementWithColorDialog(owner: JFrame, title: String): ElementWithColorDialog {
return ElementWithColorDialog(owner, title, false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class PluginFramesManager(
themesController, NoOpUpdatesChecker, viewFactory, urlOpener,
iconDelegate,
methodsColorRepository,
"<not used>"
"<not used>",
false
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ class PluginMethodsRecorderDialog(
owner: Frame,
private val settings: SettingsFacade,
private val logger: AppLogger,
private val projectInfoProvider: ProjectInfoProvider
private val projectInfoProvider: ProjectInfoProvider,
allowModalDialog: Boolean,
) : CloseByEscapeDialog(
owner,
TITLE, true
TITLE, allowModalDialog
), JavaMethodsRecorderDialogView {
private val packageNameField: JTextField
private val activityNameField: JTextField
Expand Down

0 comments on commit 61aa8c4

Please sign in to comment.