-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show progress dialog when initializing ADB in response to user action
The dialog can cancel the action, but not the initialization of the ADB itself. Issue: #326
- Loading branch information
Showing
6 changed files
with
193 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/name/mlopatkin/andlogview/ui/mainframe/device/AdbInitProgressDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright 2024 the Andlogview authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package name.mlopatkin.andlogview.ui.mainframe.device; | ||
|
||
import name.mlopatkin.andlogview.ui.mainframe.DialogFactory; | ||
import name.mlopatkin.andlogview.utils.CommonChars; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.inject.Inject; | ||
import javax.swing.JDialog; | ||
import javax.swing.JOptionPane; | ||
import javax.swing.JProgressBar; | ||
|
||
public class AdbInitProgressDialog { | ||
private final JDialog dialog; | ||
private final JOptionPane optionPane; | ||
|
||
@Inject | ||
public AdbInitProgressDialog(DialogFactory dialogFactory) { | ||
optionPane = new JOptionPane( | ||
new Object[] { | ||
"Connecting to ADB server" + CommonChars.ELLIPSIS, | ||
createProgressBar() | ||
}, JOptionPane.PLAIN_MESSAGE, | ||
JOptionPane.DEFAULT_OPTION, null, new String[] {"Cancel"}); | ||
|
||
dialog = optionPane.createDialog(dialogFactory.getOwner(), "Initializing ADB" + CommonChars.ELLIPSIS); | ||
} | ||
|
||
public void show(Runnable cancellationAction) { | ||
dialog.setVisible(true); | ||
if (!Objects.equals(optionPane.getValue(), JOptionPane.UNINITIALIZED_VALUE)) { | ||
cancellationAction.run(); | ||
} | ||
} | ||
|
||
public void hide() { | ||
dialog.setVisible(false); | ||
} | ||
|
||
private static JProgressBar createProgressBar() { | ||
var bar = new JProgressBar(JProgressBar.HORIZONTAL); | ||
bar.setIndeterminate(true); | ||
return bar; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters