/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ package xml; import java.awt.event.KeyEvent; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JToolBar; import ilog.views.gantt.action.IlvAction; import scheduleChart.ScheduleExample; import shared.GanttCommand; import shared.swing.ExampleFrame; /** * This example shows how to use the ilog.views.gantt.xml package to serialize * Gantt data. The example uses an <code>IlvScheduleChart</code> to show the * Gantt model loaded from an XML file. This class works together with the * XMLGanttActions class. See XMLGanttActions to learn how to load a Gantt model * from an XML file and how to save a Gantt model to an XML file. */ public class XMLScheduleExample extends ScheduleExample { /** * The various menu and toolbar actions. */ protected IlvAction newAction; protected IlvAction openAction; protected IlvAction saveAsAction; // Creates and installs the menu bar. Override public JMenuBar createMenuBar() { JMenuBar menu = super.createMenuBar(); // Remove the Exit menu item from the Edit menu. if (isExitAllowed()) { JMenu edit = menu.getMenu(0); edit.remove(edit.getItemCount() - 1); edit.remove(edit.getItemCount() - 1); } // Add File menu menu.add(createFileMenu(), 0); return menu; } /** * Creates the "File" menu. */ public JMenu createFileMenu() { JMenu menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_F); setStatusText(menu, "File operations"); // Menu item for "New". newAction = new GanttCommand.NewDataModelAction(chart); addAction(menu, newAction); if (isLocalFileAccessAllowed()) { // Menu item for "Open ..." openAction = new XMLGanttActions.OpenXMLAction(chart); addAction(menu, openAction); // Menu item for "Save ...". saveAsAction = new XMLGanttActions.SaveAsXMLAction(chart); addAction(menu, saveAsAction); } // Menu item for "Exit". if (isExitAllowed()) { menu.addSeparator(); addAction(menu, exitAction); } return menu; } // ========================================= // Toolbar // ========================================= /** * Populates the toolbar file actions. */ Override protected void populateToolBarFileActions(JToolBar toolbar) { if (newAction != null) addAction(toolbar, newAction); if (openAction != null) addAction(toolbar, openAction); if (saveAsAction != null) addAction(toolbar, saveAsAction); } // ========================================= // Example Application // ========================================= /** * Returns the title of the example. * * @return The title of the example. */ Override public String getTitle() { return "XML Schedule Chart Example"; } /** * Application mainline. * * @param args * The command line arguments. */ public static void main(String[] args) { ExampleFrame.createAndShowGUI(XMLScheduleExample.class); } }