Skip to content

Commit 28f438a

Browse files
committed
added 'Add all' and 'Remove all' button and display number of available devices
1 parent 31ea46b commit 28f438a

File tree

7 files changed

+91
-10
lines changed

7 files changed

+91
-10
lines changed

openrgb-plugin/dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<artifactId>OpenRGB-Plugin</artifactId>
55
<groupId>de.lars</groupId>
6-
<version>1.1</version>
6+
<version>1.2</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>openrgb-plugin</artifactId>

openrgb-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<artifactId>OpenRGB-Plugin</artifactId>
99
<groupId>de.lars</groupId>
10-
<version>1.1</version>
10+
<version>1.2</version>
1111
</parent>
1212

1313
<artifactId>openrgb-plugin</artifactId>

openrgb-plugin/src/main/java/de/lars/openrgbplugin/OpenRgbPlugin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ public boolean isVirtualOutputUsed(String outputId) {
254254
*/
255255
public OutputHandler getHandlerByVirtualOutput(String outputId) {
256256
for(OutputHandler handler : setHandler) {
257-
System.out.println("Handler output: " + handler.getVirtualOutput().getId() + " output: " + outputId + " equals: " + handler.getVirtualOutput().getId().equals(outputId));
258257
if(handler.getVirtualOutput().getId().equals(outputId))
259258
return handler;
260259
}

openrgb-plugin/src/main/java/de/lars/openrgbplugin/ui/SetupPanel.java

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,39 @@ private void initSettingsPanel() {
106106
});
107107
panelSettings.add(UserInterfaceUtil.createSettingBgr(lblDeviceId, fieldDeviceId, btnAddDeviceId));
108108

109+
if(instance.getOpenRGB().isConnected()) {
110+
// show info label, remove all and add all button
111+
int deviceCount = instance.getOpenRGB().getControllerCount();
112+
113+
JLabel lblCountInfo = new JLabel("There are " + deviceCount + " devices available.");
114+
lblCountInfo.setForeground(Style.textColor);
115+
116+
JButton btnAddAll = new JButton("Add all");
117+
UiUtils.configureButton(btnAddAll);
118+
btnAddAll.addActionListener(e -> {
119+
for(int i = 0; i < deviceCount; i++) {
120+
if(!listDevices.contains(i))
121+
listDevices.add(i);
122+
}
123+
updateDeviceListPanel();
124+
});
125+
126+
JButton btnRemoveAll = new JButton("Remove all");
127+
UiUtils.configureButton(btnRemoveAll);
128+
btnRemoveAll.addActionListener(e -> {
129+
listDevices.clear();
130+
updateDeviceListPanel();
131+
});
132+
133+
// add components to panel
134+
panelSettings.add(UserInterfaceUtil.createSettingBgr(lblCountInfo, btnAddAll, btnRemoveAll));
135+
} else {
136+
// show hint message
137+
JLabel lblHint = new JLabel("(i) Go back and connect the client to receive live data from the SDK server.");
138+
lblHint.setForeground(Style.textColorDarker);
139+
panelSettings.add(UserInterfaceUtil.createSettingBgr(lblHint));
140+
}
141+
109142
panelDeviceList = new JPanel();
110143
panelDeviceList.setBackground(Style.panelDarkBackground);
111144
panelDeviceList.setLayout(new BoxLayout(panelDeviceList, BoxLayout.Y_AXIS));
@@ -191,9 +224,11 @@ private void updateDeviceListPanel() {
191224
boolean isConnected = instance.getOpenRGB().isConnected();
192225
int controllerCount = isConnected ? instance.getOpenRGB().getControllerCount() : -1;
193226

194-
for(int deviceId : listDevices) {
227+
for(int i = 0; i < listDevices.size(); i++) {
228+
final int deviceId = listDevices.get(i);
195229
ListElement el = new ListElement(40);
196230
panelDeviceList.add(el);
231+
panelDeviceList.add(Box.createVerticalStrut(5));
197232

198233
JLabel lblDeviceId = new JLabel("Device #" + deviceId);
199234
lblDeviceId.setForeground(Style.textColor);
@@ -219,20 +254,67 @@ private void updateDeviceListPanel() {
219254
}
220255
}
221256

257+
el.add(Box.createHorizontalGlue());
258+
259+
// move device up
260+
JButton btnUp = new JButton("\u25B2");
261+
configurePanelButton(btnUp);
262+
btnUp.setToolTipText("Move up");
263+
btnUp.addActionListener(e -> {
264+
int index = listDevices.indexOf(deviceId);
265+
if(index > 0) {
266+
// move element up in list
267+
listDevices.remove(index);
268+
listDevices.add(index - 1, deviceId);
269+
}
270+
updateDeviceListPanel();
271+
});
272+
el.add(btnUp);
273+
el.add(Box.createHorizontalStrut(5));
274+
275+
// move device down
276+
JButton btnDown = new JButton("\u25BC");
277+
configurePanelButton(btnDown);
278+
btnDown.setToolTipText("Move down");
279+
btnDown.addActionListener(e -> {
280+
int index = listDevices.indexOf(deviceId);
281+
if(index < listDevices.size() - 1) {
282+
// move element down in list
283+
listDevices.remove(index);
284+
listDevices.add(index + 1, deviceId);
285+
}
286+
updateDeviceListPanel();
287+
});
288+
el.add(btnDown);
289+
el.add(Box.createHorizontalStrut(5));
290+
291+
// check to disable move up/down buttons
292+
if(i == 0)
293+
btnUp.setEnabled(false);
294+
if(i == listDevices.size() - 1)
295+
btnDown.setEnabled(false);
296+
222297
// remove device button
223-
JButton btnRemove = new JButton("X");
224-
UiUtils.configureButton(btnRemove);
298+
JButton btnRemove = new JButton("\u2715");
299+
configurePanelButton(btnRemove);
225300
btnRemove.setToolTipText("Remove device from list");
226301
btnRemove.addActionListener(e -> {
227302
listDevices.remove((Integer) deviceId);
228303
updateDeviceListPanel();
229304
});
230-
el.add(Box.createHorizontalGlue());
231305
el.add(btnRemove);
232306
}
233307
panelDeviceList.updateUI();
234308
}
235309

310+
private void configurePanelButton(JButton btn) {
311+
UiUtils.configureButton(btn);
312+
btn.setContentAreaFilled(false);
313+
btn.setBorder(null);
314+
btn.setCursor(new Cursor(Cursor.HAND_CURSOR));
315+
btn.setFont(new Font(Font.DIALOG, Font.PLAIN, 13));
316+
}
317+
236318
@Override
237319
public void onBack() {
238320
// update devices panel

openrgb-plugin/src/main/resources/plugin.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ main=de.lars.openrgbplugin.OpenRgbPlugin
22
name=OpenRGB-Plugin
33
displayname=OpenRGB Plugin
44
author=Lars (~Drumber)
5-
version=1.1
5+
version=1.2
66
scope=swing
77
minVersion=v0.2.4-rc2

openrgb-wrapper/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<artifactId>OpenRGB-Plugin</artifactId>
99
<groupId>de.lars</groupId>
10-
<version>1.1</version>
10+
<version>1.2</version>
1111
</parent>
1212

1313
<artifactId>openrgb-wrapper</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>de.lars</groupId>
88
<artifactId>OpenRGB-Plugin</artifactId>
99
<packaging>pom</packaging>
10-
<version>1.1</version>
10+
<version>1.2</version>
1111

1212
<modules>
1313
<module>openrgb-wrapper</module>

0 commit comments

Comments
 (0)