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:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -25,9 +25,12 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.ui.configuration.ProjectStructureDialogCellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.NewLibraryConfiguration;
|
||||
@@ -41,7 +44,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SortedComboBoxModel;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
@@ -66,6 +69,7 @@ import java.util.List;
|
||||
*/
|
||||
public class LibraryOptionsPanel implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ui.libraries.LibraryOptionsPanel");
|
||||
|
||||
private JLabel myMessageLabel;
|
||||
private JPanel myPanel;
|
||||
private JButton myConfigureButton;
|
||||
@@ -85,7 +89,7 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
private SortedComboBoxModel<LibraryEditor> myLibraryComboBoxModel;
|
||||
private boolean myDisposed;
|
||||
|
||||
private enum Choice {
|
||||
private static enum Choice {
|
||||
USE_LIBRARY,
|
||||
DOWNLOAD,
|
||||
SETUP_LIBRARY_LATER
|
||||
@@ -93,8 +97,10 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
|
||||
private RadioButtonEnumModel<Choice> myButtonEnumModel;
|
||||
|
||||
public LibraryOptionsPanel(final @NotNull CustomLibraryDescription libraryDescription, final @NotNull String baseDirectoryPath,
|
||||
@Nullable final FrameworkVersion currentFrameworkVersion, @NotNull final LibrariesContainer librariesContainer,
|
||||
public LibraryOptionsPanel(@NotNull final CustomLibraryDescription libraryDescription,
|
||||
@NotNull final String baseDirectoryPath,
|
||||
@Nullable final FrameworkVersion currentFrameworkVersion,
|
||||
@NotNull final LibrariesContainer librariesContainer,
|
||||
final boolean showDoNotCreateOption) {
|
||||
myLibrariesContainer = librariesContainer;
|
||||
final DownloadableLibraryDescription description = getDownloadableDescription(libraryDescription);
|
||||
@@ -183,7 +189,24 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
updateState();
|
||||
}
|
||||
});
|
||||
myExistingLibraryComboBox.setRenderer(new LibraryListCellRenderer());
|
||||
myExistingLibraryComboBox.setRenderer(new HtmlListCellRenderer(myExistingLibraryComboBox.getRenderer()) {
|
||||
@Override
|
||||
protected void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value == null) {
|
||||
append("[No library selected]");
|
||||
}
|
||||
else if (value instanceof ExistingLibraryEditor) {
|
||||
final Library library = ((ExistingLibraryEditor)value).getLibrary();
|
||||
final boolean invalid = !((LibraryEx)library).getInvalidRootUrls(OrderRootType.CLASSES).isEmpty();
|
||||
OrderEntryAppearanceService.getInstance(getProject()).forLibrary(library, invalid).customize(this);
|
||||
}
|
||||
else if (value instanceof NewLibraryEditor) {
|
||||
setIcon(PlatformIcons.LIBRARY_ICON);
|
||||
final String name = ((NewLibraryEditor)value).getName();
|
||||
append(name != null ? name : "<unnamed>");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
boolean canDownload = mySettings.getDownloadSettings() != null;
|
||||
myDownloadRadioButton.setVisible(canDownload);
|
||||
@@ -213,6 +236,14 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
showCard("editing");
|
||||
}
|
||||
|
||||
private Project getProject() {
|
||||
Project project = myLibrariesContainer.getProject();
|
||||
if (project == null) {
|
||||
project = ProjectManager.getInstance().getDefaultProject();
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
private void doConfigure() {
|
||||
switch (myButtonEnumModel.getSelected()) {
|
||||
case DOWNLOAD:
|
||||
@@ -401,21 +432,4 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
public void dispose() {
|
||||
myDisposed = true;
|
||||
}
|
||||
|
||||
private static class LibraryListCellRenderer extends ColoredListCellRenderer {
|
||||
@Override
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value == null) {
|
||||
append("[No library selected]");
|
||||
}
|
||||
else if (value instanceof ExistingLibraryEditor) {
|
||||
ProjectStructureDialogCellAppearanceUtils.forLibrary(((ExistingLibraryEditor)value).getLibrary(), null).customize(this);
|
||||
}
|
||||
else if (value instanceof NewLibraryEditor) {
|
||||
setIcon(PlatformIcons.LIBRARY_ICON);
|
||||
final String name = ((NewLibraryEditor)value).getName();
|
||||
append(name != null ? name : "<unnamed>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -34,6 +34,7 @@ import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import gnu.trove.TIntArrayList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -52,13 +53,13 @@ public class JdkChooserPanel extends JPanel {
|
||||
private final Project myProject;
|
||||
private SdkType[] myAllowedJdkTypes = null;
|
||||
|
||||
public JdkChooserPanel(Project project) {
|
||||
public JdkChooserPanel(@NotNull final Project project) {
|
||||
super(new BorderLayout());
|
||||
myProject = project;
|
||||
myListModel = new DefaultListModel();
|
||||
myList = new JBList(myListModel);
|
||||
myList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
myList.setCellRenderer(new ProjectJdkListRenderer(myList.getCellRenderer()));
|
||||
myList.setCellRenderer(new ProjectJdkListRenderer(myList.getCellRenderer(), project));
|
||||
//noinspection HardCodedStringLiteral
|
||||
myList.setPrototypeCellValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -15,26 +15,31 @@
|
||||
*/
|
||||
package com.intellij.ide.util.projectWizard;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: May 18, 2005
|
||||
* @since May 18, 2005
|
||||
*/
|
||||
public class ProjectJdkListRenderer extends HtmlListCellRenderer {
|
||||
public ProjectJdkListRenderer(final ListCellRenderer listCellRenderer) {
|
||||
private final Project myProject;
|
||||
|
||||
public ProjectJdkListRenderer(final ListCellRenderer listCellRenderer, @NotNull final Project project) {
|
||||
super(listCellRenderer);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value == null || value instanceof Sdk) {
|
||||
render(OrderEntryCellAppearanceUtils.forJdk((Sdk)value, false, selected, index != -1));
|
||||
OrderEntryAppearanceService.getInstance(myProject).forJdk((Sdk)value, false, selected, index != -1).customize(this);
|
||||
}
|
||||
else {
|
||||
final String str = value.toString();
|
||||
|
||||
+4
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -60,6 +60,9 @@ public class ProjectWizardStepFactoryImpl extends ProjectWizardStepFactory {
|
||||
return new SourcePathsStep(builder, icon, helpId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public ModuleWizardStep createProjectJdkStep(WizardContext context,
|
||||
final JavaModuleBuilder builder,
|
||||
final Computable<Boolean> isVisible,
|
||||
|
||||
+1
-33
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -20,13 +20,9 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.AnnotationOrderRootType;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.util.SimpleTextCellAppearance;
|
||||
import com.intellij.openapi.ui.PanelWithText;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.ui.ColoredTableCellRenderer;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.TableUtil;
|
||||
@@ -170,34 +166,6 @@ public class AnnotationsEditor extends ModuleElementsEditor {
|
||||
}
|
||||
}
|
||||
|
||||
private static class TableItem {
|
||||
private final String myUrl;
|
||||
private final CellAppearance myCellAppearance;
|
||||
public TableItem(VirtualFile file) {
|
||||
myUrl = file.getUrl();
|
||||
myCellAppearance = CellAppearanceUtils.forVirtualFile(file);
|
||||
}
|
||||
|
||||
public TableItem(String url) {
|
||||
myUrl = url;
|
||||
final VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
if (file != null) {
|
||||
myCellAppearance = CellAppearanceUtils.forVirtualFile(file);
|
||||
}
|
||||
else {
|
||||
myCellAppearance = SimpleTextCellAppearance.invalid(url, CellAppearanceUtils.INVALID_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
public CellAppearance getCellAppearance() {
|
||||
return myCellAppearance;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyTableModel extends DefaultTableModel implements ItemRemovable{
|
||||
public String getColumnName(int column) {
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -21,13 +21,9 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.ui.Util;
|
||||
import com.intellij.openapi.roots.JavadocOrderRootType;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.util.SimpleTextCellAppearance;
|
||||
import com.intellij.openapi.ui.PanelWithText;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.ui.ColoredTableCellRenderer;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.TableUtil;
|
||||
@@ -177,34 +173,6 @@ public class JavadocEditor extends ModuleElementsEditor {
|
||||
}
|
||||
}
|
||||
|
||||
private static class TableItem {
|
||||
private final String myUrl;
|
||||
private final CellAppearance myCellAppearance;
|
||||
public TableItem(VirtualFile file) {
|
||||
myUrl = file.getUrl();
|
||||
myCellAppearance = CellAppearanceUtils.forVirtualFile(file);
|
||||
}
|
||||
|
||||
public TableItem(String url) {
|
||||
myUrl = url;
|
||||
final VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
if (file != null) {
|
||||
myCellAppearance = CellAppearanceUtils.forVirtualFile(file);
|
||||
}
|
||||
else {
|
||||
myCellAppearance = SimpleTextCellAppearance.invalid(url, CellAppearanceUtils.INVALID_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
public CellAppearance getCellAppearance() {
|
||||
return myCellAppearance;
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyTableModel extends DefaultTableModel implements ItemRemovable{
|
||||
public String getColumnName(int column) {
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.ui.ScreenUtil;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -43,14 +44,14 @@ import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: May 18, 2005
|
||||
* @since May 18, 2005
|
||||
*/
|
||||
class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
private final JButton myEditButton = new JButton(ApplicationBundle.message("button.edit"));
|
||||
|
||||
public JdkComboBox(final ProjectSdksModel jdksModel) {
|
||||
super(new JdkComboBoxModel(jdksModel));
|
||||
setRenderer(new ProjectJdkListRenderer(getRenderer()) {
|
||||
public JdkComboBox(@NotNull final ProjectSdksModel jdkModel, @NotNull final Project project) {
|
||||
super(new JdkComboBoxModel(jdkModel));
|
||||
setRenderer(new ProjectJdkListRenderer(getRenderer(), project) {
|
||||
@Override
|
||||
public void doCustomize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
if (JdkComboBox.this.isEnabled()) {
|
||||
@@ -59,7 +60,7 @@ class JdkComboBox extends ComboBoxWithWidePopup {
|
||||
append(str, SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
}
|
||||
else if (value instanceof ProjectJdkComboBoxItem){
|
||||
final Sdk jdk = jdksModel.getProjectSdk();
|
||||
final Sdk jdk = jdkModel.getProjectSdk();
|
||||
if (jdk != null){
|
||||
setIcon(jdk.getSdkType().getIcon());
|
||||
append(ProjectBundle.message("project.roots.project.jdk.inherited"), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -101,7 +101,7 @@ public abstract class ModuleJdkConfigurable implements Disposable {
|
||||
|
||||
private void init() {
|
||||
myJdkPanel = new JPanel(new GridBagLayout());
|
||||
myCbModuleJdk = new JdkComboBox(myJdksModel);
|
||||
myCbModuleJdk = new JdkComboBox(myJdksModel, myModuleEditor.myProject);
|
||||
myCbModuleJdk.insertItemAt(new JdkComboBox.ProjectJdkComboBoxItem(), 0);
|
||||
myCbModuleJdk.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -103,7 +103,7 @@ public class ProjectJdkConfigurable implements UnnamedConfigurable {
|
||||
|
||||
private void init() {
|
||||
myJdkPanel = new JPanel(new GridBagLayout());
|
||||
myCbProjectJdk = new JdkComboBox(myJdksModel);
|
||||
myCbProjectJdk = new JdkComboBox(myJdksModel, myProject);
|
||||
myCbProjectJdk.insertItemAt(new JdkComboBox.NoneJdkComboBoxItem(), 0);
|
||||
myCbProjectJdk.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.configuration;
|
||||
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryPresentationManager;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
//todo[nik] extract service from OrderEntryCellAppearanceUtils and use this class as its implementation for idea-ui
|
||||
public class ProjectStructureDialogCellAppearanceUtils {
|
||||
|
||||
private ProjectStructureDialogCellAppearanceUtils() {
|
||||
}
|
||||
|
||||
public static CellAppearance forOrderEntry(OrderEntry orderEntry, StructureConfigurableContext context, boolean selected) {
|
||||
if (orderEntry instanceof LibraryOrderEntry) {
|
||||
final Library library = ((LibraryOrderEntry)orderEntry).getLibrary();
|
||||
if (orderEntry.isValid()) {
|
||||
return forLibrary(library, context);
|
||||
}
|
||||
}
|
||||
return OrderEntryCellAppearanceUtils.forOrderEntry(orderEntry, selected);
|
||||
}
|
||||
|
||||
public static CellAppearance forLibrary(Library library, StructureConfigurableContext context) {
|
||||
final Icon icon = LibraryPresentationManager.getInstance().getCustomIcon(library, context);
|
||||
final boolean invalid = !((LibraryEx)library).getInvalidRootUrls(OrderRootType.CLASSES).isEmpty();
|
||||
if (icon != null) {
|
||||
final String name = library.getName();
|
||||
if (name != null) {
|
||||
return OrderEntryCellAppearanceUtils.normalOrRedWaved(name, icon, invalid);
|
||||
}
|
||||
}
|
||||
return OrderEntryCellAppearanceUtils.forLibrary(library, invalid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.configuration;
|
||||
|
||||
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;
|
||||
|
||||
public TableItem(@NotNull final VirtualFile file) {
|
||||
myUrl = file.getUrl();
|
||||
myCellAppearance = FileAppearanceService.getInstance().forVirtualFile(file);
|
||||
}
|
||||
|
||||
public TableItem(@NotNull final String url) {
|
||||
myUrl = url;
|
||||
|
||||
final VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
if (file != null) {
|
||||
myCellAppearance = FileAppearanceService.getInstance().forVirtualFile(file);
|
||||
}
|
||||
else {
|
||||
myCellAppearance = FileAppearanceService.getInstance().forInvalidUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getUrl() {
|
||||
return myUrl;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CellAppearance getCellAppearance() {
|
||||
return myCellAppearance;
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -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.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.configuration.*;
|
||||
import com.intellij.openapi.roots.ui.configuration.dependencyAnalysis.AnalyzeDependenciesDialog;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil;
|
||||
@@ -39,7 +40,6 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProj
|
||||
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.roots.ui.util.OrderEntryCellAppearanceUtils;
|
||||
import com.intellij.openapi.ui.ComboBoxTableRenderer;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
@@ -625,15 +625,17 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
return elements;
|
||||
}
|
||||
|
||||
|
||||
private static CellAppearance getCellAppearance(final ClasspathTableItem<?> item,
|
||||
StructureConfigurableContext context,
|
||||
final StructureConfigurableContext context,
|
||||
final boolean selected) {
|
||||
final OrderEntryAppearanceService service = OrderEntryAppearanceService.getInstance(context.getProject());
|
||||
if (item instanceof InvalidJdkItem) {
|
||||
return OrderEntryCellAppearanceUtils.forJdk(null, false, selected);
|
||||
return service.forJdk(null, false, selected, true);
|
||||
}
|
||||
else {
|
||||
return ProjectStructureDialogCellAppearanceUtils.forOrderEntry(item.getEntry(), context, selected);
|
||||
final OrderEntry entry = item.getEntry();
|
||||
assert entry != null : item;
|
||||
return service.forOrderEntry(entry, selected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -27,9 +27,9 @@ 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.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
|
||||
import com.intellij.openapi.ui.MasterDetailsComponent;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -629,10 +629,10 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
};
|
||||
}
|
||||
else {
|
||||
return OrderEntryCellAppearanceUtils.forModule(e.getOwnerModule());
|
||||
return OrderEntryAppearanceService.getInstance(myModule.getProject()).forModule(e.getOwnerModule());
|
||||
}
|
||||
}
|
||||
return OrderEntryCellAppearanceUtils.forOrderEntry(myExplanation.entry(), selected);
|
||||
return OrderEntryAppearanceService.getInstance(myModule.getProject()).forOrderEntry(myExplanation.entry(), selected);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -678,8 +678,7 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent {
|
||||
* The constructor
|
||||
*/
|
||||
public SdkFilterAction() {
|
||||
super("Include SDK", "If selected, the SDK classes are included",
|
||||
IconLoader.findIcon("/general/jdk.png")); //To change body of overridden methods use File | Settings | File Templates.
|
||||
super("Include SDK", "If selected, the SDK classes are included", IconLoader.findIcon("/general/jdk.png"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -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.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
@@ -369,7 +369,7 @@ public class ModuleDependenciesAnalyzer {
|
||||
@NotNull
|
||||
@Override
|
||||
public CellAppearance getAppearance(boolean isSelected) {
|
||||
return OrderEntryCellAppearanceUtils.forOrderEntry(myEntry, isSelected);
|
||||
return OrderEntryAppearanceService.getInstance(myEntry.getOwnerModule().getProject()).forOrderEntry(myEntry, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -16,8 +16,8 @@
|
||||
package com.intellij.ide.structureView.impl;
|
||||
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.ModifiableCellAppearance;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
@@ -46,7 +46,7 @@ public class StructureNodeRenderer extends ColoredTreeCellRenderer {
|
||||
|
||||
public static CellAppearance forNodeDescriptorInTree(Object node, boolean expanded) {
|
||||
NodeDescriptor descriptor = getNodeDescriptor(node);
|
||||
if (descriptor == null) return CellAppearanceUtils.EMPTY;
|
||||
if (descriptor == null) return FileAppearanceService.getInstance().empty();
|
||||
String name = descriptor.toString();
|
||||
Object psiElement = descriptor.getElement();
|
||||
ModifiableCellAppearance result;
|
||||
|
||||
@@ -105,6 +105,7 @@ public interface PlatformIcons {
|
||||
Icon FOLDER_ICON = IconLoader.getIcon("/nodes/folder.png");
|
||||
Icon SOURCE_FOLDERS_ICON = IconLoader.getIcon("/nodes/sourceFolder.png");
|
||||
Icon TEST_SOURCE_FOLDER = IconLoader.getIcon("/nodes/testSourceFolder.png");
|
||||
Icon INVALID_ENTRY_ICON = IconLoader.getIcon("/nodes/ppInvalid.png");
|
||||
|
||||
Icon MODULES_SOURCE_FOLDERS_ICON = IconLoader.getIcon("/modules/sourceRootClosed.png");
|
||||
Icon MODULES_TEST_SOURCE_FOLDER = IconLoader.getIcon("/modules/testRootClosed.png");
|
||||
|
||||
+25
-26
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.LightFilePointer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -36,13 +37,16 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @deprecated please use {@linkplain com.intellij.openapi.roots.ui.OrderEntryAppearanceService} (to remove in IDEA 12)
|
||||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public class OrderEntryCellAppearanceUtils {
|
||||
public static final Icon EXCLUDE_FOLDER_ICON = CellAppearanceUtils.excludeIcon(PlatformIcons.FOLDER_ICON);
|
||||
public static final Icon EXCLUDE_FOLDER_ICON = IconLoader.getDisabledIcon(PlatformIcons.FOLDER_ICON);
|
||||
public static final Icon GENERIC_JDK_ICON = IconLoader.getIcon("/general/jdk.png");
|
||||
public static final String NO_JDK = ProjectBundle.message("jdk.missing.item");
|
||||
|
||||
private OrderEntryCellAppearanceUtils() {
|
||||
}
|
||||
private OrderEntryCellAppearanceUtils() { }
|
||||
|
||||
public static CellAppearance forOrderEntry(OrderEntry orderEntry, boolean selected) {
|
||||
if (orderEntry instanceof JdkOrderEntry) {
|
||||
@@ -50,19 +54,18 @@ public class OrderEntryCellAppearanceUtils {
|
||||
Sdk jdk = jdkLibraryEntry.getJdk();
|
||||
if (!orderEntry.isValid()) {
|
||||
final String oldJdkName = jdkLibraryEntry.getJdkName();
|
||||
return SimpleTextCellAppearance.invalid(oldJdkName != null ? oldJdkName : NO_JDK,
|
||||
CellAppearanceUtils.INVALID_ICON);
|
||||
return FileAppearanceService.getInstance().forInvalidUrl(oldJdkName != null ? oldJdkName : NO_JDK);
|
||||
}
|
||||
return forJdk(jdk, false, selected);
|
||||
}
|
||||
else if (!orderEntry.isValid()) {
|
||||
return SimpleTextCellAppearance.invalid(orderEntry.getPresentableName(), CellAppearanceUtils.INVALID_ICON);
|
||||
return FileAppearanceService.getInstance().forInvalidUrl(orderEntry.getPresentableName());
|
||||
}
|
||||
else if (orderEntry instanceof LibraryOrderEntry) {
|
||||
LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)orderEntry;
|
||||
final Library library = libraryOrderEntry.getLibrary();
|
||||
if (!libraryOrderEntry.isValid()){ //library can be removed
|
||||
return SimpleTextCellAppearance.invalid(orderEntry.getPresentableName(), CellAppearanceUtils.INVALID_ICON);
|
||||
return FileAppearanceService.getInstance().forInvalidUrl(orderEntry.getPresentableName());
|
||||
}
|
||||
return forLibrary(library);
|
||||
}
|
||||
@@ -73,7 +76,7 @@ public class OrderEntryCellAppearanceUtils {
|
||||
}
|
||||
else if (orderEntry instanceof ModuleOrderEntry) {
|
||||
final Icon icon = ModuleType.get(((ModuleOrderEntry)orderEntry).getModule()).getNodeIcon(false);
|
||||
return SimpleTextCellAppearance.normal(orderEntry.getPresentableName(), icon);
|
||||
return SimpleTextCellAppearance.regular(orderEntry.getPresentableName(), icon);
|
||||
}
|
||||
else return CompositeAppearance.single(orderEntry.getPresentableName());
|
||||
}
|
||||
@@ -95,14 +98,14 @@ public class OrderEntryCellAppearanceUtils {
|
||||
return forVirtualFilePointer(new LightFilePointer(files[0]));
|
||||
}
|
||||
String url = StringUtil.trimEnd(files[0], JarFileSystem.JAR_SEPARATOR);
|
||||
return SimpleTextCellAppearance.normal(PathUtil.getFileName(url), PlatformIcons.LIBRARY_ICON);
|
||||
return SimpleTextCellAppearance.regular(PathUtil.getFileName(url), PlatformIcons.LIBRARY_ICON);
|
||||
}
|
||||
|
||||
public static CellAppearance normalOrRedWaved(String text, final Icon icon, boolean waved) {
|
||||
if (waved) {
|
||||
return new SimpleTextCellAppearance(text, icon, new SimpleTextAttributes(SimpleTextAttributes.STYLE_WAVED, null, Color.RED));
|
||||
}
|
||||
return SimpleTextCellAppearance.normal(text, icon);
|
||||
return SimpleTextCellAppearance.regular(text, icon);
|
||||
}
|
||||
|
||||
public static Icon sourceFolderIcon(boolean testSource) {
|
||||
@@ -111,20 +114,21 @@ public class OrderEntryCellAppearanceUtils {
|
||||
|
||||
public static ModifiableCellAppearance forJdk(@Nullable Sdk jdk, boolean isInComboBox, final boolean selected, final boolean showVersion) {
|
||||
if (jdk == null) {
|
||||
return SimpleTextCellAppearance.invalid(NO_JDK, CellAppearanceUtils.INVALID_ICON);
|
||||
return (ModifiableCellAppearance)FileAppearanceService.getInstance().forInvalidUrl(NO_JDK);
|
||||
}
|
||||
String name = jdk.getName();
|
||||
CompositeAppearance appearance = new CompositeAppearance();
|
||||
appearance.setIcon(jdk.getSdkType().getIcon());
|
||||
VirtualFile homeDirectory = jdk.getHomeDirectory();
|
||||
SimpleTextAttributes attributes =
|
||||
homeDirectory != null && homeDirectory.isValid() ? CellAppearanceUtils.createSimpleCellAttributes(selected) : SimpleTextAttributes.ERROR_ATTRIBUTES;
|
||||
SimpleTextAttributes attributes = homeDirectory != null && homeDirectory.isValid()
|
||||
? CellAppearanceUtils.createSimpleCellAttributes(selected) : SimpleTextAttributes.ERROR_ATTRIBUTES;
|
||||
CompositeAppearance.DequeEnd ending = appearance.getEnding();
|
||||
ending.addText(name, attributes);
|
||||
if (showVersion) {
|
||||
String versionString = jdk.getVersionString();
|
||||
if (versionString != null && !versionString.equals(name)) {
|
||||
SimpleTextAttributes textAttributes = isInComboBox ? SimpleTextAttributes.SYNTHETIC_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES;
|
||||
SimpleTextAttributes textAttributes = isInComboBox
|
||||
? SimpleTextAttributes.SYNTHETIC_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES;
|
||||
ending.addComment(versionString, textAttributes);
|
||||
}
|
||||
}
|
||||
@@ -156,7 +160,7 @@ public class OrderEntryCellAppearanceUtils {
|
||||
}
|
||||
|
||||
public static CellAppearance forModule(Module module) {
|
||||
return SimpleTextCellAppearance.normal(module.getName(), ModuleType.get(module).getNodeIcon(false));
|
||||
return SimpleTextCellAppearance.regular(module.getName(), ModuleType.get(module).getNodeIcon(false));
|
||||
}
|
||||
|
||||
public static CellAppearance forContentEntry(ContentEntry contentEntry) {
|
||||
@@ -166,7 +170,7 @@ public class OrderEntryCellAppearanceUtils {
|
||||
public static SimpleTextCellAppearance formatRelativePath(ContentFolder folder, Icon icon) {
|
||||
LightFilePointer folderFile = new LightFilePointer(folder.getUrl());
|
||||
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(folder.getContentEntry().getUrl());
|
||||
if (file == null) return forInvalidVirtualFilePointer(folderFile);
|
||||
if (file == null) return (SimpleTextCellAppearance)FileAppearanceService.getInstance().forInvalidUrl(folderFile.getPresentableUrl());
|
||||
String contentPath = file.getPath();
|
||||
String relativePath;
|
||||
SimpleTextAttributes textAttributes;
|
||||
@@ -195,8 +199,7 @@ public class OrderEntryCellAppearanceUtils {
|
||||
// probably invalid JDK
|
||||
final String projectJdkName = projectRootManager.getProjectSdkName();
|
||||
if (projectJdkName != null) {
|
||||
appearance = SimpleTextCellAppearance.invalid(ProjectBundle.message("jdk.combo.box.invalid.item", projectJdkName),
|
||||
CellAppearanceUtils.INVALID_ICON);
|
||||
appearance = FileAppearanceService.getInstance().forInvalidUrl(ProjectBundle.message("jdk.combo.box.invalid.item", projectJdkName));
|
||||
}
|
||||
else {
|
||||
appearance = forJdk(null, false, false);
|
||||
@@ -206,12 +209,8 @@ public class OrderEntryCellAppearanceUtils {
|
||||
}
|
||||
|
||||
public static CellAppearance forVirtualFilePointer(LightFilePointer filePointer) {
|
||||
return filePointer.isValid() ?
|
||||
CellAppearanceUtils.forValidVirtualFile(filePointer.getFile()) :
|
||||
forInvalidVirtualFilePointer(filePointer);
|
||||
}
|
||||
|
||||
static SimpleTextCellAppearance forInvalidVirtualFilePointer(LightFilePointer filePointer) {
|
||||
return SimpleTextCellAppearance.invalid(filePointer.getPresentableUrl(), CellAppearanceUtils.INVALID_ICON);
|
||||
final VirtualFile file = filePointer.getFile();
|
||||
return file != null ? FileAppearanceService.getInstance().forVirtualFile(file)
|
||||
: FileAppearanceService.getInstance().forInvalidUrl(filePointer.getPresentableUrl());
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -20,7 +20,7 @@ import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -77,7 +77,7 @@ public class JumpFromRemoteFileToLocalAction extends AnAction {
|
||||
list.setCellRenderer(new ColoredListCellRenderer() {
|
||||
@Override
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
CellAppearanceUtils.forVirtualFile((VirtualFile)value).customize(this);
|
||||
FileAppearanceService.getInstance().forVirtualFile((VirtualFile)value).customize(this);
|
||||
}
|
||||
});
|
||||
new PopupChooserBuilder(list)
|
||||
|
||||
+17
-2
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* 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.util.ui.classpath;
|
||||
|
||||
import com.intellij.ide.CommonActionsManager;
|
||||
@@ -24,8 +39,8 @@ import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -286,7 +301,7 @@ public abstract class ChooseLibrariesDialogBase extends DialogWrapper {
|
||||
private static class LibraryDescriptor extends LibrariesTreeNodeBase<Library> {
|
||||
protected LibraryDescriptor(final Project project, final NodeDescriptor parentDescriptor, final Library element) {
|
||||
super(project, parentDescriptor, element);
|
||||
final CellAppearance appearance = OrderEntryCellAppearanceUtils.forLibrary(element);
|
||||
final CellAppearance appearance = OrderEntryAppearanceService.getInstance(project).forLibrary(element, false);
|
||||
final SimpleColoredComponent coloredComponent = new SimpleColoredComponent();
|
||||
appearance.customize(coloredComponent);
|
||||
final PresentationData templatePresentation = getTemplatePresentation();
|
||||
|
||||
+21
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -15,12 +15,16 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.util;
|
||||
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public abstract class BaseTextCommentCellAppearance implements CellAppearance {
|
||||
public abstract class BaseTextCommentCellAppearance implements CellAppearanceEx {
|
||||
private SimpleTextAttributes myCommentAttributes = SimpleTextAttributes.GRAY_ATTRIBUTES;
|
||||
private SimpleTextAttributes myTextAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
|
||||
|
||||
@@ -30,18 +34,29 @@ public abstract class BaseTextCommentCellAppearance implements CellAppearance {
|
||||
|
||||
protected abstract String getPrimaryText();
|
||||
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
public void customize(@NotNull final SimpleColoredComponent component) {
|
||||
component.setIcon(getIcon());
|
||||
component.append(getPrimaryText(), myTextAttributes);
|
||||
String secondaryText = getSecondaryText();
|
||||
if (secondaryText != null && secondaryText.length() > 0)
|
||||
final String secondaryText = getSecondaryText();
|
||||
if (!StringUtil.isEmptyOrSpaces(secondaryText)) {
|
||||
component.append(" (" + secondaryText + ")", myCommentAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
renderer.setIcon(getIcon());
|
||||
renderer.append(getPrimaryText(), myTextAttributes);
|
||||
final String secondaryText = getSecondaryText();
|
||||
if (!StringUtil.isEmptyOrSpaces(secondaryText)) {
|
||||
renderer.append(" (" + secondaryText + ")", myCommentAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
String secondaryText = getSecondaryText();
|
||||
if (secondaryText != null && secondaryText.length() >0)
|
||||
if (secondaryText != null && secondaryText.length() > 0) {
|
||||
return getPrimaryText() + " (" + secondaryText + ")";
|
||||
}
|
||||
return getPrimaryText();
|
||||
}
|
||||
|
||||
|
||||
+12
-35
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -18,50 +18,36 @@ package com.intellij.openapi.roots.ui.util;
|
||||
import com.intellij.ide.presentation.VirtualFilePresentation;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import com.intellij.openapi.vfs.ex.http.HttpFileSystem;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
|
||||
// Author: dyoma
|
||||
|
||||
/**
|
||||
* @deprecated please use {@linkplain com.intellij.openapi.roots.ui.FileAppearanceService} (to remove in IDEA 12)
|
||||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public class CellAppearanceUtils {
|
||||
public static final Icon INVALID_ICON = IconLoader.getIcon("/nodes/ppInvalid.png");
|
||||
public static final CellAppearance EMPTY = new EmptyAppearance();
|
||||
public static final Icon INVALID_ICON = PlatformIcons.INVALID_ENTRY_ICON;
|
||||
public static final CellAppearance EMPTY = FileAppearanceService.getInstance().empty();
|
||||
|
||||
private CellAppearanceUtils() {
|
||||
}
|
||||
private CellAppearanceUtils() { }
|
||||
|
||||
public static SimpleTextAttributes createSimpleCellAttributes(boolean isSelected){
|
||||
public static SimpleTextAttributes createSimpleCellAttributes(boolean isSelected) {
|
||||
return isSelected ? SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES;
|
||||
}
|
||||
|
||||
|
||||
public static CellAppearance forVirtualFile(VirtualFile virtualFile) {
|
||||
return virtualFile.isValid() ?
|
||||
forValidVirtualFile(virtualFile) :
|
||||
SimpleTextCellAppearance.invalid(virtualFile.getPresentableUrl(), INVALID_ICON);
|
||||
return FileAppearanceService.getInstance().forVirtualFile(virtualFile);
|
||||
}
|
||||
|
||||
public static CellAppearance forValidVirtualFile(VirtualFile virtualFile) {
|
||||
final VirtualFileSystem fileSystem = virtualFile.getFileSystem();
|
||||
if (fileSystem.getProtocol().equals(JarFileSystem.PROTOCOL)) {
|
||||
return new JarSubfileCellAppearance(virtualFile);
|
||||
}
|
||||
if (fileSystem instanceof HttpFileSystem) {
|
||||
return new HttpUrlCellAppearance(virtualFile);
|
||||
}
|
||||
if (virtualFile.isDirectory()) {
|
||||
return SimpleTextCellAppearance.normal(virtualFile.getPresentableUrl(), PlatformIcons.FOLDER_ICON);
|
||||
}
|
||||
return new ValidFileCellAppearance(virtualFile);
|
||||
return FileAppearanceService.getInstance().forVirtualFile(virtualFile);
|
||||
}
|
||||
|
||||
public static Icon iconForFile(VirtualFile file) {
|
||||
@@ -91,13 +77,4 @@ public class CellAppearanceUtils {
|
||||
appearance.setIcon(fileType.getIcon());
|
||||
return appearance;
|
||||
}
|
||||
|
||||
private static class EmptyAppearance implements CellAppearance {
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+28
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -17,16 +17,21 @@ package com.intellij.openapi.roots.ui.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class CompositeAppearance implements ModifiableCellAppearance {
|
||||
// todo: move to lang-impl ?
|
||||
public class CompositeAppearance implements ModifiableCellAppearance, CellAppearanceEx {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.ui.util.CompositeAppearance");
|
||||
|
||||
private Icon myIcon;
|
||||
@@ -35,17 +40,26 @@ public class CompositeAppearance implements ModifiableCellAppearance {
|
||||
|
||||
public synchronized void customize(SimpleColoredComponent component) {
|
||||
for (TextSection section : mySections) {
|
||||
TextAttributes attributes = section.ATTRIBUTES;
|
||||
component.append(section.TEXT, SimpleTextAttributes.fromTextAttributes(attributes));
|
||||
final TextAttributes attributes = section.getTextAttributes();
|
||||
component.append(section.getText(), SimpleTextAttributes.fromTextAttributes(attributes));
|
||||
}
|
||||
component.setIcon(myIcon);
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
for (TextSection section : mySections) {
|
||||
final TextAttributes attributes = section.getTextAttributes();
|
||||
renderer.append(section.getText(), SimpleTextAttributes.fromTextAttributes(attributes));
|
||||
}
|
||||
setIcon(myIcon);
|
||||
}
|
||||
|
||||
public synchronized Icon getIcon() {
|
||||
return myIcon;
|
||||
}
|
||||
|
||||
public void setIcon(Icon icon) {
|
||||
public synchronized void setIcon(@Nullable final Icon icon) {
|
||||
myIcon = icon;
|
||||
}
|
||||
|
||||
@@ -72,15 +86,13 @@ public class CompositeAppearance implements ModifiableCellAppearance {
|
||||
return getText().hashCode();
|
||||
}
|
||||
|
||||
protected void addSectionAt(int index, @NotNull TextSection section) {
|
||||
synchronized (this) {
|
||||
mySections.add(index, section);
|
||||
for (Iterator<TextSection> iterator = mySections.iterator(); iterator.hasNext();) {
|
||||
TextSection textSection = iterator.next();
|
||||
if (textSection == null) {
|
||||
LOG.error("index: " + index + " size: " + mySections.size());
|
||||
iterator.remove();
|
||||
}
|
||||
protected synchronized void addSectionAt(int index, @NotNull TextSection section) {
|
||||
mySections.add(index, section);
|
||||
for (Iterator<TextSection> iterator = mySections.iterator(); iterator.hasNext();) {
|
||||
TextSection textSection = iterator.next();
|
||||
if (textSection == null) {
|
||||
LOG.error("index: " + index + " size: " + mySections.size());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,7 +128,7 @@ public class CompositeAppearance implements ModifiableCellAppearance {
|
||||
|
||||
public static CompositeAppearance invalid(String absolutePath) {
|
||||
CompositeAppearance appearance = new CompositeAppearance();
|
||||
appearance.setIcon(CellAppearanceUtils.INVALID_ICON);
|
||||
appearance.setIcon(PlatformIcons.INVALID_ENTRY_ICON);
|
||||
appearance.getEnding().addText(absolutePath, SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
return appearance;
|
||||
}
|
||||
|
||||
+33
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -15,55 +15,77 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.util;
|
||||
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.ui.HtmlListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class SimpleTextCellAppearance implements ModifiableCellAppearance {
|
||||
// todo: move to lang-impl ?
|
||||
public class SimpleTextCellAppearance implements ModifiableCellAppearance, CellAppearanceEx {
|
||||
private Icon myIcon;
|
||||
private final SimpleTextAttributes myTextAttributes;
|
||||
private final String myText;
|
||||
|
||||
public static SimpleTextCellAppearance invalid(String text, Icon icon) {
|
||||
public static SimpleTextCellAppearance regular(@NotNull final String text, @Nullable final Icon icon) {
|
||||
return new SimpleTextCellAppearance(text, icon, SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
public static SimpleTextCellAppearance invalid(@NotNull final String text, @Nullable final Icon icon) {
|
||||
return new SimpleTextCellAppearance(text, icon, SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
public static CellAppearance normal(String text, Icon icon) {
|
||||
CompositeAppearance result = CompositeAppearance.single(text);
|
||||
result.setIcon(icon);
|
||||
return result;
|
||||
/** @deprecated use {@linkplain #regular(String, javax.swing.Icon)} (to remove in IDEA 12) */
|
||||
public static CellAppearance normal(@NotNull final String text, @Nullable final Icon icon) {
|
||||
return regular(text, icon);
|
||||
}
|
||||
|
||||
public static SimpleTextCellAppearance synthetic(String text, Icon icon) {
|
||||
public static SimpleTextCellAppearance synthetic(@NotNull final String text, @Nullable final Icon icon) {
|
||||
return new SimpleTextCellAppearance(text, icon, SimpleTextAttributes.SYNTHETIC_ATTRIBUTES);
|
||||
}
|
||||
|
||||
public SimpleTextCellAppearance(@NotNull String text, Icon icon, SimpleTextAttributes textAttributes) {
|
||||
public SimpleTextCellAppearance(@NotNull final String text,
|
||||
@Nullable final Icon icon,
|
||||
@NotNull final SimpleTextAttributes textAttributes) {
|
||||
myIcon = icon;
|
||||
myTextAttributes = textAttributes;
|
||||
myText = text;
|
||||
}
|
||||
|
||||
public void customize(SimpleColoredComponent component) {
|
||||
@Override
|
||||
public void customize(@NotNull final SimpleColoredComponent component) {
|
||||
component.setIcon(myIcon);
|
||||
component.append(myText, myTextAttributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(@NotNull final HtmlListCellRenderer renderer) {
|
||||
renderer.setIcon(myIcon);
|
||||
renderer.append(myText, myTextAttributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return myText;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SimpleTextAttributes getTextAttributes() {
|
||||
return myTextAttributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Icon getIcon() {
|
||||
return myIcon;
|
||||
}
|
||||
|
||||
public void setIcon(Icon icon) {
|
||||
@Override
|
||||
public void setIcon(@Nullable final Icon icon) {
|
||||
myIcon = icon;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,14 @@
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.ide.ui.ListCellRendererWrapper;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.util.ModifiableCellAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.SimpleTextCellAppearance;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.StringBuilderSpinAllocator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* <p>Replacement for {@link ColoredListCellRenderer}, L&F friendly.
|
||||
@@ -34,8 +32,7 @@ import java.util.Iterator;
|
||||
* text fragments should be added via {@link #append(String, SimpleTextAttributes)}.<br>
|
||||
* Note that not all styles from SimpleTextAttributes are supported, see method code for details.
|
||||
*
|
||||
* <p>Alternatively, item can be rendered from {@link com.intellij.openapi.roots.ui.util.ModifiableCellAppearance}
|
||||
* by {@link #render(com.intellij.openapi.roots.ui.util.ModifiableCellAppearance)}.
|
||||
* <p>Alternatively, item can be rendered by {@link com.intellij.openapi.roots.ui.CellAppearanceEx#customize(HtmlListCellRenderer)}.
|
||||
*
|
||||
* @param <T> type of list items.
|
||||
*/
|
||||
@@ -120,21 +117,8 @@ public abstract class HtmlListCellRenderer<T> extends ListCellRendererWrapper<T>
|
||||
builder.append('"');
|
||||
}
|
||||
|
||||
/** @deprecated use {@linkplain com.intellij.openapi.roots.ui.CellAppearanceEx#customize(HtmlListCellRenderer)} (to remove in IDEA 12) */
|
||||
public void render(@NotNull final ModifiableCellAppearance appearance) {
|
||||
if (appearance instanceof SimpleTextCellAppearance) {
|
||||
final SimpleTextCellAppearance simple = (SimpleTextCellAppearance)appearance;
|
||||
append(simple.getText(), simple.getTextAttributes());
|
||||
}
|
||||
else if (appearance instanceof CompositeAppearance) {
|
||||
final Iterator<CompositeAppearance.TextSection> iterator = ((CompositeAppearance)appearance).getSectionsIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final CompositeAppearance.TextSection section = iterator.next();
|
||||
append(section.getText(), SimpleTextAttributes.fromTextAttributes(section.getTextAttributes()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Unknown class: " + appearance.getClass());
|
||||
}
|
||||
setIcon(appearance.getIcon());
|
||||
((CellAppearanceEx)appearance).customize(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -262,7 +262,7 @@ public class AntExplorer extends SimpleToolWindowPanel implements DataProvider,
|
||||
|
||||
public void setBuildFileProperties() {
|
||||
final AntBuildFileBase buildFile = getCurrentBuildFile();
|
||||
if (buildFile != null && BuildFilePropertiesPanel.editBuildFile(buildFile)) {
|
||||
if (buildFile != null && BuildFilePropertiesPanel.editBuildFile(buildFile, myProject)) {
|
||||
myConfig.updateBuildFile(buildFile);
|
||||
myBuilder.queueUpdate();
|
||||
myTree.repaint();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -17,8 +17,9 @@ package com.intellij.lang.ant.config.impl;
|
||||
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.roots.ui.util.ModifiableCellAppearance;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
@@ -65,16 +66,18 @@ public class AllJarsUnderDirEntry implements AntClasspathEntry {
|
||||
|
||||
public void addFilesTo(final List<File> files) {
|
||||
File[] children = myDir.listFiles(new FileFilter() {
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.getName().endsWith(JAR_SUFFIX) && pathname.isFile();
|
||||
public boolean accept(File pathName) {
|
||||
return pathName.getName().endsWith(JAR_SUFFIX) && pathName.isFile();
|
||||
}
|
||||
});
|
||||
if (children != null) ContainerUtil.addAll(files, children);
|
||||
}
|
||||
|
||||
public CompositeAppearance getAppearance() {
|
||||
CompositeAppearance appearance = CellAppearanceUtils.forFile(myDir);
|
||||
appearance.setIcon(ALL_JARS_IN_DIR_ICON);
|
||||
public CellAppearanceEx getAppearance() {
|
||||
CellAppearanceEx appearance = FileAppearanceService.getInstance().forIoFile(myDir);
|
||||
if (appearance instanceof ModifiableCellAppearance) {
|
||||
((ModifiableCellAppearance)appearance).setIcon(ALL_JARS_IN_DIR_ICON);
|
||||
}
|
||||
return appearance;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.lang.ant.config.impl;
|
||||
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.util.PathUtil;
|
||||
@@ -48,5 +48,5 @@ public interface AntClasspathEntry {
|
||||
|
||||
void addFilesTo(List<File> files);
|
||||
|
||||
CompositeAppearance getAppearance();
|
||||
CellAppearanceEx getAppearance();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -17,8 +17,8 @@ package com.intellij.lang.ant.config.impl;
|
||||
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.roots.ui.CellAppearanceEx;
|
||||
import com.intellij.openapi.roots.ui.FileAppearanceService;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
@@ -42,17 +42,17 @@ public class SinglePathEntry implements AntClasspathEntry {
|
||||
return fromVirtulaFile(singlePathEntry);
|
||||
}
|
||||
};
|
||||
@NonNls static final String PATH = "path";
|
||||
private File myFile;
|
||||
|
||||
public SinglePathEntry() {}
|
||||
@NonNls static final String PATH = "path";
|
||||
|
||||
private File myFile;
|
||||
|
||||
public SinglePathEntry(File file) {
|
||||
myFile = file;
|
||||
}
|
||||
|
||||
public SinglePathEntry(final String ospath) {
|
||||
this(new File(ospath));
|
||||
public SinglePathEntry(final String osPath) {
|
||||
this(new File(osPath));
|
||||
}
|
||||
|
||||
public void readExternal(final Element element) throws InvalidDataException {
|
||||
@@ -69,8 +69,8 @@ public class SinglePathEntry implements AntClasspathEntry {
|
||||
files.add(myFile);
|
||||
}
|
||||
|
||||
public CompositeAppearance getAppearance() {
|
||||
return CellAppearanceUtils.forFile(myFile);
|
||||
public CellAppearanceEx getAppearance() {
|
||||
return FileAppearanceService.getInstance().forIoFile(myFile);
|
||||
}
|
||||
|
||||
public String getPresentablePath() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -17,27 +17,25 @@ package com.intellij.lang.ant.config.impl.configuration;
|
||||
|
||||
import com.intellij.ide.macro.MacrosDialog;
|
||||
import com.intellij.lang.ant.AntBundle;
|
||||
import com.intellij.lang.ant.AntIcons;
|
||||
import com.intellij.lang.ant.config.impl.AntClasspathEntry;
|
||||
import com.intellij.lang.ant.config.impl.AntInstallation;
|
||||
import com.intellij.lang.ant.config.impl.AntReference;
|
||||
import com.intellij.lang.ant.config.impl.GlobalAntConfiguration;
|
||||
import com.intellij.lang.ant.psi.AntProject;
|
||||
import com.intellij.lang.ant.psi.AntTarget;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.util.CompositeAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
|
||||
import com.intellij.openapi.roots.ui.OrderEntryAppearanceService;
|
||||
import com.intellij.openapi.ui.FixedSizeButton;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.config.AbstractProperty;
|
||||
import com.intellij.util.ui.AbstractTableCellEditor;
|
||||
import com.intellij.util.ui.CellEditorComponentWithBrowseButton;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.BadLocationException;
|
||||
@@ -46,7 +44,9 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class AntUIUtil {
|
||||
public static final Icon ANT_INSTALLATION_ICON = IconLoader.getIcon("/ant/antInstallation.png");
|
||||
private static final Icon ANT_INSTALLATION_ICON = IconLoader.getIcon("/ant/antInstallation.png");
|
||||
private static final Icon GENERIC_JDK_ICON = IconLoader.getIcon("/general/jdk.png");
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ant.impl.configuration.AntUIUtil");
|
||||
|
||||
private AntUIUtil() {
|
||||
@@ -92,7 +92,7 @@ public class AntUIUtil {
|
||||
AntInstallation antInstallation = antReference.find(configuration);
|
||||
if (antInstallation != null) customizeAnt(antInstallation.getProperties(), component);
|
||||
else {
|
||||
component.setIcon(CellAppearanceUtils.INVALID_ICON);
|
||||
component.setIcon(PlatformIcons.INVALID_ENTRY_ICON);
|
||||
component.append(antReference.getName(), SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
@@ -165,12 +165,12 @@ public class AntUIUtil {
|
||||
}
|
||||
|
||||
public static class ProjectJdkRenderer extends ColoredListCellRenderer {
|
||||
private final GlobalAntConfiguration myAntConfiguration;
|
||||
private final Project myProject;
|
||||
private final boolean myInComboBox;
|
||||
private final String myProjectJdkName;
|
||||
|
||||
public ProjectJdkRenderer(GlobalAntConfiguration antConfiguration, boolean inComboBox, String projectJdkName) {
|
||||
myAntConfiguration = antConfiguration;
|
||||
public ProjectJdkRenderer(@NotNull final Project project, boolean inComboBox, String projectJdkName) {
|
||||
myProject = project;
|
||||
myInComboBox = inComboBox;
|
||||
myProjectJdkName = projectJdkName != null ? projectJdkName : "";
|
||||
}
|
||||
@@ -178,46 +178,20 @@ public class AntUIUtil {
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
String jdkName = (String)value;
|
||||
if (jdkName == null || jdkName.length() == 0) jdkName = "";
|
||||
Sdk jdk = myAntConfiguration.findJdk(jdkName);
|
||||
Sdk jdk = GlobalAntConfiguration.findJdk(jdkName);
|
||||
if (jdk == null) {
|
||||
if (myProjectJdkName.length() > 0) {
|
||||
setIcon(OrderEntryCellAppearanceUtils.GENERIC_JDK_ICON);
|
||||
setIcon(GENERIC_JDK_ICON);
|
||||
append(AntBundle.message("project.jdk.project.jdk.name.list.column.value", myProjectJdkName), selected ? SimpleTextAttributes.SELECTED_SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
|
||||
}
|
||||
else {
|
||||
setIcon(CellAppearanceUtils.INVALID_ICON);
|
||||
setIcon(PlatformIcons.INVALID_ENTRY_ICON);
|
||||
append(AntBundle.message("project.jdk.not.specified.list.column.value"), SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
else {
|
||||
OrderEntryCellAppearanceUtils.forJdk(jdk, myInComboBox, selected).customize(this);
|
||||
OrderEntryAppearanceService.getInstance(myProject).forJdk(jdk, myInComboBox, selected, true).customize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class DOMTargetRenderer extends ColoredListCellRenderer {
|
||||
private final AntProject myDomProject;
|
||||
|
||||
public DOMTargetRenderer(final AntProject domProject) {
|
||||
myDomProject = domProject;
|
||||
}
|
||||
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
AntTarget target = (AntTarget)value;
|
||||
String name = target.getName();
|
||||
CompositeAppearance appearance = name != null
|
||||
? CompositeAppearance.single(name, SimpleTextAttributes.REGULAR_ATTRIBUTES)
|
||||
: CompositeAppearance.single(AntBundle.message("unnamed.string.presentation"), SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
|
||||
AntProject project = target.getAntProject();
|
||||
if (project != myDomProject) {
|
||||
String projectName = project.getName();
|
||||
if (projectName == null || projectName.trim().length() == 0)
|
||||
projectName = project.getAntFile().getName();
|
||||
appearance.getEnding().addComment(projectName);
|
||||
}
|
||||
appearance.customize(this);
|
||||
setIcon(AntIcons.ANT_TARGET_ICON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.lang.ant.config.impl.*;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.ui.ProjectJdksEditor;
|
||||
@@ -38,6 +39,7 @@ import com.intellij.util.config.AbstractProperty;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -49,10 +51,12 @@ import java.util.*;
|
||||
|
||||
public class BuildFilePropertiesPanel {
|
||||
@NonNls private static final String DIMENSION_SERVICE_KEY = "antBuildFilePropertiesDialogDimension";
|
||||
private final Form myForm = new Form();
|
||||
|
||||
private final Form myForm;
|
||||
private AntBuildFileBase myBuildFile;
|
||||
|
||||
private BuildFilePropertiesPanel() {
|
||||
private BuildFilePropertiesPanel(@NotNull final Project project) {
|
||||
myForm = new Form(project);
|
||||
}
|
||||
|
||||
private void reset(final AntBuildFileBase buildFile) {
|
||||
@@ -90,8 +94,8 @@ public class BuildFilePropertiesPanel {
|
||||
Disposer.dispose(myForm);
|
||||
}
|
||||
|
||||
public static boolean editBuildFile(AntBuildFileBase buildFile) {
|
||||
BuildFilePropertiesPanel panel = new BuildFilePropertiesPanel();
|
||||
public static boolean editBuildFile(AntBuildFileBase buildFile, @NotNull final Project project) {
|
||||
BuildFilePropertiesPanel panel = new BuildFilePropertiesPanel(project);
|
||||
panel.reset(buildFile);
|
||||
return panel.showDialog();
|
||||
}
|
||||
@@ -131,16 +135,18 @@ public class BuildFilePropertiesPanel {
|
||||
private JPanel myTabsPlace;
|
||||
private JPanel myWholePanel;
|
||||
private JLabel myHeapSizeLabel;
|
||||
private final Tab[] myTabs = {
|
||||
new PropertiesTab(),
|
||||
new ExecutionTab(GlobalAntConfiguration.getInstance()),
|
||||
new AdditionalClasspathTab(),
|
||||
new FiltersTab()
|
||||
};
|
||||
private final Tab[] myTabs;
|
||||
private final UIPropertyBinding.Composite myBinding = new UIPropertyBinding.Composite();
|
||||
private final TabbedPaneWrapper myWrapper;
|
||||
|
||||
private Form() {
|
||||
private Form(@NotNull final Project project) {
|
||||
myTabs = new Tab[]{
|
||||
new PropertiesTab(),
|
||||
new ExecutionTab(GlobalAntConfiguration.getInstance(), project),
|
||||
new AdditionalClasspathTab(),
|
||||
new FiltersTab()
|
||||
};
|
||||
|
||||
myHeapSizeLabel.setLabelFor(myXmx);
|
||||
myWrapper = new TabbedPaneWrapper(this);
|
||||
myTabsPlace.setLayout(new BorderLayout());
|
||||
@@ -365,9 +371,11 @@ public class BuildFilePropertiesPanel {
|
||||
|
||||
private AntReference myProjectDefaultAnt = null;
|
||||
private final GlobalAntConfiguration myAntGlobalConfiguration;
|
||||
private final Project myProject;
|
||||
|
||||
public ExecutionTab(final GlobalAntConfiguration antConfiguration) {
|
||||
public ExecutionTab(final GlobalAntConfiguration antConfiguration, @NotNull final Project project) {
|
||||
myAntGlobalConfiguration = antConfiguration;
|
||||
myProject = project;
|
||||
myAntCommandLine.attachLabel(myAntCmdLineLabel);
|
||||
myAntCommandLine.setDialogCaption(AntBundle.message("run.execution.tab.ant.command.line.dialog.title"));
|
||||
setLabelFor(myJDKLabel, myJDKs);
|
||||
@@ -425,7 +433,7 @@ public class BuildFilePropertiesPanel {
|
||||
|
||||
public void reset(AbstractProperty.AbstractPropertyContainer options) {
|
||||
String projectJdkName = AntConfigurationImpl.DEFAULT_JDK_NAME.get(options);
|
||||
myJDKsController.setRenderer(new AntUIUtil.ProjectJdkRenderer(myAntGlobalConfiguration, true, projectJdkName));
|
||||
myJDKsController.setRenderer(new AntUIUtil.ProjectJdkRenderer(myProject, true, projectJdkName));
|
||||
super.reset(options);
|
||||
myJDKsController.resetList(null);
|
||||
myProjectDefaultAnt = AntConfigurationImpl.DEFAULT_ANT.get(options);
|
||||
|
||||
Reference in New Issue
Block a user