cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding rich UI development in SAP MI

Former Member
0 Kudos

Hi,

We have a .Net application with very rich UI and having lot of features lik GPS, Map viewing.

We are planning to build an application with the same functionality in SAP MI as the client is moving to SAP.

I have come to know that rich UI is built using Swings.

Can I use swings in SAP Mobile Infrastructure. If yes, I guess it should be deployed over SAP MI AWT client. Let me know if my view is correct.

Can we implement GPS and map viewing functionality in SAP MI.

Regards

Raja Sekhar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hello raja,

which specific swing objects are you considering to use?

e.g. japplet or jframe?

here's what MDK tells you about swing support in MI.

http://media.sdn.sap.com/public/html/submitted_docs/MI/MDK_2.5/content/appdev/awt/swing.html

generally, it is possible to create swing application.

you can just close the MI main page and startup your swing

application separately.

regards

jo

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Jo,

the code is pasted below

/***************************************************/

package SampleApplicationtPackage;

import java.awt.MenuItem;

import java.awt.Panel;

import org.jdesktop.layout.*;

import org.netbeans.lib.awtextra.*;

import javax.swing.*;

import com.sap.ip.me.api.runtime.awt.AwtApplication;

public class SampleApplicationClass extends javax.swing.JFrame implements AwtApplication, Constants {

private Antenna ant;

/**

  • Return the name of the application

*/

public String getApplicationName() {

return MI_APPLICATION_NAME;

}

public Panel getRootPanel() {

return null;

}

public void actionMenuItem(MenuItem arg0) {

}

public void initApplication() {

/*init();

this.setVisible(true);*/

ant = new Antenna();

ant.setVisible(true);

}

public void activateApplication() {

}

public void deactivateApplication() {

}

public void destroyApplication() {

}

}

class Antenna extends javax.swing.JFrame {

/** Creates new form Antenna */

public Antenna() {

initComponents();

}

/** This method is called from within the constructor to

  • initialize the form.

  • WARNING: Do NOT modify this code. The content of this method is

  • always regenerated by the Form Editor.

*/

// <editor-fold defaultstate="collapsed" desc=" Generated Code ">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jTextField1 = new javax.swing.JTextField();

jTextField2 = new javax.swing.JTextField();

jCheckBox1 = new javax.swing.JCheckBox();

jPanel2 = new javax.swing.JPanel();

jLabel3 = new javax.swing.JLabel();

jLabel4 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

jLabel6 = new javax.swing.JLabel();

jLabel7 = new javax.swing.JLabel();

jTextField3 = new javax.swing.JTextField();

jLabel8 = new javax.swing.JLabel();

jTextField4 = new javax.swing.JTextField();

jComboBox1 = new javax.swing.JComboBox();

jTextField5 = new javax.swing.JTextField();

jLabel9 = new javax.swing.JLabel();

jTextField6 = new javax.swing.JTextField();

jButton1 = new javax.swing.JButton();

jTextField8 = new javax.swing.JTextField();

jLabel10 = new javax.swing.JLabel();

jTextField9 = new javax.swing.JTextField();

jButton2 = new javax.swing.JButton();

jComboBox2 = new javax.swing.JComboBox();

jButton5 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

setTitle("Antenna");

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(" Position/Direction "));

jLabel1.setText("Direction (\u00b0):");

jLabel2.setText("Height (m):");

jTextField1.setText("140.000");

jTextField2.setText("110.000");

jCheckBox1.setText("Height is Lower Edge (Not Center)");

jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));

jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));

org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)

.add(jLabel2)

.add(jLabel1))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(jCheckBox1)

.add(jTextField2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)

.add(jTextField1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE))

.addContainerGap())

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(jPanel1Layout.createSequentialGroup()

.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jLabel1)

.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jLabel2)

.add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jCheckBox1)

.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(" System "));

jLabel3.setText("Channels:");

jLabel4.setText("Antenna Type:");

jLabel5.setText("Electrical Downtilt From (\u00b0):");

jLabel6.setText("Polarization:");

jLabel7.setText("Frequency From (MHz):");

jTextField3.setText("2");

jLabel8.setText("Watts:");

jTextField4.setText("12.000");

jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Kathrein 742151" }));

jTextField5.setText("0.000");

jLabel9.setText("To:");

jTextField6.setText("10.000");

jButton1.setText("Adjust");

jTextField8.setText("943.000");

jLabel10.setText("To:");

jTextField9.setText("951.000");

jButton2.setText("Adjust");

jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "X +45\u00b0" }));

jButton5.setText("Adjust");

org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);

jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel7)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel6)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel5)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel4)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel3))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(jComboBox1, 0, 307, Short.MAX_VALUE)

.add(jPanel2Layout.createSequentialGroup()

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(jTextField8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)

.add(jTextField5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)

.add(jTextField3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)

.add(jLabel8)

.add(jLabel9)

.add(jLabel10))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)

.add(org.jdesktop.layout.GroupLayout.TRAILING, jTextField9, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(jButton5)

.add(jButton1)

.add(jButton2)))

.add(jComboBox2, 0, 307, Short.MAX_VALUE))

.addContainerGap())

);

jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(jPanel2Layout.createSequentialGroup()

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jLabel3)

.add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(jLabel8)

.add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(jButton5))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jLabel4)

.add(jComboBox1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jLabel5)

.add(jTextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(jButton1)

.add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(jLabel9))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jLabel6)

.add(jComboBox2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jLabel7)

.add(jTextField8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(jButton2)

.add(jTextField9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.add(jLabel10))

.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jButton3.setText("Cancel");

jButton4.setText("OK");

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(layout.createSequentialGroup()

.addContainerGap()

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()

.add(jButton4)

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jButton3)))

.addContainerGap())

);

layout.linkSize(new java.awt.Component[] {jButton3, jButton4}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

layout.setVerticalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(layout.createSequentialGroup()

.addContainerGap()

.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)

.add(jButton3)

.add(jButton4))

.addContainerGap())

);

pack();

}// </editor-fold>

/**

  • @param args the command line arguments

*/

/* public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new Antenna().setVisible(true);

}

});

}

*/

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JButton jButton5;

private javax.swing.JCheckBox jCheckBox1;

private javax.swing.JComboBox jComboBox1;

private javax.swing.JComboBox jComboBox2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel10;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JLabel jLabel9;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;

private javax.swing.JTextField jTextField1;

private javax.swing.JTextField jTextField2;

private javax.swing.JTextField jTextField3;

private javax.swing.JTextField jTextField4;

private javax.swing.JTextField jTextField5;

private javax.swing.JTextField jTextField6;

private javax.swing.JTextField jTextField8;

private javax.swing.JTextField jTextField9;

// End of variables declaration

}

/***************************************************/

THe manifest.mf is as below

/****************************************************/

Manifest-Version: 1.0

Implementation-Version: unofficial

Specification-Title: ME AWT created by MDK plug-in

Specification-Version: 2.5

Implementation-Title: Template

Main-Class: SampleApplicationtPackage.SampleApplicationClass

Implementation-Vendor-Id: sap.com

Implementation-Vendor: SAP

ApplicationClass: SampleApplicationtPackage.SampleApplicationClass

Description: A Mobile Engine AWT application

Specification-Vendor: SAP AG

OwnFrame: true

/**********************************************/

The two packages included in the java file

org.jdesktop.layout.*;

import org.netbeans.lib.awtextra.*; are from Netbeans.

I tried to import them MI project by import from zip file option, but on building the project, the imported classes were getting deleted.

So I gave the path to those jar files in the class path. Will they be included in the generated MI archive

If not,Is there another way to import jar files?

Please provide the solution.

Regards

Raja Sekhar

Former Member
0 Kudos

hello raja,

you have 2 JFrame implementation.

try adding a constructor for SampleApplicationClass and

call the necessary initialization from it. you have to

set the size and the visibility to true as well...

You have another JFrame class (Antenna)... no need for this.

you just need a JPanel that will contain your components for

this class then call the setContentPane() of your SampleApplicationClass

instance.

regards

jo

Former Member
0 Kudos

Hi Jo,

Initially my application gui was a jFrame.

I made the changes you had suggested.

1. Add OwnFrame:true in manifest.mf

2. In the initapplication, I instantiated the jFrame class and set its visibility to true.

I deployed the app to mobile device and clicked on the application. It was not displaying the GUI.

Regards

Raja Sekhar

Former Member
0 Kudos

Hi Jo

Thanks for your reply.

I changed the jFrame to jApplet as per the MI documentation.

My application code looks like below

public class SampleApplicationClass extends javax.swing.JApplet implements AwtApplication, Constants {

/**

  • Return the name of the application

*/

public String getApplicationName() {

return MI_APPLICATION_NAME;

}

public Panel getRootPanel() {

return this.getRootPanel();

}

public void actionMenuItem(MenuItem arg0) {

}

public void initApplication() {

init();

this.setVisible(true);

}

public void activateApplication() {

}

public void deactivateApplication() {

}

public void destroyApplication() {

}

/** Initializes the applet AntennaMI */

public void init() {

try {

java.awt.EventQueue.invokeAndWait(new Runnable() {

public void run() {

initLookAndFeel();

initComponents();

}

});

} catch (Exception ex) {

ex.printStackTrace();

}

}

The initLookAndFeel sets the GUI look and feel while initcomponents initializes the GUI components like buttons and textboxes etc. I havent displayed the code.

I have deployed the application to AWT client. When I click on the application, no action takes place. The application doesnot become visible.

Please let me know the issues in the code.

Regards

Raja Sekhar

P.S - I built the project and exported the project into a MI archive which was uploaded to WebConsole. Is this way of building correct.

Regards

Raja Sekhar

Former Member
0 Kudos

hello raja,

did you do what i had written above?

jg

Former Member
0 Kudos

Hi,

Jo,Thanks for your reply.

I have built a swing application using net beans. The application class extends javax.swing.jFrame and am trying to use the code generated in NWDS Sp 14.

The MI documentation says that the Panel returned by the swing class shud be returned in the getRootPanel function.

But the problem is that jFrame class doesnot have a member function which returns Panel or jApplet.

I could find one function getRootPane() which returns a jRootPane. I tried using that function but it gave a compiler error saying that jRootPane cannot be converted to Panel.

Do let me know if there is a work around

Regards

Raja Sekhar

Former Member
0 Kudos

hello raja,

if your application has its own frame, specify the following

entry in your Manifest.mf file.

OwnFrame: true

the framework will set the MI main AWT page to invisible and

will not call the getRootPanel() method of your class. don't

forget to set your Frame visibility to true.

regards

jo

additional info:

at the moment, there's no public API for notifying the

main page that your JFrame will be exiting or closing.

you can use however the implementation class

HomeFrame.getInstance().setVisible(true)

in your code to make the MI main page visible again.

ditto

Message was edited by: Jo Gel Santiago

Former Member
0 Kudos

Hi Jo,

Thanks for the link.

When I create an MI project for AWT it creates a java file with 5 functions

1.getApplicationName()

2.getRootPanel()

3.actionMenuItem(MenuItem arg0)

4.initApplication()

5.activateApplication()

6.public void deactivateApplication()

A.Can I remove the above functions.. If not, how shud I embed my code using the above functions.

B. I am using NetBeans IDE to create GUI. Is the code generated by it compatible for MI.

C. How do I package swing libraries with my application.

Regards

Raja Sekhar

Former Member
0 Kudos

hello raja,

you have to implement those methods. they are called by MI

framework when initiating your application. this class will

serve as the MI entry...

1.getApplicationName()

-> return the string which should be the same with your

MCD name

2.getRootPanel()

-> return the class which extends the Panel class.

this will be the implementation of you GUI classes that

you have created in NetBeans...

3.actionMenuItem(MenuItem arg0)

-> notifier method

4.initApplication()

-> called by MI when its tries to initialize your application

5.activateApplication()

-> called by MI when its tries to activate your application.

e.g. when switching from other application/framework to

your application.

6.public void deactivateApplication()

-> called by MI when its tries to deactivate your application.

i.e. when it leaves your application and invoke other

application or framework.

regards

jo