OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [java/] [src/] [edu/] [byu/] [cc/] [plieber/] [fpgaenet/] [modmod/] [ConfigurationChannel.java] - Blame information for rev 10

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
package edu.byu.cc.plieber.fpgaenet.modmod;
2
 
3
import java.nio.channels.Channel;
4
 
5
import com.trolltech.extensions.signalhandler.QSignalHandler1;
6
import com.trolltech.qt.QSignalEmitter.Signal1;
7
import com.trolltech.qt.gui.QDragEnterEvent;
8
import com.trolltech.qt.gui.QDragLeaveEvent;
9
import com.trolltech.qt.gui.QDropEvent;
10
import com.trolltech.qt.gui.QFrame;
11
import com.trolltech.qt.gui.QMouseEvent;
12
import com.trolltech.qt.gui.QWidget;
13
 
14
public class ConfigurationChannel extends QFrame implements ModuleContainer {
15
 
16
        public ConfigurationChannel(int ch) {
17
                setFrameStyle(QFrame.Shape.Panel.value());
18
                setLineWidth(2);
19
                setMinimumSize(80, 80);
20
                setMaximumSize(80, 80);
21
                channel = ch;
22
                ChannelConfiguredSignal = new Signal1<ConfigurationChannel>();
23
                ModuleRemovedSignal = new Signal1<AvailableModule>();
24
                ModuleSelectedSignal = new Signal1<AvailableModule>();
25
                setAcceptDrops(true);
26
        }
27
 
28
        private int channel;
29
 
30
        public void setChannel(int ch) {
31
                channel = ch;
32
        }
33
 
34
        public int getChannel() {
35
                return channel;
36
        }
37
 
38
        AvailableModule resident;
39
 
40
        public boolean isOccupied() {
41
                return (resident != null);
42
        }
43
 
44
        public AvailableModule getResident() {
45
                return resident;
46
        }
47
 
48
        @Override
49
        public void addModule(AvailableModule module) {
50
                if (resident != null) {
51
                        removeModule(resident);
52
                }
53
                resident = module;
54
                resident.setAvailable(false);
55
                resident.move(0, 0);
56
                resident.show();
57
                ChannelConfiguredSignal.emit(this);
58
        }
59
 
60
        @Override
61
        public void removeModule(AvailableModule module) {
62
                ModuleRemovedSignal.emit(resident);
63
                resident.close();
64
                resident = null;
65
        }
66
 
67
        @Override
68
        protected void dragEnterEvent(QDragEnterEvent event) {
69
                if (event.mimeData().hasFormat("application/x-availablemodule")) {
70
                        event.acceptProposedAction();
71
                }
72
                this.setLineWidth(4);
73
        }
74
 
75
        @Override
76
        protected void dropEvent(QDropEvent event) {
77
                if (event.mimeData().hasFormat("application/x-availablemodule")) {
78
                        event.acceptProposedAction();
79
                        AvailableModule module =(AvailableModule) event.source();
80
                        AvailableModule newmodule = new AvailableModule(module, this);
81
                        module.getParentContainer().removeModule(module);
82
                        this.addModule(newmodule);
83
                        this.setLineWidth(4);
84
                        ModuleSelectedSignal.emit(resident);
85
                }
86
        }
87
 
88
        @Override
89
        protected void dragLeaveEvent(QDragLeaveEvent event) {
90
                this.setLineWidth(2);
91
        }
92
 
93
        @Override
94
        protected void mouseReleaseEvent(QMouseEvent arg__1) {
95
                this.setLineWidth(4);
96
                if (resident != null)
97
                        ModuleSelectedSignal.emit(resident);
98
        }
99
 
100
        public Signal1<ConfigurationChannel> ChannelConfiguredSignal;
101
        public Signal1<AvailableModule> ModuleRemovedSignal;
102
        public Signal1<AvailableModule> ModuleSelectedSignal;
103
 
104
        private boolean programmable;
105
 
106
        public boolean isProgrammable() {
107
                return programmable;
108
        }
109
 
110
        public void setProgrammable(boolean programmable) {
111
                this.programmable = programmable;
112
                setAcceptDrops(programmable);
113
        }
114
 
115
        @SuppressWarnings("unused")
116
        private void moduleSelectedHandler(AvailableModule am) {
117
                if (am != null && am == this.getResident())
118
                        this.setLineWidth(4);
119
                else
120
                        this.setLineWidth(2);
121
        }
122
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.