tags:

views:

84

answers:

1

I think I need to restate my question ...

I want to create a SIMPLE form application that edits certain areas of one very specific text file. Though I have some web development experience, I do not want to create a browser based application. Basically I want to give a Desktop application a try and I am looking for some help to get started including suggestions for the language of choice. The application should run on Mac OS X. Besides there's no restriction: Java, Cocoa, Python, even a some interactive shell script would be ok.

If you are interested in the details, continue to read here, but not that my question is not LaTex specific...: I have an automatically generated report file that contains LaTex Code. Now I want to build a little application that creates a form field for every section and it's header. The document contains only a few hundred lines and the should work the following:

\section{ This is were the header text should go inside the document  }
\normalsize{ This is where the normal text should go}

The header / normalsize pairs occur 5-6 times within the document. All I want is a little GUI that allows user to edit between the curly braces without seeing any TeX code. I know that there's LyX and other WYSIWYG approaches to LaTeX – I do not want to reinvent the wheel. I just want to protect the auto-generated code a litte from users and make it a little more comfortable to them.

EDIT: here's my very first try. I guess I should use PlainDocument instead of directly sending it, but I´ll figure that out, since I got plenty of help from trashgod with the editor / Text Component links. The major problem is to single out the content from \section{} and \normalsize{} stuff. Probably I will some regexp here. I need to get a new text area for every appearance.

import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.FileReader;

import javax.swing.*;

public class basicFrame extends JFrame {
// Declare Variables

    JScrollPane bildlauf = new JScrollPane();
    JTextArea txtfeld = new JTextArea();

    public basicFrame() {
        super();


        // Main window
        setTitle("ReportEditor");
        setBackground(Color.LIGHT_GRAY);

        // components 
        try {
            File datei = new File("report.Rnw");
            FileReader in = new FileReader(datei);
            txtfeld.read(in, datei);
            in.close();

        } catch (Exception e) {
            System.out.println("Error !");
        }

        // setLayout(new GridLayout(2,2));

        // Scroll Shizzle
        bildlauf.getViewport().add(txtfeld, null);
        getContentPane().add(bildlauf, BorderLayout.CENTER);

        //txtfeld.setSize(500,680);
        //add(txtfeld);
        //this.getContentPane().add(txtfeld);

        // close
        addWindowListener(new WindowLauscher());
    }

    // event handlers... 
    protected static final class WindowLauscher extends WindowAdapter {

        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    }

    public static void main(String[] args) {
        //Fesnter erzeugen und anzeigen, die main Sache halt
        basicFrame hf = new basicFrame();
        hf.setSize(500, 700);
        hf.setLocation(100, 100);
        hf.setVisible(true);

    }
}

Thx in advance for any suggestions!

+1  A: 

The TeX on Mac OS X wiki recommends jEdit, which supports plugins. LaTeXTools might be a good start.

Addendum:

I do not want to reinvent the wheel.
All I want to do is create a form application.

Although these goals are somewhat contradictory, you can always parse the file and use a suitable JTextComponent for each editable section. Here's an overview of Using Text Components; see Text Component Features if you want to create your own editor kit, as discussed in Customizing a Text Editor.

Addendum: In addition to the tutorial, you might look at this text field layout example. Also, consider a two-column JTable, which would allow you to cleanly separate your document model from your form view.

Addendum: A few notes on your code.

  1. Class names are usually capitalized, e.g. BasicFrame.

  2. Don't extend JFrame if you're not changing it's behavior; JPanel is a good container for other components, and it can be displayed in a JFrame.

  3. Always buid your GUI on the EDT.

  4. Keep you view and model separate.

trashgod
Thx for the interesting links, but I am looking for a start to build my own "editor". Eh, not editor. All I wanna do is create a form application.
ran2
@ran2: I've elaborated above.
trashgod
thx! the elaborated version really helps. I will work through it. Java seems a good choice too.
ran2
@ran2: Excellent; I've added two additional links.
trashgod
thx again. Particularly the SO thread looks pretty helpful. I just posted my very initial code in the latest edit. Feel free to laugh, it's my second Java "program" – if you count "hello world" as a program.
ran2
@ran2: No laughter; I updated the example code cited above.
trashgod
@trashgod: Thanks for pointing me into the right place within the help.In case you stumble across more helpful links in your library... feel free to post them ;) . What would also be very helpful is some complete code (as opposed to only snippets in the help). Of course it does not have to be specifically my example since I don't want you to my work, but something that helps to understand how files and classes work together over different files – particularly for this MVC thing.Eh, and is there a way download these help files as whole that you keep sending?I am a commuter :)
ran2
@ran2: http://download.oracle.com/javase/tutorial/ is the top, but I don't see download. I think `JTable` for the view and `AbstractTableModel` for the model is the way to go; the tutorial has complete examples.
trashgod
found no downloadable file either.. now I really got something to work through before I get back here... :)
ran2