Dont know update what?
This commit is contained in:
@@ -124,6 +124,10 @@ public class IOUtils {
|
||||
return realPath;
|
||||
}
|
||||
|
||||
public static boolean isAbsolutePath(String path) {
|
||||
return path.startsWith("/") || path.indexOf(":") > 0;
|
||||
}
|
||||
|
||||
public static File currentDir() {
|
||||
return new File(".");
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/>
|
||||
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
|
||||
@@ -83,8 +83,8 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(C.i18n("logwindow.title")); // NOI18N
|
||||
addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
public void windowClosed(java.awt.event.WindowEvent evt) {
|
||||
formWindowClosed(evt);
|
||||
public void windowClosing(java.awt.event.WindowEvent evt) {
|
||||
formWindowClosing(evt);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -172,14 +172,14 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
.addComponent(btnClear)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnClose))
|
||||
.addComponent(lblCrash, javax.swing.GroupLayout.Alignment.LEADING))
|
||||
.addComponent(lblCrash, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(lblCrash, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblCrash)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
@@ -199,33 +199,15 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
|
||||
boolean flag = false;
|
||||
for (Frame f : Frame.getFrames()) {
|
||||
if (f == this)
|
||||
continue;
|
||||
if (f.isVisible())
|
||||
flag = true;
|
||||
}
|
||||
if (flag)
|
||||
this.dispose();
|
||||
else
|
||||
try {
|
||||
Utils.shutdownForcely(0);
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show(C.i18n("launcher.exit_failed"));
|
||||
HMCLog.err("Failed to shutdown forcely", e);
|
||||
}
|
||||
if (listener != null && listener.apply() && terminateGameListener != null)
|
||||
terminateGameListener.run();
|
||||
SwingUtils.exitIfNoWindow(this, true);
|
||||
}//GEN-LAST:event_btnCloseActionPerformed
|
||||
|
||||
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
|
||||
this.txtLog.setText("");
|
||||
}//GEN-LAST:event_btnClearActionPerformed
|
||||
|
||||
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
|
||||
if (listener != null && listener.apply() && terminateGameListener != null)
|
||||
terminateGameListener.run();
|
||||
}//GEN-LAST:event_formWindowClosed
|
||||
|
||||
private void btnCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCopyActionPerformed
|
||||
Utils.setClipborad(this.txtLog.getText());
|
||||
}//GEN-LAST:event_btnCopyActionPerformed
|
||||
@@ -251,6 +233,12 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
SwingUtils.openLink(C.URL_GITHUB);
|
||||
}//GEN-LAST:event_btnGitHubActionPerformed
|
||||
|
||||
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
|
||||
if (listener != null && listener.apply() && terminateGameListener != null)
|
||||
terminateGameListener.run();
|
||||
SwingUtils.exitIfNoWindow(this);
|
||||
}//GEN-LAST:event_formWindowClosing
|
||||
|
||||
public void log(String status) {
|
||||
log(status, Level.INFO);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package org.jackhuang.hellominecraft.util.ui;
|
||||
import java.awt.Component;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Frame;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@@ -41,6 +42,7 @@ import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
import org.jackhuang.hellominecraft.util.Utils;
|
||||
import org.jackhuang.hellominecraft.util.func.NonFunction;
|
||||
import org.jackhuang.hellominecraft.util.system.OS;
|
||||
|
||||
@@ -276,4 +278,27 @@ public class SwingUtils {
|
||||
}
|
||||
component.setEnabled(t);
|
||||
}
|
||||
|
||||
public static void exitIfNoWindow(Frame thisFrame) {
|
||||
exitIfNoWindow(thisFrame, false);
|
||||
}
|
||||
|
||||
public static void exitIfNoWindow(Frame thisFrame, boolean neededDispose) {
|
||||
boolean flag = false;
|
||||
for (Frame f : Frame.getFrames()) {
|
||||
if (f == thisFrame)
|
||||
continue;
|
||||
if (f.isVisible())
|
||||
flag = true;
|
||||
}
|
||||
if (!flag)
|
||||
try {
|
||||
Utils.shutdownForcely(0);
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show(C.i18n("launcher.exit_failed"));
|
||||
HMCLog.err("Failed to shutdown forcely", e);
|
||||
}
|
||||
else
|
||||
thisFrame.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,15 +45,7 @@ public class WebFrame extends JFrame {
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
boolean flag = false;
|
||||
for (Frame f : Frame.getFrames()) {
|
||||
if (f == WebFrame.this)
|
||||
continue;
|
||||
if (f.isVisible())
|
||||
flag = true;
|
||||
}
|
||||
if (!flag)
|
||||
System.exit(0);
|
||||
SwingUtils.exitIfNoWindow(WebFrame.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user