Altova MapForce 2024 Enterprise Edition

Im unten gezeigten Code sehen Sie wie grundlegende Events behandelt werden. Bei Aufruf der MapForceControl-Methode open oder beim Öffnen einer Datei über das Menü oder die Projektstruktur wird das onOpenedOrFocused Event an den dazugehörigen Event Handler gesendet. Im Prinzip wird dieses Event behandelt, indem die Datei durch Aufruf der open-Methode des MapForceDocumentControl geöffnet wird.

 

 

01       // Open the Marketing file when button is pressed

02       btnMarkExp.addActionListener( new ActionListener() {

03         public void actionPerformed(ActionEvent e) {

04           try {

05             // Instruct the Document control to open the file - avoid calling the open method of MapForceControl (see help)

06             mapForceDocument.open( strExamplesFolder + "MarketingExpenses.mfd" );

07             mapForceDocument.requestFocusInWindow();

08           } catch (AutomationException e1) {

09             e1.printStackTrace();

10           }

11         }

12       } );

13       public void onOpenedOrFocused( String i_strFileName, boolean i_bOpenWithThisControl, boolean i_bFileAlreadyOpened ) throws AutomationException

14   {

15     // Handle the New/Open events coming from the Project tree or from the menus

16     if ( !i_bFileAlreadyOpened )

17     {

18       // This is basically an SDI interface, so open the file in the already existing document control

19       try {

20         MapForceContainer.mapForceDocument.open( i_strFileName );

21         MapForceContainer.mapForceDocument.requestFocusInWindow();

22       } catch (Exception e) {

23         e.printStackTrace();

24       }

25     }

26   }

 

© 2017-2023 Altova GmbH