File: Interface.java

package info (click to toggle)
thepeg 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 9,312 kB
  • ctags: 11,509
  • sloc: cpp: 57,129; sh: 11,315; java: 3,212; lisp: 1,402; makefile: 830; ansic: 58; perl: 3
file content (116 lines) | stat: -rw-r--r-- 2,856 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package ThePEG;

import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.text.html.HTMLDocument;

public class Interface extends JDialog {

  SetupThePEG owner;
  String object;
  String objectName;
  String interfaceName;
  String description = "";
  boolean readonly;

  //  JTextArea info = new JTextArea(new HTMLDocument());
  JEditorPane info = new JEditorPane();

  public Interface(SetupThePEG own, ObjectFrame obj, LinkedList input) {
    super(obj);
    owner = own;
    object = obj.getFullName();
    objectName = obj.getName();
    info.addHyperlinkListener(obj);
  }

  protected boolean setup(LinkedList input) {
    String s = (String)input.remove(0);
    if ( input.size() > 0 ) interfaceName = (String)input.remove(0);
    else return false;
    while ( input.size() > 0 && ( s = (String)input.remove(0) ) != null &&
	    !s.equals("-*-mutable-*-") && !s.equals("-*-readonly-*-") )
      description += s + " ";
    if ( s.equals("-*-mutable-*-") ) readonly = false;
    else if ( s.equals("-*-readonly-*-") ) readonly = true;
    else return false;
    return true;
  }

  protected boolean reset() {
    return setup(owner.exec("fulldescribe " + object + ":" + interfaceName));
  }

  protected void setupFrame(int width, int height) {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    owner.setLocation(this);
    setSize(width, height);
    setVisible(true);
  }

  public void setTitle(String type) {
    super.setTitle("ThePEG " + type + " " + getObjectName() + ":" + getName());
  }
    
  protected JScrollPane getDescriptionArea() {
    info.setContentType("text/html");
    info.setText("<font size=-1>" + ObjectFrame.htmlFormat(description) +
		 "</font>");
    info.setEditable(false);
    info.setCaretPosition(0);
    return new JScrollPane(info);
  }

  protected boolean isReadonly() {
    return readonly;
  }

  protected void exec(String cmd) {
    owner.action(cmd);
  }

  protected void setValue(String val) {
    exec("set " + getObject() + ":" + getName() + " " + val);
    reset();
  }

  protected void setValue(int indx, String val) {
    exec("set " + getObject() + ":" + getName() + " [" +
	 Integer.toString(indx) + "] " + val);
    reset();
  }

  protected void insert(int indx, String val) {
    exec("insert " + getObject() + ":" + getName() + "[" +
	 Long.toString(indx) + "] " + val);
    reset();    
  }

  protected void erase(int indx) {
    exec("erase " + getObject() + ":" + getName() + "[" +
	 Long.toString(indx) + "] ");
    reset();    
  }

  public String getName() {
    return interfaceName;
  }

  public String getObject() {
    return object;
  }

  public String getObjectName() {
    return objectName;
  }

  public void dispose() {
    owner.removeLocation(this);
    super.dispose();
  }

  public static void classcheck() {}

}