本文整理汇总了Java中com.cburch.logisim.proj.Project.doAction方法的典型用法代码示例。如果您正苦于以下问题:Java Project.doAction方法的具体用法?Java Project.doAction怎么用?Java Project.doAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.cburch.logisim.proj.Project
的用法示例。
在下文中一共展示了Project.doAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doLoadBuiltinLibrary
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
public static void doLoadBuiltinLibrary(Project proj) {
LogisimFile file = proj.getLogisimFile();
List<Library> baseBuilt = file.getLoader().getBuiltin().getLibraries();
ArrayList<Library> builtins = new ArrayList<Library>(baseBuilt);
builtins.removeAll(file.getLibraries());
if (builtins.isEmpty()) {
JOptionPane.showMessageDialog(proj.getFrame(), Strings.get("loadBuiltinNoneError"),
Strings.get("loadBuiltinErrorTitle"), JOptionPane.INFORMATION_MESSAGE);
return;
}
LibraryJList list = new LibraryJList(builtins);
JScrollPane listPane = new JScrollPane(list);
int action = JOptionPane.showConfirmDialog(proj.getFrame(), listPane, Strings.get("loadBuiltinDialogTitle"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (action == JOptionPane.OK_OPTION) {
Library[] libs = list.getSelectedLibraries();
if (libs != null)
proj.doAction(LogisimFileActions.loadLibraries(libs));
}
}
示例2: doUnloadLibraries
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
public static void doUnloadLibraries(Project proj) {
LogisimFile file = proj.getLogisimFile();
ArrayList<Library> canUnload = new ArrayList<Library>();
for (Library lib : file.getLibraries()) {
String message = file.getUnloadLibraryMessage(lib);
if (message == null)
canUnload.add(lib);
}
if (canUnload.isEmpty()) {
JOptionPane.showMessageDialog(proj.getFrame(), Strings.get("unloadNoneError"),
Strings.get("unloadErrorTitle"), JOptionPane.INFORMATION_MESSAGE);
return;
}
LibraryJList list = new LibraryJList(canUnload);
JScrollPane listPane = new JScrollPane(list);
int action = JOptionPane.showConfirmDialog(proj.getFrame(), listPane, Strings.get("unloadLibrariesDialogTitle"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (action == JOptionPane.OK_OPTION) {
Library[] libs = list.getSelectedLibraries();
if (libs != null)
proj.doAction(LogisimFileActions.unloadLibraries(libs));
}
}
示例3: paste
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void paste() {
Project proj = frame.getProject();
Selection sel = frame.getCanvas().getSelection();
selectSelectTool(proj);
Action action = SelectionActions.pasteMaybe(proj, sel);
if (action != null) {
proj.doAction(action);
}
}
示例4: actionPerformed
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
Project proj = frame.getProject();
Circuit cur = proj == null ? null : proj.getCurrentCircuit();
if (src == LogisimMenuBar.ADD_CIRCUIT) {
ProjectCircuitActions.doAddCircuit(proj);
} else if (src == LogisimMenuBar.MOVE_CIRCUIT_UP) {
ProjectCircuitActions.doMoveCircuit(proj, cur, -1);
} else if (src == LogisimMenuBar.MOVE_CIRCUIT_DOWN) {
ProjectCircuitActions.doMoveCircuit(proj, cur, 1);
} else if (src == LogisimMenuBar.SET_MAIN_CIRCUIT) {
ProjectCircuitActions.doSetAsMainCircuit(proj, cur);
} else if (src == LogisimMenuBar.REMOVE_CIRCUIT) {
ProjectCircuitActions.doRemoveCircuit(proj, cur);
} else if (src == LogisimMenuBar.EDIT_LAYOUT) {
frame.setEditorView(Frame.EDIT_LAYOUT);
} else if (src == LogisimMenuBar.EDIT_APPEARANCE) {
frame.setEditorView(Frame.EDIT_APPEARANCE);
} else if (src == LogisimMenuBar.VIEW_TOOLBOX) {
frame.setExplorerView(Frame.VIEW_TOOLBOX);
} else if (src == LogisimMenuBar.VIEW_SIMULATION) {
frame.setExplorerView(Frame.VIEW_SIMULATION);
} else if (src == LogisimMenuBar.REVERT_APPEARANCE) {
proj.doAction(new RevertAppearanceAction(cur));
} else if (src == LogisimMenuBar.ANALYZE_CIRCUIT) {
ProjectCircuitActions.doAnalyze(proj, cur);
} else if (src == LogisimMenuBar.CIRCUIT_STATS) {
StatisticsDialog.show(frame, proj.getLogisimFile(), cur);
}
}
示例5: doAddCircuit
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
public static void doAddCircuit(Project proj) {
String name = promptForCircuitName(proj.getFrame(), proj.getLogisimFile(), "");
if (name != null) {
Circuit circuit = new Circuit(name);
proj.doAction(LogisimFileActions.addCircuit(circuit));
proj.setCurrentCircuit(circuit);
}
}
示例6: doMoveCircuit
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
public static void doMoveCircuit(Project proj, Circuit cur, int delta) {
AddTool tool = proj.getLogisimFile().getAddTool(cur);
if (tool != null) {
int oldPos = proj.getLogisimFile().getCircuits().indexOf(cur);
int newPos = oldPos + delta;
int toolsCount = proj.getLogisimFile().getTools().size();
if (newPos >= 0 && newPos < toolsCount) {
proj.doAction(LogisimFileActions.moveCircuit(tool, newPos));
}
}
}
示例7: doRemoveCircuit
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
public static void doRemoveCircuit(Project proj, Circuit circuit) {
if (proj.getLogisimFile().getTools().size() == 1) {
JOptionPane.showMessageDialog(proj.getFrame(), Strings.get("circuitRemoveLastError"),
Strings.get("circuitRemoveErrorTitle"), JOptionPane.ERROR_MESSAGE);
} else if (!proj.getDependencies().canRemove(circuit)) {
JOptionPane.showMessageDialog(proj.getFrame(), Strings.get("circuitRemoveUsedError"),
Strings.get("circuitRemoveErrorTitle"), JOptionPane.ERROR_MESSAGE);
} else {
proj.doAction(LogisimFileActions.removeCircuit(circuit));
}
}
示例8: doLoadLogisimLibrary
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
public static void doLoadLogisimLibrary(Project proj) {
Loader loader = proj.getLogisimFile().getLoader();
JFileChooser chooser = loader.createChooser();
chooser.setDialogTitle(Strings.get("loadLogisimDialogTitle"));
chooser.setFileFilter(Loader.LOGISIM_FILTER);
int check = chooser.showOpenDialog(proj.getFrame());
if (check == JFileChooser.APPROVE_OPTION) {
File f = chooser.getSelectedFile();
Library lib = loader.loadLogisimLibrary(f);
if (lib != null) {
proj.doAction(LogisimFileActions.loadLibrary(lib));
}
}
}
示例9: doUnloadLibrary
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
public static void doUnloadLibrary(Project proj, Library lib) {
String message = proj.getLogisimFile().getUnloadLibraryMessage(lib);
if (message != null) {
JOptionPane.showMessageDialog(proj.getFrame(), message, Strings.get("unloadErrorTitle"),
JOptionPane.ERROR_MESSAGE);
} else {
proj.doAction(LogisimFileActions.unloadLibrary(lib));
}
}
示例10: keyPressed
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void keyPressed(Canvas canvas, KeyEvent event) {
processKeyEvent(canvas, event, KeyConfigurationEvent.KEY_PRESSED);
if (!event.isConsumed() && event.getModifiersEx() == 0) {
switch (event.getKeyCode()) {
case KeyEvent.VK_UP:
setFacing(canvas, Direction.NORTH);
break;
case KeyEvent.VK_DOWN:
setFacing(canvas, Direction.SOUTH);
break;
case KeyEvent.VK_LEFT:
setFacing(canvas, Direction.WEST);
break;
case KeyEvent.VK_RIGHT:
setFacing(canvas, Direction.EAST);
break;
case KeyEvent.VK_BACK_SPACE:
if (lastAddition != null && canvas.getProject().getLastAction() == lastAddition) {
canvas.getProject().undoAction();
lastAddition = null;
}
break;
case KeyEvent.VK_DELETE:
case KeyEvent.VK_ESCAPE:
if (state == SHOW_GHOST) {
Project proj = canvas.getProject();
Tool next = determineNext(proj);
if (next != null) {
proj.setTool(next);
Action act = SelectionActions.dropAll(canvas.getSelection());
if (act != null) {
proj.doAction(act);
}
}
}
break;
}
}
}
示例11: mouseReleased
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void mouseReleased(Canvas canvas, Graphics g, MouseEvent e) {
Component added = null;
if (state == SHOW_ADD) {
Circuit circ = canvas.getCircuit();
if (!canvas.getProject().getLogisimFile().contains(circ))
return;
if (shouldSnap)
Canvas.snapToGrid(e);
moveTo(canvas, g, e.getX(), e.getY());
Location loc = Location.create(e.getX(), e.getY());
AttributeSet attrsCopy = (AttributeSet) attrs.clone();
ComponentFactory source = getFactory();
if (source == null)
return;
Component c = source.createComponent(loc, attrsCopy);
if (circ.hasConflict(c)) {
canvas.setErrorMessage(Strings.getter("exclusiveError"));
return;
}
Bounds bds = c.getBounds(g);
if (bds.getX() < 0 || bds.getY() < 0) {
canvas.setErrorMessage(Strings.getter("negativeCoordError"));
return;
}
try {
CircuitMutation mutation = new CircuitMutation(circ);
mutation.add(c);
Action action = mutation.toAction(Strings.getter("addComponentAction", factory.getDisplayGetter()));
canvas.getProject().doAction(action);
lastAddition = action;
added = c;
} catch (CircuitException ex) {
JOptionPane.showMessageDialog(canvas.getProject().getFrame(), ex.getMessage());
}
setState(canvas, SHOW_GHOST);
} else if (state == SHOW_ADD_NO) {
setState(canvas, SHOW_NONE);
}
Project proj = canvas.getProject();
Tool next = determineNext(proj);
if (next != null) {
proj.setTool(next);
Action act = SelectionActions.dropAll(canvas.getSelection());
if (act != null) {
proj.doAction(act);
}
if (added != null)
canvas.getSelection().add(added);
}
}
示例12: copy
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void copy() {
Project proj = frame.getProject();
Selection sel = frame.getCanvas().getSelection();
proj.doAction(SelectionActions.copy(sel));
}
示例13: cut
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void cut() {
Project proj = frame.getProject();
Selection sel = frame.getCanvas().getSelection();
proj.doAction(SelectionActions.cut(sel));
}
示例14: delete
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void delete() {
Project proj = frame.getProject();
Selection sel = frame.getCanvas().getSelection();
proj.doAction(SelectionActions.clear(sel));
}
示例15: duplicate
import com.cburch.logisim.proj.Project; //导入方法依赖的package包/类
@Override
public void duplicate() {
Project proj = frame.getProject();
Selection sel = frame.getCanvas().getSelection();
proj.doAction(SelectionActions.duplicate(sel));
}