Skip to content
Permalink
Browse files

Add AddEditMast frame

  • Loading branch information...
pete_ pete_
pete_ authored and pete_ committed Jun 4, 2019
1 parent b46ff77 commit 8e49baef3fd3b6d33262ccd25024f6de99a0ea44
@@ -115,6 +115,7 @@
private EditPortalFrame _editPortalFrame;
private EditCircuitPaths _editPathsFrame;
private EditPortalDirection _editDirectionFrame;
private EditSignalFrame _editSignalFrame;

// list of icons making a circuit (OBlock) - used by editing frames to indicate block(s) being worked on
private ArrayList<Positionable> _circuitIcons; // Dark Blue
@@ -218,6 +219,14 @@ private void makeCircuitMenu() {
}
editPortalDirection("editDirectionItem", true);
});
editItem = new JMenuItem(Bundle.getMessage("editSignalItem"));
_circuitMenu.add(editItem);
editItem.addActionListener((ActionEvent event) -> {
if (_cbFrame !=null) {
_cbFrame.dispose();
}
editSignalFrame("editSignalItem", true);
});
_todoMenu = new JMenu(Bundle.getMessage("circuitErrorsItem"));
_circuitMenu.add(_todoMenu);
makeToDoMenu();
@@ -526,6 +535,29 @@ protected void editPortalDirection(String title, boolean fromMenu) {
}
}

protected void editSignalFrame(String title, boolean fromMenu) {
if (editingOK()) {
if (fromMenu) {
editCircuitDialog(title);
}
if (_currentBlock != null) {
_circuitIcons = _circuitMap.get(_currentBlock);
// check icons to be indicator type
if (!iconsConverted(_currentBlock)) {
queryConvertIcons(_currentBlock);
}
_editor.setSelectionGroup(makeSelectionGroup(_currentBlock, true));
_editor.disableMenus();
TargetPane targetPane = (TargetPane) _editor.getTargetPanel();
targetPane.setSelectGroupColor(_editGroupColor);
targetPane.setHighlightColor(_highlightColor);
_editSignalFrame = new EditSignalFrame(Bundle.getMessage("OpenSignalsTitle"), this, _currentBlock);
} else if (!fromMenu) {
selectPrompt();
}
}
}

protected void editCircuitPaths(String title, boolean fromMenu) {
if (editingOK()) {
if (fromMenu) {
@@ -564,6 +596,8 @@ protected void hidePortalIcons() {
_editPathsFrame.clearListSelection();
} else if (_editDirectionFrame != null) {
_editDirectionFrame.clearListSelection();
} else if (_editSignalFrame != null) {
_editSignalFrame.clearListSelection();
} else {
Iterator<PortalIcon> it = _portalIconMap.values().iterator();
while (it.hasNext()) {
@@ -573,7 +607,8 @@ protected void hidePortalIcons() {
}

private boolean editingOK() {
if (_editCircuitFrame != null || _editPathsFrame != null || _editPortalFrame != null || _editDirectionFrame != null) {
if (_editCircuitFrame != null || _editPathsFrame != null || _editPortalFrame != null ||
_editDirectionFrame != null || _editSignalFrame != null) {
// Already editing a circuit, ask for completion of that edit
JOptionPane.showMessageDialog(_editCircuitFrame,
Bundle.getMessage("AlreadyEditing"), Bundle.getMessage("ErrorTitle"),
@@ -590,6 +625,9 @@ private boolean editingOK() {
} else if (_editDirectionFrame != null) {
_editDirectionFrame.toFront();
_editDirectionFrame.setVisible(true);
} else if (_editSignalFrame != null) {
_editSignalFrame.toFront();
_editSignalFrame.setVisible(true);
}
return false;
}
@@ -798,11 +836,6 @@ private void setPortalsPositionable(OBlock block, boolean set) {
}

////////////////////////// Closing Editing Frames //////////////////////////
protected void closeCircuitFrame() {
_editCircuitFrame = null;
closeCircuitBuilder();
}

/**
* Edit frame closing, set block's icons
* @param block OBlock to set icon selections into data maps
@@ -852,6 +885,11 @@ protected String setIconGroup(OBlock block) {
return null;
}

protected void closeCircuitFrame() {
_editCircuitFrame = null;
closeCircuitBuilder();
}

protected void closePathFrame(OBlock block) {
if (_currentBlock != null) {
_currentBlock.deAllocate(null);
@@ -874,6 +912,12 @@ protected void closePortalDirection(OBlock block) {
closeCircuitBuilder();
}

protected void closeEditSignalFrame(OBlock block) {
setPortalsPositionable(block, false);
_editSignalFrame = null;
closeCircuitBuilder();
}

private void closeCircuitBuilder() {
_currentBlock = null;
_circuitIcons = null;
@@ -1504,10 +1548,8 @@ private boolean okToAdd(Positionable pos, OBlock editBlock) {
*/
protected boolean saveSelectionGroup(ArrayList<Positionable> selectionGroup) {
_saveSelectionGroup = selectionGroup;
return _editCircuitFrame != null
|| _editPortalFrame != null
|| _editPathsFrame != null
|| _editDirectionFrame != null;
return _editCircuitFrame != null || _editPortalFrame != null || _editPathsFrame != null
|| _editDirectionFrame != null || _editSignalFrame != null;
}

/**
@@ -1531,6 +1573,9 @@ protected boolean doMousePressed(MouseEvent event, Positionable selection) {
} else if (_editDirectionFrame != null) {
_editDirectionFrame.toFront();
_editor.setSelectionGroup(_saveSelectionGroup);
} else if (_editSignalFrame != null) {
_editSignalFrame.toFront();
_editor.setSelectionGroup(_saveSelectionGroup);
} else {
return false;
}
@@ -1540,8 +1585,12 @@ protected boolean doMousePressed(MouseEvent event, Positionable selection) {
public boolean doMouseReleased(Positionable selection, boolean dragging) {
if (_editCircuitFrame != null || _editPathsFrame != null || _editDirectionFrame != null) {
return true;
} else if (_editPortalFrame != null) {
} else if (_editPortalFrame != null || _editSignalFrame != null) {
if (selection instanceof PortalIcon && _circuitIcons.contains(selection)) {
if (_editSignalFrame != null) {
_editSignalFrame.setSelected((PortalIcon)selection);
return true;
}
if (dragging) {
_editPortalFrame.checkPortalIconForUpdate((PortalIcon) selection, true);
} else {
@@ -1555,7 +1604,8 @@ public boolean doMouseReleased(Positionable selection, boolean dragging) {

protected boolean doMouseClicked(List<Positionable> selections, MouseEvent event) {
if (_editCircuitFrame != null || _editPathsFrame != null
|| _editPortalFrame != null || _editDirectionFrame != null) {
|| _editPortalFrame != null || _editDirectionFrame != null
|| _editSignalFrame != null) {
if (selections != null && selections.size() > 0) {
ArrayList<Positionable> tracks = new ArrayList<>();
Iterator<Positionable> iter = selections.iterator();
@@ -1637,7 +1687,7 @@ private Positionable getSelection(List<Positionable> tracks) {
* @return true to prevent dragging; false otherwise
*/
public boolean doMouseDragged(Positionable selection, MouseEvent event) {
if (_editCircuitFrame != null || _editPathsFrame != null) {
if (_editCircuitFrame != null || _editPathsFrame != null || _editSignalFrame != null) {
return true; // no dragging when editing
}
if (selection instanceof PortalIcon) {
@@ -1710,6 +1760,15 @@ private void handleSelection(Positionable selection, MouseEvent event) {
_editDirectionFrame.setPortalIcon(null, false);
}
_editDirectionFrame.toFront();
} else if (_editSignalFrame != null) {
if (log.isDebugEnabled()) {
log.debug("selection= " + (selection == null ? "null"
: selection.getClass().getName()));
}
if (selection instanceof PortalIcon) {
_editSignalFrame.setSelected((PortalIcon)selection);
}
_editSignalFrame.toFront();
}
}

@@ -1747,7 +1806,7 @@ private void handleSelection(Positionable selection, MouseEvent event) {
panel.add(makeButton("editPortalsItem", PORTAL));
panel.add(makeButton("editCircuitPathsItem", OPATH));
panel.add(makeButton("editDirectionItem", ARROW));
// panel.add(makeButton("editSignalItem", SIGNAL));
panel.add(makeButton("editSignalItem", SIGNAL));
b.setSelected(true);
panel0.add(panel);

@@ -1775,7 +1834,7 @@ private void handleSelection(Positionable selection, MouseEvent event) {
} else if (_which == ARROW) {
editPortalDirection("editDirectionItem", false);
} else if (_which == SIGNAL) {
//editSignal("editSignalItem", false);
editSignalFrame("editSignalItem", false);
}
}
});
@@ -14,6 +14,7 @@ editCircuitItem = Edit Circuit OBlock
OpenCircuitItem = Edit "{0}" Track
OpenPortalTitle = Edit "{0}" Portals
OpenDirectionTitle= Edit "{0}" Portal Direction Arrows
OpenSignalsTitle= Edit "{0}" Signal Masts
OpenPortalTitle2= Add/Edit Portals between "{0}" and "{1}"
OpenPathTitle = Add/Edit "{0}" Paths
noCircuitsItem = No Detector Circuits are defined
@@ -113,6 +114,7 @@ blockName = Circuit Name:
portalName = Portal Name
makePortal = Make Portal
PortalTitle = Portals into and out of circuit {0}
SignalTitle = Signal masts protecting block {0}
selectPortal = To make an icon for a Portal in the list, select it from the list,
dragIcon = then drag the icon below to its position between the circuits on the panel.
portalIconPosition=A portal icon must touch both Blocks of the Portal\nDrag the highlighted icon to a position straddling the two block circuits.

0 comments on commit 8e49bae

Please sign in to comment.
You can’t perform that action at this time.