55 lines
2.1 KiB
Java
55 lines
2.1 KiB
Java
|
package io.gitlab.jfronny.inceptum.gtk.control;
|
||
|
|
||
|
import ch.bailu.gtk.GTK;
|
||
|
import ch.bailu.gtk.bridge.ListIndex;
|
||
|
import ch.bailu.gtk.gtk.*;
|
||
|
import ch.bailu.gtk.type.Str;
|
||
|
import io.gitlab.jfronny.inceptum.common.Utils;
|
||
|
import io.gitlab.jfronny.inceptum.gtk.GtkMenubar;
|
||
|
import io.gitlab.jfronny.inceptum.gtk.util.I18n;
|
||
|
import io.gitlab.jfronny.inceptum.launcher.util.InstanceList;
|
||
|
|
||
|
import java.util.List;
|
||
|
|
||
|
public class InstanceGridEntryFactory extends SignalListItemFactory {
|
||
|
public InstanceGridEntryFactory(List<InstanceList.Entry> instanceList) {
|
||
|
super();
|
||
|
//TODO better design
|
||
|
onSetup(item -> {
|
||
|
var box = new Box(Orientation.HORIZONTAL, 5);
|
||
|
|
||
|
Label label = new Label(Str.NULL);
|
||
|
// label.setXalign(0);
|
||
|
label.setWidthChars(20);
|
||
|
label.setMarginEnd(10);
|
||
|
box.append(label);
|
||
|
|
||
|
Button launch = new Button();
|
||
|
launch.setIconName(new Str("computer-symbolic"));
|
||
|
launch.setTooltipText(I18n.str("instance.launch"));
|
||
|
launch.setHasTooltip(GTK.TRUE);
|
||
|
box.append(launch);
|
||
|
|
||
|
Button openDir = new Button();
|
||
|
openDir.setIconName(new Str("folder-symbolic"));
|
||
|
openDir.setTooltipText(I18n.str("instance.directory"));
|
||
|
openDir.setHasTooltip(GTK.TRUE);
|
||
|
box.append(openDir);
|
||
|
|
||
|
item.setChild(box);
|
||
|
//TODO server launch with network-server-symbolic
|
||
|
//TODO kill current instance
|
||
|
});
|
||
|
onBind(item -> {
|
||
|
Label label = new Label(item.getChild().getFirstChild().cast());
|
||
|
Button launch = new Button(label.getNextSibling().cast());
|
||
|
Button openDir = new Button(launch.getNextSibling().cast());
|
||
|
InstanceList.Entry instance = instanceList.get(ListIndex.toIndex(item));
|
||
|
label.setText(new Str(instance.toString()));
|
||
|
launch.onClicked(() -> GtkMenubar.launch(instance));
|
||
|
openDir.onClicked(() -> Utils.openFile(instance.path().toFile()));
|
||
|
//TODO edit button document-edit-symbolic -> edit-delete-symbolic, edit-copy-symbolic
|
||
|
});
|
||
|
}
|
||
|
}
|