Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Finkbeiner2011-04-18 00:02:39 -0400
committerRyan D. Brooks2011-04-18 00:02:39 -0400
commit029d4a3a90591a90b7c2f75fbf0e6234beaedf20 (patch)
tree092bc6cf37dc0c624c217004c3468e01fb84a25d /plugins/org.eclipse.osee.ote.ui.message
parent4a82f0f0b015c233f328b622a5f1f2f931f42818 (diff)
downloadorg.eclipse.osee-029d4a3a90591a90b7c2f75fbf0e6234beaedf20.tar.gz
org.eclipse.osee-029d4a3a90591a90b7c2f75fbf0e6234beaedf20.tar.xz
org.eclipse.osee-029d4a3a90591a90b7c2f75fbf0e6234beaedf20.zip
feature: Add drag and drop support to add messages from java files to message watch
Diffstat (limited to 'plugins/org.eclipse.osee.ote.ui.message')
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/SignalStripper.java2
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java11
-rw-r--r--plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchViewDropAdapter.java58
3 files changed, 66 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/SignalStripper.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/SignalStripper.java
index 7d0e348280..4b36170d0e 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/SignalStripper.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/SignalStripper.java
@@ -147,7 +147,7 @@ public class SignalStripper {
private List<String> extractMessageImports(String fileAsString) {
List<String> retVal = new ArrayList<String>();
- Pattern pattern = Pattern.compile("import (.*+.(\\w|.)+.[A-Z0-9_]+);");
+ Pattern pattern = Pattern.compile("import ((\\w|\\.)+?\\.[A-Z0-9_]+);");
Matcher matcher = pattern.matcher(fileAsString);
while( matcher.find()){
String fullyQualifiesMessageClass = matcher.group(1);
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java
index 7090812015..32eb02d59a 100644
--- a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchView.java
@@ -96,7 +96,10 @@ import org.eclipse.osee.ote.ui.message.watch.recording.RecordingWizard;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseAdapter;
@@ -244,8 +247,6 @@ public final class WatchView extends ViewPart implements IActionable, IMessageDi
private Composite parentComposite;
private WatchList watchList;
- private MessageFinder messageFinder;
-
public WatchView() {
watchFile = OseeData.getFile("msgWatch.txt");
msgServiceTracker = new ClientMessageServiceTracker(Activator.getDefault().getBundle().getBundleContext(), this);
@@ -433,6 +434,10 @@ public final class WatchView extends ViewPart implements IActionable, IMessageDi
public void keyReleased(KeyEvent e) {
}
});
+
+ int ops = DND.DROP_COPY | DND.DROP_MOVE;
+ Transfer[] transfers = new Transfer[] { FileTransfer.getInstance(), TextTransfer.getInstance()};
+ treeViewer.addDropSupport(ops, transfers, new WatchViewDropAdapter(this));
}
@Override
@@ -1005,8 +1010,6 @@ public final class WatchView extends ViewPart implements IActionable, IMessageDi
@Override
public void onDictionaryLoaded(final IMessageDictionary dictionary) {
- messageFinder = new MessageFinder(dictionary);
-
Displays.ensureInDisplayThread(new Runnable() {
@Override
public void run() {
diff --git a/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchViewDropAdapter.java b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchViewDropAdapter.java
new file mode 100644
index 0000000000..9c3b8bd0f7
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.ui.message/src/org/eclipse/osee/ote/ui/message/watch/WatchViewDropAdapter.java
@@ -0,0 +1,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) {
+ }
+
+}

Back to the top