fix: only empty fields are pre-selected in the scraper dialog when opened
This commit is contained in:
parent
5ef84bf316
commit
1ebd4a14e7
|
@ -276,7 +276,7 @@ public class GameDetailsBackgroundPanel extends JPanel
|
|||
{
|
||||
if (scraperDialog == null)
|
||||
{
|
||||
scraperDialog = new ScraperDialog(MainWindow.getInstance(), scraperManager);
|
||||
scraperDialog = new ScraperDialog(MainWindow.getInstance(), scraperManager, model.getInfoModel());
|
||||
scraperDialog.pack();
|
||||
scraperDialog.setLocationRelativeTo(MainWindow.getInstance());
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import javax.swing.UIManager;
|
|||
import javax.swing.event.HyperlinkEvent;
|
||||
|
||||
import se.lantz.manager.ScraperManager;
|
||||
import se.lantz.model.InfoModel;
|
||||
import se.lantz.model.data.ScraperFields;
|
||||
import se.lantz.util.ExceptionHandler;
|
||||
|
||||
|
@ -50,11 +51,13 @@ public class C64comOptionsPanel extends JPanel
|
|||
private JButton okButton;
|
||||
private JCheckBox genreCheckBox;
|
||||
private JCheckBox composerCheckBox;
|
||||
private InfoModel model;
|
||||
|
||||
public C64comOptionsPanel(ScraperManager scraper, JButton okButton)
|
||||
public C64comOptionsPanel(ScraperManager scraper, JButton okButton, InfoModel model)
|
||||
{
|
||||
this.scraper = scraper;
|
||||
this.okButton = okButton;
|
||||
this.model = model;
|
||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||
setLayout(gridBagLayout);
|
||||
GridBagConstraints gbc_infoLabel = new GridBagConstraints();
|
||||
|
@ -386,4 +389,16 @@ public class C64comOptionsPanel extends JPanel
|
|||
}
|
||||
return composerCheckBox;
|
||||
}
|
||||
|
||||
public void preSelectFields()
|
||||
{
|
||||
getTitleCheckBox().setSelected(model.getTitle().isEmpty());
|
||||
getAuthorCheckBox().setSelected(model.getAuthor().isEmpty());
|
||||
getYearCheckBox().setSelected(model.getYear() == 1986 && model.isNewGame());
|
||||
getGenreCheckBox().setSelected(model.getGenre().isEmpty());
|
||||
getComposerCheckBox().setSelected(model.getComposer().isEmpty());
|
||||
getCoverCheckBox().setSelected(model.getCoverFile().isEmpty() && model.getCoverImage() == null);
|
||||
getScreensCheckBox().setSelected((model.getScreens1File().isEmpty() && model.getScreen1Image() == null) || (model.getScreens1File().isEmpty() && model.getScreen1Image() == null));
|
||||
getGameCheckBox().setSelected(model.getGamesFile().isEmpty() && model.getGamesPath() == null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import javax.swing.UIManager;
|
|||
import javax.swing.event.HyperlinkEvent;
|
||||
|
||||
import se.lantz.manager.ScraperManager;
|
||||
import se.lantz.model.InfoModel;
|
||||
import se.lantz.model.data.ScraperFields;
|
||||
import se.lantz.util.ExceptionHandler;
|
||||
|
||||
|
@ -49,11 +50,13 @@ public class Gb64comOptionsPanel extends JPanel
|
|||
private JButton okButton;
|
||||
private JCheckBox genreCheckBox;
|
||||
private JCheckBox composerCheckBox;
|
||||
private InfoModel model;
|
||||
|
||||
public Gb64comOptionsPanel(ScraperManager scraper, JButton okButton)
|
||||
public Gb64comOptionsPanel(ScraperManager scraper, JButton okButton, InfoModel model)
|
||||
{
|
||||
this.scraper = scraper;
|
||||
this.okButton = okButton;
|
||||
this.model = model;
|
||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||
setLayout(gridBagLayout);
|
||||
GridBagConstraints gbc_infoLabel = new GridBagConstraints();
|
||||
|
@ -368,4 +371,15 @@ public class Gb64comOptionsPanel extends JPanel
|
|||
}
|
||||
return composerCheckBox;
|
||||
}
|
||||
|
||||
public void preSelectFields()
|
||||
{
|
||||
getTitleCheckBox().setSelected(model.getTitle().isEmpty());
|
||||
getAuthorCheckBox().setSelected(model.getAuthor().isEmpty());
|
||||
getYearCheckBox().setSelected(model.getYear() == 1986 && model.isNewGame());
|
||||
getGenreCheckBox().setSelected(model.getGenre().isEmpty());
|
||||
getComposerCheckBox().setSelected(model.getComposer().isEmpty());
|
||||
getScreensCheckBox().setSelected((model.getScreens1File().isEmpty() && model.getScreen1Image() == null) || (model.getScreens1File().isEmpty() && model.getScreen1Image() == null));
|
||||
getGameCheckBox().setSelected(model.getGamesFile().isEmpty() && model.getGamesPath() == null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import javax.swing.UIManager;
|
|||
import javax.swing.event.HyperlinkEvent;
|
||||
|
||||
import se.lantz.manager.ScraperManager;
|
||||
import se.lantz.model.InfoModel;
|
||||
import se.lantz.model.data.ScraperFields;
|
||||
import se.lantz.util.ExceptionHandler;
|
||||
|
||||
|
@ -50,11 +51,13 @@ public class MobyGamesOptionsPanel extends JPanel
|
|||
private JButton okButton;
|
||||
private JCheckBox genreCheckBox;
|
||||
private JCheckBox composerCheckBox;
|
||||
private InfoModel model;
|
||||
|
||||
public MobyGamesOptionsPanel(ScraperManager scraper, JButton okButton)
|
||||
public MobyGamesOptionsPanel(ScraperManager scraper, JButton okButton, InfoModel model)
|
||||
{
|
||||
this.scraper = scraper;
|
||||
this.okButton = okButton;
|
||||
this.model = model;
|
||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||
setLayout(gridBagLayout);
|
||||
GridBagConstraints gbc_infoLabel = new GridBagConstraints();
|
||||
|
@ -384,4 +387,16 @@ public class MobyGamesOptionsPanel extends JPanel
|
|||
}
|
||||
return composerCheckBox;
|
||||
}
|
||||
|
||||
public void preSelectFields()
|
||||
{
|
||||
getTitleCheckBox().setSelected(model.getTitle().isEmpty());
|
||||
getAuthorCheckBox().setSelected(model.getAuthor().isEmpty());
|
||||
getYearCheckBox().setSelected(model.getYear() == 1986 && model.isNewGame());
|
||||
getGenreCheckBox().setSelected(model.getGenre().isEmpty());
|
||||
getDescriptionCheckBox().setSelected(model.getDescription().isEmpty());
|
||||
getComposerCheckBox().setSelected(model.getComposer().isEmpty());
|
||||
getCoverCheckBox().setSelected(model.getCoverFile().isEmpty() && model.getCoverImage() == null);
|
||||
getScreensCheckBox().setSelected((model.getScreens1File().isEmpty() && model.getScreen1Image() == null) || (model.getScreens1File().isEmpty() && model.getScreen1Image() == null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import javax.swing.JPanel;
|
|||
import se.lantz.gui.BaseDialog;
|
||||
import se.lantz.manager.ScraperManager;
|
||||
import se.lantz.manager.ScraperManager.SCRAPER;
|
||||
import se.lantz.model.InfoModel;
|
||||
import se.lantz.model.data.ScraperFields;
|
||||
|
||||
public class ScraperDialog extends BaseDialog
|
||||
|
@ -35,10 +36,12 @@ public class ScraperDialog extends BaseDialog
|
|||
private JLabel scraperInfoLabel;
|
||||
private JComboBox scraperComboBox;
|
||||
private JPanel cardPanel;
|
||||
private InfoModel model;
|
||||
|
||||
public ScraperDialog(Frame owner, ScraperManager scraper)
|
||||
public ScraperDialog(Frame owner, ScraperManager scraper, InfoModel model)
|
||||
{
|
||||
super(owner);
|
||||
this.model = model;
|
||||
setTitle("Scrape game information");
|
||||
this.scraper = scraper;
|
||||
JPanel content = new JPanel();
|
||||
|
@ -58,7 +61,7 @@ public class ScraperDialog extends BaseDialog
|
|||
{
|
||||
if (mobyGamesPanel == null)
|
||||
{
|
||||
mobyGamesPanel = new MobyGamesOptionsPanel(scraper, getOkButton());
|
||||
mobyGamesPanel = new MobyGamesOptionsPanel(scraper, getOkButton(), model);
|
||||
}
|
||||
return mobyGamesPanel;
|
||||
}
|
||||
|
@ -67,7 +70,7 @@ public class ScraperDialog extends BaseDialog
|
|||
{
|
||||
if (c64comPanel == null)
|
||||
{
|
||||
c64comPanel = new C64comOptionsPanel(scraper, getOkButton());
|
||||
c64comPanel = new C64comOptionsPanel(scraper, getOkButton(), model);
|
||||
}
|
||||
return c64comPanel;
|
||||
}
|
||||
|
@ -76,7 +79,7 @@ public class ScraperDialog extends BaseDialog
|
|||
{
|
||||
if (gb64comPanel == null)
|
||||
{
|
||||
gb64comPanel = new Gb64comOptionsPanel(scraper, getOkButton());
|
||||
gb64comPanel = new Gb64comOptionsPanel(scraper, getOkButton(), model);
|
||||
}
|
||||
return gb64comPanel;
|
||||
}
|
||||
|
@ -100,6 +103,9 @@ public class ScraperDialog extends BaseDialog
|
|||
@Override
|
||||
public boolean showDialog()
|
||||
{
|
||||
getMobyGamesPanel().preSelectFields();
|
||||
getC64comPanel().preSelectFields();
|
||||
getGb64comPanel().preSelectFields();
|
||||
getMobyGamesPanel().getUrlTextField().requestFocusInWindow();
|
||||
this.getRootPane().setDefaultButton(getMobyGamesPanel().getConnectButton());
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ public class GameDetails
|
|||
|
||||
public GameDetails()
|
||||
{
|
||||
setTitle("New Game");
|
||||
setJoy1("J:1:" + JoystickModel.DEFAULT_CONFIG);
|
||||
setJoy2("J:2*:" + JoystickModel.DEFAULT_CONFIG);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue