use of megamek.client.ui.swing.UnitSelectorDialog in project megameklab by MegaMek.
the class UnitPrintManager method selectUnitToPrint.
public static void selectUnitToPrint(JFrame parent) {
UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parent);
UnitSelectorDialog viewer = new UnitSelectorDialog(parent, unitLoadingDialog, true);
Entity entity = null;
entity = viewer.getChosenEntity();
viewer.setVisible(false);
viewer.dispose();
if (null != entity) {
UnitPrintManager.printEntity(entity);
}
}
use of megamek.client.ui.swing.UnitSelectorDialog in project megameklab by MegaMek.
the class UnitPrintQueueDialog method actionPerformed.
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == bCancel) {
dispose();
}
if (ae.getSource() == bPrint) {
UnitPrintManager.printAllUnits(units, chSinglePrint.isSelected());
dispose();
}
if (ae.getSource().equals(bSelectCache)) {
UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(clientgui);
unitLoadingDialog.setVisible(true);
UnitSelectorDialog viewer = new UnitSelectorDialog(clientgui, unitLoadingDialog, true);
viewer.setVisible(false);
Entity entity = viewer.getChosenEntity();
if (entity != null) {
units.add(entity);
refresh();
}
} else if (ae.getSource().equals(bSelectFile)) {
String filePathName = System.getProperty("user.dir").toString() + "/data/mechfiles/";
JFileChooser f = new JFileChooser(filePathName);
f.setLocation(clientgui.getLocation().x + 150, clientgui.getLocation().y + 100);
f.setDialogTitle("Print Unit File");
f.setMultiSelectionEnabled(true);
FileNameExtensionFilter filter = new FileNameExtensionFilter("Unit Files", "blk", "mtf");
// Add a filter
f.setFileFilter(filter);
int returnVal = f.showOpenDialog(clientgui);
if ((returnVal != JFileChooser.APPROVE_OPTION) || (f.getSelectedFile() == null)) {
// I want a file, y'know!
return;
}
for (File entityFile : f.getSelectedFiles()) {
try {
Entity tempEntity = new MechFileParser(entityFile).getEntity();
units.add(tempEntity);
} catch (Exception ex) {
ex.printStackTrace();
}
}
refresh();
} else if (ae.getSource().equals(bRemove)) {
if (unitList.getSelectedIndices().length > 0) {
for (int pos = unitList.getSelectedIndices().length - 1; pos >= 0; pos--) {
units.remove(unitList.getSelectedIndices()[pos]);
}
refresh();
}
}
}
use of megamek.client.ui.swing.UnitSelectorDialog in project megameklab by MegaMek.
the class MenuBarCreator method jMenuGetUnitValidationFromCache_actionPerformed.
private void jMenuGetUnitValidationFromCache_actionPerformed() {
UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parentFrame);
unitLoadingDialog.setVisible(true);
UnitSelectorDialog viewer = new UnitSelectorDialog(parentFrame, unitLoadingDialog, true);
Entity tempEntity = viewer.getChosenEntity();
if (null == tempEntity) {
return;
}
UnitUtil.showValidation(tempEntity, parentFrame);
}
use of megamek.client.ui.swing.UnitSelectorDialog in project megameklab by MegaMek.
the class UnitPrintManager method printSelectedUnit.
public static void printSelectedUnit(JFrame parent) {
UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parent);
unitLoadingDialog.setVisible(true);
UnitSelectorDialog viewer = new UnitSelectorDialog(parent, unitLoadingDialog, true);
viewer.setVisible(false);
Entity entity = viewer.getChosenEntity();
if (entity != null) {
boolean printed = UnitPrintManager.printEntity(entity);
viewer.dispose();
if (!printed) {
JOptionPane.showMessageDialog(parent, "Unable to print that unit type!");
}
}
}
Aggregations