UMS.conf and GUI mode editing ???

General discussion about Universal Media Server (no support or requests)
Post Reply
User avatar
Sami32
Posts: 851
Joined: Mon Apr 11, 2016 5:09 am

UMS.conf and GUI mode editing ???

Post by Sami32 »

Why this editing option is available in GUI mode from the "General Configuration" tab ?
Because for me it look like more code in UMS for a tool that is hardly usable without a search bar...
Perhaps it come from UMS version 1.4.0 https://github.com/UniversalMediaServer ... 39df915b2e

viewtopic.php?f=13&t=8469

This part in GeneralTab.java could be changed

Code: Select all

CustomJButton confEdit = new CustomJButton(Messages.getString("NetworkTab.51"));
			confEdit.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					JPanel tPanel = new JPanel(new BorderLayout());
					final File conf = new File(configuration.getProfilePath());
					final JTextArea textArea = new JTextArea();
					textArea.setFont(new Font("Courier", Font.PLAIN, 12));
					JScrollPane scrollPane = new JScrollPane(textArea);
					scrollPane.setPreferredSize(new Dimension(900, 450));

					try {
						try (FileInputStream fis = new FileInputStream(conf); BufferedReader in = new BufferedReader(new InputStreamReader(fis))) {
							String line;
							StringBuilder sb = new StringBuilder();

							while ((line = in.readLine()) != null) {
								sb.append(line);
								sb.append("\n");
							}
							textArea.setText(sb.toString());
						}
					} catch (IOException e1) {
						return;
					}

					tPanel.add(scrollPane, BorderLayout.NORTH);
					Object[] options = {Messages.getString("LooksFrame.9"), Messages.getString("NetworkTab.45")};

					if (JOptionPane.showOptionDialog(looksFrame,
						tPanel, Messages.getString("NetworkTab.51"),
						JOptionPane.OK_CANCEL_OPTION,
						JOptionPane.PLAIN_MESSAGE, null, options, null) == JOptionPane.OK_OPTION) {
						String text = textArea.getText();

						try {
							try (FileOutputStream fos = new FileOutputStream(conf)) {
								fos.write(text.getBytes());
								fos.flush();
							}
							configuration.reload();
						} catch (Exception e1) {
							JOptionPane.showMessageDialog(looksFrame, Messages.getString("NetworkTab.52") + e1.toString());
						}
					}
				}
			});
in something similar to what is done in DbgPacker.java that give us the possibility to access files from an external editor.

I guess it could be easely done, but i really doesn't understand the interface code :cry:
Post Reply