blob: 6f80370f97b42e01014a6a3ff64254055c6581bd (
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
|
/*******************************************************************************
* Copyright (c) 2007 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.ui.CUIPlugin;
public class ManageConfigRunner implements IConfigManager {
private static final String MANAGE_TITLE = UIMessages.getString("ManageConfigDialog.0"); //$NON-NLS-1$
protected static ManageConfigRunner instance = null;
private ICProjectDescription des = null;
private IProject prj = null;
public static ManageConfigRunner getDefault() {
if (instance == null)
instance = new ManageConfigRunner();
return instance;
}
public boolean canManage(IProject[] obs) {
// Only one project can be accepted
return (obs != null && obs.length == 1);
}
public boolean manage(IProject[] obs, boolean doOk) {
if (!canManage(obs))
return false;
ManageConfigDialog d = new ManageConfigDialog(CUIPlugin.getActiveWorkbenchShell(),
obs[0].getName()+ ": " + MANAGE_TITLE, obs[0]); //$NON-NLS-1$
boolean result = false;
if (d.open() == Window.OK) {
if (doOk) {
des = d.getProjectDescription();
prj = obs[0];
if(des != null)
try {
PlatformUI.getWorkbench().getProgressService().run(false, false, getRunnable());
} catch (InvocationTargetException e) {}
catch (InterruptedException e) {}
}
AbstractPage.updateViews(obs[0]);
result = true;
} else if (doOk) {
CDTPropertyManager.performCancel(d.getShell());
}
return result;
}
public IRunnableWithProgress getRunnable() {
return new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException {
CUIPlugin.getDefault().getShell().getDisplay().syncExec(new Runnable() {
public void run() {
try {
CoreModel.getDefault().setProjectDescription(prj, des);
} catch (CoreException e) {
e.printStackTrace();
}
}
});
}
});
}
}
|