Permalink
Browse files

lambdification (mostly via Netbeans hints)

git-svn-id: https://svn.java.net/svn/worldclock-application~svn/trunk@216 b57468bd-8988-41ea-ecec-821d63db5d79
  • Loading branch information...
Ludovic HOCHET
Ludovic HOCHET committed May 21, 2013
1 parent 47d3a73 commit 63324259b7b561ba2f7f4d58210e701d3114dc2f
@@ -52,14 +52,10 @@ private void jbInit() throws Exception
flowLayout1.setAlignment(FlowLayout.LEFT);
tfPath.setColumns(30);
btnBrowse.setText("...");
btnBrowse.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
btnBrowse_actionPerformed(e);
}
});
btnBrowse.addActionListener((ActionEvent e) ->
{
btnBrowse_actionPerformed(e);
});
this.add(jLabel1);
this.add(tfPath);
this.add(btnBrowse);
@@ -169,57 +169,41 @@ private static PopupMenu createPopup()
PopupMenu popup = new PopupMenu();
MenuItem mnuiShow = new MenuItem(res.getString("SHOW_LBL"));
mnuiShow.addActionListener(new ActionListener()
mnuiShow.addActionListener((ActionEvent e) ->
{
@Override
public void actionPerformed(ActionEvent e)
{
showWindow();
}
showWindow();
});
popup.add(mnuiShow);
MenuItem mnuiShowOptions = new MenuItem(res.getString("OPTIONS_LBL"));
mnuiShowOptions.addActionListener(new ActionListener()
mnuiShowOptions.addActionListener((ActionEvent e) ->
{
@Override
public void actionPerformed(ActionEvent e)
PropsManager props = PropsManager.getInstance();
ConfigPanel panel = new ConfigPanel();
panel.setConfigPath(props.getConfigPath());
if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(null, panel,
res.getString("OPTIONS_LBL"), JOptionPane.OK_CANCEL_OPTION))
{
PropsManager props = PropsManager.getInstance();
ConfigPanel panel = new ConfigPanel();
panel.setConfigPath(props.getConfigPath());
if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(null, panel,
res.getString("OPTIONS_LBL"), JOptionPane.OK_CANCEL_OPTION))
{
props.setConfigPath(panel.getConfigPath());
props.save();
frame = null;
}
props.setConfigPath(panel.getConfigPath());
props.save();
frame = null;
}
});
popup.add(mnuiShowOptions);
MenuItem mnuiAbout = new MenuItem(res.getString("ABOUT_LBL"));
mnuiAbout.addActionListener(new ActionListener()
mnuiAbout.addActionListener((ActionEvent e) ->
{
@Override
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null, APP_NAME + " " + APP_VERSION, res.getString("ABOUT_LBL"), JOptionPane.INFORMATION_MESSAGE);
}
JOptionPane.showMessageDialog(null, APP_NAME + " " + APP_VERSION, res.getString("ABOUT_LBL"), JOptionPane.INFORMATION_MESSAGE);
});
popup.add(mnuiAbout);
popup.addSeparator();
MenuItem mnuiExit = new MenuItem(res.getString("EXIT_LBL"));
mnuiExit.addActionListener(new ActionListener()
mnuiExit.addActionListener((ActionEvent e) ->
{
@Override
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
System.exit(0);
});
popup.add(mnuiExit);
@@ -102,11 +102,10 @@ public void loadConfig(URL url)
public void paintComponent(Graphics graphics)
{
board.paintComponent(graphics);
for (City city : cities)
cities.stream().forEach((city) ->
{
city.paint(graphics, width, height, true);
}
});
}
public void updateSize(int newWidth, int newHeight)
@@ -9,7 +9,6 @@
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.Timer;
import javax.swing.Icon;
@@ -32,74 +31,59 @@ public EditorView(SingleFrameApplication app)
// status bar initialization - message timeout, idle icon and busy animation, etc
ResourceMap resourceMap = getResourceMap();
int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
messageTimer = new Timer(messageTimeout, new ActionListener()
messageTimer = new Timer(messageTimeout, (ActionEvent e) ->
{
@Override
public void actionPerformed(ActionEvent e)
{
statusMessageLabel.setText("");
}
statusMessageLabel.setText("");
});
messageTimer.setRepeats(false);
int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
for (int i = 0; i < busyIcons.length; i++)
{
busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
}
busyIconTimer = new Timer(busyAnimationRate, new ActionListener()
busyIconTimer = new Timer(busyAnimationRate, (ActionEvent e) ->
{
@Override
public void actionPerformed(ActionEvent e)
{
busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
}
busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
});
idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);
// connecting action tasks to status bar via TaskMonitor
TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener()
taskMonitor.addPropertyChangeListener((java.beans.PropertyChangeEvent evt) ->
{
@Override
public void propertyChange(java.beans.PropertyChangeEvent evt)
String propertyName = evt.getPropertyName();
switch (propertyName)
{
String propertyName = evt.getPropertyName();
switch (propertyName)
{
case "started":
if (!busyIconTimer.isRunning())
{
statusAnimationLabel.setIcon(busyIcons[0]);
busyIconIndex = 0;
busyIconTimer.start();
}
progressBar.setVisible(true);
progressBar.setIndeterminate(true);
break;
case "done":
busyIconTimer.stop();
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);
progressBar.setValue(0);
break;
case "message":
String text = (String) (evt.getNewValue());
statusMessageLabel.setText((text == null) ? "" : text);
messageTimer.restart();
break;
case "progress":
int value = (Integer) (evt.getNewValue());
progressBar.setVisible(true);
progressBar.setIndeterminate(false);
progressBar.setValue(value);
break;
}
case "started":
if (!busyIconTimer.isRunning())
{
statusAnimationLabel.setIcon(busyIcons[0]);
busyIconIndex = 0;
busyIconTimer.start();
}
progressBar.setVisible(true);
progressBar.setIndeterminate(true);
break;
case "done":
busyIconTimer.stop();
statusAnimationLabel.setIcon(idleIcon);
progressBar.setVisible(false);
progressBar.setValue(0);
break;
case "message":
String text = (String) (evt.getNewValue());
statusMessageLabel.setText((text == null) ? "" : text);
messageTimer.restart();
break;
case "progress":
int value = (Integer) (evt.getNewValue());
progressBar.setVisible(true);
progressBar.setIndeterminate(false);
progressBar.setValue(value);
break;
}
});
}
@@ -228,30 +228,20 @@ private void btnFindActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:e
{//GEN-HEADEREND:event_btnFindActionPerformed
// TODO add your handling code here:
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
SwingUtilities.invokeLater(new Runnable()
SwingUtilities.invokeLater(() ->
{
@Override
public void run()
{
model.update(GeonamesWSWrapper.getGeonames(tfCity.getText(), (Integer) spMax.getValue()));
setCursor(Cursor.getDefaultCursor());
}
model.update(GeonamesWSWrapper.getGeonames(tfCity.getText(), (Integer) spMax.getValue()));
setCursor(Cursor.getDefaultCursor());
});
}//GEN-LAST:event_btnFindActionPerformed
private void tfCityActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_tfCityActionPerformed
{//GEN-HEADEREND:event_tfCityActionPerformed
// TODO add your handling code here:
SwingUtilities.invokeLater(new Runnable()
SwingUtilities.invokeLater(() ->
{
@Override
public void run()
{
btnFind.doClick();
}
btnFind.doClick();
});
}//GEN-LAST:event_tfCityActionPerformed
@@ -23,15 +23,14 @@ public static void main(String[] args)
{
try
{
// for (Geoname g : getGeonamesFromFile(new File("geonames.xml")))
for (Geoname g : getGeonames("Paris", 20))
getGeonames("Paris", 20).stream().forEach((g) ->
{
System.out.println("name: " + g.getName());
System.out.println("lat: " + g.getLat());
System.out.println("lng: " + g.getLng());
System.out.println("country: " + g.getCountryName());
System.out.println("timezone: " + g.getTimezone());
}
});
}
catch (Exception ex)
{
Oops, something went wrong.

0 comments on commit 6332425

Please sign in to comment.