Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » plug-in help
plug-in help [message #155417] Sun, 04 June 2006 18:47
Richard is currently offline RichardFriend
Messages: 21
Registered: July 2009
Junior Member
I trying to make the following code into a new wizard item plugin, asking
the project name and its folders. I have been trying so many times to do
this. i look at the eclipse tutorial and eclipse books and i am still
having problems. I get up to the pde perpective and it is a blank. Can
someone please show me a complete step by step from start to finish
procedure on how to do this? I really going crazy on this.

/**
*
*/
package src;

import gov.va.med.foundations.adapter.cci.VistaLinkConnection;
import gov.va.med.foundations.adapter.record.VistaLinkFaultExceptio n;
import gov.va.med.foundations.rpc.RpcRequest;
import gov.va.med.foundations.rpc.RpcRequestFactory;
import gov.va.med.foundations.rpc.RpcResponse;
import gov.va.med.foundations.security.vistalink.CallbackHandlerSwi ng;
import gov.va.med.foundations.security.vistalink.VistaKernelPrincip alImpl;
import gov.va.med.foundations.security.vistalink.VistaLoginModuleEx ception;
import gov.va.med.foundations.utilities.FoundationsException;

import java.awt.BorderLayout;
import java.awt.Event;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.Timer;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

/**
* @author xxxxxxx xxxxxxxxxxxxx
*
*/
public class RTMonitor {

private JFrame jFrame = null; //
@jve:decl-index=0:visual-constraint="10,10"

private JPanel jContentPane = null;

private JMenuBar jJMenuBar = null;

private JMenu fileMenu = null;

private JMenu editMenu = null;

private JMenu helpMenu = null;

private JMenuItem exitMenuItem = null;

private JMenuItem aboutMenuItem = null;

private JMenuItem cutMenuItem = null;

private JMenuItem copyMenuItem = null;

private JMenuItem pasteMenuItem = null;

private JMenuItem saveMenuItem = null;

private JDialog aboutDialog = null;

private JPanel aboutContentPane = null;

private JLabel aboutVersionLabel = null;

private JLabel jLabelReturnValue = null;

private JTextField jTextFieldReturnValue = null;

private JLabel jLabelInterval = null;

private JSpinner jSpinnerInterval = null;

private JLabel jLabelResponseTime = null;

private JTextField jTextFieldResponseTime = null;

private JButton jButtonStart = null;

private JButton jButtonStop = null;

protected String jaasConfigName = "MirrorServer";

protected LoginContext loginContext = null; // @jve:decl-index=0:

private static Logger logger = Logger.getLogger(RTMonitor.class); //
@jve:decl-index=0:

private JFrame jFrameCallBack = null; //
@jve:decl-index=0:visual-constraint="66,339"

private JPanel jContentPaneCallBack = null;

private VistaKernelPrincipalImpl userPrincipal = null;

private Timer timerTaskVistaCall = null; //
@jve:decl-index=0:visual-constraint="276,349"

private ActionListener actionListenerCallVista = null; //
@jve:decl-index=0:visual-constraint="412,346"

protected RpcRequest vReq = null;

protected static VistaLinkConnection myConnection = null;

protected RpcResponse vResp = null; // @jve:decl-index=0:

protected Date startDate = null;

protected Date stopDate = null;

protected SimpleDateFormat vistaFMExtDateFormat = null;

protected long deltaRT = 0;

private SpinnerNumberModel spinnerNumberModel1 = null; //
@jve:decl-index=0:visual-constraint="555,350"

/**
* This method initializes jTextFieldReturnValue
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldReturnValue() {
if (jTextFieldReturnValue == null) {
jTextFieldReturnValue = new JTextField();
jTextFieldReturnValue.setBounds(new Rectangle(111, 18, 135, 20));
}
return jTextFieldReturnValue;
}

/**
* This method initializes jSpinnerInterval
*
* @return javax.swing.JSpinner
*/
private JSpinner getJSpinnerInterval() {
if (jSpinnerInterval == null) {
jSpinnerInterval = new JSpinner();
jSpinnerInterval.setBounds(new Rectangle(397, 19, 63, 20));
jSpinnerInterval.setModel(getSpinnerNumberModel1());
jSpinnerInterval
.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent e) {
System.out.println("stateChanged()");
if (getTimerTaskVistaCall().isRunning())
getTimerTaskVistaCall().setDelay(
Integer.parseInt(jSpinnerInterval
.getValue().toString()) * 1000);
}
});
}
return jSpinnerInterval;
}

/**
* This method initializes jTextFieldResponseTime
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldResponseTime() {
if (jTextFieldResponseTime == null) {
jTextFieldResponseTime = new JTextField();
jTextFieldResponseTime.setBounds(new Rectangle(207, 70, 93, 20));
}
return jTextFieldResponseTime;
}

/**
* This method initializes jButtonStart
*
* @return javax.swing.JButton
*/
private JButton getJButtonStart() {
if (jButtonStart == null) {
jButtonStart = new JButton();
jButtonStart.setBounds(new Rectangle(134, 190, 106, 19));
jButtonStart.setText("START");
jButtonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()");
jButtonStart.setEnabled(false);
getJButtonStop().setEnabled(true);
getTimerTaskVistaCall().start();
getTimerTaskVistaCall().setDelay(10 * 1000);
}
});
}
return jButtonStart;
}

/**
* This method initializes jButtonStop
*
* @return javax.swing.JButton
*/
private JButton getJButtonStop() {
if (jButtonStop == null) {
jButtonStop = new JButton();
jButtonStop.setBounds(new Rectangle(258, 189, 106, 19));
jButtonStop.setText("STOP");
jButtonStop.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()");
jButtonStop.setEnabled(false);
getJButtonStart().setEnabled(true);
getTimerTaskVistaCall().stop();
}
});
}
return jButtonStop;
}

/**
* This method initializes jFrameCallBack
*
* @return javax.swing.JFrame
*/
private JFrame getJFrameCallBack() {
if (jFrameCallBack == null) {
jFrameCallBack = new JFrame();
jFrameCallBack.setContentPane(getJContentPaneCallBack());
}
return jFrameCallBack;
}

/**
* This method initializes jContentPaneCallBack
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPaneCallBack() {
if (jContentPaneCallBack == null) {
jContentPaneCallBack = new JPanel();
jContentPaneCallBack.setLayout(new BorderLayout());
}
return jContentPaneCallBack;
}

/**
* This method initializes timerTaskVistaCall
*
* @return javax.swing.Timer
*/
private Timer getTimerTaskVistaCall() {
if (timerTaskVistaCall == null) {
timerTaskVistaCall = new Timer(0, getActionListenerCallVista());
}
return timerTaskVistaCall;
}

/**
* This method initializes actionListenerCallVista
*
* @return java.awt.event.ActionListener
*/
private ActionListener getActionListenerCallVista() {
if (actionListenerCallVista == null) {
actionListenerCallVista = new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
startDate.setTime(System.currentTimeMillis());
System.out.println("actionevent Performed()"
+ startDate.toString());
try {
vReq = getRPCRequest("AEEQ RT MONITOR", "AEEQ GET RTM VALUE");
} catch (FoundationsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
startDate.setTime(System.currentTimeMillis());
vResp = getRPCResponse(vReq);
stopDate.setTime(System.currentTimeMillis());
deltaRT = stopDate.getTime() - startDate.getTime();
getJTextFieldReturnValue().setText(vResp.getResults());
getJTextFieldResponseTime().setText(Long.toString(deltaRT));
System.out.println("Start date: " +
vistaFMExtDateFormat.format(startDate)
+ " Stop Date: " + vistaFMExtDateFormat.format(stopDate));
} catch (FoundationsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
}
return actionListenerCallVista;
}

/**
* This method initializes spinnerNumberModel1
*
* @return javax.swing.SpinnerNumberModel
*/
private SpinnerNumberModel getSpinnerNumberModel1() {
if (spinnerNumberModel1 == null) {
spinnerNumberModel1 = new SpinnerNumberModel();
spinnerNumberModel1.setMinimum(10);
spinnerNumberModel1.setValue(10);
}
return spinnerNumberModel1;
}

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
public void run() {
RTMonitor application = new RTMonitor();
application.getJFrame().setVisible(true);
}
});
}

/**
* This method initializes jFrame
*
* @return javax.swing.JFrame
*/
private JFrame getJFrame() {
if (jFrame == null) {
jFrame = new JFrame();
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setJMenuBar(getJJMenuBar());
jFrame.setSize(497, 315);
jFrame.setContentPane(getJContentPane());
jFrame.setTitle("Application");
jFrame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.out.println("windowClosing()");
if (getTimerTaskVistaCall().isRunning())
getTimerTaskVistaCall().stop();
myLogout();
System.exit(0);
}

public void windowActivated(java.awt.event.WindowEvent e) {
System.out.println("windowActivated()");
DOMConfigurator.configure("props/log4jConfig.xml");
logger.debug("Starting to run Swing Tester...");
startDate = new Date(System.currentTimeMillis());
stopDate = new Date(System.currentTimeMillis());
vistaFMExtDateFormat = new SimpleDateFormat(
"MM/dd/yyyy@HH:mm:ss");
}

public void windowOpened(java.awt.event.WindowEvent e) {
System.out.println("windowOpened()");
getJButtonStop().setEnabled(false);
myLogin();
myPostLogin();
}
});
}
return jFrame;
}

/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelResponseTime = new JLabel();
jLabelResponseTime.setBounds(new Rectangle(23, 69, 180, 17));
jLabelResponseTime.setText("Response Time (milliseconds):");
jLabelInterval = new JLabel();
jLabelInterval.setBounds(new Rectangle(281, 21, 111, 16));
jLabelInterval.setText("Interval (seconds):");
jLabelReturnValue = new JLabel();
jLabelReturnValue.setBounds(new Rectangle(25, 19, 82, 16));
jLabelReturnValue.setText("Return Value:");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setName(null);
jContentPane.add(jLabelReturnValue, null);
jContentPane.add(getJTextFieldReturnValue(), null);
jContentPane.add(jLabelInterval, null);
jContentPane.add(getJSpinnerInterval(), null);
jContentPane.add(jLabelResponseTime, null);
jContentPane.add(getJTextFieldResponseTime(), null);
jContentPane.add(getJButtonStart(), null);
jContentPane.add(getJButtonStop(), null);
}
return jContentPane;
}

/**
* This method initializes jJMenuBar
*
* @return javax.swing.JMenuBar
*/
private JMenuBar getJJMenuBar() {
if (jJMenuBar == null) {
jJMenuBar = new JMenuBar();
jJMenuBar.add(getFileMenu());
jJMenuBar.add(getEditMenu());
jJMenuBar.add(getHelpMenu());
}
return jJMenuBar;
}

/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getFileMenu() {
if (fileMenu == null) {
fileMenu = new JMenu();
fileMenu.setText("File");
fileMenu.add(getSaveMenuItem());
fileMenu.add(getExitMenuItem());
}
return fileMenu;
}

/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getEditMenu() {
if (editMenu == null) {
editMenu = new JMenu();
editMenu.setText("Edit");
editMenu.add(getCutMenuItem());
editMenu.add(getCopyMenuItem());
editMenu.add(getPasteMenuItem());
}
return editMenu;
}

/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getHelpMenu() {
if (helpMenu == null) {
helpMenu = new JMenu();
helpMenu.setText("Help");
helpMenu.add(getAboutMenuItem());
}
return helpMenu;
}

/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getExitMenuItem() {
if (exitMenuItem == null) {
exitMenuItem = new JMenuItem();
exitMenuItem.setText("Exit");
exitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
return exitMenuItem;
}

/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getAboutMenuItem() {
if (aboutMenuItem == null) {
aboutMenuItem = new JMenuItem();
aboutMenuItem.setText("About");
aboutMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JDialog aboutDialog = getAboutDialog();
aboutDialog.pack();
Point loc = getJFrame().getLocation();
loc.translate(20, 20);
aboutDialog.setLocation(loc);
aboutDialog.setVisible(true);
}
});
}
return aboutMenuItem;
}

/**
* This method initializes aboutDialog
*
* @return javax.swing.JDialog
*/
private JDialog getAboutDialog() {
if (aboutDialog == null) {
aboutDialog = new JDialog(getJFrame(), true);
aboutDialog.setTitle("About");
aboutDialog.setContentPane(getAboutContentPane());
}
return aboutDialog;
}

/**
* This method initializes aboutContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getAboutContentPane() {
if (aboutContentPane == null) {
aboutContentPane = new JPanel();
aboutContentPane.setLayout(new BorderLayout());
aboutContentPane.add(getAboutVersionLabel(), BorderLayout.CENTER);
}
return aboutContentPane;
}

/**
* This method initializes aboutVersionLabel
*
* @return javax.swing.JLabel
*/
private JLabel getAboutVersionLabel() {
if (aboutVersionLabel == null) {
aboutVersionLabel = new JLabel();
aboutVersionLabel.setText("Version 1.0");
aboutVersionLabel.setHorizontalAlignment(SwingConstants.CENT ER);
}
return aboutVersionLabel;
}

/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getCutMenuItem() {
if (cutMenuItem == null) {
cutMenuItem = new JMenuItem();
cutMenuItem.setText("Cut");
cutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.V K_X,
Event.CTRL_MASK, true));
}
return cutMenuItem;
}

/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getCopyMenuItem() {
if (copyMenuItem == null) {
copyMenuItem = new JMenuItem();
copyMenuItem.setText("Copy");
copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent. VK_C,
Event.CTRL_MASK, true));
}
return copyMenuItem;
}

/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getPasteMenuItem() {
if (pasteMenuItem == null) {
pasteMenuItem = new JMenuItem();
pasteMenuItem.setText("Paste");
pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent .VK_V,
Event.CTRL_MASK, true));
}
return pasteMenuItem;
}

/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getSaveMenuItem() {
if (saveMenuItem == null) {
saveMenuItem = new JMenuItem();
saveMenuItem.setText("Save");
saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent. VK_S,
Event.CTRL_MASK, true));
}
return saveMenuItem;
}

private void myLogin() {
try {
CallbackHandlerSwing cbhSwing = new CallbackHandlerSwing(
getJFrameCallBack());
loginContext = new LoginContext(jaasConfigName, cbhSwing);
loginContext.login();
} catch (VistaLoginModuleException vle) {
JOptionPane.showMessageDialog(null, vle.getMessage(),
"Login error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
} catch (LoginException vle) {
JOptionPane.showMessageDialog(null, vle.getMessage(),
"Login error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
}

/**
*
*/
private void myPostLogin() {
try {
userPrincipal = VistaKernelPrincipalImpl
.getKernelPrincipal(loginContext.getSubject());
} catch (FoundationsException e) {
JOptionPane.showMessageDialog(null, e.getMessage(), "Login error",
JOptionPane.ERROR_MESSAGE);
}
myConnection = userPrincipal.getAuthenticatedConnection();
}

/**
*
*/
private void myLogout() {
if (this.userPrincipal != null) {
try {
loginContext.logout();
} catch (LoginException e) {
JOptionPane.showMessageDialog(null, e.getMessage(),
"Logout error", JOptionPane.ERROR_MESSAGE);
}
}
}

/**
*
*/
public static RpcResponse getRPCResponse(RpcRequest vRPCRequest)
throws FoundationsException {
RpcResponse vResponse = null;
try {
vResponse = myConnection.executeRPC(vRPCRequest);
} catch (VistaLinkFaultException e) {
// process exception as needed
} catch (FoundationsException e) {
// process exception as needed
}
return vResponse;
}

/**
*
*/
public static RpcRequest getRPCRequest(String rpcContext, String rpcName)
throws FoundationsException {
RpcRequest vRequest = null;
try {
vRequest = RpcRequestFactory.getRpcRequest(rpcContext, rpcName);
} catch (FoundationsException e) {

}

return vRequest;
}

}
Previous Topic:missing IAdaptable
Next Topic:Eclipse on Solaris 10
Goto Forum:
  


Current Time: Thu Apr 25 22:36:09 GMT 2024

Powered by FUDForum. Page generated in 0.08261 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top