Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2012-05-17 14:47:30 +02:00
13 changed files with 95 additions and 107 deletions
@@ -135,7 +135,7 @@ public class ITNProxy {
params.add(Pair.create("app.version.major", appInfo.getMajorVersion()));
params.add(Pair.create("app.version.minor", appInfo.getMinorVersion()));
params.add(Pair.create("app.build.date", format(appInfo.getBuildDate())));
params.add(Pair.create("app.build.date.release.", format(appInfo.getMajorReleaseBuildDate())));
params.add(Pair.create("app.build.date.release", format(appInfo.getMajorReleaseBuildDate())));
params.add(Pair.create("app.update.channel", appInfo.getDefaultUpdateChannel()));
params.add(Pair.create("app.compilation.timestamp", compilationTimestamp));
@@ -176,11 +176,7 @@ public class ITNProxy {
}
private static String format(Calendar calendar) {
if (calendar == null) {
return null;
} else {
return new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
}
return calendar == null ? null : Long.toString(calendar.getTime().getTime());
}
private static HttpURLConnection post(URL url, byte[] bytes) throws IOException {
@@ -16,7 +16,6 @@
package com.intellij.android.designer.designSurface;
import com.android.ide.common.rendering.api.RenderSession;
import com.android.ide.common.rendering.api.Result;
import com.android.ide.common.resources.configuration.*;
import com.android.sdklib.IAndroidTarget;
import com.intellij.android.designer.actions.ProfileAction;
@@ -24,11 +23,13 @@ import com.intellij.android.designer.componentTree.AndroidTreeDecorator;
import com.intellij.android.designer.model.ModelParser;
import com.intellij.android.designer.model.PropertyParser;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.android.designer.model.viewAnimator.RadViewAnimatorLayout;
import com.intellij.android.designer.profile.ProfileManager;
import com.intellij.designer.DesignerToolWindowManager;
import com.intellij.designer.componentTree.TreeComponentDecorator;
import com.intellij.designer.designSurface.*;
import com.intellij.designer.designSurface.ComponentDecorator;
import com.intellij.designer.designSurface.DesignerEditorPanel;
import com.intellij.designer.designSurface.EditOperation;
import com.intellij.designer.designSurface.OperationContext;
import com.intellij.designer.designSurface.selection.NonResizeSelectionDecorator;
import com.intellij.designer.designSurface.tools.ComponentCreationFactory;
import com.intellij.designer.designSurface.tools.ComponentPasteFactory;
@@ -38,7 +39,6 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
@@ -57,7 +57,6 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.lang.reflect.Method;
import java.util.List;
/**
@@ -112,71 +111,6 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
});
}
@Override
public void updateTreeArea(EditableArea area) {
area.addSelectionListener(new ComponentSelectionListener() {
@Override
public void selectionChanged(EditableArea area) {
List<RadComponent> selection = area.getSelection();
if (selection.size() == 1) {
final RadComponent component = selection.get(0);
final RadComponent parent = component.getParent();
if (parent instanceof RadViewComponent && parent.getLayout() instanceof RadViewAnimatorLayout) {
ApplicationManager.getApplication().invokeLater(
new Runnable() {
@Override
public void run() {
try {
int index = parent.getChildren().indexOf(component);
Object parentView =
((RadViewComponent)parent).getViewInfo().getViewObject();
Method method =
parentView.getClass().getMethod("setDisplayedChild", int.class);
method.invoke(parentView, index);
Result result = mySession.render();
// XXX
if (!result.isSuccess()) {
System.out.println(
"No re render session: " +
result.getErrorMessage() +
" : " +
result.getStatus() +
" : " +
result.getData() +
" : " +
result.getException());
}
else {
RadViewComponent rootComponent = (RadViewComponent)myRootComponent;
RootView rootView = (RootView)rootComponent.getNativeComponent();
rootView.setImage(mySession.getImage());
ModelParser.updateRootComponent(rootComponent, mySession, rootView);
myLayeredPane.revalidate();
DesignerToolWindowManager.getInstance(getProject()).refresh(true);
}
}
catch (Throwable e) {
showError("Render error", e);
}
}
}, new Condition() {
@Override
public boolean value(Object o) {
return mySession == null;
}
}
);
}
}
}
});
}
private void reparseFile() {
try {
storeState();
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -37,7 +37,7 @@ public class IdManager {
public void addComponent(RadViewComponent component) {
String id = component.getId();
if (id != null) {
if (id != null && !id.startsWith("@android:id/")) {
myIdList.add(id);
}
}
@@ -71,18 +71,18 @@ public class IdManager {
return newId;
}
public void ensurePasteIds(final RadViewComponent component) {
public void ensureIds(final RadViewComponent container) {
// TODO: rename all references
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
component.accept(new RadComponentVisitor() {
container.accept(new RadComponentVisitor() {
@Override
public void endVisit(RadComponent component) {
RadViewComponent viewComponent = (RadViewComponent)component;
String idValue = viewComponent.getId();
if (idValue != null && myIdList.contains(idValue)) {
if (component == container || (idValue != null && myIdList.contains(idValue))) {
createId(viewComponent);
}
}
@@ -179,21 +179,20 @@ public class ModelParser extends XmlRecursiveElementVisitor {
public String compute() {
return newComponent.getMetaModel().getCreation();
}
}, true);
});
PropertyParser propertyParser = container.getRoot().getClientProperty(PropertyParser.KEY);
propertyParser.load(newComponent);
if (!newComponent.getTag().isEmpty()) {
MetaManager metaManager = ViewsMetaManager.getInstance(newComponent.getTag().getProject());
IdManager idManager = container.getRoot().getClientProperty(IdManager.KEY);
addComponent(newComponent, metaManager, idManager, propertyParser);
addComponent(newComponent, ViewsMetaManager.getInstance(newComponent.getTag().getProject()), propertyParser);
}
IdManager.get(container).ensureIds(newComponent);
}
private static void addComponent(RadViewComponent parentComponent,
MetaManager metaManager,
IdManager idManager,
PropertyParser propertyParser) throws Exception {
for (XmlTag tag : parentComponent.getTag().getSubTags()) {
MetaModel metaModel = metaManager.getModelByTag(tag.getName());
@@ -203,11 +202,10 @@ public class ModelParser extends XmlRecursiveElementVisitor {
RadViewComponent component = createComponent(tag, metaModel);
idManager.addComponent(component);
parentComponent.add(component, null);
propertyParser.load(component);
addComponent(component, metaManager, idManager, propertyParser);
addComponent(component, metaManager, propertyParser);
}
}
@@ -218,7 +216,7 @@ public class ModelParser extends XmlRecursiveElementVisitor {
PropertyParser propertyParser = container.getRoot().getClientProperty(PropertyParser.KEY);
pasteComponent(newComponent, container.getTag(), insertBefore == null ? null : insertBefore.getTag(), propertyParser);
IdManager.get(container).ensurePasteIds(newComponent);
IdManager.get(container).ensureIds(newComponent);
}
private static void pasteComponent(final RadViewComponent component,
@@ -262,7 +260,7 @@ public class ModelParser extends XmlRecursiveElementVisitor {
return builder.append("/>").toString();
}
}, false);
});
XmlTag xmlTag = component.getTag();
List<RadComponent> children = component.getChildren();
@@ -284,8 +282,7 @@ public class ModelParser extends XmlRecursiveElementVisitor {
public static void addComponentTag(final XmlTag parentTag,
final RadViewComponent component,
final XmlTag nextTag,
final Computable<String> tagBuilder,
final boolean createId) {
final Computable<String> tagBuilder) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
@@ -323,10 +320,6 @@ public class ModelParser extends XmlRecursiveElementVisitor {
}
component.setTag(xmlTag);
if (createId) {
component.ensureId();
}
}
});
}
@@ -92,6 +92,9 @@ public class RadViewComponent extends RadVisualComponent {
if (StringUtil.isEmpty(idValue)) {
return null;
}
if (idValue.startsWith("@android:id/")) {
return idValue;
}
return "@id/" + idValue.substring(idValue.indexOf('/') + 1);
}
@@ -1230,6 +1230,64 @@
</creation>
</meta>
<meta model="com.intellij.android.designer.model.RadViewComponent"
layout="com.intellij.android.designer.model.RadViewLayout"
class="android.widget.TabHost"
tag="TabHost">
<palette title="TabHost" icon="/com/intellij/android/designer/icons/TabHost.png"
tooltip="Container for a tabbed window view. This object holds two children: a set of tab labels that the user clicks to select a specific tab, and a FrameLayout object that displays the contents of that page. The individual elements are typically controlled using this container object, rather than setting values on the child elements themselves."/>
<creation>
<![CDATA[
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/tab1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</LinearLayout>
<LinearLayout
android:id="@+id/tab2"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</LinearLayout>
<LinearLayout
android:id="@+id/tab3"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
]]>
</creation>
</meta>
<meta model="com.intellij.android.designer.model.RadViewComponent"
class="android.widget.TabWidget"
tag="TabWidget">
<palette title="TabWidget" icon="/com/intellij/android/designer/icons/TabWidget.png"/>
<properties important="divider tabStripEnabled tabStripLeft tabStripRight tabLayout"/>
</meta>
<!-- ================= Palette ================= -->
<palette>
@@ -1283,6 +1341,7 @@
<item tag="RadioGroup"/>
<item tag="ListView"/>
<item tag="GridView"/>
<item tag="TabHost"/>
<item tag="Gallery"/>
<item tag="Spinner"/>
<item tag="ExpandableListView"/>
@@ -121,15 +121,17 @@ class GitMockProject implements Project {
}
@Override
boolean hasComponent(Class interfaceClass) {
boolean hasComponent(@NotNull Class interfaceClass) {
throw new UnsupportedOperationException()
}
@NotNull
@Override
def <T> T[] getComponents(Class<T> baseClass) {
throw new UnsupportedOperationException()
}
@NotNull
@Override
PicoContainer getPicoContainer() {
throw new UnsupportedOperationException()
@@ -150,6 +152,7 @@ class GitMockProject implements Project {
throw new UnsupportedOperationException()
}
@NotNull
@Override
Condition getDisposed() {
throw new UnsupportedOperationException()
@@ -359,8 +359,8 @@ public class SvnHistoryProvider
SVNWCClient wcClient = myVcs.createWCClient();
final SVNURL svnurl = SVNURL.parseURIEncoded(myUrl);
SVNRevision operationalFrom = myFrom == null ? SVNRevision.HEAD : myFrom;
SVNInfo info = wcClient.doInfo(svnurl, myPeg, operationalFrom);
final String root = info.getRepositoryRootURL().toString();
final SVNURL rootURL = getRepositoryRoot(svnurl, myFrom);
final String root = rootURL.toString();
String relativeUrl = myUrl;
if (myUrl.startsWith(root)) {
relativeUrl = myUrl.substring(root.length());
@@ -368,8 +368,7 @@ public class SvnHistoryProvider
SVNLogClient client = myVcs.createLogClient();
client.doLog(svnurl, new String[]{}, myPeg == null ? myFrom : myPeg,
operationalFrom, myTo == null ? SVNRevision.create(1) : myTo, false, true, mySupport15, myLimit, null,
new RepositoryLogEntryHandler(myVcs, myUrl, SVNRevision.UNDEFINED, relativeUrl, createConsumerAdapter(myConsumer),
info.getRepositoryRootURL()));
new RepositoryLogEntryHandler(myVcs, myUrl, SVNRevision.UNDEFINED, relativeUrl, createConsumerAdapter(myConsumer), rootURL));
}
catch (SVNCancelException e) {
//
@@ -436,7 +435,7 @@ public class SvnHistoryProvider
catch (SVNException e) {
return false;
}
return info != null && info.getURL() != null;
return info != null && info.getURL() != null && info.getRevision().isValid();
}
}
@@ -104,6 +104,11 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel {
descriptionsEqual(((ConflictedSvnChange)change).getBeforeDescription(), myChange.getBeforeDescription());
}
@Override
public boolean refreshDataSynch() {
return true;
}
private boolean descriptionsEqual(SVNTreeConflictDescription d1, SVNTreeConflictDescription d2) {
if (d1.isPropertyConflict() != d2.isPropertyConflict()) return false;
if (d1.isTextConflict() != d2.isTextConflict()) return false;
@@ -164,7 +169,8 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel {
}
else {
long committed = description.getSourceLeftVersion().getPegRevision();
if (myCommittedRevision != null && myCommittedRevision.getRevision().getNumber() < committed) {
if (myCommittedRevision != null && (myCommittedRevision.getRevision().getNumber() < committed) &&
myCommittedRevision.getRevision().isValid()) {
committed = myCommittedRevision.getRevision().getNumber();
}
pegFromLeft = SVNRevision.create(committed);
@@ -45,8 +45,6 @@ public final class ComponentTreeBuilder extends AbstractTreeBuilder implements C
new TreeDropListener(tree, myTreeArea, designer.getToolProvider());
designer.updateTreeArea(myTreeArea);
selectFromSurface();
expandFromState();
@@ -637,9 +637,6 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
public abstract String getPlatformTarget();
public void updateTreeArea(EditableArea area) {
}
protected abstract ComponentDecorator getRootSelectionDecorator();
@Nullable