Merge change 26773 into eclair

* changes:
  Disable clipping toggle when not supported.
This commit is contained in:
Android (Google) Code Review
2009-09-24 02:35:11 -04:00
5 changed files with 41 additions and 11 deletions

View File

@@ -41,7 +41,6 @@ import com.android.layoutlib.api.ILayoutResult;
import com.android.layoutlib.api.IProjectCallback; import com.android.layoutlib.api.IProjectCallback;
import com.android.layoutlib.api.IResourceValue; import com.android.layoutlib.api.IResourceValue;
import com.android.layoutlib.api.IXmlPullParser; import com.android.layoutlib.api.IXmlPullParser;
import com.android.layoutlib.api.ILayoutResult.ILayoutViewInfo;
import com.android.sdklib.IAndroidTarget; import com.android.sdklib.IAndroidTarget;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@@ -76,7 +75,6 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@@ -484,7 +482,6 @@ public class GraphicalEditorPart extends EditorPart implements IGraphicalLayoutE
// to trigger the edit of the new file. // to trigger the edit of the new file.
res.refreshLocal(IResource.DEPTH_INFINITE, new IProgressMonitor() { res.refreshLocal(IResource.DEPTH_INFINITE, new IProgressMonitor() {
public void done() { public void done() {
mConfigComposite.setConfig(config);
mConfigComposite.getDisplay().asyncExec(new Runnable() { mConfigComposite.getDisplay().asyncExec(new Runnable() {
public void run() { public void run() {
onConfigurationChange(); onConfigurationChange();
@@ -970,6 +967,19 @@ public class GraphicalEditorPart extends EditorPart implements IGraphicalLayoutE
} }
} }
public void reloadConfigurationUi() {
// enable the clipping button if it's supported.
Sdk currentSdk = Sdk.getCurrent();
if (currentSdk != null) {
IAndroidTarget target = currentSdk.getTarget(mEditedFile.getProject());
AndroidTargetData data = currentSdk.getTargetData(target);
if (data != null) {
LayoutBridge bridge = data.getLayoutBridge();
mConfigComposite.setClippingSupport(bridge.apiLevel >= 4);
}
}
}
/** /**
* Used by LayoutEditor.UiEditorActions.selectUiNode to select a new UI Node * Used by LayoutEditor.UiEditorActions.selectUiNode to select a new UI Node
* created by {@link ElementCreateCommand#execute()}. * created by {@link ElementCreateCommand#execute()}.

View File

@@ -547,6 +547,8 @@ public class GraphicalLayoutEditor extends GraphicalEditorWithPalette
// enable the create button if the current and edited config are not equals // enable the create button if the current and edited config are not equals
mConfigComposite.setEnabledCreate( mConfigComposite.setEnabledCreate(
mEditedConfig.equals(mConfigComposite.getCurrentConfig()) == false); mEditedConfig.equals(mConfigComposite.getCurrentConfig()) == false);
reloadConfigurationUi();
} }
public Rectangle getBounds() { public Rectangle getBounds() {
@@ -728,7 +730,18 @@ public class GraphicalLayoutEditor extends GraphicalEditorWithPalette
PaletteFactory.createPaletteRoot(mPaletteRoot, mLayoutEditor.getTargetData()); PaletteFactory.createPaletteRoot(mPaletteRoot, mLayoutEditor.getTargetData());
} }
public void reloadConfigurationUi() {
// enable the clipping button if it's supported.
Sdk currentSdk = Sdk.getCurrent();
if (currentSdk != null) {
IAndroidTarget target = currentSdk.getTarget(mEditedFile.getProject());
AndroidTargetData data = currentSdk.getTargetData(target);
if (data != null) {
LayoutBridge bridge = data.getLayoutBridge();
mConfigComposite.setClippingSupport(bridge.apiLevel >= 4);
}
}
}
/** /**
* Looks for a file matching the new {@link FolderConfiguration} and attempts to open it. * Looks for a file matching the new {@link FolderConfiguration} and attempts to open it.
@@ -1231,7 +1244,6 @@ public class GraphicalLayoutEditor extends GraphicalEditorWithPalette
// to trigger the edit of the new file. // to trigger the edit of the new file.
res.refreshLocal(IResource.DEPTH_INFINITE, new IProgressMonitor() { res.refreshLocal(IResource.DEPTH_INFINITE, new IProgressMonitor() {
public void done() { public void done() {
mConfigComposite.setConfig(config);
mParent.getDisplay().asyncExec(new Runnable() { mParent.getDisplay().asyncExec(new Runnable() {
public void run() { public void run() {
onConfigurationChange(); onConfigurationChange();

View File

@@ -82,4 +82,6 @@ import org.eclipse.ui.IEditorPart;
abstract Clipboard getClipboard(); abstract Clipboard getClipboard();
abstract void reloadConfigurationUi();
} }

View File

@@ -410,6 +410,7 @@ public class LayoutEditor extends AndroidEditor implements IShowEditorInput, IPa
if (mGraphicalEditor != null) { if (mGraphicalEditor != null) {
mGraphicalEditor.reloadEditor(); mGraphicalEditor.reloadEditor();
mGraphicalEditor.reloadPalette(); mGraphicalEditor.reloadPalette();
mGraphicalEditor.reloadConfigurationUi();
mGraphicalEditor.recomputeLayout(); mGraphicalEditor.recomputeLayout();
} }
} }

View File

@@ -227,11 +227,6 @@ public class ConfigurationComposite extends Composite {
onDeviceConfigChange(); onDeviceConfigChange();
} }
public void setConfig(FolderConfiguration config) {
// mCurrentConfig.set(config);
throw new UnsupportedOperationException("setConfig");
}
public FolderConfiguration getCurrentConfig() { public FolderConfiguration getCurrentConfig() {
return mCurrentConfig; return mCurrentConfig;
} }
@@ -429,6 +424,17 @@ public class ConfigurationComposite extends Composite {
mCreateButton.setEnabled(enabled); mCreateButton.setEnabled(enabled);
} }
public void setClippingSupport(boolean b) {
mClippingButton.setEnabled(b);
if (b) {
mClippingButton.setToolTipText("Toggles screen clipping on/off");
} else {
mClipping = true;
mClippingButton.setSelection(true);
mClippingButton.setToolTipText("Non clipped rendering is not supported");
}
}
/** /**
* Update the UI controls state with a given {@link FolderConfiguration}. * Update the UI controls state with a given {@link FolderConfiguration}.
* <p/>If <var>force</var> is set to <code>true</code> the UI will be changed to exactly reflect * <p/>If <var>force</var> is set to <code>true</code> the UI will be changed to exactly reflect
@@ -596,5 +602,4 @@ public class ConfigurationComposite extends Composite {
return false; return false;
} }
} }