Code Duplication    Length = 43-44 lines in 2 locations

client/osci/dialog/FleetsAnalysisDlg.py 1 location

@@ 113-156 (lines=44) @@
110
            return
111
        self.win.setStatus(_("Cannot show location"))
112
113
    def createUI(self):
114
        screenWidth, screenHeight = gdata.scrnSize
115
        # size of dialog in layout metrics (for SimpleGridLM)
116
        cols = 36
117
        rows = 27
118
        # dialog width and height in pixels
119
        width = cols * 20 + 5
120
        height = rows * 20 + 4
121
        #creating dialog window
122
        self.win = ui.Window(self.app,
123
            modal = 1,
124
            escKeyClose = 1,
125
            movable = 0,
126
            title = _("Fleets analysis"),
127
            rect = ui.Rect((screenWidth - width) / 2, (screenHeight - height) / 2, width, height),
128
            layoutManager = ui.SimpleGridLM(),
129
        )
130
        self.win.subscribeAction('*', self)
131
        # first row is window title
132
        rows -= 1
133
134
        halfCols = cols / 2
135
        ui.Title(self.win, layout = (0, 0, halfCols, 1), text = _("Ship designs"),
136
            align = ui.ALIGN_W, id = "vDesignsTitle", font = "normal-bold")
137
        ui.Listbox(self.win, layout = (0, 1, halfCols, rows - 2), id = "vDesigns",
138
            columns = (
139
                (_("Design name"), "text", halfCols - 5, ui.ALIGN_W),
140
                (_("# fleets"), "tShipsCount", 4, ui.ALIGN_E)
141
            ),
142
            columnLabels = 1, action = "onSelectDesign", sortable = True)
143
144
        ui.Title(self.win, layout = (halfCols, 0, halfCols, 1), text = "",
145
            align = ui.ALIGN_W, id = "vFleetsTitle", font = "normal-bold")
146
        ui.Listbox(self.win, layout = (halfCols, 1, halfCols, rows - 2), id = "vFleets",
147
            columns = (
148
                (_("Fleet name"), "text", halfCols - 9, ui.ALIGN_W),
149
                (_("Ships"), "tClassCount",4, ui.ALIGN_E),
150
                (_("Fleet size"), "tShipsCount", 4, ui.ALIGN_E)
151
            ),
152
            columnLabels = 1, action = "onSelectFleet", rmbAction = "onShowLocation", sortable = True)
153
154
        # dialog bottom line
155
        ui.Title(self.win, layout = (0, rows - 1, cols - 5, 1))
156
        ui.TitleButton(self.win, layout = (cols - 5, rows - 1, 5, 1), text = _("Close"), action = "onClose")
157

client/osci/dialog/PlanetsAnalysisDlg.py 1 location

@@ 110-152 (lines=43) @@
107
            return
108
        self.win.setStatus(_("Cannot show location"))
109
110
    def createUI(self):
111
        screenWidth, screenHeight = gdata.scrnSize
112
        # size of dialog in layout metrics (for SimpleGridLM)
113
        cols = 36
114
        rows = 27
115
        # dialog width and height in pixels
116
        width = cols * 20 + 5
117
        height = rows * 20 + 4
118
        #creating dialog window
119
        self.win = ui.Window(self.app,
120
            modal = 1,
121
            escKeyClose = 1,
122
            movable = 0,
123
            title = _("Planets analysis"),
124
            rect = ui.Rect((screenWidth - width) / 2, (screenHeight - height) / 2, width, height),
125
            layoutManager = ui.SimpleGridLM(),
126
        )
127
        self.win.subscribeAction('*', self)
128
        # first row is window title
129
        rows -= 1
130
131
        halfCols = cols / 2
132
        ui.Title(self.win, layout = (0, 0, halfCols, 1), text = _("Structures"),
133
            align = ui.ALIGN_W, id = "vStructuresTitle", font = "normal-bold")
134
        ui.Listbox(self.win, layout = (0, 1, halfCols, rows - 2), id = "vStructures",
135
            columns = (
136
                (_("Structure name"), "text", halfCols - 5, ui.ALIGN_W),
137
                (_("Total #"), "tStructCount", 4, ui.ALIGN_E)
138
            ),
139
            columnLabels = 1, action = "onSelectStruct", sortable = True)
140
141
        ui.Title(self.win, layout = (halfCols, 0, halfCols, 1), text = "",
142
            align = ui.ALIGN_W, id = "vPlanetsTitle", font = "normal-bold")
143
        ui.Listbox(self.win, layout = (halfCols, 1, halfCols, rows - 2), id = "vPlanets",
144
            columns = (
145
                (_("Planet name"), "text", halfCols - 5, ui.ALIGN_W),
146
                (_("# of structs"), "tStructCount", 4, ui.ALIGN_E)
147
            ),
148
            columnLabels = 1, action = "onSelectPlanet", rmbAction = "onShowLocation", sortable = True)
149
150
        # dialog bottom line
151
        ui.Title(self.win, layout = (0, rows - 1, cols - 5, 1))
152
        ui.TitleButton(self.win, layout = (cols - 5, rows - 1, 5, 1), text = _("Close"), action = "onClose")
153