@Override @SuppressWarnings({"EmptyCatchBlock"}) public void readExternal(final Element element) { myId = element.getAttributeValue(ID_ATTR); myWasRead = true; try { myActive = Boolean.valueOf(element.getAttributeValue(ACTIVE_ATTR)).booleanValue(); } catch (NumberFormatException ignored) { } try { myAnchor = ToolWindowAnchor.fromText(element.getAttributeValue(ANCHOR_ATTR)); } catch (IllegalArgumentException ignored) { } myAutoHide = Boolean.valueOf(element.getAttributeValue(AUTOHIDE_ATTR)).booleanValue(); try { myInternalType = ToolWindowType.valueOf(element.getAttributeValue(INTERNAL_TYPE_ATTR)); } catch (IllegalArgumentException ignored) { } try { setTypeAndCheck(ToolWindowType.valueOf(element.getAttributeValue(TYPE_ATTR))); } catch (IllegalArgumentException ignored) { } myVisible = Boolean.valueOf(element.getAttributeValue(VISIBLE_ATTR)).booleanValue(); if (element.getAttributeValue(SHOW_STRIPE_BUTTON) != null) { myShowStripeButton = Boolean.valueOf(element.getAttributeValue(SHOW_STRIPE_BUTTON)).booleanValue(); } try { myWeight = Float.parseFloat(element.getAttributeValue(WEIGHT_ATTR)); } catch (NumberFormatException ignored) { } try { String value = element.getAttributeValue(SIDE_WEIGHT_ATTR); if (value != null) { mySideWeight = Float.parseFloat(value); } } catch (NumberFormatException ignored) { } try { myOrder = Integer.valueOf(element.getAttributeValue(ORDER_ATTR)).intValue(); } catch (NumberFormatException ignored) { } try { int x = Integer.parseInt(element.getAttributeValue(X_ATTR)); int y = Integer.parseInt(element.getAttributeValue(Y_ATTR)); int width = Integer.parseInt(element.getAttributeValue(WIDTH_ATTR)); int height = Integer.parseInt(element.getAttributeValue(HEIGHT_ATTR)); myFloatingBounds = new Rectangle(x, y, width, height); } catch (NumberFormatException ignored) { } mySplitMode = Boolean.parseBoolean(element.getAttributeValue(SIDE_TOOL_ATTR)); myContentUiType = ToolWindowContentUiType.getInstance(element.getAttributeValue(CONTENT_UI_ATTR)); }
@Nullable @SuppressWarnings({"HardCodedStringLiteral"}) private JPanel readExternalPanel( final Element element, @Nullable JPanel panel, Ref<EditorWindow> currentWindow) { final Element splitterElement = element.getChild("splitter"); if (splitterElement != null) { return readSplitter(panel, splitterElement, currentWindow); } final Element leaf = element.getChild("leaf"); if (leaf == null) { return null; } EditorWindow window = (panel == null) ? new EditorWindow(this) : findWindowWith(panel); LOG.assertTrue(window != null); @SuppressWarnings("unchecked") final List<Element> children = ContainerUtil.newArrayList(leaf.getChildren("file")); if (UISettings.getInstance().ACTIVATE_RIGHT_EDITOR_ON_CLOSE) { Collections.reverse(children); } VirtualFile currentFile = null; for (final Element file : children) { try { final HistoryEntry entry = new HistoryEntry(getManager().getProject(), file.getChild(HistoryEntry.TAG), true); boolean isCurrent = Boolean.valueOf(file.getAttributeValue("current")).booleanValue(); getManager().openFileImpl3(window, entry.myFile, false, entry, isCurrent); if (getManager().isFileOpen(entry.myFile)) { window.setFilePinned( entry.myFile, Boolean.valueOf(file.getAttributeValue("pinned")).booleanValue()); if (Boolean.valueOf(file.getAttributeValue("current-in-tab")).booleanValue()) { currentFile = entry.myFile; } } } catch (InvalidDataException e) { // OK } } if (currentFile != null) { final EditorComposite editor = window.findFileComposite(currentFile); if (editor != null) { window.setSelectedEditor(editor, true); } } return window.myPanel; }
@Nullable @SuppressWarnings({"HardCodedStringLiteral"}) private JPanel readExternalPanel( final Element element, @Nullable JPanel panel, Ref<EditorWindow> currentWindow) { final Element splitterElement = element.getChild("splitter"); if (splitterElement != null) { return readSplitter(panel, splitterElement, currentWindow); } final Element leaf = element.getChild("leaf"); if (leaf == null) { return null; } final EditorWindow window = panel == null ? new EditorWindow(this) : findWindowWith(panel); LOG.assertTrue(window != null); @SuppressWarnings("unchecked") final List<Element> children = ContainerUtil.newArrayList(leaf.getChildren("file")); if (UISettings.getInstance().ACTIVATE_RIGHT_EDITOR_ON_CLOSE) { Collections.reverse(children); } // trim to EDITOR_TAB_LIMIT, ignoring CLOSE_NON_MODIFIED_FILES_FIRST policy for (Iterator<Element> iterator = children.iterator(); iterator.hasNext() && UISettings.getInstance().EDITOR_TAB_LIMIT < children.size(); ) { Element child = iterator.next(); if (!Boolean.valueOf(child.getAttributeValue(PINNED)).booleanValue()) { iterator.remove(); } } VirtualFile currentFile = null; for (int i = 0; i < children.size(); i++) { final Element file = children.get(i); try { final FileEditorManagerImpl fileEditorManager = getManager(); final HistoryEntry entry = new HistoryEntry(fileEditorManager.getProject(), file.getChild(HistoryEntry.TAG), true); final boolean isCurrent = Boolean.valueOf(file.getAttributeValue("current")).booleanValue(); fileEditorManager.openFileImpl4(window, entry.myFile, false, entry, isCurrent, i); if (fileEditorManager.isFileOpen(entry.myFile)) { window.setFilePinned( entry.myFile, Boolean.valueOf(file.getAttributeValue(PINNED)).booleanValue()); if (Boolean.valueOf(file.getAttributeValue("current-in-tab")).booleanValue()) { currentFile = entry.myFile; } } } catch (InvalidDataException e) { if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.error(e); } } } if (currentFile != null) { final EditorComposite editor = window.findFileComposite(currentFile); if (editor != null) { window.setSelectedEditor(editor, true); } } return window.myPanel; }