Methods Summary |
---|
protected void | computeResult()
Object[] elements = getSelectedElements();
if (elements.length == 1 && elements[0] instanceof ResourceItem) {
ResourceItem item = (ResourceItem)elements[0];
mCurrentResource = mResourceType.getXmlString(item,
SHOW_SYSTEM_RESOURCE && mSystemButton.getSelection());
}
|
private void | createButtons(org.eclipse.swt.widgets.Composite top)Creates the radio button to switch between project and system resources.
if (!SHOW_SYSTEM_RESOURCE) {
return;
}
mProjectButton = new Button(top, SWT.RADIO);
mProjectButton.setText("Project Resources");
mProjectButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
if (mProjectButton.getSelection()) {
setListElements(mProjectResources.getResources(mResourceType));
}
}
});
mSystemButton = new Button(top, SWT.RADIO);
mSystemButton.setText("System Resources");
mSystemButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
if (mProjectButton.getSelection()) {
setListElements(mSystemResources.getResources(mResourceType));
}
}
});
|
protected org.eclipse.swt.widgets.Control | createDialogArea(org.eclipse.swt.widgets.Composite parent)
Composite top = (Composite)super.createDialogArea(parent);
createMessageArea(top);
createButtons(top);
createFilterText(top);
createFilteredList(top);
// create the "New Resource" button
createNewResButtons(top);
setupResourceList();
selectResourceString(mCurrentResource);
return top;
|
private void | createNewResButtons(org.eclipse.swt.widgets.Composite top)Creates the "New Resource" button.
Button newResButton = new Button(top, SWT.NONE);
String title = String.format("New %1$s...", mResourceType.getDisplayName());
newResButton.setText(title);
// We only support adding new strings right now
newResButton.setEnabled(mResourceType == ResourceType.STRING);
newResButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
if (mResourceType == ResourceType.STRING) {
createNewString();
}
}
});
|
private void | createNewString()
ExtractStringRefactoring ref = new ExtractStringRefactoring(
mProject, true /*enforceNew*/);
RefactoringWizard wizard = new ExtractStringWizard(ref, mProject);
RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
try {
IWorkbench w = PlatformUI.getWorkbench();
if (op.run(w.getDisplay().getActiveShell(), wizard.getDefaultPageTitle()) ==
IDialogConstants.OK_ID) {
// Recompute the "current resource" to select the new id
setupResourceList();
// select it if possible
selectItemName(ref.getXmlStringId());
}
} catch (InterruptedException ex) {
// Interrupted. Pass.
}
|
private com.android.ide.eclipse.common.resources.IResourceRepository | getCurrentRepository()
IResourceRepository repo = mProjectResources;
if (SHOW_SYSTEM_RESOURCE && mSystemButton.getSelection()) {
repo = mSystemResources;
}
return repo;
|
public java.lang.String | getCurrentResource()
return mCurrentResource;
|
private void | selectItemName(java.lang.String itemName)Select an item by its name, if possible.
if (itemName == null) {
return;
}
IResourceRepository repo = getCurrentRepository();
ResourceItem[] items = repo.getResources(mResourceType);
for (ResourceItem item : items) {
if (itemName.equals(item.getName())) {
setSelection(new Object[] { item });
break;
}
}
|
private void | selectResourceString(java.lang.String resourceString)Select an item by its full resource string.
This also selects between project and system repository based on the resource string.
boolean isSystem = false;
String itemName = null;
// Is this a system resource?
// If not a system resource or if they are not available, this will be a project res.
if (SHOW_SYSTEM_RESOURCE) {
Matcher m = mSystemResourcePattern.matcher(resourceString);
if (m.matches()) {
itemName = m.group(1);
isSystem = true;
}
}
if (!isSystem && itemName == null) {
// Try to match project resource name
Matcher m = mProjectResourcePattern.matcher(resourceString);
if (m.matches()) {
itemName = m.group(1);
}
}
// Update the repository selection
if (SHOW_SYSTEM_RESOURCE) {
mProjectButton.setSelection(!isSystem);
mSystemButton.setSelection(isSystem);
}
// Update the list
setupResourceList();
// If we have a selection name, select it
if (itemName != null) {
selectItemName(itemName);
}
|
public void | setCurrentResource(java.lang.String resource)
mCurrentResource = resource;
|
private void | setupResourceList()Setups the current list.
IResourceRepository repo = getCurrentRepository();
setListElements(repo.getResources(mResourceType));
|