package art.client.GUI.components.devices.window.colors.rtz32.configuration; import art.library.gui.flat.FlatTabbedPane; import art.library.model.devices.colors.controller.RTZ32.RTZ32_Controller; import art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerConfiguration; import art.client.GUI.components.ArticPanel; import art.client.GUI.components.devices.window.DeviceWindow; import art.client.GUI.components.devices.window.colors.junction.configuration.PanelConfigurationGeneric; import art.client.models.ModelGUI; import art.library.gui.flat.FlatButton; import art.library.gui.flat.FlatDialog; import art.library.gui.flat.FlatPanel; import art.library.gui.flat.FlatProgressBar; import art.library.gui.flat.FlatWindow; import art.library.interop.InteropParameters; import art.library.interop.InteropResponse; import art.library.interop.serialization.Serialization; import art.library.model.devices.colors.controller.RTZ32.RTZ32_ControllerCommands; import art.library.utils.resources.Resources; import art.servers.Shared; import art.servers.rtzserver.controller.ListenerImplementation; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public class RTZ32_PanelConfiguration extends ArticPanel { private RTZ32_Controller controller = null; private RTZ32_ControllerConfiguration configuration = null; private FlatTabbedPane flatTabbedPane = null; private PanelConfigurationGeneric selectedPanel = null; private FlatButton buttonDownload = null; private FlatPanel panelContent = null; private FlatProgressBar progressbar = null; private RTZ32_PanelConfiguration_Programs panelConfiguration_Programs = null; private RTZ32_PanelConfiguration_Tables panelConfiguration_Tables = null; public RTZ32_PanelConfiguration(RTZ32_Controller controller) { this.controller = controller; reload(); } public RTZ32_ControllerConfiguration getConfiguration() { return configuration; } public void setConfiguration(RTZ32_ControllerConfiguration configuration) { this.configuration = configuration; } public void reload() { try { deselection(); this.configuration = (RTZ32_ControllerConfiguration)Serialization.clone(controller.getDeviceConfiguration()); initialise(); } catch (Exception e) { } } public void grants() { } public void help() { } public void timer() { try { // TODO // rtz32.reading.progress // progressbar.setVisible(true); // progressbar.setValue(rtz32.reading.progress); // progressbar.setString(Shared.getMessage("Table") + " " + rtz32.reading.table); } catch (Exception exception) { progressbar.setValue(0); progressbar.setVisible(false); } } public void print() { } public void edit(boolean value) { } public void selection() { try { FlatWindow window = (FlatWindow) SwingUtilities.getRoot(this); window.addButtonSeparator(); // TODO : grants window.addButtonMenu(buttonDownload); window.addComponent(progressbar); window.addTransparentSeparator(8); selectedPanel = (PanelConfigurationGeneric)flatTabbedPane.getSelectedComponent(); selectedPanel.selection(); } catch (Exception e) { } } public void deselection() { try { FlatWindow window = (FlatWindow) SwingUtilities.getRoot(this); window.addButtonSeparator(); // TODO : grants window.removeComponentMenu(buttonDownload); window.removeComponentMenu(progressbar); selectedPanel.deselection(); } catch (Exception e) { } } private void initialise() { if (configuration == null) return; removeAll(); progressbar = new FlatProgressBar(); { progressbar.setSize(new Dimension(128, 24)); progressbar.setStringPainted(true); progressbar.setPreferredSize(new Dimension(128, 24)); progressbar.setMaximumSize(new Dimension(128, 24)); progressbar.setMinimum(0); progressbar.setMaximum(100); progressbar.setValue(0); progressbar.setVisible(false); } buttonDownload = new FlatButton(Shared.getMessage("&Read tables")); buttonDownload.setPreferredSize(new Dimension(buttonDownload.getStringWidth(), 0)); buttonDownload.setIcon(Resources.getResourceURL(ModelGUI.Icons.DOWNLOAD_24x24)); buttonDownload.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { readTables(); } }); panelConfiguration_Programs = new RTZ32_PanelConfiguration_Programs(configuration); panelConfiguration_Tables = new RTZ32_PanelConfiguration_Tables(configuration); flatTabbedPane = new FlatTabbedPane(); { flatTabbedPane.addTab(Shared.getMessage("Programs"), panelConfiguration_Programs); flatTabbedPane.addTab(Shared.getMessage("Tables"), panelConfiguration_Tables); flatTabbedPane.allowTitleChange(false); flatTabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { deselection(); selection(); } }); } panelContent = new FlatPanel(); { panelContent.setLayout(new BorderLayout()); panelContent.add(flatTabbedPane, BorderLayout.CENTER); } this.setLayout(new BorderLayout()); this.add(flatTabbedPane, BorderLayout.CENTER); this.selectedPanel = panelConfiguration_Programs; this.selectedPanel.selection(); } private void readTables() { // TODO : Cambiar por invokes (listenerImplementation.xxxxxx) DeviceWindow window = (DeviceWindow)SwingUtilities.getRoot(RTZ32_PanelConfiguration.this); RTZ32_Controller rtz32 = (RTZ32_Controller)window.getDevice(); try { // Comprobar si existe ListenerImplementation listenerImplementation = (art.servers.rtzserver.controller.ListenerImplementation)art.servers.rtzserver.Shared.controllerListenerHttps.getListenerImplementation(); RTZ32_ControllerCommands commands = new RTZ32_ControllerCommands(); commands.configurationRead = new Boolean(true); InteropParameters parameters = new InteropParameters(); parameters.addParameter("language", "en-GB"); parameters.addParameter("device", rtz32.getIdentifier()); parameters.addBodycontent(commands); InteropResponse response = listenerImplementation.sendCommands(parameters); // Barra de progreso timer(); } catch (Exception exception) { FlatDialog.showDialog(window, Shared.getMessage("Error"), exception.getMessage(), true, FlatDialog.DIALOG_ERROR); } } }