All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.cloudfarming.client.geoviewer.wms.ToolbarPanel Maven / Gradle / Ivy

/**
 * Copyright (C) 2011 Agrosense 
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.cloudfarming.client.geoviewer.wms;

import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;

/**
 *
 * @author Timon Veenstra
 */
public class ToolbarPanel extends JPanel{
    private final Image addWmsServerImage = ImageUtilities.loadImage("nl/cloudfarming/client/icon/map-add-icon.png");
    private final Icon addWmsServerIcon = ImageUtilities.image2Icon(addWmsServerImage);

    public ToolbarPanel() {
        JButton addServerButton = new JButton(addWmsServerIcon);
        add(addServerButton);
        addServerButton.addActionListener(new ActionListener() {
            
            @Override
            public void actionPerformed(ActionEvent e) {
                
                String urlString = JOptionPane.showInputDialog(new JTextField(),"enter wms server URL (http://wms.someserver.com/something?)");
                ServerRegistry registry = Lookup.getDefault().lookup(ServerRegistry.class);
                try {
                    WmsServer wmsServer = new WmsServer(new URL(urlString));
                    registry.getServers().add(wmsServer);
                } catch (MalformedURLException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        });
//        addServerButton.setAction(new AbstractAction() {
//
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                JOptionPane.showMessageDialog(null,"jajaja");
//            }
//        });
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy