本文整理汇总了Java中org.eclipse.jface.util.Policy类的典型用法代码示例。如果您正苦于以下问题:Java Policy类的具体用法?Java Policy怎么用?Java Policy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Policy类属于org.eclipse.jface.util包,在下文中一共展示了Policy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
if(selection.isEmpty())
return null;
Collection<IProject> projects = SelectionUtils.getProjects(selection);
if(!projects.isEmpty()){
try {
CodeScannerView view = (CodeScannerView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(CodeScannerView.ID);
if(view != null){
view.scan(projects);
}
} catch (PartInitException e) {
Policy.logException(e);
}
}
return null;
}
示例2: warnAddingTraits
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
private boolean warnAddingTraits(
Shell shell, TreeNode tgt, Set<String> addingTraits) {
final String title = "Adding traits";
final S msg = new S();
msg.addf("The source entry has more traits than the target one. ");
msg.addf("To proceed, the following traits:%n");
List<String> traitList = new ArrayList<>(addingTraits);
traitList.sort(Policy.getComparator());
for(String tr: addingTraits) {
msg.addf("%s%n", tr);
}
msg.addf("%nwill be added to the target%n");
msg.addf("%s .%n", tgt.path());
msg.addf("%nDo you want to do so?");
return MessageDialog.openConfirm(shell, title, msg.toString());
}
示例3: createSupportArea
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* Create the area for extra error support information.
*
* @param parent
*/
private void createSupportArea(Composite parent) {
ErrorSupportProvider provider = Policy.getErrorSupportProvider();
if (provider == null)
return;
Composite supportArea = new Composite(parent, SWT.NONE);
provider.createSupportArea(supportArea, status);
GridData supportData = new GridData(SWT.FILL, SWT.FILL, true, true);
supportData.verticalSpan = 3;
supportArea.setLayoutData(supportData);
if (supportArea.getLayout() == null){
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
supportArea.setLayout(layout); // Give it a default layout if one isn't set
}
}
示例4: hardClose
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* Closes this window.
*
* @return <code>true</code> if the window is (or was already) closed, and
* <code>false</code> if it is still open
*/
private boolean hardClose() {
// inform wizards
for (int i = 0; i < createdWizards.size(); i++) {
IWizard createdWizard = (IWizard) createdWizards.get(i);
try {
createdWizard.dispose();
} catch (Exception e) {
Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
Policy.getLog().log(status);
}
// Remove this dialog as a parent from the managed wizard.
// Note that we do this after calling dispose as the wizard or
// its pages may need access to the container during
// dispose code
createdWizard.setContainer(null);
}
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202534
// disposing the wizards could cause the image currently set in
// this dialog to be disposed. A subsequent repaint event during
// close would then fail. To prevent this case, we null out the image.
setTitleImage(null);
return super.close();
}
示例5: getSchemeIds
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* <p>
* Ascends all of the parents of the scheme until no more parents are found.
* </p>
* <p>
* This method completes in <code>O(n)</code>, where <code>n</code> is the
* height of the context tree.
* </p>
*
* @param schemeId
* The id of the scheme for which the parents should be found;
* may be <code>null</code>.
* @return The array of scheme ids (<code>String</code>) starting with
* <code>schemeId</code> and then ascending through its ancestors.
*/
private final String[] getSchemeIds(String schemeId) {
final List strings = new ArrayList();
while (schemeId != null) {
strings.add(schemeId);
try {
schemeId = getScheme(schemeId).getParentId();
} catch (final NotDefinedException e) {
Policy.getLog().log(
new Status(IStatus.ERROR, Policy.JFACE, IStatus.OK,
"Failed ascending scheme parents", //$NON-NLS-1$
e));
return new String[0];
}
}
return (String[]) strings.toArray(new String[strings.size()]);
}
示例6: hardClose
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* Closes this window.
*
* @return <code>true</code> if the window is (or was already) closed, and
* <code>false</code> if it is still open
*/
private boolean hardClose() {
// inform wizards
for (int i = 0; i < createdWizards.size(); i++) {
IWizard createdWizard = (IWizard) createdWizards.get(i);
try {
createdWizard.dispose();
} catch (Exception e) {
Status status = new Status(IStatus.ERROR, Policy.JFACE,
IStatus.ERROR, e.getMessage(), e);
Policy.getLog().log(status);
}
// Remove this dialog as a parent from the managed wizard.
// Note that we do this after calling dispose as the wizard or
// its pages may need access to the container during
// dispose code
createdWizard.setContainer(null);
}
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202534
// disposing the wizards could cause the image currently set in
// this dialog to be disposed. A subsequent repaint event during
// close would then fail. To prevent this case, we null out the image.
setTitleImage(null);
return super.close();
}
示例7: dispose
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* The <code>Wizard</code> implementation of this <code>IWizard</code>
* method disposes all the pages controls using
* <code>DialogPage.dispose</code>. Subclasses should extend this method
* if the wizard instance maintains addition SWT resource that need to be
* disposed.
*/
public void dispose() {
// notify pages
for (int i = 0; i < pages.size(); i++) {
try {
((IWizardPage) pages.get(i)).dispose();
} catch (Exception e) {
Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
Policy.getLog().log(status);
}
}
// dispose of image
if (defaultImage != null) {
JFaceResources.getResources().destroyImage(defaultImageDescriptor);
defaultImage = null;
}
}
示例8: assertElementsNotNull
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* Asserts that the given array of elements is itself non- <code>null</code>
* and contains no <code>null</code> elements.
*
* @param elements
* the array to check
*/
protected void assertElementsNotNull(Object[] elements) {
Assert.isNotNull(elements);
for (int i = 0, n = elements.length; i < n; ++i) {
Assert.isNotNull(elements[i]);
}
if (InternalPolicy.DEBUG_LOG_EQUAL_VIEWER_ELEMENTS
&& elements.length > 1) {
CustomHashtable elementSet = newHashtable(elements.length * 2);
for (int i = 0; i < elements.length; i++) {
Object element = elements[i];
Object old = elementSet.put(element, element);
if (old != null) {
String message = "Sibling elements in viewer must not be equal:\n " //$NON-NLS-1$
+ old + ",\n " + element; //$NON-NLS-1$
Policy.getLog().log(
new Status(IStatus.WARNING, Policy.JFACE, message,
new RuntimeException()));
return;
}
}
}
}
示例9: assertElementsNotNull
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* Asserts that the given array of elements is itself non- <code>null</code>
* and contains no <code>null</code> elements.
*
* @param parent
* the parent element
* @param elements
* the array to check
*
* @see #assertElementsNotNull(Object[])
*/
private void assertElementsNotNull(Object parent, Object[] elements) {
Assert.isNotNull(elements);
for (int i = 0, n = elements.length; i < n; ++i) {
Assert.isNotNull(elements[i]);
}
if (InternalPolicy.DEBUG_LOG_EQUAL_VIEWER_ELEMENTS
&& elements.length > 1) {
CustomHashtable elementSet = newHashtable(elements.length * 2);
for (int i = 0; i < elements.length; i++) {
Object element = elements[i];
Object old = elementSet.put(element, element);
if (old != null) {
String message = "Sibling elements in viewer must not be equal:\n " //$NON-NLS-1$
+ old
+ ",\n " + element + ",\n parent: " + parent; //$NON-NLS-1$ //$NON-NLS-2$
Policy.getLog().log(
new Status(IStatus.WARNING, Policy.JFACE, message,
new RuntimeException()));
return;
}
}
}
}
示例10: labelProviderChanged
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
public void labelProviderChanged(LabelProviderChangedEvent event) {
Control control = getControl();
if (control == null || control.isDisposed()) {
if (logWhenDisposed) {
String message = "Ignored labelProviderChanged notification because control is diposed." + //$NON-NLS-1$
" This indicates a potential memory leak."; //$NON-NLS-1$
if (!InternalPolicy.DEBUG_LOG_LABEL_PROVIDER_NOTIFICATIONS_WHEN_DISPOSED) {
// stop logging after the first
logWhenDisposed = false;
message += " This is only logged once per viewer instance," + //$NON-NLS-1$
" but similar calls will still be ignored."; //$NON-NLS-1$
}
Policy.getLog().log(
new Status(IStatus.WARNING, Policy.JFACE, message,
new RuntimeException()));
}
return;
}
ContentViewer.this.handleLabelProviderChanged(event);
}
示例11: handleSave
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* Save the values specified in the pages.
* <p>
* The default implementation of this framework method saves all pages of
* type <code>PreferencePage</code> (if their store needs saving and is a
* <code>PreferenceStore</code>).
* </p>
* <p>
* Subclasses may override.
* </p>
*/
protected void handleSave() {
Iterator nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator();
while (nodes.hasNext()) {
IPreferenceNode node = (IPreferenceNode) nodes.next();
IPreferencePage page = node.getPage();
if (page instanceof PreferencePage) {
// Save now in case tbe workbench does not shutdown cleanly
IPreferenceStore store = ((PreferencePage) page).getPreferenceStore();
if (store != null && store.needsSaving()
&& store instanceof IPersistentPreferenceStore) {
try {
((IPersistentPreferenceStore) store).save();
} catch (IOException e) {
String message =JFaceResources.format(
"PreferenceDialog.saveErrorMessage", new Object[] { page.getTitle(), e.getMessage() }); //$NON-NLS-1$
Policy.getStatusHandler().show(
new Status(IStatus.ERROR, Policy.JFACE, message, e),
JFaceResources.getString("PreferenceDialog.saveErrorTitle")); //$NON-NLS-1$
}
}
}
}
}
示例12: dispose
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* The <code>Wizard</code> implementation of this <code>IWizard</code>
* method disposes all the pages controls using
* <code>DialogPage.dispose</code>. Subclasses should extend this method if
* the wizard instance maintains addition SWT resource that need to be
* disposed.
*/
@Override
public void dispose() {
super.dispose();
// notify pages
for (int i = 0; i < pages.size(); i++) {
try {
pages.get(i).dispose();
} catch (Exception e) {
Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
Policy.getLog().log(status);
}
}
}
示例13: loadSavedResults
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
private void loadSavedResults() {
String fileName = getScanResultFileLocation();
try {
ScanResult result = RulesJSONProcessor.INSTANCE.fetchResults(fileName);
results.clear();
if (result.getRuleResults() != null) {
for (RuleScanResult ruleResult : result.getRuleResults()) {
results.put(ruleResult.getRule(),
ruleResult.getDescriptors());
}
}
tagsViewer.setInput(results.keySet().toArray());
tagsViewer
.setSelection(results.isEmpty() ? StructuredSelection.EMPTY
: new StructuredSelection(results.keySet()
.iterator().next()));
loadLbl.setText(Messages.bind(
Messages.CodeScannerView_SCANRESULTS_TIME,
DateFormat.getDateTimeInstance().format(
result.getSearchDate())));
} catch (FileNotFoundException e) {
Policy.logException(e);
}
}
示例14: fill
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* The control item implementation of this <code>IContributionItem</code>
* method calls the <code>createControl</code> framework method to
* create a control under the given parent, and then creates
* a new tool item to hold it.
* Subclasses must implement <code>createControl</code> rather than
* overriding this method.
*/
public final void fill(ToolBar parent, int index) {
Control control = createControl(parent);
if (control == null) {
Policy.logException(new IllegalStateException("createControl(Composite) of " + getClass() //$NON-NLS-1$
+ " returned null, cannot fill toolbar")); //$NON-NLS-1$
} else {
ToolItem ti = new ToolItem(parent, SWT.SEPARATOR, index);
ti.setControl(control);
ti.setWidth(computeWidth(control));
mainControl = ti;
}
}
示例15: dispose
import org.eclipse.jface.util.Policy; //导入依赖的package包/类
/**
* The <code>Wizard</code> implementation of this <code>IWizard</code> method disposes all the pages controls using
* <code>DialogPage.dispose</code>. Subclasses should extend this method if the wizard instance maintains addition SWT
* resource that need to be disposed.
*/
public void dispose() {
// notify pages
for (int i = 0; i < wizardPages.size(); i++) {
try {
((IWizardPage) wizardPages.get(i)).dispose();
} catch (Exception e) {
Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
Policy.getLog().log(status);
}
}
super.dispose();
}