Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.win32/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName
Bundle-SymbolicName: org.eclipse.ui.win32
Bundle-Version: 3.5.300.qualifier
Bundle-Version: 3.5.400.qualifier
Bundle-Vendor: %providerName
Fragment-Host: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)"
Require-Bundle: org.eclipse.core.resources;resolution:=optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,19 @@ public class OleEditor extends EditorPart {
* The resource listener updates the receiver when
* a change has occurred.
*/
private IResourceChangeListener resourceListener = new IResourceChangeListener() {
private final IResourceChangeListener resourceListener = new IResourceChangeListener() {

@Override
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta mainDelta = event.getDelta();
if (mainDelta == null)
if (mainDelta == null) {
return;
}
IResourceDelta affectedElement = mainDelta.findMember(resource
.getFullPath());
if (affectedElement != null)
if (affectedElement != null) {
processDelta(affectedElement);
}
}

/*
Expand Down Expand Up @@ -115,8 +117,9 @@ private boolean processDelta(final IResourceDelta delta) {
break;
}

if (changeRunnable != null)
if (changeRunnable != null) {
update(changeRunnable);
}

return true; // because we are sitting on files anyway
}
Expand Down Expand Up @@ -191,8 +194,9 @@ public void createPartControl(Composite parent) {

private void createClientSite() {
//If there was an OLE Error or nothing has been created yet
if (clientFrame == null || clientFrame.isDisposed())
if (clientFrame == null || clientFrame.isDisposed()) {
return;
}
// Create a OLE client site.
try {
clientSite = new OleClientSite(clientFrame, SWT.NONE, source);
Expand All @@ -215,8 +219,9 @@ private void createClientSite() {
*/
private void displayErrorDialog(String title, String message) {
Shell parent = null;
if (getClientSite() != null)
if (getClientSite() != null) {
parent = getClientSite().getShell();
}
MessageDialog.openError(parent, title, message);
}

Expand All @@ -242,8 +247,9 @@ public void dispose() {
* Print this object's contents
*/
public void doPrint() {
if (clientSite == null)
if (clientSite == null) {
return;
}
BusyIndicator.showWhile(clientSite.getDisplay(),
() -> clientSite.exec(OLE.OLECMDID_PRINT, OLE.OLECMDEXECOPT_PROMPTUSER, null, null));
}
Expand All @@ -253,8 +259,9 @@ public void doPrint() {
*/
@Override
public void doSave(final IProgressMonitor monitor) {
if (clientSite == null)
if (clientSite == null) {
return;
}
BusyIndicator.showWhile(clientSite.getDisplay(), () -> {

// Do not try and use the component provided save if the source has
Expand All @@ -277,13 +284,15 @@ public void doSave(final IProgressMonitor monitor) {
}
if (saveFile(source)) {
try {
if (resource != null)
if (resource != null) {
resource.refreshLocal(IResource.DEPTH_ZERO, monitor);
}
} catch (CoreException ex2) {
// Do nothing on a failed refresh
}
} else
} else {
displayErrorDialog(SAVE_ERROR_TITLE, SAVE_ERROR_MESSAGE + source.getName());
}
});
}

Expand All @@ -292,8 +301,9 @@ public void doSave(final IProgressMonitor monitor) {
*/
@Override
public void doSaveAs() {
if (clientSite == null)
if (clientSite == null) {
return;
}
WorkspaceModifyOperation op = saveNewFileOperation();
Shell shell = clientSite.getShell();
try {
Expand Down Expand Up @@ -375,18 +385,20 @@ public void init(IEditorSite site, IEditorInput input)
private boolean validatePathEditorInput(IEditorInput input) throws PartInitException {
// Check input type.
IPathEditorInput pathEditorInput = Adapters.adapt(input, IPathEditorInput.class);
if (pathEditorInput == null)
if (pathEditorInput == null) {
throw new PartInitException(OleMessages.format(
"OleEditor.invalidInput", new Object[] { input })); //$NON-NLS-1$
}

IPath path = pathEditorInput.getPath();

//Cannot create this with a file and no physical location
if (!(new File(path.toOSString()).exists()))
if (!(new File(path.toOSString()).exists())) {
throw new PartInitException(
OleMessages
.format(
"OleEditor.noFileInput", new Object[] { path.toOSString() })); //$NON-NLS-1$
}
return true;
}

Expand All @@ -395,8 +407,9 @@ private boolean validatePathEditorInput(IEditorInput input) throws PartInitExcep
*/
protected void initializeWorkbenchMenus() {
//If there was an OLE Error or nothing has been created yet
if (clientFrame == null || clientFrame.isDisposed())
if (clientFrame == null || clientFrame.isDisposed()) {
return;
}
// Get the browser menu bar. If one does not exist then
// create it.
Shell shell = clientFrame.getShell();
Expand All @@ -416,13 +429,14 @@ protected void initializeWorkbenchMenus() {
for (int i = 0; i < menuBar.getItemCount(); i++) {
MenuItem item = menuBar.getItem(i);
String id = ""; //$NON-NLS-1$
if (item.getData() instanceof IMenuManager)
if (item.getData() instanceof IMenuManager) {
id = ((IMenuManager) item.getData()).getId();
if (id.equals(IWorkbenchActionConstants.M_FILE))
}
if (id.equals(IWorkbenchActionConstants.M_FILE)) {
fileMenu[0] = item;
else if (id.equals(IWorkbenchActionConstants.M_WINDOW))
} else if (id.equals(IWorkbenchActionConstants.M_WINDOW)) {
windowMenu[0] = item;
else {
} else {
if (window.isApplicationMenu(id)) {
containerItems.addElement(item);
}
Expand Down Expand Up @@ -499,8 +513,9 @@ public void execute(final IProgressMonitor monitor)
dialog.open();

IPath newPath = dialog.getResult();
if (newPath == null)
if (newPath == null) {
return;
}

if (dialog.getReturnCode() == Window.OK) {
String projectName = newPath.segment(0);
Expand Down Expand Up @@ -531,8 +546,9 @@ public void execute(final IProgressMonitor monitor)

@Override
public void setFocus() {
if (clientSite != null)
if (clientSite != null) {
clientSite.setFocus();
}
}

/**
Expand All @@ -541,8 +557,9 @@ public void setFocus() {
private void oleActivate() {
//If there was an OLE Error or nothing has been created yet
if (clientSite == null || clientFrame == null
|| clientFrame.isDisposed())
|| clientFrame.isDisposed()) {
return;
}

clientSite.doVerb(OLE.OLEIVERB_SHOW);
String progId = clientSite.getProgramID();
Expand All @@ -554,12 +571,14 @@ private void oleActivate() {
@Override
protected void setInputWithNotify(IEditorInput input) {
IPathEditorInput pathEditorInput = Adapters.adapt(input, IPathEditorInput.class);
if (pathEditorInput != null)
if (pathEditorInput != null) {
source = new File(pathEditorInput.getPath().toOSString());
}

if (input instanceof IFileEditorInput) {
if (resource == null)
if (resource == null) {
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceListener);
}
resource = ((IFileEditorInput)input).getFile();
} else if (resource != null) {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceListener);
Expand Down Expand Up @@ -611,16 +630,19 @@ private void update(Runnable runnable) {
if (windows != null && windows.length > 0) {
Display display = windows[0].getShell().getDisplay();
display.asyncExec(runnable);
} else
} else {
runnable.run();
}
}

private boolean isDirty = false;
private void updateDirtyFlag() {
final Runnable dirtyFlagUpdater = new Runnable() {
@Override
public void run() {
if (clientSite == null || resource == null) return;
if (clientSite == null || resource == null) {
return;
}
boolean dirty = isDirty();
if (isDirty != dirty) {
isDirty = dirty;
Expand Down
Loading