use of se.light.assembly64.Support.Type in project assembly64fx by freabemania.
the class SearchService method search2.
public List<SearchResultItem> search2(String name, String group, String year, String handle, String event, String rating, String category, String searchFromStart, String d64, String t64, String d71, String d81, String prg, String tap, String crt, String sid, String bin, String g64, String orSearch, int days) throws SearchException {
Response response = null;
try {
boolean anyCat = d64.equals("Y") || t64.equals("Y") || d71.equals("Y") || d81.equals("Y") || prg.equals("Y") || tap.equals("Y") || crt.equals("Y") || sid.equals("Y") || bin.equals("Y") || g64.equals("Y");
boolean anyField = !name.equals("***") || !group.equals("***") || !handle.equals("***") || !event.equals("***");
if (!(days > -1 || anyField) && anyCat) {
GenericMessageDialogController.withErrorProps("Oops", "Please enter valid searchcriterias").showAndWait();
return Collections.<SearchResultItem>emptyList();
}
response = getClient().target(getBackendServer()).path("/leet/search/get/" + urlEncode(name) + "/" + urlEncode(group) + "/" + urlEncode(year) + "/" + urlEncode(handle) + "/" + urlEncode(event) + "/" + urlEncode(rating) + "/" + urlEncode(category) + "/" + searchFromStart + "/" + d64 + "/" + t64 + "/" + d71 + "/" + d81 + "/" + prg + "/" + tap + "/" + crt + "/" + sid + "/" + bin + "/" + g64 + "/" + orSearch + "/" + Integer.toString(days)).request().header("Content-Type", "application/json").header("email", getSessionInfo().getEmail()).header("token", getSessionInfo().getToken()).get();
if (response.getStatus() == 200) {
return response.readEntity(new GenericType<List<SearchResultItem>>() {
});
} else if (response.getStatus() == 425) {
throw SearchException.ofRefineSearch();
} else if (response.getStatus() == 424) {
throw SearchException.ofSearchesExceeded();
} else {
throw new RuntimeException("Unknown");
}
} finally {
if (response != null) {
response.close();
}
}
}
use of se.light.assembly64.Support.Type in project assembly64fx by freabemania.
the class Main method setupTree.
public static void setupTree() {
GuiLocation rootsLocations = GuiLocation.builder().id(-1).type(TYPE.ROOT).name("Installations").build();
ImageView iconR = new ImageView();
iconR.setFitWidth(40);
iconR.setFitHeight(20);
iconR.setImage(ImageResolveService.getInstance().getImage("image-root-base.png"));
rootItemBase = new TreeItem<GuiLocation>(rootsLocations, iconR);
rootItemBase.setExpanded(true);
tree = new TreeView<GuiLocation>(rootItemBase);
tree.setMinWidth(topContainer.getWidth());
tree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
tree.setOnScrollStarted((event) -> {
tree.getSelectionModel().clearSelection();
});
tree.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> handleMouseClicked(event));
Image searchImage = new Image(Main.class.getResourceAsStream("button-magnifiersmall.png"), 30, 30, false, false);
searchView = new ImageView();
searchView.setImage(searchImage);
sidifyView = new ImageView();
sidifyView.setImage(new Image(Main.class.getResourceAsStream("button-sidify.png"), 30, 30, false, false));
downloadLatestDbView = new ImageView();
downloadLatestDbView.setImage(new Image(Main.class.getResourceAsStream("button-latestdb.png"), 30, 30, false, false));
searchView.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
executeIfPremium((Runnable) -> {
Analytics.sendEvent("application_click", "open_search");
GuiUtils.showDialog("searchMain.fxml", "Assembly64 search", Artifact.nullArtifact());
}, "open_search");
});
setMagnifierAndSidify();
treeAndComponents.getChildren().addAll(tree, searchView, sidifyView, downloadLatestDbView);
topContainer.getChildren().add(treeAndComponents);
}
use of se.light.assembly64.Support.Type in project assembly64fx by freabemania.
the class Main method refreshTree.
public static void refreshTree() {
Platform.runLater(new Runnable() {
@Override
public void run() {
try {
ProgressbarEnhanced progressBar = (ProgressbarEnhanced) GlobalRepoService.getInstance().get("pbar");
if (progressBar != null) {
topContainer.getChildren().remove(progressBar);
}
rootItemBase.getChildren().clear();
for (WorkLocation location : userService.getLocations()) {
List<Artifact> artifactsDb = artifactsService.getArtifactsDb();
Set<LatestInstalledItemInfo> lastestAdditions = null;
if (location.exists()) {
lastestAdditions = InstallationService.getInstance().resolveLatestInstalledByLocation(location.toLocationAndInstallation());
} else {
lastestAdditions = lastestAdditionsNotFound;
}
ImageView icon = new ImageView();
icon.setFitWidth(20);
icon.setFitHeight(20);
if (location.exists()) {
if (userService.isInstallationPrimary(location.getId())) {
icon.setImage(ImageResolveService.getInstance().getImage("image-root-primary.png"));
} else {
icon.setImage(ImageResolveService.getInstance().getImage("image-root.png"));
}
TreeItem<GuiLocation> rootItem = new TreeItem<GuiLocation>(GuiLocation.builder().id(location.getId()).type(TYPE.INSTALLATION_ROOT).name(Support.removeEndingSlash(location.getPath())).build(), icon);
rootItem.setExpanded(localDbService.getBooleanLocalDBSetting(resolveInstallationExpandedKey(location.getId()), false));
rootItemBase.getChildren().add(rootItem);
TreeItem<GuiLocation> leaf = rootItem;
for (Artifact entry : artifactsDb) {
String node = entry.getPrefix();
if (node != null) {
String[] path = node.split("/");
String leafKey = "";
for (String pathItem : path) {
leafKey += pathItem + "/";
ImageView testIcon = new ImageView();
testIcon.setFitWidth(20);
testIcon.setFitHeight(20);
if (checkIfFolderNeedsUpdate(leafKey, location) && userService.isPremium()) {
testIcon.setImage(ImageResolveService.getInstance().getImage("image-folder-updateneeded.png"));
} else {
testIcon.setImage(ImageResolveService.getInstance().getImage("image-folder.png"));
}
Optional<TreeItem<GuiLocation>> categoryItem = leaf.getChildren().stream().filter(item -> item.getValue().getName() != null && item.getValue().getName().equals(pathItem)).findFirst();
if (!categoryItem.isPresent()) {
TreeItem<GuiLocation> depNode = new TreeItem<GuiLocation>(GuiLocation.builder().id(location.getId()).type(TYPE.LEAF).name(pathItem).leafKey(leafKey).build(), testIcon);
leaf.getChildren().add(depNode);
leaf = depNode;
} else {
leaf = categoryItem.get();
}
leaf.setExpanded(localDbService.getBooleanLocalDBSetting(resolveLeafInInstallationExpandedKey(leaf.getValue()), false));
}
// we're at thre position in the list now with the correct leaf
if (!localDbService.hasLocalDBSetting("exclude_" + location.getId() + "_" + entry.getName())) {
ImageView itemIcon = new ImageView();
itemIcon.setFitWidth(16);
itemIcon.setFitHeight(16);
if (entry.getCurrentInstallingId() != null && entry.getCurrentInstallingId().equals(location.getId())) {
if (entry.isMarkedForUpdate() && !entry.isUpdating()) {
itemIcon.setImage(ImageResolveService.getInstance().getImage("image-waiting.png"));
} else if (entry.isUpdating()) {
itemIcon.setImage(ImageResolveService.getInstance().getImage("image-install2.png"));
}
} else {
if (entry.getHero() && userService.isFreemium()) {
itemIcon.setImage(ImageResolveService.getInstance().getImage("image-notavailable.png"));
} else if (entry.getType() == ArtifactType.LOCAL && !artifactsService.isPrivateDirAvailable()) {
itemIcon.setImage(ImageResolveService.getInstance().getImage("image-notavailable.png"));
} else if (!artifactsService.isInstalled(location.toLocationAndInstallation(), entry)) {
itemIcon.setImage(ImageResolveService.getInstance().getImage("image-notinstalled2bw.png"));
} else if (artifactsService.needsUpdate(location.toLocationAndInstallation(), entry)) {
itemIcon.setImage(ImageResolveService.getInstance().getImage("image-needsupdatebw.png"));
} else {
Optional<LatestInstalledItemInfo> findFirst = lastestAdditions.stream().filter(item -> item.getId().equals(entry.getName())).findFirst();
if (findFirst.isPresent() && userService.isPremium()) {
itemIcon.setImage(ImageResolveService.getInstance().getImage("image-updated-new.png"));
} else {
itemIcon.setImage(ImageResolveService.getInstance().getImage("image-updated2.png"));
}
}
}
TreeItem<GuiLocation> depNode = new TreeItem<GuiLocation>(GuiLocation.builder().id(location.getId()).type(TYPE.INSTALLATION).artifact(entry).build(), itemIcon);
leaf.getChildren().add(depNode);
}
// reset
leaf = rootItem;
}
}
} else {
icon.setImage(ImageResolveService.getInstance().getImage("image-root-invalid.png"));
TreeItem<GuiLocation> rootItem = new TreeItem<GuiLocation>(GuiLocation.builder().id(location.getId()).type(TYPE.INSTALLATION_ROOT).name(Support.removeEndingSlash(location.getPath())).build(), icon);
rootItemBase.getChildren().add(rootItem);
}
}
if (Scheduler.getInstance() != null && Scheduler.getInstance().isWorking() && ProgressControlWrapper.getInstance().isClosed()) {
int height = 25;
progressBar = new ProgressbarEnhanced();
progressBar.setMinWidth(300);
progressBar.setMinHeight(height);
progressBar.addEventHandler(MouseEvent.MOUSE_CLICKED, (MouseEvent event) -> handleMouseClicked2(event));
topContainer.getChildren().add(1, progressBar);
GlobalRepoService.getInstance().put("pbar", progressBar);
tree.setMinHeight(topContainer.getHeight() - menuBar.getHeight() - height);
} else {
tree.setMinHeight(topContainer.getHeight() - menuBar.getHeight());
}
} catch (Exception e) {
LOGGER.error("Unable to refresh view", e);
GenericMessageDialogController.withErrorProps("Ooops", "Unable to refresh view").showAndWait();
}
}
});
}
use of se.light.assembly64.Support.Type in project assembly64fx by freabemania.
the class DiskImage method readImage.
/**
* Load image from disk
* @param filename file name of disk image
* @param expectedFileSize if uncompressed image is smaller, then throw CbmException. If larger, print warning message.
* @param type the type of image to load. Used for logging.
* @throws CbmException
*/
protected void readImage(String filename, int expectedFileSize, String type) throws CbmException {
feedbackMessage = new StringBuffer();
FileInputStream input;
int magic = 0;
feedbackMessage.append("Trying to load " + type + " image ").append(filename).append("\n");
this.cbmDisk = null;
try {
magic = getFileMagic(filename) & 0xffff;
} catch (Exception e) {
throw new CbmException("Failed to open header. " + e.getMessage());
}
if (magic == GZIPInputStream.GZIP_MAGIC) {
feedbackMessage.append("GZIP compressed file detected.\n");
readZippedFile(filename);
} else {
File file = new File(filename);
if (file.isFile() == false) {
throw new CbmException("File is not a regular file.");
} else if (file.length() <= 0) {
throw new CbmException("File is empty.");
} else if (file.length() > Integer.MAX_VALUE) {
throw new CbmException("File is too large.");
} else if (file.length() < expectedFileSize) {
throw new CbmException("File smaller than normal size. A " + type + " file should be " + expectedFileSize + " bytes.");
} else if (file.length() > expectedFileSize) {
feedbackMessage.append("Warning: File larger than normal size. A " + type + " file should be ").append(expectedFileSize).append(" bytes.\n");
}
try {
input = new FileInputStream(filename);
} catch (Exception e) {
throw new CbmException("Failed to open file. " + e.getMessage());
}
try {
this.cbmDisk = new byte[(int) file.length()];
for (int i = 0; i < cbmDisk.length; i++) {
cbmDisk[i] = 0;
}
input.read(cbmDisk);
} catch (Exception e) {
try {
input.close();
} catch (Exception e2) {
}
throw new CbmException("Failed to read file. " + e.getMessage());
}
try {
input.close();
} catch (Exception e) {
throw new CbmException("Failed to close file. " + e.getMessage());
}
}
feedbackMessage.append(type + " disk image was loaded.\n");
}
Aggregations