/* * @(#)Mode.java * * This file is part of webCDwriter - Network CD/DVD Writing. * * Copyright (C) 1999-2006 Jörg P. M. Haeger * * webCDwriter is free software. See CDcreator.java for details. * * Jörg Haeger, 31.03.2001 */ import javax.swing.DefaultComboBoxModel; import javax.swing.JOptionPane; /** * The mode of webCDcreator. * * @version 20060419 * @author Jörg P. M. Haeger */ class Mode { final public static String CDR = "CD-R", CDRW = "CD-RW", CDR74 = CDR + " 74", CDRW74 = CDRW + " 74", CDR80 = CDR + " 80", CDRW80 = CDRW + " 80", CDR90 = CDR + " 90"; static String medium = CDR; static int mediumSize = 650; final public static int audio = 0, data = 1; final public static int copy = 0, current = 1, server = 2; static int source = current, type = data; static boolean makeImage = true, store = false; static boolean saveImage = false; static String saveImageAs = ""; final private static String[] mediaLabels = { CDR74, CDRW74, CDR80, CDRW80 }; static DefaultComboBoxModel media = new DefaultComboBoxModel(mediaLabels) { public void setSelectedItem(Object anObject) { // System.out.println("setSelectedItem " + anObject); super.setSelectedItem(anObject); Options.overburn = false; String name = (String) anObject; if (name.startsWith(CDRW)) medium = CDRW; else if (name.startsWith(CDR)) medium = CDR; else medium = name; if (name.equals(CDR74) || name.equals(CDRW74)) mediumSize = 650; else if (name.equals(CDR80) || name.equals(CDRW80)) mediumSize = 700; else if (name.equals(CDR90)) { mediumSize = 800; Options.overburn = true; } else if (name.startsWith("DVD")) { if (name.indexOf(" DL") < 0) mediumSize = 4482; else mediumSize = 8152; } if (CDcreator.view != null) { CDcreator.view.createMenuBar(); CDcreator.view.updateCDRoot(); if (CDcreator.view.sessionSizeView != null) { CDcreator.view.sessionSizeView.repaint(); CDcreator.view.sessionSizeView.setToolTipText( CDcreator.i18n("TTsessionSize")); } } } }; static void addMedium(String name) { if (media.getIndexOf(name) < 0) if (name.equals(CDR90)) media.insertElementAt(name, media.getSize() - 1); else media.addElement(name); } static boolean audioCD() { return type == audio; } static boolean burnImageFile() { return type == data && !makeImage; } static boolean copyCD() { return source == copy; } static boolean isMediumDVD() { return medium.startsWith("DVD"); } static boolean isMediumDVDRW() { return medium.equals("DVD-RW") || medium.equals("DVD+RW") || medium.equals("DVD-RAM"); } static boolean isMedium(String name) { return ((String) media.getSelectedItem()).startsWith(name); } static boolean makeISOImage() { return source != copy && type == data && makeImage; } static void reset() { source = current; type = data; makeImage = true; store = false; } static boolean serverSession() { return source == server; } static void setMedium(String name) { int p = media.getIndexOf(name); if (p < 0) { System.out.println("Invalid medium: <" + name + ">"); return; } media.setSelectedItem(name); if (name.startsWith(CDRW) && type != audio) Options.speed = Options.speedCDRW; } static void setTypeAudio() { type = audio; Options.speed = Options.speedAudio; } }