mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PropertyTable extracted to platform
This commit is contained in:
+1
-27
@@ -13,16 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.designer.inspection;
|
||||
package com.intellij.designer.model;
|
||||
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.RadComponentVisitor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -73,27 +70,4 @@ public final class ErrorInfo {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<ErrorInfo> get(RadComponent component) {
|
||||
List<ErrorInfo> errorInfos = component.getClientProperty(KEY);
|
||||
return errorInfos == null ? Collections.<ErrorInfo>emptyList() : errorInfos;
|
||||
}
|
||||
|
||||
public static void add(RadComponent component, ErrorInfo errorInfo) {
|
||||
List<ErrorInfo> errorInfos = component.getClientProperty(KEY);
|
||||
if (errorInfos == null) {
|
||||
errorInfos = new ArrayList<ErrorInfo>();
|
||||
component.setClientProperty(KEY, errorInfos);
|
||||
}
|
||||
errorInfos.add(errorInfo);
|
||||
}
|
||||
|
||||
public static void clear(RadComponent component) {
|
||||
component.accept(new RadComponentVisitor() {
|
||||
@Override
|
||||
public void endVisit(RadComponent component) {
|
||||
component.extractClientProperty(KEY);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.designer.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class PropertiesContainer {
|
||||
public abstract List<Property> getProperties();
|
||||
}
|
||||
+5
-4
@@ -13,9 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.designer.propertyTable;
|
||||
package com.intellij.designer.model;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -26,7 +27,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public abstract class Property<T extends RadComponent> {
|
||||
public abstract class Property<T extends PropertiesContainer> {
|
||||
private final Property myParent;
|
||||
private final String myName;
|
||||
private boolean myImportant;
|
||||
@@ -89,7 +90,7 @@ public abstract class Property<T extends RadComponent> {
|
||||
public void setDefaultValue(T component) throws Exception {
|
||||
}
|
||||
|
||||
public boolean availableFor(List<RadComponent> components) {
|
||||
public boolean availableFor(List<PropertiesContainer> components) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.designer.model;
|
||||
|
||||
public interface PropertyContext {
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.designer.inspection;
|
||||
package com.intellij.designer.model;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
+4
-3
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package com.intellij.designer.propertyTable;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -29,8 +30,8 @@ public abstract class PropertyEditor {
|
||||
private final EventListenerList myListenerList = new EventListenerList();
|
||||
|
||||
@NotNull
|
||||
public abstract JComponent getComponent(@NotNull RadComponent rootComponent,
|
||||
@Nullable RadComponent component,
|
||||
public abstract JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
@Nullable PropertyContext context,
|
||||
Object value,
|
||||
@Nullable InplaceContext inplaceContext);
|
||||
|
||||
+4
-2
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package com.intellij.designer.propertyTable;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,7 +27,8 @@ import javax.swing.*;
|
||||
*/
|
||||
public interface PropertyRenderer {
|
||||
@NotNull
|
||||
JComponent getComponent(@Nullable RadComponent component, @Nullable Object value, boolean selected, boolean hasFocus);
|
||||
JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
PropertyContext context, @Nullable Object value, boolean selected, boolean hasFocus);
|
||||
|
||||
void updateUI();
|
||||
}
|
||||
+71
-138
@@ -15,16 +15,11 @@
|
||||
*/
|
||||
package com.intellij.designer.propertyTable;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.designSurface.ComponentSelectionListener;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.inspection.ErrorInfo;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.ErrorInfo;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
@@ -40,13 +35,11 @@ import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.ui.EmptyIcon;
|
||||
import com.intellij.util.ui.IndentedIcon;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.plaf.TableUI;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.JTableHeader;
|
||||
@@ -57,17 +50,18 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public final class PropertyTable extends JBTable implements DataProvider, ComponentSelectionListener {
|
||||
public abstract class PropertyTable extends JBTable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.designer.propertyTable.PropertyTable");
|
||||
|
||||
private final AbstractTableModel myModel = new PropertyTableModel();
|
||||
private List<RadComponent> myComponents = Collections.emptyList();
|
||||
private List<PropertiesContainer> myContainers = Collections.emptyList();
|
||||
private List<Property> myProperties = Collections.emptyList();
|
||||
private final Set<String> myExpandedProperties = new HashSet<String>();
|
||||
|
||||
@@ -78,15 +72,8 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
private final TableCellRenderer myCellRenderer = new PropertyCellRenderer();
|
||||
|
||||
private boolean mySkipUpdate;
|
||||
private EditableArea myArea;
|
||||
private DesignerEditorPanel myDesigner;
|
||||
private Property myInitialSelection;
|
||||
|
||||
private boolean myShowExpert;
|
||||
|
||||
private QuickFixManager myQuickFixManager;
|
||||
|
||||
private PropertyTablePanel myPropertyTablePanel;
|
||||
|
||||
public PropertyTable() {
|
||||
setModel(myModel);
|
||||
@@ -94,14 +81,6 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
showColumns(false);
|
||||
|
||||
addMouseListener(new MouseTableListener());
|
||||
getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (myDesigner != null) {
|
||||
myDesigner.setSelectionProperty(getSelectionProperty());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Updates UI after LAF updated
|
||||
}
|
||||
@@ -112,14 +91,6 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
tableHeader.setPreferredSize(value ? null : new Dimension());
|
||||
}
|
||||
|
||||
public void initQuickFixManager(JViewport viewPort) {
|
||||
myQuickFixManager = new QuickFixManager(this, viewPort);
|
||||
}
|
||||
|
||||
public void setPropertyTablePanel(PropertyTablePanel propertyTablePanel) {
|
||||
myPropertyTablePanel = propertyTablePanel;
|
||||
}
|
||||
|
||||
public void setUI(TableUI ui) {
|
||||
super.setUI(ui);
|
||||
|
||||
@@ -160,56 +131,13 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
return myCellRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
if (PlatformDataKeys.FILE_EDITOR.is(dataId) && myDesigner != null) {
|
||||
return myDesigner.getEditor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setArea(@Nullable DesignerEditorPanel designer, @Nullable EditableArea area) {
|
||||
myDesigner = designer;
|
||||
myInitialSelection = designer == null ? null : designer.getSelectionProperty();
|
||||
myQuickFixManager.setDesigner(designer);
|
||||
|
||||
finishEditing();
|
||||
|
||||
if (myArea != null) {
|
||||
myArea.removeSelectionListener(this);
|
||||
}
|
||||
|
||||
myArea = area;
|
||||
|
||||
if (myArea != null) {
|
||||
myArea.addSelectionListener(this);
|
||||
}
|
||||
|
||||
updateProperties();
|
||||
}
|
||||
|
||||
public void updateInspections() {
|
||||
myQuickFixManager.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectionChanged(EditableArea area) {
|
||||
updateProperties();
|
||||
}
|
||||
|
||||
public boolean isShowExpert() {
|
||||
return myShowExpert;
|
||||
}
|
||||
|
||||
public void showExpert(boolean showExpert) {
|
||||
myShowExpert = showExpert;
|
||||
updateProperties();
|
||||
update();
|
||||
}
|
||||
|
||||
public void restoreDefaultValue() {
|
||||
@@ -219,24 +147,26 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
cellEditor.stopCellEditing();
|
||||
}
|
||||
|
||||
myDesigner.getToolProvider().execute(new ThrowableRunnable<Exception>() {
|
||||
doRestoreDefault(new ThrowableRunnable<Exception>() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
for (RadComponent component : myComponents) {
|
||||
for (PropertiesContainer component : myContainers) {
|
||||
if (!property.isDefaultValue(component)) {
|
||||
property.setDefaultValue(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, DesignerBundle.message("designer.properties.restore_default"), false);
|
||||
});
|
||||
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean doRestoreDefault(ThrowableRunnable<Exception> runnable);
|
||||
|
||||
@Nullable
|
||||
public ErrorInfo getErrorInfoForRow(int row) {
|
||||
if (myComponents.size() != 1) {
|
||||
if (myContainers.size() != 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -245,7 +175,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
return null;
|
||||
}
|
||||
|
||||
for (ErrorInfo errorInfo : ErrorInfo.get(myComponents.get(0))) {
|
||||
for (ErrorInfo errorInfo : getErrors(myContainers.get(0))) {
|
||||
if (property.getName().equals(errorInfo.getPropertyName())) {
|
||||
return errorInfo;
|
||||
}
|
||||
@@ -253,6 +183,8 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract List<ErrorInfo> getErrors(@NotNull PropertiesContainer container);
|
||||
|
||||
@Override
|
||||
public String getToolTipText(MouseEvent event) {
|
||||
int row = rowAtPoint(event.getPoint());
|
||||
@@ -277,7 +209,18 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void updateProperties() {
|
||||
@Nullable
|
||||
protected PropertyContext getPropertyContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
doUpdate(myContainers, null);
|
||||
}
|
||||
|
||||
public void doUpdate(@NotNull List<? extends PropertiesContainer> containers, @Nullable Property initialSelection) {
|
||||
finishEditing();
|
||||
|
||||
if (mySkipUpdate) {
|
||||
return;
|
||||
}
|
||||
@@ -288,28 +231,12 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
cellEditor.stopCellEditing();
|
||||
}
|
||||
|
||||
if (myArea == null) {
|
||||
myComponents = Collections.emptyList();
|
||||
myProperties = Collections.emptyList();
|
||||
myModel.fireTableDataChanged();
|
||||
}
|
||||
else {
|
||||
Property selection = getSelectionProperty();
|
||||
myComponents = new ArrayList<RadComponent>(myArea.getSelection());
|
||||
fillProperties();
|
||||
myModel.fireTableDataChanged();
|
||||
Property selection = initialSelection != null ? initialSelection : getSelectionProperty();
|
||||
myContainers = new ArrayList<PropertiesContainer>(containers);
|
||||
fillProperties();
|
||||
myModel.fireTableDataChanged();
|
||||
|
||||
if (myInitialSelection != null && !myComponents.isEmpty()) {
|
||||
selection = myInitialSelection;
|
||||
myInitialSelection = null;
|
||||
}
|
||||
|
||||
restoreSelection(selection);
|
||||
}
|
||||
|
||||
if (myPropertyTablePanel != null) {
|
||||
myPropertyTablePanel.updateActions();
|
||||
}
|
||||
restoreSelection(selection);
|
||||
}
|
||||
finally {
|
||||
mySkipUpdate = false;
|
||||
@@ -349,21 +276,21 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
|
||||
private void fillProperties() {
|
||||
myProperties = new ArrayList<Property>();
|
||||
int size = myComponents.size();
|
||||
int size = myContainers.size();
|
||||
|
||||
if (size > 0) {
|
||||
fillProperties(myComponents.get(0), myProperties);
|
||||
fillProperties(myContainers.get(0), myProperties);
|
||||
|
||||
if (size > 1) {
|
||||
for (Iterator<Property> I = myProperties.iterator(); I.hasNext(); ) {
|
||||
if (!I.next().availableFor(myComponents)) {
|
||||
if (!I.next().availableFor(myContainers)) {
|
||||
I.remove();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < size; i++) {
|
||||
List<Property> properties = new ArrayList<Property>();
|
||||
fillProperties(myComponents.get(i), properties);
|
||||
fillProperties(myContainers.get(i), properties);
|
||||
|
||||
for (Iterator<Property> I = myProperties.iterator(); I.hasNext(); ) {
|
||||
Property property = I.next();
|
||||
@@ -401,7 +328,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
}
|
||||
}
|
||||
|
||||
private void fillProperties(RadComponent component, List<Property> properties) {
|
||||
private void fillProperties(PropertiesContainer component, List<Property> properties) {
|
||||
for (Property property : component.getProperties()) {
|
||||
addProperty(property, properties);
|
||||
}
|
||||
@@ -503,8 +430,8 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RadComponent getCurrentComponent() {
|
||||
return myComponents.size() == 1 ? myComponents.get(0) : null;
|
||||
private PropertiesContainer getCurrentComponent() {
|
||||
return myContainers.size() == 1 ? myContainers.get(0) : null;
|
||||
}
|
||||
|
||||
private List<Property> getChildren(Property property) {
|
||||
@@ -523,7 +450,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
}
|
||||
|
||||
public boolean isDefault(Property property) throws Exception {
|
||||
for (RadComponent component : myComponents) {
|
||||
for (PropertiesContainer component : myContainers) {
|
||||
if (!property.isDefaultValue(component)) {
|
||||
return false;
|
||||
}
|
||||
@@ -533,14 +460,14 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
|
||||
@Nullable
|
||||
private Object getValue(Property property) throws Exception {
|
||||
int size = myComponents.size();
|
||||
int size = myContainers.size();
|
||||
if (size == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Object value = property.getValue(myComponents.get(0));
|
||||
Object value = property.getValue(myContainers.get(0));
|
||||
for (int i = 1; i < size; i++) {
|
||||
if (!Comparing.equal(value, property.getValue(myComponents.get(i)))) {
|
||||
if (!Comparing.equal(value, property.getValue(myContainers.get(i)))) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -608,7 +535,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
super.setValueAt(aValue, row, column);
|
||||
|
||||
if (property.needRefreshPropertyList()) {
|
||||
updateProperties();
|
||||
update();
|
||||
}
|
||||
|
||||
repaint();
|
||||
@@ -700,41 +627,47 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
boolean isSetValue = true;
|
||||
|
||||
if (isNewValue) {
|
||||
isSetValue = myDesigner.getToolProvider().execute(new ThrowableRunnable<Exception>() {
|
||||
isSetValue = doSetValue(new ThrowableRunnable<Exception>() {
|
||||
@Override
|
||||
public void run() throws Exception {
|
||||
for (RadComponent component : myComponents) {
|
||||
for (PropertiesContainer component : myContainers) {
|
||||
property.setValue(component, newValue);
|
||||
}
|
||||
}
|
||||
}, DesignerBundle.message("command.set.property.value"), false);
|
||||
});
|
||||
}
|
||||
|
||||
if (isSetValue) {
|
||||
if (property.needRefreshPropertyList()) {
|
||||
updateProperties();
|
||||
update();
|
||||
}
|
||||
else if (myPropertyTablePanel != null) {
|
||||
myPropertyTablePanel.updateActions();
|
||||
else {
|
||||
myModel.fireTableRowsUpdated(row, row);
|
||||
}
|
||||
}
|
||||
|
||||
return isSetValue;
|
||||
}
|
||||
|
||||
protected abstract boolean doSetValue(ThrowableRunnable<Exception> runnable);
|
||||
|
||||
private static void showInvalidInput(Exception e) {
|
||||
Throwable cause = e.getCause();
|
||||
String message = cause == null ? e.getMessage() : cause.getMessage();
|
||||
|
||||
if (message == null || message.length() == 0) {
|
||||
message = DesignerBundle.message("designer.properties.no_message.error");
|
||||
message = "No message";
|
||||
}
|
||||
|
||||
Messages.showMessageDialog(DesignerBundle.message("designer.properties.setting.error", message),
|
||||
DesignerBundle.message("designer.properties.invalid_input"),
|
||||
Messages.showMessageDialog(formatErrorGettingValueMesage(message),
|
||||
"Invalid Input",
|
||||
Messages.getErrorIcon());
|
||||
}
|
||||
|
||||
private static String formatErrorGettingValueMesage(String message) {
|
||||
return MessageFormat.format("Error setting value: {0}", message);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
@@ -893,8 +826,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
}
|
||||
|
||||
private class PropertyTableModel extends AbstractTableModel {
|
||||
private final String[] myColumnNames =
|
||||
{DesignerBundle.message("designer.properties.column1"), DesignerBundle.message("designer.properties.column2")};
|
||||
private final String[] myColumnNames = {"Property", "Value"};
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
@@ -974,7 +906,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
try {
|
||||
JComponent component = myEditor.getComponent(myDesigner.getRootComponent(), getCurrentComponent(), getValue((Property)value), null);
|
||||
JComponent component = myEditor.getComponent(getCurrentComponent(), getPropertyContext() , getValue((Property)value), null);
|
||||
|
||||
if (component instanceof JComboBox) {
|
||||
component.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
|
||||
@@ -990,7 +922,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
LOG.debug(e);
|
||||
SimpleColoredComponent errComponent = new SimpleColoredComponent();
|
||||
errComponent
|
||||
.append(DesignerBundle.message("designer.properties.getting.error", e.getMessage()), SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
.append(MessageFormat.format("Error getting value: {0}", e.getMessage()), SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
return errComponent;
|
||||
}
|
||||
}
|
||||
@@ -1017,6 +949,9 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract TextAttributesKey getErrorAttributes(@NotNull HighlightSeverity severity);
|
||||
|
||||
private class PropertyCellRenderer implements TableCellRenderer {
|
||||
private final Map<HighlightSeverity, SimpleTextAttributes> myRegularAttributes = new HashMap<HighlightSeverity, SimpleTextAttributes>();
|
||||
private final Map<HighlightSeverity, SimpleTextAttributes> myBoldAttributes = new HashMap<HighlightSeverity, SimpleTextAttributes>();
|
||||
@@ -1106,8 +1041,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
SimpleTextAttributes errorAttributes = cache.get(severity);
|
||||
|
||||
if (errorAttributes == null) {
|
||||
TextAttributesKey attributesKey =
|
||||
SeverityRegistrar.getInstance(myDesigner.getProject()).getHighlightInfoTypeBySeverity(severity).getAttributesKey();
|
||||
TextAttributesKey attributesKey = getErrorAttributes(severity);
|
||||
TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey);
|
||||
|
||||
if (property.isImportant()) {
|
||||
@@ -1168,7 +1102,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
else {
|
||||
try {
|
||||
PropertyRenderer renderer = property.getRenderer();
|
||||
JComponent component = renderer.getComponent(getCurrentComponent(), getValue(property), selected, hasFocus);
|
||||
JComponent component = renderer.getComponent(getCurrentComponent(), getPropertyContext(), getValue(property), selected, hasFocus);
|
||||
|
||||
if (!selected) {
|
||||
component.setBackground(background);
|
||||
@@ -1185,8 +1119,7 @@ public final class PropertyTable extends JBTable implements DataProvider, Compon
|
||||
catch (Throwable e) {
|
||||
LOG.debug(e);
|
||||
myErrorRenderer.clear();
|
||||
myErrorRenderer
|
||||
.append(DesignerBundle.message("designer.properties.getting.error", e.getMessage()), SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
myErrorRenderer.append(formatErrorGettingValueMesage(e.getMessage()), SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
return myErrorRenderer;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -20,10 +20,10 @@ import com.intellij.designer.componentTree.AttributeWrapper;
|
||||
import com.intellij.designer.componentTree.TreeComponentDecorator;
|
||||
import com.intellij.designer.model.IComponentDecorator;
|
||||
import com.intellij.designer.model.MetaModel;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.palette.DefaultPaletteItem;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
@@ -102,7 +102,7 @@ public final class AndroidTreeDecorator implements TreeComponentDecorator {
|
||||
component.getMetaModel().getTarget() +
|
||||
" without properties");
|
||||
}
|
||||
Property property = PropertyTable.findProperty(component.getProperties(), name);
|
||||
Property property = RadPropertyTable.findProperty(component.getProperties(), name);
|
||||
if (property != null) {
|
||||
try {
|
||||
return String.valueOf(property.getValue(component));
|
||||
|
||||
+3
-7
@@ -25,11 +25,7 @@ import com.intellij.codeInspection.SuppressIntentionAction;
|
||||
import com.intellij.codeInspection.ex.DisableInspectionToolAction;
|
||||
import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction;
|
||||
import com.intellij.designer.inspection.AbstractQuickFixManager;
|
||||
import com.intellij.designer.inspection.ErrorInfo;
|
||||
import com.intellij.designer.inspection.QuickFix;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.RadComponentVisitor;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.*;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -48,7 +44,7 @@ import java.util.List;
|
||||
*/
|
||||
public final class ErrorAnalyzer {
|
||||
public static void load(final Project project, final XmlFile xmlFile, RadComponent rootComponent, ProgressIndicator progress) {
|
||||
ErrorInfo.clear(rootComponent);
|
||||
RadComponent.clearErrors(rootComponent);
|
||||
|
||||
AndroidLintExternalAnnotator annotator = new AndroidLintExternalAnnotator();
|
||||
State state = annotator.collectionInformation(xmlFile);
|
||||
@@ -80,7 +76,7 @@ public final class ErrorAnalyzer {
|
||||
if (startElement != null && endElement != null && !inspection.isSuppressedFor(startElement)) {
|
||||
Pair<RadComponent, String> componentInfo = findComponent(rootComponent, startElement);
|
||||
ErrorInfo errorInfo = new ErrorInfo(message, componentInfo.second, pair.getSecond());
|
||||
ErrorInfo.add(componentInfo.first, errorInfo);
|
||||
RadComponent.addError(componentInfo.first, errorInfo);
|
||||
|
||||
Icon icon =
|
||||
errorInfo.getLevel() == HighlightDisplayLevel.ERROR ? AbstractQuickFixManager.ICON_ERROR : AbstractQuickFixManager.ICON;
|
||||
|
||||
+11
-15
@@ -18,12 +18,8 @@ package com.intellij.android.designer.model;
|
||||
import com.android.ide.common.rendering.api.ViewInfo;
|
||||
import com.android.sdklib.IAndroidTarget;
|
||||
import com.intellij.android.designer.propertyTable.*;
|
||||
import com.intellij.designer.model.MetaManager;
|
||||
import com.intellij.designer.model.MetaModel;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.RadLayout;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.model.*;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.android.dom.attrs.AttributeDefinition;
|
||||
import org.jetbrains.android.dom.attrs.AttributeDefinitions;
|
||||
@@ -205,7 +201,7 @@ public class PropertyParser {
|
||||
|
||||
List<Property> superProperties = loadWidgetProperties(superComponentClass, superModel);
|
||||
for (Property superProperty : superProperties) {
|
||||
if (PropertyTable.findProperty(properties, superProperty) == -1) {
|
||||
if (RadPropertyTable.findProperty(properties, superProperty) == -1) {
|
||||
if (model == null) {
|
||||
properties.add(superProperty);
|
||||
}
|
||||
@@ -226,11 +222,11 @@ public class PropertyParser {
|
||||
|
||||
if (model != null) {
|
||||
for (String topName : model.getTopProperties()) {
|
||||
PropertyTable.moveProperty(properties, topName, properties, 0);
|
||||
RadPropertyTable.moveProperty(properties, topName, properties, 0);
|
||||
}
|
||||
}
|
||||
|
||||
PropertyTable.moveProperty(properties, "style", properties, 0);
|
||||
RadPropertyTable.moveProperty(properties, "style", properties, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +313,7 @@ public class PropertyParser {
|
||||
|
||||
if (++index < components.length) {
|
||||
for (Property property : loadLayoutProperties(components, index, models)) {
|
||||
if (PropertyTable.findProperty(properties, property) == -1) {
|
||||
if (RadPropertyTable.findProperty(properties, property) == -1) {
|
||||
if (model == null) {
|
||||
properties.add(property);
|
||||
}
|
||||
@@ -337,10 +333,10 @@ public class PropertyParser {
|
||||
}
|
||||
});
|
||||
|
||||
PropertyTable.moveProperty(properties, "layout:margin", properties, 0);
|
||||
PropertyTable.moveProperty(properties, "layout:gravity", properties, 0);
|
||||
PropertyTable.moveProperty(properties, "layout:height", properties, 0);
|
||||
PropertyTable.moveProperty(properties, "layout:width", properties, 0);
|
||||
RadPropertyTable.moveProperty(properties, "layout:margin", properties, 0);
|
||||
RadPropertyTable.moveProperty(properties, "layout:gravity", properties, 0);
|
||||
RadPropertyTable.moveProperty(properties, "layout:height", properties, 0);
|
||||
RadPropertyTable.moveProperty(properties, "layout:width", properties, 0);
|
||||
}
|
||||
|
||||
if (model != null) {
|
||||
@@ -357,7 +353,7 @@ public class PropertyParser {
|
||||
public static void moveProperties(List<Property> source, Property destination, String... names) {
|
||||
List<Property> children = destination.getChildren(null);
|
||||
for (int i = 0; i < names.length; i += 2) {
|
||||
Property property = PropertyTable.extractProperty(source, names[i]);
|
||||
Property property = RadPropertyTable.extractProperty(source, names[i]);
|
||||
if (property != null) {
|
||||
children.add(property.createForNewPresentation(destination, names[i + 1]));
|
||||
}
|
||||
|
||||
+4
-8
@@ -19,12 +19,8 @@ import com.intellij.android.designer.propertyTable.CustomViewProperty;
|
||||
import com.intellij.android.designer.propertyTable.editors.ChooseClassDialog;
|
||||
import com.intellij.designer.ModuleProvider;
|
||||
import com.intellij.designer.componentTree.AttributeWrapper;
|
||||
import com.intellij.designer.model.IComponentDecorator;
|
||||
import com.intellij.designer.model.MetaManager;
|
||||
import com.intellij.designer.model.MetaModel;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.model.*;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
@@ -137,13 +133,13 @@ public class RadCustomViewComponent extends RadViewComponent implements IConfigu
|
||||
properties.add(CLASS_PROPERTY);
|
||||
|
||||
for (String name : metaModel.getInplaceProperties()) {
|
||||
Property property = PropertyTable.findProperty(allProperties, name);
|
||||
Property property = RadPropertyTable.findProperty(allProperties, name);
|
||||
if (property != null) {
|
||||
properties.add(property);
|
||||
}
|
||||
}
|
||||
|
||||
properties.add(PropertyTable.findProperty(allProperties, "id"));
|
||||
properties.add(RadPropertyTable.findProperty(allProperties, "id"));
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import com.intellij.android.designer.propertyTable.JavadocParser;
|
||||
import com.intellij.android.designer.propertyTable.editors.ChooseClassDialog;
|
||||
import com.intellij.android.designer.propertyTable.editors.ResourceEditor;
|
||||
import com.intellij.designer.ModuleProvider;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.editors.TextEditor;
|
||||
import org.jetbrains.android.dom.attrs.AttributeFormat;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
+1
-1
@@ -22,8 +22,8 @@ import com.intellij.android.designer.propertyTable.IdProperty;
|
||||
import com.intellij.android.designer.propertyTable.IncludeLayoutProperty;
|
||||
import com.intellij.android.designer.propertyTable.editors.ResourceDialog;
|
||||
import com.intellij.designer.ModuleProvider;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.android.designer.model;
|
||||
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.Property;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
+3
-7
@@ -17,12 +17,8 @@ package com.intellij.android.designer.model;
|
||||
|
||||
import com.android.ide.common.rendering.api.ViewInfo;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.intellij.designer.model.EmptyXmlTag;
|
||||
import com.intellij.designer.model.MetaModel;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.RadVisualComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.model.*;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
@@ -210,7 +206,7 @@ public class RadViewComponent extends RadVisualComponent {
|
||||
@Override
|
||||
public List<Property> getInplaceProperties() throws Exception {
|
||||
List<Property> properties = super.getInplaceProperties();
|
||||
Property idProperty = PropertyTable.findProperty(myProperties, "id");
|
||||
Property idProperty = RadPropertyTable.findProperty(myProperties, "id");
|
||||
if (idProperty != null) {
|
||||
properties.add(idProperty);
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,8 +19,9 @@ import com.android.sdklib.SdkConstants;
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.propertyTable.IXmlAttributeLocator;
|
||||
import com.intellij.android.designer.propertyTable.JavadocParser;
|
||||
import com.intellij.android.designer.propertyTable.editors.StringsComboEditor;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.renderers.LabelPropertyRenderer;
|
||||
@@ -28,7 +29,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.psi.xml.XmlAttribute;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.android.designer.propertyTable.JavadocParser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
package com.intellij.android.designer.model.layout.relative;
|
||||
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.Property;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
||||
+6
-6
@@ -24,14 +24,14 @@ import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.model.RadViewLayoutWithData;
|
||||
import com.intellij.android.designer.model.layout.actions.AllGravityAction;
|
||||
import com.intellij.android.designer.propertyTable.AttributeProperty;
|
||||
import com.intellij.android.designer.propertyTable.RelativeIdAttributeProperty;
|
||||
import com.intellij.android.designer.propertyTable.JavadocParser;
|
||||
import com.intellij.android.designer.propertyTable.RelativeIdAttributeProperty;
|
||||
import com.intellij.designer.componentTree.TreeEditOperation;
|
||||
import com.intellij.designer.designSurface.*;
|
||||
import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -89,9 +89,9 @@ public class RadRelativeLayout extends RadViewLayoutWithData implements ILayoutD
|
||||
"layout:alignWithParentIfMissing", "missing");
|
||||
properties.add(alignParent);
|
||||
|
||||
PropertyTable.extractProperty(properties, "layout:centerInParent");
|
||||
PropertyTable.extractProperty(properties, "layout:centerHorizontal");
|
||||
PropertyTable.extractProperty(properties, "layout:centerVertical");
|
||||
RadPropertyTable.extractProperty(properties, "layout:centerInParent");
|
||||
RadPropertyTable.extractProperty(properties, "layout:centerHorizontal");
|
||||
RadPropertyTable.extractProperty(properties, "layout:centerVertical");
|
||||
properties.add(new CenterProperty());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.propertyTable.editors.ResourceEditor;
|
||||
import com.intellij.android.designer.propertyTable.editors.StringsComboEditor;
|
||||
import com.intellij.android.designer.propertyTable.renderers.ResourceRenderer;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.editors.TextEditor;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
package com.intellij.android.designer.propertyTable;
|
||||
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.android.dom.attrs.AttributeDefinition;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+1
-1
@@ -17,8 +17,8 @@ package com.intellij.android.designer.propertyTable;
|
||||
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.designer.model.MetaModel;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.IPropertyDecorator;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.renderers.LabelPropertyRenderer;
|
||||
|
||||
+3
-3
@@ -19,8 +19,8 @@ import com.intellij.android.designer.model.PropertyParser;
|
||||
import com.intellij.android.designer.model.RadCustomViewComponent;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.propertyTable.editors.ResourceEditor;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.renderers.LabelPropertyRenderer;
|
||||
@@ -103,7 +103,7 @@ public class CustomViewProperty extends Property<RadCustomViewComponent> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean availableFor(List<RadComponent> components) {
|
||||
public boolean availableFor(List<PropertiesContainer> components) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -18,8 +18,8 @@ package com.intellij.android.designer.propertyTable;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.designer.model.MetaModel;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.IPropertyDecorator;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.editors.BooleanEditor;
|
||||
|
||||
+3
-3
@@ -18,8 +18,8 @@ package com.intellij.android.designer.propertyTable;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.renderers.LabelPropertyRenderer;
|
||||
@@ -87,7 +87,7 @@ public class FragmentProperty extends Property<RadViewComponent> implements IXml
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean availableFor(List<RadComponent> components) {
|
||||
public boolean availableFor(List<PropertiesContainer> components) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package com.intellij.android.designer.propertyTable;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.propertyTable.editors.StringsComboEditor;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.renderers.LabelPropertyRenderer;
|
||||
|
||||
+3
-3
@@ -17,8 +17,8 @@ package com.intellij.android.designer.propertyTable;
|
||||
|
||||
import com.intellij.android.designer.model.IdManager;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.android.dom.attrs.AttributeDefinition;
|
||||
@@ -83,7 +83,7 @@ public class IdProperty extends AttributeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean availableFor(List<RadComponent> components) {
|
||||
public boolean availableFor(List<PropertiesContainer> components) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -20,8 +20,8 @@ import com.intellij.android.designer.model.RadIncludeLayout;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.propertyTable.editors.ResourceEditor;
|
||||
import com.intellij.android.designer.propertyTable.renderers.ResourceRenderer;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -78,7 +78,7 @@ public class IncludeLayoutProperty extends Property<RadViewComponent> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean availableFor(List<RadComponent> components) {
|
||||
public boolean availableFor(List<PropertiesContainer> components) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.model.layout.relative.RadRelativeLayoutComponent;
|
||||
import com.intellij.android.designer.propertyTable.editors.ComponentEditor;
|
||||
import com.intellij.android.designer.propertyTable.renderers.ComponentRenderer;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
@@ -76,7 +77,7 @@ public class RelativeIdAttributeProperty extends AttributeProperty {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean availableFor(List<RadComponent> components) {
|
||||
public boolean availableFor(List<PropertiesContainer> components) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -19,7 +19,7 @@ import com.android.resources.ResourceType;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.propertyTable.editors.ResourceEditor;
|
||||
import com.intellij.android.designer.propertyTable.renderers.ResourceRenderer;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
|
||||
+9
-6
@@ -17,6 +17,8 @@ package com.intellij.android.designer.propertyTable.editors;
|
||||
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.propertyTable.renderers.ComponentRenderer;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.InplaceContext;
|
||||
import com.intellij.designer.propertyTable.editors.ComboEditor;
|
||||
@@ -57,17 +59,18 @@ public abstract class ComponentEditor extends ComboEditor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent(@NotNull RadComponent rootComponent,
|
||||
@Nullable RadComponent component,
|
||||
Object value,
|
||||
public JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
@Nullable PropertyContext context, Object value,
|
||||
@Nullable InplaceContext inplaceContext) {
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||
myCombo.setModel(model);
|
||||
model.addElement(StringsComboEditor.UNSET);
|
||||
for (RadComponent childComponent : getComponents(component)) {
|
||||
model.addElement(childComponent);
|
||||
if (container instanceof RadComponent) {
|
||||
for (RadComponent childComponent : getComponents((RadComponent)container)) {
|
||||
model.addElement(childComponent);
|
||||
}
|
||||
myCombo.setSelectedItem(myRenderer.getComponentById((RadComponent)container, (String)value));
|
||||
}
|
||||
myCombo.setSelectedItem(myRenderer.getComponentById(component, (String)value));
|
||||
myCombo.setBorder(inplaceContext == null ? null : myComboBorder);
|
||||
return myCombo;
|
||||
}
|
||||
|
||||
+8
-4
@@ -20,7 +20,10 @@ import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.android.designer.model.RadViewComponent;
|
||||
import com.intellij.android.designer.propertyTable.renderers.ResourceRenderer;
|
||||
import com.intellij.designer.ModuleProvider;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.RadPropertyContext;
|
||||
import com.intellij.designer.propertyTable.InplaceContext;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.editors.ComboEditor;
|
||||
@@ -207,12 +210,13 @@ public class ResourceEditor extends PropertyEditor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent(@NotNull RadComponent rootComponent,
|
||||
@Nullable RadComponent component,
|
||||
public JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
@Nullable PropertyContext context,
|
||||
Object object,
|
||||
@Nullable InplaceContext inplaceContext) {
|
||||
myRootComponent = rootComponent;
|
||||
myComponent = component;
|
||||
myComponent = container instanceof RadComponent ? (RadComponent)container : null;
|
||||
myRootComponent = context instanceof RadPropertyContext ? ((RadPropertyContext)context).getRootComponent() : null;
|
||||
|
||||
String value = (String)object;
|
||||
JTextField text = getComboText();
|
||||
|
||||
|
||||
+4
-4
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package com.intellij.android.designer.propertyTable.editors;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.propertyTable.InplaceContext;
|
||||
import com.intellij.designer.propertyTable.editors.ComboEditor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -54,9 +55,8 @@ public class StringsComboEditor extends ComboEditor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent(@NotNull RadComponent rootComponent,
|
||||
@Nullable RadComponent component,
|
||||
Object value,
|
||||
public JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
@Nullable PropertyContext context, Object value,
|
||||
@Nullable InplaceContext inplaceContext) {
|
||||
myCombo.setSelectedItem(value);
|
||||
myCombo.setBorder(inplaceContext == null ? null : myComboBorder);
|
||||
|
||||
+11
-5
@@ -18,9 +18,11 @@ package com.intellij.android.designer.propertyTable.renderers;
|
||||
import com.intellij.android.designer.propertyTable.editors.StringsComboEditor;
|
||||
import com.intellij.designer.componentTree.AttributeWrapper;
|
||||
import com.intellij.designer.componentTree.TreeComponentDecorator;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
@@ -36,7 +38,7 @@ public abstract class ComponentRenderer extends ColoredListCellRenderer implemen
|
||||
@Override
|
||||
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
clear();
|
||||
PropertyTable.updateRenderer(this, selected);
|
||||
RadPropertyTable.updateRenderer(this, selected);
|
||||
|
||||
if (value == StringsComboEditor.UNSET) {
|
||||
append(StringsComboEditor.UNSET);
|
||||
@@ -54,12 +56,16 @@ public abstract class ComponentRenderer extends ColoredListCellRenderer implemen
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent(@Nullable RadComponent component, @Nullable Object object, boolean selected, boolean hasFocus) {
|
||||
public JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
PropertyContext context,
|
||||
@Nullable Object object,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
clear();
|
||||
PropertyTable.updateRenderer(this, selected);
|
||||
RadPropertyTable.updateRenderer(this, selected);
|
||||
|
||||
String value = (String)object;
|
||||
RadComponent idComponent = getComponentById(component, value);
|
||||
RadComponent idComponent = container instanceof RadComponent ? getComponentById((RadComponent)container, value) : null;
|
||||
|
||||
if (idComponent != null) {
|
||||
renderComponent(idComponent);
|
||||
|
||||
+12
-6
@@ -17,9 +17,11 @@ package com.intellij.android.designer.propertyTable.renderers;
|
||||
|
||||
import com.intellij.android.designer.model.ModelParser;
|
||||
import com.intellij.designer.ModuleProvider;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.designer.propertyTable.renderers.BooleanRenderer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
@@ -36,8 +38,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
@@ -63,16 +65,20 @@ public class ResourceRenderer implements PropertyRenderer {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent(@Nullable RadComponent component, @Nullable Object object, boolean selected, boolean hasFocus) {
|
||||
public JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
PropertyContext context,
|
||||
@Nullable Object object,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
String value = (String)object;
|
||||
|
||||
if (myBooleanRenderer != null && (StringUtil.isEmpty(value) || "false".equals(value) || "true".equals(value))) {
|
||||
return myBooleanRenderer.getComponent(component, "true".equals(value), selected, hasFocus);
|
||||
return myBooleanRenderer.getComponent(container, context, "true".equals(value), selected, hasFocus);
|
||||
}
|
||||
|
||||
myColoredComponent.clear();
|
||||
PropertyTable.updateRenderer(myColoredComponent, selected);
|
||||
formatValue(component, value);
|
||||
RadPropertyTable.updateRenderer(myColoredComponent, selected);
|
||||
if (container instanceof RadComponent) formatValue((RadComponent)container, value);
|
||||
|
||||
return myColoredComponent;
|
||||
}
|
||||
|
||||
+3
-3
@@ -18,7 +18,7 @@ package com.intellij.designer;
|
||||
import com.intellij.designer.componentTree.ComponentTree;
|
||||
import com.intellij.designer.componentTree.ComponentTreeBuilder;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.propertyTable.PropertyTablePanel;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTablePanel;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -52,7 +52,7 @@ public final class DesignerToolWindowManager extends AbstractToolWindowManager {
|
||||
private Splitter myToolWindowPanel;
|
||||
private ComponentTree myComponentTree;
|
||||
private ComponentTreeBuilder myTreeBuilder;
|
||||
private PropertyTablePanel myPropertyTablePanel;
|
||||
private RadPropertyTablePanel myPropertyTablePanel;
|
||||
|
||||
public DesignerToolWindowManager(Project project, FileEditorManager fileEditorManager) {
|
||||
super(project, fileEditorManager);
|
||||
@@ -129,7 +129,7 @@ public final class DesignerToolWindowManager extends AbstractToolWindowManager {
|
||||
treeScrollPane.setPreferredSize(new Dimension(250, -1));
|
||||
myComponentTree.initQuickFixManager(treeScrollPane.getViewport());
|
||||
|
||||
myPropertyTablePanel = new PropertyTablePanel();
|
||||
myPropertyTablePanel = new RadPropertyTablePanel(myProject);
|
||||
|
||||
myToolWindowPanel = new Splitter(true, 0.42f);
|
||||
myToolWindowPanel.setFirstComponent(treeScrollPane);
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ import com.intellij.designer.actions.StartInplaceEditing;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.designSurface.FeedbackTreeLayer;
|
||||
import com.intellij.designer.inspection.ErrorInfo;
|
||||
import com.intellij.designer.model.ErrorInfo;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
@@ -151,7 +151,7 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
if (path != null) {
|
||||
RadComponent component = extractComponent(path.getLastPathComponent());
|
||||
if (component != null) {
|
||||
List<ErrorInfo> errorInfos = ErrorInfo.get(component);
|
||||
List<ErrorInfo> errorInfos = RadComponent.getError(component);
|
||||
if (!errorInfos.isEmpty()) {
|
||||
return errorInfos.get(0).getName();
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
private static HighlightDisplayLevel getHighlightDisplayLevel(Project project, RadComponent component) {
|
||||
HighlightDisplayLevel displayLevel = null;
|
||||
SeverityRegistrar severityRegistrar = SeverityRegistrar.getInstance(project);
|
||||
for (ErrorInfo errorInfo : ErrorInfo.get(component)) {
|
||||
for (ErrorInfo errorInfo : RadComponent.getError(component)) {
|
||||
if (displayLevel == null || severityRegistrar.compare(errorInfo.getLevel().getSeverity(), displayLevel.getSeverity()) > 0) {
|
||||
displayLevel = errorInfo.getLevel();
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ package com.intellij.designer.componentTree;
|
||||
import com.intellij.designer.designSurface.ComponentSelectionListener;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.inspection.AbstractQuickFixManager;
|
||||
import com.intellij.designer.inspection.ErrorInfo;
|
||||
import com.intellij.designer.model.ErrorInfo;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class QuickFixManager extends AbstractQuickFixManager implements Co
|
||||
protected List<ErrorInfo> getErrorInfos() {
|
||||
List<RadComponent> selection = myArea.getSelection();
|
||||
if (selection.size() == 1) {
|
||||
return ErrorInfo.get(selection.get(0));
|
||||
return RadComponent.getError(selection.get(0));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
+3
-5
@@ -22,14 +22,11 @@ import com.intellij.designer.ModuleProvider;
|
||||
import com.intellij.designer.actions.DesignerActionPanel;
|
||||
import com.intellij.designer.componentTree.TreeComponentDecorator;
|
||||
import com.intellij.designer.designSurface.tools.*;
|
||||
import com.intellij.designer.model.FindComponentVisitor;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.WrapInProvider;
|
||||
import com.intellij.designer.model.*;
|
||||
import com.intellij.designer.palette.PaletteGroup;
|
||||
import com.intellij.designer.palette.PaletteItem;
|
||||
import com.intellij.designer.palette.PaletteToolWindowManager;
|
||||
import com.intellij.designer.propertyTable.InplaceContext;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.diagnostic.LogMessageEx;
|
||||
import com.intellij.diagnostic.errordialog.Attachment;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
@@ -72,7 +69,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public abstract class DesignerEditorPanel extends JPanel implements DataProvider, ModuleProvider {
|
||||
public abstract class DesignerEditorPanel extends JPanel implements DataProvider, ModuleProvider, RadPropertyContext {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.designer.designSurface.DesignerEditorPanel");
|
||||
|
||||
protected static final Integer LAYER_COMPONENT = JLayeredPane.DEFAULT_LAYER;
|
||||
@@ -744,6 +741,7 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RadComponent getRootComponent() {
|
||||
return myRootComponent;
|
||||
}
|
||||
|
||||
+2
-3
@@ -17,9 +17,9 @@ package com.intellij.designer.designSurface;
|
||||
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.designSurface.feedbacks.LineMarginBorder;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.propertyTable.InplaceContext;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.designer.propertyTable.PropertyEditorListener;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
@@ -151,8 +151,7 @@ public class InplaceEditingLayer extends JComponent {
|
||||
PropertyEditor editor = property.getEditor();
|
||||
myEditors.add(editor);
|
||||
|
||||
JComponent component =
|
||||
editor.getComponent(myRadComponent.getRoot(), myRadComponent, property.getValue(myRadComponent), inplaceContext);
|
||||
JComponent component = editor.getComponent(myRadComponent, myDesigner, property.getValue(myRadComponent), inplaceContext);
|
||||
|
||||
myInplaceComponent.add(component,
|
||||
new GridConstraints(row++, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
package com.intellij.designer.designSurface;
|
||||
|
||||
import com.intellij.designer.inspection.AbstractQuickFixManager;
|
||||
import com.intellij.designer.inspection.ErrorInfo;
|
||||
import com.intellij.designer.model.ErrorInfo;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -45,7 +45,7 @@ public final class QuickFixManager extends AbstractQuickFixManager implements Co
|
||||
protected List<ErrorInfo> getErrorInfos() {
|
||||
List<RadComponent> selection = myDesigner.getSurfaceArea().getSelection();
|
||||
if (selection.size() == 1) {
|
||||
return ErrorInfo.get(selection.get(0));
|
||||
return RadComponent.getError(selection.get(0));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
+2
@@ -18,6 +18,8 @@ package com.intellij.designer.inspection;
|
||||
import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.model.ErrorInfo;
|
||||
import com.intellij.designer.model.QuickFix;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.intellij.designer.model;
|
||||
|
||||
import com.intellij.designer.palette.DefaultPaletteItem;
|
||||
import com.intellij.designer.propertyTable.IPropertyDecorator;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
+35
-8
@@ -21,8 +21,7 @@ import com.intellij.designer.designSurface.OperationContext;
|
||||
import com.intellij.designer.designSurface.StaticDecorator;
|
||||
import com.intellij.designer.designSurface.tools.DragTracker;
|
||||
import com.intellij.designer.designSurface.tools.InputTool;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -36,12 +35,19 @@ import java.util.List;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public abstract class RadComponent {
|
||||
public abstract class RadComponent extends PropertiesContainer {
|
||||
private static final String ERROR_KEY = "Inspection.Errors";
|
||||
|
||||
protected MetaModel myMetaModel;
|
||||
private RadComponent myParent;
|
||||
private RadLayout myLayout;
|
||||
private final Map<Object, Object> myClientProperties = new HashMap<Object, Object>();
|
||||
|
||||
@Override
|
||||
public List<Property> getProperties() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MetaModel
|
||||
@@ -185,17 +191,13 @@ public abstract class RadComponent {
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public List<Property> getProperties() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<Property> getInplaceProperties() throws Exception {
|
||||
List<Property> properties = new ArrayList<Property>();
|
||||
|
||||
if (myMetaModel != null) {
|
||||
List<Property> allProperties = getProperties();
|
||||
for (String name : myMetaModel.getInplaceProperties()) {
|
||||
Property property = PropertyTable.findProperty(allProperties, name);
|
||||
Property property = RadPropertyTable.findProperty(allProperties, name);
|
||||
if (property != null) {
|
||||
properties.add(property);
|
||||
}
|
||||
@@ -276,6 +278,31 @@ public abstract class RadComponent {
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public static List<ErrorInfo> getError(RadComponent component) {
|
||||
List<ErrorInfo> errorInfos = component.getClientProperty(ERROR_KEY);
|
||||
return errorInfos == null ? Collections.<ErrorInfo>emptyList() : errorInfos;
|
||||
}
|
||||
|
||||
public static void addError(RadComponent component, ErrorInfo errorInfo) {
|
||||
List<ErrorInfo> errorInfos = component.getClientProperty(ERROR_KEY);
|
||||
if (errorInfos == null) {
|
||||
errorInfos = new ArrayList<ErrorInfo>();
|
||||
component.setClientProperty(ERROR_KEY, errorInfos);
|
||||
}
|
||||
errorInfos.add(errorInfo);
|
||||
}
|
||||
|
||||
public static void clearErrors(RadComponent component) {
|
||||
component.accept(new RadComponentVisitor() {
|
||||
@Override
|
||||
public void endVisit(RadComponent component) {
|
||||
component.extractClientProperty(ERROR_KEY);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
||||
public static Set<RadComponent> getParents(List<RadComponent> components) {
|
||||
Set<RadComponent> parents = new HashSet<RadComponent>();
|
||||
for (RadComponent component : components) {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.designer.model;
|
||||
|
||||
import com.intellij.designer.designSurface.*;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.designer.model;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface RadPropertyContext extends PropertyContext {
|
||||
@Nullable
|
||||
RadComponent getRootComponent();
|
||||
}
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
package com.intellij.designer.propertyTable;
|
||||
|
||||
import com.intellij.designer.inspection.AbstractQuickFixManager;
|
||||
import com.intellij.designer.inspection.ErrorInfo;
|
||||
import com.intellij.designer.model.ErrorInfo;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -45,7 +45,7 @@ public final class QuickFixManager extends AbstractQuickFixManager implements Li
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<ErrorInfo> getErrorInfos() {
|
||||
PropertyTable component = (PropertyTable)myComponent;
|
||||
RadPropertyTable component = (RadPropertyTable)myComponent;
|
||||
|
||||
int selectedRow = component.getSelectedRow();
|
||||
if (selectedRow < 0 || selectedRow >= component.getRowCount()) {
|
||||
@@ -61,7 +61,7 @@ public final class QuickFixManager extends AbstractQuickFixManager implements Li
|
||||
|
||||
@Override
|
||||
protected Rectangle getErrorBounds() {
|
||||
PropertyTable component = (PropertyTable)myComponent;
|
||||
RadPropertyTable component = (RadPropertyTable)myComponent;
|
||||
|
||||
int selectedRow = component.getSelectedRow();
|
||||
if (selectedRow < 0 || selectedRow >= component.getRowCount()) {
|
||||
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.designer.propertyTable;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar;
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.designSurface.ComponentSelectionListener;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.model.ErrorInfo;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class RadPropertyTable extends PropertyTable implements DataProvider, ComponentSelectionListener {
|
||||
private final Project myProject;
|
||||
|
||||
private EditableArea myArea;
|
||||
private DesignerEditorPanel myDesigner;
|
||||
private QuickFixManager myQuickFixManager;
|
||||
private RadPropertyTablePanel myPropertyTablePanel;
|
||||
|
||||
|
||||
public RadPropertyTable(@NotNull Project project) {
|
||||
myProject = project;
|
||||
|
||||
getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (myDesigner != null) {
|
||||
myDesigner.setSelectionProperty(getSelectionProperty());
|
||||
}
|
||||
if (myPropertyTablePanel != null) {
|
||||
myPropertyTablePanel.updateActions();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getModel().addTableModelListener(new TableModelListener() {
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent e) {
|
||||
if (myPropertyTablePanel != null) {
|
||||
myPropertyTablePanel.updateActions();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void initQuickFixManager(JViewport viewPort) {
|
||||
myQuickFixManager = new QuickFixManager(this, viewPort);
|
||||
}
|
||||
|
||||
public void setPropertyTablePanel(RadPropertyTablePanel propertyTablePanel) {
|
||||
myPropertyTablePanel = propertyTablePanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
if (PlatformDataKeys.FILE_EDITOR.is(dataId) && myDesigner != null) {
|
||||
return myDesigner.getEditor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ErrorInfo> getErrors(@NotNull PropertiesContainer container) {
|
||||
return container instanceof RadComponent ? RadComponent.getError((RadComponent)container) : Collections.<ErrorInfo>emptyList();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected TextAttributesKey getErrorAttributes(@NotNull HighlightSeverity severity) {
|
||||
return SeverityRegistrar.getInstance(myProject).getHighlightInfoTypeBySeverity(severity).getAttributesKey();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setArea(@Nullable DesignerEditorPanel designer, @Nullable EditableArea area) {
|
||||
myDesigner = designer;
|
||||
myQuickFixManager.setDesigner(designer);
|
||||
|
||||
if (myArea != null) {
|
||||
myArea.removeSelectionListener(this);
|
||||
}
|
||||
|
||||
myArea = area;
|
||||
|
||||
if (myArea != null) {
|
||||
myArea.addSelectionListener(this);
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectionChanged(EditableArea area) {
|
||||
update();
|
||||
}
|
||||
|
||||
public void updateInspections() {
|
||||
myQuickFixManager.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
doUpdate(myArea.getSelection(), myDesigner.getSelectionProperty());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doRestoreDefault(ThrowableRunnable<Exception> runnable) {
|
||||
return myDesigner.getToolProvider().execute(runnable, DesignerBundle.message("designer.properties.restore_default"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doSetValue(ThrowableRunnable<Exception> runnable) {
|
||||
return myDesigner.getToolProvider().execute(runnable, DesignerBundle.message("command.set.property.value"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PropertyContext getPropertyContext() {
|
||||
return myDesigner;
|
||||
}
|
||||
}
|
||||
+7
-4
@@ -19,6 +19,7 @@ import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.propertyTable.actions.*;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.impl.ActionButton;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
@@ -32,11 +33,13 @@ import java.awt.*;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public final class PropertyTablePanel extends JPanel implements ListSelectionListener {
|
||||
private final PropertyTable myPropertyTable = new PropertyTable();
|
||||
public final class RadPropertyTablePanel extends JPanel implements ListSelectionListener {
|
||||
private final RadPropertyTable myPropertyTable;
|
||||
private final AnAction[] myActions;
|
||||
|
||||
public PropertyTablePanel() {
|
||||
public RadPropertyTablePanel(Project project) {
|
||||
myPropertyTable = new RadPropertyTable(project);
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
setBorder(IdeBorderFactory.createBorder(SideBorder.TOP));
|
||||
|
||||
@@ -86,7 +89,7 @@ public final class PropertyTablePanel extends JPanel implements ListSelectionLis
|
||||
myPropertyTable.setPropertyTablePanel(this);
|
||||
}
|
||||
|
||||
public PropertyTable getPropertyTable() {
|
||||
public RadPropertyTable getPropertyTable() {
|
||||
return myPropertyTable;
|
||||
}
|
||||
|
||||
+5
-5
@@ -16,8 +16,8 @@
|
||||
package com.intellij.designer.propertyTable.actions;
|
||||
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -27,9 +27,9 @@ import com.intellij.openapi.actionSystem.Presentation;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class RestoreDefault extends AnAction implements IPropertyTableAction {
|
||||
private final PropertyTable myTable;
|
||||
private final RadPropertyTable myTable;
|
||||
|
||||
public RestoreDefault(PropertyTable table) {
|
||||
public RestoreDefault(RadPropertyTable table) {
|
||||
myTable = table;
|
||||
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
@@ -49,7 +49,7 @@ public class RestoreDefault extends AnAction implements IPropertyTableAction {
|
||||
setEnabled(myTable, getTemplatePresentation());
|
||||
}
|
||||
|
||||
private static void setEnabled(PropertyTable table, Presentation presentation) {
|
||||
private static void setEnabled(RadPropertyTable table, Presentation presentation) {
|
||||
try {
|
||||
Property property = table.getSelectionProperty();
|
||||
presentation.setEnabled(property != null && !table.isDefault(property));
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
package com.intellij.designer.propertyTable.actions;
|
||||
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
@@ -25,9 +25,9 @@ import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class ShowColumns extends ToggleAction {
|
||||
private final PropertyTable myTable;
|
||||
private final RadPropertyTable myTable;
|
||||
|
||||
public ShowColumns(PropertyTable table) {
|
||||
public ShowColumns(RadPropertyTable table) {
|
||||
myTable = table;
|
||||
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
package com.intellij.designer.propertyTable.actions;
|
||||
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
@@ -31,9 +31,9 @@ import javax.swing.*;
|
||||
public class ShowExpert extends ToggleAction {
|
||||
private static final Icon ICON = IconLoader.getIcon("/com/intellij/designer/icons/filter.png");
|
||||
|
||||
private final PropertyTable myTable;
|
||||
private final RadPropertyTable myTable;
|
||||
|
||||
public ShowExpert(PropertyTable table) {
|
||||
public ShowExpert(RadPropertyTable table) {
|
||||
myTable = table;
|
||||
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
|
||||
+5
-5
@@ -18,8 +18,8 @@ package com.intellij.designer.propertyTable.actions;
|
||||
import com.intellij.codeInsight.documentation.DocumentationComponent;
|
||||
import com.intellij.codeInsight.documentation.DocumentationManager;
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.model.Property;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -41,9 +41,9 @@ import java.awt.*;
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class ShowJavadoc extends AnAction implements IPropertyTableAction {
|
||||
private final PropertyTable myTable;
|
||||
private final RadPropertyTable myTable;
|
||||
|
||||
public ShowJavadoc(PropertyTable table) {
|
||||
public ShowJavadoc(RadPropertyTable table) {
|
||||
myTable = table;
|
||||
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
@@ -63,7 +63,7 @@ public class ShowJavadoc extends AnAction implements IPropertyTableAction {
|
||||
setEnabled(myTable, getTemplatePresentation());
|
||||
}
|
||||
|
||||
private static void setEnabled(PropertyTable table, Presentation presentation) {
|
||||
private static void setEnabled(RadPropertyTable table, Presentation presentation) {
|
||||
Property property = table.getSelectionProperty();
|
||||
presentation.setEnabled(property != null && (property.getJavadocElement() != null || !StringUtil.isEmpty(property.getJavadocText())));
|
||||
}
|
||||
|
||||
+4
-4
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package com.intellij.designer.propertyTable.editors;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.propertyTable.InplaceContext;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -59,9 +60,8 @@ public class BooleanEditor extends PropertyEditor {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JComponent getComponent(@NotNull RadComponent rootComponent,
|
||||
@Nullable RadComponent component,
|
||||
Object value,
|
||||
public JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
@Nullable PropertyContext context, Object value,
|
||||
@Nullable InplaceContext inplaceContext) {
|
||||
try {
|
||||
myInsideChange = true;
|
||||
|
||||
+6
-6
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package com.intellij.designer.propertyTable.editors;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.propertyTable.InplaceContext;
|
||||
import com.intellij.designer.propertyTable.PropertyEditor;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
@@ -52,11 +53,10 @@ public class TextEditor extends PropertyEditor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JComponent getComponent(@NotNull RadComponent rootComponent,
|
||||
@Nullable RadComponent component,
|
||||
Object value,
|
||||
public JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
@Nullable PropertyContext context, Object value,
|
||||
@Nullable InplaceContext inplaceContext) {
|
||||
setEditorValue(component, value);
|
||||
setEditorValue(value);
|
||||
if (inplaceContext == null) {
|
||||
myTextField.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class TextEditor extends PropertyEditor {
|
||||
return myTextField.getText();
|
||||
}
|
||||
|
||||
protected void setEditorValue(@Nullable RadComponent component, Object value) {
|
||||
protected void setEditorValue(Object value) {
|
||||
myTextField.setText(value == null ? "" : value.toString());
|
||||
}
|
||||
|
||||
|
||||
+9
-4
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package com.intellij.designer.propertyTable.renderers;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -29,8 +30,12 @@ import javax.swing.*;
|
||||
*/
|
||||
public class BooleanRenderer extends JCheckBox implements PropertyRenderer {
|
||||
@NotNull
|
||||
public JComponent getComponent(@Nullable RadComponent component, @Nullable Object value, boolean selected, boolean hasFocus) {
|
||||
PropertyTable.updateRenderer(this, selected);
|
||||
public JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
PropertyContext context,
|
||||
@Nullable Object value,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
RadPropertyTable.updateRenderer(this, selected);
|
||||
setSelected(value != null && (Boolean)value);
|
||||
return this;
|
||||
}
|
||||
|
||||
+9
-4
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package com.intellij.designer.propertyTable.renderers;
|
||||
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.PropertiesContainer;
|
||||
import com.intellij.designer.model.PropertyContext;
|
||||
import com.intellij.designer.propertyTable.PropertyRenderer;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.RadPropertyTable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -41,13 +42,17 @@ public class LabelPropertyRenderer extends JLabel implements PropertyRenderer {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JComponent getComponent(@Nullable RadComponent component, @Nullable Object value, boolean selected, boolean hasFocus) {
|
||||
public JComponent getComponent(@Nullable PropertiesContainer container,
|
||||
PropertyContext context,
|
||||
@Nullable Object value,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
// Reset text and icon
|
||||
setText(null);
|
||||
setIcon(null);
|
||||
|
||||
// Background and foreground
|
||||
PropertyTable.updateRenderer(this, selected);
|
||||
RadPropertyTable.updateRenderer(this, selected);
|
||||
|
||||
if (value != null) {
|
||||
customize(value);
|
||||
|
||||
Reference in New Issue
Block a user