Commit a3e66763 authored by irengrig's avatar irengrig
Browse files

WEB-19198 JSCS: Import Code Style: IllegalStateException for empty input file

parent bb84169b
Showing with 18 additions and 7 deletions
+18 -7
......@@ -35,7 +35,6 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.codeStyle.CodeStyleScheme;
import com.intellij.psi.codeStyle.CodeStyleSchemes;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.table.JBTable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -170,16 +169,19 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
}
}
catch (SchemeImportException e) {
showStatus(myImportButton,
ApplicationBundle.message("message.code.style.scheme.import.failure", selectedImporterName, e.getMessage()),
MessageType.ERROR);
if (e.isWarning()) {
showStatus(myImportButton, e.getMessage(), MessageType.WARNING);
return;
}
final String message = ApplicationBundle.message("message.code.style.scheme.import.failure", selectedImporterName, e.getMessage());
showStatus(myImportButton, message, MessageType.ERROR);
}
}
}
}
}
private static void showStatus(final Component component, final String message, MessageType messageType) {
private static void showStatus(final JComponent component, final String message, MessageType messageType) {
BalloonBuilder balloonBuilder = JBPopupFactory.getInstance()
.createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(),
messageType.getPopupBackground(), null);
......@@ -187,8 +189,7 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
final Balloon balloon = balloonBuilder.createBalloon();
final Rectangle rect = component.getBounds();
final Point p = new Point(rect.x, rect.y + rect.height);
final RelativePoint point = new RelativePoint(component, p);
balloon.show(point, Balloon.Position.below);
balloon.showInCenterOf(component);
Disposer.register(ProjectManager.getInstance().getDefaultProject(), balloon);
}
......
......@@ -22,6 +22,7 @@ package com.intellij.openapi.options;
* @author Rustam Vishnyakov
*/
public class SchemeImportException extends Exception {
boolean myIsWarning;
public SchemeImportException(String message) {
super(message);
}
......@@ -29,4 +30,13 @@ public class SchemeImportException extends Exception {
public SchemeImportException(Throwable cause) {
super(cause);
}
public SchemeImportException setWarning() {
myIsWarning = true;
return this;
}
public boolean isWarning() {
return myIsWarning;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment