diff options
3 files changed, 33 insertions, 40 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java index 13389fd5..6bd54d50 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java @@ -97,13 +97,6 @@ public class App { public static void main(final String[] args) { try { - UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException - | UnsupportedLookAndFeelException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - try { Config.init(); } catch (Exception e) { showAwtMessage("Error loading configuration", e); @@ -128,6 +121,15 @@ public class App { showAwtMessage("Error loading SWT libraries", e); return; } + // Setup swing + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + } catch (Exception e1) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception e) { + } + } // setup global thrift connection error handler before anything else // Set master server to use (TODO: make configurable via command line) diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java index 69e65e93..fd39c942 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageListWindow.java @@ -57,49 +57,40 @@ public class ImageListWindow extends ImageListWindowLayout { jtable.setModel(itm); // SWING TABLE STUFF jtable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { - @Override public void valueChanged(ListSelectionEvent e) { - ImageTableModel model = (ImageTableModel) jtable.getModel(); int rowIndex = jtable.getSelectedRow(); - ImageSummaryRead image = null; - if (rowIndex != -1) { - image = model.get(jtable.convertRowIndexToModel(jtable.getSelectedRow())); - LOGGER.debug(image.toString()); - } else { - LOGGER.error("No selection!"); - } - final ImageSummaryRead finalImage = image; + if (rowIndex == -1) + return; + ImageTableModel model = (ImageTableModel) jtable.getModel(); + final ImageSummaryRead image = model.get(jtable.convertRowIndexToModel(rowIndex)); + LOGGER.debug(image); if (image == null) return; Gui.asyncExec(new Runnable() { public void run() { - updateDetailPane(finalImage); + updateDetailPane(image); } }); } }); jtable.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent me) { + @Override + public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { - // your valueChanged overridden method - ImageTableModel model = (ImageTableModel) jtable.getModel(); int rowIndex = jtable.getSelectedRow(); - ImageSummaryRead image = null; - if (rowIndex != -1) { - image = model.get(jtable.convertRowIndexToModel(rowIndex)); - LOGGER.debug(image.toString()); - } else { - LOGGER.error("No selection!"); - } - final ImageSummaryRead finalImage = image; - if (finalImage == null) + if (rowIndex == -1) + return; + ImageTableModel model = (ImageTableModel) jtable.getModel(); + final ImageSummaryRead image = model.get(jtable.convertRowIndexToModel(rowIndex)); + LOGGER.debug(image); + if (image == null) return; Gui.asyncExec(new Runnable() { public void run() { ImageDetailsWindow popup = MainWindow.openPopup(ImageDetailsWindow.class, true, false); if (popup != null) - popup.setImage(finalImage.getImageBaseId()); + popup.setImage(image.getImageBaseId()); } }); } @@ -109,12 +100,15 @@ public class ImageListWindow extends ImageListWindowLayout { }); // filter the objects in the table depending on the search field searchTextField.addKeyListener(new KeyAdapter() { + @Override public void keyReleased(KeyEvent ke) { - Gui.asyncExec(new Runnable() { + final String term = searchTextField.getText(); + SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { RowFilter<ImageTableModel, Object> filter = null; try { - filter = RowFilter.regexFilter(".*" + searchTextField.getText() + ".*"); + filter = RowFilter.regexFilter(".*" + term + ".*"); } catch (java.util.regex.PatternSyntaxException e) { return; } @@ -192,7 +186,7 @@ public class ImageListWindow extends ImageListWindowLayout { refreshList(false); } - public void deleteCallback(ImageSummaryRead image, Throwable t) { + private void deleteCallback(ImageSummaryRead image, Throwable t) { if (t == null) { Gui.showMessageBox(getShell(), "Deleted image with UUID '" + image + "'.", MessageType.INFO, LOGGER, t); @@ -201,7 +195,7 @@ public class ImageListWindow extends ImageListWindowLayout { } } - public void updateDetailPane(ImageSummaryRead image) { + private void updateDetailPane(ImageSummaryRead image) { // -- Set details -- // set the image name setFieldText(imageSelectedNameLabel, image.getImageName()); @@ -227,6 +221,7 @@ public class ImageListWindow extends ImageListWindowLayout { templateInfo.setText("Nein"); } } + private void setFieldText(Text control, String content) { if (content == null) { control.setText("<null>"); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java index bd8a6728..bad50d23 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java @@ -121,11 +121,7 @@ public abstract class ImageListWindowLayout extends CompositePage { final Frame frame = SWT_AWT.new_Frame(comp); SwingUtilities.invokeLater(new Runnable() { public void run() { - try { - System.setProperty("sun.awt.noerasebackground", "true"); - } catch (NoSuchMethodError error) { - LOGGER.error("BAD"); - } + System.setProperty("sun.awt.noerasebackground", "true"); // auto-resize-on-scroll http://stackoverflow.com/questions/17858132/automatically-adjust-jtable-column-to-fit-content JPanel panel = new JPanel(new BorderLayout()); frame.add(panel); |