Java 类org.openide.util.datatransfer.NewType 实例源码

项目:incubator-netbeans    文件:RADMenuComponent.java   
/** Support for new types that can be created in this node.
 * @return array of new type operations that are allowed
 */
@Override
public NewType[] getNewTypes() {
    if (isReadOnly())
        return RADComponent.NO_NEW_TYPES;

    Class[] classes = supportedMenus.get(Integer.valueOf(getMenuItemType()));

    if (classes == null)
        return RADComponent.NO_NEW_TYPES;

    NewType[] types = new NewType[classes.length];
    for (int i = 0; i < types.length; i++)
        types[i] = new NewMenuType(classes[i]);

    return types;
}
项目:incubator-netbeans    文件:AllPropsNode.java   
public NewType[] getNewTypes() {
    return new NewType[] { new NewType() {
        public String getName() {
            return bundle.getString("LBL_NewProp");
        }
        public HelpCtx getHelpCtx() {
            return new HelpCtx("org.myorg.systemproperties");
        }
        public void create() throws IOException {
            String title = bundle.getString("LBL_NewProp_dialog");
            String msg = bundle.getString("MSG_NewProp_dialog_key");
            NotifyDescriptor.InputLine desc = new NotifyDescriptor.InputLine(msg, title);
            DialogDisplayer.getDefault().notify(desc);
            String key = desc.getInputText();
            if ("".equals(key)) return;
            msg = bundle.getString("MSG_NewProp_dialog_value");
            desc = new NotifyDescriptor.InputLine(msg, title);
            DialogDisplayer.getDefault().notify(desc);
            String value = desc.getInputText();
            System.setProperty(key, value);
            PropertiesNotifier.changed();
        }
    } };
}
项目:incubator-netbeans    文件:NewAction.java   
/** Performs action on given type
 */
private static void performAction(Node[] activatedNodes, NewType type) {
    PasteAction.NodeSelector sel = null;

    try {
        ExplorerManager em = PasteAction.findExplorerManager();

        if (em != null) {
            sel = new PasteAction.NodeSelector(em, activatedNodes);
        }

        type.create();
    } catch (java.io.IOException e) {
        Exceptions.printStackTrace(e);
    } finally {
        if (sel != null) {
            sel.select();
        }
    }
}
项目:incubator-netbeans    文件:NewAction.java   
private NewType[] newTypes() {
    if (lookup != null) {
        java.util.Collection c = lookup.lookupResult(Node.class).allItems();

        if (c.size() == 1) {
            java.util.Iterator it = c.iterator();

            while (it.hasNext()) {
                Lookup.Item item = (Lookup.Item) it.next();
                Node n = (Node) item.getInstance();

                if (n != null) {
                    if (n == prevNode && prevTypes != null) {
                        return prevTypes;
                    }
                    prevNode = n;
                    prevTypes = n.getNewTypes();
                    return prevTypes;
                }
            }
        }
    }

    return getNewTypes();
}
项目:incubator-netbeans    文件:NewAction.java   
public void performActionAt(int index) {
    NewType[] nt = newTypes();

    // bugfix #41587, AIOBE if array is empty
    if (nt.length <= index) {
        return;
    }

    Node[] arr;

    if (lookup != null) {
        arr = (Node[]) lookup.lookupAll(Node.class).toArray(new Node[0]);
    } else {
        arr = WindowManager.getDefault().getRegistry().getCurrentNodes();
    }

    performAction(arr, nt[index]);
}
项目:studio    文件:IndexedPropertyEditor.java   
public NewType[] getNewTypes() {
    NewType nt = new NewType() {
        public void create() {
            if (array != null) {
                Object []newArray = (Object[])Array.newInstance(getConvertedType(), array.length+1);
                System.arraycopy(array, 0, newArray, 0, array.length);
                // throw away the old array!
                array = newArray;
                array[array.length-1] = defaultValue();
            } else {
                // throw away the old array!
                array = (Object[])Array.newInstance(getConvertedType(), 1);
                array[0] = defaultValue();
            }
            IndexedPropertyEditor.this.firePropertyChange();
            DisplayIndexedNode din = new DisplayIndexedNode(array.length-1);
            getChildren().add(new Node[] { din });
            Index i = (Index)getCookie(Index.class);
            i.addChangeListener(WeakListener.change(din, i));
        }
    };
    return new NewType[] { nt };
}
项目:studio    文件:NewAction.java   
/** Performs action on given type
 */
private static void performAction (Node[] activatedNodes, NewType type) {
    PasteAction.NodeSelector sel = null;
    try {
        ExplorerManager em = PasteAction.findExplorerManager();
        if (em != null) {
            sel = new PasteAction.NodeSelector (em, activatedNodes);
        }
        type.create();
    } catch (java.io.IOException e) {
        DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE));
    } finally {
        if (sel != null) {
            sel.select ();
        }
    }
}
项目:studio    文件:NewAction.java   
private NewType[] newTypes () {
    if (lookup != null) {
        java.util.Collection c = lookup.lookup (
            new Lookup.Template (Node.class)
        ).allItems ();
        if (c.size () == 1) {
            java.util.Iterator it = c.iterator();
            while (it.hasNext()) {
                Lookup.Item item = (Lookup.Item)it.next ();
                Node n = (Node)item.getInstance();
                if (n != null) {
                    return n.getNewTypes();
                }
            }
        }
    }
    return getNewTypes ();
}
项目:incubator-netbeans    文件:IndexedPropertyEditor.java   
public NewType[] getNewTypes() {
    NewType nt = new NewType() {
            public void create() {
                if (array != null) {
                    Object[] newArray = (Object[]) Array.newInstance(getConvertedType(), array.length + 1);
                    System.arraycopy(array, 0, newArray, 0, array.length);

                    // throw away the old array!
                    array = newArray;
                    array[array.length - 1] = defaultValue();
                } else {
                    // throw away the old array!
                    array = (Object[]) Array.newInstance(getConvertedType(), 1);
                    array[0] = defaultValue();
                }

                IndexedPropertyEditor.this.firePropertyChange();

                DisplayIndexedNode din = new DisplayIndexedNode(array.length - 1);
                getChildren().add(new Node[] { din });

                Index i = getCookie(Index.class);
                i.addChangeListener(org.openide.util.WeakListeners.change(din, i));
            }
        };

    return new NewType[] { nt };
}
项目:incubator-netbeans    文件:RootNode.java   
@Override
public NewType[] getNewTypes() {
    NewType[] res = super.getNewTypes();
    if( null == res || res.length == 0 ) {
        DataFolder paletteFolder = (DataFolder)getCookie( DataFolder.class );
        if( null != paletteFolder )
            res = new NewType[] { new NewCategory() };
    }
    return res;
}
项目:incubator-netbeans    文件:Utils.java   
public void actionPerformed(ActionEvent event) {
    NewType[] newTypes = paletteNode.getNewTypes();
    try {
        if( null != newTypes && newTypes.length > 0 ) {
            newTypes[0].create();
        }
    } catch( IOException ioE ) {
        ERR.log( Level.INFO, ioE.getLocalizedMessage(), ioE );
    }
}
项目:incubator-netbeans    文件:PhadhailLook.java   
public NewType[] getNewTypes(Phadhail ph, Lookup e) {
    if (ph.hasChildren()) {
        return new NewType[] {
            new PhadhailNewType(ph, false),
            new PhadhailNewType(ph, true),
        };
    } else {
        return new NewType[0];
    }
}
项目:incubator-netbeans    文件:PhadhailNode.java   
public NewType[] getNewTypes() {
    if (ph.hasChildren()) {
        return new NewType[] {
            new PhadhailNewType(ph, false),
            new PhadhailNewType(ph, true),
        };
    } else {
        return new NewType[0];
    }
}
项目:incubator-netbeans    文件:PropertiesDataNode.java   
/** Gets new types that can be created in this node.
 * @return array with <code>NewLocaleType</code> */
@Override
public NewType[] getNewTypes() {
    PropertiesDataObject propDO = (PropertiesDataObject) getDataObject();
    if (propDO.isMultiLocale()) {
    return new NewType[] {new NewLocaleType()};
    } else {
        PropertiesFileEntry pfEntry = (PropertiesFileEntry) propDO.getPrimaryEntry();
        return new NewType[] { new NewLocaleType(),
                               new PropertiesLocaleNode.NewPropertyType(pfEntry) };
}
}
项目:incubator-netbeans    文件:NewAction.java   
/** Performs action on index and nodes.
*/
private static void performAction(Node[] activatedNodes, int indx) {
    NewType[] types = getNewTypes(activatedNodes);

    if (types.length <= indx) {
        return;
    }

    performAction(activatedNodes, types[indx]);
}
项目:incubator-netbeans    文件:NewAction.java   
/** Getter for array of activated new types.
*/
private static NewType[] getNewTypes(Node[] activatedNodes) {
    if ((activatedNodes == null) || (activatedNodes.length != 1)) {
        return new NewType[0];
    } else {
        return activatedNodes[0].getNewTypes();
    }
}
项目:incubator-netbeans    文件:NewAction.java   
/** Utility method, creates name for action depending on specified new types. */
private static String createName(NewType[] newTypes) {
    if ((newTypes != null) && (newTypes.length == 1)) {
        return NbBundle.getMessage(NewAction.class, "NewArg", newTypes[0].getName());
    } else {
        return NbBundle.getMessage(NewAction.class, "New");
    }
}
项目:incubator-netbeans    文件:NewAction.java   
public String getLabel(int index) {
    NewType[] newTypes = newTypes();

    if (newTypes.length <= index) {
        return null;
    } else {
        return newTypes[index].getName();
    }
}
项目:incubator-netbeans    文件:NewAction.java   
public HelpCtx getHelpCtx(int index) {
    NewType[] newTypes = newTypes();

    if (newTypes.length <= index) {
        return null;
    } else {
        return newTypes[index].getHelpCtx();
    }
}
项目:ireport-fork    文件:CrosstabGroupsNode.java   
/**
 *  We can create a new Parameter here...
 */
@Override
public NewType[] getNewTypes()
{
    // TODO: add the ability to create a new group...
    if (getType() == CrosstabGroupNode.ROW_GROUP)
    {
        return NewTypesUtils.getNewType(this, NewTypesUtils.CROSSTAB_ROW_GROUP);
    }
    else
    {
        return NewTypesUtils.getNewType(this, NewTypesUtils.CROSSTAB_COLUMN_GROUP);
    }
}
项目:ireport-fork    文件:LibraryTemplateReferenceNode.java   
@Override
public NewType[] getNewTypes()
{
    if (getParentNode() instanceof TemplateNode)
    {
        return ((TemplateNode)getParentNode()).getNewTypes();
    }
    return super.getNewTypes();
}
项目:ireport-fork    文件:LibraryStyleNode.java   
@Override
public NewType[] getNewTypes()
{
    if (getParentNode() instanceof TemplateNode)
    {
        return ((TemplateNode)getParentNode()).getNewTypes();
    }
    return super.getNewTypes();
}
项目:studio    文件:NewAction.java   
/** Performs action on index and nodes.
*/
private static void performAction (Node[] activatedNodes, int indx) {
    NewType[] types = getNewTypes (activatedNodes);
    if (types.length <= indx) {
        return;
    }

    performAction (activatedNodes, types[indx]);
}
项目:studio    文件:NewAction.java   
/** Getter for array of activated new types.
*/
private static  NewType[] getNewTypes (Node[] activatedNodes) {
    if (activatedNodes == null || activatedNodes.length != 1) {
        return new NewType[0];
    } else {
        return activatedNodes[0].getNewTypes ();
    }
}
项目:studio    文件:NewAction.java   
protected boolean enable (Node[] activatedNodes) {
    NewType[] types = getNewTypes ();

    // notify listeners
    Object[] listeners = model.getListenerList();
    if (listeners.length > 0) {
        ChangeEvent ev = new ChangeEvent (model);
        for (int i = listeners.length-1; i>=0; i-=2) {
            ((ChangeListener)listeners[i]).stateChanged (ev);
        }
    }

    return (types.length > 0);
}
项目:studio    文件:NewAction.java   
/** Utility method, creates name for action depending on specified new types. */
private static String createName(NewType[] newTypes) {
    if ((newTypes != null) && (newTypes.length == 1)) {
        return NbBundle.getMessage(NewAction.class, "NewArg", newTypes[0].getName());
    } else {
        return NbBundle.getMessage(NewAction.class, "New");
    }
}
项目:studio    文件:NewAction.java   
public String getLabel(int index) {
    NewType[] newTypes = newTypes();
    if (newTypes.length <= index)
        return null;
    else
        return newTypes[index].getName();
}
项目:studio    文件:NewAction.java   
public HelpCtx getHelpCtx (int index) {
    NewType[] newTypes = newTypes();
    if (newTypes.length <= index)
        return null;
    else
        return newTypes[index].getHelpCtx();
}
项目:studio    文件:NewAction.java   
public void performActionAt(int index) {
    NewType[] nt = newTypes ();
    if (nt.length < index) {
        return;
    }

    Node[] arr;
    if (lookup != null) {
        arr = (Node[])lookup.lookup (new Lookup.Template (Node.class)).allInstances ().toArray (new Node[0]);
    } else {
        arr = WindowManager.getDefault().getRegistry ().getCurrentNodes ();
    }

    performAction (arr, nt[index]);
}
项目:incubator-netbeans    文件:RADComponentNode.java   
@Override
public NewType[] getNewTypes() {
    return component.getNewTypes();
}
项目:incubator-netbeans    文件:RADComponent.java   
/** Support for new types that can be created in this node.
 * @return array of new type operations that are allowed
 */
public NewType[] getNewTypes() {
    return NO_NEW_TYPES;
}
项目:incubator-netbeans    文件:Utils.java   
@Override
public boolean isEnabled() {
    NewType[] newTypes = paletteNode.getNewTypes();
    return null != newTypes && newTypes.length > 0;
}
项目:incubator-netbeans    文件:PropertiesLocaleNode.java   
/** List new types that can be created in this node. Overrides superclass method.
 * @return new types
 */
@Override
public NewType[] getNewTypes () {
    return new NewType[] { new NewPropertyType((PropertiesFileEntry)getFileEntry()) };
}
项目:incubator-netbeans    文件:JavaSrc.java   
/** Support for new types that can be created in this node.
* @return array of new type operations that are allowed
*/
public NewType[] getNewTypes () {
    return new NewType[0];
}
项目:incubator-netbeans    文件:FilterNode.java   
public NewType[] getNewTypes() {
    return original.getNewTypes();
}
项目:incubator-netbeans    文件:NewAction.java   
/** Getter for array of activated new types.
*/
private static NewType[] getNewTypes() {
    return getNewTypes(WindowManager.getDefault().getRegistry().getCurrentNodes());
}
项目:incubator-netbeans    文件:NewAction.java   
protected boolean enable(Node[] activatedNodes) {
    NewType[] types = getNewTypes();
    model.cs.fireChange();
    return (types.length > 0);
}
项目:incubator-netbeans    文件:EditActionTest.java   
public NewType[] getNewTypes() { 
    return null; 
}
项目:incubator-netbeans    文件:OpenActionTest.java   
public NewType[] getNewTypes() { 
    return null; 
}
项目:incubator-netbeans    文件:PrintActionTest.java   
public NewType[] getNewTypes() { 
    return null; 
}