Package ketUI

Source Code of ketUI.StateList

/*
* Copyright (C) 2011  Alasdair C. Hamilton
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>
*/

package ketUI;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;

import ket.math.*;
import ket.math.Type;
import ket.math.purpose.Word;

/**
* A list of states.
*/

public class StateList extends PurposeList {

  // TODO: Duplicate from Cycle.java.

  public StateList(Document document, JComponent source) {
    super(document, source);
  }

  @Override
  public void populate(Vector<String> all) {
    for (Purpose p : Symbol.GREEK_LETTERS) {
      all.add(p.getName());
    }
    for (Purpose p : Symbol.DEFAULT_OPERAND_SYMBOLS) {
      all.add(p.getName());
    }
    for (Purpose p : Symbol.ROMAN_LETTERS) {
      all.add(p.getName());
    }
  }

  @Override
  protected Purpose seek(String text) {
    if (text==null) return null;
    for (Purpose p : Symbol.GREEK_LETTERS) {
      if (text.equals(p.getName())) {
        return p;
      }
    }
    for (Purpose p : Symbol.DEFAULT_OPERAND_SYMBOLS) {
      if (text.equals(p.getName())) {
        return p;
      }
    }
    for (Purpose p : Symbol.ROMAN_LETTERS) {
      if (text.equals(p.getName())) {
        return p;
      }
    }
    return null;
  }

  @Override
  public void insert(Purpose purpose) {
    getDocument().getSelection().replace(new Token((State) purpose));
  }

  @Override
  protected Purpose create(String name) {
    return new Word(name);
  }

}
TOP

Related Classes of ketUI.StateList

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.