Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Error parsing refactored code(Cannot see hand-written code in WindowBuilder)
Error parsing refactored code [message #850026] Thu, 19 April 2012 17:38 Go to next message
david Missing name is currently offline david Missing nameFriend
Messages: 2
Registered: July 2009
Junior Member
Built a ui using Window Builder, got it all working, then refactored to move some code out of main class. Now WindowBuilder won't show the ui.
Any way of checking for errors in the parsing to work out what is causing the parser not to recognise the new code?
I had everything in one class, then moved it into a new class which extends JFrame. Every time the design view parses the new class, it only shows the content pane.
Is there a specific way of defining content in source that WindowBuilder is looking for?
Is there an error log I can look at?
Is there a way of running the parser outside Eclipse so I could see any exceptions thrown?
Thanks for help & suggestions.


This is the code that's causing the problems...

public class DestPredWindow extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JDesktopPane desktopPane;
private final JLabel lblNewLabel = new JLabel("Training Data");
private String theDirectory=".";

FileFilter trnFilter = new FileNameExtensionFilter("File Type","type");

public DestPredWindow() throws Exception {

}

/**
* Initialize the contents of the frame.
* @throws Exception
*/
public void initialize() throws Exception {

setBounds(100, 100, 1160, 861);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
desktopPane = new JDesktopPane();
getContentPane().add(desktopPane, BorderLayout.CENTER);

final JPanel panel = new JPanel();
panel.setBorder(new LineBorder(new Color(0, 0, 0), 2));
panel.setBounds(6, 6, 209, 255);
desktopPane.add(panel);
panel.add(lblNewLabel);

final JList trainingFilesList = new JList();
trainingFilesList.setModel(new DefaultListModel() {
String[] values = new String[] {"Select Training File(s)"};
public int getSize() {
return values.length;
}
public Object getElementAt(int index) {
return values[index];
}
});
panel.add(trainingFilesList);

JButton btnBrowse = new JButton("Browse");
btnBrowse.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {

}
});

btnBrowse.setToolTipText("browse for training data");
panel.add(btnBrowse);

JButton btnTrain = new JButton("Train");
btnTrain.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}

});
panel.add(btnTrain);

JSeparator separator = new JSeparator();
panel.add(separator);

JLabel lblNewLabel_1 = new JLabel("Testing Data");
panel.add(lblNewLabel_1);

final JList testFilesList = new JList();
testFilesList.setModel(new DefaultListModel() {
String[] values = new String[] {"Select Test File(s)"};
public int getSize() {
return values.length;
}
public Object getElementAt(int index) {
return values[index];
}
});
panel.add(testFilesList);


JButton btnBrowse_1 = new JButton("Browse");
btnBrowse_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

}
});

JSeparator separator_1 = new JSeparator();
separator_1.setOrientation(SwingConstants.VERTICAL);
panel.add(separator_1);

JSeparator separator_2 = new JSeparator();
separator_2.setOrientation(SwingConstants.VERTICAL);
panel.add(separator_2);
panel.add(btnBrowse_1);

JButton btnTest = new JButton("Test");
btnTest.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

}
});
panel.add(btnTest);

JButton btnNext = new JButton("Next");
btnNext.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
panel.add(btnNext);

JButton btnReset = new JButton("Reset");
btnReset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
panel.add(btnReset);

JPanel mapPanel = new TileMapPanel(new Dimension(724,799), this);
mapPanel.setBorder(new EtchedBorder(EtchedBorder.RAISED, null, null));
mapPanel.setBounds(215, 6, 939, 805);
desktopPane.add(mapPanel);

JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);

JMenu mnFile = new JMenu("File");
menuBar.add(mnFile);

JMenuItem mntmExit = new JMenuItem("Exit");
mntmExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.exit(-1);
}
});
mnFile.add(mntmExit);
}



/**
* Gets some files from a directory.
* Starts off in the directory given by 'theDirectory', returns all files selected
* from that directory
* @param ff a file filter describing what kinds of files should be selected
* @return the files that the user has selected
*/
File[] getFromFileDialog(FileFilter ff, Component par ) {
System.out.println("The Directory: \""+theDirectory+"\"");
JFileChooser fc = new JFileChooser(theDirectory);

File[] theFiles=null;

fc.addChoosableFileFilter(ff);
fc.setMultiSelectionEnabled(true);
int ret = fc.showOpenDialog(par);
if ( ret == JFileChooser.APPROVE_OPTION ) {
theFiles = fc.getSelectedFiles();
theDirectory = theFiles[0].getParent();
}

return theFiles;
}


}
Re: Error parsing refactored code [message #850355 is a reply to message #850026] Fri, 20 April 2012 01:23 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
When I add call of initialize() from constructor, it shows UI.
  public DestPredWindow() throws Exception {
    initialize();
  }


Konstantin Scheglov,
Google, Inc.
Re: Error parsing refactored code [message #851183 is a reply to message #850355] Fri, 20 April 2012 18:30 Go to previous messageGo to next message
david Missing name is currently offline david Missing nameFriend
Messages: 2
Registered: July 2009
Junior Member
That did the trick! I moved the initialize() code into the constructor, and the hand-coded UI has come back.
Re: Error parsing refactored code [message #851455 is a reply to message #851183] Sat, 21 April 2012 01:28 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 886
Registered: July 2009
Location: Boston, MA
Senior Member
Good. It sounds like WB is working correctly and as expected.
Re: Error parsing refactored code [message #861583 is a reply to message #851455] Sat, 28 April 2012 16:44 Go to previous message
Hans Mueller is currently offline Hans MuellerFriend
Messages: 28
Registered: April 2012
Junior Member
very good
Previous Topic:Custom composite problem - replicate/double copy of component
Next Topic:How to check is category created in "com.google.gdt.eclipse.designer.wbp-palette.xml"?
Goto Forum:
  


Current Time: Thu Nov 27 14:49:07 GMT 2014

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

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