Skip to content

Commit

Permalink
Fixed issue #3 copy and paste now working on the send-message view
Browse files Browse the repository at this point in the history
  • Loading branch information
cemartins committed Oct 9, 2014
1 parent 38a7580 commit 3abb350
Show file tree
Hide file tree
Showing 289 changed files with 18,603 additions and 275 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/.classpath
/.project
/.DS_Store
/pom.xml.versionsBackup
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.jms.TextMessage;

import net.sf.juffrou.mq.activemq.task.ActiveMqMessageReceivingTask;
import net.sf.juffrou.mq.activemq.util.ActiveMqDestinationResolver;
import net.sf.juffrou.mq.activemq.util.ActiveMqMessageDescriptorHelper;
import net.sf.juffrou.mq.dom.HeaderDescriptor;
import net.sf.juffrou.mq.dom.MessageDescriptor;
Expand Down Expand Up @@ -66,8 +67,7 @@ public void sendMessage(MessageSendPresenter presenter, MessageDescriptor messag
connection.start();

session = (ActiveMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

Destination sendDestination = jmsTemplate.getDestinationResolver().resolveDestinationName(session, queueNameSend.getId(), false);
Destination sendDestination = ActiveMqDestinationResolver.resolveDestination(jmsTemplate, session, queueNameSend);

TextMessage message = session.createTextMessage(messageDescriptor.getText());
ActiveMqMessageDescriptorHelper.setMessageHeaders(message, messageDescriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public List<QueueDescriptor> getQueues(QueuesListPresenter presenter) {
MapMessage statistics = getStatistics("Destination." + mqQueue.getQueueName());

QueueDescriptor queue = new QueueDescriptor();
queue.setId(mqQueue.getQualifiedName());
queue.setId(mqQueue.getQueueName());
queue.setName(mqQueue.getQueueName());
queue.setDescription(mqQueue.getQualifiedName());
queue.setDept(statistics.getLong("size"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package net.sf.juffrou.mq.activemq.util;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Session;

import net.sf.juffrou.mq.dom.QueueDescriptor;
import net.sf.juffrou.mq.error.CannotFindDestinationException;

import org.springframework.jms.core.JmsTemplate;

public class ActiveMqDestinationResolver {


public static Destination resolveDestination(JmsTemplate template, Session session, QueueDescriptor destination) {
return resolveDestination(template, session, destination.getName());
}

public static Destination resolveDestination(JmsTemplate template, Session session, String destinationName) {

Destination destination = null;
try {
destination = template.getDestinationResolver().resolveDestinationName(session, destinationName, false);
} catch (JMSException e) {
try {
destination = template.getDestinationResolver().resolveDestinationName(session, destinationName, true);
} catch (JMSException e1) {
e1.printStackTrace();
throw new CannotFindDestinationException("Cannot find " + destinationName, e);
}
}
return destination;
}

}
10 changes: 5 additions & 5 deletions mqc-assembler/src/main/deploy/package/broker.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# WebsphereMQ
#broker_hostname=localhost
broker_hostname=127.0.0.1
broker_hostname=localhost
#broker_hostname=192.168.0.28
#broker_port=1414
#broker_port=61616
broker_port=5445
broker_port=61616
#broker_port=5445
broker_channel=giros.clients
broker_queue_manager=ADX.QUEUE.MANAGER
broker_username=Guest
broker_userpwd=Guest
broker_userpwd=guest
broker_timeout=60000
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
import javafx.scene.control.TablePosition;
import javafx.scene.control.TableView;
import javafx.scene.control.TitledPane;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import javafx.util.Callback;
Expand All @@ -51,6 +57,7 @@ public class MessageSendPresenter {
protected static final Logger LOG = LoggerFactory.getLogger(MessageSendPresenter.class);

private static final String SCRIPT_SET_TEXT_PREFIX = "editor.setValue(\"";
private static final String SCRIPT_PASTE_TEXT_PREFIX = "editor.onPaste(\"";
private static final String SCRIPT_SET_TEXT_SUFFIX = "\");";
private static final String SCRIPT_GET_TEXT = "editor.getValue();";

Expand Down Expand Up @@ -243,6 +250,13 @@ public void changed(ObservableValue ov, State oldState, State newState) {
// Load the javascript editor into the receving payload pane
WebEngine receveEngine = receivePayload.getEngine();
receveEngine.load(resource.toString());

// set the copy and paste handlers
engine.setOnAlert(new ClipboardCopyHandler());
sendPayload.addEventFilter(KeyEvent.KEY_PRESSED, new ClipboardPasteHandler(engine));

receveEngine.setOnAlert(new ClipboardCopyHandler());
receivePayload.addEventFilter(KeyEvent.KEY_PRESSED, new ClipboardPasteHandler(receveEngine));

}

Expand Down Expand Up @@ -320,4 +334,41 @@ public void displayMessageReceived(MessageDescriptor messageDescriptor) {
public Stage getStage() {
return (Stage) messageAccordionSend.getScene().getWindow();
}

private class ClipboardPasteHandler implements EventHandler<KeyEvent> {

private final WebEngine webEngine;

public ClipboardPasteHandler(WebEngine webEngine) {
this.webEngine = webEngine;
}

@Override
public void handle(KeyEvent keyEvent) {
if ((keyEvent.isControlDown() || keyEvent.isMetaDown()) && keyEvent.getCode() == KeyCode.V){
// PASTE
final Clipboard clipboard = Clipboard.getSystemClipboard();
String content = (String) clipboard.getContent(DataFormat.PLAIN_TEXT);
content = content.replaceAll("\\\n", "\\\\n");
content = content.replaceAll("\"", "\\\\\"");
String script = SCRIPT_PASTE_TEXT_PREFIX + content + SCRIPT_SET_TEXT_SUFFIX;
webEngine.executeScript(script);
}
}
}

private class ClipboardCopyHandler implements EventHandler<WebEvent<String>> {

@Override
public void handle(WebEvent<String> we) {
if(we.getData()!=null && we.getData().startsWith("copy: ")){
// COPY
final Clipboard clipboard = Clipboard.getSystemClipboard();
final ClipboardContent content = new ClipboardContent();
content.putString(we.getData().substring(6));
clipboard.setContent(content);
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</Accordion>
<ToolBar nodeOrientation="LEFT_TO_RIGHT" prefHeight="40.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0">
<items>
<CheckBox fx:id="hasReply" mnemonicParsing="false" onAction="#hasReplyChanged" selected="true" text="Has Reply" />
<CheckBox fx:id="hasReply" mnemonicParsing="false" onAction="#hasReplyChanged" selected="true" text="Has Response" />
<ComboBox fx:id="replyQueueCB" minWidth="-Infinity" prefHeight="26.0" prefWidth="290.0" promptText="Reply queue">
<items>
<FXCollections fx:factory="observableArrayList">
Expand Down
18,160 changes: 18,156 additions & 4 deletions mqc-core/src/main/resources/net/sf/juffrou/mq/messages/presenter/src-min/ace.js

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3abb350

Please sign in to comment.