Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: de5557a287cca4dbc90849bc84ff12a98a3d361e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/******************************************************************************
 * Copyright (c) 2005, 2018 BEA Systems, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    Konstantin Komissarchik - initial API and implementation
 ******************************************************************************/

package org.eclipse.wst.web.ui.internal;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator;
import org.eclipse.ui.views.markers.WorkbenchMarkerResolution;
import org.eclipse.wst.common.componentcore.internal.ModuleMigratorManager;
import org.eclipse.wst.web.ui.internal.WSTWebUIPlugin;

/**
 * This has been deprecated since WTP 3.1.2 and will be deleted post WTP 3.2.
 * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=292934
 * @deprecated 
 * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a>
 */
public final class ModuleCoreValidatorMarkerResolutions

    implements IMarkerResolutionGenerator
    
{
    @Override
	public IMarkerResolution[] getResolutions( IMarker marker )
    {
        return new IMarkerResolution[] 
        { 
            new ModuleCoreMigrationResolution( marker ) 
        };
    }
    
    private class ModuleCoreMigrationResolution extends WorkbenchMarkerResolution
        
    {
        private final IMarker theMarker;
        private final String MARKERTYPE = "org.eclipse.wst.common.modulecore.ModuleCoreValidatorMarker"; //$NON-NLS-1$
        
        public ModuleCoreMigrationResolution( IMarker marker )
        {
            this.theMarker = marker;
        }
        
        @Override
		public String getLabel()
        {
            return Resources.migrateMetaData;
        }

        
        
        @Override
		public void run( IMarker marker )
        {
            
            IProject proj = marker.getResource().getProject();
            
            try
            {
        		ModuleMigratorManager manager = ModuleMigratorManager.getManager(proj);
        		if (!manager.isMigrating() && !ResourcesPlugin.getWorkspace().isTreeLocked()) 
        				manager.migrateOldMetaData(proj,true);
            }
            catch( Exception e )
            {
            	WSTWebUIPlugin.logError(e);
            }
        }

		@Override
		public String getDescription() {
			return Resources.migrateMetaData;
		}

		@Override
		public Image getImage() {
			return null;
		}

		@Override
		public IMarker[] findOtherMarkers(IMarker[] markers) {
			List marks = new ArrayList();
			for (int i = 0; i < markers.length; i++) {
				IMarker marker = markers[i];
				try {
					if (marker.getType().equals(MARKERTYPE) && !(marker.equals(theMarker)))
						marks.add(marker);
				} catch (CoreException e) {
					WSTWebUIPlugin.logError(e);
				}
			}
			return (IMarker[])marks.toArray(new IMarker[marks.size()]);
		}
     
    }

    private static final class Resources
    
        extends NLS
        
    {
    	public static String migrateMetaData;
        
        static
        {
            initializeMessages( ModuleCoreValidatorMarkerResolutions.class.getName(), 
                                Resources.class );
        }
    }
    
    
}

Back to the top