Subversion Repositories svn.mios

Rev

Rev 628 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
628 adamjking 1
/*
2
 * @(#)HexFileUploadDeviceManager.java  beta8   2006/04/23
3
 *
4
 * Copyright (C) 2008   Adam King (adamjking@optusnet.com.au)
5
 *
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.mios;
22
 
23
import java.util.Observable;
24
import java.util.Observer;
25
import java.util.Vector;
26
 
721 adamjking 27
import org.midibox.midi.MidiFilterDevice;
28
 
628 adamjking 29
public class HexFileUploadDeviceManager extends Observable implements Observer {
30
 
31
    private Vector hexFileUploadDevices;
32
 
721 adamjking 33
    private boolean mios32Mode;
628 adamjking 34
 
35
    public HexFileUploadDeviceManager() {
36
        hexFileUploadDevices = new Vector();
37
 
721 adamjking 38
        mios32Mode = false;
628 adamjking 39
    }
40
 
721 adamjking 41
    public boolean isMIOS32Mode() {
42
        return mios32Mode;
628 adamjking 43
    }
44
 
721 adamjking 45
    public void setMIOS32Mode(boolean mode) {
628 adamjking 46
 
721 adamjking 47
        mios32Mode = mode;
628 adamjking 48
    }
49
 
50
    public HexFileUploadDevice newHexFileUploadDevice() {
51
 
52
        HexFileUploadDevice hexFileUploadDevice = new HexFileUploadDevice(
721 adamjking 53
                "MIOS Hex File Upload " + (hexFileUploadDevices.size() + 1));
628 adamjking 54
 
721 adamjking 55
        hexFileUploadDevice.getHexFileUpload().setMIOS32Mode(mios32Mode);
628 adamjking 56
        hexFileUploadDevice.getHexFileUpload().addObserver(this);
57
 
58
        hexFileUploadDevices.add(hexFileUploadDevice);
59
 
60
        setChanged();
61
        notifyObservers(hexFileUploadDevice);
62
        clearChanged();
63
 
64
        return hexFileUploadDevice;
65
    }
66
 
67
    public void removeHexFileUploadDevice(
68
            HexFileUploadDevice hexFileUploadDevice) {
69
        hexFileUploadDevices.remove(hexFileUploadDevice);
70
        hexFileUploadDevice.getHexFileUpload().deleteObserver(this);
721 adamjking 71
 
72
        hexFileUploadDevices.remove(hexFileUploadDevice);
628 adamjking 73
 
721 adamjking 74
        for (int i = 0; i < hexFileUploadDevices.size(); i++) {
75
 
76
            HexFileUploadDevice currentHexFileUploadDevice = (HexFileUploadDevice) hexFileUploadDevices.elementAt(i);
77
 
78
            currentHexFileUploadDevice.setName("MIOS Hex File Upload " + (i + 1));
79
        }
80
 
628 adamjking 81
        setChanged();
82
        notifyObservers(hexFileUploadDevice);
83
        clearChanged();
84
    }
85
 
86
    public Vector getHexFileUploadDevices() {
87
        return hexFileUploadDevices;
88
    }
89
 
90
    public void update(Observable observable, Object object) {
91
        if (object == HexFileUpload.MIOS32_MODE) {
721 adamjking 92
            mios32Mode = ((HexFileUpload) observable).isMIOS32Mode();
628 adamjking 93
        }
94
    }
95
}