Java Code Examples for org.openide.windows.TopComponent#Cloneable
The following examples show how to use
org.openide.windows.TopComponent#Cloneable .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TopComponentDragSupport.java From netbeans with Apache License 2.0 | 6 votes |
/** Implements <code>Transferable</code> method. * @return Array of <code>DataFlavor</code> with mimetype * {@link #MIME_TOP_COMPONENT} and also with mimetype * {@link #MIME_CLONEABLE_TOP_COMPONENT} * if the <code>tc</code> is instance * of <code>TopComponent.Cloneable</code> */ @Override public DataFlavor[] getTransferDataFlavors() { try { TopComponent tc = weakTC.get(); if(tc instanceof TopComponent.Cloneable) { return new DataFlavor[]{ new DataFlavor(MIME_TOP_COMPONENT, null, TopComponent.class.getClassLoader()), new DataFlavor(MIME_TOP_COMPONENT_CLONEABLE, null, TopComponent.Cloneable.class.getClassLoader())}; } else { return new DataFlavor[] { new DataFlavor(MIME_TOP_COMPONENT, null, TopComponent.class.getClassLoader()) }; } } catch (ClassNotFoundException ex) { Logger.getLogger(TopComponentDragSupport.class.getName()).log( Level.WARNING, ex.getMessage(), ex); } return new DataFlavor[0]; }
Example 2
Source File: ActionUtils.java From netbeans with Apache License 2.0 | 6 votes |
static void cloneWindow(TopComponent tc) { if(tc instanceof TopComponent.Cloneable) { TopComponent clone = ((TopComponent.Cloneable)tc).cloneComponent(); int openIndex = -1; Mode m = findMode(tc); if( null != m ) { TopComponent[] tcs = m.getTopComponents(); for( int i=0; i<tcs.length; i++ ) { if( tcs[i] == tc ) { openIndex = i + 1; break; } } if( openIndex >= tcs.length ) openIndex = -1; } if( openIndex >= 0 ) { clone.openAtTabPosition(openIndex); } else { clone.open(); } clone.requestActive(); } }
Example 3
Source File: CloneDocumentAction.java From netbeans with Apache License 2.0 | 6 votes |
/** Perform the action. Sets/unsets maximzed mode. */ @Override public void actionPerformed(java.awt.event.ActionEvent ev) { TopComponent tc = TopComponent.getRegistry().getActivated(); if(tc == null || !(tc instanceof TopComponent.Cloneable)) { return; } ModeImpl mode = (ModeImpl)WindowManagerImpl.getInstance().findMode(tc); if(mode == null) { return; } if(mode.getKind() == Constants.MODE_KIND_EDITOR) { ActionUtils.cloneWindow(tc); } }
Example 4
Source File: TopComponentDragSupport.java From netbeans with Apache License 2.0 | 5 votes |
/** Implements <code>Transferable</code> method. * @return <code>TopComponent</code> instance for <code>DataFlavor</code> * with mimetype equal to {@link #MIME_TOP_COMPONENT} or if mimetype * equals to {@link #MIME_CLONEABLE_TOP_COMPONENT} and the top component * is instance of <code>TopComponent.Cloneable</code> returns the instance */ @Override public Object getTransferData(DataFlavor df) { TopComponent tc = weakTC.get(); if(MIME_TOP_COMPONENT.equals(df.getMimeType())) { return tc; } else if(MIME_TOP_COMPONENT_CLONEABLE.equals( df.getMimeType()) && tc instanceof TopComponent.Cloneable) { return tc; } return null; }
Example 5
Source File: TopComponentDragSupport.java From netbeans with Apache License 2.0 | 5 votes |
/** Implements <code>Transferable</code> method. * @return <code>true</code> for <code>DataFlavor</code> with mimetype * equal to {@link #MIME_TOP_COMPONENT} * and if <code>tc</code> is instance * of <code>TopComponent.Cloneable</code> also for the one * with mimetype {@link #MIME_TOP_COMPONENT_CLONEABLE}, * <code>false</code> otherwise */ @Override public boolean isDataFlavorSupported(DataFlavor df) { TopComponent tc = weakTC.get(); if(MIME_TOP_COMPONENT.equals(df.getMimeType())) { return true; } else if(MIME_TOP_COMPONENT_CLONEABLE.equals( df.getMimeType()) && tc instanceof TopComponent.Cloneable) { return true; } return false; }