Java Code Examples for net.sf.mpxj.ProjectFile#getViews()
The following examples show how to use
net.sf.mpxj.ProjectFile#getViews() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectTreeController.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Add views to the tree. * * @param parentNode parent tree node * @param file views container */ private void addViews(MpxjTreeNode parentNode, ProjectFile file) { for (View view : file.getViews()) { final View v = view; MpxjTreeNode childNode = new MpxjTreeNode(view) { @Override public String toString() { return v.getName(); } }; parentNode.add(childNode); } }
Example 2
Source File: MppBarStyleTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Tests default bar styles. * * @param mpp The ProjectFile being tested. * @param styles styles to test * @throws Exception */ private void testDefaultBarStyles(ProjectFile mpp, Object[][] styles) throws Exception { // // Retrieve the views // List<View> views = mpp.getViews(); assertNotNull(views); assertTrue(views.size() > 0); // // Retrieve the Gantt Chart view // GanttChartView view = (GanttChartView) views.get(0); assertEquals("Gantt Chart", view.getName()); // // Test the bar styles // GanttBarStyle[] barStyles = view.getBarStyles(); for (int loop = 0; loop < barStyles.length; loop++) { assertStyleEquals(styles[loop], barStyles[loop]); } }
Example 3
Source File: MppBarStyleTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Tests exception bar styles. * * @param mpp The ProjectFile being tested. * @throws Exception */ private void testExceptionBarStyles(ProjectFile mpp) throws Exception { // // Retrieve the views // List<View> views = mpp.getViews(); assertNotNull(views); assertTrue(views.size() > 0); // // Retrieve the Gantt Chart view // GanttChartView view = (GanttChartView) views.get(0); assertEquals("Gantt Chart", view.getName()); // // Test the exception styles // GanttBarStyleException[] exceptionStyles = view.getBarStyleExceptions(); for (int loop = 0; loop < exceptionStyles.length; loop++) { assertStyleExceptionEquals(EXCEPTION_STYLES[loop], exceptionStyles[loop]); } }
Example 4
Source File: MppGanttTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test Gantt chart view summary data. * * @param file project file */ private void testSummaryData(ProjectFile file) { List<View> views = file.getViews(); // // Retrieve the Gantt Chart view // GanttChartView view = (GanttChartView) views.get(0); assertEquals("Gantt Chart", view.getName()); assertTrue(view.getShowInMenu()); assertEquals(778, view.getTableWidth()); assertFalse(view.getHighlightFilter()); assertEquals("Entry", view.getTableName()); assertEquals("&All Tasks", view.getDefaultFilterName()); assertEquals("No Group", view.getGroupName()); assertEquals("Standard", view.getNonWorkingDaysCalendarName()); assertEquals("java.awt.Color[r=194,g=220,b=255]", view.getNonWorkingColor().toString()); assertEquals(ChartPattern.LIGHTDOTTED, view.getNonWorkingPattern()); assertEquals(NonWorkingTimeStyle.BEHIND, view.getNonWorkingStyle()); }
Example 5
Source File: MppGanttTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test the timescale settings. * * @param file project file */ private void testTimescales(ProjectFile file) { List<View> views = file.getViews(); // // Retrieve the Gantt Chart view // GanttChartView view = (GanttChartView) views.get(0); assertEquals("Gantt Chart", view.getName()); assertEquals(2, view.getTimescaleShowTiers()); assertEquals(100, view.getTimescaleSize()); assertTrue(view.getTimescaleScaleSeparator()); assertEquals("[TimescaleTier UsesFiscalYear=true TickLines=true Units=None Count=1 Format=[None] Alignment=Center]", view.getTimescaleTopTier().toString()); assertEquals("[TimescaleTier UsesFiscalYear=true TickLines=true Units=Weeks Count=1 Format=[January 27, '02] Alignment=Left]", view.getTimescaleMiddleTier().toString()); assertEquals("[TimescaleTier UsesFiscalYear=true TickLines=true Units=Days Count=1 Format=[S, M, T, ...] Alignment=Center]", view.getTimescaleBottomTier().toString()); }
Example 6
Source File: MppGanttTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test the layout settings. * * @param file project file */ private void testLayout(ProjectFile file) { List<View> views = file.getViews(); // // Retrieve the Gantt Chart view // GanttChartView view = (GanttChartView) views.get(0); assertEquals("Gantt Chart", view.getName()); assertTrue(view.getShowDrawings()); assertTrue(view.getRoundBarsToWholeDays()); assertTrue(view.getShowBarSplits()); assertFalse(view.getAlwaysRollupGanttBars()); assertFalse(view.getHideRollupBarsWhenSummaryExpanded()); assertEquals(12, view.getGanttBarHeight()); assertEquals(GanttBarDateFormat.DDMM, view.getBarDateFormat()); assertEquals(LinkStyle.END_TOP, view.getLinkStyle()); }
Example 7
Source File: MppGanttTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test the table font style settings. * * @param file project file */ private void testTableFontStyles(ProjectFile file) { List<View> views = file.getViews(); // // Retrieve the Gantt Chart view // GanttChartView view = (GanttChartView) views.get(0); assertEquals("Gantt Chart", view.getName()); TableFontStyle[] tfs = view.getTableFontStyles(); assertEquals(TABLE_FONT_STYLES.length, tfs.length); for (int loop = 0; loop < tfs.length; loop++) { assertTrue(TABLE_FONT_STYLES_SET.contains(tfs[loop].toString())); } }
Example 8
Source File: BasicTest.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test retrieval of view information. * * @throws Exception */ @Test public void testViews() throws Exception { ProjectFile mpp = new MPPReader().read(MpxjTestData.filePath("legacy/sample98.mpp")); List<View> views = mpp.getViews(); assertEquals("Incorrect number of views", 1, views.size()); mpp = new MPPReader().read(MpxjTestData.filePath("legacy/sample.mpp")); views = mpp.getViews(); assertEquals("Incorrect number of views", 3, views.size()); }
Example 9
Source File: MppGanttTest.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test the font styles associated with a Gantt chart view. * * @param file project file */ private void testFontStyles(ProjectFile file) { List<View> views = file.getViews(); // // Retrieve the Gantt Chart view // GanttChartView view = (GanttChartView) views.get(0); assertEquals("Gantt Chart", view.getName()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=false underline=false strikethrough=false color=java.awt.Color[r=0,g=0,b=255] backgroundColor=null backgroundPattern=Solid]", view.getHighlightedTasksFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=false underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getRowAndColumnFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Berlin Sans FB size=8] italic=false bold=true underline=true strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getNonCriticalTasksFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=false underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getCriticalTasksFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=true underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getSummaryTasksFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Baskerville Old Face size=9] italic=true bold=false underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getMilestoneTasksFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=false underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getMiddleTimescaleFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=false underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getBottomTimescaleFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=true underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getBarTextLeftFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=true underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getBarTextRightFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=true underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getBarTextTopFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=true underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getBarTextBottomFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=true underline=false strikethrough=false color=java.awt.Color[r=0,g=0,b=0] backgroundColor=null backgroundPattern=Solid]", view.getBarTextInsideFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=BankGothic Lt BT size=8] italic=false bold=false underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getMarkedTasksFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=10] italic=false bold=true underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getProjectSummaryTasksFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=false underline=false strikethrough=false color=java.awt.Color[r=128,g=128,b=128] backgroundColor=null backgroundPattern=Solid]", view.getExternalTasksFontStyle().toString()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=false underline=false strikethrough=false color=null backgroundColor=null backgroundPattern=Solid]", view.getTopTimescaleFontStyle().toString()); }
Example 10
Source File: MppGanttTest.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Common gridline tests. * * @param file project file */ private void testGridlines(ProjectFile file) { List<View> views = file.getViews(); // // Retrieve the Gantt Chart view // GanttChartView view = (GanttChartView) views.get(0); assertEquals("Gantt Chart", view.getName()); // // Test each set of grid line definitions // assertEquals("[GridLines NormalLineColor=null NormalLineStyle=None IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=null]", view.getGanttRowsGridLines().toString()); assertEquals("[GridLines NormalLineColor=java.awt.Color[r=255,g=0,b=0] NormalLineStyle=Solid IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=null]", view.getBarRowsGridLines().toString()); assertEquals("[GridLines NormalLineColor=java.awt.Color[r=0,g=0,b=255] NormalLineStyle=Dotted1 IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=java.awt.Color[r=0,g=0,b=0]]", view.getMiddleTierColumnGridLines().toString()); assertEquals("[GridLines NormalLineColor=java.awt.Color[r=0,g=128,b=0] NormalLineStyle=None IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=null]", view.getBottomTierColumnGridLines().toString()); assertEquals("[GridLines NormalLineColor=java.awt.Color[r=128,g=128,b=128] NormalLineStyle=Dotted1 IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=java.awt.Color[r=128,g=128,b=128]]", view.getCurrentDateGridLines().toString()); assertEquals("[GridLines NormalLineColor=java.awt.Color[r=192,g=192,b=192] NormalLineStyle=Solid IntervalNumber=5 IntervalLineStyle=None IntervalLineColor=java.awt.Color[r=192,g=192,b=192]]", view.getSheetRowsGridLines().toString()); assertEquals("[GridLines NormalLineColor=java.awt.Color[r=192,g=192,b=192] NormalLineStyle=Solid IntervalNumber=2 IntervalLineStyle=Dotted1 IntervalLineColor=java.awt.Color[r=192,g=192,b=192]]", view.getSheetColumnsGridLines().toString()); assertEquals("[GridLines NormalLineColor=java.awt.Color[r=128,g=128,b=128] NormalLineStyle=Solid IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=java.awt.Color[r=128,g=128,b=128]]", view.getTitleVerticalGridLines().toString()); assertEquals("[GridLines NormalLineColor=java.awt.Color[r=128,g=128,b=128] NormalLineStyle=Solid IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=java.awt.Color[r=128,g=128,b=128]]", view.getTitleHorizontalGridLines().toString()); assertEquals("[GridLines NormalLineColor=null NormalLineStyle=Dashed IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=null]", view.getPageBreakGridLines().toString()); assertEquals("[GridLines NormalLineColor=null NormalLineStyle=None IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=null]", view.getProjectStartGridLines().toString()); assertEquals("[GridLines NormalLineColor=null NormalLineStyle=None IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=null]", view.getProjectFinishGridLines().toString()); assertEquals("[GridLines NormalLineColor=null NormalLineStyle=None IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=null]", view.getStatusDateGridLines().toString()); assertEquals("[GridLines NormalLineColor=java.awt.Color[r=0,g=0,b=128] NormalLineStyle=None IntervalNumber=0 IntervalLineStyle=None IntervalLineColor=null]", view.getTopTierColumnGridLines().toString()); }
Example 11
Source File: MppViewTest.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Tests MPP's Views. Not an in-depth test, but covers the basics of * Views, like View Names, Column Names, and Column Widths * * @param mpp The ProjectFile being tested. */ private void testViews(ProjectFile mpp) { List<View> views = mpp.getViews(); // not sure what order MPP12 will store the views in, // so make a Set to check against when done reading in the views HashSet<String> setViewNames = new HashSet<>(); for (int viewNum = 0; viewNum < views.size(); viewNum++) { // View Names View view = views.get(viewNum); String viewName = view.getName(); setViewNames.add(viewName); Table table = null; if (view instanceof GanttChartView) { GanttChartView view9 = (GanttChartView) view; if (null != view9.getTable()) { table = view9.getTable(); ViewType viewType = view.getType(); assertEquals(ViewType.GANTT_CHART, viewType); // verify all columns List<Column> cols = table.getColumns(); HashSet<String> setColumnNames = new HashSet<>(); for (int n = 0; n < cols.size(); n++) { Column col = cols.get(n); setColumnNames.add(col.getTitle()); int width = col.getWidth(); assertTrue(width > 0); } //assertEquals(7, setColumnNames.size()); assertTrue(setColumnNames.contains("ID")); assertTrue(setColumnNames.contains("Unique ID")); assertTrue(setColumnNames.contains("Task Name")); assertTrue(setColumnNames.contains("Indicators")); assertTrue(setColumnNames.contains("Start")); assertTrue(setColumnNames.contains("Finish")); assertTrue(setColumnNames.contains("Resource Names")); assertTrue(view9.getTableWidth() > 0); } } } //assertEquals(7, setViewNames.size()); assertTrue(setViewNames.contains("Gantt Chart")); assertTrue(setViewNames.contains("Test View")); assertTrue(setViewNames.contains("Tracking Gantt")); assertTrue(setViewNames.contains("Resource Sheet")); assertTrue(setViewNames.contains("Resource Usage")); assertTrue(setViewNames.contains("Task Usage")); //assertTrue(setViewNames.contains("")); // why blank? }
Example 12
Source File: MppGanttTest.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Test the progress line settings. * * @param file project file */ private void testProgressLines(ProjectFile file) { SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); List<View> views = file.getViews(); // // Retrieve the Gantt Chart view // GanttChartView view = (GanttChartView) views.get(0); assertEquals("Gantt Chart", view.getName()); assertTrue(view.getProgressLinesEnabled()); assertFalse(view.getProgressLinesAtCurrentDate()); assertTrue(view.getProgressLinesAtRecurringIntervals()); assertEquals(Interval.WEEKLY, view.getProgressLinesInterval()); assertEquals(1, view.getProgressLinesIntervalDailyDayNumber()); assertTrue(view.isProgressLinesIntervalDailyWorkday()); boolean[] weeklyDay = view.getProgressLinesIntervalWeeklyDay(); assertFalse(weeklyDay[Day.SUNDAY.getValue()]); assertTrue(weeklyDay[Day.MONDAY.getValue()]); assertFalse(weeklyDay[Day.TUESDAY.getValue()]); assertFalse(weeklyDay[Day.WEDNESDAY.getValue()]); assertFalse(weeklyDay[Day.THURSDAY.getValue()]); assertFalse(weeklyDay[Day.FRIDAY.getValue()]); assertFalse(weeklyDay[Day.SATURDAY.getValue()]); assertEquals(1, view.getProgressLinesIntervalWeekleyWeekNumber()); assertFalse(view.getProgressLinesIntervalMonthlyDay()); assertEquals(1, view.getProgressLinesIntervalMonthlyDayMonthNumber()); assertEquals(1, view.getProgressLinesIntervalMonthlyDayDayNumber()); assertEquals(ProgressLineDay.DAY, view.getProgressLinesIntervalMonthlyFirstLastDay()); assertTrue(view.getProgressLinesIntervalMonthlyFirstLast()); assertEquals(1, view.getProgressLinesIntervalMonthlyFirstLastMonthNumber()); assertFalse(view.getProgressLinesBeginAtProjectStart()); assertEquals("13/05/2010", df.format(view.getProgressLinesBeginAtDate())); assertTrue(view.getProgressLinesDisplaySelected()); assertTrue(view.getProgressLinesActualPlan()); assertEquals(0, view.getProgressLinesDisplayType()); assertFalse(view.getProgressLinesShowDate()); assertEquals(26, view.getProgressLinesDateFormat()); assertEquals("[FontStyle fontBase=[FontBase name=Arial size=8] italic=false bold=false underline=false strikethrough=false color=java.awt.Color[r=0,g=0,b=0] backgroundColor=null backgroundPattern=Solid]", view.getProgressLinesFontStyle().toString()); assertEquals("java.awt.Color[r=255,g=0,b=0]", view.getProgressLinesCurrentLineColor().toString()); assertEquals(LineStyle.SOLID, view.getProgressLinesCurrentLineStyle()); assertEquals("java.awt.Color[r=255,g=0,b=0]", view.getProgressLinesCurrentProgressPointColor().toString()); assertEquals(13, view.getProgressLinesCurrentProgressPointShape()); assertEquals(null, view.getProgressLinesOtherLineColor()); assertEquals(LineStyle.SOLID, view.getProgressLinesOtherLineStyle()); assertEquals(null, view.getProgressLinesOtherProgressPointColor()); assertEquals(0, view.getProgressLinesOtherProgressPointShape()); assertEquals(2, view.getProgressLinesDisplaySelectedDates().length); assertEquals("01/02/2010", df.format(view.getProgressLinesDisplaySelectedDates()[0])); assertEquals("01/01/2010", df.format(view.getProgressLinesDisplaySelectedDates()[1])); }