Skip to content

Commit

Permalink
Add ResultDialog execution menu
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcsgit committed Jun 18, 2024
1 parent 0adb5b6 commit 38fd081
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 48 deletions.
89 changes: 50 additions & 39 deletions src/com/blogspot/kotlinstudy/lognote/AgingTestManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class AgingTestManager private constructor(fileName: String) : PropertiesBase(fi
mActionCombo = ColorComboBox()
mActionCombo.isEditable = false
mActionCombo.renderer = ColorComboBox.ComboBoxRenderer()
mActionCombo.preferredSize = Dimension(200, mNameTF.preferredSize.height)
mActionCombo.preferredSize = Dimension(270, mNameTF.preferredSize.height)
for (action in ACTION_MAP) {
mActionCombo.addItem(action.value)
}
Expand Down Expand Up @@ -689,7 +689,7 @@ class AgingTestManager private constructor(fileName: String) : PropertiesBase(fi

if (SwingUtilities.isRightMouseButton(p0)) {
val point = Point(p0.x, p0.y)
popupMenu = PopUpTable(point)
popupMenu = PopUpTable(point, mTriggerTable.selectedRow)
popupMenu?.show(p0.component, p0.x, p0.y)
}
else {
Expand Down Expand Up @@ -741,7 +741,7 @@ class AgingTestManager private constructor(fileName: String) : PropertiesBase(fi
}
}

internal inner class PopUpTable(point: Point) : JPopupMenu() {
internal inner class PopUpTable(point: Point, row: Int) : JPopupMenu() {
var mStartItem: JMenuItem = JMenuItem(Strings.START)
var mStopItem = JMenuItem(Strings.STOP)
var mAddItem = JMenuItem(Strings.ADD)
Expand All @@ -752,7 +752,10 @@ class AgingTestManager private constructor(fileName: String) : PropertiesBase(fi
var mPrevItem = JMenuItem(Strings.MOVE_UP)
var mNextItem = JMenuItem(Strings.MOVE_DOWN)
var mLastItem = JMenuItem(Strings.MOVE_LAST)
var mResultItem = JMenuItem(Strings.RESULT)
private val mActionHandler = ActionHandler()

val mRow = row

init {
mStartItem.addActionListener(mActionHandler)
Expand All @@ -777,22 +780,31 @@ class AgingTestManager private constructor(fileName: String) : PropertiesBase(fi
add(mNextItem)
mLastItem.addActionListener(mActionHandler)
add(mLastItem)
addSeparator()
mResultItem.addActionListener(mActionHandler)
add(mResultItem)
if (mRow < 0) {
mStartItem.isEnabled = false
mStopItem.isEnabled = false
mCopyItem.isEnabled = false
mEditItem.isEnabled = false
mDeleteItem.isEnabled = false
mFirstItem.isEnabled = false
mPrevItem.isEnabled = false
mNextItem.isEnabled = false
mLastItem.isEnabled = false
mResultItem.isEnabled = false
}
}

internal inner class ActionHandler : ActionListener {
override fun actionPerformed(p0: ActionEvent?) {
val selectedRow = mTriggerTable.selectedRow
if (selectedRow < 0) {
JOptionPane.showMessageDialog(this@TriggerPanel, "${Strings.INVALID_INDEX} \"$selectedRow\"", Strings.ERROR, JOptionPane.ERROR_MESSAGE)
return
}

when (p0?.source) {
mStartItem -> {
startTrigger(selectedRow)
startTrigger(mRow)
}
mStopItem -> {
stopTrigger(selectedRow)
stopTrigger(mRow)
}
mAddItem -> {
showAddDialog()
Expand All @@ -803,85 +815,84 @@ class AgingTestManager private constructor(fileName: String) : PropertiesBase(fi
return
}

val editDialog = EditDialog(MainUI.getInstance(), TRIGGER_COPY, mTriggerList[selectedRow])
val editDialog = EditDialog(MainUI.getInstance(), TRIGGER_COPY, mTriggerList[mRow])
editDialog.setLocationRelativeTo(MainUI.getInstance())
editDialog.isVisible = true
}
mEditItem -> {
if (mTriggerList[selectedRow].mStatus == TriggerStatus.STOPPED) {
if (mTriggerList[mRow].mStatus == TriggerStatus.STOPPED) {
val editDialog =
EditDialog(MainUI.getInstance(), TRIGGER_EDIT, mTriggerList[selectedRow])
EditDialog(MainUI.getInstance(), TRIGGER_EDIT, mTriggerList[mRow])
editDialog.setLocationRelativeTo(MainUI.getInstance())
editDialog.isVisible = true
}
else {
JOptionPane.showMessageDialog(this@TriggerPanel, "${Strings.TRIGGER_CANNOT_EDIT}, ${mTriggerList[selectedRow].mName}", Strings.ERROR, JOptionPane.ERROR_MESSAGE)
JOptionPane.showMessageDialog(this@TriggerPanel, "${Strings.TRIGGER_CANNOT_EDIT}, ${mTriggerList[mRow].mName}", Strings.ERROR, JOptionPane.ERROR_MESSAGE)
}
}
mDeleteItem -> {
if (mTriggerList[selectedRow].mStatus == TriggerStatus.STOPPED) {
if (mTriggerList[mRow].mStatus == TriggerStatus.STOPPED) {
val ret = JOptionPane.showConfirmDialog(
MainUI.getInstance(),
"${Strings.DELETE} ${mTriggerList[selectedRow].mName} ?",
"${Strings.DELETE} ${mTriggerList[mRow].mName} ?",
Strings.DELETE,
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE
)
if (ret == JOptionPane.OK_OPTION) {
mTriggerList.removeAt(selectedRow)
mTriggerList.removeAt(mRow)
saveList()
mTriggerTableModel.fireTableDataChanged()
}
}
else {
JOptionPane.showMessageDialog(this@TriggerPanel, "${Strings.TRIGGER_CANNOT_DELETE}, ${mTriggerList[selectedRow].mName}", Strings.ERROR, JOptionPane.ERROR_MESSAGE)
JOptionPane.showMessageDialog(this@TriggerPanel, "${Strings.TRIGGER_CANNOT_DELETE}, ${mTriggerList[mRow].mName}", Strings.ERROR, JOptionPane.ERROR_MESSAGE)
}

}
mFirstItem -> {
val selectedIdx = mTriggerTable.selectedRow
if (mTriggerList.size > 1 && mTriggerList.size > selectedIdx) {
val trigger = mTriggerList[selectedIdx]
mTriggerList.removeAt(selectedIdx)
if (mTriggerList.size > 1 && mTriggerList.size > mRow) {
val trigger = mTriggerList[mRow]
mTriggerList.removeAt(mRow)
mTriggerList.add(0, trigger)
saveList()
mTriggerTableModel.fireTableDataChanged()
mTriggerTable.setRowSelectionInterval(0, 0)
}
}
mPrevItem -> {
val selectedIdx = mTriggerTable.selectedRow
if (mTriggerList.size > 1 && mTriggerList.size > selectedIdx && selectedIdx > 0) {
val trigger = mTriggerList[selectedIdx]
mTriggerList.removeAt(selectedIdx)
mTriggerList.add(selectedIdx - 1, trigger)
if (mTriggerList.size > 1 && mTriggerList.size > mRow && mRow > 0) {
val trigger = mTriggerList[mRow]
mTriggerList.removeAt(mRow)
mTriggerList.add(mRow - 1, trigger)
saveList()
mTriggerTableModel.fireTableDataChanged()
mTriggerTable.setRowSelectionInterval(selectedIdx - 1, selectedIdx - 1)
mTriggerTable.setRowSelectionInterval(mRow - 1, mRow - 1)
}
}
mNextItem -> {
val selectedIdx = mTriggerTable.selectedRow
if (mTriggerList.size > 1 && mTriggerList.size > selectedIdx && selectedIdx < (mTriggerList.size - 1)) {
val trigger = mTriggerList[selectedIdx]
mTriggerList.removeAt(selectedIdx)
mTriggerList.add(selectedIdx + 1, trigger)
if (mTriggerList.size > 1 && mTriggerList.size > mRow && mRow < (mTriggerList.size - 1)) {
val trigger = mTriggerList[mRow]
mTriggerList.removeAt(mRow)
mTriggerList.add(mRow + 1, trigger)
saveList()
mTriggerTableModel.fireTableDataChanged()
mTriggerTable.setRowSelectionInterval(selectedIdx + 1, selectedIdx + 1)
mTriggerTable.setRowSelectionInterval(mRow + 1, mRow + 1)
}
}
mLastItem -> {
val selectedIdx = mTriggerTable.selectedRow
if (mTriggerList.size > 1 && mTriggerList.size > selectedIdx) {
val trigger = mTriggerList[selectedIdx]
mTriggerList.removeAt(selectedIdx)
if (mTriggerList.size > 1 && mTriggerList.size > mRow) {
val trigger = mTriggerList[mRow]
mTriggerList.removeAt(mRow)
mTriggerList.add(mTriggerList.size, trigger)
saveList()
mTriggerTableModel.fireTableDataChanged()
mTriggerTable.setRowSelectionInterval(mTriggerList.size - 1, mTriggerList.size - 1)
}
}
mResultItem -> {
mTriggerList[mRow].mResultDialog.isVisible = true
}
}
}
}
Expand Down
19 changes: 10 additions & 9 deletions src/com/blogspot/kotlinstudy/lognote/MainUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ class MainUI private constructor() : JFrame(), FormatManager.FormatEventListener
}
}

private val mConfigManager = ConfigManager.getInstance()
init {
val prop = mConfigManager.getItem(ConfigManager.ITEM_LANG)
if (!prop.isNullOrEmpty()) {
Strings.lang = prop.toInt()
} else {
Strings.lang = Strings.EN
}
}

private lateinit var mMenuBar: JMenuBar
private lateinit var mMenuFile: JMenu
private lateinit var mItemFileOpen: JMenuItem
Expand Down Expand Up @@ -166,7 +176,6 @@ class MainUI private constructor() : JFrame(), FormatManager.FormatEventListener
private val mComponentHandler = ComponentHandler()
private val mStatusChangeListener = StatusChangeListener()

private val mConfigManager = ConfigManager.getInstance()
private val mRecentFileManager = RecentFileManager.getInstance()
private val mColorManager = ColorManager.getInstance()
private val mBookmarkManager = BookmarkManager.getInstance()
Expand Down Expand Up @@ -288,14 +297,6 @@ class MainUI private constructor() : JFrame(), FormatManager.FormatEventListener
mRotationStatus = prop.toInt()
}

prop = mConfigManager.getItem(ConfigManager.ITEM_LANG)
if (!prop.isNullOrEmpty()) {
Strings.lang = prop.toInt()
}
else {
Strings.lang = Strings.EN
}

prop = mConfigManager.getItem(ConfigManager.ITEM_SHOW_LOG_STYLE)
mShowLogComboStyle = if (!prop.isNullOrEmpty()) {
FilterComboBox.Mode.fromInt(prop.toInt())
Expand Down
3 changes: 3 additions & 0 deletions src/com/blogspot/kotlinstudy/lognote/Strings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class Strings private constructor() {
private val IDX_TRIGGER_CANNOT_DELETE = idx++
private val IDX_TRIGGER_CANNOT_HIDE = idx++
private val IDX_LOG_TRIGGER = idx++
private val IDX_RESULT = idx++
// private val IDX_ = idx++

val FILE: String
Expand Down Expand Up @@ -455,5 +456,7 @@ class Strings private constructor() {
get() { return currStrings[IDX_TRIGGER_CANNOT_HIDE] }
val LOG_TRIGGER: String
get() { return currStrings[IDX_LOG_TRIGGER] }
val RESULT: String
get() { return currStrings[IDX_RESULT] }
}
}
1 change: 1 addition & 0 deletions src/com/blogspot/kotlinstudy/lognote/StringsEn.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class StringsEn private constructor() {
, "Trigger cannot be deleted while in use"
, "Trigger View cannot be hidden while in use"
, "Log Trigger(Aging Test)"
, "Result"
// , ""
)
}
Expand Down
1 change: 1 addition & 0 deletions src/com/blogspot/kotlinstudy/lognote/StringsKo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class StringsKo private constructor() {
, "사용중에는 트리거를 삭제할 수 없습니다."
, "사용중에는 트리거 뷰를 숨길 수 없습니다."
, "로그 트리거(에이징 테스트)"
, "결과"
// , ""
)
}
Expand Down

0 comments on commit 38fd081

Please sign in to comment.