Search in sources :

Example 6 with UnitSelectorDialog

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);
    }
}
Also used : Entity(megamek.common.Entity) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog)

Example 7 with UnitSelectorDialog

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();
        }
    }
}
Also used : Entity(megamek.common.Entity) JFileChooser(javax.swing.JFileChooser) MechFileParser(megamek.common.MechFileParser) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) File(java.io.File) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog)

Example 8 with UnitSelectorDialog

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);
}
Also used : Entity(megamek.common.Entity) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog)

Example 9 with UnitSelectorDialog

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!");
        }
    }
}
Also used : Entity(megamek.common.Entity) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog)

Aggregations

UnitLoadingDialog (megamek.client.ui.swing.UnitLoadingDialog)9 UnitSelectorDialog (megamek.client.ui.swing.UnitSelectorDialog)9 Entity (megamek.common.Entity)9 File (java.io.File)1 JFileChooser (javax.swing.JFileChooser)1 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)1 MegaMek (megamek.MegaMek)1 Aero (megamek.common.Aero)1 BattleArmor (megamek.common.BattleArmor)1 MechFileParser (megamek.common.MechFileParser)1 MegaMekLabMainUI (megameklab.com.ui.MegaMekLabMainUI)1