mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Migration to cell appearance services
This commit is contained in:
@@ -15,15 +15,15 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration;
|
||||
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class TableItem {
|
||||
private final String myUrl;
|
||||
private final CellAppearance myCellAppearance;
|
||||
private final CellAppearanceEx myCellAppearance;
|
||||
|
||||
public TableItem(@NotNull final VirtualFile file) {
|
||||
myUrl = file.getUrl();
|
||||
@@ -48,7 +48,7 @@ class TableItem {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CellAppearance getCellAppearance() {
|
||||
public CellAppearanceEx getCellAppearance() {
|
||||
return myCellAppearance;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -27,6 +27,7 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablePresentation;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.configuration.*;
|
||||
import com.intellij.openapi.roots.ui.configuration.dependencyAnalysis.AnalyzeDependenciesDialog;
|
||||
@@ -39,7 +40,6 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryPro
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.SdkProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.ui.ComboBoxTableRenderer;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
@@ -625,9 +625,9 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
return elements;
|
||||
}
|
||||
|
||||
private static CellAppearance getCellAppearance(final ClasspathTableItem<?> item,
|
||||
final StructureConfigurableContext context,
|
||||
final boolean selected) {
|
||||
private static CellAppearanceEx getCellAppearance(final ClasspathTableItem<?> item,
|
||||
final StructureConfigurableContext context,
|
||||
final boolean selected) {
|
||||
final OrderEntryAppearanceService service = OrderEntryAppearanceService.getInstance(context.getProject());
|
||||
if (item instanceof InvalidJdkItem) {
|
||||
return service.forJdk(null, false, selected, true);
|
||||
|
||||
+20
-13
@@ -27,18 +27,15 @@ import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ModuleRootListener;
|
||||
import com.intellij.openapi.roots.ModuleSourceOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.ui.MasterDetailsComponent;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.PathUtil;
|
||||
@@ -138,7 +135,7 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
if (value instanceof MyNode && !(value instanceof MyRootNode)) {
|
||||
final MyNode node = (MyNode)value;
|
||||
PathNode<?> n = (PathNode<?>)node.getUserObject();
|
||||
CellAppearance a = n.getAppearance(selected, node.isDisplayInBold());
|
||||
CellAppearanceEx a = n.getAppearance(selected, node.isDisplayInBold());
|
||||
a.customize(this);
|
||||
}
|
||||
}
|
||||
@@ -466,13 +463,13 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get appearance for renderring in master list
|
||||
* Get appearance for rendering in master list
|
||||
*
|
||||
* @param selected true if selected
|
||||
* @param bold true if bold
|
||||
* @return the result appearance
|
||||
*/
|
||||
public abstract CellAppearance getAppearance(boolean selected, boolean bold);
|
||||
public abstract CellAppearanceEx getAppearance(boolean selected, boolean bold);
|
||||
|
||||
/**
|
||||
* @retrun the string cut so it would fit the banner (the prefix is dropped)
|
||||
@@ -514,7 +511,7 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
return;
|
||||
}
|
||||
ModuleDependenciesAnalyzer.OrderPathElement e = (ModuleDependenciesAnalyzer.OrderPathElement)userObject;
|
||||
final CellAppearance appearance = e.getAppearance(selected);
|
||||
final CellAppearanceEx appearance = e.getAppearance(selected);
|
||||
appearance.customize(this);
|
||||
}
|
||||
}
|
||||
@@ -538,8 +535,8 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public CellAppearance getAppearance(boolean selected, final boolean isBold) {
|
||||
return new CellAppearance() {
|
||||
public CellAppearanceEx getAppearance(boolean selected, final boolean isBold) {
|
||||
return new CellAppearanceEx() {
|
||||
@Override
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
component.setIcon(getIcon());
|
||||
@@ -556,6 +553,11 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
component.append(" (" + PathUtil.getParentPath(p) + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
throw new UnsupportedOperationException("Rendering in combo box not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return getDisplayName();
|
||||
@@ -611,17 +613,22 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public CellAppearance getAppearance(boolean selected, final boolean isBold) {
|
||||
public CellAppearanceEx getAppearance(boolean selected, final boolean isBold) {
|
||||
if (myExplanation.entry() instanceof ModuleSourceOrderEntry) {
|
||||
ModuleSourceOrderEntry e = (ModuleSourceOrderEntry)myExplanation.entry();
|
||||
if (e.getOwnerModule() == myModule) {
|
||||
return new CellAppearance() {
|
||||
return new CellAppearanceEx() {
|
||||
@Override
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
component.setIcon(ModuleType.get(myModule).getNodeIcon(false));
|
||||
component.append("<This Module>", SimpleTextAttributes.SYNTHETIC_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
throw new UnsupportedOperationException("Rendering in combo box not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "<This Module>";
|
||||
|
||||
+4
-4
@@ -18,8 +18,8 @@ package com.intellij.openapi.roots.ui.configuration.dependencyAnalysis;
|
||||
import com.intellij.ide.presentation.VirtualFilePresentation;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
@@ -202,7 +202,7 @@ public class ModuleDependenciesAnalyzer {
|
||||
if (!myProduction || !myCompile) {
|
||||
CompilerModuleExtension e = CompilerModuleExtension.getInstance(m);
|
||||
final OrderPath p = new OrderPath(myStack);
|
||||
for (String u : e.getOutputRootUrls(!myCompile ? !myProduction : level > 0 ? !myProduction : false)) {
|
||||
for (String u : e.getOutputRootUrls(!myCompile ? !myProduction : level > 0 && !myProduction)) {
|
||||
addUrlPath(p, u);
|
||||
}
|
||||
addEntryPath(orderEntry, p);
|
||||
@@ -307,7 +307,7 @@ public class ModuleDependenciesAnalyzer {
|
||||
* @return the appearance to use for rendering
|
||||
*/
|
||||
@NotNull
|
||||
public abstract CellAppearance getAppearance(boolean isSelected);
|
||||
public abstract CellAppearanceEx getAppearance(boolean isSelected);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,7 +368,7 @@ public class ModuleDependenciesAnalyzer {
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public CellAppearance getAppearance(boolean isSelected) {
|
||||
public CellAppearanceEx getAppearance(boolean isSelected) {
|
||||
return OrderEntryAppearanceService.getInstance(myEntry.getOwnerModule().getProject()).forOrderEntry(myEntry, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.util;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class HttpUrlCellAppearance extends ValidFileCellAppearance {
|
||||
public HttpUrlCellAppearance(VirtualFile file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
protected Icon getIcon() {
|
||||
return PlatformIcons.WEB_ICON;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.util;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class JarSubfileCellAppearance extends ValidFileCellAppearance {
|
||||
public JarSubfileCellAppearance(VirtualFile file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
protected Icon getIcon() {
|
||||
return FileTypes.ARCHIVE.getIcon();
|
||||
}
|
||||
|
||||
protected int getSplitUrlIndex(String url) {
|
||||
int jarNameEnd = url.lastIndexOf(JarFileSystem.JAR_SEPARATOR.charAt(0));
|
||||
String jarUrl = jarNameEnd >= 0 ? url.substring(0, jarNameEnd) : url;
|
||||
return super.getSplitUrlIndex(jarUrl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.util;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
|
||||
public class ValidFileCellAppearance extends BaseTextCommentCellAppearance {
|
||||
private final VirtualFile myFile;
|
||||
|
||||
public ValidFileCellAppearance(VirtualFile file) {
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
protected Icon getIcon() {
|
||||
return FileTypeManager.getInstance().getFileTypeByFile(myFile).getIcon();
|
||||
}
|
||||
|
||||
protected String getSecondaryText() {
|
||||
return getSubname(true);
|
||||
}
|
||||
|
||||
protected String getPrimaryText() {
|
||||
return getSubname(false);
|
||||
}
|
||||
|
||||
private String getSubname(boolean headOrTail) {
|
||||
String presentableUrl = myFile.getPresentableUrl();
|
||||
int separatorIndex = getSplitUrlIndex(presentableUrl);
|
||||
if (headOrTail)
|
||||
return separatorIndex >= 0 ? presentableUrl.substring(0, separatorIndex) : "";
|
||||
else
|
||||
return presentableUrl.substring(separatorIndex + 1);
|
||||
}
|
||||
|
||||
protected int getSplitUrlIndex(String presentableUrl) {
|
||||
return presentableUrl.lastIndexOf(File.separatorChar);
|
||||
}
|
||||
|
||||
public VirtualFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user