Skip to content

Commit

Permalink
added saving of Dialog location and size for Generate CSD to SCreen [c…
Browse files Browse the repository at this point in the history
…loses #357]
  • Loading branch information
kunstmusik committed May 3, 2017
1 parent 8c266b0 commit 8b54d24
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ NEW
* Issue #355 - Added default layer heights to Program Options->Project Defaults;
added default layer height as property for AudioLayerGroups

* Issue #357 - Added maintenance of dialog size/location when Generating CSD to
Screen

UPDATED

* Mixer:
Expand Down
72 changes: 68 additions & 4 deletions blue-ui-core/src/blue/gui/InfoDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.InvocationTargetException;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import javax.swing.AbstractAction;
import javax.swing.JDialog;
import javax.swing.JPanel;
Expand All @@ -37,6 +41,7 @@
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import org.openide.util.Exceptions;
import org.openide.util.NbPreferences;
import org.openide.windows.WindowManager;

/**
Expand Down Expand Up @@ -84,9 +89,39 @@ public static synchronized final void showInformationDialog(Component parent,
dlg.setModal(true);
dlg.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dlg.setTitle(title);
dlg.setSize(new Dimension(760, 400));

GUI.centerOnScreen(dlg);
final Preferences prefs = NbPreferences.forModule(
InfoDialog.class);

int w = prefs.getInt("infoDialogWidth", 760);
int h = prefs.getInt("infoDialogHeight", 400);

dlg.setSize(new Dimension(w, h));
dlg.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
final Preferences prefs = NbPreferences.forModule(
InfoDialog.class);

prefs.putInt("infoDialogWidth", dlg.getWidth());
prefs.putInt("infoDialogHeight", dlg.getHeight());
prefs.putInt("infoDialogX", dlg.getX());
prefs.putInt("infoDialogY", dlg.getY());
try {
prefs.sync();
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
}
});

int x = prefs.getInt("infoDialogX", -1);
int y = prefs.getInt("infoDialogY", -1);
if (x > 0 && y > 0) {
dlg.setLocation(x, y);
} else {
GUI.centerOnScreen(dlg);
}
dlg.setVisible(true);
infoText.setText("");
}
Expand All @@ -100,9 +135,38 @@ public static final void showInformationDialogTabs(String information,
tabs = new JTabbedPane();
dialog.getContentPane().add(tabs);

dialog.setSize(640, 480);
final Preferences prefs = NbPreferences.forModule(
InfoDialog.class);

int w = prefs.getInt("infoDialogTabsWidth", 640);
int h = prefs.getInt("infoDialogTabsHeight", 480);

dialog.setSize(new Dimension(w, h));
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
final Preferences prefs = NbPreferences.forModule(
InfoDialog.class);

prefs.putInt("infoDialogTabsWidth", dialog.getWidth());
prefs.putInt("infoDialogTabsHeight", dialog.getHeight());
prefs.putInt("infoDialogTabsX", dialog.getX());
prefs.putInt("infoDialogTabsY", dialog.getY());
try {
prefs.sync();
} catch (BackingStoreException ex) {
Exceptions.printStackTrace(ex);
}
}
});

GUI.centerOnScreen(dialog);
int x = prefs.getInt("infoDialogTabsX", -1);
int y = prefs.getInt("infoDialogTabsY", -1);
if (x > 0 && y > 0) {
dialog.setLocation(x, y);
} else {
GUI.centerOnScreen(dialog);
}

popup = new JPopupMenu();

Expand Down

0 comments on commit 8b54d24

Please sign in to comment.