Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
irengrig
2012-03-19 15:59:33 +04:00
9 changed files with 115 additions and 98 deletions
@@ -10,6 +10,7 @@
<orderEntry type="module" module-name="execution-openapi" />
<orderEntry type="module" module-name="jsp-openapi" />
<orderEntry type="module" module-name="java-psi-api" />
<orderEntry type="module" module-name="resources-en" />
</component>
<component name="copyright">
<Base>
@@ -52,8 +52,10 @@ public class DummyHolder extends PsiFileImpl {
protected static Language language(PsiElement context, Language defaultLanguage) {
if (context == null) return defaultLanguage;
PsiFile file = context.getContainingFile();
if (file == null) return defaultLanguage;
Language contextLanguage = context.getLanguage();
Language language = context.getContainingFile().getLanguage();
Language language = file.getLanguage();
if (language.isKindOf(contextLanguage)) return language;
return contextLanguage;
}
@@ -17,7 +17,6 @@ package com.intellij.ui;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.ui.border.CustomLineBorder;
import com.intellij.ui.table.TableView;
import com.intellij.util.ui.ElementProducer;
@@ -89,8 +88,11 @@ public abstract class ToolbarDecorator implements DataProvider, CommonActionsPan
}
protected ToolbarDecorator initPositionAndBorder() {
myToolbarPosition = SystemInfo.isMac ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT;
myBorder = new CustomLineBorder(0, SystemInfo.isMac ? 0 : 1, 0, 0);
myToolbarPosition = UIUtil.isUnderAquaLookAndFeel() ? ActionToolbarPosition.BOTTOM : ActionToolbarPosition.RIGHT;
myBorder = new CustomLineBorder(0,
myToolbarPosition == ActionToolbarPosition.RIGHT ? 1 : 0,
myToolbarPosition == ActionToolbarPosition.TOP ? 1 : 0,
myToolbarPosition == ActionToolbarPosition.LEFT ? 1 : 0);
final JComponent c = getComponent();
if (c != null) {
c.setBorder(IdeBorderFactory.createEmptyBorder(0));
@@ -180,6 +182,10 @@ public abstract class ToolbarDecorator implements DataProvider, CommonActionsPan
public ToolbarDecorator setToolbarPosition(ActionToolbarPosition position) {
myToolbarPosition = position;
myBorder = new CustomLineBorder(0,
myToolbarPosition == ActionToolbarPosition.RIGHT ? 1 : 0,
myToolbarPosition == ActionToolbarPosition.TOP ? 1 : 0,
myToolbarPosition == ActionToolbarPosition.LEFT ? 1 : 0);
return this;
}
@@ -122,14 +122,22 @@ public class StartupUtil {
private static boolean checkTmpIsAccessible() {
if (!SystemInfo.isUnix || SystemInfo.isMac) return true;
final File tmpDir = new File(System.getProperty("java.io.tmpdir"));
if (!tmpDir.isDirectory()) {
showError("Inaccessible Temp Directory", "Temp directory '" + tmpDir + "' does not exist.\n" +
"Please set 'java.io.tmpdir' system property to point to an existing directory.");
return false;
}
final File tmp;
try {
tmp = FileUtil.createTempFile("idea_check_", ".tmp");
//noinspection SSBasedInspection
tmp = File.createTempFile("idea_tmp_check_", ".sh", tmpDir);
FileUtil.writeToFile(tmp, "#!/bin/sh\n" +
"exit 0");
}
catch (IOException e) {
showError("Inaccessible Temp Directory", e.getMessage() + " (" + FileUtil.getTempDirectory() + ").\n" +
showError("Inaccessible Temp Directory", e.getMessage() + " (" + tmpDir + ").\n" +
"Temp directory is not accessible.\n" +
"Please set 'java.io.tmpdir' system property to point to a writable directory.");
return false;
@@ -173,7 +173,7 @@ public abstract class BaseInspectionVisitor extends JavaElementVisitor {
protected final void registerError(@NotNull PsiElement location,
Object... infos) {
if (location.getTextLength() == 0) {
if (location.getTextLength() == 0 && !(location instanceof PsiFile)) {
return;
}
final InspectionGadgetsFix[] fixes = createFixes(infos);
@@ -6,4 +6,11 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Empty class</problem_class>
<description>Class &lt;code&gt;ReportMe&lt;/code&gt; is empty #loc</description>
</problem>
<problem>
<file>EmptyFile.java</file>
<line>1</line>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Empty class</problem_class>
<description>Java file does not declare any class #loc</description>
</problem>
</problems>
@@ -42,74 +42,18 @@
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="1a993" binding="myPropertiesPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<grid id="1a993" binding="myPropertiesPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="1" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="1" use-parent-layout="false">
<preferred-size width="-1" height="250"/>
</grid>
</constraints>
<properties/>
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
</clientProperties>
<border type="none" title="Properties"/>
<children>
<grid id="25699" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="eb376" class="com.intellij.ui.components.JBScrollPane">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f2d63" class="com.intellij.ui.table.JBTable" binding="myPropertiesTable">
<constraints/>
<properties>
<preferredScrollableViewportSize width="350" height="200"/>
</properties>
</component>
</children>
</scrollpane>
<grid id="c5a2a" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3370" class="javax.swing.JButton" binding="myAddButton" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Add"/>
</properties>
</component>
<vspacer id="4ebaf">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="ada4f" class="javax.swing.JButton" binding="myRemoveButton" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Remove"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</children>
<children/>
</grid>
</children>
</grid>
@@ -21,20 +21,23 @@ import com.intellij.lang.ant.config.AntConfiguration;
import com.intellij.lang.ant.config.impl.BuildFileProperty;
import com.intellij.lang.ant.config.impl.TargetChooserDialog;
import com.intellij.lang.ant.config.impl.configuration.UIPropertyBinding;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.ui.FixedSizeButton;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.packaging.ui.ArtifactEditorContext;
import com.intellij.packaging.ui.ArtifactPropertiesEditor;
import com.intellij.ui.*;
import com.intellij.ui.table.JBTable;
import com.intellij.util.NewInstanceFactory;
import com.intellij.util.config.ListProperty;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.ColumnInfo;
import com.intellij.util.ui.ListTableModel;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
@@ -45,32 +48,34 @@ import java.util.List;
*/
public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor {
private static final ListProperty<BuildFileProperty> ANT_PROPERTIES = ListProperty.create("ant-properties");
private static final ColumnInfo<BuildFileProperty, String> NAME_COLUMN = new ColumnInfo<BuildFileProperty, String>(AntBundle.message("edit.ant.properties.name.column.name")) {
public String valueOf(BuildFileProperty buildFileProperty) {
return buildFileProperty.getPropertyName();
}
private static final ColumnInfo<BuildFileProperty, String> NAME_COLUMN =
new ColumnInfo<BuildFileProperty, String>(AntBundle.message("edit.ant.properties.name.column.name")) {
public String valueOf(BuildFileProperty buildFileProperty) {
return buildFileProperty.getPropertyName();
}
public boolean isCellEditable(BuildFileProperty buildFileProperty) {
return USER_PROPERTY_CONDITION.value(buildFileProperty);
}
public boolean isCellEditable(BuildFileProperty buildFileProperty) {
return USER_PROPERTY_CONDITION.value(buildFileProperty);
}
public void setValue(BuildFileProperty buildFileProperty, String name) {
buildFileProperty.setPropertyName(name);
}
};
private static final ColumnInfo<BuildFileProperty, String> VALUE_COLUMN = new ColumnInfo<BuildFileProperty, String>(AntBundle.message("edit.ant.properties.value.column.name")) {
public boolean isCellEditable(BuildFileProperty buildFileProperty) {
return USER_PROPERTY_CONDITION.value(buildFileProperty);
}
public void setValue(BuildFileProperty buildFileProperty, String name) {
buildFileProperty.setPropertyName(name);
}
};
private static final ColumnInfo<BuildFileProperty, String> VALUE_COLUMN =
new ColumnInfo<BuildFileProperty, String>(AntBundle.message("edit.ant.properties.value.column.name")) {
public boolean isCellEditable(BuildFileProperty buildFileProperty) {
return USER_PROPERTY_CONDITION.value(buildFileProperty);
}
public String valueOf(BuildFileProperty buildFileProperty) {
return buildFileProperty.getPropertyValue();
}
public String valueOf(BuildFileProperty buildFileProperty) {
return buildFileProperty.getPropertyValue();
}
public void setValue(BuildFileProperty buildFileProperty, String value) {
buildFileProperty.setPropertyValue(value);
}
};
public void setValue(BuildFileProperty buildFileProperty, String value) {
buildFileProperty.setPropertyValue(value);
}
};
private static final ColumnInfo[] PROPERTY_COLUMNS = new ColumnInfo[]{NAME_COLUMN, VALUE_COLUMN};
private static final Condition<BuildFileProperty> USER_PROPERTY_CONDITION = new Condition<BuildFileProperty>() {
@Override
@@ -84,8 +89,6 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor {
private JCheckBox myRunTargetCheckBox;
private FixedSizeButton mySelectTargetButton;
private JBTable myPropertiesTable;
private JButton myAddButton;
private JButton myRemoveButton;
private JPanel myPropertiesPanel;
private AntBuildTarget myTarget;
private final boolean myPostProcessing;
@@ -111,10 +114,59 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor {
}
});
myPropertiesTable = new JBTable();
UIPropertyBinding.Composite binding = new UIPropertyBinding.Composite();
myBinding = binding.bindList(myPropertiesTable, PROPERTY_COLUMNS, ANT_PROPERTIES);
myBinding.addAddFacility(myAddButton, NewInstanceFactory.fromClass(BuildFileProperty.class));
myBinding.addRemoveFacility(myRemoveButton, USER_PROPERTY_CONDITION);
myPropertiesPanel.add(
ToolbarDecorator.createDecorator(myPropertiesTable)
.setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
ListTableModel<BuildFileProperty> model = (ListTableModel<BuildFileProperty>)myPropertiesTable.getModel();
if (myPropertiesTable.isEditing() && !myPropertiesTable.getCellEditor().stopCellEditing()) {
return;
}
BuildFileProperty item = new BuildFileProperty();
ArrayList<BuildFileProperty> items = new ArrayList<BuildFileProperty>(model.getItems());
items.add(item);
model.setItems(items);
int newIndex = model.indexOf(item);
ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel();
selectionModel.clearSelection();
selectionModel.setSelectionInterval(newIndex, newIndex);
ColumnInfo[] columns = model.getColumnInfos();
for (int i = 0; i < columns.length; i++) {
ColumnInfo column = columns[i];
if (column.isCellEditable(item)) {
myPropertiesTable.requestFocusInWindow();
myPropertiesTable.editCellAt(newIndex, i);
break;
}
}
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
TableUtil.removeSelectedItems(myPropertiesTable);
}
}).setRemoveActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
final ListSelectionModel selectionModel = myPropertiesTable.getSelectionModel();
ListTableModel<BuildFileProperty> model = (ListTableModel<BuildFileProperty>)myPropertiesTable.getModel();
boolean enable = false;
if (!selectionModel.isSelectionEmpty()) {
enable = true;
for (int i : myPropertiesTable.getSelectedRows()) {
if (AntArtifactProperties.isPredefinedProperty(model.getItems().get(i).getPropertyName())) {
enable = false;
break;
}
}
}
return enable;
}
}).disableUpDownActions().createPanel(), BorderLayout.CENTER);
}
private void selectTarget() {
@@ -135,9 +187,6 @@ public class AntArtifactPropertiesEditor extends ArtifactPropertiesEditor {
}
final boolean enabled = myTarget != null && myRunTargetCheckBox.isSelected();
UIUtil.setEnabled(myPropertiesPanel, enabled, true);
if (enabled) {
myBinding.updateRemoveButton(myRemoveButton, USER_PROPERTY_CONDITION);
}
}
public String getTabName() {