AbsoluteLayout

This commit is contained in:
Alexander Lobas
2012-04-10 21:58:59 +04:00
parent 0029d0e8b1
commit d2898f1012
4 changed files with 133 additions and 0 deletions
@@ -0,0 +1,46 @@
/*
* 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.android.designer.designSurface.layout;
import com.intellij.android.designer.designSurface.AbstractEditOperation;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.designer.designSurface.OperationContext;
/**
* @author Alexander Lobas
*/
public class AbsoluteLayoutOperation extends AbstractEditOperation {
public AbsoluteLayoutOperation(RadViewComponent container, OperationContext context) {
super(container, context);
}
@Override
public void showFeedback() {
// TODO: Auto-generated method stub
}
@Override
public void eraseFeedback() {
// TODO: Auto-generated method stub
}
@Override
public void execute() throws Exception {
if (!myContext.isMove()) {
super.execute();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

@@ -0,0 +1,69 @@
/*
* 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.android.designer.model.layout;
import com.intellij.android.designer.designSurface.TreeDropToOperation;
import com.intellij.android.designer.designSurface.layout.AbsoluteLayoutOperation;
import com.intellij.android.designer.designSurface.layout.ResizeOperation;
import com.intellij.android.designer.model.RadViewComponent;
import com.intellij.android.designer.model.RadViewLayoutWithData;
import com.intellij.designer.designSurface.ComponentDecorator;
import com.intellij.designer.designSurface.EditOperation;
import com.intellij.designer.designSurface.OperationContext;
import com.intellij.designer.designSurface.selection.ResizeSelectionDecorator;
import com.intellij.designer.model.RadComponent;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.List;
/**
* @author Alexander Lobas
*/
public class RadAbsoluteLayout extends RadViewLayoutWithData {
private static final String[] LAYOUT_PARAMS = {"AbsoluteLayout_Layout", "ViewGroup_Layout"};
private ResizeSelectionDecorator mySelectionDecorator;
@Override
@NotNull
public String[] getLayoutParams() {
return LAYOUT_PARAMS;
}
@Override
public EditOperation processChildOperation(OperationContext context) {
if (context.isCreate() || context.isPaste() || context.isAdd() || context.isMove()) {
if (context.isTree()) {
return new TreeDropToOperation(myContainer, context);
}
return new AbsoluteLayoutOperation((RadViewComponent)myContainer, context);
}
if (context.is(ResizeOperation.TYPE)) {
return new ResizeOperation(context);
}
return null;
}
@Override
public ComponentDecorator getChildSelectionDecorator(RadComponent component, List<RadComponent> selection) {
if (mySelectionDecorator == null) {
mySelectionDecorator = new ResizeSelectionDecorator(Color.red, 1);
ResizeOperation.points(mySelectionDecorator);
}
return mySelectionDecorator;
}
}
@@ -1074,6 +1074,24 @@
</creation>
</meta>
<meta model="com.intellij.android.designer.model.RadViewContainer"
layout="com.intellij.android.designer.model.layout.RadAbsoluteLayout"
class="android.widget.AbsoluteLayout"
tag="AbsoluteLayout">
<palette title="AbsoluteLayout" icon="/com/intellij/android/designer/icons/AbsoluteLayout.png"
tooltip="A layout that lets you specify exact locations (x/y coordinates) of its children. Absolute layouts are less flexible and harder to maintain than other types of layouts without absolute positioning."/>
<creation>
<![CDATA[
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</AbsoluteLayout>
]]>
</creation>
</meta>
<!-- ================= Palette ================= -->
<palette>