Skip to content

Commit 3113b24

Browse files
shobhanmandalsmehrbrodt
authored andcommitted
Fix #21: Show error when RegistrationHandler.classes empty (#67)
show an error message when RegistrationHandler.classes is empty
1 parent 7842ff7 commit 3113b24

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

java/source/org/libreoffice/ide/eclipse/java/JavaResourceDeltaVisitor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ private void removeImplementation(IResourceDelta pDelta,
116116
RegistrationHelper.removeImplementation(pUnoprj, implName);
117117
}
118118
}
119+
} else if (res.getName().endsWith(".jar")) {
120+
RegistrationHelper.isFileEmpty(pUnoprj);
119121
}
120122
}
121123

java/source/org/libreoffice/ide/eclipse/java/registration/RegistrationHelper.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
import org.eclipse.core.resources.IFile;
5656
import org.eclipse.core.resources.IFolder;
5757
import org.eclipse.core.runtime.IPath;
58+
import org.eclipse.jface.dialogs.MessageDialog;
59+
import org.eclipse.swt.widgets.Display;
5860
import org.libreoffice.ide.eclipse.core.PluginLogger;
5961
import org.libreoffice.ide.eclipse.core.model.IUnoidlProject;
6062
import org.libreoffice.ide.eclipse.java.utils.TemplatesHelper;
@@ -228,4 +230,41 @@ private static IFile getClassesListFile(IUnoidlProject pProject) {
228230

229231
return dest.getFile("RegistrationHandler.classes"); //$NON-NLS-1$
230232
}
233+
234+
/**
235+
* Check if the RegistrationHandler.classes file is empty
236+
* <code>org.libreoffice.ide.eclipse.java.JavaResourceDeltaVisitor</code>
237+
*
238+
* @param pProject the project where to check empty file
239+
*/
240+
public static void isFileEmpty(IUnoidlProject pProject) {
241+
IFile list = getClassesListFile(pProject);
242+
File file = list.getLocation().toFile();
243+
boolean checkFileEmpty = true;
244+
FileInputStream in = null;
245+
BufferedReader reader = null;
246+
try {
247+
in = new FileInputStream(file);
248+
reader = new BufferedReader(new InputStreamReader(in));
249+
if (reader.readLine() == null) {
250+
checkFileEmpty = true;
251+
} else {
252+
checkFileEmpty = false;
253+
}
254+
} catch (Exception e) {
255+
checkFileEmpty = true;
256+
257+
} finally {
258+
try {
259+
reader.close();
260+
in.close();
261+
} catch (Exception e) {
262+
}
263+
}
264+
if (checkFileEmpty) {
265+
PluginLogger.error(Messages.getString("RegistrationHelper.RegistrationHandlerEmptyClassError"));
266+
MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
267+
Messages.getString("RegistrationHelper.RegistrationHandlerEmptyClassError"));
268+
}
269+
}
231270
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
FileRefreshJob.Error=Can't refresh the registration classes file
22
RegistrationHelper.WriteClassesListError=Error during classes list writing
3+
RegistrationHelper.RegistrationHandlerEmptyClassError=The RegistrationHandler.classes is empty, exported .oxt extension will not work properly
4+

0 commit comments

Comments
 (0)