Advertisement
Kartom

TaskMonitorDialog.java

Oct 25th, 2024
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.82 KB | Source Code | 0 0
  1. package com.pnfsoftware.jeb.rcpclient.extensions.p002ui;
  2.  
  3. /* loaded from: jeb.apk:com/pnfsoftware/rcpclient/extensions/ui/TaskMonitorDialog.class */
  4. public class TaskMonitorDialog extends com.pnfsoftware.jeb.rcpclient.dialogs.JebDialog {
  5.     private static final com.pnfsoftware.jeb.util.logging.ILogger logger = com.pnfsoftware.jeb.util.logging.GlobalLog.getLogger(com.pnfsoftware.jeb.rcpclient.extensions.p002ui.TaskMonitorDialog.class);
  6.     private java.lang.String[] labels;
  7.     private org.eclipse.swt.widgets.Label[] wLabels;
  8.  
  9.     /* renamed from: t */
  10.     private java.lang.Thread f4144t;
  11.  
  12.     /* renamed from: ex */
  13.     private java.lang.Exception f4145ex;
  14.     private long popupTimeout;
  15.     private volatile boolean canceled;
  16.     com.pnfsoftware.jeb.rcpclient.extensions.p002ui.ITaskProgressMonitor monitor;
  17.  
  18.     public TaskMonitorDialog(org.eclipse.swt.widgets.Shell parent) {
  19.         this(parent, 0L);
  20.     }
  21.  
  22.     public TaskMonitorDialog(org.eclipse.swt.widgets.Shell parent, long popupTimeout) {
  23.         super(parent, 67616, "Task", (java.lang.String) null);
  24.         this.labels = new java.lang.String[]{"Please wait...", "", "", ""};
  25.         this.wLabels = new org.eclipse.swt.widgets.Label[this.labels.length];
  26.         this.monitor = new com.pnfsoftware.jeb.rcpclient.extensions.p002ui.TaskMonitorDialog$Monitor(this);
  27.         this.doNotCloseOnEscape = true;
  28.         this.boundsRestorationType = com.pnfsoftware.jeb.rcpclient.extensions.ShellWrapper$BoundsRestorationType.NONE;
  29.         this.doNotOpenShell = true;
  30.         this.doNotDispatchEvents = true;
  31.         this.popupTimeout = popupTimeout;
  32.     }
  33.  
  34.     @Override // com.pnfsoftware.jeb.rcpclient.dialogs.JebDialog
  35.     protected void createContents(org.eclipse.swt.widgets.Composite parent) {
  36.         com.pnfsoftware.jeb.rcpclient.extensions.UIUtil.setStandardLayout(parent, 1);
  37.         org.eclipse.swt.widgets.Composite c = new org.eclipse.swt.widgets.Composite(parent, 0);
  38.         org.eclipse.swt.layout.GridData data = new org.eclipse.swt.layout.GridData();
  39.         data.grabExcessHorizontalSpace = true;
  40.         data.minimumWidth = 680;
  41.         data.grabExcessVerticalSpace = true;
  42.         data.minimumHeight = 140;
  43.         c.setLayoutData(data);
  44.         com.pnfsoftware.jeb.rcpclient.extensions.UIUtil.setStandardLayout(c, 1);
  45.         for (int i = 0; i < this.wLabels.length; i++) {
  46.             this.wLabels[i] = new org.eclipse.swt.widgets.Label(c, 0);
  47.             this.wLabels[i].setText(com.pnfsoftware.jeb.util.format.Strings.safe(this.labels[i]));
  48.             this.wLabels[i].setLayoutData(com.pnfsoftware.jeb.rcpclient.extensions.UIUtil.createGridDataFillHorizontally());
  49.         }
  50.         createButtons(parent, 256, 256);
  51.     }
  52.  
  53.     /* JADX INFO: Access modifiers changed from: protected */
  54.     @Override // com.pnfsoftware.jeb.rcpclient.dialogs.JebDialog
  55.     public void onButtonClick(int style) {
  56.         if (style == 256) {
  57.             this.monitor.setCanceled(true);
  58.             getButtonByStyle(256).setEnabled(false);
  59.         } else {
  60.             super.onButtonClick(style);
  61.         }
  62.     }
  63.  
  64.     public void run(com.pnfsoftware.jeb.rcpclient.extensions.p002ui.UITask<?> task) throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException {
  65.         if (org.eclipse.swt.widgets.Display.getCurrent() == null) {
  66.             throw new java.lang.RuntimeException("TaskMonitorDialog.run() must be called from the UI thread");
  67.         }
  68.         this.f4144t = com.pnfsoftware.jeb.util.concurrent.ThreadUtil.start(new com.pnfsoftware.jeb.rcpclient.extensions.p002ui.TaskMonitorDialog$1(this, task));
  69.         super.open();
  70.         long t0 = java.lang.System.currentTimeMillis();
  71.         org.eclipse.swt.graphics.Rectangle bounds0 = this.shell.getBounds();
  72.         this.shell.setBounds(0, -50, 1, 1);
  73.         boolean hiddenShell = true;
  74.         this.shell.open();
  75.         org.eclipse.swt.widgets.Display display = this.shell.getDisplay();
  76.         while (true) {
  77.             if (this.shell.isDisposed()) {
  78.                 break;
  79.             }
  80.             if (!display.readAndDispatch()) {
  81.                 this.f4144t.join(20L);
  82.                 if (this.monitor.isCanceled()) {
  83.                     this.f4144t.interrupt();
  84.                 }
  85.                 if (!this.f4144t.isAlive()) {
  86.                     this.shell.close();
  87.                     break;
  88.                 }
  89.                 if (hiddenShell && java.lang.System.currentTimeMillis() - t0 >= this.popupTimeout) {
  90.                     org.eclipse.swt.graphics.Rectangle displaybounds = this.shell.getDisplay().getClientArea();
  91.                     int offx = 0;
  92.                     int offy = 0;
  93.                     org.eclipse.swt.widgets.Composite parent = this.shell.getParent();
  94.                     if (parent != null) {
  95.                         org.eclipse.swt.graphics.Rectangle r = parent.getBounds();
  96.                         offx = (r.x + (r.width / 2)) - (displaybounds.x + (displaybounds.width / 2));
  97.                         offy = (r.y + (r.height / 2)) - (displaybounds.y + (displaybounds.height / 2));
  98.                     }
  99.                     this.shell.setBounds(displaybounds.x + ((displaybounds.width - bounds0.width) / 2) + offx, displaybounds.y + ((displaybounds.height - bounds0.height) / 2) + offy, bounds0.width, bounds0.height);
  100.                     hiddenShell = false;
  101.                 }
  102.             }
  103.         }
  104.         if (this.f4145ex instanceof java.lang.reflect.InvocationTargetException) {
  105.             throw ((java.lang.reflect.InvocationTargetException) this.f4145ex);
  106.         }
  107.         if (this.f4145ex instanceof java.lang.InterruptedException) {
  108.             throw ((java.lang.InterruptedException) this.f4145ex);
  109.         }
  110.         if (this.f4145ex != null) {
  111.             com.pnfsoftware.jeb.util.base.Throwables.rethrowUnchecked(this.f4145ex);
  112.         }
  113.     }
  114. }
Tags: JEB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement