Eclipse Mars crashes when using Windowbuilder

After some time, I started work on the project again from the beginning of this year. This application was built around a graphical interface that was created using the Eclipse ADT Windowbuilder. Now that I want to view my GUI class again using the window builder, Eclipse starts parsing and just falls into a “refreshing” state. Here is the crash message I get in the terminal:

Exception in thread "Thread-16" org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(SWT.java:4397) at org.eclipse.swt.SWT.error(SWT.java:4312) at org.eclipse.swt.SWT.error(SWT.java:4283) at org.eclipse.swt.widgets.Widget.error(Widget.java:481) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:419) at org.eclipse.swt.widgets.Control.isVisible(Control.java:3620) at org.eclipse.swt.widgets.ProgressBar.timerProc(ProgressBar.java:283) at org.eclipse.swt.widgets.Display.windowTimerProc(Display.java:4587) [xcb] Unknown sequence number while processing queue [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called [xcb] Aborting, sorry about that. java: ../../src/xcb_io.c:274: poll_for_event: Zusicherung »!xcb_xlib_threads_sequence_lost« nicht erfüllt. 

So far, I have no idea how to fix this. Windowbuilder has been working with this application a few months ago.

EDIT:

Here is the class for the graphical interface.

 public class DBDatabaseSystem implements Serializable { public static JFrame mainGui; public static Config config; private static final long serialVersionUID = -5614180535012598751L; private static final String programVersion = "20.07.2015-001"; private static JTable table; private static JSplitPane splitPane; private static DefaultTableModel model; private static SequentialNumber sequentialNumber = new SequentialNumber(); private static boolean unsavedChanges = false; private static boolean filechooserOpen = false; private static JList<String> infoList = new JList<String>(); private static DefaultListModel<String> infoListModel = new DefaultListModel<String>(); private static JScrollPane scrollPane_1 = new JScrollPane(); private static String adminEmailLink = ""; public static void main(String[] args) { long startTime = System.nanoTime(); config = new Config(); config.loadConfig(); mainGui = new JFrame(); mainGui.setIconImage(Toolkit.getDefaultToolkit() .getImage("1426088835_Database-Cloud-512.png")); mainGui.setTitle("DB Baumaßnahmen Datenbank " + programVersion); mainGui.setResizable(false); mainGui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainGui.setSize(1360, 645); mainGui.setLocationRelativeTo(null); // center window mainGui.addWindowListener(new WindowAdapter() { // event listener for // window close action @Override public void windowClosing(WindowEvent e) { if (config.getDatabaseFile().contains(".dbd")) { if (unsavedChanges == true) { int selection = JOptionPane.showConfirmDialog(mainGui, "Es sind noch ungesicherte Änderungen in der Datenbank vorhanden. Möchten sie diese vor dem Beenden speichern?", "Nicht gespiecherte Änderungen an der Datenbank", JOptionPane.YES_NO_OPTION); if (selection == 0) { saveModel(new File(config.getDatabaseFile())); } } } config.saveConfig(); } }); JMenuBar menuBar = new JMenuBar(); mainGui.setJMenuBar(menuBar); JMenu menuDatabase = new JMenu("Datenbank"); menuBar.add(menuDatabase); JMenu mnEe = new JMenu("Exportieren"); menuBar.add(mnEe); JMenuItem mntmNewMenuItem = new JMenuItem("Speicherpfad für Aufträge auswählen..."); mnEe.add(mntmNewMenuItem); mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fc.showOpenDialog(mainGui) == JFileChooser.APPROVE_OPTION && fc.getSelectedFile().toString() != "") { // add trailing / to pdf files config.setPdfExportPath(fc.getSelectedFile().getAbsolutePath() + "/"); } } }); JMenuItem menuButtonExportTasks = new JMenuItem("Gewählte Aufträge exportieren"); mnEe.add(menuButtonExportTasks); menuButtonExportTasks.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (table.getSelectedRow() != -1) { ExportTaskToPDF.exportTaskToPdf("Durchzuführende Baumaßnahmen", getSelectedTasksAsList()); ExportTaskToPDF.openExportPath(); } else { addWarning("Es muss mindestens ein Auftrag zum Export ausgewählt sein."); } } }); JMenu menuView = new JMenu("Ansicht"); menuBar.add(menuView); JMenu menuHelp = new JMenu("Hilfe"); menuBar.add(menuHelp); JMenuItem menuItemNewDatabase = new JMenuItem("Neue Datenbank anlegen..."); menuDatabase.add(menuItemNewDatabase); menuItemNewDatabase.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setDatabasePath(); createEmptyModel(); table.setModel(model); initColumModel(); } }); JSeparator seperatorMenuDatabase = new JSeparator(); menuDatabase.add(seperatorMenuDatabase); JMenuItem MenuItemLoadDatabase = new JMenuItem("Datenbank öffnen..."); menuDatabase.add(MenuItemLoadDatabase); MenuItemLoadDatabase.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { filechooserOpen = true; setDatabasePath(); if (config.getDatabaseFile().contains(".dbd")) { loadModel(new File(config.getDatabaseFile())); } } }); JMenuItem menuItemSaveDatabase = new JMenuItem("Datenbank speichern"); menuDatabase.add(menuItemSaveDatabase); menuItemSaveDatabase.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { saveModel(new File(config.getDatabaseFile())); } }); JMenuItem menuItemSaveDatabaseAs = new JMenuItem("Datenbank speichern unter..."); menuDatabase.add(menuItemSaveDatabaseAs); menuItemSaveDatabaseAs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setDatabasePath(); saveModel(new File(config.getDatabaseFile())); } }); JMenuItem menuItemResetView = new JMenuItem("Ansicht zurücksetzen"); menuView.add(menuItemResetView); final JCheckBoxMenuItem chckbxmntmFrameAlwaysOnTop = new JCheckBoxMenuItem("Fenster immer im Vordergrund"); menuView.add(chckbxmntmFrameAlwaysOnTop); chckbxmntmFrameAlwaysOnTop.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (chckbxmntmFrameAlwaysOnTop.isSelected()) { mainGui.setAlwaysOnTop(true); } else { mainGui.setAlwaysOnTop(false); } } }); menuItemResetView.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { initColumModel(); } }); JMenuItem menuItemAbout = new JMenuItem("Über..."); menuHelp.add(menuItemAbout); menuItemAbout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(mainGui, "<html>Programm: DB Baumaßnahmen<br><br>Version: " + programVersion + "<br><br>Entwickler: <br><br>Support: " + adminEmailLink, "Über", JOptionPane.INFORMATION_MESSAGE); } }); JMenuItem menuItemCheckUpdates = new JMenuItem("Auf Updates prüfen..."); menuItemCheckUpdates.setEnabled(false); menuHelp.add(menuItemCheckUpdates); mainGui.getContentPane().setLayout(new BorderLayout(0, 0)); JPanel panel = new JPanel(); mainGui.getContentPane().add(panel); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); splitPane = new JSplitPane(); splitPane.setEnabled(false); splitPane.setResizeWeight(0.55); splitPane.setAlignmentY(Component.CENTER_ALIGNMENT); splitPane.setAlignmentX(Component.CENTER_ALIGNMENT); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); panel.add(splitPane); JScrollPane scrollPane = new JScrollPane(); splitPane.setLeftComponent(scrollPane); table = new JTable(); table.getTableHeader().setReorderingAllowed(false); table.setAutoCreateRowSorter(true); table.setRowHeight(20); table.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { unsavedChanges = true; // catch if there was a change } }); if (config.getDatabaseFile().contains(".dbd")) { loadModel(new File(config.getDatabaseFile())); // autoload table // from disk if // possible initColumModel(); // reset table layout to defaults } else { createEmptyModel(); table.setModel(model); initColumModel(); } scrollPane.setViewportView(table); JPopupMenu popupMenu = new JPopupMenu(); addPopup(table, popupMenu); JMenuItem mntmAuftragHinzufgen = new JMenuItem("Auftrag hinzufügen"); popupMenu.add(mntmAuftragHinzufgen); mntmAuftragHinzufgen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addRow(); } }); JMenuItem mntmNewMenuItem_4 = new JMenuItem("Auftrag entfernen"); popupMenu.add(mntmNewMenuItem_4); mntmNewMenuItem_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { removeSelectedRows(); } }); JPanel panel_1 = new JPanel(); splitPane.setRightComponent(panel_1); panel_1.setLayout(null); JButton buttonNewTask = new JButton("Neuer Auftrag"); buttonNewTask.setBounds(12, 12, 174, 25); panel_1.add(buttonNewTask); buttonNewTask.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addRow(); } }); JButton buttonDeleteTask = new JButton("Auftrag entfernen"); buttonDeleteTask.setBounds(12, 49, 174, 25); panel_1.add(buttonDeleteTask); buttonDeleteTask.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { removeSelectedRows(); } }); JButton buttonPrintTask = new JButton("Auftrag exportieren"); buttonPrintTask.setBounds(198, 12, 174, 25); panel_1.add(buttonPrintTask); scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane_1.setBounds(745, 12, 600, 65); panel_1.add(scrollPane_1); infoList.setForeground(Color.BLACK); // add info panel (list) containing runtime information infoList.setModel(infoListModel); scrollPane_1.setViewportView(infoList); buttonPrintTask.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ExportTaskToPDF.exportTaskToPdf("Durchzuführende Baumaßnahmen", getSelectedTasksAsList()); } }); // scroll down to latest element table.scrollRectToVisible((table.getCellRect(table.getRowCount() - 1, 0, true))); mainGui.setVisible(true); // add startup time to infoList long endTime = System.nanoTime(); addInfo(((endTime - startTime) / 1000000) + " ms Startzeit"); } public static void initColumModel() { table.getColumnModel().getColumn(0).setResizable(false); table.getColumnModel().getColumn(0).setPreferredWidth(50); table.getColumnModel().getColumn(1).setResizable(false); table.getColumnModel().getColumn(1).setPreferredWidth(50); table.getColumnModel().getColumn(2).setResizable(false); table.getColumnModel().getColumn(2).setPreferredWidth(81); table.getColumnModel().getColumn(3).setResizable(false); table.getColumnModel().getColumn(3).setPreferredWidth(81); table.getColumnModel().getColumn(4).setPreferredWidth(81); table.getColumnModel().getColumn(5).setPreferredWidth(134); table.getColumnModel().getColumn(6).setPreferredWidth(123); table.getColumnModel().getColumn(7).setPreferredWidth(95); table.getColumnModel().getColumn(8).setPreferredWidth(95); table.getColumnModel().getColumn(9).setPreferredWidth(226); table.getColumnModel().getColumn(10).setResizable(false); table.getColumnModel().getColumn(10).setPreferredWidth(300); table.getColumnModel().getColumn(11).setResizable(false); table.getColumnModel().getColumn(11).setPreferredWidth(102); } public static void saveModel(File filename) { FileOutputStream fos = null; ObjectOutputStream out = null; if (!config.getDatabaseFile().contains(".dbd")) { setDatabasePath(); filename = new File(config.getDatabaseFile()); } try { table.clearSelection(); // undo all selections to prevent user from // editing while saving if (table.isEditing()) { // prevent saving when user is editing a cell table.getCellEditor().stopCellEditing(); } fos = new FileOutputStream(filename); out = new ObjectOutputStream(fos); table.setModel(new DefaultTableModel()); // detach model from table prior serializing out.writeObject(model); table.setModel(model); // re-attach table model initColumModel(); // set layout again out.writeObject(sequentialNumber); } catch (Exception errWrite) { errWrite.printStackTrace(); System.out.println("Fehler beim speichern der Datenbank"); addError("Fehler beim speichern der Datenbank"); } finally { try { fos.close(); out.close(); unsavedChanges = false; } catch (Exception errClose) { errClose.printStackTrace(); System.out.println("Fehler beim Schließen der Dateiströme"); addError("Fehler beim Schließen der Dateiströme"); } } } public static void loadModel(File filename) { FileInputStream fis = null; ObjectInputStream ois = null; if (!config.getDatabaseFile().contains(".dbd")) { setDatabasePath(); filename = new File(config.getDatabaseFile()); } try { fis = new FileInputStream(filename); ois = new ObjectInputStream(fis); // TODO Lock database for application runtime to avoid conflicts // with other clients model = (DefaultTableModel) ois.readObject(); sequentialNumber = (SequentialNumber) ois.readObject(); table.setModel(model); // set the table model to the just loaded // one, this makes data appear initColumModel(); // make sure the layout fits ois.close(); fis.close(); addInfo(model.getRowCount() + " Datensätze erfolgreich geladen"); } catch (FileNotFoundException errNotFound) { addError("Datenbank konnte nicht gefunden werden, öffne leere Datenbank"); errNotFound.printStackTrace(); createEmptyModel(); table.setModel(model); } catch (IOException errIO) { System.out.println("Datei konnte nicht gelesen werden (IO Exception)"); errIO.printStackTrace(); if (filechooserOpen == true) { addError("Fehler beim Lesen der Datenbank! (IO Exception)"); } else { addError("Fehler beim Lesen der Datenbank! (IO Exception) Öffne jetzt mit leerer Datenbank!"); createEmptyModel(); table.setModel(model); } } catch (ClassNotFoundException errClassNotFound) { System.out.println("Klasse zum Deserialisieren nicht gefunden"); errClassNotFound.printStackTrace(); addError("Fehler beim Lesen der Datenbank! (Datenbank veraltet). Erstelle jetzt neue Datenbank!"); createEmptyModel(); table.setModel(model); } } public static void setDatabasePath() { JFileChooser fc = new JFileChooser(); int fcRetrunValue = fc.showSaveDialog(fc); if ((fcRetrunValue != JFileChooser.ABORT && fcRetrunValue != JFileChooser.CANCEL_OPTION) && fc.getSelectedFile().toString().contains(".dbd")) { do { JOptionPane.showMessageDialog(mainGui, "Bitte wählen Sie das richtige Dateiformat (.dbd)", "", JOptionPane.ERROR_MESSAGE); int fcReturnValueInLoop = fc.showSaveDialog(fc); if (fcReturnValueInLoop == JFileChooser.ABORT || fcReturnValueInLoop == JFileChooser.CANCEL_OPTION) { break; // prevent infinite file chooser } else if (fc.getSelectedFile().toString().contains(".dbd")) { config.setDatabaseFile(fc.getSelectedFile().toString()); break; } } while (!fc.getSelectedFile().toString().contains(".dbd")); } else { if (fc.getSelectedFile().toString() != "" && fc.getSelectedFile().toString().contains(".dbd")) { config.setDatabaseFile(fc.getSelectedFile().toString()); } } } public static void addRow() { // get current date String timeStamp = new SimpleDateFormat("dd.MM.yyyy").format(Calendar.getInstance().getTime()); // sequential number represents some kind of primary key in the database sequentialNumber.increase(); model.addRow(new Object[] { sequentialNumber.getNumber(), "FB", null, null, timeStamp, null, null, null, null, null, null, null }); // scroll to last row table.scrollRectToVisible((table.getCellRect(table.getRowCount() - 1, 0, true))); unsavedChanges = true; // ask upon close to save changes } public static void removeSelectedRows() { // create int array that contains the row numbers of the user selection int selectedRows[] = table.getSelectedRows(); for (int i = 0; i < selectedRows.length; i++) { // [i] - i to take into account that the lines shift while removing model.removeRow(selectedRows[i] - i); unsavedChanges = true; } } /** * Initialize an empty table with default settings */ private static void createEmptyModel() { model = new DefaultTableModel(new Object[][] {}, new String[] { "Lfd. Nr.", "FB Nr.", "Auftr. / Meld. Nr.", "Betra Nr.", "Datum", "Bahnhof", "Str. Km.", "Sprz.", "Arb. Zeit", "Mitarbeiter", "Auftrag / Objekt(e)", "Abgeschlossen" }) { private static final long serialVersionUID = 3701695679244364045L; @SuppressWarnings("rawtypes") Class[] columnTypes = new Class[] { Integer.class, String.class, Long.class, Long.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, Boolean.class }; @SuppressWarnings({ "unchecked", "rawtypes" }) public Class getColumnClass(int columnIndex) { return columnTypes[columnIndex]; } }; sequentialNumber.reset(); } public static ArrayList<Object[]> getSelectedTasksAsList() { ArrayList<Object[]> tasks = new ArrayList<Object[]>(); if (table.getSelectedRowCount() > 0) { // check if there are selected // rows int[] selectedRows = table.getSelectedRows(); // get a list of // selected rows for (int i = 0; i < selectedRows.length; i++) { // print all // selected tasks Object[] taskAsArray = new Object[table.getColumnCount() - 1]; for (int j = 0; j < table.getColumnCount() - 1; j++) { // add all columns from currently processed row to Object // array if ((table.getValueAt(table.convertRowIndexToModel(selectedRows[i]), // avoid null pointer exception if column is empty table.convertColumnIndexToModel(j))) != null) { taskAsArray[j] = (table.getValueAt(table.convertRowIndexToModel(selectedRows[i]), table.convertColumnIndexToModel(j))); } else taskAsArray[j] = new String(""); } tasks.add(taskAsArray); } } return tasks; } public void restart() { // TODO implement function to restart app } public void updateApp() { // TODO implement function to self-update the application } @SuppressWarnings("unused") private void compareDates(String date1, String date2) { DateTimeFormatter formatter = DateTimeFormat.forPattern("dd.MM.yyyy"); LocalDate localDate1 = formatter.parseLocalDate(date1); LocalDate localDate2 = formatter.parseLocalDate(date2); if (localDate1.isAfter(localDate2)) { System.out.println("date1 comes after date2"); } else { System.out.println("date1 comes before date2"); } } private static void addPopup(Component component, final JPopupMenu popup) { component.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { showMenu(e); } } private void showMenu(MouseEvent e) { popup.show(e.getComponent(), e.getX(), e.getY()); } }); } public static void addInfo(String message) { infoList.setFont(new Font("Dialog", Font.PLAIN, 12)); infoListModel.addElement("[INFO]: " + message); // make sure last index is visible else scroll accordingly infoList.ensureIndexIsVisible(infoList.getModel().getSize() - 1); } public static void addWarning(String message) { infoList.setFont(new Font("Dialog", Font.PLAIN, 12)); infoListModel.addElement("[WARN]: " + message); infoList.ensureIndexIsVisible(infoList.getModel().getSize() - 1); } public static void addError(String message) { infoList.setFont(new Font("Dialog", Font.PLAIN, 12)); infoListModel.addElement("[ERROR]: " + message); infoList.ensureIndexIsVisible(infoList.getModel().getSize() - 1); } } 
+5
source share

All Articles