Refine search
private static FileObject getFileObject(Lookup lookup) { FileObject fileObject = lookup.lookup(FileObject.class); if( null == fileObject) { DataObject dataObject = lookup.lookup(DataObject.class); if( null != dataObject ) { fileObject = dataObject.getPrimaryFile(); } } return fileObject; }
public boolean isActionEnabled(String command, Lookup context) throws IllegalArgumentException { Project p = context.lookup(Project.class); if (p != null) { return false; } Collection<? extends DataObject> files = context.lookupAll(DataObject.class); if (files.isEmpty()) { return false; } for (DataObject d : files) { if (!d.getPrimaryFile().getMIMEType().equals(RubyInstallation.RUBY_MIME_TYPE)) { return false; } } return true; }
private static FileObject getFileObject(Lookup lookup) { FileObject fileObject = lookup.lookup(FileObject.class); if( null == fileObject) { DataObject dataObject = lookup.lookup(DataObject.class); if( null != dataObject ) { fileObject = dataObject.getPrimaryFile(); } } return fileObject; }
private FileObject getFileObject(TopComponent topComponent) { FileObject fileObject = null; DataObject dataObject = topComponent.getLookup().lookup(DataObject.class); if (dataObject != null) { fileObject = dataObject.getPrimaryFile(); } return fileObject; }
private static FileObject getFileObjectFromNode(Node node) { DataObject dobj = node.getLookup().lookup(DataObject.class); return dobj != null ? dobj.getPrimaryFile() : null; }
/** * Get {@link FileObject} for the given {@link Lookup context}. * @param context {@link Lookup context} where the {@link FileObject} is searched for * @return {@link FileObject} for the given {@link Lookup context} or <code>null</code> if not found */ @CheckForNull public static FileObject getFileObject(Lookup context) { FileObject fo = context.lookup(FileObject.class); if (fo != null) { return fo; } DataObject d = context.lookup(DataObject.class); if (d != null) { return d.getPrimaryFile(); } return null; }
/** * just gets the array of FOs from lookup. */ protected static FileObject[] extractFileObjectsfromLookup(Lookup lookup) { List<FileObject> files = new ArrayList<FileObject>(); Iterator<? extends DataObject> it = lookup.lookup(new Lookup.Template<DataObject>(DataObject.class)).allInstances().iterator(); while (it.hasNext()) { DataObject d = it.next(); FileObject f = d.getPrimaryFile(); files.add(f); } return files.toArray(new FileObject[files.size()]); }
private FileObject getFileObject() { FileObject fileObject = originalNode.getLookup().lookup(FileObject.class); if (fileObject != null) { return fileObject; } // just fallback, should not happen DataObject dataObject = originalNode.getLookup().lookup(DataObject.class); assert dataObject != null; fileObject = dataObject.getPrimaryFile(); assert fileObject != null; return fileObject; } }
public void run() { List<FileObject> fileObjects = new ArrayList<FileObject>(nodes.size()); for (Node node:nodes) { DataObject dataObject = node.getLookup().lookup(DataObject.class); if (dataObject!=null) { FileObject primaryFileObject = dataObject.getPrimaryFile(); if (primaryFileObject != null) { fileObjects.add(primaryFileObject); } } } UI.openRefactoringUI(createRefactoringUI(fileObjects.toArray(new FileObject[fileObjects.size()]))); }
protected FileObject getNodeFileObject(Transferable transferable) { Node node = NodeTransfer.node(transferable, NodeTransfer.DND_COPY_OR_MOVE); if (node == null) return null; DataObject dataObject = (DataObject) node.getLookup().lookup(DataObject.class); if (dataObject == null) return null; FileObject file = dataObject.getPrimaryFile(); return file; }
protected static Project getProject(Node node) { DataObject dataObject = node.getLookup().lookup(DataObject.class); if (dataObject != null) { FileObject fileObject = dataObject.getPrimaryFile(); if (fileObject != null) { return FileOwnerQuery.getOwner(fileObject); } } return null; }
private FileObject getTarget(Lookup look) { ExplorerContext drop = look.lookup(ExplorerContext.class); if (drop==null) return null; Node n = (Node) drop.getTargetNode(); if (n==null) return null; DataObject dob = n.getCookie(DataObject.class); if (dob!=null) return dob.getPrimaryFile(); return null; }
@Override public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (COMMAND_SELECT.equals(command)) { Node[] selection = browsePanel.getExplorerManager().getSelectedNodes(); if (selection != null && selection.length > 0) { DataObject dobj = (DataObject) selection[0].getLookup().lookup(DataObject.class); result = dobj.getPrimaryFile(); } } }
private boolean onRunSingleStep(MakeConfiguration conf, ArrayList<ProjectActionEvent> actionEvents, Lookup context, Type actionEvent) { // FIXUP: not sure this is used... if (conf.isMakefileConfiguration()) { DataObject d = context.lookup(DataObject.class); String path = CndFileUtils.toFile(d.getPrimaryFile()).getPath(); ProjectActionEvent projectActionEvent = new ProjectActionEvent(project, actionEvent, path, conf, null, false); actionEvents.add(projectActionEvent); } else { assert false; } return true; }
private static FileObject getFileObjectFromNode(Node node) { DataObject dO; DataFolder df; dO = node.getLookup().lookup(DataObject.class); if (null != dO) { return dO.getPrimaryFile(); } df = node.getLookup().lookup(DataFolder.class); if (null != df) { return df.getPrimaryFile(); } return null; }
/** * Provide cookies to actions. * If a node represents primary file of a DataObject * it has respective DataObject cookies. */ @SuppressWarnings("unchecked") // Adding getCookie(Class<Cookie> klass) results in name clash @Override public Cookie getCookie(Class klass) { FileObject fo = getLookup().lookup(FileObject.class); if (fo != null && dobj != null && fo.equals(dobj.getPrimaryFile())) { return dobj.getCookie(klass); } return super.getCookie(klass); }
public ContextAction(Lookup context) { super(NbBundle.getMessage(BowerInstallAction.class, "CTL_BowerInstallAction")); Project p = context.lookup(Project.class); if (p!=null) { bower_json = p.getProjectDirectory().getFileObject("bower.json");//NOI18N } else { DataObject dob = context.lookup(DataObject.class); bower_json = dob.getPrimaryFile(); } setEnabled(bower_json!=null); putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); }
/** * Indicates if this node allows setting it selected. * * @return true if this node can be selected, false otherwise. */ public boolean canSelect() { DataObject dobj = (DataObject) getLookup().lookup(DataObject.class); return dobj != null && !dobj.getPrimaryFile().isFolder() && decorator.validate(this) == null; }
private FileObject getCurrentFile() { Node[] activatedNodes = TopComponent.getRegistry().getActivatedNodes(); if (activatedNodes == null || activatedNodes.length != 1) { return null; } DataObject dobj = activatedNodes[0].getLookup().lookup(DataObject.class); if (dobj == null) { return null; } FileObject fo = dobj.getPrimaryFile(); return fo; }
public void actionPerformed( ActionEvent e ) { String command = e.getActionCommand(); if ( COMMAND_SELECT.equals( command ) ) { Node selection[] = browsePanel.getExplorerManager().getSelectedNodes(); if ( selection != null && selection.length > 0 ) { DataObject dobj = (DataObject)selection[0].getLookup().lookup( DataObject.class ); if ( dobj != null ) { FileObject fo = dobj.getPrimaryFile(); if ( fo.isFolder() ) { result = fo; } } } } }