mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' into upsource-master
This commit is contained in:
+21
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -17,11 +17,9 @@ package com.intellij.ide.structureView.impl;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.impl.StructureViewWrapperImpl;
|
||||
import com.intellij.ide.structureView.StructureView;
|
||||
import com.intellij.ide.structureView.StructureViewBuilder;
|
||||
import com.intellij.ide.structureView.StructureViewFactoryEx;
|
||||
import com.intellij.ide.structureView.StructureViewWrapper;
|
||||
import com.intellij.ide.structureView.*;
|
||||
import com.intellij.ide.structureView.newStructureView.StructureViewComponent;
|
||||
import com.intellij.ide.util.treeView.smartTree.TreeElement;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageStructureViewBuilder;
|
||||
import com.intellij.lang.PsiStructureViewFactory;
|
||||
@@ -96,7 +94,7 @@ public abstract class TemplateLanguageStructureViewBuilder implements StructureV
|
||||
if (structureViewWrapper == null) return;
|
||||
|
||||
Language baseLanguage = provider.getTemplateDataLanguage();
|
||||
if (baseLanguage == myTemplateDataLanguage) {
|
||||
if (baseLanguage == myTemplateDataLanguage && isPsiValid()) {
|
||||
updateBaseLanguageView();
|
||||
}
|
||||
else {
|
||||
@@ -115,6 +113,23 @@ public abstract class TemplateLanguageStructureViewBuilder implements StructureV
|
||||
PsiManager.getInstance(myProject).addPsiTreeChangeListener(myPsiTreeChangeAdapter);
|
||||
}
|
||||
|
||||
private boolean isPsiValid() {
|
||||
final StructureViewComponent view = (StructureViewComponent)myBaseStructureViewDescriptor.structureView;
|
||||
if (view.isDisposed()) return false;
|
||||
|
||||
final Object root = view.getTreeStructure().getRootElement();
|
||||
if (root instanceof StructureViewComponent.StructureViewTreeElementWrapper) {
|
||||
final TreeElement value = ((StructureViewComponent.StructureViewTreeElementWrapper)root).getValue();
|
||||
if (value instanceof StructureViewTreeElement) {
|
||||
final Object psi = ((StructureViewTreeElement)value).getValue();
|
||||
if (psi instanceof PsiElement) {
|
||||
return ((PsiElement)psi).isValid();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TemplateLanguageFileViewProvider getViewProvider() {
|
||||
final FileViewProvider provider = PsiManager.getInstance(myProject).findViewProvider(myVirtualFile);
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.jetbrains.android.dom.attrs;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -27,7 +28,8 @@ public class AttributeDefinition {
|
||||
private final String myName;
|
||||
private final Set<AttributeFormat> myFormats = EnumSet.noneOf(AttributeFormat.class);
|
||||
private final List<String> myValues = new ArrayList<String>();
|
||||
|
||||
private String myDocValue;
|
||||
|
||||
public AttributeDefinition(@NotNull String name) {
|
||||
myName = name;
|
||||
}
|
||||
@@ -60,6 +62,20 @@ public class AttributeDefinition {
|
||||
return ArrayUtil.toStringArray(myValues);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDocValue() {
|
||||
return myDocValue;
|
||||
}
|
||||
|
||||
public void addDocValue(String docValue) {
|
||||
if (myDocValue == null) {
|
||||
myDocValue = docValue;
|
||||
}
|
||||
else {
|
||||
myDocValue += "\n" + docValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myName + " [" + myFormats + ']';
|
||||
|
||||
@@ -17,10 +17,14 @@ package org.jetbrains.android.dom.attrs;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.xml.XmlComment;
|
||||
import com.intellij.psi.xml.XmlDocument;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.xml.util.XmlUtil;
|
||||
import com.intellij.xml.util.documentation.XmlDocumentationProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -109,10 +113,21 @@ public class AttributeDefinitions {
|
||||
myAttrs.put(def.getName(), def);
|
||||
}
|
||||
def.addFormats(formats);
|
||||
parseDocComment(tag, def);
|
||||
parseAndAddValues(def, values);
|
||||
return def;
|
||||
}
|
||||
|
||||
private static void parseDocComment(XmlTag tag, AttributeDefinition def) {
|
||||
PsiElement comment = XmlDocumentationProvider.findPreviousComment(tag);
|
||||
if (comment != null) {
|
||||
String docValue = XmlUtil.getCommentText((XmlComment)comment);
|
||||
if (!StringUtil.isEmpty(docValue)) {
|
||||
def.addDocValue(docValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<AttributeFormat> parseAttrFormat(String formatString) {
|
||||
List<AttributeFormat> result = new ArrayList<AttributeFormat>();
|
||||
final String[] formats = formatString.split("\\|");
|
||||
|
||||
@@ -15,12 +15,13 @@
|
||||
</project-components>
|
||||
|
||||
<actions>
|
||||
<group id="UIDesigner.ComponentTreePopupMenu">
|
||||
<reference ref="$Cut"/>
|
||||
<reference ref="$Copy"/>
|
||||
<reference ref="$Paste"/>
|
||||
<separator/>
|
||||
<reference ref="$Delete"/>
|
||||
<group id="UIDesigner.PropertyTable">
|
||||
<action id="UIDesigner.PropertyTable.RestoreDefault"
|
||||
class="com.intellij.designer.propertyTable.actions.RestoreDefault"
|
||||
use-shortcut-of="$Delete"/>
|
||||
|
||||
<action id="UIDesigner.PropertyTable.ShowExpert"
|
||||
class="com.intellij.designer.propertyTable.actions.ShowExpert"/>
|
||||
</group>
|
||||
</actions>
|
||||
|
||||
|
||||
+5
@@ -19,6 +19,7 @@ import com.intellij.designer.componentTree.ComponentTree;
|
||||
import com.intellij.designer.componentTree.ComponentTreeBuilder;
|
||||
import com.intellij.designer.componentTree.TreeEditableArea;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.designer.propertyTable.PropertyTablePanel;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -155,6 +156,10 @@ public final class DesignerToolWindowManager implements ProjectComponent {
|
||||
return editors.length > 0 ? getDesigner(editors[0]) : null;
|
||||
}
|
||||
|
||||
public PropertyTable getPropertyTable() {
|
||||
return myPropertyTablePanel.getPropertyTable();
|
||||
}
|
||||
|
||||
private void bindToDesigner(final DesignerEditorPanel designer) {
|
||||
myWindowQueue.cancelAllUpdates();
|
||||
myWindowQueue.queue(new Update("update") {
|
||||
|
||||
+31
-5
@@ -25,6 +25,7 @@ import com.intellij.ui.SideBorder;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -32,11 +33,11 @@ import java.util.List;
|
||||
*/
|
||||
public class DesignerActionPanel implements DataProvider {
|
||||
public static final String TOOLBAR = "DesignerToolbar";
|
||||
public static final String POPUP = "DesignerPopup";
|
||||
|
||||
private final DefaultActionGroup myActionGroup = new DefaultActionGroup();
|
||||
private final DefaultActionGroup myStaticGroup = new DefaultActionGroup();
|
||||
private final DefaultActionGroup myDynamicGroup = new DefaultActionGroup();
|
||||
private final DefaultActionGroup myPopupGroup = new DefaultActionGroup();
|
||||
private JComponent myToolbar;
|
||||
private final DesignerEditorPanel myDesigner;
|
||||
private final CommonEditActionsProvider myCommonEditActionsProvider;
|
||||
@@ -50,14 +51,37 @@ public class DesignerActionPanel implements DataProvider {
|
||||
myActionGroup.add(myStaticGroup);
|
||||
myActionGroup.add(myDynamicGroup);
|
||||
|
||||
ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(TOOLBAR, myActionGroup, true);
|
||||
ActionManager actionManager = ActionManager.getInstance();
|
||||
ActionToolbar actionToolbar = actionManager.createActionToolbar(TOOLBAR, myActionGroup, true);
|
||||
actionToolbar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY);
|
||||
|
||||
myToolbar = actionToolbar.getComponent();
|
||||
myToolbar.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
|
||||
myToolbar.setVisible(false);
|
||||
|
||||
registerAction(new SelectAllAction(designer.getSurfaceArea()), "$SelectAll");
|
||||
AnAction selectParent = new AnAction("Select Parent", "Select Parent", null) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myDesigner.getToolProvider().processKeyEvent(new KeyEvent(myDesigner.getSurfaceArea().getNativeComponent(),
|
||||
KeyEvent.KEY_PRESSED, 0, 0,
|
||||
KeyEvent.VK_ESCAPE,
|
||||
(char)KeyEvent.VK_ESCAPE),
|
||||
myDesigner.getSurfaceArea());
|
||||
}
|
||||
};
|
||||
selectParent.registerCustomShortcutSet(KeyEvent.VK_ESCAPE, 0, null);
|
||||
|
||||
SelectAllAction selectAllAction = new SelectAllAction(designer.getSurfaceArea());
|
||||
registerAction(selectAllAction, "$SelectAll");
|
||||
|
||||
myPopupGroup.add(actionManager.getAction("$Cut"));
|
||||
myPopupGroup.add(actionManager.getAction("$Copy"));
|
||||
myPopupGroup.add(actionManager.getAction("$Paste"));
|
||||
myPopupGroup.addSeparator();
|
||||
myPopupGroup.add(actionManager.getAction("$Delete"));
|
||||
myPopupGroup.addSeparator();
|
||||
myPopupGroup.add(selectParent);
|
||||
myPopupGroup.add(selectAllAction);
|
||||
|
||||
designer.getSurfaceArea().addSelectionListener(new ComponentSelectionListener() {
|
||||
@Override
|
||||
@@ -65,8 +89,6 @@ public class DesignerActionPanel implements DataProvider {
|
||||
updateSelectionActions(area.getSelection());
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: support popup
|
||||
}
|
||||
|
||||
private void registerAction(AnAction action, @NonNls String actionId) {
|
||||
@@ -132,6 +154,10 @@ public class DesignerActionPanel implements DataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public ActionGroup getPopupActions() {
|
||||
return myPopupGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId) ||
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ public class SelectAllAction extends AnAction {
|
||||
private final EditableArea myArea;
|
||||
|
||||
public SelectAllAction(EditableArea area) {
|
||||
super("Select All", "Select All", null);
|
||||
myArea = area;
|
||||
}
|
||||
|
||||
|
||||
+1
-6
@@ -18,9 +18,8 @@ package com.intellij.designer.componentTree;
|
||||
import com.intellij.designer.actions.DesignerActionPanel;
|
||||
import com.intellij.designer.designSurface.FeedbackTreeLayer;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -56,10 +55,6 @@ public final class ComponentTree extends Tree implements DataProvider {
|
||||
// Install convenient keyboard navigation
|
||||
TreeUtil.installActions(this);
|
||||
|
||||
PopupHandler
|
||||
.installPopupHandler(this, (ActionGroup)ActionManager.getInstance().getAction("UIDesigner.ComponentTreePopupMenu"),
|
||||
ActionPlaces.GUI_DESIGNER_COMPONENT_TREE_POPUP, ActionManager.getInstance());
|
||||
|
||||
// TODO: F2 should start inplace editing
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -19,6 +19,7 @@ import com.intellij.designer.designSurface.ComponentSelectionListener;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeBuilder;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
|
||||
@@ -39,7 +40,12 @@ public final class ComponentTreeBuilder extends AbstractTreeBuilder implements C
|
||||
initRootNode();
|
||||
|
||||
mySurfaceArea = designer.getSurfaceArea();
|
||||
myTreeArea = new TreeEditableArea(tree, this);
|
||||
myTreeArea = new TreeEditableArea(tree, this) {
|
||||
@Override
|
||||
public ActionGroup getPopupActions() {
|
||||
return mySurfaceArea.getPopupActions();
|
||||
}
|
||||
};
|
||||
myGlassLayer = new TreeGlassLayer(tree, designer.getToolProvider(), myTreeArea);
|
||||
myExpandStateHandler = new ExpandStateHandler(tree, designer, this);
|
||||
|
||||
|
||||
+7
-1
@@ -19,6 +19,7 @@ import com.intellij.designer.designSurface.*;
|
||||
import com.intellij.designer.designSurface.tools.InputTool;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeBuilder;
|
||||
import com.intellij.openapi.actionSystem.ActionPlaces;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -36,7 +37,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public final class TreeEditableArea implements EditableArea, FeedbackTreeLayer, TreeSelectionListener {
|
||||
public abstract class TreeEditableArea implements EditableArea, FeedbackTreeLayer, TreeSelectionListener {
|
||||
private final EventListenerList myListenerList = new EventListenerList();
|
||||
private final ComponentTree myTree;
|
||||
private final AbstractTreeBuilder myTreeBuilder;
|
||||
@@ -238,6 +239,11 @@ public final class TreeEditableArea implements EditableArea, FeedbackTreeLayer,
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPopupPlace() {
|
||||
return ActionPlaces.GUI_DESIGNER_COMPONENT_TREE_POPUP;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FeedbackTreeLayer
|
||||
|
||||
+16
-3
@@ -21,9 +21,7 @@ import com.intellij.designer.model.FindComponentVisitor;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.designer.model.RadVisualComponent;
|
||||
import com.intellij.ide.DeleteProvider;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.SideBorder;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
@@ -50,6 +48,7 @@ public class CaptionPanel extends JLayeredPane implements DataProvider, DeletePr
|
||||
private final EditableArea myArea;
|
||||
private final DecorationLayer myDecorationLayer;
|
||||
private final FeedbackLayer myFeedbackLayer;
|
||||
private DefaultActionGroup myActionGroup;
|
||||
private final CommonEditActionsProvider myActionsProvider;
|
||||
private final RadVisualComponent myRootComponent;
|
||||
private List<RadComponent> myRootChildren = Collections.emptyList();
|
||||
@@ -125,6 +124,20 @@ public class CaptionPanel extends JLayeredPane implements DataProvider, DeletePr
|
||||
public RadComponent getRootComponent() {
|
||||
return myRootComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionGroup getPopupActions() {
|
||||
if (myActionGroup == null) {
|
||||
myActionGroup = new DefaultActionGroup();
|
||||
myActionGroup.add(ActionManager.getInstance().getAction("$Delete"));
|
||||
}
|
||||
return myActionGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPopupPlace() {
|
||||
return "UIDesigner.CaptionPanel";
|
||||
}
|
||||
};
|
||||
|
||||
add(new GlassLayer(designer.getToolProvider(), myArea), DesignerEditorPanel.LAYER_GLASS);
|
||||
|
||||
+11
-1
@@ -28,7 +28,7 @@ import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.diagnostic.LogMessageEx;
|
||||
import com.intellij.diagnostic.errordialog.Attachment;
|
||||
import com.intellij.ide.palette.impl.PaletteManager;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -183,6 +183,16 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
|
||||
public RadComponent getRootComponent() {
|
||||
return myRootComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionGroup getPopupActions() {
|
||||
return myActionPanel.getPopupActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPopupPlace() {
|
||||
return ActionPlaces.GUI_DESIGNER_EDITOR_POPUP;
|
||||
}
|
||||
};
|
||||
|
||||
myPaletteListener = new ListSelectionListener() {
|
||||
|
||||
+6
@@ -17,6 +17,7 @@ package com.intellij.designer.designSurface;
|
||||
|
||||
import com.intellij.designer.designSurface.tools.InputTool;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.openapi.actionSystem.ActionGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -52,6 +53,7 @@ public interface EditableArea {
|
||||
void setSelection(@NotNull List<RadComponent> components);
|
||||
|
||||
void deselectAll();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Visual
|
||||
@@ -86,4 +88,8 @@ public interface EditableArea {
|
||||
|
||||
@Nullable
|
||||
FeedbackTreeLayer getFeedbackTreeLayer();
|
||||
|
||||
ActionGroup getPopupActions();
|
||||
|
||||
String getPopupPlace();
|
||||
}
|
||||
+7
@@ -17,6 +17,8 @@ package com.intellij.designer.designSurface.tools;
|
||||
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionPopupMenu;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
@@ -136,6 +138,11 @@ public class SelectionTool extends InputTool {
|
||||
myTracker.mouseUp(event, area);
|
||||
}
|
||||
super.mouseUp(event, area);
|
||||
if (event.isPopupTrigger()) {
|
||||
ActionManager actionManager = ActionManager.getInstance();
|
||||
ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(area.getPopupPlace(), area.getPopupActions());
|
||||
popupMenu.getComponent().show(area.getNativeComponent(), event.getX(), event.getY());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-12
@@ -20,7 +20,6 @@ import com.intellij.designer.designSurface.ComponentSelectionListener;
|
||||
import com.intellij.designer.designSurface.DesignerEditorPanel;
|
||||
import com.intellij.designer.designSurface.EditableArea;
|
||||
import com.intellij.designer.model.RadComponent;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
@@ -32,7 +31,6 @@ 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.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -54,7 +52,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public final class PropertyTable extends JBTable implements ComponentSelectionListener, DataProvider {
|
||||
public final class PropertyTable extends JBTable implements ComponentSelectionListener {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.designer.propertyTable");
|
||||
|
||||
private final AbstractTableModel myModel = new PropertyTableModel();
|
||||
@@ -91,8 +89,6 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi
|
||||
|
||||
// TODO: ShowJavadocAction
|
||||
|
||||
// TODO: Popup menu
|
||||
|
||||
// TODO: Updates UI after LAF updated
|
||||
}
|
||||
|
||||
@@ -136,11 +132,6 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi
|
||||
return myCellRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
@@ -395,7 +386,7 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Property getSelectionProperty() {
|
||||
public Property getSelectionProperty() {
|
||||
int selectedRow = getSelectedRow();
|
||||
if (selectedRow >= 0 && selectedRow < myProperties.size()) {
|
||||
return myProperties.get(selectedRow);
|
||||
@@ -423,7 +414,7 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi
|
||||
return properties;
|
||||
}
|
||||
|
||||
private boolean isDefault(Property property) throws Exception {
|
||||
public boolean isDefault(Property property) throws Exception {
|
||||
for (RadComponent component : myComponents) {
|
||||
if (!property.isDefaultValue(component)) {
|
||||
return false;
|
||||
|
||||
+28
-32
@@ -16,22 +16,25 @@
|
||||
package com.intellij.designer.propertyTable;
|
||||
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.propertyTable.actions.IPropertyTableAction;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.impl.ActionButton;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.SideBorder;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public final class PropertyTablePanel extends JPanel {
|
||||
private final DefaultActionGroup myActionGroup = new DefaultActionGroup();
|
||||
public final class PropertyTablePanel extends JPanel implements ListSelectionListener {
|
||||
private final PropertyTable myPropertyTable = new PropertyTable();
|
||||
private final AnAction[] myActions;
|
||||
|
||||
public PropertyTablePanel() {
|
||||
setLayout(new GridBagLayout());
|
||||
@@ -40,46 +43,39 @@ public final class PropertyTablePanel extends JPanel {
|
||||
add(new JLabel(DesignerBundle.message("designer.properties.title")),
|
||||
new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 0), 0, 0));
|
||||
|
||||
createActions();
|
||||
ActionGroup actionGroup = (ActionGroup)ActionManager.getInstance().getAction("UIDesigner.PropertyTable");
|
||||
|
||||
AnAction[] actions = myActionGroup.getChildren(null);
|
||||
for (int i = 0; i < actions.length; i++) {
|
||||
AnAction action = actions[i];
|
||||
PopupHandler.installPopupHandler(myPropertyTable, actionGroup,
|
||||
ActionPlaces.GUI_DESIGNER_PROPERTY_INSPECTOR_POPUP,
|
||||
ActionManager.getInstance());
|
||||
|
||||
myActions = actionGroup.getChildren(null);
|
||||
for (int i = 0; i < myActions.length; i++) {
|
||||
AnAction action = myActions[i];
|
||||
add(new ActionButton(action, action.getTemplatePresentation(), ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE),
|
||||
new GridBagConstraints(i + 1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE,
|
||||
new Insets(2, 0, 2, i == actions.length - 1 ? 2 : 0), 0, 0));
|
||||
new Insets(2, 0, 2, i == myActions.length - 1 ? 2 : 0), 0, 0));
|
||||
}
|
||||
|
||||
myPropertyTable.getSelectionModel().addListSelectionListener(this);
|
||||
valueChanged(null);
|
||||
|
||||
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myPropertyTable);
|
||||
scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP));
|
||||
add(scrollPane, new GridBagConstraints(0, 1, actions.length + 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||
add(scrollPane, new GridBagConstraints(0, 1, myActions.length + 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||
new Insets(0, 0, 0, 0), 0, 0));
|
||||
}
|
||||
|
||||
private void createActions() {
|
||||
String restore = DesignerBundle.message("designer.properties.restore_default");
|
||||
myActionGroup.add(new AnAction(restore, restore, IconLoader.getIcon("/actions/reset-to-default.png")) {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
myPropertyTable.restoreDefaultValue();
|
||||
}
|
||||
});
|
||||
|
||||
String expert = DesignerBundle.message("designer.properties.show.expert");
|
||||
myActionGroup.add(new ToggleAction(expert, expert, IconLoader.getIcon("/com/intellij/designer/icons/filter.png")) {
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
return myPropertyTable.isShowExpert();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
myPropertyTable.showExpert(state);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public PropertyTable getPropertyTable() {
|
||||
return myPropertyTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
for (AnAction action : myActions) {
|
||||
if (action instanceof IPropertyTableAction) {
|
||||
((IPropertyTableAction)action).update(myPropertyTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.actions;
|
||||
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public interface IPropertyTableAction {
|
||||
void update(PropertyTable table);
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* 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.actions;
|
||||
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.DesignerToolWindowManager;
|
||||
import com.intellij.designer.propertyTable.Property;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class RestoreDefault extends AnAction implements IPropertyTableAction {
|
||||
public RestoreDefault() {
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
String text = DesignerBundle.message("designer.properties.restore_default");
|
||||
presentation.setText(text);
|
||||
presentation.setDescription(text);
|
||||
presentation.setIcon(IconLoader.getIcon("/actions/reset-to-default.png"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
PropertyTable table = DesignerToolWindowManager.getInstance(e.getProject()).getPropertyTable();
|
||||
setEnabled(table, e.getPresentation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(PropertyTable table) {
|
||||
setEnabled(table, getTemplatePresentation());
|
||||
}
|
||||
|
||||
private static void setEnabled(PropertyTable table, Presentation presentation) {
|
||||
try {
|
||||
Property property = table.getSelectionProperty();
|
||||
presentation.setEnabled(property != null && !table.isDefault(property));
|
||||
}
|
||||
catch (Exception e) {
|
||||
presentation.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
PropertyTable table = DesignerToolWindowManager.getInstance(e.getProject()).getPropertyTable();
|
||||
table.restoreDefaultValue();
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.actions;
|
||||
|
||||
import com.intellij.designer.DesignerBundle;
|
||||
import com.intellij.designer.DesignerToolWindowManager;
|
||||
import com.intellij.designer.propertyTable.PropertyTable;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
|
||||
/**
|
||||
* @author Alexander Lobas
|
||||
*/
|
||||
public class ShowExpert extends ToggleAction {
|
||||
public ShowExpert() {
|
||||
Presentation presentation = getTemplatePresentation();
|
||||
String text = DesignerBundle.message("designer.properties.show.expert");
|
||||
presentation.setText(text);
|
||||
presentation.setDescription(text);
|
||||
presentation.setIcon(IconLoader.getIcon("/com/intellij/designer/icons/filter.png"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
PropertyTable table = DesignerToolWindowManager.getInstance(e.getProject()).getPropertyTable();
|
||||
return table.isShowExpert();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(AnActionEvent e, boolean state) {
|
||||
PropertyTable table = DesignerToolWindowManager.getInstance(e.getProject()).getPropertyTable();
|
||||
table.showExpert(state);
|
||||
}
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public class XmlDocumentationProvider implements DocumentationProvider {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiElement findPreviousComment(final PsiElement element) {
|
||||
public static PsiElement findPreviousComment(final PsiElement element) {
|
||||
PsiElement curElement = element;
|
||||
|
||||
while(curElement!=null && !(curElement instanceof XmlComment)) {
|
||||
|
||||
Reference in New Issue
Block a user