use of megamek.common.MechView in project megameklab by MegaMek.
the class MenuBarCreator method jMenuExportEntityText_actionPerformed.
public void jMenuExportEntityText_actionPerformed(ActionEvent event) {
if (UnitUtil.validateUnit(parentFrame.getEntity()).length() > 0) {
JOptionPane.showMessageDialog(parentFrame, "Warning: exporting an invalid unit!");
}
String unitName = parentFrame.getEntity().getChassis() + " " + parentFrame.getEntity().getModel();
MechView mview = new MechView(parentFrame.getEntity(), true, true, false);
FileDialog fDialog = new FileDialog(parentFrame, "Save As", FileDialog.SAVE);
String filePathName = new File(System.getProperty("user.dir").toString()).getAbsolutePath();
fDialog.setDirectory(filePathName);
fDialog.setFile(unitName + ".txt");
fDialog.setLocationRelativeTo(parentFrame);
fDialog.setVisible(true);
if (fDialog.getFile() != null) {
filePathName = fDialog.getDirectory() + fDialog.getFile();
} else {
return;
}
try {
FileOutputStream out = new FileOutputStream(filePathName);
PrintStream p = new PrintStream(out);
p.println(mview.getMechReadout());
p.close();
out.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
use of megamek.common.MechView in project megameklab by MegaMek.
the class MenuBarCreator method jMenuExportEntityClipboard_actionPerformed.
public void jMenuExportEntityClipboard_actionPerformed(ActionEvent event) {
MechView mview = new MechView(parentFrame.getEntity(), true, true, false);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(mview.getMechReadout());
clipboard.setContents(stringSelection, this);
}
use of megamek.common.MechView in project megameklab by MegaMek.
the class PreviewTab method refresh.
public void refresh() {
boolean populateTextFields = true;
MechView mechView = null;
try {
mechView = new MechView(getInfantry(), false);
} catch (Exception e) {
e.printStackTrace();
// error unit didn't load right. this is bad news.
populateTextFields = false;
}
if (populateTextFields && (mechView != null)) {
panelMekView.setMech(getInfantry());
} else {
panelMekView.reset();
}
}
use of megamek.common.MechView in project megameklab by MegaMek.
the class PreviewTab method refresh.
public void refresh() {
boolean populateTextFields = true;
MechView mechView = null;
try {
mechView = new MechView(getBattleArmor(), false);
} catch (Exception e) {
e.printStackTrace();
// error unit didn't load right. this is bad news.
populateTextFields = false;
}
if (populateTextFields && (mechView != null)) {
panelMekView.setMech(getBattleArmor());
} else {
panelMekView.reset();
}
}
use of megamek.common.MechView in project megameklab by MegaMek.
the class MenuBarCreator method jMenuExportEntityHTML_actionPerformed.
public void jMenuExportEntityHTML_actionPerformed(ActionEvent event) {
if (UnitUtil.validateUnit(parentFrame.getEntity()).length() > 0) {
JOptionPane.showMessageDialog(parentFrame, "Warning: exporting an invalid unit!");
}
String unitName = parentFrame.getEntity().getChassis() + " " + parentFrame.getEntity().getModel();
MechView mview = new MechView(parentFrame.getEntity(), false);
FileDialog fDialog = new FileDialog(parentFrame, "Save As", FileDialog.SAVE);
String filePathName = new File(System.getProperty("user.dir").toString()).getAbsolutePath();
fDialog.setDirectory(filePathName);
fDialog.setFile(unitName + ".html");
fDialog.setLocationRelativeTo(parentFrame);
fDialog.setVisible(true);
if (fDialog.getFile() != null) {
filePathName = fDialog.getDirectory() + fDialog.getFile();
} else {
return;
}
try {
FileOutputStream out = new FileOutputStream(filePathName);
PrintStream p = new PrintStream(out);
p.println(mview.getMechReadout());
p.close();
out.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations