Skip to content

Commit

Permalink
Solve some "Discouraged access" by using API
Browse files Browse the repository at this point in the history
  • Loading branch information
EcljpseB0T authored and jukzi committed Dec 8, 2023
1 parent 8abe1b1 commit 54e2bcd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.internal.runtime.RuntimeLog;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.ILog;
import org.eclipse.e4.ui.css.core.dom.CSSStylableElement;
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler;
import org.eclipse.e4.ui.css.core.dom.properties.providers.AbstractCSSPropertyHandlerProvider;
Expand Down Expand Up @@ -232,7 +230,7 @@ public Collection<String> getCSSProperties(Object element) {

protected void logError(String message) {
// we log as an error to ensure it's shown
RuntimeLog.log(new Status(IStatus.ERROR, "org.eclipse.e4.ui.css.core", message));
ILog.get().error(message);
}

private class DeprecatedPropertyHandlerWrapper implements ICSSPropertyHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Hashtable;
import org.eclipse.core.internal.runtime.InternalPlatform;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.DialogSettings;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.osgi.service.datalocation.Location;
Expand Down Expand Up @@ -266,7 +266,7 @@ private IPath getStateLocationOrNull() {
// However, using it causes problems in the activation order
// So, for now, we get it directly.
try {
return InternalPlatform.getDefault().getStateLocation(context.getBundle(), true);
return Platform.getStateLocation(context.getBundle());
} catch (IllegalStateException e) {
// This occurs if -data=@none is explicitly specified, so ignore
// this silently.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.pde.internal.core.util.CoreUtility;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
Expand Down Expand Up @@ -386,7 +385,7 @@ public void copyResourceToProject() {
// file).getContributionData().className + ".class";
IPath newPath = IPath.fromOSString(path);
if (newPath.isEmpty() == false) {
CoreUtility.createFolder(project.getFolder(newPath));
NonReferencedResourceDialog.createFolder(project.getFolder(newPath));
}
if (className != null) {
newPath.append(className + ".class"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import java.util.jar.Manifest;
import java.util.zip.ZipFile;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
Expand All @@ -39,7 +41,6 @@
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.pde.internal.core.util.CoreUtility;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
Expand Down Expand Up @@ -404,6 +405,16 @@ public IFile getResult() {
return result;
}

public static void createFolder(IFolder folder) throws CoreException {
if (!folder.exists()) {
IContainer parent = folder.getParent();
if (parent instanceof IFolder) {
createFolder((IFolder) parent);
}
folder.create(true, true, null);
}
}

public void copyResourceToProject(IProject project) {
try {
final ProjectFolderPickerDialog dlg = new ProjectFolderPickerDialog(getShell(), project, file.getFullPath()
Expand All @@ -423,7 +434,7 @@ protected Control createContents(Composite parent) {
// file).getContributionData().className + ".class";
IPath newPath = IPath.fromOSString(dlg.getValue());
if (newPath.isEmpty() == false) {
CoreUtility.createFolder(project.getFolder(newPath));
createFolder(project.getFolder(newPath));
}
if (className != null) {
newPath.append(className + ".class"); //$NON-NLS-1$
Expand Down

0 comments on commit 54e2bcd

Please sign in to comment.