List of usage examples for org.eclipse.jface.dialogs DialogSettings load
@Override
public void load(String fileName) throws IOException
From source file:at.bestsolution.efxclipse.tooling.fxgraph.ui.wizards.NewFXGraphWizard.java
License:Open Source License
public NewFXGraphWizard() { if (getDialogSettings() == null) { DialogSettings settings = new DialogSettings("new-fxgraph"); try {//from ww w .j a va2 s . c om settings.load(SETTINGS_FILE); } catch (IOException e) { } setDialogSettings(settings); } }
From source file:at.bestsolution.efxclipse.tooling.fxml.wizards.NewFXMLWizard.java
License:Open Source License
public NewFXMLWizard() { if (getDialogSettings() == null) { DialogSettings settings = new DialogSettings("new-fxml"); try {/*from w w w . j a va 2 s. com*/ settings.load(SETTINGS_FILE); } catch (IOException e) { } setDialogSettings(settings); } }
From source file:com.bdaum.zoom.operations.internal.gen.AbstractGalleryGenerator.java
License:Open Source License
protected String generateImageList(boolean relative, boolean boost) { Shell shell = adaptable.getAdapter(Shell.class); File manifest = new File(imageFolder, "imagelist.xml"); //$NON-NLS-1$ DialogSettings newsettings = new DialogSettings("images"); //$NON-NLS-1$ DialogSettings settings = new DialogSettings("images"); //$NON-NLS-1$ try {//from w w w. j a v a2s . c o m settings.load(manifest.getAbsolutePath()); } catch (IOException e1) { // ignore } Map<String, WebParameter> parameters = gallery.getParameter(); StringBuilder sb = new StringBuilder(); ICore activator = CoreActivator.getDefault(); IDbManager dbManager = activator.getDbManager(); int thumbnailSizeInPixel = getThumbnailSizeInPixel(gallery.getThumbSize()); int i = 0; boolean first = true; for (Storyboard storyboard : gallery.getStoryboard()) { if (selectedStoryboard != null && selectedStoryboard != storyboard) continue; maxImageWidthInSection = -1; maxImageHeightInSection = -1; String sectionSnippet = getSectionHeader(++i); Map<String, String> sectionvars = null; if (sectionSnippet != null) { sectionvars = getSectionSnippetVars((StoryboardImpl) storyboard, i); StringBuffer generated = generateSnippet(parameters, sectionvars, sectionSnippet); if (sb.length() > 0 && generated.length() > 0) sb.append('\n'); sb.append(generated); } boolean enlarge = storyboard.getEnlargeSmall(); int imageSizeInPixels = getImageSizeInPixels(storyboard.getImageSize()); List<String> exhibits = storyboard.getExhibit(); try (Assetbox box = new Assetbox(null, status, false)) { for (String id : exhibits) { WebExhibitImpl exhibit = dbManager.obtainById(WebExhibitImpl.class, id); if (exhibit != null) { String assetId = exhibit.getAsset(); AssetImpl asset = dbManager.obtainAsset(assetId); if (asset != null) { int isize = imageSizeInPixels; if (boost) { int width = asset.getWidth(); int height = asset.getHeight(); if (width != 0 && height != 0) { double ratio = (double) width / height; if (ratio < 1d) ratio = 1d / ratio; isize *= ratio; } } String copyright = null; if (gallery.getAddWatermark()) { copyright = asset.getCopyright(); if (copyright == null || copyright.isEmpty()) copyright = gallery.getCopyright(); if (copyright != null && copyright.isEmpty()) copyright = null; } File originalFile = box.obtainFile(asset); Rectangle bounds = null; if (originalFile != null) { URI uri = box.getUri(); boolean includeMetadata = exhibit.getIncludeMetadata(); int rotation = asset.getRotation(); IDialogSettings manifestSection = createManifestEntry(newsettings, uri, rotation, isize, thumbnailSizeInPixel, getBigImageSize(), includeMetadata, copyright, enlarge, gallery.getRadius(), gallery.getAmount(), gallery.getThreshold(), gallery.getApplySharpening()); String imageName = Core.getFileName(uri, false) + ".jpg"; //$NON-NLS-1$ File imageFile = new File(imageFolder, imageName); File bigFile = bigFolder != null ? new File(bigFolder, imageName) : null; File thumbnail = thumbnailFolder == null ? null : new File(thumbnailFolder, imageName); Rectangle imageDims = manifestEntryModified(settings, imageFile, thumbnail, uri, rotation, isize, thumbnailSizeInPixel, getBigImageSize(), includeMetadata, copyright, enlarge, gallery.getRadius(), gallery.getAmount(), gallery.getThreshold(), gallery.getApplySharpening()); if (imageDims == null) { UnsharpMask umask = gallery.getApplySharpening() ? ImageActivator.getDefault().computeUnsharpMask(gallery.getRadius(), gallery.getAmount(), gallery.getThreshold()) : null; Rectangle bigImageSize = getBigImageSize(); ZImage zimage = null; try { zimage = CoreActivator.getDefault().getHighresImageLoader().loadImage(null, status, originalFile, rotation, asset.getFocalLengthIn35MmFilm(), bigImageSize == null ? computeImageBounds(isize) : bigImageSize, 1d, enlarge ? Double.MAX_VALUE : 1d, true, ImageConstants.SRGB, null, umask, null, fileWatcher, opId, this); } catch (UnsupportedOperationException e) { // do nothing } Image image = null; Image bigImage = null; try { if (bigImageSize != null) { bigImage = zimage == null ? null : zimage.getSwtImage(shell.getDisplay(), true, ZImage.CROPPED, bigImageSize.width, bigImageSize.height); if (bigImage != null) { image = new Image(shell.getDisplay(), ImageUtilities .downSample(bigImage.getImageData(), isize, isize, 0)); bigFile = decorateImage(bigImage, bigFile, asset, copyright, includeMetadata); imageFile = decorateImage(image, imageFile, asset, copyright, includeMetadata); if (thumbnail != null && thumbnailSizeInPixel > 0) thumbnail = generateThumbnail(thumbnail, image, thumbnailSizeInPixel); } } else { image = zimage == null ? null : zimage.getSwtImage(shell.getDisplay(), true, ZImage.CROPPED, isize, isize); if (image != null) { imageFile = decorateImage(image, imageFile, asset, copyright, includeMetadata); if (thumbnail != null && thumbnailSizeInPixel > 0) thumbnail = generateThumbnail(thumbnail, image, thumbnailSizeInPixel); } } } finally { if (bigImage != null) bigImage.dispose(); if (image != null) { bounds = image.getBounds(); image.dispose(); updateSection(manifestSection, bounds); } } } else { bounds = imageDims; if (filter != null && !filter.isEmpty()) { imageFile = generateImage(asset, imageFile, null, includeMetadata, jpegQuality); if (bigFile != null) bigFile = generateImage(asset, bigFile, null, includeMetadata, jpegQuality); } } File copiedFile = new File(originalsFolder, originalFile.getName()); boolean downloadable = exhibit.getDownloadable() && needsOriginals(); if (originalModified(settings, copiedFile, downloadable, uri)) { if (downloadable) copiedFile = copyImage(originalFile, copiedFile); else { copiedFile.delete(); copiedFile = null; } } Map<String, String> vars = getImageSnippetVars(exhibit, asset, storyboard, thumbnail == null ? null : (relative) ? thumbnail.getName() : thumbnailFolder.getName() + '/' + thumbnail.getName(), imageFile == null ? null : (relative) ? imageFile.getName() : imageFolder.getName() + '/' + imageFile.getName(), bigFile == null ? null : (relative) ? bigFile.getName() : bigFolder.getName() + '/' + bigFile.getName(), copiedFile == null ? null : (relative) ? copiedFile.getName() : originalsFolder == null ? null : originalsFolder.getName() + '/' + copiedFile.getName(), i); if (bounds != null) { vars.put(IMAGE_WIDTH, String.valueOf(bounds.width)); vars.put(IMAGE_HEIGHT, String.valueOf(bounds.height)); if (bounds.width > maxImageWidthInSection) maxImageWidthInSection = bounds.width; if (bounds.height > maxImageHeightInSection) maxImageHeightInSection = bounds.height; } else { vars.put(IMAGE_WIDTH, "-1"); //$NON-NLS-1$ vars.put(IMAGE_HEIGHT, "-1"); //$NON-NLS-1$ } String snippet = getImageSnippet(first); first = false; StringBuffer generated = generateSnippet(parameters, vars, snippet); if (sb.length() > 0 && generated.length() > 0) sb.append('\n'); sb.append(generated); } } } monitor.worked(1); if (monitor.isCanceled()) return ""; //$NON-NLS-1$ } } if (sectionSnippet != null) { StringBuffer generated = generateSnippet(parameters, sectionvars, sectionSnippet = getSectionFooter()); if (sb.length() > 0 && generated.length() > 0) sb.append('\n'); sb.append(generated); } } manifest.delete(); try { newsettings.save(manifest.getAbsolutePath()); } catch (IOException e) { // ignore } return sb.toString(); }
From source file:com.bdaum.zoom.vr.internal.ExhibitionJob.java
License:Open Source License
protected int generateImageList(File resFolder, final File roomFolder, String roomName, StringBuilder sb, Point sceneSize, Point woff, double scale, double headHeight, int entries) { Set<String> artists = new HashSet<String>(); int infoPlatePosition = gallery.getInfoPlatePosition(); Wall doorWall = null;/*w ww . ja va 2 s . c o m*/ entryImage = null; entryGC = null; int tileSize = ENTRYSIZE / entries; int entryX = 0; int entryY = 0; int mx = sceneSize.x / 2; int my = sceneSize.y / 2; final Shell shell = adaptable.getAdapter(Shell.class); File manifest = new File(resFolder, "imagelist.xml"); //$NON-NLS-1$ DialogSettings newsettings = new DialogSettings("images"); //$NON-NLS-1$ DialogSettings settings = new DialogSettings("images"); //$NON-NLS-1$ try { settings.load(manifest.getAbsolutePath()); } catch (IOException e1) { // ignore } ICore activator = CoreActivator.getDefault(); IVolumeManager volumeManager = activator.getVolumeManager(); IDbManager dbManager = activator.getDbManager(); double zoom = 0.24d; int sx = gallery.getStartX(); int sy = gallery.getStartY(); int tagId = 1; int wallId = 1; try (Ticketbox box = new Ticketbox()) { List<File> renamedFiles = new ArrayList<File>(); for (Wall wall : gallery.getWall()) { Rgb_type wallColor = getWallColor(wall); double angle = wall.getGAngle(); double cos = Math.cos(Math.toRadians(angle)); double sin = Math.sin(Math.toRadians(angle)); int wallX1 = wall.getGX(); int wallY1 = wall.getGY(); int wallW = wall.getWidth(); double wallX2 = wallX1 + cos * wallW; double wallX3 = wallX2; double wallY2 = wallY1 + sin * wallW; double wallY3 = wallY2; boolean door = false; if (sx >= Math.min(wallX1, wallX2) - 50 && sx <= Math.max(wallX1, wallX2) + 50 && sy >= Math.min(wallY1, wallY2) - 50 && sy <= Math.max(wallY1, wallY2) + 50) { if (Math.abs(cos) > 0.01d) door = Math.abs(wallY1 - sy + (sx - wallX1) * sin / cos) < 50; else door = true; } double doorX1 = 0; double doorY1 = 0; if (door) { if (infoPlatePosition == INFOLEFT) { doorX1 = sx + cos * (INFOGAP + INFOWIDTH - DOORWIDTH / 2); doorY1 = sy + sin * (INFOGAP + INFOWIDTH - DOORWIDTH / 2); } else { doorX1 = sx - cos * DOORWIDTH / 2; doorY1 = sy - sin * DOORWIDTH / 2; } wallX2 = doorX1; wallY2 = doorY1; } double x1 = (wallX1 - mx + woff.x) * scale; double x2 = (wallX2 - mx + woff.x) * scale; double x3 = (wallX3 - mx + woff.x) * scale; double y1 = headHeight * scale; double vHeight = gallery.getDefaultViewingHeight(); double y2 = -vHeight * scale; double z1 = (my - wallY1 + woff.y) * scale; double z2 = (my - wallY2 + woff.y) * scale; double z3 = (my - wallY3 + woff.y) * scale; // Left wall part generateEmptyWall(sb, x1, y1, z1, x2, y2, z2, wallColor, 2000, -1001, false, "Wall " + wallId + (door ? " (left part)" : "")); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ if (door) { doorWall = wall; double doorX2 = doorX1 + cos * DOORWIDTH; double doorY2 = doorY1 + sin * DOORWIDTH; double dx1 = (doorX1 - mx + woff.x + sin * DOORDEPTH) * scale; double dx2 = (doorX2 - mx + woff.x + sin * DOORDEPTH) * scale; double dy1 = (DOORHEIGHT - vHeight) * scale; double dy2 = -vHeight * scale; double dz1 = (my - doorY1 + woff.y + cos * DOORDEPTH) * scale; double dz2 = (my - doorY2 + woff.y + cos * DOORDEPTH) * scale; // Right wall part double sx1 = (doorX1 - mx + woff.x) * scale; double sx2 = (doorX2 - mx + woff.x) * scale; double sz1 = (my - doorY1 + woff.y) * scale; double sz2 = (my - doorY2 + woff.y) * scale; generateEmptyWall(sb, sx2, y1, sz2, x3, y2, z3, wallColor, 2000, -1001, false, "Wall " + wallId + " (right part)"); //$NON-NLS-1$ //$NON-NLS-2$ // Wall above door generateEmptyWall(sb, sx1, y1, sz1, sx2, dy1, sz2, wallColor, 2000, -1001, false, "Wall " + wallId + " (above door)"); //$NON-NLS-1$ //$NON-NLS-2$ // Top door frame generateEmptyWall(sb, sx1, dy1, dz1, dx2, dy1, sz2, wallColor, 3000, -200, true, "Door frame (top)"); //$NON-NLS-1$ // Left door frame generateEmptyWall(sb, sx1, dy1, sz1, dx1, dy2, dz1, wallColor, 500, -200, false, "Door frame (left)"); //$NON-NLS-1$ // Right door frame generateEmptyWall(sb, dx2, dy1, dz2, sx2, dy2, sz2, wallColor, 500, -200, false, "Door frame (right)"); //$NON-NLS-1$ // Next room Rgb_type nextColor = new Rgb_typeImpl(wallColor.getR() * 2 / 3, wallColor.getG() * 2 / 3, wallColor.getB() * 2 / 3); double nx1 = x1 + sin * DOORDEPTH * scale; double nz1 = z1 + cos * DOORDEPTH * scale; double nx2 = nx1 + cos * wallW * scale; double nz2 = nz1 - sin * wallW * scale; double ex1 = x1 + sin * sceneSize.x * scale; double ez1 = z1 + cos * sceneSize.x * scale; double ex2 = ex1 + cos * wallW * scale; double ez2 = ez1 - sin * wallW * scale; double dzoom = 27 * zoom * scale; generateWallWithImage(sb, roomName, tagId++, "door.png", //$NON-NLS-1$ nx1, y1, nz1, ex1, y2, ez1, nextColor, 8000, -200, 720 - angle, dzoom, 0d, "none", //$NON-NLS-1$ "Neighbour room (left)", true); //$NON-NLS-1$ generateWallWithImage(sb, roomName, tagId++, "door.png", //$NON-NLS-1$ ex1, y1, ez1, ex2, y2, ez2, nextColor, 8000, -200, 630 - angle, dzoom, 0d, "none", //$NON-NLS-1$ "Neighbour room (middle)", true); //$NON-NLS-1$ generateWallWithImage(sb, roomName, tagId++, "door.png", //$NON-NLS-1$ ex2, y1, ez2, nx2, y2, nz2, nextColor, 8000, -200, 540 - angle, dzoom, 0d, "none", //$NON-NLS-1$ "Neighbour room (right)", true); //$NON-NLS-1$ } List<String> exhibits = wall.getExhibit(); for (String id : exhibits) { final ExhibitImpl exhibit = dbManager.obtainById(ExhibitImpl.class, id); if (exhibit != null) { AssetImpl asset = dbManager.obtainAsset(exhibit.getAsset()); if (asset != null) { artists.addAll(Core.fromStringList(exhibit.getCredits(), ",")); //$NON-NLS-1$ int isize = (int) (Math.max(exhibit.getWidth(), exhibit.getHeight()) * scale / zoom); String copyright = null; if (gallery.getAddWatermark()) { copyright = asset.getCopyright(); if (copyright == null || copyright.isEmpty()) copyright = gallery.getCopyright(); if (copyright != null && copyright.isEmpty()) copyright = null; } URI uri = volumeManager.findExistingFile(asset, false); if (uri != null) { File originalFile = null; try { originalFile = box.obtainFile(uri); } catch (IOException e) { status.add(new Status(IStatus.ERROR, CoreActivator.PLUGIN_ID, NLS.bind(Messages.ExhibitionJob_download_image_failed, uri), e)); } if (originalFile != null) { int rotation = asset.getRotation(); String imageName = tagId + ".jpg"; //$NON-NLS-1$ createManifestEntry(newsettings, exhibit.getStringId(), imageName, uri, rotation, isize, copyright, gallery.getRadius(), gallery.getAmount(), gallery.getThreshold(), gallery.getApplySharpening()); File imageFile = new File(roomFolder, imageName); if (manifestEntryModified(settings, imageFile, exhibit.getStringId(), uri, rotation, isize, copyright, gallery.getRadius(), gallery.getAmount(), gallery.getThreshold(), gallery.getApplySharpening())) { UnsharpMask umask = gallery.getApplySharpening() ? ImageActivator .getDefault().computeUnsharpMask(gallery.getRadius(), gallery.getAmount(), gallery.getThreshold()) : null; ZImage zimage = null; try { zimage = CoreActivator.getDefault().getHighresImageLoader().loadImage( null, status, originalFile, rotation, asset.getFocalLengthIn35MmFilm(), new Rectangle(0, 0, isize, isize), 1d, 1d, true, ImageConstants.SRGB, null, umask, null, fileWatcher, opId, this); } catch (UnsupportedOperationException e) { // do nothing } Image image = null; image = zimage == null ? null : zimage.getSwtImage(shell.getDisplay(), true, ZImage.CROPPED, isize, isize); if (image != null) { addToEntryImage(image, entryX, entryY, tileSize); try { image = decorateImage(image, copyright); imageFile = saveImage(imageFile, image, SWT.IMAGE_JPEG, jpegQuality); } finally { if (image != null) image.dispose(); } } } else { reviewSequence(settings, exhibit.getStringId(), imageName, roomFolder, renamedFiles); ImageData[] data = new ImageLoader().load(imageFile.getAbsolutePath()); Image image = new Image(shell.getDisplay(), data[0]); addToEntryImage(image, entryX, entryY, tileSize); image.dispose(); } ++entryX; if (entryX >= entries) { entryX = 0; ++entryY; } Boolean b = exhibit.getHideLabel(); boolean hideLabel = b == null ? gallery.getHideLabel() : b.booleanValue(); if (!hideLabel) { final int tid = tagId; shell.getDisplay().asyncExec(() -> { if (!shell.isDisposed()) generateLabel(shell.getDisplay(), exhibit, roomFolder, tid); }); } generateExhibit(sb, wall, roomName, exhibit, tagId++, sceneSize, woff, scale, zoom, headHeight, hideLabel); } } } } monitor.worked(1); } ++wallId; } for (File file : renamedFiles) { String fileName = file.getAbsolutePath(); if (fileName.endsWith(TMP)) file.renameTo(new File(fileName.substring(0, fileName.length() - TMP.length()))); } if (entryGC != null) { entryGC.dispose(); entryGC = null; } if (entryImage != null) saveImage(new File(roomFolder, "entry.jpg"), entryImage, SWT.IMAGE_JPEG, jpegQuality); //$NON-NLS-1$ if (doorWall != null && infoPlatePosition != INFONONE) generateInfoPlate(sb, shell, artists, roomFolder, roomName, doorWall, scale, woff, mx, my, tagId); } finally { if (entryGC != null) entryGC.dispose(); if (entryImage != null) entryImage.dispose(); } manifest.delete(); try { newsettings.save(manifest.getAbsolutePath()); } catch (IOException e) { // ignore } return --tagId; }
From source file:com.metaaps.eoclipse.common.Util.java
License:Open Source License
static public DialogSettings getDialogSettings(String section) { DialogSettings dialogSettings = new DialogSettings(section); try {//from ww w.ja va2s. c om // loads existing settings if any. dialogSettings.load("eoclipsesettings.xml"); } catch (IOException e) { e.printStackTrace(); } return dialogSettings; }
From source file:com.sonatype.buildserver.monitor.MonitorPersistence.java
License:Open Source License
/** * Retrieve a monitor given its ID./*from w w w .j a v a 2s . c om*/ * * @param id the monitor's id * @return the loaded monitor, or null if it does not exist */ static synchronized Object load(String id) { DialogSettings settings = new DialogSettings(id.toString()); try { settings.load(getLocation(id)); } catch (IOException e) { return new CompositeMonitor(UUID.fromString(id)); } String[] monitors = settings.getArray(MONITORS); if (monitors != null) { return loadComposite(id, monitors); } return loadMonitor(id, settings); }
From source file:com.sonatype.buildserver.monitor.MonitorPersistence.java
License:Open Source License
private static HudsonMonitor loadMonitor(String id) throws IOException { DialogSettings settings = new DialogSettings(id); settings.load(getLocation(id)); return loadMonitor(id, settings); }
From source file:de.maybebuggy.finder.commands.FinderDialog.java
License:Open Source License
private SearchHistory getSearchHistory() { String fileName = getSearchHistoryFileName(); SearchHistory history = new SearchHistory(); DialogSettings searchDirectories = new DialogSettings("SearchHistory"); try {//from ww w . j a v a 2 s .co m createFileIfMissing(fileName); searchDirectories.load(fileName); } catch (IOException e) { e.printStackTrace(); return history; } String[] paths = searchDirectories.getArray("searchPaths"); history.addSearchPaths(paths); String[] terms = searchDirectories.getArray("searchTerms"); history.addSearchTerms(terms); return history; }
From source file:de.maybebuggy.finder.commands.FinderDialog.java
License:Open Source License
private void restoreLastUsed() { String fileName = getSettingsFileName(); DialogSettings settings = new DialogSettings("FinderDialog"); try {/*ww w . j av a2 s .co m*/ createFileIfMissing(fileName); settings.load(fileName); } catch (IOException e) { // ignore e.printStackTrace(); return; } SearchHistory history = getSearchHistory(); String[] items = history.getSearchTerms().toArray(new String[] {}); searchTermField.setItems(items); searchTermField.setText(items[0]); items = history.getSearchPaths().toArray(new String[] {}); searchPathField.setItems(items); searchPathField.setText(items[0]); matchWhole.setSelection(settings.getBoolean("matchWhole")); caseSensitive.setSelection(settings.getBoolean("caseSensitive")); searchForClasses.setSelection(settings.getBoolean("searchForClasses")); searchForFiles.setSelection(settings.getBoolean("searchForFiles")); searchJars.setSelection(settings.getBoolean("searchJars")); searchZips.setSelection(settings.getBoolean("searchZips")); searchDefaultArchives.setSelection(settings.getBoolean("searchDefaultArchives")); searchArchivesRecursive.setSelection(settings.getBoolean("searchArchivesRecursive")); additionalExtensions.setText(settings.get("additionalExtensions")); }
From source file:org.eclipse.fx.ide.fxml.wizards.NewFXMLWizard.java
License:Open Source License
/** * Create a new instance//from w w w .j a va 2s. c o m */ public NewFXMLWizard() { if (getDialogSettings() == null) { DialogSettings settings = new DialogSettings("new-fxml"); //$NON-NLS-1$ try { settings.load(SETTINGS_FILE); } catch (IOException e) { //nothing } setDialogSettings(settings); } }