use of jack.rm.data.romset.Settings in project rom-manager by Jakz.
the class InfoPanel method buildPopupMenu.
public void buildPopupMenu() {
customPopup.removeAll();
JMenu embedded = new JMenu("Embedded");
customPopup.add(embedded);
JMenu custom = new JMenu("Custom");
customPopup.add(custom);
Attribute[] cattributes = new Attribute[] { GameAttribute.GENRE, GameAttribute.TAG, GameAttribute.EXPORT_TITLE };
MyGameSetFeatures helper = set.helper();
Settings settings = helper.settings();
List<Attribute> enabledAttribs = settings.getRomAttributes();
Stream<Attribute> eattributes = Arrays.stream(set.getSupportedAttributes());
Runnable menuItemPostAction = () -> {
buildMainLayout();
buildFields();
pFields.revalidate();
updateFields(game);
buildPopupMenu();
};
for (Attribute cattrib : cattributes) {
JMenuItem item = null;
if (enabledAttribs.contains(cattrib)) {
item = new JMenuItem("Remove \'" + cattrib.getCaption() + "\'");
item.addActionListener(e -> {
settings.getRomAttributes().remove(cattrib);
set.stream().forEach(r -> r.clearCustomAttribute(cattrib));
menuItemPostAction.run();
});
} else {
item = new JMenuItem("Add \'" + cattrib.getCaption() + "\'");
item.addActionListener(e -> {
settings.getRomAttributes().add(cattrib);
menuItemPostAction.run();
});
}
custom.add(item);
}
eattributes.forEach(eattrib -> {
JMenuItem item = null;
if (enabledAttribs.contains(eattrib)) {
item = new JMenuItem("Hide \'" + eattrib.getCaption() + "\'");
item.addActionListener(e -> {
settings.getRomAttributes().remove(eattrib);
menuItemPostAction.run();
});
} else {
item = new JMenuItem("Show \'" + eattrib.getCaption() + "\'");
item.addActionListener(e -> {
List<Attribute> newAttributes = Arrays.stream(set.getSupportedAttributes()).filter(ee -> enabledAttribs.contains(ee) || ee == eattrib).collect(Collectors.toList());
enabledAttribs.stream().filter(ee -> !Arrays.asList(set.getSupportedAttributes()).contains(ee)).forEach(newAttributes::add);
enabledAttribs.clear();
enabledAttribs.addAll(newAttributes);
menuItemPostAction.run();
});
}
embedded.add(item);
});
}
use of jack.rm.data.romset.Settings in project rom-manager by Jakz.
the class Organizer method cleanup.
public void cleanup() {
MyGameSetFeatures helper = set.helper();
Settings settings = helper.settings();
Set<CleanupPlugin> plugins = settings.plugins.getEnabledPlugins(PluginRealType.ROMSET_CLEANUP);
plugins.stream().forEach(p -> p.execute(set));
}
use of jack.rm.data.romset.Settings in project rom-manager by Jakz.
the class MoveUnknownFilesPlugin method execute.
@Override
public void execute(GameSet set) {
try {
counter = 0;
if (!Files.exists(path) || !Files.isDirectory(path))
Files.createDirectory(path);
Set<Path> existing = set.romStream().filter(r -> r.isPresent()).map(r -> r.handle().path()).collect(Collectors.toSet());
Settings settings = getGameSetSettings();
Set<Path> total = new FolderScanner(FileSystems.getDefault().getPathMatcher("glob:*.*"), settings.getIgnoredPaths(), true).scan(settings.romsPath);
total.removeAll(existing);
total.stream().filter(f -> !f.getParent().equals(path)).forEach(f -> {
Path dest = path.resolve(f.getFileName());
int i = 1;
while (Files.exists(dest)) dest = path.resolve(f.getFileName().toString() + (i++));
try {
Files.move(f, dest);
++counter;
} catch (IOException e) {
e.printStackTrace();
/* TODO: log */
}
});
message("Moved " + counter + " unknown files");
} catch (IOException e) {
e.printStackTrace();
// TODO: log
}
}
use of jack.rm.data.romset.Settings in project rom-manager by Jakz.
the class InfoPanel method buildFields.
void buildFields() {
MyGameSetFeatures helper = set.helper();
Settings settings = helper.settings();
List<Attribute> attributes = settings.getRomAttributes();
fields = attributes.stream().map(a -> buildField(a, true)).collect(Collectors.toList());
/* add file name and path attributes only if there is a single rom per game */
if (set.hasFeature(Feature.SINGLE_ROM_PER_GAME)) {
// TODO: hardcoded for now
fields.add(buildField(RomAttribute.CRC, false));
fields.add(buildField(GameAttribute.PATH, false));
}
pFields.removeAll();
pFields.setLayout(new MigLayout());
for (AttributeField field : fields) {
pFields.add(field.title, "span 4");
if (field.deleteButton != null) {
pFields.add(field.getComponent(), "span 8, growx");
pFields.add(field.deleteButton, "wrap");
} else
pFields.add(field.getComponent(), "span 9, growx, wrap");
}
pFields.add(addCustomFieldButton);
pFields.add(editButton);
pFields.add(resetCustomFieldsButton);
}
use of jack.rm.data.romset.Settings in project rom-manager by Jakz.
the class SetInfoPanel method updateFields.
public void updateFields(GameSet set) {
this.set = set;
MyGameSetFeatures helper = set.helper();
Settings settings = helper.settings();
if (settings.romsPath != null)
romsPathButton.setPath(settings.romsPath);
else
romsPathButton.clear();
}
Aggregations