blob: 9c3b8bd0f76690b3c6b5e688a2d1325bd635ca85 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package org.eclipse.osee.ote.ui.message.watch;
import java.io.IOException;
import java.util.logging.Level;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.DropTargetListener;
public class WatchViewDropAdapter implements DropTargetListener {
private WatchView watchViewer;
public WatchViewDropAdapter(WatchView watchViewer) {
this.watchViewer = watchViewer;
}
@Override
public void dragEnter(DropTargetEvent event) {
}
@Override
public void dragLeave(DropTargetEvent event) {
}
@Override
public void dragOperationChanged(DropTargetEvent event) {
}
@Override
public void dragOver(DropTargetEvent event) {
}
@Override
public void drop(DropTargetEvent event) {
if(event.data instanceof String[]){
for(String file: (String[])event.data){
java.io.File realFile = new java.io.File(file);
if(realFile.exists() && !realFile.isDirectory()){
try {
String fileAsString = Lib.fileToString(realFile);
SignalStripper signalStripper = new SignalStripper();
String mwi = signalStripper.generateStringToWrite(fileAsString);
watchViewer.loadWatchFile(mwi);
} catch (IOException e) {
OseeLog.log(WatchViewDropAdapter.class, Level.SEVERE, "Failed to read file from drag and drop into message watch.", e);
}
}
}
}
}
@Override
public void dropAccept(DropTargetEvent event) {
}
}
|