Package com.cburch.logisim.proj

Examples of com.cburch.logisim.proj.Project


    }
  }
 
  private class MyListener implements ActionListener {
    public void actionPerformed(ActionEvent event) {
      Project dest = null;
      String name = null;
      boolean twoInputs = false;
      boolean useNands = false;
      boolean replace = false;
     
      boolean ok = false;
      while (!ok) {
        DialogPanel dlog = new DialogPanel();
        int action = JOptionPane.showConfirmDialog(parent,
            dlog, Strings.get("buildDialogTitle"), JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);
        if (action != JOptionPane.OK_OPTION) return;
               
        ProjectItem projectItem = (ProjectItem) dlog.project.getSelectedItem();
        if (projectItem == null) {
          JOptionPane.showMessageDialog(parent, Strings.get("buildNeedProjectError"),
              Strings.get("buildDialogErrorTitle"), JOptionPane.ERROR_MESSAGE);
          continue;
        }
        dest = projectItem.project;
       
        name = dlog.name.getText().trim();
        if (name.equals("")) {
          JOptionPane.showMessageDialog(parent, Strings.get("buildNeedCircuitError"),
              Strings.get("buildDialogErrorTitle"), JOptionPane.ERROR_MESSAGE);
          continue;
        }
       
        if (dest.getLogisimFile().getCircuit(name) != null) {
          int choice = JOptionPane.showConfirmDialog(parent,
              StringUtil.format(Strings.get("buildConfirmReplaceMessage"), name),
              Strings.get("buildConfirmReplaceTitle"), JOptionPane.YES_NO_OPTION);
          if (choice != JOptionPane.YES_OPTION) {
            continue;
View Full Code Here


        remove.setEnabled(false);
        attrTable.setAttrTableModel(null);
      } else {
        remove.setEnabled(true);
        Tool tool = model.getTool(row);
        Project proj = getProject();
        AttrTableModel model;
        if (tool.getAttributeSet() == null) {
          model = null;
        } else {
          model = new AttrTableToolModel(proj, tool);
View Full Code Here

    canvas.addPropertyChangeListener(Canvas.MODEL_PROPERTY, this);
  }
 
  @Override
  public void computeEnabled() {
    Project proj = canvas.getProject();
    Circuit circ = canvas.getCircuit();
    Selection sel = canvas.getSelection();
    boolean selEmpty = sel.isEmpty();
    boolean canChange = proj.getLogisimFile().contains(circ);
    boolean clipExists = !Clipboard.isEmpty();
    boolean selHasRemovable = false;
    for (CanvasObject o : sel.getSelected()) {
      if (!(o instanceof AppearanceElement)) {
        selHasRemovable = true;
View Full Code Here

    add(lowerBottom);
    addSeparator();
    add(addCtrl);
    add(remCtrl);
   
    Project proj = menubar.getProject();
    if (proj != null) {
      proj.addProjectListener(myListener);
      undo.addActionListener(myListener);
    }

    undo.setEnabled(false);
    menubar.registerItem(LogisimMenuBar.CUT, cut);
View Full Code Here

import com.cburch.logisim.util.StringUtil;

class MenuEdit extends Menu {
  private class MyListener implements ProjectListener, ActionListener {
    public void projectChanged(ProjectEvent e) {
      Project proj = menubar.getProject();
      Action last = proj == null ? null : proj.getLastAction();
      if (last == null) {
        undo.setText(Strings.get("editCantUndoItem"));
        undo.setEnabled(false);
      } else {
        undo.setText(StringUtil.format(Strings.get("editUndoItem"),
View Full Code Here

      }
    }

    public void actionPerformed(ActionEvent e) {
      Object src = e.getSource();
      Project proj = menubar.getProject();
      if (src == undo) {
        if (proj != null) proj.undoAction();
      }
    }
View Full Code Here

  private class MyListener implements ActionListener, SimulatorListener,
      ChangeListener {
    public void actionPerformed(ActionEvent e) {
      Object src = e.getSource();
      Project proj = menubar.getProject();
      Simulator sim = proj == null ? null : proj.getSimulator();
      if (src == run || src == LogisimMenuBar.SIMULATE_ENABLE) {
        if (sim != null) {
          sim.setIsRunning(!sim.isRunning());
          proj.repaintCanvas();
        }
      } else if (src == reset) {
        if (sim != null) sim.requestReset();
      } else if (src == step || src == LogisimMenuBar.SIMULATE_STEP) {
        if (sim != null) sim.step();
View Full Code Here

          if (p != null) {
            Caret caret = p.getPokeCaret(event);
            setPokedComponent(circ, c, caret);
            AttributeSet attrs = c.getAttributeSet();
            if (attrs != null && attrs.getAttributes().size() > 0) {
              Project proj = canvas.getProject();
              proj.getFrame().viewComponentAttributes(circ, c);
            }
          }
        }
      }
    }
View Full Code Here

    return true;
  }

  @Override
  public void draw(Canvas canvas, ComponentDrawContext context) {
    Project proj = canvas.getProject();
    int dx = curDx;
    int dy = curDy;
    if (state == MOVING) {
      proj.getSelection().drawGhostsShifted(context, dx, dy);

      MoveGesture gesture = moveGesture;
      if (gesture != null && drawConnections && (dx != 0 || dy != 0)) {
        MoveResult result = gesture.findResult(dx, dy);
        if (result != null) {
View Full Code Here

    canvas.requestFocusInWindow();
  }

  @Override
  public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
    Project proj = canvas.getProject();
    Selection sel = proj.getSelection();
    Circuit circuit = canvas.getCircuit();
    start = Location.create(e.getX(), e.getY());
    curDx = 0;
    curDy = 0;
    moveGesture = null;

    // if the user clicks into the selection,
    // selection is being modified
    Collection<Component> in_sel = sel.getComponentsContaining(start, g);
    if (!in_sel.isEmpty()) {
      if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
        setState(proj, MOVING);
        proj.repaintCanvas();
        return;
      } else {
        Action act = SelectionActions.drop(sel, in_sel);
        if (act != null) {
          proj.doAction(act);
        }
      }
    }

    // if the user clicks into a component outside selection, user
    // wants to add/reset selection
    Collection<Component> clicked = circuit.getAllContaining(start, g);
    if (!clicked.isEmpty()) {
      if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
        if (sel.getComponentsContaining(start).isEmpty()) {
          Action act = SelectionActions.dropAll(sel);
          if (act != null) {
            proj.doAction(act);
          }
        }
      }
      for (Component comp : clicked) {
        if (!in_sel.contains(comp)) {
          sel.add(comp);
        }
      }
      setState(proj, MOVING);
      proj.repaintCanvas();
      return;
    }

    // The user clicked on the background. This is a rectangular
    // selection (maybe with the shift key down).
    if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
      Action act = SelectionActions.dropAll(sel);
      if (act != null) {
        proj.doAction(act);
      }
    }
    setState(proj, RECT_SELECT);
    proj.repaintCanvas();
  }
View Full Code Here

TOP

Related Classes of com.cburch.logisim.proj.Project

Copyright © 2018 www.massapicom. 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.