Example usage for org.eclipse.jface.dialogs DialogSettings save

List of usage examples for org.eclipse.jface.dialogs DialogSettings save

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs DialogSettings save.

Prototype

private void save(XMLWriter out) throws IOException 

Source Link

Usage

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 {/* www  . j a  v a 2s  .  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;//from w  w  w  . j ava  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.sonatype.buildserver.monitor.MonitorPersistence.java

License:Open Source License

/**
 * Persist a {@code HudsonMonitor}, it can be reloaded later using the monitor's ID.
 * /*  w  w w .  ja  v  a  2  s .c  om*/
 * @param monitor the monitor to persist
 */
static void store(HudsonMonitor monitor) {
    synchronized (monitor) {
        DialogSettings settings = new DialogSettings(monitor.getId().toString());
        settings.put(ADDRESS, monitor.getServerURI().toString());

        Collection<String> jobIds = monitor.getMonitoredJobIds();
        if (jobIds != null && jobIds.size() > 0)
            settings.put(JOBS, jobIds.toArray(new String[jobIds.size()]));

        try {
            settings.save(getLocation(monitor.getId().toString()));
        } catch (IOException e) {
            log.error("Error while saving Hudson preferences: " + e.getMessage());
        }
    }
}

From source file:com.sonatype.buildserver.monitor.MonitorPersistence.java

License:Open Source License

/**
 * Persist a {@code CompositeMonitor}, it can be reloaded later using the monitor's ID.
 * /* w w  w  . j  a  v  a 2s  .  c o m*/
 * @param compositeMonitor the monitor to persist
 */
static void store(CompositeMonitor compositeMonitor) {
    synchronized (compositeMonitor) {
        DialogSettings settings = new DialogSettings(compositeMonitor.getId().toString());
        Collection<HudsonMonitor> monitors = compositeMonitor.getAllMonitors();

        Collection<String> monitorIDs = new ArrayList<String>();
        for (HudsonMonitor m : monitors) {
            store(m);
            monitorIDs.add(m.getId().toString());
        }
        settings.put(MONITORS, monitorIDs.toArray(new String[monitorIDs.size()]));

        try {
            settings.save(getLocation(compositeMonitor.getId().toString()));
        } catch (IOException e) {
            log.error("Error while saving Hudson preferences: " + e.getMessage());
        }
    }
}

From source file:de.maybebuggy.finder.commands.FinderDialog.java

License:Open Source License

private void saveSearchHistory(SearchHistory history) {
    try {//from www  .ja  v a2s . c  o m
        String fileName = getSearchHistoryFileName();
        createFileIfMissing(fileName);

        DialogSettings searchDirectories = new DialogSettings("SearchHistory");
        searchDirectories.put("searchPaths", history.getSearchPaths().toArray(new String[] {}));
        searchDirectories.put("searchTerms", history.getSearchTerms().toArray(new String[] {}));

        searchDirectories.save(fileName);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:de.maybebuggy.finder.commands.FinderDialog.java

License:Open Source License

private void saveLastUsed() {
    try {//  ww  w .ja va2 s  .  c o  m
        String fileName = getSettingsFileName();
        createFileIfMissing(fileName);

        DialogSettings settings = new DialogSettings("FinderDialog");
        SearchHistory history = getSearchHistory();
        history.addSearchTerm(searchTermField.getText());
        history.addSearchPath(searchPathField.getText());
        saveSearchHistory(history);
        settings.put("matchWhole", matchWhole.getSelection());
        settings.put("caseSensitive", caseSensitive.getSelection());
        settings.put("searchForClasses", searchForClasses.getSelection());
        settings.put("searchForFiles", searchForFiles.getSelection());
        settings.put("searchJars", searchJars.getSelection());
        settings.put("searchZips", searchZips.getSelection());
        settings.put("searchDefaultArchives", searchDefaultArchives.getSelection());
        settings.put("searchArchivesRecursive", searchArchivesRecursive.getSelection());
        settings.put("additionalExtensions", additionalExtensions.getText());
        settings.save(fileName);
    } catch (IOException e) {
        e.printStackTrace();
        //ignore
    }
}

From source file:org.eclipsetrader.ui.internal.application.Activator.java

License:Open Source License

private void migrateDialogSections() throws Exception {
    IPath workspacePath = Platform.getLocation().append(".metadata").append(".plugins");

    File dialogSettingsFile = workspacePath.append("org.eclipsetrader.ui").append("dialog_settings.xml")
            .toFile();//from ww w.  j av a  2  s  . c  o  m
    DialogSettings dialogSettings = new DialogSettings("Workbench");
    if (dialogSettingsFile.exists()) {
        dialogSettings.load(dialogSettingsFile.toString());
    }

    File legacyDialogSettingsFile = workspacePath.append("org.eclipsetrader.ui.charts")
            .append("dialog_settings.xml").toFile();
    if (legacyDialogSettingsFile.exists()) {
        DialogSettings legacyDialogSettings = new DialogSettings("Workbench");
        legacyDialogSettings.load(legacyDialogSettingsFile.toString());

        IDialogSettings[] childSections = legacyDialogSettings.getSections();
        migrateSections(childSections, dialogSettings);

        legacyDialogSettingsFile.delete();
    }

    legacyDialogSettingsFile = workspacePath.append("org.eclipsetrader.ui.trading")
            .append("dialog_settings.xml").toFile();
    if (legacyDialogSettingsFile.exists()) {
        DialogSettings legacyDialogSettings = new DialogSettings("Workbench");
        legacyDialogSettings.load(legacyDialogSettingsFile.toString());

        IDialogSettings[] childSections = legacyDialogSettings.getSections();
        migrateSections(childSections, dialogSettings);

        legacyDialogSettingsFile.delete();
    }

    legacyDialogSettingsFile = workspacePath.append("org.eclipsetrader.ui.ats").append("dialog_settings.xml")
            .toFile();
    if (legacyDialogSettingsFile.exists()) {
        DialogSettings legacyDialogSettings = new DialogSettings("Workbench");
        legacyDialogSettings.load(legacyDialogSettingsFile.toString());

        IDialogSettings[] childSections = legacyDialogSettings.getSections();
        migrateSections(childSections, dialogSettings);

        legacyDialogSettingsFile.delete();
    }

    if (!dialogSettingsFile.exists()) {
        dialogSettingsFile.getParentFile().mkdirs();
    }
    dialogSettings.save(dialogSettingsFile.toString());
}

From source file:org.wesnoth.preprocessor.PreprocessorUtils.java

License:Open Source License

/**
 * Saves the current timestamps for preprocessed files
 * to filesystem//from   w  w w. java  2s  .co m
 */
public void saveTimestamps() {
    DialogSettings settings = new DialogSettings("preprocessed"); //$NON-NLS-1$
    try {
        settings.put("files", //$NON-NLS-1$
                filesTimeStamps_.keySet().toArray(new String[filesTimeStamps_.size()]));
        List<String> timestamps = new ArrayList<String>();
        for (Long timestamp : filesTimeStamps_.values()) {
            timestamps.add(timestamp.toString());
        }
        settings.put("timestamps", //$NON-NLS-1$
                timestamps.toArray(new String[timestamps.size()]));
        settings.save(PREPROCESSED_FILE_PATH);
    } catch (Exception e) {
        Logger.getInstance().logException(e);
    }
}

From source file:org.wesnoth.preprocessor.PreprocessorUtils.java

License:Open Source License

/**
 * Restores the timestamps for preprocessed files from
 * the filesystem//from   www .  java2s  . co  m
 */
public void restoreTimestamps() {
    DialogSettings settings = new DialogSettings("preprocessed"); //$NON-NLS-1$
    filesTimeStamps_.clear();

    try {
        // ensure the creation of a valid file if it doesn't exist
        if (!new File(PREPROCESSED_FILE_PATH).exists()) {
            settings.save(PREPROCESSED_FILE_PATH);
        }

        settings.load(PREPROCESSED_FILE_PATH);
        String[] timestamps = settings.getArray("timestamps"); //$NON-NLS-1$
        String[] files = settings.getArray("files"); //$NON-NLS-1$
        if (timestamps != null && files != null && timestamps.length == files.length) {
            for (int index = 0; index < files.length; ++index) {
                filesTimeStamps_.put(files[index], Long.valueOf(timestamps[index]));
            }
        }
    } catch (IOException e) {
        Logger.getInstance().logException(e);
    }
}

From source file:org.wesnoth.utils.PreprocessorUtils.java

License:Open Source License

/**
 * Saves the current timestamps for preprocessed files
 * to filesystem/*www  .  j  a  v  a  2 s. com*/
 */
public void saveTimestamps() {
    IPath path = Activator.getDefault().getStateLocation();
    String filename = path.append("preprocessed.txt").toOSString(); //$NON-NLS-1$
    DialogSettings settings = new DialogSettings("preprocessed"); //$NON-NLS-1$
    try {
        settings.put("files", filesTimeStamps_.keySet().toArray(new String[0])); //$NON-NLS-1$
        List<String> timestamps = new ArrayList<String>();
        for (Long timestamp : filesTimeStamps_.values()) {
            timestamps.add(timestamp.toString());
        }
        settings.put("timestamps", timestamps.toArray(new String[0])); //$NON-NLS-1$
        settings.save(filename);
    } catch (Exception e) {
        Logger.getInstance().logException(e);
    }
}