Search in sources :

Example 61 with Transfer

use of org.eclipse.swt.dnd.Transfer in project gemoc-studio by eclipse.

the class FsmEditor method createContextMenuFor.

/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu = contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
Also used : UnwrappingSelectionProvider(org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider) ViewerDragAdapter(org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) LocalTransfer(org.eclipse.emf.edit.ui.dnd.LocalTransfer) Transfer(org.eclipse.swt.dnd.Transfer) FileTransfer(org.eclipse.swt.dnd.FileTransfer) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator) Point(org.eclipse.swt.graphics.Point) EditingDomainViewerDropAdapter(org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)

Example 62 with Transfer

use of org.eclipse.swt.dnd.Transfer in project gemoc-studio by eclipse.

the class GexpressionsEditor method createContextMenuFor.

/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu = contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
Also used : UnwrappingSelectionProvider(org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider) ViewerDragAdapter(org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) LocalTransfer(org.eclipse.emf.edit.ui.dnd.LocalTransfer) Transfer(org.eclipse.swt.dnd.Transfer) FileTransfer(org.eclipse.swt.dnd.FileTransfer) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator) Point(org.eclipse.swt.graphics.Point) EditingDomainViewerDropAdapter(org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)

Example 63 with Transfer

use of org.eclipse.swt.dnd.Transfer in project BiglyBT by BiglySoftware.

the class ConfigSectionSecurity method configSectionCreate.

@Override
public Composite configSectionCreate(final Composite parent) {
    int userMode = COConfigurationManager.getIntParameter("User Mode");
    java.util.List<Button> buttons = new ArrayList<>();
    GridData gridData;
    Composite gSecurity = new Composite(parent, SWT.NULL);
    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    gSecurity.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    gSecurity.setLayout(layout);
    // row
    Label cert_label = new Label(gSecurity, SWT.NULL);
    Messages.setLanguageText(cert_label, "ConfigView.section.tracker.createcert");
    Button cert_button = new Button(gSecurity, SWT.PUSH);
    buttons.add(cert_button);
    Messages.setLanguageText(cert_button, "ConfigView.section.tracker.createbutton");
    cert_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            new CertificateCreatorWindow();
        }
    });
    new Label(gSecurity, SWT.NULL);
    // row
    Label reset_certs_label = new Label(gSecurity, SWT.NULL);
    Messages.setLanguageText(reset_certs_label, "ConfigView.section.security.resetcerts");
    Button reset_certs_button = new Button(gSecurity, SWT.PUSH);
    buttons.add(reset_certs_button);
    Messages.setLanguageText(reset_certs_button, "Button.reset");
    reset_certs_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            MessageBoxShell mb = new MessageBoxShell(SWT.ICON_WARNING | SWT.OK | SWT.CANCEL, MessageText.getString("ConfigView.section.security.resetcerts.warning.title"), MessageText.getString("ConfigView.section.security.resetcerts.warning.msg"));
            mb.setDefaultButtonUsingStyle(SWT.CANCEL);
            mb.setParent(parent.getShell());
            mb.open(new UserPrompterResultListener() {

                @Override
                public void prompterClosed(int returnVal) {
                    if (returnVal != SWT.OK) {
                        return;
                    }
                    if (SESecurityManager.resetTrustStore(false)) {
                        MessageBoxShell mb = new MessageBoxShell(SWT.ICON_INFORMATION | SWT.OK, MessageText.getString("ConfigView.section.security.restart.title"), MessageText.getString("ConfigView.section.security.restart.msg"));
                        mb.setParent(parent.getShell());
                        mb.open(null);
                        UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
                        if (uiFunctions != null) {
                            uiFunctions.dispose(true, false);
                        }
                    } else {
                        MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.resetcerts.error.title"), MessageText.getString("ConfigView.section.security.resetcerts.error.msg"));
                        mb.setParent(parent.getShell());
                        mb.open(null);
                    }
                }
            });
        }
    });
    reset_certs_button.setEnabled(SESecurityManager.resetTrustStore(true));
    new Label(gSecurity, SWT.NULL);
    // row
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    new BooleanParameter(gSecurity, "security.cert.auto.install", "security.cert.auto.install").setLayoutData(gridData);
    // row
    Label info_label = new Label(gSecurity, SWT.WRAP);
    Messages.setLanguageText(info_label, "ConfigView.section.security.toolsinfo");
    info_label.setLayoutData(Utils.getWrappableLabelGridData(3, 0));
    // row
    Label lStatsPath = new Label(gSecurity, SWT.NULL);
    // $NON-NLS-1$
    Messages.setLanguageText(lStatsPath, "ConfigView.section.security.toolsdir");
    ImageLoader imageLoader = ImageLoader.getInstance();
    Image imgOpenFolder = imageLoader.getImage("openFolderButton");
    gridData = new GridData();
    gridData.widthHint = 150;
    // $NON-NLS-1$ //$NON-NLS-2$
    final StringParameter pathParameter = new StringParameter(gSecurity, "Security.JAR.tools.dir", "");
    pathParameter.setLayoutData(gridData);
    Button browse = new Button(gSecurity, SWT.PUSH);
    browse.setImage(imgOpenFolder);
    imgOpenFolder.setBackground(browse.getBackground());
    browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));
    browse.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.APPLICATION_MODAL);
            dialog.setFilterPath(pathParameter.getValue());
            // $NON-NLS-1$
            dialog.setText(MessageText.getString("ConfigView.section.security.choosetoolssavedir"));
            String path = dialog.open();
            if (path != null) {
                pathParameter.setValue(path);
            }
        }
    });
    // row
    Label pw_label = new Label(gSecurity, SWT.NULL);
    Messages.setLanguageText(pw_label, "ConfigView.section.security.clearpasswords");
    Button pw_button = new Button(gSecurity, SWT.PUSH);
    buttons.add(pw_button);
    Messages.setLanguageText(pw_button, "ConfigView.section.security.clearpasswords.button");
    pw_button.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event event) {
            SESecurityManager.clearPasswords();
            CryptoManagerFactory.getSingleton().clearPasswords();
        }
    });
    new Label(gSecurity, SWT.NULL);
    if (userMode >= 2) {
        final CryptoManager crypt_man = CryptoManagerFactory.getSingleton();
        final Group crypto_group = new Group(gSecurity, SWT.NULL);
        gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 3;
        crypto_group.setLayoutData(gridData);
        layout = new GridLayout();
        layout.numColumns = 3;
        crypto_group.setLayout(layout);
        Messages.setLanguageText(crypto_group, "ConfigView.section.security.group.crypto");
        // wiki link
        final Label linkLabel = new Label(crypto_group, SWT.NULL);
        linkLabel.setText(MessageText.getString("ConfigView.label.please.visit.here"));
        linkLabel.setData(Constants.URL_WIKI + "w/Public_Private_Keys");
        linkLabel.setCursor(linkLabel.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
        linkLabel.setForeground(Colors.blue);
        gridData = new GridData();
        gridData.horizontalSpan = 3;
        linkLabel.setLayoutData(gridData);
        linkLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDoubleClick(MouseEvent arg0) {
                Utils.launch((String) ((Label) arg0.widget).getData());
            }

            @Override
            public void mouseDown(MouseEvent arg0) {
                Utils.launch((String) ((Label) arg0.widget).getData());
            }
        });
        ClipboardCopy.addCopyToClipMenu(linkLabel);
        // publick key display
        byte[] public_key = crypt_man.getECCHandler().peekPublicKey();
        Label public_key_label = new Label(crypto_group, SWT.NULL);
        Messages.setLanguageText(public_key_label, "ConfigView.section.security.publickey");
        final Label public_key_value = new Label(crypto_group, SWT.NULL);
        if (public_key == null) {
            Messages.setLanguageText(public_key_value, "ConfigView.section.security.publickey.undef");
        } else {
            public_key_value.setText(Base32.encode(public_key));
        }
        Messages.setLanguageText(public_key_value, "ConfigView.copy.to.clipboard.tooltip", true);
        public_key_value.setCursor(public_key_value.getDisplay().getSystemCursor(SWT.CURSOR_HAND));
        public_key_value.setForeground(Colors.blue);
        public_key_value.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDoubleClick(MouseEvent arg0) {
                copyToClipboard();
            }

            @Override
            public void mouseDown(MouseEvent arg0) {
                copyToClipboard();
            }

            protected void copyToClipboard() {
                new Clipboard(parent.getDisplay()).setContents(new Object[] { public_key_value.getText() }, new Transfer[] { TextTransfer.getInstance() });
            }
        });
        final CryptoManagerKeyListener cryptoManagerKeyListener = new CryptoManagerKeyListener() {

            @Override
            public void keyChanged(final CryptoHandler handler) {
                final CryptoManagerKeyListener me = this;
                Utils.execSWTThread(new Runnable() {

                    @Override
                    public void run() {
                        if (public_key_value.isDisposed()) {
                            crypt_man.removeKeyListener(me);
                        } else {
                            if (handler.getType() == CryptoManager.HANDLER_ECC) {
                                byte[] public_key = handler.peekPublicKey();
                                if (public_key == null) {
                                    Messages.setLanguageText(public_key_value, "ConfigView.section.security.publickey.undef");
                                } else {
                                    public_key_value.setText(Base32.encode(public_key));
                                }
                                crypto_group.layout();
                            }
                        }
                    }
                });
            }

            @Override
            public void keyLockStatusChanged(CryptoHandler handler) {
            }
        };
        crypt_man.addKeyListener(cryptoManagerKeyListener);
        parent.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                if (cryptoManagerKeyListener != null) {
                    CryptoManagerFactory.getSingleton().removeKeyListener(cryptoManagerKeyListener);
                }
            }
        });
        new Label(crypto_group, SWT.NULL);
        // manage keys
        /*
		    gridData = new GridData();
		    gridData.horizontalSpan = 3;

		    final BooleanParameter manage_keys = new BooleanParameter(
		    		crypto_group, "crypto.keys.system.managed.temp",
		    		"ConfigView.section.security.system.managed");

		    manage_keys.setLayoutData( gridData );

		    final ClientCryptoManager crypto_man 	= CryptoManagerFactory.getSingleton();
			final CryptoHandler ecc_handler = crypto_man.getECCHandler();

		    manage_keys.setSelected(
		    		ecc_handler.getDefaultPasswordHandlerType() == CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM );


		    manage_keys.addChangeListener(
		    	new ParameterChangeAdapter ()
		    	{
		    		public void
		    		parameterChanged(
		    			Parameter 	p,
		    			boolean 	caused_internally )
		    		{
	    				boolean existing_value = ecc_handler.getDefaultPasswordHandlerType() == CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM;

	    				if ( existing_value == manage_keys.isSelected()){

	    					return;
	    				}

	    				String	error = null;

	    				int	new_type = manage_keys.isSelected()?CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM:CryptoManagerPasswordHandler.HANDLER_TYPE_USER;

    					try{
    						ecc_handler.setDefaultPasswordHandlerType( new_type );

    						error = null;

    					}catch( CryptoManagerPasswordException e ){

    						if ( e.wasIncorrect()){

    							error = MessageText.getString( "ConfigView.section.security.unlockkey.error" );

    						}else{

    							if ( existing_value || !ecc_handler.isUnlocked()){

    								error = MessageText.getString( "Torrent.create.progress.cancelled" );

    							}else{

    								error = MessageText.getString( "ConfigView.section.security.vuze.login" );
    							}
    						}
    					}catch( Throwable e ){

    						error = Debug.getNestedExceptionMessage( e );
    					}

	    				if ( error != null ){

	    					MessageBoxShell mb = new MessageBoxShell(
	    							SWT.ICON_ERROR | SWT.OK,
	    							MessageText.getString("ConfigView.section.security.op.error.title"),
	    							MessageText.getString("ConfigView.section.security.op.error",
	    									new String[] { error }));
	      				mb.setParent(parent.getShell());
	    					mb.open(null);
	    				}

	    				boolean new_value = ecc_handler.getDefaultPasswordHandlerType() == CryptoManagerPasswordHandler.HANDLER_TYPE_SYSTEM;

	    				if ( new_value != manage_keys.isSelected()){

	    					manage_keys.setSelected( new_value );
	    				}
		    		}
		    	});
		    */
        // reset keys
        Label reset_key_label = new Label(crypto_group, SWT.NULL);
        Messages.setLanguageText(reset_key_label, "ConfigView.section.security.resetkey");
        Button reset_key_button = new Button(crypto_group, SWT.PUSH);
        buttons.add(reset_key_button);
        Messages.setLanguageText(reset_key_button, "ConfigView.section.security.clearpasswords.button");
        reset_key_button.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                MessageBoxShell mb = new MessageBoxShell(SWT.ICON_WARNING | SWT.OK | SWT.CANCEL, MessageText.getString("ConfigView.section.security.resetkey.warning.title"), MessageText.getString("ConfigView.section.security.resetkey.warning"));
                mb.setDefaultButtonUsingStyle(SWT.CANCEL);
                mb.setParent(parent.getShell());
                mb.open(new UserPrompterResultListener() {

                    @Override
                    public void prompterClosed(int returnVal) {
                        if (returnVal != SWT.OK) {
                            return;
                        }
                        try {
                            crypt_man.getECCHandler().resetKeys("Manual key reset");
                        } catch (Throwable e) {
                            MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e));
                            mb.setParent(parent.getShell());
                            mb.open(null);
                        }
                    }
                });
            }
        });
        new Label(crypto_group, SWT.NULL);
        // unlock
        Label priv_key_label = new Label(crypto_group, SWT.NULL);
        Messages.setLanguageText(priv_key_label, "ConfigView.section.security.unlockkey");
        Button priv_key_button = new Button(crypto_group, SWT.PUSH);
        buttons.add(priv_key_button);
        Messages.setLanguageText(priv_key_button, "ConfigView.section.security.unlockkey.button");
        priv_key_button.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                try {
                    crypt_man.getECCHandler().getEncryptedPrivateKey("Manual unlock");
                } catch (Throwable e) {
                    MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.resetkey.error.title"), getError(e));
                    mb.setParent(parent.getShell());
                    mb.open(null);
                }
            }
        });
        new Label(crypto_group, SWT.NULL);
        // backup
        Label backup_keys_label = new Label(crypto_group, SWT.NULL);
        Messages.setLanguageText(backup_keys_label, "ConfigView.section.security.backupkeys");
        final Button backup_keys_button = new Button(crypto_group, SWT.PUSH);
        buttons.add(backup_keys_button);
        Messages.setLanguageText(backup_keys_button, "ConfigView.section.security.backupkeys.button");
        backup_keys_button.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                FileDialog dialog = new FileDialog(backup_keys_button.getShell(), SWT.APPLICATION_MODAL);
                String target = dialog.open();
                if (target != null) {
                    try {
                        String keys = crypt_man.getECCHandler().exportKeys();
                        PrintWriter pw = new PrintWriter(new FileWriter(target));
                        pw.println(keys);
                        pw.close();
                    } catch (Throwable e) {
                        MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.op.error.title"), MessageText.getString("ConfigView.section.security.op.error", new String[] { getError(e) }));
                        mb.setParent(parent.getShell());
                        mb.open(null);
                    }
                }
            }
        });
        new Label(crypto_group, SWT.NULL);
        // restore
        Label restore_keys_label = new Label(crypto_group, SWT.NULL);
        Messages.setLanguageText(restore_keys_label, "ConfigView.section.security.restorekeys");
        final Button restore_keys_button = new Button(crypto_group, SWT.PUSH);
        buttons.add(restore_keys_button);
        Messages.setLanguageText(restore_keys_button, "ConfigView.section.security.restorekeys.button");
        restore_keys_button.addListener(SWT.Selection, new Listener() {

            @Override
            public void handleEvent(Event event) {
                FileDialog dialog = new FileDialog(backup_keys_button.getShell(), SWT.APPLICATION_MODAL);
                String target = dialog.open();
                if (target != null) {
                    try {
                        LineNumberReader reader = new LineNumberReader(new FileReader(target));
                        String str = "";
                        try {
                            while (true) {
                                String line = reader.readLine();
                                if (line == null) {
                                    break;
                                }
                                str += line + "\r\n";
                            }
                        } finally {
                            reader.close();
                        }
                        boolean restart = crypt_man.getECCHandler().importKeys(str);
                        if (restart) {
                            MessageBoxShell mb = new MessageBoxShell(SWT.ICON_INFORMATION | SWT.OK, MessageText.getString("ConfigView.section.security.restart.title"), MessageText.getString("ConfigView.section.security.restart.msg"));
                            mb.setParent(parent.getShell());
                            mb.open(null);
                            UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
                            if (uiFunctions != null) {
                                uiFunctions.dispose(true, false);
                            }
                        }
                    } catch (Throwable e) {
                        MessageBoxShell mb = new MessageBoxShell(SWT.ICON_ERROR | SWT.OK, MessageText.getString("ConfigView.section.security.op.error.title"), MessageText.getString("ConfigView.section.security.op.error", new String[] { getError(e) }));
                        mb.setParent(parent.getShell());
                        mb.open(null);
                    }
                }
            }
        });
        new Label(crypto_group, SWT.NULL);
    }
    Utils.makeButtonsEqualWidth(buttons);
    return gSecurity;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeListener(org.eclipse.swt.events.DisposeListener) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) ArrayList(java.util.ArrayList) Image(org.eclipse.swt.graphics.Image) DisposeEvent(org.eclipse.swt.events.DisposeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) MouseEvent(org.eclipse.swt.events.MouseEvent) CertificateCreatorWindow(com.biglybt.ui.swt.auth.CertificateCreatorWindow) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell) UIFunctionsSWT(com.biglybt.ui.swt.UIFunctionsSWT) UserPrompterResultListener(com.biglybt.ui.UserPrompterResultListener) GridData(org.eclipse.swt.layout.GridData) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) DisposeEvent(org.eclipse.swt.events.DisposeEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) Clipboard(org.eclipse.swt.dnd.Clipboard) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Example 64 with Transfer

use of org.eclipse.swt.dnd.Transfer in project epp.mpc by eclipse.

the class NewsViewer method createNoBrowserPart.

protected Control createNoBrowserPart(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).equalWidth(false).margins(20, 0).applyTo(container);
    Label noEmbedBrowserLabel = new Label(container, SWT.WRAP);
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.END).grab(true, true).hint(450, SWT.DEFAULT).applyTo(noEmbedBrowserLabel);
    noEmbedBrowserLabel.setText(Messages.NewsViewer_No_embeddable_browser);
    final Link link = new Link(container, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).indent(IDialogConstants.SMALL_INDENT, 0).grab(true, true).hint(450 - IDialogConstants.SMALL_INDENT, SWT.DEFAULT).applyTo(link);
    link.setText(Messages.NewsViewer_No_news);
    link.setEnabled(false);
    link.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            WorkbenchUtil.openUrl(e.text, IWorkbenchBrowserSupport.AS_EXTERNAL);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    Menu popup = new Menu(parent.getShell(), SWT.POP_UP);
    MenuItem copyMenuItem = new MenuItem(popup, SWT.PUSH);
    copyMenuItem.setText(Messages.NewsViewer_Copy_Link_Address);
    copyMenuItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            Clipboard clipboard = new Clipboard(link.getDisplay());
            // $NON-NLS-1$
            String data = (String) link.getData("href");
            clipboard.setContents(new Object[] { data }, new Transfer[] { TextTransfer.getInstance() });
            clipboard.dispose();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    link.setMenu(popup);
    browser = link;
    return container;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) Clipboard(org.eclipse.swt.dnd.Clipboard) Link(org.eclipse.swt.widgets.Link) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 65 with Transfer

use of org.eclipse.swt.dnd.Transfer in project epp.mpc by eclipse.

the class ShareSolutionLink method copyLinkToClipboard.

protected void copyLinkToClipboard() {
    Clipboard clipboard = new Clipboard(control.getDisplay());
    TextTransfer textTransfer = TextTransfer.getInstance();
    Transfer[] transfers = new Transfer[] { textTransfer };
    Object[] data = new Object[] { getUrl() };
    clipboard.setContents(data, transfers);
    clipboard.dispose();
}
Also used : TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Aggregations

Transfer (org.eclipse.swt.dnd.Transfer)151 TextTransfer (org.eclipse.swt.dnd.TextTransfer)71 Point (org.eclipse.swt.graphics.Point)63 Clipboard (org.eclipse.swt.dnd.Clipboard)51 Menu (org.eclipse.swt.widgets.Menu)37 IMenuManager (org.eclipse.jface.action.IMenuManager)32 MenuManager (org.eclipse.jface.action.MenuManager)32 Separator (org.eclipse.jface.action.Separator)32 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)32 EditingDomainViewerDropAdapter (org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)30 LocalTransfer (org.eclipse.emf.edit.ui.dnd.LocalTransfer)30 ViewerDragAdapter (org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter)30 UnwrappingSelectionProvider (org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider)30 FileTransfer (org.eclipse.swt.dnd.FileTransfer)30 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)27 DropTarget (org.eclipse.swt.dnd.DropTarget)23 GridData (org.eclipse.swt.layout.GridData)23 GridLayout (org.eclipse.swt.layout.GridLayout)22 Composite (org.eclipse.swt.widgets.Composite)22 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)20