-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide default columns unless they are explicitly marked as shown in th…
…e xml view Fixes issue #2306
- Loading branch information
Showing
2 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
ganttproject-tester/test/net/sourceforge/ganttproject/parser/TestViewSerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
Copyright 2023 BarD Software s.r.o, Dmitry Barashev | ||
This file is part of GanttProject, an open-source project management tool. | ||
GanttProject is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
GanttProject is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with GanttProject. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.sourceforge.ganttproject.parser | ||
|
||
import biz.ganttproject.core.io.XmlView | ||
import biz.ganttproject.core.model.task.TaskDefaultColumn | ||
import biz.ganttproject.core.table.ColumnList | ||
import biz.ganttproject.core.time.impl.GPTimeUnitStack | ||
import biz.ganttproject.lib.fx.BuiltinColumns | ||
import biz.ganttproject.lib.fx.ColumnListImpl | ||
import biz.ganttproject.lib.fx.copyOf | ||
import net.sourceforge.ganttproject.gui.zoom.ZoomManager | ||
import net.sourceforge.ganttproject.task.CustomColumnsManager | ||
import org.junit.jupiter.api.Assertions.* | ||
import org.junit.jupiter.api.Test | ||
|
||
class TestViewSerializer { | ||
private val builtinColumns = BuiltinColumns( | ||
isZeroWidth = { | ||
when (TaskDefaultColumn.find(it)) { | ||
TaskDefaultColumn.COLOR, TaskDefaultColumn.INFO -> true | ||
else -> false | ||
} | ||
}, | ||
allColumns = { | ||
ColumnList.Immutable.fromList(TaskDefaultColumn.getColumnStubs()).copyOf() | ||
} | ||
) | ||
@Test | ||
fun `default columns remain hidden - issue 2306`() { | ||
val storage = mutableListOf<ColumnList.Column>() | ||
val columnList = ColumnListImpl(columnList = storage, customPropertyManager = CustomColumnsManager(), tableColumns = { emptyList() }, builtinColumns = builtinColumns) | ||
val xmlView = XmlView(fields = listOf( | ||
XmlView.XmlField(id = TaskDefaultColumn.NAME.stub.id, name = "Name", width = 50, order = 0), | ||
XmlView.XmlField(id = TaskDefaultColumn.BEGIN_DATE.stub.id, name = "Begin date", width = 70, order = 1) | ||
)) | ||
loadView(xmlView, ZoomManager(GPTimeUnitStack()), columnList) | ||
columnList.columns().first { it.id == TaskDefaultColumn.BEGIN_DATE.stub.id }.also { | ||
assertTrue(it.isVisible) | ||
assertEquals(70, it.width) | ||
assertEquals(1, it.order) | ||
} | ||
columnList.columns().first { it.id == TaskDefaultColumn.NAME.stub.id }.also { | ||
assertTrue(it.isVisible) | ||
assertEquals(50, it.width) | ||
assertEquals(0, it.order) | ||
} | ||
columnList.columns().first { it.id == TaskDefaultColumn.END_DATE.stub.id }.also { | ||
assertFalse(it.isVisible) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters