Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.netbeans.modules.db.dataview.util.DBReadWriteHelper;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.windows.WindowManager;
Expand Down Expand Up @@ -539,7 +540,6 @@ private void processKeyEvents(KeyEvent e) {
} else if (KeyStroke.getKeyStrokeForEvent(e).equals(tab)) {
}
}
private Clipboard clipBoard = Toolkit.getDefaultToolkit().getSystemClipboard();

private void copy() {
StringBuilder strBuffer = new StringBuilder();
Expand All @@ -562,15 +562,22 @@ private void copy() {
strBuffer.append("\n");
}
StringSelection stringSelection = new StringSelection(strBuffer.toString());
clipBoard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipBoard.setContents(stringSelection, stringSelection);
Clipboard clipboard = Lookup.getDefault().lookup(Clipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
clipboard.setContents(stringSelection, stringSelection);
}

private void paste() {
int startRow = (insertRecordTableUI.getSelectedRows())[0];
int startCol = (insertRecordTableUI.getSelectedColumns())[0];
try {
String trstring = (String) (clipBoard.getContents(this).getTransferData(DataFlavor.stringFlavor));
Clipboard clipboard = Lookup.getDefault().lookup(Clipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
String trstring = (String) (clipboard.getContents(this).getTransferData(DataFlavor.stringFlavor));
StringTokenizer st1 = new StringTokenizer(trstring, "\n");
for (int i = 0; st1.hasMoreTokens(); i++) {
int rowIdx = startRow + i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.openide.awt.StatusDisplayer;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;

Expand Down Expand Up @@ -461,7 +462,10 @@ private class HyperlinkAction implements HyperlinkListener {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e != null && e.getEventType() == HyperlinkEvent.EventType.ACTIVATED && e.getDescription().startsWith("copy.snippet")) {
Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Clipboard systemClipboard = Lookup.getDefault().lookup(Clipboard.class);
if (systemClipboard == null) {
systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
String snippetCount = e.getDescription().replaceAll("[^0-9]", "");
HTMLDocument HtmlDoc = (HTMLDocument) e.getSourceElement().getDocument();
HTMLDocView source = (HTMLDocView) e.getSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.netbeans.modules.editor;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.util.Exceptions;
Expand Down Expand Up @@ -58,6 +59,7 @@
import org.netbeans.modules.editor.lib2.view.PrintUtils;
import org.openide.awt.Mnemonics;
import org.openide.filesystems.FileChooserBuilder;
import org.openide.util.Lookup;
import org.openide.util.NbPreferences;

public class ExportHtmlAction extends CookieAction {
Expand Down Expand Up @@ -247,7 +249,11 @@ public void run() {
htmlPrintContainer.addLines(lines);
String result = htmlPrintContainer.end();
if (toClipboard) {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(result), null);
Clipboard clipboard = Lookup.getDefault().lookup(Clipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
clipboard.setContents(new StringSelection(result), null);
} else {
PrintWriter out = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import javax.swing.event.ListSelectionListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.JTextComponent;
import org.openide.util.Lookup;
import org.openide.util.Utilities;

/**
Expand Down Expand Up @@ -616,7 +617,10 @@ public void keyTyped(KeyEvent evt) {

private void pasteContent() throws HeadlessException {
Transferable transferable = layout.getSelectedValue().getTransferable();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Clipboard clipboard = Lookup.getDefault().lookup(Clipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
if (transferable != null) {
clipboard.setContents(transferable, layout.getSelectedValue());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@

import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.io.CharConversionException;
import java.lang.ref.WeakReference;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
Expand Down Expand Up @@ -202,11 +201,15 @@ public Action[] getActions(boolean context) {
}
if (callStack.length() > 0) {
final String trace = callStack.toString();
actions.add(new AbstractAction(Bundle.LBL_CopyStackTrace()) {
@Override
public void actionPerformed(ActionEvent e) {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(trace), null);
}
actions.add(new AbstractAction(Bundle.LBL_CopyStackTrace()) {
@Override
public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Lookup.getDefault().lookup(Clipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
clipboard.setContents(new StringSelection(trace), null);
}
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.netbeans.modules.versioning.util.common;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.event.KeyEvent;
import javax.swing.Action;
Expand All @@ -29,6 +30,7 @@
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.JTextComponent;
import org.openide.awt.Mnemonics;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;

/**
Expand Down Expand Up @@ -63,9 +65,13 @@ JPopupMenu getPopup(JTextComponent component) {

cutAction.setEnabled(textSelected);
copyAction.setEnabled(textSelected);

boolean hasClipboardText = Toolkit.getDefaultToolkit().getSystemClipboard()
.isDataFlavorAvailable(DataFlavor.stringFlavor);

Clipboard clipboard = Lookup.getDefault().lookup(Clipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}

boolean hasClipboardText = clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor);

pasteAction.setEnabled(hasClipboardText);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<SubComponents>
<Container class="javax.swing.JToolBar" name="toolBar">
<Properties>
<Property name="floatable" type="boolean" value="false"/>
<Property name="rollover" type="boolean" value="true"/>
</Properties>

Expand Down Expand Up @@ -106,9 +105,6 @@
</Container>
<Container class="javax.swing.JSplitPane" name="splitPane">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="dividerLocation" type="int" value="180"/>
<Property name="dividerSize" type="int" value="7"/>
<Property name="orientation" type="int" value="0"/>
Expand Down Expand Up @@ -164,7 +160,6 @@
<SubComponents>
<Container class="javax.swing.JToolBar" name="toolBar2">
<Properties>
<Property name="floatable" type="boolean" value="false"/>
<Property name="rollover" type="boolean" value="true"/>
</Properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.Mutex;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;
Expand Down Expand Up @@ -176,7 +177,6 @@ private class JPQLEditorPopupMouseAdapter extends PopupMouseAdapter {
private final String COPY_COMMAND = NbBundle.getMessage(JPQLEditorTopComponent.class, "CTL_COPY_COMMAND");
private final String PASTE_COMMAND = NbBundle.getMessage(JPQLEditorTopComponent.class, "CTL_PASTE_COMMAND");
private final String SELECT_ALL_COMMAND = NbBundle.getMessage(JPQLEditorTopComponent.class, "CTL_SELECT_ALL_COMMAND");
private Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();

public JPQLEditorPopupMouseAdapter() {
super();
Expand Down Expand Up @@ -230,7 +230,7 @@ protected void showPopup(MouseEvent evt) {
copyMenuItem.setEnabled(true);
}

Transferable transferable = (Transferable) systemClipboard.getContents(null);
Transferable transferable = getClipboard().getContents(null);
if (transferable.getTransferDataFlavors().length == 0) {
pasteMenuItem.setEnabled(false);
} else {
Expand All @@ -251,17 +251,17 @@ public void actionPerformed(ActionEvent e) {
jpqlEditor.selectAll();
} else if (e.getActionCommand().equals(CUT_COMMAND)) {
StringSelection stringSelection = new StringSelection(jpqlEditor.getSelectedText());
systemClipboard.setContents(stringSelection, stringSelection);
getClipboard().setContents(stringSelection, stringSelection);
jpqlEditor.setText(
jpqlEditor.getText().substring(0, jpqlEditor.getSelectionStart())
+ jpqlEditor.getText().substring(jpqlEditor.getSelectionEnd()));

} else if (e.getActionCommand().equals(COPY_COMMAND)) {
StringSelection stringSelection = new StringSelection(jpqlEditor.getSelectedText());
systemClipboard.setContents(stringSelection, stringSelection);
getClipboard().setContents(stringSelection, stringSelection);

} else if (e.getActionCommand().equals(PASTE_COMMAND)) {
Transferable transferable = (Transferable) systemClipboard.getContents(null);
Transferable transferable = getClipboard().getContents(null);
String clipboardContents = "";
try {
if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
Expand Down Expand Up @@ -953,4 +953,12 @@ private void puComboboxActionPerformed() {
}
}
}

private Clipboard getClipboard() {
Clipboard c = Lookup.getDefault().lookup(Clipboard.class);
if (c == null) {
c = Toolkit.getDefaultToolkit().getSystemClipboard();
}
return c;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.netbeans.modules.java.stackanalyzer.StackLineAnalyser.Link;
import org.openide.util.Exceptions;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
Expand Down Expand Up @@ -227,7 +228,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

private void insertButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_insertButtonActionPerformed
try {
Clipboard clipBoard = Toolkit.getDefaultToolkit ().getSystemClipboard ();
Clipboard clipBoard = Lookup.getDefault().lookup(Clipboard.class);
if (clipBoard == null) {
clipBoard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
Transferable transferable = clipBoard.getContents (this);
if (!transferable.isDataFlavorSupported (DataFlavor.stringFlavor)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataFolder;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.datatransfer.PasteType;

Expand All @@ -74,7 +75,10 @@ public CreateJavaClassFileFromClipboard(DataFolder context, Transferable t) {
@Override
public Transferable paste() throws IOException {
try {
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
Clipboard c = Lookup.getDefault().lookup(Clipboard.class);
if (c == null) {
c = Toolkit.getDefaultToolkit().getSystemClipboard();
}
if (!c.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
return t;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.awt.Component;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
Expand Down Expand Up @@ -98,7 +99,9 @@
import org.netbeans.modules.maven.model.pom.Exclusion;
import org.netbeans.modules.maven.model.pom.POMModel;
import org.netbeans.spi.project.ui.PathFinder;

import static org.netbeans.modules.maven.nodes.Bundle.*;

import org.netbeans.modules.maven.queries.MavenFileOwnerQueryImpl;
import org.netbeans.modules.maven.queries.RepositoryForBinaryQueryImpl;
import org.netbeans.modules.maven.queries.RepositoryForBinaryQueryImpl.Coordinates;
Expand Down Expand Up @@ -1238,8 +1241,13 @@ private class CopyLocationAction extends AbstractAction {
super(CopyLocationAction_name());
}

@Override public void actionPerformed(ActionEvent e) {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(data.art.getFile().getAbsolutePath()), null);
@Override
public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Lookup.getDefault().lookup(Clipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
clipboard.setContents(new StringSelection(data.art.getFile().getAbsolutePath()), null);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
import org.openide.NotifyDescriptor;
import org.openide.awt.HtmlBrowser;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.datatransfer.ExClipboard;

/**
*
Expand Down Expand Up @@ -266,8 +268,11 @@ private void copySettings(String settings) {
}

private void copyToClipboard(String contents) {
Clipboard clipboard = Lookup.getDefault().lookup(Clipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
StringSelection selection = new StringSelection(contents);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, selection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
import org.openide.awt.Mnemonics;
import org.openide.util.HelpCtx;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.Mutex;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;
Expand Down Expand Up @@ -527,8 +528,11 @@ private void showCopyToClipboardPopupMenu(MouseEvent e) {
pm.add(new AbstractAction(NbBundle.getMessage(NbPresenter.class, "Lbl_CopyToClipboard")) { //NOI18N
@Override
public void actionPerformed(ActionEvent e) {
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
c.setContents(new StringSelection(clipboardText), null);
Clipboard clipboard = Lookup.getDefault().lookup(Clipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
clipboard.setContents(new StringSelection(clipboardText), null);
}
});
pm.show(e.getComponent(), e.getX(), e.getY());
Expand Down
Loading
Loading