SnakeDoc / superD_legacy

A file duplication utility in pure java.
Apache License 2.0
1 stars 3 forks source link

Add User Interface (CLI or GUI) #9

Closed SnakeDoc closed 11 years ago

SnakeDoc commented 11 years ago

Probably lean towards the CLI for now since it makes the program more reusable in other program and later projects. the jcurses library looks very nice and we could do something simple and have a couple columns and use selectable checkboxes or soemthing.

Issue needs research.

SnakeDoc commented 11 years ago

OK so I checked into JCurses as a CLI/GUI option... it's pretty darn nice, but there's some caveats we may not be able to sacrifice.

Generally all Linux distro's include the curses library as standard, so we'd have full support there. OSX I'm not sure on (no mac for me to test on), and the real kicker is windows. So windows does not support curses windowing library, so jcurses has two .dll's you can bundle in the jar to take care of that... but there's a 32 bit and a 64 bit one... and it's too stupid to figure out it should use the 64 bit one on a 64 bit system IF the 32 bit dll is also present in the directory. So basically this means we'd have to have either some script run outside of java and determine if we were 64 bit windows and then launch the directory that had the correct dll file... eh... or we can release a 64 bit and a 32 bit version... eh... also, it won't run on 64 bit JVM, so even on a 64 bit system you have to have the 32 bit JVM installed... eh...

all these add up to ... i'm not sure...

Try t out though,

1) copy the source (below) and paste to file and save to some directory.

2)Download the JCurses lib from: http://sourceforge.net/projects/javacurses/files/latest/download

3) Unpack jcurses and copy the jcurses.jar and either the libjcurses.dll OR libjcurses64.dll to the directory where you saved the source file. This depends on which OS type you're on for windows.

4) Compile by doing: javac -classpath .;jcurses.jar Curses_Demo.java

5) Run by doing: java -classpath .;jcurses.jar Curses_Demo

it's a real basic demo, but pretty neat.

here's the source: Curses_Demo.java

    import jcurses.system.*;
    import jcurses.widgets.*;
    import jcurses.util.*;
    import jcurses.event.*;

    /**
     * JCurses demo found at: http://www.rgagnon.com/javadetails/java-0047.html
     *
     */

    public class Curses_Demo extends Window implements ItemListener, ActionListener,
        ValueChangedListener, WindowListener, WidgetsConstants {
      static Curses_Demo window = null;
      static TextField textfield = null;
      static Button button = null;

      public Curses_Demo(int width, int height) {
        super(width, height, true, "JCurses Test");
      }

      public static void main(String[] args) throws Exception {
        window = new Curses_Demo(30, 20);
        window.init();
      }

      public void init() {
        DefaultLayoutManager mgr = new DefaultLayoutManager();
        mgr.bindToContainer(window.getRootPanel());
        mgr.addWidget(
        new Label("Hello World!",
                      new CharColor(CharColor.WHITE, CharColor.GREEN)),
                      0, 0, 20, 10,
                      WidgetsConstants.ALIGNMENT_CENTER,
                      WidgetsConstants.ALIGNMENT_CENTER);

        textfield = new TextField(10);
        mgr.addWidget(textfield, 0, 0, 20, 20,
            WidgetsConstants.ALIGNMENT_CENTER,
            WidgetsConstants.ALIGNMENT_CENTER);

        button = new Button("Quit");
        mgr.addWidget(button, 0, 0, 20, 30,
            WidgetsConstants.ALIGNMENT_CENTER,
            WidgetsConstants.ALIGNMENT_CENTER);

        button.setShortCut('q');
        button.addListener(this);
        window.addListener((WindowListener) this);
        window.show();
      }

      public void actionPerformed(ActionEvent event) {
        Widget w = event.getSource();
        if (w == button) {
          new Message("HowTo", "You are about to quit", "OK").show();
          window.close();
        }
      }

      public void stateChanged(ItemEvent e) {  }

      public void valueChanged(ValueChangedEvent e) {  }

      public void windowChanged(WindowEvent event) {
        if (event.getType() == WindowEvent.CLOSING) {
          event.getSourceWindow().close();
          // Toolkit.clearScreen(new CharColor(CharColor.WHITE, CharColor.BLACK));
        }
      }
    }
tracehagan commented 11 years ago

Built Deleter class to build GUI. It's a start. Closing this for now

commit 12cb8b06cbed9cf02fec283bd81d1ed0ffdeb57f

SnakeDoc commented 11 years ago

could you copy/paste the commit + hash that closed this issue into your last comment? This way we can see which commit/changes closed which ticket...