mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Block user operations
This commit is contained in:
+42
-28
@@ -1,42 +1,56 @@
|
|||||||
package org.diylc.swing.gui;
|
package org.diylc.swing.gui;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
import java.awt.Cursor;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.Point;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseMotionAdapter;
|
import java.awt.event.MouseListener;
|
||||||
|
|
||||||
import javax.swing.Icon;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JComponent;
|
|
||||||
|
|
||||||
public class CustomGlassPane extends JComponent {
|
public class CustomGlassPane extends JPanel implements MouseListener,
|
||||||
|
KeyListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
public static final CustomGlassPane GLASS_PANE = new CustomGlassPane();
|
||||||
private Icon icon;
|
|
||||||
|
private static final long serialVersionUID = -5344758920442881290L;
|
||||||
|
|
||||||
public CustomGlassPane() {
|
public CustomGlassPane() {
|
||||||
super();
|
addKeyListener(this);
|
||||||
addMouseMotionListener(new MouseMotionAdapter() {
|
addMouseListener(this);
|
||||||
|
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||||
@Override
|
setOpaque(false);
|
||||||
public void mouseMoved(MouseEvent e) {
|
|
||||||
if (icon != null) {
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCursorIcon(Icon icon) {
|
|
||||||
this.icon = icon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void mouseClicked(final MouseEvent pArg0) {
|
||||||
Point cursor = getMousePosition();
|
|
||||||
if ((icon != null) && (cursor != null)) {
|
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
|
||||||
icon.paintIcon(this, g2d, cursor.x + 10, cursor.y + 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(final MouseEvent pArg0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(final MouseEvent pArg0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(final MouseEvent pArg0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(final MouseEvent pArg0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(KeyEvent e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -148,7 +148,7 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// setGlassPane(new CustomGlassPane());
|
setGlassPane(new CustomGlassPane());
|
||||||
// getGlassPane().setVisible(true);
|
// getGlassPane().setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Object> void executeBackgroundTask(final ITask<T> task) {
|
public <T extends Object> void executeBackgroundTask(final ITask<T> task) {
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
getGlassPane().setVisible(true);
|
||||||
SwingWorker<T, Void> worker = new SwingWorker<T, Void>() {
|
SwingWorker<T, Void> worker = new SwingWorker<T, Void>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -333,7 +333,7 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
LOG.error("Task failed", e);
|
LOG.error("Task failed", e);
|
||||||
task.failed(e);
|
task.failed(e);
|
||||||
}
|
}
|
||||||
setCursor(Cursor.getDefaultCursor());
|
getGlassPane().setVisible(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
worker.execute();
|
worker.execute();
|
||||||
|
|||||||
@@ -770,6 +770,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Polygon Ground Fill component</description>
|
<description>Polygon Ground Fill component</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Block user actions during long operations (print, export, etc)</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
<url>http://code.google.com/p/diy-layout-creator/downloads/list</url>
|
||||||
</org.diylc.appframework.update.Version>
|
</org.diylc.appframework.update.Version>
|
||||||
|
|||||||
Reference in New Issue
Block a user