mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
refactor deck import content to include hints
This commit is contained in:
parent
baeb9d8b00
commit
b1df464e8f
2 changed files with 24 additions and 6 deletions
|
@ -16,6 +16,15 @@ import javax.swing.*;
|
|||
|
||||
public class DeckImportFromClipboardDialog extends JDialog {
|
||||
|
||||
private static final String FORMAT_TEXT =
|
||||
"// Example:\n" +
|
||||
"//1 Library of Congress\n" +
|
||||
"//1 Cryptic Gateway\n" +
|
||||
"//1 Azami, Lady of Scrolls\n" +
|
||||
"// NB: This is slow as, and will lock your screen :)\n" +
|
||||
"\n" +
|
||||
"// Your current clipboard:\n";
|
||||
|
||||
private JPanel contentPane;
|
||||
private JButton buttonOK;
|
||||
private JButton buttonCancel;
|
||||
|
@ -25,6 +34,9 @@ public class DeckImportFromClipboardDialog extends JDialog {
|
|||
|
||||
public DeckImportFromClipboardDialog() {
|
||||
initComponents();
|
||||
|
||||
onRefreshClipboard();
|
||||
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
getRootPane().setDefaultButton(buttonOK);
|
||||
|
@ -42,8 +54,6 @@ public class DeckImportFromClipboardDialog extends JDialog {
|
|||
|
||||
// Close on "ESC"
|
||||
contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||
|
||||
getClipboardStringData().ifPresent(content -> txtDeckList.setText(content));
|
||||
}
|
||||
|
||||
private Optional<String> getClipboardStringData() {
|
||||
|
@ -75,6 +85,10 @@ public class DeckImportFromClipboardDialog extends JDialog {
|
|||
dispose();
|
||||
}
|
||||
|
||||
private void onRefreshClipboard() {
|
||||
txtDeckList.setText(FORMAT_TEXT + getClipboardStringData().orElse(""));
|
||||
}
|
||||
|
||||
public String getTmpPath() {
|
||||
return tmpPath;
|
||||
}
|
||||
|
@ -158,7 +172,7 @@ public class DeckImportFromClipboardDialog extends JDialog {
|
|||
|
||||
txtDeckList.setMinimumSize(new Dimension(250, 400));
|
||||
txtDeckList.setPreferredSize(new Dimension(550, 400));
|
||||
txtDeckList.setText("// Example:\n//1 Library of Congress\n//1 Cryptic Gateway\n//1 Azami, Lady of Scrolls\n// NB: This is slow as, and will lock your screen :)");
|
||||
txtDeckList.setText(FORMAT_TEXT);
|
||||
JScrollPane txtScrollableDeckList = new JScrollPane(txtDeckList);
|
||||
panel3.add(txtScrollableDeckList, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
|
||||
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||
|
|
|
@ -26,6 +26,8 @@ import mage.view.CardView;
|
|||
import mage.view.PermanentView;
|
||||
import net.xeoh.plugins.base.PluginManager;
|
||||
import net.xeoh.plugins.base.impl.PluginManagerFactory;
|
||||
import net.xeoh.plugins.base.util.uri.ClassURI;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.CardPluginImpl;
|
||||
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
|
||||
|
@ -46,13 +48,15 @@ public enum Plugins implements MagePlugins {
|
|||
|
||||
@Override
|
||||
public void loadPlugins() {
|
||||
|
||||
LOGGER.info("Loading plugins...");
|
||||
pm = PluginManagerFactory.createPluginManager();
|
||||
pm.addPluginsFrom(new File(PLUGINS_DIRECTORY + File.separator).toURI());
|
||||
this.cardPlugin = new CardPluginImpl();
|
||||
pm.addPluginsFrom(new ClassURI(CardPluginImpl.class).toURI());
|
||||
pm.addPluginsFrom(new ClassURI(ThemePluginImpl.class).toURI());
|
||||
|
||||
this.cardPlugin = pm.getPlugin(CardPlugin.class);
|
||||
this.counterPlugin = pm.getPlugin(CounterPlugin.class);
|
||||
this.themePlugin = new ThemePluginImpl();
|
||||
this.themePlugin = pm.getPlugin(ThemePlugin.class);
|
||||
LOGGER.info("Done.");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue