Changeset 24559 in osm for applications/editors


Ignore:
Timestamp:
2010-12-03T16:19:59+01:00 (14 years ago)
Author:
postfix
Message:

first steps to use the layers of josm

Location:
applications/editors/josm/plugins/smed
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed/plugs/harbour/src/harbour/Harbour.java

    r24518 r24559  
    88import javax.swing.ImageIcon;
    99import javax.swing.JComponent;
     10
     11import org.openstreetmap.josm.Main;
     12import org.openstreetmap.josm.gui.MapView;
    1013
    1114import smed.plug.ifc.SmedPluggable;
     
    2124        @Override
    2225        public boolean start() {
    23                 // TODO Auto-generated method stub
    2426                return false;
    2527        }
     
    3335        @Override
    3436        public boolean hasFocus() {
    35                 // TODO Auto-generated method stub
    36                 return false;
     37                Main.map.mapView.addPropertyChangeListener(harbour);
     38                MapView.addLayerChangeListener(harbour);
     39                return true;
    3740        }
    3841
    3942        @Override
    4043        public boolean lostFocus() {
    41                 // TODO Auto-generated method stub
    42                 return false;
     44                Main.map.mapView.removePropertyChangeListener(harbour);
     45                MapView.removeLayerChangeListener(harbour);
     46                return true;
    4347        }
    4448
  • applications/editors/josm/plugins/smed/plugs/harbour/src/harbour/dialogs/HarbourAction.java

    r24540 r24559  
    1010import javax.swing.JLabel;
    1111import java.awt.Font;
     12import java.awt.event.ComponentEvent;
     13import java.awt.event.ComponentListener;
     14import java.beans.PropertyChangeEvent;
     15import java.beans.PropertyChangeListener;
     16
    1217import javax.swing.JComboBox;
    1318import javax.swing.ImageIcon;
    1419import javax.swing.JToggleButton;
    1520
    16 public class HarbourAction {
    17 
    18         private JPanel harbourPanel = null;  //  @jve:decl-index=0:visual-constraint="68,31"
     21import org.openstreetmap.josm.Main;
     22import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
     23import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
     24import org.openstreetmap.josm.gui.layer.Layer;
     25import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     26
     27public class HarbourAction implements PropertyChangeListener, LayerChangeListener, EditLayerChangeListener, ComponentListener {
     28
     29        private JPanel harbourPanel = null;
    1930        private JButton comButton = null;
    2031        private JButton restButton = null;
     
    4758        private JButton queryjButton = null;
    4859        private JToggleButton chartButton = null;
     60        private JPanel curPanel = null;
     61       
    4962        public HarbourAction() {
    5063                panelGeneral= new PanelGeneral();
    5164                panelGeneral.setBounds(new Rectangle(2, 56, 330, 270));
    5265                panelGeneral.setVisible(true);
     66                curPanel = panelGeneral;
    5367               
    5468                panelLimits = new PanelLimits();
     
    7791                if (harbourPanel == null) {
    7892                        regLabel = new JLabel();
    79                         regLabel.setBounds(new Rectangle(90, 32, 45, 20));
     93                        regLabel.setBounds(new Rectangle(93, 32, 54, 20));
    8094                        regLabel.setText("Region:");
    8195                        noLabel1 = new JLabel();
    82                         noLabel1.setBounds(new Rectangle(200, 32, 26, 20));
     96                        noLabel1.setBounds(new Rectangle(205, 32, 26, 20));
    8397                        noLabel1.setText("Nr.:");
    8498                        countryLabel = new JLabel();
    85                         countryLabel.setBounds(new Rectangle(2, 32, 32, 20));
     99                        countryLabel.setBounds(new Rectangle(2, 32, 40, 20));
    86100                        countryLabel.setText("Land:");
    87101                        typeLabel = new JLabel();
    88                         typeLabel.setBounds(new Rectangle(289, 32, 30, 20));
     102                        typeLabel.setBounds(new Rectangle(289, 32, 39, 20));
    89103                        typeLabel.setText("Type:");
    90104                        queryLabel = new JLabel();
    91                         queryLabel.setBounds(new Rectangle(201, 334, 72, 15));
     105                        queryLabel.setBounds(new Rectangle(201, 334, 78, 15));
    92106                        queryLabel.setFont(new Font("Dialog", Font.PLAIN, 12));
    93107                        queryLabel.setText("Suche nach:");
    94108                        setLabel = new JLabel();
    95                         setLabel.setBounds(new Rectangle(2, 330, 60, 21));
     109                        setLabel.setBounds(new Rectangle(2, 330, 67, 21));
    96110                        setLabel.setFont(new Font("Dialog", Font.PLAIN, 12));
    97111                        setLabel.setText("Datensatz:");
     
    157171                                        panelGeneral.setVisible(true);
    158172                                        chartButton.setEnabled(false);
     173                                        curPanel = panelGeneral;
    159174                                }
    160175                        });
     
    182197                                        panelLimits.setVisible(true);
    183198                                        chartButton.setEnabled(false);
     199                                        curPanel = panelLimits;
    184200                                }
    185201                        });
     
    207223                                        panelServices.setVisible(true);
    208224                                        chartButton.setEnabled(false);
     225                                        curPanel = panelServices;
    209226                                }
    210227                        });
     
    232249                                        panelEnv.setVisible(true);
    233250                                        chartButton.setEnabled(true);
     251                                        curPanel = panelEnv;
    234252                                }
    235253                        });
     
    257275                                        panelRelations.setVisible(true);
    258276                                        chartButton.setEnabled(true);
     277                                        curPanel = panelRelations;
    259278                                }
    260279                        });
     
    284303                if (fastbackButton == null) {
    285304                        fastbackButton = new JButton();
    286                         fastbackButton.setBounds(new Rectangle(62, 330, 20, 20));
     305                        fastbackButton.setBounds(new Rectangle(72, 330, 20, 20));
    287306                }
    288307                return fastbackButton;
     
    297316                if (backButton == null) {
    298317                        backButton = new JButton();
    299                         backButton.setBounds(new Rectangle(81, 330, 20, 20));
     318                        backButton.setBounds(new Rectangle(90, 330, 20, 20));
    300319                }
    301320                return backButton;
     
    310329                if (setTextField == null) {
    311330                        setTextField = new JTextField();
    312                         setTextField.setBounds(new Rectangle(101, 329, 60, 23));
     331                        setTextField.setBounds(new Rectangle(110, 329, 51, 23));
    313332                        setTextField.setText("");
    314333                }
     
    350369                if (typComboBox == null) {
    351370                        typComboBox = new JComboBox();
    352                         typComboBox.setBounds(new Rectangle(323, 28, 72, 25));
     371                        typComboBox.setBounds(new Rectangle(328, 28, 69, 25));
    353372                }
    354373                return typComboBox;
     
    363382                if (countryComboBox == null) {
    364383                        countryComboBox = new JComboBox();
    365                         countryComboBox.setBounds(new Rectangle(36, 29, 50, 25));
     384                        countryComboBox.setBounds(new Rectangle(42, 29, 50, 25));
    366385                }
    367386                return countryComboBox;
     
    376395                if (noTextField == null) {
    377396                        noTextField = new JTextField();
    378                         noTextField.setBounds(new Rectangle(225, 29, 60, 25));
     397                        noTextField.setBounds(new Rectangle(230, 29, 60, 25));
    379398                        noTextField.setText("");
    380399                }
     
    390409                if (regTextField == null) {
    391410                        regTextField = new JTextField();
    392                         regTextField.setBounds(new Rectangle(135, 29, 60, 25));
     411                        regTextField.setBounds(new Rectangle(145, 29, 60, 25));
    393412                }
    394413                return regTextField;
     
    409428                        queryComboBox.addItem("Type");
    410429                        queryComboBox.addItem("Query");
    411                         queryComboBox.setBounds(new Rectangle(272, 331, 86, 20));
     430                        queryComboBox.setBounds(new Rectangle(279, 331, 86, 20));
    412431                }
    413432                return queryComboBox;
     
    422441                if (queryjButton == null) {
    423442                        queryjButton = new JButton();
    424                         queryjButton.setBounds(new Rectangle(364, 330, 28, 20));
     443                        queryjButton.setBounds(new Rectangle(364, 331, 28, 20));
    425444                }
    426445                return queryjButton;
     
    435454                if (chartButton == null) {
    436455                        chartButton = new JToggleButton();
    437                         chartButton.setBounds(new Rectangle(365, 5, 28, 18));
     456                        chartButton.setBounds(new Rectangle(367, 5, 28, 18));
    438457                        chartButton.setEnabled(false);
    439458                }
     
    441460        }
    442461
     462        @Override
     463        public void propertyChange(PropertyChangeEvent evt) {
     464                if(curPanel == panelEnv) System.out.println("Start HarbourAction.propertyChange");
     465        }
     466
     467        @Override
     468        public void componentHidden(ComponentEvent arg0) {
     469                if(curPanel == panelEnv) System.out.println("Start HarbourAction.componentHidden");
     470        }
     471
     472        @Override
     473        public void componentMoved(ComponentEvent arg0) {
     474                if(curPanel == panelEnv) System.out.println("Start HarbourAction.componentMoved");
     475        }
     476
     477        @Override
     478        public void componentResized(ComponentEvent arg0) {
     479                if(curPanel == panelEnv) System.out.println("Start HarbourAction.componentResized");
     480        }
     481
     482        @Override
     483        public void componentShown(ComponentEvent arg0) {
     484                if(curPanel == panelEnv) System.out.println("Start HarbourAction.componentShown");
     485        }
     486
     487        @Override
     488        public void activeLayerChange(Layer arg0, Layer arg1) {
     489                if(curPanel == panelEnv) System.out.println("Start HarbourAction.activeLayerChange");
     490        }
     491
     492        @Override
     493        public void layerAdded(Layer arg0) {
     494                if(curPanel == panelEnv) System.out.println("Start HarbourAction.layerAdded");
     495        }
     496
     497        @Override
     498        public void layerRemoved(Layer arg0) {
     499                if(curPanel == panelServices) System.out.println("Start HarbourAction.layerRemoved");
     500        }
     501
     502        @Override
     503        public void editLayerChanged(OsmDataLayer arg0, OsmDataLayer arg1) {
     504                System.out.println("Start HarbourAction.editLayerChanged");
     505        }
     506
    443507}
  • applications/editors/josm/plugins/smed/plugs/oseam/src/oseam/OSeaM.java

    r24556 r24559  
    3333        @Override
    3434        public boolean hasFocus() {
    35                 // TODO Auto-generated method stub
    3635                return false;
    3736        }
  • applications/editors/josm/plugins/smed/src/smed/Smed.java

    r23479 r24559  
    155155            smedTab.closeDialog();
    156156        }
     157       
     158        if(Main.map != null) {
     159                // von SmedTabbedPane nach hier verlagert, damit sicher ist Main.map != null
     160                SmedPluggable p = SmedTabbedPane.getCurPlugin();
     161               
     162                if(p != null) p.hasFocus();             
     163        }
    157164    }
    158165
  • applications/editors/josm/plugins/smed/src/smed/tabs/SmedTabbedPane.java

    r23445 r24559  
    3434        private SmedPluginManager manager = null;
    3535        private int activeIndex = -1;
     36        static private SmedPluggable curPlugin = null;
    3637       
    3738    public SmedTabbedPane() {
     
    6465                                tabbedPane.setMnemonicAt(i, KeyEvent.VK_1 + i);
    6566                                if(i == 0) {
    66                                         p.hasFocus();
     67                                        curPlugin = p;
    6768                                        activeIndex = 0;
    6869                                }
     
    9495                                                activeIndex = pane.getSelectedIndex();
    9596                                                for(SmedPluggable p : plugins) {
    96                                                         if(p.getIndex() == activeIndex) p.hasFocus();
     97                                                        if(p.getIndex() == activeIndex) {
     98                                                                p.hasFocus();
     99                                                                curPlugin = p;
     100                                                        }
    97101                                                }
    98102                                        }
     
    108112    public static List<SmedPluggable> getPlugins() { return plugins; }
    109113    public static JTabbedPane getTabbedPane() { return tabbedPane; }
     114    public static SmedPluggable getCurPlugin() { return curPlugin; }
    110115}
Note: See TracChangeset for help on using the changeset viewer.