I have an exam and I would like to print my Java (in NetBeans project) files as fast as possible. I was wondering is there a way to print an entire project/project in NetBeans with one click? or do you have a better suggestion? (I will be using Windows XP and there is no nice editor like Gedit or Kate installed)
Give that the identical question on the netbeans forum from last year is not answered yet, I would say no.
When I needed to print off my final year Comp Sc project (needed to hand in a full print out + polished install CD, oh the poor trees that died for that one...), I opened every file then went through and did a print & close on each one. :(
It can be done. Switch to file mode, select all files, open all, then print. From http://dgreen.github.io/blog/2010/11/02/printing-multiple-files-in-netbeans/
I had the same problem. I am in a Computer Science class with Java Programming. My homework asignment involves creating a project with many class files (7 at the moment) so I searched google for how to print out the project and found nothing. However, I have come up with a bit of a kludgy way to do this, after reading it you can be the judge of how much time it will actually save. The more classes you have in a single project, the more time it will save. The methodology is kludgy because it involves as little system access as possible, because as you said you are on a school computer so I will assume only the most basic access. It DOES require command prompt access, so this may not be helpful for you. However, it is possible that if you cannot open the command prompt you may be able to execute a .bat file. So here goes.
Point command prompt to your source directory and type:
dir /b > projectDir.txt
or save that 1 line in a text editor as dir.bat
this will give you a text file listing all of the java files in your source directory
open notepad and type this 1 line
/*PAGEBREAK*/
save that file as pagebreak.txt
now, open the projectDir.txt file you created with Notepad.
do a global replace of ".java" with ".java+pagebreak.txt+"
get rid of the line that has projectDir.txt listed
save the file as projectDir.html
open this file in a web browser. the point of this is to get rid of the line breaks created by using dir /b.
now, copy this line of text and paste it into a new notepad window. at the beginning of the line, add "copy /b " and at the end of the line, replace the final "+" with " wholeProject.java"
run your bat file. if everything has been successful, you will have a single java file containing all of your classes. add this file to your project tree in netBeans IDE.
Export that file as an HTML file. one problem is that if you use line numbers, the numbers will be continuous; each new class will not start with 1, so I would advise against that.
Open up the html file in notepad. Do a global replace of "/*PAGEBREAK*/" with "<p style='page-break-before: always'>". Save your file, open it in a browser.
When you print it, it should print each class on its own page.
hope this helps! netBeans should really implement this though, my method is pretty goofy and contrived.
I found a new way (I hope it is a new way...)
You first want to copy the html , you can do that by choosing "Print to HTML ... " option from the Netbeans settings and choose the " Print to Clipboard " option .
Open the any text app and paste it , save with .html extension .
Now you can use from any browser to print the way you want it .
Related
Is there's any command line interface to close a single file from all the open files?
I know I can close all files yet I sometimes work from a network location and I would like to close a set of files with a single script.
For recent MATLABs you can close files that are open in the MATLAB editor with something like the following:
matlab.desktop.editor.findOpenDocument( 'C:\my_function.m' ).close()
For older MATLABs you can try something like this (but I don't have an old installation to test):
com.mathworks.mlservices.MLEditorServices.closeDocument( 'C:\my_function.m' )
I'm trying to use the save_file() from traitsui.file_dialog, and I'm having a problem...the really odd thing is that if I run my code in Visual Studio (using PTVS), it works just fine!
Here's the problem as I see it...
When I use the dialog created by save_file() to pick an already existing file, I get NotImplemented errors in the iPython window of the Canopy editor, and I think it indicates that I don't have a FileExistsHandler in my code (I'm still in the early phases of learning Python/Canopy/Traits, so I may be all wet here :)). I never get a 'File Already Exists' popup either.
However, when I run the same code from inside Visual Studio using PTVS, I do get the 'File Already Exists' popup with the option to accept it or cancel.
Why does the PTVS version work, and (more importantly) how can I get my Canopy Editor version to work???
Thanks for any hand-holding anyone can supply :)
Steve
Steve, one simple thing to try in the Canopy preferences dialog's Python tab would be changing the GUI backend from Qt to WX.
Updating:
A somewhat more attractive and performant solution would be to continue using Qt but to use the file dialogs from pyface (pyface.api.FileDialog (Qt-specific; for the API, see https://github.com/enthought/pyface/blob/master/pyface/i_file_dialog.py).
Further Update...
Here's a simple block of code that works fine when using WX as the Python backend, but it has problems running using Qt:
from traitsui.file_dialog import save_file, TextInfo
import os
def SaveFile ( filename ):
""" Handles the user clicking the 'SaveAs...' button.
"""
if not os.path.isfile(filename): # if the file doesn't exist, just put the path into the file_name so I start in the same directory
(filename, dummyname) = os.path.split(filename)
filename = save_file( extensions = TextInfo(),
file_name = filename,
title = 'Save File As...',
)
return filename
newfile = SaveFile('C:\\temp\\already_there.txt')
If you run this using WX, you get the pop-up 'File already exists...' dialog with OK/Cancel buttons...running using Qt on the backend produces no pop-up, and NotImplemented errors in the iPython window :( (If I type in a new, non-existing filename, the save_file works correctly)
I really like the look of Qt screens, and someone told me that WX is for Windows only (I'm not sure of that, I haven't checked)
Is there a way I can get the save_file() to work correctly and error-free under Qt?
I want to use gvim as the standard editor for Matlab. It used to work on Linux but now I am forced to use windows and I can't seem to figure out how to set the editor such that files are opened in gvim in a new tab.
In the preferences there is a field which allows to pass a command that points to the prefered text editor. That works, but things fail when I try to give additional options, in my case that would be "--remote-tab-silent" to tell gvim to open the file in a running instance in a new tab. More specifically, the following line in the matlab preferences works:
C:\pathtovim\gvim.exe
while this one fails
C:\pathtovim\gvim.exe --remote-tab-silent
A command line opens with the following error message (my own translation from German):
The command ""C:\pathtovim\gvim.exe --remote-tab-silent"" is either spelled incorrectly or could not be found.
My guess is that it has something to do with the additional quotes, I have no idea why the command is issued with quotes, even though in the field I put it without. The follwing commands work when typed into the command line directly:
"C:\pathtovim\gvim.exe"
C:\pathtovim\gvim.exe --remote-tab-silent file.m
and this one fails:
"C:\pathtovim\gvim.exe --remote-tab-silent file.m"
I'd really appreciate any help! Thanks!
I can't find a good way to hack around it through the MATLAB settings; it looks like MATLAB is stupidly expecting the text editor to take only file names as arguments.
I think your best option, is to create a .bat script that simply passes any arguments it receives on to Vim, inserting the --remote-tab-silent.
I.e. create a .bat file with these contents:
"C:\pathtovim\gvim.exe" --remote-tab-silent %*
Then set up your MATLAB preferences to invoke the .bat file rather than Vim.
This might seem to be a very very stupid question.
But for the past few years I have been using vim and cscope on the terminal, with some screen to make life a bit bearable.
I have just started to learn emacs and it is much more satisfying to use it.
Problem using emacs:
Every time I do M-x find-c-symbol, I get a new buffer with a bunch of files, but I don't know how to open the file at the exact line number.
I googled a lot and found this to open file under cursor: M-x ffap
but this opens at the first line. Can some emacs expert help me??
Thanks
I've got both Emacs 23.x and 24.x installed, both setup with working cscope and xcscope installs. Neither has a "find-c-symbol" function, but there is a "cscope-find-this-symbol", which is what I assume you're actually using.
I'm going to assume you're using a GUI version, and not the text-only version, and that you're actually getting the *cscope* buffer automatically being opened and created (since that's what it sounds like from your description).
For a simple search, I'll get results that look like this:
Finding symbol: debug
Database directory: /home/user/emacs_tags/modular/
-------------------------------------------------------------------------------
*** /home/user/code/modular/frontend/common/controller.test/src/MainTest.cpp:
<global>[73] #ifdef debug
-------------------------------------------------------------------------------
Database directory: /home/user/emacs_tags/rrsdk/
-------------------------------------------------------------------------------
*** /home/user/code/rrsdk/fs/apps/busybox/src/shell/ash.c:
<global>[303] #define debug optlist[15 + ENABLE_ASH_BASH_COMPAT]
*** /home/user/code/rrsdk/bootloader/u-boot/src/board/mcc200/auto_update.c:
<global>[53] #undef debug
<global>[55] #define debug(fmt,args...) printf (fmt ,##args)
<global>[57] #define debug(fmt,args...)
-------------------------------------------------------------------------------
Search complete. Search time = 22.44 seconds.
Assuming your results look similar (they should), there are two multiple target areas in the result. Each file line (the lines starting with ***) is a target to the start of that file. Each individual result is also a target area. If you click on one of the lines that lists a specific match (or put your cursor on it and press enter), it will attempt to jump to the specific line matching the result. If it's not jumping to the specific line correctly it usually means your code has changed since the last time the cscope index file was generated.
I'm not sure how you're using the cscope tool, but you can setup xcscope to auto-index on every change to keep the file up to date, but it really only works for smaller code bases where you can keep the cscope.out files in the top level directory and provide it with a full file list for the files to index. Most people I've talked to use the cscope tool by hand in an external script to manually index/re-index every once in a while and then just interface to the existing cscope database(s) using the emacs tools (mine takes about 4 hours to generate the cscope database for a project that includes the Linux kernel as a sub-part).
I'm looking to streamline my Sweave document creation, and I'd like to hear about people's current setups. I feel like the holy grail goes something like this:
Editing Rnw code on one half of the
screen
Single keybinding compiles
Sweave document and runs pdflatex
View PDF
on the other half of the screen; once
compiled, PDF is refreshed and centered around the portion of the document you're editing
If compilation has errors, replace the PDF with the results of the compilation (e.g. latex errors or Sweave errors)
I am guessing/hoping that the solution is part Emacs/ESS combined with some code for the Emacs profile and/or a nice Makefile. But I would really like to hear about everybody's preferred way of creating Sweave and/or Latex documents.
A few other R users I talked to use a 'one-directory-per-project' setup, and a simple Makefile. As you suspected, that works well with Emacs/ESS.
I tend to just call a simple shell script sweave which I wrote before before 'R CMD Sweave' was added (as I find re-creating or copying the Makefile unappealing, YMMV). I also use Emacs and an auto-refreshing pdf viewer (like okular or kpdf). Emacs23 can preview pdf files directly too but I have yet to switch my work flow to that.
edd#ron:~$ cat bin/sweave
#!/bin/bash -e
function errorexit () {
echo "Error: $1"
exit 1
}
function filetest () {
if [ ! -f $1 ]; then
errorexit "File $1 not found"
fi
return 0
}
if [ "$#" -lt 1 ]; then
errorexit "Need to specify argument file"
fi
BASENAME=$(basename $1 .Rnw)
RNWFILE=$BASENAME.Rnw
filetest $RNWFILE
echo "library(tools); Sweave(\"$RNWFILE\")" \
| R --no-save --no-restore --slave
LATEXFILE=$BASENAME.tex
filetest $LATEXFILE && pdflatex $LATEXFILE
You can do everything that you suggest there with the StatET plugin for Eclipse. That's what I use for Sweave development; it understands both latex and R very well, including syntax highlighting, etc.
You can get it here: http://www.walware.de/goto/statet.
Longhow Lam has written a nice guide: http://www.splusbook.com/Rintro/R_Eclipse_StatET.pdf.
http://www.statalgo.com/?p=93
I use TeXShop on OS X to produce all of my LaTeX and Sweave reports. For me, a new compilation pipeline is as simple as adding a file, called Sweave.engine to ~/Library/TeXShop/Engines/ which contains the following:
#!/usr/bin/env Rscript
args <- commandArgs(T)
fname <- strsplit(args[1],'\\.')[[1]][2]
Sweave(paste(fname,'Rnw',sep='.'))
system(paste('pdflatex',paste(fname,'tex',sep='.')))
Sweave is now a selectable method of compiling a document inside TeXShop. I can set it to be the default for a document by adding the following TeX hash-bang to the top of the file:
% !TEX TS-program = Sweave
Hitting Cmd-T will typeset the document- the pdf automatically pops up in a separate window. TeXShop also incorporates SyncTeX technology so a Cmd-Click in the Rnw source will highlight the corresponding output in the PDF window and a Cmd-Click in the PDF window will highlight the corresponding input in the Rnw source.
TeXShop is mac-only but a great Qt/poppler-based clone, TeXworks, is available for Linux, Windows and Mac and supports many of the same features-- including TeX hash-bangs and SyncTeX. TeXworks has reached a level of maturity where it is included in version 2.8 of the MikTeX package for Windows.
Try RStudio.
I have been a fan of Emacs and TeXShop as mentioned in previous answers.
However, Rstudio is starting to win me over. It is a rapidly-improving dedicated IDE for R. Definitely worth checking out.
I still love doing certain R-only development tasks in the standard R IDE for mac. But for Sweave documents and some associated R devel at the same time, RStudio wins. It works with virtually zero tweaking. I'm not sure about the PDF-related features in the latter half of the original question.
One thing that has saved me some time is the 'auto-insert' mode in emacs. I have it set up so that each time I open a new .rnw file, emacs automatically sets up a basic document template and all I need to do is start writing my report.
Update: I've switched away from auto-insert. Now I use the "template.el" approach.
I use the "one-directory-per-project" and Makefile approach as well. I also include commands to create output in HTML, which can then be converted to OOo and MS Word, using tth. This is important for me since a lot of my collaborators are MS Office users and are resistant to using the PDF output. I learned a lot about how to do this from Frank Harrell's twiki at Vanderbilt.
Personally I use gvim as my editor of choice and running make from there is quite simple, as it is from Emacs.