1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.sdkuilib.internal.repository.sdkman2; 18 19 import com.android.sdklib.internal.repository.SdkRepoSource; 20 import com.android.sdklib.internal.repository.SdkSource; 21 import com.android.sdkuilib.internal.repository.UpdaterData; 22 23 24 class PkgCategorySource extends PkgCategory { 25 26 /** 27 * A special {@link SdkSource} object that represents the locally installed 28 * items, or more exactly a lack of remote source. 29 */ 30 public final static SdkSource UNKNOWN_SOURCE = 31 new SdkRepoSource("http://no.source", "Local Packages"); 32 private final SdkSource mSource; 33 34 public PkgCategorySource(SdkSource source, UpdaterData updaterData) { 35 super( 36 source, // the source is the key and it can be null 37 source == UNKNOWN_SOURCE ? "Local Packages" : source.toString(), 38 source == UNKNOWN_SOURCE ? 39 updaterData.getImageFactory().getImageByName(PackagesPage.ICON_PKG_INSTALLED) : 40 source); 41 mSource = source; 42 } 43 44 @Override 45 public String toString() { 46 return String.format("%s <source=%s, #items=%d>", 47 this.getClass().getSimpleName(), 48 mSource.toString(), 49 getItems().size()); 50 } 51 52 public SdkSource getSource() { 53 return mSource; 54 } 55 } 56