blob: a10f63d5ab67c78214819705c66c8ec3977eada1 (
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
|
/*******************************************************************************
* Copyright (c) 2000, 2005 IBM 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
/*
* http://dev.eclipse.org/bugs/show_bug.cgi?id=19104
*/
public class ActionUtil {
private ActionUtil(){
}
//bug 31998 we will have to disable renaming of linked packages (and cus)
public static boolean mustDisableCModelAction(Shell shell, Object element) {
return false;
// if (!(element instanceof IPackageFragment) && !(element instanceof IPackageFragmentRoot))
// return false;
//
// IResource resource= ResourceUtil.getResource(element);
// if ((resource == null) || (! (resource instanceof IFolder)) || (! resource.isLinked()))
// return false;
//
// MessageDialog.openInformation(shell, ActionMessages.getString("ActionUtil.not_possible"), ActionMessages.getString("ActionUtil.no_linked")); //$NON-NLS-1$ //$NON-NLS-2$
// return true;
}
public static boolean isProcessable(Shell shell, CEditor editor) {
if (editor == null)
return true;
ICElement input= SelectionConverter.getInput(editor);
// if a Java editor doesn't have an input of type Java element
// then it is for sure not on the build path
if (input == null) {
MessageDialog.openInformation(shell,
ActionMessages.getString("ActionUtil.notOnBuildPath.title"), //$NON-NLS-1$
ActionMessages.getString("ActionUtil.notOnBuildPath.message")); //$NON-NLS-1$
return false;
}
return isProcessable(shell, input);
}
public static boolean isProcessable(Shell shell, Object element) {
if (!(element instanceof ICElement))
return true;
if (isOnBuildPath((ICElement)element))
return true;
MessageDialog.openInformation(shell,
ActionMessages.getString("ActionUtil.notOnBuildPath.title"), //$NON-NLS-1$
ActionMessages.getString("ActionUtil.notOnBuildPath.message")); //$NON-NLS-1$
return false;
}
public static boolean isOnBuildPath(ICElement element) {
//fix for bug http://dev.eclipse.org/bugs/show_bug.cgi?id=20051
if (element.getElementType() == ICElement.C_PROJECT)
return true;
// ICProject project= element.getCProject();
// if (!project.isOnSourceRoot(element.getResource()))
// return false;
return true;
}
}
|