use of java.awt.datatransfer.UnsupportedFlavorException in project blue by kunstmusik.
the class UDOTreeDropTarget method drop.
@Override
public void drop(DropTargetDropEvent dtde) {
Point pt = dtde.getLocation();
DropTargetContext dtc = dtde.getDropTargetContext();
JTree tree = (JTree) dtc.getComponent();
TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
Object node = parentpath.getLastPathComponent();
if (dtde.isDataFlavorSupported(TransferableUDO.UDO_CAT_FLAVOR)) {
if (!(node instanceof UDOCategory)) {
dtde.rejectDrop();
return;
}
if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) {
dtde.acceptDrop(dtde.getDropAction());
Transferable tr = dtde.getTransferable();
try {
Object transferNode = tr.getTransferData(TransferableUDO.UDO_CAT_FLAVOR);
UDOCategory udoCategory = (UDOCategory) transferNode;
UDOCategory parentNode = (UDOCategory) node;
UDOLibrary udoLibrary = (UDOLibrary) tree.getModel();
udoLibrary.addCategory(parentNode, udoCategory);
dtde.dropComplete(true);
} catch (UnsupportedFlavorException | IOException e) {
dtde.dropComplete(false);
}
} else {
dtde.rejectDrop();
}
} else if (dtde.isDataFlavorSupported(TransferableUDO.UDO_FLAVOR)) {
dtde.acceptDrop(dtde.getDropAction());
try {
Transferable tr = dtde.getTransferable();
Object transferNode = tr.getTransferData(TransferableUDO.UDO_FLAVOR);
UserDefinedOpcode udo = (UserDefinedOpcode) transferNode;
UDOLibrary udoLibrary = (UDOLibrary) tree.getModel();
// iLibrary.removeInstrument(instrument);
if (node instanceof UDOCategory) {
UDOCategory parentNode = (UDOCategory) node;
udoLibrary.addUDO(parentNode, udo);
} else if (node instanceof UserDefinedOpcode) {
UDOCategory parentNode = (UDOCategory) parentpath.getPathComponent(parentpath.getPathCount() - 2);
int index = ListUtil.indexOfByRef(parentNode.getUserDefinedOpcodes(), node);
int closestRow = tree.getClosestRowForLocation(pt.x, pt.y);
Rectangle bounds = tree.getRowBounds(closestRow);
if (pt.y > bounds.y + bounds.height) {
udoLibrary.addUDO(parentNode, udo);
} else {
udoLibrary.addUDO(parentNode, index, udo);
}
}
dtde.dropComplete(true);
} catch (UnsupportedFlavorException | IOException e) {
dtde.dropComplete(false);
}
} else {
dtde.rejectDrop();
}
}
use of java.awt.datatransfer.UnsupportedFlavorException in project com.revolsys.open by revolsys.
the class RecordTransferable method getTransferData.
@Override
public Object getTransferData(final DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (this.object == null) {
return null;
} else if (DATA_OBJECT_FLAVOR.equals(flavor) || MapTransferable.MAP_FLAVOR.equals(flavor)) {
return this.object;
} else if (DataFlavor.stringFlavor.equals(flavor)) {
final StringWriter out = new StringWriter();
final Collection<String> fieldNames = this.object.getRecordDefinition().getFieldNames();
Csv.writeColumns(out, fieldNames, '\t', '\n');
final Collection<Object> values = this.object.values();
Csv.writeColumns(out, values, '\t', '\n');
final String text = out.toString();
return text;
} else {
throw new UnsupportedFlavorException(flavor);
}
}
use of java.awt.datatransfer.UnsupportedFlavorException in project gate-core by GateNLP.
the class CorpusEditor method initGuiComponents.
protected void initGuiComponents() {
setLayout(new BorderLayout());
renderer = new DocumentNameRenderer();
docTable = new XJTable(docTableModel);
docTable.setSortable(true);
docTable.setSortedColumn(DocumentTableModel.COL_INDEX);
docTable.setAutoResizeMode(XJTable.AUTO_RESIZE_LAST_COLUMN);
docTable.getColumnModel().getColumn(DocumentTableModel.COL_NAME).setCellRenderer(renderer);
docTable.setDragEnabled(true);
docTable.setTransferHandler(new TransferHandler() {
// drag and drop to move up and down the table rows
// import selected documents from the resources tree
String source = "";
@Override
public int getSourceActions(JComponent c) {
return MOVE;
}
@Override
protected Transferable createTransferable(JComponent c) {
int[] selectedRows = docTable.getSelectedRows();
Arrays.sort(selectedRows);
return new StringSelection("CorpusEditor" + Arrays.toString(selectedRows));
}
@Override
protected void exportDone(JComponent c, Transferable data, int action) {
}
@Override
public boolean canImport(JComponent c, DataFlavor[] flavors) {
for (DataFlavor flavor : flavors) {
if (DataFlavor.stringFlavor.equals(flavor)) {
return true;
}
}
return false;
}
@Override
public boolean importData(JComponent c, Transferable t) {
if (!canImport(c, t.getTransferDataFlavors())) {
return false;
}
try {
source = (String) t.getTransferData(DataFlavor.stringFlavor);
if (source.startsWith("ResourcesTree")) {
int insertion = docTable.getSelectedRow();
List<Document> documents = new ArrayList<Document>();
source = source.replaceFirst("^ResourcesTree\\[", "");
source = source.replaceFirst("\\]$", "");
final String[] documentsNames = source.split(", ");
List<Resource> loadedDocuments;
try {
loadedDocuments = Gate.getCreoleRegister().getAllInstances("gate.Document");
} catch (GateException e) {
e.printStackTrace();
return false;
}
// get the list of documents selected when dragging started
for (String documentName : documentsNames) {
for (Resource loadedDocument : loadedDocuments) {
if (loadedDocument.getName().equals(documentName) && !corpus.contains(loadedDocument)) {
documents.add((Document) loadedDocument);
}
}
}
// add the documents at the insertion point
for (Document document : documents) {
if (insertion != -1) {
corpus.add(docTable.rowViewToModel(insertion), document);
if (insertion == docTable.getRowCount()) {
insertion++;
}
} else {
corpus.add(document);
}
}
// select the moved/already existing documents
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
docTable.clearSelection();
for (String documentName : documentsNames) {
for (int row = 0; row < docTable.getRowCount(); row++) {
if (docTable.getValueAt(row, docTable.convertColumnIndexToView(1)).equals(documentName)) {
docTable.addRowSelectionInterval(row, row);
}
}
}
}
});
changeMessage();
return true;
} else if (source.startsWith("CorpusEditor")) {
int insertion = docTable.getSelectedRow();
int initialInsertion = insertion;
List<Document> documents = new ArrayList<Document>();
source = source.replaceFirst("^CorpusEditor\\[", "");
source = source.replaceFirst("\\]$", "");
String[] selectedRows = source.split(", ");
if (Integer.parseInt(selectedRows[0]) < insertion) {
insertion++;
}
// get the list of documents selected when dragging started
for (String row : selectedRows) {
if (Integer.parseInt(row) == initialInsertion) {
// the user dragged the selected rows on themselves, do nothing
return false;
}
documents.add(corpus.get(docTable.rowViewToModel(Integer.parseInt(row))));
if (Integer.parseInt(row) < initialInsertion) {
insertion--;
}
}
// remove the documents selected when dragging started
for (Document document : documents) {
corpus.remove(document);
}
// add the documents at the insertion point
for (Document document : documents) {
corpus.add(docTable.rowViewToModel(insertion), document);
insertion++;
}
// select the moved documents
docTable.addRowSelectionInterval(insertion - selectedRows.length, insertion - 1);
return true;
} else {
return false;
}
} catch (UnsupportedFlavorException ufe) {
return false;
} catch (IOException ioe) {
return false;
}
}
});
JScrollPane scroller = new JScrollPane(docTable);
scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroller.getViewport().setBackground(docTable.getBackground());
add(scroller, BorderLayout.CENTER);
toolbar = new JToolBar();
toolbar.setFloatable(false);
toolbar.add(newDocumentAction = new NewDocumentAction());
toolbar.add(removeDocumentsAction = new RemoveDocumentsAction());
toolbar.addSeparator();
toolbar.add(moveUpAction = new MoveUpAction());
toolbar.add(moveDownAction = new MoveDownAction());
toolbar.addSeparator();
toolbar.add(openDocumentsAction = new OpenDocumentsAction());
removeDocumentsAction.setEnabled(false);
moveUpAction.setEnabled(false);
moveDownAction.setEnabled(false);
openDocumentsAction.setEnabled(false);
JPanel topPanel = new JPanel(new BorderLayout());
topPanel.add(toolbar, BorderLayout.NORTH);
messageLabel = new JLabel();
changeMessage();
topPanel.add(messageLabel, BorderLayout.SOUTH);
add(topPanel, BorderLayout.NORTH);
}
use of java.awt.datatransfer.UnsupportedFlavorException in project gate-core by GateNLP.
the class SerialControllerEditor method initListeners.
// initGuiComponents()
protected void initListeners() {
Gate.getCreoleRegister().addCreoleListener(this);
this.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
processMouseEvent(e);
}
@Override
public void mouseReleased(MouseEvent e) {
processMouseEvent(e);
}
protected void processMouseEvent(MouseEvent e) {
if (e.isPopupTrigger()) {
// context menu
if (handle != null && handle.getPopup() != null) {
handle.getPopup().show(SerialControllerEditor.this, e.getX(), e.getY());
}
}
}
});
moveUpButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int[] rows = memberPRsTable.getSelectedRows();
if (rows == null || rows.length == 0) {
JOptionPane.showMessageDialog(SerialControllerEditor.this, "Please select some components to be moved " + "from the list of used components!\n", "GATE", JOptionPane.ERROR_MESSAGE);
} else {
// we need to make sure the rows are sorted
Arrays.sort(rows);
// get the list of PRs
for (int row : rows) {
if (row > 0) {
// move it up
List<RunningStrategy> strategies = null;
if (conditionalMode) {
strategies = new ArrayList<RunningStrategy>(((ConditionalController) controller).getRunningStrategies());
RunningStrategy straegy = strategies.remove(row);
strategies.add(row - 1, straegy);
}
ProcessingResource value = controller.remove(row);
controller.add(row - 1, value);
if (conditionalMode) {
((ConditionalController) controller).setRunningStrategies(strategies);
;
}
}
}
// restore selection
for (int row : rows) {
int newRow;
if (row > 0)
newRow = row - 1;
else
newRow = row;
memberPRsTable.addRowSelectionInterval(newRow, newRow);
}
memberPRsTable.requestFocusInWindow();
}
}
});
moveDownButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int[] rows = memberPRsTable.getSelectedRows();
if (rows == null || rows.length == 0) {
JOptionPane.showMessageDialog(SerialControllerEditor.this, "Please select some components to be moved " + "from the list of used components!\n", "GATE", JOptionPane.ERROR_MESSAGE);
} else {
// we need to make sure the rows are sorted
Arrays.sort(rows);
// get the list of PRs
for (int i = rows.length - 1; i >= 0; i--) {
int row = rows[i];
if (row < controller.getPRs().size() - 1) {
List<RunningStrategy> strategies = null;
if (conditionalMode) {
strategies = new ArrayList<RunningStrategy>(((ConditionalController) controller).getRunningStrategies());
RunningStrategy straegy = strategies.remove(row);
strategies.add(row + 1, straegy);
}
// move it down
ProcessingResource value = controller.remove(row);
controller.add(row + 1, value);
if (conditionalMode) {
((ConditionalController) controller).setRunningStrategies(strategies);
;
}
}
}
// restore selection
for (int row : rows) {
int newRow;
if (row < controller.getPRs().size() - 1)
newRow = row + 1;
else
newRow = row;
memberPRsTable.addRowSelectionInterval(newRow, newRow);
}
memberPRsTable.requestFocusInWindow();
}
}
});
// mouse click edit the resource
// mouse double click or context menu add the resource to the application
loadedPRsTable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
processMouseEvent(e);
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
processMouseEvent(e);
}
}
@Override
public void mouseClicked(MouseEvent e) {
processMouseEvent(e);
}
protected void processMouseEvent(MouseEvent e) {
int row = loadedPRsTable.rowAtPoint(e.getPoint());
if (row == -1) {
return;
}
if (e.isPopupTrigger()) {
// context menu
if (!loadedPRsTable.isRowSelected(row)) {
// if right click outside the selection then reset selection
loadedPRsTable.getSelectionModel().setSelectionInterval(row, row);
}
JPopupMenu popup = new XJPopupMenu();
popup.add(addPRAction);
popup.show(loadedPRsTable, e.getPoint().x, e.getPoint().y);
} else if (e.getID() == MouseEvent.MOUSE_CLICKED) {
if (e.getClickCount() == 2) {
// add selected modules on double click
addPRAction.actionPerformed(null);
}
}
}
});
// drag and drop support
loadedPRsTable.setTransferHandler(new TransferHandler() {
// minimal drag and drop that only call the removePRAction when importing
String source = "";
@Override
public int getSourceActions(JComponent c) {
return MOVE;
}
@Override
protected Transferable createTransferable(JComponent c) {
return new StringSelection("loadedPRsTable");
}
@Override
protected void exportDone(JComponent c, Transferable data, int action) {
}
@Override
public boolean canImport(JComponent c, DataFlavor[] flavors) {
for (DataFlavor flavor : flavors) {
if (DataFlavor.stringFlavor.equals(flavor)) {
return true;
}
}
return false;
}
@Override
public boolean importData(JComponent c, Transferable t) {
if (canImport(c, t.getTransferDataFlavors())) {
try {
source = (String) t.getTransferData(DataFlavor.stringFlavor);
if (source.startsWith("memberPRsTable")) {
removePRAction.actionPerformed(null);
return true;
} else {
return false;
}
} catch (UnsupportedFlavorException ufe) {
// just return false later
} catch (IOException ioe) {
// just return false later
}
}
return false;
}
});
// mouse click edit the resource
// mouse double click or context menu remove the resource from the
// application
memberPRsTable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger()) {
processMouseEvent(e);
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
processMouseEvent(e);
}
}
@Override
public void mouseClicked(MouseEvent e) {
processMouseEvent(e);
}
protected void processMouseEvent(MouseEvent e) {
int row = memberPRsTable.rowAtPoint(e.getPoint());
if (row == -1) {
return;
}
if (e.isPopupTrigger()) {
// context menu
if (!memberPRsTable.isRowSelected(row)) {
// if right click outside the selection then reset selection
memberPRsTable.getSelectionModel().setSelectionInterval(row, row);
}
JPopupMenu popup = new XJPopupMenu();
popup.add(removePRAction);
popup.show(memberPRsTable, e.getPoint().x, e.getPoint().y);
} else if (e.getID() == MouseEvent.MOUSE_CLICKED) {
if (e.getClickCount() == 2) {
// open the double-clicked PR in the main view.
Component root = SwingUtilities.getRoot(SerialControllerEditor.this);
if (!(root instanceof MainFrame)) {
return;
}
final MainFrame mainFrame = (MainFrame) root;
if (controller != null) {
ProcessingResource res = controller.getPRs().get(row);
if (res != null)
mainFrame.select(res);
}
}
}
}
});
// Drag and drop support
memberPRsTable.setTransferHandler(new TransferHandler() {
// minimal drag and drop that only call the addPRAction when importing
String source = "";
@Override
public int getSourceActions(JComponent c) {
return MOVE;
}
@Override
protected Transferable createTransferable(JComponent c) {
int[] selectedRows = memberPRsTable.getSelectedRows();
Arrays.sort(selectedRows);
return new StringSelection("memberPRsTable" + Arrays.toString(selectedRows));
}
@Override
protected void exportDone(JComponent c, Transferable data, int action) {
}
@Override
public boolean canImport(JComponent c, DataFlavor[] flavors) {
for (DataFlavor flavor : flavors) {
if (DataFlavor.stringFlavor.equals(flavor)) {
return true;
}
}
return false;
}
@Override
public boolean importData(JComponent c, Transferable t) {
if (!canImport(c, t.getTransferDataFlavors())) {
return false;
}
try {
source = (String) t.getTransferData(DataFlavor.stringFlavor);
if (source.startsWith("memberPRsTable")) {
int insertion = memberPRsTable.getSelectedRow();
int initialInsertion = insertion;
List<ProcessingResource> prs = new ArrayList<ProcessingResource>();
source = source.replaceFirst("^memberPRsTable\\[", "");
source = source.replaceFirst("\\]$", "");
String[] selectedRows = source.split(", ");
if (Integer.parseInt(selectedRows[0]) < insertion) {
insertion++;
}
// get the list of PRs selected when dragging started
for (String row : selectedRows) {
if (Integer.parseInt(row) == initialInsertion) {
// the user draged the selected rows on themselves, do nothing
return false;
}
prs.add((ProcessingResource) memberPRsTable.getValueAt(Integer.parseInt(row), memberPRsTable.convertColumnIndexToView(1)));
if (Integer.parseInt(row) < initialInsertion) {
insertion--;
}
}
// remove the PRs selected when dragging started
for (ProcessingResource pr : prs) {
controller.remove(pr);
}
// add the PRs at the insertion point
for (ProcessingResource pr : prs) {
controller.add(insertion, pr);
insertion++;
}
// select the moved PRs
memberPRsTable.addRowSelectionInterval(insertion - selectedRows.length, insertion - 1);
return true;
} else if (source.equals("loadedPRsTable")) {
addPRAction.actionPerformed(null);
return true;
} else {
return false;
}
} catch (UnsupportedFlavorException ufe) {
return false;
} catch (IOException ioe) {
return false;
}
}
});
loadedPRsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
// disable Add button if no selection
addButton.setEnabled(loadedPRsTable.getSelectedRowCount() > 0);
}
});
memberPRsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
// disable Remove and Move buttons if no selection
removeButton.setEnabled(memberPRsTable.getSelectedRowCount() > 0);
moveUpButton.setEnabled(memberPRsTable.getSelectedRowCount() > 0 && !memberPRsTable.isRowSelected(0));
moveDownButton.setEnabled(memberPRsTable.getSelectedRowCount() > 0 && !memberPRsTable.isRowSelected(memberPRsTable.getRowCount() - 1));
// update the parameters & strategy editors
if (memberPRsTable.getSelectedRowCount() == 1) {
// only one selection
selectPR(memberPRsTable.getSelectedRow());
} else {
// clean up UI
selectPR(-1);
}
}
});
if (conditionalMode) {
/**
* A listener called when the selection state changes for any of the
* execution mode radio buttons. We use selection changes rather than
* action listeners, as the change of state may not be as results of an
* action (e.g. editing one of the text fields, changes the selection).
*/
ItemListener strategyModeListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (selectedPRRunStrategy != null) {
if (selectedPRRunStrategy instanceof AnalyserRunningStrategy) {
AnalyserRunningStrategy strategy = (AnalyserRunningStrategy) selectedPRRunStrategy;
if (yes_RunRBtn.isSelected()) {
strategy.setRunMode(RunningStrategy.RUN_ALWAYS);
} else if (no_RunRBtn.isSelected()) {
strategy.setRunMode(RunningStrategy.RUN_NEVER);
} else if (conditional_RunRBtn.isSelected()) {
strategy.setRunMode(RunningStrategy.RUN_CONDITIONAL);
}
} else if (selectedPRRunStrategy instanceof UnconditionalRunningStrategy) {
UnconditionalRunningStrategy strategy = (UnconditionalRunningStrategy) selectedPRRunStrategy;
if (yes_RunRBtn.isSelected()) {
strategy.shouldRun(true);
} else if (no_RunRBtn.isSelected()) {
strategy.shouldRun(false);
}
}
}
// some icons may have changed!
memberPRsTable.repaint();
}
};
yes_RunRBtn.addItemListener(strategyModeListener);
no_RunRBtn.addItemListener(strategyModeListener);
conditional_RunRBtn.addItemListener(strategyModeListener);
featureNameTextField.getDocument().addDocumentListener(new javax.swing.event.DocumentListener() {
@Override
public void insertUpdate(javax.swing.event.DocumentEvent e) {
changeOccured(e);
}
@Override
public void removeUpdate(javax.swing.event.DocumentEvent e) {
changeOccured(e);
}
@Override
public void changedUpdate(javax.swing.event.DocumentEvent e) {
changeOccured(e);
}
protected void changeOccured(javax.swing.event.DocumentEvent e) {
if (selectedPRRunStrategy != null && selectedPRRunStrategy instanceof AnalyserRunningStrategy) {
AnalyserRunningStrategy strategy = (AnalyserRunningStrategy) selectedPRRunStrategy;
strategy.setFeatureName(featureNameTextField.getText());
}
// editing the textfield changes the running strategy to conditional
conditional_RunRBtn.setSelected(true);
}
});
featureValueTextField.getDocument().addDocumentListener(new javax.swing.event.DocumentListener() {
@Override
public void insertUpdate(javax.swing.event.DocumentEvent e) {
changeOccured(e);
}
@Override
public void removeUpdate(javax.swing.event.DocumentEvent e) {
changeOccured(e);
}
@Override
public void changedUpdate(javax.swing.event.DocumentEvent e) {
changeOccured(e);
}
protected void changeOccured(javax.swing.event.DocumentEvent e) {
if (selectedPRRunStrategy != null && selectedPRRunStrategy instanceof AnalyserRunningStrategy) {
AnalyserRunningStrategy strategy = (AnalyserRunningStrategy) selectedPRRunStrategy;
strategy.setFeatureValue(featureValueTextField.getText());
}
// editing the textfield changes the running strategy to conditional
conditional_RunRBtn.setSelected(true);
}
});
}
if (corpusControllerMode) {
corpusCombo.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
corpusComboModel.fireDataChanged();
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
}
});
}
addAncestorListener(new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
// every time the user switches back to this view, we check
// whether another controller has just included this one
loadedPRsTableModel.fireTableDataChanged();
memberPRsTableModel.fireTableDataChanged();
}
@Override
public void ancestorRemoved(AncestorEvent event) {
/* do nothing */
}
@Override
public void ancestorMoved(AncestorEvent event) {
/* do nothing */
}
});
// binds F3 key to the run action
getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke("F3"), "Run");
getActionMap().put("Run", runAction);
}
use of java.awt.datatransfer.UnsupportedFlavorException in project CCEmuX by CCEmuX.
the class AWTRenderer method keyPressed.
@Override
public void keyPressed(KeyEvent e) {
// Pasting should be handled first as it blocks all events
boolean hasModifier = (e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0;
if (rendererConfig.nativePaste.get() ? DefaultEditorKit.pasteAction.equals(((InputMap) UIManager.getLookAndFeelDefaults().get("TextField.focusInputMap")).get(KeyStroke.getKeyStrokeForEvent(e))) : hasModifier && e.getKeyCode() == KeyEvent.VK_V) {
try {
computer.paste((String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor));
} catch (HeadlessException | UnsupportedFlavorException | IOException er) {
log.error("Could not read clipboard", er);
}
return;
}
if (allowKeyEvents()) {
computer.pressKey(translateToCC(e.getKeyCode()), keysDown.get(e.getKeyCode()));
keysDown.set(e.getKeyCode());
}
// Start action timers
if (hasModifier) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_S && shutdownTimer < 0)
shutdownTimer = 0;
if (key == KeyEvent.VK_R && rebootTimer < 0)
rebootTimer = 0;
if (key == KeyEvent.VK_T && terminateTimer < 0)
terminateTimer = 0;
}
}
Aggregations