001/**
002 * Copyright (C) 2014  Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/
003 *
004 * This file is part of Dicoogle/dicoogle.
005 *
006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * Dicoogle/dicoogle is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with Dicoogle.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package pt.ua.dicoogle.rGUI.client.windows;
020
021import java.rmi.RemoteException;
022import java.awt.Image;
023import java.awt.Toolkit;
024import java.io.IOException;
025import java.net.URL;
026import java.util.ArrayList;
027import java.util.List;
028import java.util.concurrent.Semaphore;
029import org.slf4j.Logger;
030import org.slf4j.LoggerFactory;
031import org.slf4j.Logger;
032import org.slf4j.LoggerFactory;
033import javax.swing.GroupLayout;
034import javax.swing.GroupLayout.ParallelGroup;
035import javax.swing.GroupLayout.SequentialGroup;
036
037import javax.swing.ImageIcon;
038import javax.swing.JButton;
039import javax.swing.JLabel;
040import javax.swing.JOptionPane;
041import pt.ua.dicoogle.rGUI.interfaces.controllers.IServices;
042import pt.ua.dicoogle.rGUI.client.AdminRefs;
043import pt.ua.dicoogle.rGUI.interfaces.controllers.IPluginControllerAdmin;
044
045/**
046 *
047 * @author Samuel Campos <samuelcampos@ua.pt>
048 */
049@Deprecated
050public class Services extends javax.swing.JFrame
051{
052    private ArrayList<buttonNlabel> listbuttons;
053    private static Semaphore sem = new Semaphore(1, true);
054    private static Services instance = null;
055    private static IServices serv;
056    private static IPluginControllerAdmin plugin;
057    //private static INetworkInterfaces networkInterfaces;
058    private ImageIcon startIcon = new ImageIcon(Thread.currentThread().getContextClassLoader().getResource("playSmall.png"));
059    private ImageIcon stopIcon = new ImageIcon(Thread.currentThread().getContextClassLoader().getResource("stopSmall.png"));
060
061    
062    
063     public static Image getImage(final String pathAndFileName) {
064        final URL url = Thread.currentThread().getContextClassLoader().getResource(pathAndFileName);
065        return Toolkit.getDefaultToolkit().getImage(url);
066    }
067    
068    private class buttonNlabel
069    {
070
071        private JButton button;
072        private JLabel label;
073        private JLabel labelName;
074        private IPluginControllerAdmin pluginController;
075
076        
077        
078        public buttonNlabel(boolean isRunning, String labelName)
079        {
080            this.pluginController = AdminRefs.getInstance().getPluginController();
081
082            this.labelName = new JLabel();
083            this.labelName.setText(labelName);
084
085            this.label = new JLabel();
086
087            this.button = new JButton();
088
089            if (isRunning)
090            {
091                label.setText("Running");
092                button.setText("Stop");
093                button.setIcon(stopIcon);
094            } else
095            {
096                label.setText("Stopped");
097                button.setText("Start");
098                button.setIcon(startIcon);
099            }
100            button.addActionListener(new java.awt.event.ActionListener()
101            {
102
103                @Override
104                public void actionPerformed(java.awt.event.ActionEvent evt)
105                {
106                    buttonActionPerformed(evt);
107                }
108            });
109        }
110
111        private void buttonActionPerformed(java.awt.event.ActionEvent evt)
112        {
113            try
114            {
115                if (this.pluginController.isRunning(this.labelName.getText()))
116                {
117                    this.pluginController.StopPlugin(this.labelName.getText());
118                } else
119                {
120                    this.pluginController.InitiatePlugin(this.labelName.getText());
121                }
122                refreshInterface();
123            } catch (RemoteException ex)
124            {
125                LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
126            }
127        }
128
129        /* public void setIsRunning(boolean isRunning)
130        {
131        if (isRunning)
132        {
133        label.setText("Running");
134        button.setText("Stop");
135        button.setIcon(stopIcon);
136        } else
137        {
138        label.setText("Stopped");
139        button.setText("Start");
140        button.setIcon(startIcon);
141        }
142        }*/
143        public void refresh()
144        {
145            try
146            {
147                if (this.pluginController.isRunning(this.labelName.getText()))
148                {
149                    label.setText("Running");
150                    button.setText("Stop");
151                    button.setIcon(stopIcon);
152                } else
153                {
154                    label.setText("Stopped");
155                    button.setText("Start");
156                    button.setIcon(startIcon);
157                }
158            } catch (RemoteException ex)
159            {
160                LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
161            }
162        }
163
164        public JButton getButton()
165        {
166            return button;
167        }
168
169        public JLabel getLabel()
170        {
171            return label;
172        }
173
174        public JLabel getLabelName()
175        {
176            return labelName;
177        }
178
179
180    }
181    
182
183    public static synchronized Services getInstance()
184    {
185        try
186        {
187            sem.acquire();
188            if (instance == null)
189            {
190                instance = new Services();
191            }
192            sem.release();
193        } catch (InterruptedException ex)
194        {
195//            LoggerFactory.getLogger(MainWindow.class.getName()).log(Level.FATAL, null, ex);
196        }
197        return instance;
198    }
199
200    /** Creates new form Services */
201    private Services()
202    {
203        plugin = AdminRefs.getInstance().getPluginController();
204        List<String> names = null;
205        try
206        {
207            names = plugin.getPluginNames();
208        } catch (RemoteException ex)
209        {
210            LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
211        }
212
213        this.listbuttons = new ArrayList<buttonNlabel>();
214        if(names != null)
215        {
216            for(String pluginName: names)
217            {
218                try
219                {
220                    this.listbuttons.add(new buttonNlabel(plugin.isRunning(pluginName), pluginName));
221                } catch (RemoteException ex)
222                {
223                    LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
224                }
225            }
226        }
227
228        initComponents();
229
230        javax.swing.GroupLayout jPanel4Layout = (GroupLayout) jPanel4.getLayout();
231        javax.swing.GroupLayout jPanel5Layout = (GroupLayout) jPanel5.getLayout();
232        javax.swing.GroupLayout jPanel2Layout = (GroupLayout) jPanel2.getLayout();
233
234        ParallelGroup buttonsH = jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235                    .addComponent(jButtonQR)
236                    .addComponent(jButtonStorage)
237                    .addComponent(jButtonWeb)
238                    .addComponent(jButtonWebServices);
239        SequentialGroup buttonsV = jPanel4Layout.createSequentialGroup()
240                .addComponent(jButtonStorage)
241                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
242                .addComponent(jButtonQR)
243                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
244                .addComponent(jButtonWeb)
245                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
246                .addComponent(jButtonWebServices);
247
248        ParallelGroup namesH = jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
249                    .addComponent(jLabel1)
250                    .addComponent(jLabel5)
251                    .addComponent(jLabel6)
252                    .addComponent(jLabel7);
253        SequentialGroup namesV = jPanel5Layout.createSequentialGroup()
254                .addContainerGap()
255                .addComponent(jLabel1)
256                .addGap(18, 18, 18)
257                .addComponent(jLabel5)
258                .addGap(18, 18, 18)
259                .addComponent(jLabel6)
260                .addGap(18, 18, 18)
261                .addComponent(jLabel7);
262
263        ParallelGroup statesH = jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
264                .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
265                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
266                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
267                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE);
268        SequentialGroup statesV = jPanel2Layout.createSequentialGroup()
269                .addContainerGap()
270                .addComponent(jLabel8)
271                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
272                .addComponent(jLabel9)
273                .addGap(18, 18, 18)
274                .addComponent(jLabel10)
275                .addGap(18, 18, 18)
276                .addComponent(jLabel11);
277
278        for(buttonNlabel bNl : this.listbuttons)
279        {
280            buttonsH.addComponent(bNl.getButton());
281            buttonsV.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(bNl.getButton());
282
283            namesH.addComponent(bNl.getLabelName());
284            namesV.addGap(18, 18, 18).addComponent(bNl.getLabelName());
285
286            statesH.addComponent(bNl.getLabel());
287            statesV.addGap(18, 18, 18).addComponent(bNl.getLabel());
288        }
289
290        jPanel4Layout.setHorizontalGroup(
291            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
292            .addGroup(jPanel4Layout.createSequentialGroup()
293                .addContainerGap()
294                .addGroup(buttonsH)
295                .addContainerGap(16, Short.MAX_VALUE)));
296        
297        jPanel4Layout.setVerticalGroup(
298            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
299            .addGroup(buttonsV.addContainerGap(51, Short.MAX_VALUE)));
300
301        jPanel5Layout.setHorizontalGroup(
302            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
303            .addGroup(jPanel5Layout.createSequentialGroup()
304                .addContainerGap()
305                .addGroup(namesH)
306                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
307        );
308        jPanel5Layout.setVerticalGroup(
309            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
310            .addGroup(namesV.addContainerGap(71, Short.MAX_VALUE))
311        );
312
313        jPanel2Layout.setHorizontalGroup(
314            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
315            .addGroup(jPanel2Layout.createSequentialGroup()
316                .addContainerGap()
317                .addGroup(statesH)
318                .addContainerGap())
319        );
320        jPanel2Layout.setVerticalGroup(
321            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
322            .addGroup(statesV.addContainerGap(71, Short.MAX_VALUE))
323        );
324
325        Services.serv = AdminRefs.getInstance().getServices();
326      //  Services.networkInterfaces = AdminRefs.getInstance().getNetworkInterfaces();
327        Services.plugin = AdminRefs.getInstance().getPluginController();
328        Image image = Toolkit.getDefaultToolkit().getImage(Thread.currentThread().getContextClassLoader().getResource("trayicon.gif"));
329        this.setIconImage(image);
330
331        refreshInterface();
332    }
333
334    /**
335     * Refresh buttons and labels
336     * with current running services
337     *
338     */
339    private void refreshInterface()
340    {
341        try
342        {
343            if (serv.storageIsRunning())
344            {
345                jLabel8.setText("Running");
346                jButtonStorage.setText("Stop");
347                jButtonStorage.setIcon(stopIcon);
348            } else
349            {
350                jLabel8.setText("Stopped");
351                jButtonStorage.setText("Start");
352                jButtonStorage.setIcon(startIcon);
353            }
354            if (serv.queryRetrieveIsRunning())
355            {
356                jLabel9.setText("Running");
357                jButtonQR.setText("Stop");
358                jButtonQR.setIcon(stopIcon);
359            } else
360            {
361                jLabel9.setText("Stopped");
362                jButtonQR.setText("Start");
363                jButtonQR.setIcon(startIcon);
364            }
365            if (serv.webServerIsRunning())
366            {
367                jLabel10.setText("Running");
368                jButtonWeb.setText("Stop");
369                jButtonWeb.setIcon(stopIcon);
370            } else
371            {
372                jLabel10.setText("Stopped");
373                jButtonWeb.setText("Start");
374                jButtonWeb.setIcon(startIcon);
375            }
376            if (serv.webServicesIsRunning())
377            {
378                jLabel11.setText("Running");
379                jButtonWebServices.setText("Stop");
380                jButtonWebServices.setIcon(stopIcon);
381            } else
382            {
383                jLabel11.setText("Stopped");
384                jButtonWebServices.setText("Start");
385                jButtonWebServices.setIcon(startIcon);
386            }
387
388            for (buttonNlabel b : this.listbuttons)
389            {
390                b.refresh();
391            }
392            /*            if (serv.p2PIsRunning()) {
393            jLabel13.setText("Running");
394            jButtonP2P.setText("Stop");
395            jButtonP2P.setIcon(stopIcon);
396            } else {
397            jLabel13.setText("Stopped");
398            jButtonP2P.setText("Start");
399            jButtonP2P.setIcon(startIcon);
400            }*/
401        } catch (RemoteException ex)
402        {
403            LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
404        }
405        //Updates allways the members list.
406    /*    jComboBox1.removeAllItems();
407        try
408        {
409            for (String networkInterface : networkInterfaces.getNetworkInterfaces())
410            {
411                jComboBox1.addItem(networkInterface);
412            }
413            if (networkInterfaces.getNetworkInterface() != null)
414            {
415                this.jComboBox1.setSelectedItem(networkInterfaces.getNetworkInterface());
416            }
417               if(networkInterfaces.getNetworkInterface() == null)
418            networkInterfaces.setNetworkInterface((String) this.jComboBox1.getSelectedItem());
419            else
420            {
421            System.out.println(networkInterfaces.getNetworkInterface());
422            this.jComboBox1.setSelectedItem(networkInterfaces.getNetworkInterface());
423            }
424        } catch (RemoteException ex)
425        {
426            LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
427        }*/
428    }
429
430    private void showOptions()
431    {
432    }
433
434    /** This method is called from within the constructor to
435     * initialize the form.
436     * WARNING: Do NOT modify this code. The content of this method is
437     * always regenerated by the Form Editor.
438     */
439    @SuppressWarnings("unchecked")
440    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
441    private void initComponents() {
442
443        jPanel1 = new javax.swing.JPanel();
444        jSeparator1 = new javax.swing.JSeparator();
445        jPanel2 = new javax.swing.JPanel();
446        jLabel8 = new javax.swing.JLabel();
447        jLabel9 = new javax.swing.JLabel();
448        jLabel10 = new javax.swing.JLabel();
449        jLabel11 = new javax.swing.JLabel();
450        jPanel3 = new javax.swing.JPanel();
451        jLabel2 = new javax.swing.JLabel();
452        jLabel3 = new javax.swing.JLabel();
453        jLabel4 = new javax.swing.JLabel();
454        jPanel5 = new javax.swing.JPanel();
455        jLabel1 = new javax.swing.JLabel();
456        jLabel5 = new javax.swing.JLabel();
457        jLabel6 = new javax.swing.JLabel();
458        jLabel7 = new javax.swing.JLabel();
459        jPanel4 = new javax.swing.JPanel();
460        jButtonStorage = new javax.swing.JButton();
461        jButtonQR = new javax.swing.JButton();
462        jButtonWeb = new javax.swing.JButton();
463        jButtonWebServices = new javax.swing.JButton();
464        jPanel6 = new javax.swing.JPanel();
465        jButtonQRStorageServers = new javax.swing.JButton();
466        jLabel12 = new javax.swing.JLabel();
467
468        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
469        setTitle("Dicoogle Services");
470        setResizable(false);
471        addWindowListener(new java.awt.event.WindowAdapter() {
472            public void windowClosing(java.awt.event.WindowEvent evt) {
473                formWindowClosing(evt);
474            }
475        });
476
477        jLabel8.setText("status");
478
479        jLabel9.setText("status");
480
481        jLabel10.setText("status");
482
483        jLabel11.setText("status");
484
485        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
486        jPanel2.setLayout(jPanel2Layout);
487        jPanel2Layout.setHorizontalGroup(
488            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
489            .addGroup(jPanel2Layout.createSequentialGroup()
490                .addContainerGap()
491                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
492                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
493                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
494                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
495                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))
496                .addContainerGap())
497        );
498        jPanel2Layout.setVerticalGroup(
499            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
500            .addGroup(jPanel2Layout.createSequentialGroup()
501                .addContainerGap()
502                .addComponent(jLabel8)
503                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
504                .addComponent(jLabel9)
505                .addGap(18, 18, 18)
506                .addComponent(jLabel10)
507                .addGap(18, 18, 18)
508                .addComponent(jLabel11)
509                .addContainerGap(76, Short.MAX_VALUE))
510        );
511
512        jLabel8.getAccessibleContext().setAccessibleName("storageStatusLabel");
513
514        jLabel2.setText("Service");
515
516        jLabel3.setText("Status");
517
518        jLabel4.setText("Control");
519
520        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
521        jPanel3.setLayout(jPanel3Layout);
522        jPanel3Layout.setHorizontalGroup(
523            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
524            .addGroup(jPanel3Layout.createSequentialGroup()
525                .addGap(24, 24, 24)
526                .addComponent(jLabel2)
527                .addGap(90, 90, 90)
528                .addComponent(jLabel3)
529                .addGap(72, 72, 72)
530                .addComponent(jLabel4)
531                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
532        );
533        jPanel3Layout.setVerticalGroup(
534            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
535            .addGroup(jPanel3Layout.createSequentialGroup()
536                .addContainerGap()
537                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
538                    .addComponent(jLabel2)
539                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
540                    .addComponent(jLabel4))
541                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
542        );
543
544        jLabel1.setText("DICOM Storage:");
545
546        jLabel5.setText("DICOM Query/Retrieve:");
547
548        jLabel6.setText("Dicoogle Web:");
549
550        jLabel7.setText("Dicoogle WebServices:");
551
552        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
553        jPanel5.setLayout(jPanel5Layout);
554        jPanel5Layout.setHorizontalGroup(
555            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
556            .addGroup(jPanel5Layout.createSequentialGroup()
557                .addContainerGap()
558                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
559                    .addComponent(jLabel1)
560                    .addComponent(jLabel5)
561                    .addComponent(jLabel6)
562                    .addComponent(jLabel7))
563                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
564        );
565        jPanel5Layout.setVerticalGroup(
566            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
567            .addGroup(jPanel5Layout.createSequentialGroup()
568                .addContainerGap()
569                .addComponent(jLabel1)
570                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
571                .addComponent(jLabel5)
572                .addGap(18, 18, 18)
573                .addComponent(jLabel6)
574                .addGap(18, 18, 18)
575                .addComponent(jLabel7)
576                .addContainerGap(76, Short.MAX_VALUE))
577        );
578
579        jButtonStorage.setIcon(new ImageIcon(getImage("playSmall.png")));
580        jButtonStorage.setText("Start");
581        jButtonStorage.addActionListener(new java.awt.event.ActionListener() {
582            public void actionPerformed(java.awt.event.ActionEvent evt) {
583                jButtonStorageActionPerformed(evt);
584            }
585        });
586
587        jButtonQR.setIcon(new ImageIcon(getImage("playSmall.png")));
588        jButtonQR.setText("Start");
589        jButtonQR.addActionListener(new java.awt.event.ActionListener() {
590            public void actionPerformed(java.awt.event.ActionEvent evt) {
591                jButtonQRActionPerformed(evt);
592            }
593        });
594
595        jButtonWeb.setIcon(new ImageIcon(getImage("playSmall.png")));
596        jButtonWeb.setText("Start");
597        jButtonWeb.addActionListener(new java.awt.event.ActionListener() {
598            public void actionPerformed(java.awt.event.ActionEvent evt) {
599                jButtonWebActionPerformed(evt);
600            }
601        });
602
603        jButtonWebServices.setIcon(new ImageIcon(getImage("playSmall.png")));
604        jButtonWebServices.setText("Start");
605        jButtonWebServices.addActionListener(new java.awt.event.ActionListener() {
606            public void actionPerformed(java.awt.event.ActionEvent evt) {
607                jButtonWebServicesActionPerformed(evt);
608            }
609        });
610
611        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
612        jPanel4.setLayout(jPanel4Layout);
613        jPanel4Layout.setHorizontalGroup(
614            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
615            .addGroup(jPanel4Layout.createSequentialGroup()
616                .addContainerGap()
617                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
618                    .addComponent(jButtonQR)
619                    .addComponent(jButtonStorage)
620                    .addComponent(jButtonWeb)
621                    .addComponent(jButtonWebServices))
622                .addContainerGap(16, Short.MAX_VALUE))
623        );
624        jPanel4Layout.setVerticalGroup(
625            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
626            .addGroup(jPanel4Layout.createSequentialGroup()
627                .addComponent(jButtonStorage)
628                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
629                .addComponent(jButtonQR)
630                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
631                .addComponent(jButtonWeb)
632                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
633                .addComponent(jButtonWebServices)
634                .addContainerGap(60, Short.MAX_VALUE))
635        );
636
637        jButtonQRStorageServers.setIcon(new ImageIcon(getImage("data-server.png")));
638        jButtonQRStorageServers.setText("Storage Servers");
639        jButtonQRStorageServers.addActionListener(new java.awt.event.ActionListener() {
640            public void actionPerformed(java.awt.event.ActionEvent evt) {
641                jButtonQRStorageServersActionPerformed(evt);
642            }
643        });
644
645        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
646        jPanel6.setLayout(jPanel6Layout);
647        jPanel6Layout.setHorizontalGroup(
648            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
649            .addGroup(jPanel6Layout.createSequentialGroup()
650                .addContainerGap()
651                .addComponent(jButtonQRStorageServers)
652                .addContainerGap(111, Short.MAX_VALUE))
653        );
654        jPanel6Layout.setVerticalGroup(
655            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
656            .addGroup(jPanel6Layout.createSequentialGroup()
657                .addGap(31, 31, 31)
658                .addComponent(jButtonQRStorageServers)
659                .addContainerGap(113, Short.MAX_VALUE))
660        );
661
662        jLabel12.setText("To define Dicoogle Inicial Services go to: Preferences -> Inicial Services");
663
664        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
665        jPanel1.setLayout(jPanel1Layout);
666        jPanel1Layout.setHorizontalGroup(
667            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
668            .addComponent(jSeparator1)
669            .addGroup(jPanel1Layout.createSequentialGroup()
670                .addGap(27, 27, 27)
671                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
672                .addContainerGap())
673            .addGroup(jPanel1Layout.createSequentialGroup()
674                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
675                    .addGroup(jPanel1Layout.createSequentialGroup()
676                        .addGap(6, 6, 6)
677                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
678                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
679                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
680                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
681                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
682                        .addGap(7, 7, 7)
683                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
684                    .addGroup(jPanel1Layout.createSequentialGroup()
685                        .addContainerGap()
686                        .addComponent(jLabel12)))
687                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
688        );
689        jPanel1Layout.setVerticalGroup(
690            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
691            .addGroup(jPanel1Layout.createSequentialGroup()
692                .addContainerGap()
693                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
694                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
695                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
696                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
697                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
698                    .addGroup(jPanel1Layout.createSequentialGroup()
699                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
700                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
701                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
702                            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
703                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
704                        .addComponent(jLabel12)
705                        .addGap(9, 9, 9))
706                    .addGroup(jPanel1Layout.createSequentialGroup()
707                        .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
708                        .addContainerGap())))
709        );
710
711        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
712        getContentPane().setLayout(layout);
713        layout.setHorizontalGroup(
714            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
715            .addGroup(layout.createSequentialGroup()
716                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
717                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
718        );
719        layout.setVerticalGroup(
720            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
721            .addGroup(layout.createSequentialGroup()
722                .addContainerGap()
723                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
724                .addContainerGap(9, Short.MAX_VALUE))
725        );
726
727        pack();
728    }// </editor-fold>//GEN-END:initComponents
729
730    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
731        MainWindow main = MainWindow.getInstance();
732
733        main.toFront();
734        main.setEnabled(true);
735
736        this.dispose();
737    }//GEN-LAST:event_formWindowClosing
738
739    private void jButtonStorageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonStorageActionPerformed
740        try
741        {
742            if (serv.storageIsRunning())
743            {
744                serv.stopStorage();
745            } else
746            {
747                try
748                {
749                    if (serv.startStorage() == -1)
750                    {
751                        int choice = JOptionPane.showConfirmDialog(null, "The server's storage path is not defined. Do you wish to define it?", "Error: Undefined Storage Path", JOptionPane.YES_NO_OPTION);
752                        if (choice == 0)
753                        {
754                            showOptions();
755                        }
756                    }
757                } catch (IOException ex)
758                {
759                    LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
760                }
761            }
762            refreshInterface();
763        } catch (RemoteException ex)
764        {
765            LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
766        }
767    }//GEN-LAST:event_jButtonStorageActionPerformed
768
769    private void jButtonQRActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQRActionPerformed
770        try
771        {
772            if (serv.queryRetrieveIsRunning())
773            {
774                serv.stopQueryRetrieve();
775            } else
776            {
777                serv.startQueryRetrieve();
778            }
779            refreshInterface();
780        } catch (RemoteException ex)
781        {
782            LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
783        }
784    }//GEN-LAST:event_jButtonQRActionPerformed
785
786    private void jButtonWebActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWebActionPerformed
787        try
788        {
789            if (serv.webServerIsRunning())
790            {
791                serv.stopWebServer();
792            } else
793            {
794                serv.startWebServer();
795            }
796            refreshInterface();
797        } catch (RemoteException ex)
798        {
799            LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
800        }       
801        
802    }//GEN-LAST:event_jButtonWebActionPerformed
803
804    private void jButtonWebServicesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWebServicesActionPerformed
805        try
806        {
807            if (serv.webServicesIsRunning())
808            {
809                serv.stopWebServices();
810            } else
811            {
812                serv.startWebServices();
813            }
814
815        } catch (Exception ex)
816        {
817            LoggerFactory.getLogger(Services.class).error(ex.getMessage(), ex);
818        }
819        refreshInterface();
820    }//GEN-LAST:event_jButtonWebServicesActionPerformed
821
822    private void jButtonQRStorageServersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonQRStorageServersActionPerformed
823        QRServers QRservers = QRServers.getInstance();
824        QRservers.setVisible(true);
825        QRservers.toFront();
826    }//GEN-LAST:event_jButtonQRStorageServersActionPerformed
827
828    // Variables declaration - do not modify//GEN-BEGIN:variables
829    private javax.swing.JButton jButtonQR;
830    private javax.swing.JButton jButtonQRStorageServers;
831    private javax.swing.JButton jButtonStorage;
832    private javax.swing.JButton jButtonWeb;
833    private javax.swing.JButton jButtonWebServices;
834    private javax.swing.JLabel jLabel1;
835    private javax.swing.JLabel jLabel10;
836    private javax.swing.JLabel jLabel11;
837    private javax.swing.JLabel jLabel12;
838    private javax.swing.JLabel jLabel2;
839    private javax.swing.JLabel jLabel3;
840    private javax.swing.JLabel jLabel4;
841    private javax.swing.JLabel jLabel5;
842    private javax.swing.JLabel jLabel6;
843    private javax.swing.JLabel jLabel7;
844    private javax.swing.JLabel jLabel8;
845    private javax.swing.JLabel jLabel9;
846    private javax.swing.JPanel jPanel1;
847    private javax.swing.JPanel jPanel2;
848    private javax.swing.JPanel jPanel3;
849    private javax.swing.JPanel jPanel4;
850    private javax.swing.JPanel jPanel5;
851    private javax.swing.JPanel jPanel6;
852    private javax.swing.JSeparator jSeparator1;
853    // End of variables declaration//GEN-END:variables
854}