org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/RefreshJob.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 19 Aug 2010 16:13:44 -0700
changeset 468 a05c6e5cc7d9
parent 304 d92630dec325
permissions -rw-r--r--
Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
300
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/**
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
 *
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * Contributors:
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * Description:
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 * Overview:
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
 * Details:
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
 * Failures and causes:
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
 */
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
package org.symbian.tools.wrttools.previewer.preview;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
301
a908b05787d1 Bug 2444 - Rename project creates bad state
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 300
diff changeset
    21
import java.util.Map.Entry;
300
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
301
a908b05787d1 Bug 2444 - Rename project creates bad state
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 300
diff changeset
    23
import org.eclipse.core.resources.IProject;
300
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
import org.eclipse.core.resources.IResourceDelta;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
import org.eclipse.core.resources.ResourcesPlugin;
301
a908b05787d1 Bug 2444 - Rename project creates bad state
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 300
diff changeset
    26
import org.eclipse.core.runtime.IPath;
300
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
import org.eclipse.core.runtime.IProgressMonitor;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
import org.eclipse.core.runtime.IStatus;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
import org.eclipse.core.runtime.Status;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
import org.eclipse.core.runtime.jobs.Job;
468
a05c6e5cc7d9 Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 304
diff changeset
    31
import org.symbian.tools.tmw.previewer.internal.PreviewerUtil;
a05c6e5cc7d9 Previewer now is TMWed (can support projects with different natures). Note: this commit does not compile. This previewer still only supports WRT libraries
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 304
diff changeset
    32
import org.symbian.tools.tmw.previewer.internal.PreviewerUtil.ChangedResourcesCollector;
300
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
public class RefreshJob extends Job {
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
    private final IResourceDelta delta;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
    private final PreviewView view;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
    public RefreshJob(IResourceDelta delta, PreviewView view) {
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
        super("Refresh preview browser");
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
        this.delta = delta;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
        this.view = view;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
        setRule(ResourcesPlugin.getWorkspace().getRoot());
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    43
        setSystem(true);
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    44
    }
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    45
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
    @Override
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    47
    protected IStatus run(IProgressMonitor monitor) {
304
d92630dec325 Refactoring server-side preview code
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 303
diff changeset
    48
        final ChangedResourcesCollector visitor = PreviewerUtil.collectResourceChanges(delta);
301
a908b05787d1 Bug 2444 - Rename project creates bad state
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 300
diff changeset
    49
        for (Entry<IProject, IPath> entry : visitor.renamed.entrySet()) {
a908b05787d1 Bug 2444 - Rename project creates bad state
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 300
diff changeset
    50
            view.projectRenamed(entry.getKey(), entry.getValue());
a908b05787d1 Bug 2444 - Rename project creates bad state
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 300
diff changeset
    51
        }
300
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    52
        if (visitor.files.size() > 0) {
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    53
            view.refreshPages(visitor.files);
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    54
        }
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    55
        return Status.OK_STATUS;
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    56
    }
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    57
9505af44d7bf Bug 2480 and bug 2430
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    58
}