-/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
- * 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.installmanager.ui;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.RowData;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.installmanager.cli.InstallManagerNoUI;
-import org.tizen.installmanager.core.Config;
-import org.tizen.installmanager.core.IMExitException;
-import org.tizen.installmanager.core.IMFatalException;
-import org.tizen.installmanager.core.InstallManager;
-import org.tizen.installmanager.core.Options;
-import org.tizen.installmanager.core.Performance;
-import org.tizen.installmanager.lib.ErrorController;
-import org.tizen.installmanager.lib.IMError;
-import org.tizen.installmanager.lib.Log;
-import org.tizen.installmanager.lib.Platform;
-import org.tizen.installmanager.lib.ProgramController;
-import org.tizen.installmanager.lib.Registry;
-import org.tizen.installmanager.lib.exception.IMNetworkException;
-import org.tizen.installmanager.lib.mac.CocoaUtil;
-import org.tizen.installmanager.pkg.lib.PackageManager;
-import org.tizen.installmanager.pkg.model.ConfigFile;
-import org.tizen.installmanager.pkg.model.PackageSet;
-import org.tizen.installmanager.ui.dialog.AddExtraRepositoryDialog;
-import org.tizen.installmanager.ui.dialog.IndeterminateProgressDialog;
-import org.tizen.installmanager.ui.dialog.MessageBoxDlg;
-import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;
-import org.tizen.installmanager.ui.dialog.ProxySettingsDialog;
-import org.tizen.installmanager.ui.model.Item;
-import org.tizen.installmanager.ui.page.CompletePage;
-import org.tizen.installmanager.ui.page.InstallPage;
-import org.tizen.installmanager.ui.page.InstallableListPage;
-import org.tizen.installmanager.ui.page.InstallingPage;
-import org.tizen.installmanager.ui.page.LicensePage;
-import org.tizen.installmanager.ui.page.SetInstallDirectoryPage;
-import org.tizen.installmanager.ui.page.UninstallableListPage;
-import org.tizen.installmanager.ui.page.UninstallingPage;
-import org.tizen.installmanager.ui.page.UpdatableListPage;
-import org.tizen.installmanager.ui.page.ViewController;
-import org.tizen.installmanager.ui.page.WelcomePage;
-import org.tizen.installmanager.ui.page.InstallingPage.InstallProgressMonitor;
-import org.tizen.installmanager.ui.page.WelcomePage.INSTALLMANAGER_ACTION;
-import org.tizen.installmanager.util.PathUtil;
-import org.tizen.installmanager.pkg.model.Package;
-
-
-/**
- * This class is main class for install manager.
- * @author Taeyoung Son <taeyoung2.son@samsung.com>
- */
-public class InstallManagerWindow extends ApplicationWindow {
- private static final RGB RGB_BACKGROUND = new RGB(242, 242, 242);
-
- private static final Point POINT_MAIN_WINDOW = new Point(628, 478);
- private static Image IMAGE_WINDOW_ICON;
- private static Color COLOR_BACKGROUND;
-
- private static InstallManagerWindow window;
-
-// private StackLayout sl_composite = new StackLayout();
- public StackLayout sl_composite = new StackLayout();
- private static Button btnClose;
- private static Button btnBack;
- private static Button btnNext;
-
- private Composite pageComposite; // Page area
- private WelcomePage compositeWelcomePage;
- private LicensePage compositeLicensePage;
- private InstallableListPage compositeInstallableListPage;
- private UninstallableListPage compositeUninstallableListPage;
- private InstallingPage compositeInstallingPage;
- private UninstallingPage compositeUninstallingPage;
- private CompletePage compositeCompletePage;
- private SetInstallDirectoryPage compositeSetInstallDirectoryPage;
- public UpdatableListPage compositeUpdatableListPage;
-
- protected static ViewController controller;
- private SelectionAdapter cancelBtnSelectionAdapter = null;
- private SelectionAdapter closeBtnSelectionAdapter = null;
-
- /**
- * Create the application window.
- */
- public InstallManagerWindow() {
- super(null);
- setShellStyle(SWT.SHELL_TRIM);
- setShellStyle(SWT.BORDER | SWT.TITLE);
- }
-
- /**
- * Get installmanager window background color.
- * @return background color
- */
- public static Color getBackgroundColor() {
- if (COLOR_BACKGROUND == null) {
- COLOR_BACKGROUND = new Color(null, RGB_BACKGROUND);
- }
- return COLOR_BACKGROUND;
- }
-
- private static Image getWindowIconImage() {
- if (IMAGE_WINDOW_ICON == null) {
- IMAGE_WINDOW_ICON = PathUtil.getImageFromResource("/res/icons/SDK_icon.png");
- }
- return IMAGE_WINDOW_ICON;
- }
-
- private void init() throws IMExitException{
- Log.log("Window init start");
-
- //make waiting dialog.
- final IndeterminateProgressDialog progressbar = IndeterminateProgressDialog.getInstance();
-
- final Shell shell = progressbar.getParent();
- shell.getDisplay().asyncExec(new Runnable(){
- public void run() {
- //initialize installmanager
- progressbar.updateName("Connecting to package server.\nIt may take a minute...");
-
- shell.getDisplay().asyncExec(new Runnable() {
- public void run() {
- initInstallManager();
- }
-
- });
-
- //init end
- progressbar.finish();
- }
- });
-
- if (!shell.isDisposed()) {
- progressbar.open();
- }
-
- Log.log("Window init end");
- }
-
- private void updateInstallManager(Shell shell) {
- if (controller.canInstallManagerUpdate()) {
- String msg = "There is a new installer on the server. \nNew install-manager will be started. \nIt may take a minute...";
- MessageBoxDlg.showDlg(shell, "InstallManager", msg, DialogType.NOTIFY, false);
-
- controller.updateInstallManager();
- }
- }
-
- /**
- * init IM's configuation and packages information.
- * @return
- */
- public boolean initInstallManager() {
- ErrorController.setInstallationSuccess(true);
-
- controller = new ViewController();
-
- if (controller.init()) {
- if (Config.isSupportMultiSDK()) {
- Log.log("Multi SDK installation.");
- } else {
- Log.log("Single SDK installation.");
- }
- return true;
- } else {
- Log.err("InstallManager init fail.");
- ErrorController.setInstallationSuccess(false);
-
- return false;
- }
- }
-
- /**
- * Create contents of the application window.
- *
- * @param parent
- */
- @Override
- protected Control createContents(Composite parent) {
-
- parent.setSize(630, 490);
- IMError.setComposite(parent);
- Composite container = new Composite(parent, SWT.NONE);
-
- // Set layout attributes.
- RowLayout rl_container = new RowLayout(SWT.VERTICAL);
- rl_container.spacing = 0;
- rl_container.marginTop = 0;
- rl_container.marginRight = 0;
- rl_container.marginLeft = 0;
- rl_container.marginBottom = 0;
- container.setLayout(rl_container);
-
- // Set page composite size. (image, label, etc.)
- pageComposite = new Composite(container, SWT.NONE);
- pageComposite.setLayoutData(new RowData(628, 405));
- pageComposite.setLayout(sl_composite);
-
- Composite composite_buttonArea = new Composite(container, SWT.NONE);
- composite_buttonArea.setLayoutData(new RowData(628, 52));
- composite_buttonArea.setBackground(getBackgroundColor());
-
- setButtonClose(composite_buttonArea);
- setButtonNext(composite_buttonArea);
- setButtonBack(composite_buttonArea);
-
- compositeWelcomePage = new WelcomePage(pageComposite, SWT.NONE);
- compositeLicensePage = new LicensePage(pageComposite, SWT.NONE);
- compositeCompletePage = new CompletePage(pageComposite, SWT.NONE);
- compositeInstallingPage = new InstallingPage(pageComposite, SWT.NONE);
- compositeInstallableListPage = new InstallableListPage(pageComposite, SWT.NONE);
- compositeUninstallingPage = new UninstallingPage(pageComposite, SWT.NONE);
- compositeUninstallableListPage = new UninstallableListPage(pageComposite, SWT.NONE);
- compositeSetInstallDirectoryPage = new SetInstallDirectoryPage(pageComposite, SWT.NONE);
- compositeUpdatableListPage = new UpdatableListPage(pageComposite, SWT.NONE);
-
-// registLicensePageListener();
-// registCompletePageListener();
-
- initWelcomePage();
-
- return container;
- }
-
- private void setButtonClose(Composite composite) {
- btnClose = new Button(composite, SWT.NONE);
- btnClose.setText("Cancel");
- cancelBtnSelectionAdapter = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int result = MessageBoxDlg.NO;
- if (sl_composite.topControl == compositeInstallingPage) {
- InstallProgressMonitor mon = compositeInstallingPage.getInstallProgressMonitor();
- mon.setCancelRequested(true);
- result = MessageBoxDlg.showDlg(
- e.display.getActiveShell(),
- "Tizen SDK Install Manager",
- "Are you sure you want to quit Install Manager?\n\nIf you click \"Yes\", the installation is stopped.",
- DialogType.WARNING, false);
- if (result == MessageBoxDlg.YES) {
- mon.setCanceled(true);
- } else {
- mon.setCancelRequested(false);
- }
- return;
- } else if (sl_composite.topControl == compositeUninstallingPage) {
- result = MessageBoxDlg.showDlg(
- e.display.getActiveShell(),
- "Tizen SDK Install Manager",
- "Are you sure to quit Install Manager?\n\nIf you click \"Yes\", the uninstallation is stopped.",
- DialogType.WARNING, false);
- } else if (sl_composite.topControl == compositeCompletePage) {
- controller.showChangeLog();
-
- if (!Options.doResumeDownloading) {
- controller.cleanUpTargetDirectory();
- }
-
- result = MessageBoxDlg.YES;
- } else {
- result = MessageBoxDlg.showDlg(e.display.getActiveShell(),
- "Tizen SDK Install Manager",
- "Are you sure to quit Install Manager?",
- DialogType.WARNING, false);
- }
-
- if (result == MessageBoxDlg.YES) {
- e.display.close();
- }
- }
- };
-
- closeBtnSelectionAdapter = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- arg0.display.close();
- }
- };
-
- btnClose.addSelectionListener(cancelBtnSelectionAdapter);
- btnClose.setBounds(531, 10, 78, 29);
- }
-
- private void setButtonNext(Composite composite) {
- btnNext = new Button(composite, SWT.NONE);
- btnNext.setText("Next");
- btnNext.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (sl_composite.topControl == compositeWelcomePage) {
- updateInstallManager(e.display.getActiveShell());
- btnNext.setVisible(false);
- if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.INSTALL) {
- if (!checkVaildPkgVersion()) {
- return;
- }
-
- if (!controller.isNewInstallation()) {// Update case
- Config.status = Config.Status.UPDATE;
- compositeUpdatableListPage.loadPage(controller);
- btnBack.setVisible(true);
- btnNext.setVisible(true);
- showComposite(compositeUpdatableListPage);
- if (controller.existRemovablePackage()) {
- btnNext.setText("Install");
- }
- btnBack.setVisible(true);
- } else {
- boolean hasItem = compositeInstallableListPage.loadPage(controller);
- if (hasItem) {
- Config.status = Config.Status.INSTALL;
- showComposite(compositeInstallableListPage);
- btnNext.setVisible(true);
- btnNext.setEnabled(hasItem);
- btnBack.setVisible(hasItem);
- if (controller.existRemovablePackage()) {
- btnNext.setText("Install");
- }
- } else {
- Log.err("Installable packages do not exist. This is error.");
- //TODO
- }
- }
- } else if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.UPDATE) {
-// btnNext.setEnabled(compositeLicensePage.getAcceptButton().getSelection());
- btnNext.setEnabled(true);
- PackageManager.dispose();
- initInstallManager();
- compositeUpdatableListPage.loadPage(controller);
- btnBack.setVisible(true);
- showComposite(compositeUpdatableListPage);
- if (controller.existRemovablePackage()) {
- btnNext.setText("Install");
- }
- btnBack.setVisible(true);
- } else if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.UNINSTALL) {
- showComposite(compositeUninstallableListPage);
- btnNext.setVisible(true);
- btnBack.setVisible(true);
- btnNext.setText("Uninstall");
- compositeUninstallableListPage.loadPage(controller);
-// int resultDialog = MessageBoxDlg.NO;
-// resultDialog = MessageBoxDlg.showDlg(
-// e.display.getActiveShell(),
-// "Tizen SDK Install Manager",
-// "Are you sure you want to remove the Tizen SDK?\n\nIf you click \"Yes\", the Tizen SDK is uninstalled.",
-// DialogType.WARNING, false);
-// if (resultDialog == MessageBoxDlg.YES) {
-// showComposite(compositeUninstallingPage);
-// btnBack.setVisible(false);
-// btnNext.setVisible(false);
-// btnClose.setEnabled(false);
-//
-// if (Config.isSupportMultiSDK()) {
-// PackageManager.dispose();
-// initInstallManager();
-// }
-//
-// List<Item> items = compositeUninstallablePage.getItems();
-// boolean result = compositeUninstallingPage.loadPage(getSelectedPackageNames(items) /* compositeInstallablePage.getCheckedPackageNames()*/,
-// controller,
-// window);
-// if (!result) {
-// showComposite(compositeWelcomePage);
-// btnBack.setVisible(true);
-// btnNext.setVisible(true);
-// btnClose.setEnabled(true);
-// }
-// } else {
-// return;
-// }
- }
- } else if (sl_composite.topControl == compositeInstallableListPage) {
-// btnNext.setEnabled(compositeLicensePage.getAcceptButton().getSelection());
- btnNext.setEnabled(true);
- if (Config.isSupportMultiSDK()) {
- showComposite(compositeLicensePage);
- btnBack.setVisible(true);
- } else {
- if (!controller.isNewInstallation()) {// Update case
- compositeUpdatableListPage.loadPage(controller);
- btnBack.setVisible(true);
- showComposite(compositeUpdatableListPage);
- if (controller.existRemovablePackage()) {
- btnNext.setText("Install");
- }
- btnBack.setVisible(true);
- } else {
- //License page button status setting.
- showComposite(compositeLicensePage);
- btnNext.setText("I agree");
- btnNext.setEnabled(true);
- btnNext.setFocus();
- btnBack.setVisible(true);
- }
- }
- } else if (sl_composite.topControl == compositeLicensePage) {
- List<Item> items = compositeInstallableListPage.getItems();
- if (getSelectedPackageNames(items).size() <= 0) {
- return;
- }
- if (Config.isSupportMultiSDK()) {
- showComposite(compositeSetInstallDirectoryPage);
- compositeSetInstallDirectoryPage.loadPage(
- controller, compositeInstallableListPage.getCheckedPackageSize(false));
-// btnNext.setText("Install");
- } else {
- if (controller.existRemovablePackage()) { // update case
- btnBack.setVisible(false);
- btnNext.setVisible(false);
- showComposite(compositeInstallingPage);
- boolean result = compositeInstallingPage.loadPage(getSelectedPackageNames(items),
- controller,
- Registry.getInstalledPath(),
- window, true);
- if (!result) {
- showComposite(compositeInstallableListPage);
- btnBack.setVisible(true);
- btnNext.setVisible(true);
- btnClose.setEnabled(true);
- }
- } else {
- showComposite(compositeSetInstallDirectoryPage);
- compositeSetInstallDirectoryPage.loadPage(
- controller, compositeInstallableListPage.getCheckedPackageSize(false));
- btnNext.setText("Install");
-// btnNext.setVisible(false);
-// btnBack.setBounds(447, 10, 78, 29);
- }
- }
- } else if (sl_composite.topControl == compositeUpdatableListPage) {
- List<Item> items = compositeUpdatableListPage.getItems();
- if (getSelectedPackageNames(items).size() <= 0) {
- return;
- }
-
- btnBack.setVisible(false);
- btnNext.setVisible(false);
- showComposite(compositeInstallingPage);
- boolean result = compositeInstallingPage.loadPage(getSelectedPackageNames(items), controller, Registry.getInstalledPath(), window, true);
-
- if (!result) {
- showComposite(compositeUpdatableListPage);
- btnBack.setVisible(true);
- btnNext.setVisible(true);
- btnClose.setEnabled(true);
- }
- } else if (sl_composite.topControl == compositeSetInstallDirectoryPage) {
- boolean installable = compositeSetInstallDirectoryPage.isInstallablePath();
-
- Config.USER_CONFIG_HOME_PATH = compositeSetInstallDirectoryPage.getSDKWorkSpacePath();
- Registry.sdkDataPath = controller.getSDKWorkSpacePath();
- Registry.targetPath = controller.getInstallPath();
- Registry.saveSDKInfo(Registry.targetPath);
-
- InstallManager.getInstance().initPackageList();
-
- if (!installable) {
- MessageBoxDlg.showDlg(
- Display.getCurrent().getShells()[0],
- "Error",
- "Not enough disk space for the installation. Select a different installation path.",
- DialogType.ERROR, false);
- return;
- }
-
- if (!compositeSetInstallDirectoryPage.isWorkSpaceDuplicate()) {
- int result = MessageBoxDlg.showDlg(
- Display.getCurrent().getShells()[0],
- "Warning",
- "Tizen SDK data directory is used already. Do you want to continue?",
- DialogType.WARNING, false);
- if (result == MessageBoxDlg.NO) {
- return;
- }
- }
-
- btnBack.setVisible(false);
- btnNext.setVisible(false);
- List<Item> items = compositeInstallableListPage.getItems();
- showComposite(compositeInstallingPage);
- boolean result = compositeInstallingPage.loadPage(getSelectedPackageNames(items),
- controller,
- compositeSetInstallDirectoryPage.getInstallPath(),
- window, false);
- if (!result) {
- showComposite(compositeInstallableListPage);
- btnBack.setVisible(true);
- btnNext.setVisible(true);
- btnClose.setEnabled(true);
- }
- } else if (sl_composite.topControl == compositeUninstallableListPage) {
- showComposite(compositeUninstallingPage);
- btnBack.setVisible(false);
- btnNext.setVisible(false);
- btnClose.setEnabled(false);
- List<Item> items = compositeUninstallableListPage.getItems();
- boolean result = compositeUninstallingPage.loadPage(getSelectedPackageNames(items) /* compositeInstallablePage.getCheckedPackageNames()*/,
- controller,
- window);
- if (!result) {
- showComposite(compositeUninstallableListPage);
- btnBack.setVisible(true);
- btnNext.setVisible(true);
- btnClose.setEnabled(true);
- }
- }
- }
- });
- btnNext.setBounds(447, 10, 78, 29);
- }
-
- private void setButtonBack(Composite composite) {
- btnBack = new Button(composite, SWT.NONE);
- btnBack.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (sl_composite.topControl == compositeInstallableListPage
- || sl_composite.topControl == compositeUpdatableListPage) {
- compositeInstallableListPage.getItems().clear();
- showComposite(compositeWelcomePage);
-// if (controller.existRemovablePackage()) {
-// btnBack.setVisible(false);
-// showComposite(compositeWelcomePage);
-// } else {
-// showComposite(compositeLicensePage);
-// }
- btnNext.setEnabled(true);
- btnNext.setText("Next");
- } else if (sl_composite.topControl == compositeLicensePage) {
- btnNext.setEnabled(true);
- btnBack.setVisible(false);
- btnNext.setFocus();
- if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.INSTALL) {
- showComposite(compositeInstallableListPage);
- btnNext.setText("Next");
- btnBack.setVisible(true);
- } else if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.UPDATE) {
- showComposite(compositeUpdatableListPage);
- btnNext.setText("Next");
- btnBack.setVisible(true);
- }
- } else if (sl_composite.topControl == compositeSetInstallDirectoryPage) {
- showComposite(compositeLicensePage);
- btnNext.setText("I agree");
- btnNext.setEnabled(true);
- } else if (sl_composite.topControl == compositeUninstallableListPage) {
- showComposite(compositeWelcomePage);
- btnNext.setText("Next");
- btnNext.setEnabled(true);
- btnBack.setVisible(false);
- }
- }
- });
- btnBack.setBounds(363, 10, 78, 29);
- btnBack.setText("Back");
- btnBack.setVisible(false);
- }
-
- private void initWelcomePage() {
- compositeWelcomePage.setViewController(controller);
-
- if (ErrorController.checkInstallationSuccess()) {
-// compositeWelcomePage.setTitle(WelcomePage.STRING_TITLE);
-// compositeWelcomePage.setSubTitleBounds(20, 190, 600, 40);
-// compositeWelcomePage.setSubTitle(WelcomePage.STRING_SUBTITLE1);
-//
-// compositeWelcomePage.setVisibleRadioButton(true);
-// btnNext.setEnabled(true);
- btnNext.setVisible(false);
- btnClose.setText("Cancel");
-
- btnClose.removeSelectionListener(closeBtnSelectionAdapter);
- btnClose.removeSelectionListener(cancelBtnSelectionAdapter);
- btnClose.addSelectionListener(cancelBtnSelectionAdapter);
-
- compositeWelcomePage.setButtonStatus();
- } else {
- compositeWelcomePage.setVisibleRadioButton(false);
- btnNext.setVisible(false);
-
- compositeWelcomePage.setTitle("Cannot start Tizen SDK Install Manager.");
-
- String errMsg = ErrorController.getErrorMessage();
- String repository = Config.getInstance().getConfigFile().getRepository();
-
- if (repository != null && !repository.isEmpty()) {
- errMsg = errMsg + "\n(" + repository + ")";
- }
- compositeWelcomePage.setSubTitleBounds(20, 190, 600, 100);
- compositeWelcomePage.setErrorSubTitle(errMsg);
-
- btnClose.setText("Close");
-
- btnClose.removeSelectionListener(closeBtnSelectionAdapter);
- btnClose.removeSelectionListener(cancelBtnSelectionAdapter);
- btnClose.addSelectionListener(closeBtnSelectionAdapter);
- }
- btnNext.setFocus();
- sl_composite.topControl = compositeWelcomePage;
-// sl_composite.topControl = compositeUninstallingPage;
- }
-
- /**
- * Refresh InstallManager.
- * Refresh packages and configuration information.
- */
- public void refresh() {
- final IndeterminateProgressDialog progressbar = IndeterminateProgressDialog.getInstance();
- final Shell shell = progressbar.getParent();
- shell.getDisplay().asyncExec(new Runnable(){
- public void run() {
- progressbar.updateName("Initializing...");
-
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- PackageManager.dispose();
- initInstallManager();
- initWelcomePage();
- }
- });
-
- //init end
- progressbar.finish();
- }
- });
-
- if (!shell.isDisposed()) {
- progressbar.open();
- }
-
- Log.log("Window refresh end");
- }
-
- /**
- * Checks if there's updatable meta package.
- * Then print "updatable" to stdout.
- */
- private static void checkMetaPackageUpdate() {
- if (PackageManager.getInstance().getUpdatableMetaPackages().size() != 0) {
- System.out.println("updatable");
- }
- }
-
- /**
- * There is no UI, just download packages.
- * @throws IMExitException
- */
- private static void onlyDownloadPackages() throws IMExitException {
- ViewController controller = new ViewController();
- controller.init();
-
- InstallManager installManager = InstallManager.getInstance();
- PackageManager packageManager = installManager.getPackageManager();
-
- // Get all meta packages list by boundary.(eg. public, partner, all....)
- PackageSet filteredMeta = filterPackageSet();
- PackageSet downloadablePkgs = packageManager.getDependsPackagesFromRepository(filteredMeta);
-
- // Download all meta packages.
- boolean filteredPackages = false;
- try {
- filteredPackages = installManager.downloadPackages(
- downloadablePkgs, null);
- } catch (IMNetworkException e) {
- Log.ExceptionLog(e);
- return;
- }
-
- if (filteredPackages) {
- Log.log("Success to download packages from repository");
- } else {
- Log.err("Fail to download packages from repository");
- return;
- }
- }
-
- private static PackageSet filterPackageSet() {
- PackageManager pm = PackageManager.getInstance();
-
- PackageSet downloadPackageList = pm.getLeafMetaPackages();
-
- String boundary = Options.boundary;
- if (boundary.equalsIgnoreCase("public")) {
- PackageSet partnerMetaPackages = pm.getPartnerMetaPackages();
-
- if (!partnerMetaPackages.isEmpty()) {
- downloadPackageList.removeAll(partnerMetaPackages);
- }
- } else if (boundary.equalsIgnoreCase("partner")) {
- PackageSet publicMetaPackages = pm.getPublicMetaPackages();
-
- if (!publicMetaPackages.isEmpty()) {
- downloadPackageList.removeAll(publicMetaPackages);
- }
- }
-
- return downloadPackageList;
- }
-
- private static void showInstallManagerVersion() {
- System.out.println("InstallManager Version : " +
- Config.getInstance().getInstallManagerVersion().toString());
- }
-
- /**
- * Logging all system information.
- */
- private static void loggingProperty() {
- Log.log("=========== System properties ===========");
- Properties sysprops = System.getProperties();
- for (Enumeration e = sysprops.propertyNames(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- String value = sysprops.getProperty(key);
- Log.log(key + " = " + value);
- }
-
- Log.log("=========== Environment variables ===========");
-
- Map<String, String> env = System.getenv();
- Set<String> set = env.keySet();
- Iterator<String> iter = set.iterator();
-
- while (iter.hasNext()) {
- String key = (String) iter.next();
- Set<Entry<String, String>> value = env.entrySet();
- Log.log(key + " = " + value);
- }
- Log.log("=============================================");
- }
-
- /**
- * Launch the application.
- *
- * @param args
- */
- public static void main(String args[]) {
- //performance measurement
- Performance.setIMStartTime();
-
- InstallManager.deleteTempFile();
-
- Log.open();
- Log.LogTitle("Installmanager start");
- Log.log(Platform.getPlatformInfo());
- Log.log(PathUtil.getCurrentDir());
-
- if (Options.propertyLogging) {
- loggingProperty();
- }
-
- try {
- Options.loadCmdArgs(args);
- } catch (IMFatalException e) {
- Log.err("Check your options. => " + Arrays.toString(args));
- System.out.println("Check your options. => " + Arrays.toString(args));
- return;
- }
-
- try {
- if (Options.onlyDownload) {
- onlyDownloadPackages();
- System.exit(0);
- } else if (Options.doInstallNoUI) {
- if (InstallManagerNoUI.cliInstall(Options.packages)) {
- Log.log("Success to command line install.");
- System.out.println("Success to console install.");
- } else {
- Log.log("Fail to command line install.");
- System.out.println("Fail to console install.");
- }
-
- Performance.setIMEndTime();
- if (Options.doTest) {
- Performance.printTestResultXmlFormat();
-// Performance.printTestResultXmlFormat2();
- }
-
- System.exit(0);
- } else if (Options.doRemoveNoUI) {
- if (InstallManagerNoUI.cliUninstall(Options.packages)) {
- Log.log("Success to command line remove.");
- System.out.println("Success to remove.");
- } else {
- Log.log("Fail to command line remove.");
- System.out.println("Fail to remove.");
- }
-
- Performance.setIMEndTime();
- if (Options.doTest) {
- Performance.printTestResultXmlFormat();
-// Performance.printTestResultXmlFormat2();
- }
-
- System.exit(0);
- } else if (Options.showVersion) {
- showInstallManagerVersion();
- System.exit(0);
- } else if (Options.doShowHelp) {
- InstallManagerNoUI.cliShowHelp();
- System.exit(0);
- }
-
- if (Platform.isMacOS()) {
- System.setProperty("apple.laf.useScreenMenuBar", "true");
- System.setProperty(
- "com.apple.mrj.application.apple.menu.about.name",
- "Emulator Manager");
- Display display = Display.getDefault();
- display.syncExec(new Runnable() {
- @Override
- public void run() {
- new CocoaUtil().removeTopMenuItems();
- }
- });
- }
-
- window = new InstallManagerWindow();
- window.setBlockOnOpen(true);
-
- window.init();
-
- Log.log("after init");
- if (Options.checkPackageUpdate) {
- checkMetaPackageUpdate();
- } else if (Options.printDepGraph) {
- InstallManager.getInstance().getPackageManager().printDepGraph();
- } else if (Options.doShowDistListNoUI) {
- InstallManagerNoUI.cliShowRepoInformation();
- } else if (Options.doShowPackageListNoUI) {
- InstallManagerNoUI.cliShowPackageList();
- } else if (Options.doShowSDKInstallStatus) {
- InstallManagerNoUI.cliShowInstallInformation();
- } else {
- window.open();
- if (Display.getCurrent() != null
- && !Display.getCurrent().isDisposed()) {
- Display.getCurrent().dispose();
- }
- }
- } catch (IMExitException e) {
- // do not remove sdk temp dir if exit for self update
- if (ErrorController.getExitCode() == Config.EXITCODE_HAS_SELF_UPDATE) {
- Options.doRemoveTempTizenSDK = false;
- }
-
- Log.log("Gracefully exit");
- } catch (Throwable e) {
- Log.err("Unexpected error occurred");
- Log.ExceptionLog(e);
-
- if (Options.doInstallNoUI || Options.doRemoveNoUI) {
- PathUtil.remove(Registry.REGISTRY_FILE_PATH);
- PathUtil.remove(Registry.MULTI_SDK_FILE_PATH);
- System.out.println("Fatal error occurred.");
- System.exit(0);
- }
-
- // show error message
- if (window != null) {
- window.open();
-
- if (Display.getCurrent() != null
- && !Display.getCurrent().isDisposed()) {
- Display.getCurrent().dispose();
- }
- }
-
- ErrorController.setExitCode(Config.EXITCODE_UNKNOWN_ERROR);
- } finally {
- if (Platform.isWindows()) {
- ProgramController.createProgramController().removeSDKTempDir();
- }
-
- //performance measurement
- Performance.setIMEndTime();
- Performance.printToLogFile();
-
- if (Options.doTest) {
- Performance.printTestResultXmlFormat();
-// Performance.printTestResultXmlFormat2();
- }
-
- Log.LogTitle("Installmanager finish");
- Log.close();
-
- if (Platform.isMacOS()) {
- System.exit(ErrorController.getExitCode());
- } else {
- if (ErrorController.getExitCode() == Config.EXITCODE_HAS_SELF_UPDATE) {
- String binary = PathUtil.get(Registry.getInstalledPath(), Config.INSTALL_MANAGER_DIRECTORY, Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER);
- try {
- Runtime.getRuntime().exec(binary);
- } catch (IOException e) {
- Log.ExceptionLog(e);
- }
- } else if (ErrorController.getExitCode() != Config.EXITCODE_NORMAL) {
- System.exit(ErrorController.getExitCode());
- }
- }
- }
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- newShell.setBackground(getBackgroundColor());
- newShell.setMinimumSize(getInitialSize());
- newShell.setSize(getInitialSize());
- newShell.setImage(getWindowIconImage());
- super.configureShell(newShell);
-
- newShell.setText("Tizen SDK Install Manager");
- }
-
- @Override
- /**
- * Install manager window is close.
- */
- public boolean close() {
- return false;
- }
-
- /**
- * Return the initial size of the window.
- */
- @Override
- protected Point getInitialSize() {
- return POINT_MAIN_WINDOW;
- }
-
- /**
- * Show the composite depending on parameter.
- * @param composite
- */
- public void showComposite(Composite composite) {
- StackLayout layout;
- if (composite.getParent().getLayout() instanceof StackLayout) {
- layout = (StackLayout) composite.getParent().getLayout();
- layout.topControl = composite;
- }
- composite.getParent().layout();
- }
-
-// private void registLicensePageListener() {
-// compositeLicensePage.getAcceptButton()
-// .addSelectionListener(new SelectionAdapter() {
-//
-// @Override
-// public void widgetSelected(SelectionEvent e) {
-// btnNext.setEnabled(compositeLicensePage.getAcceptButton()
-// .getSelection());
-// }
-// });
-// }
-
- private void registCompletePageListener() {
- compositeCompletePage.addPaintListener(new PaintListener() {
-
- @Override
- public void paintControl(PaintEvent arg0) {
- btnClose.setText("Close");
- }
- });
- }
-
- public void setNameOfCancelButton(String name) {
- btnClose.setText("Close");
- }
-
- /**
- * Get selected package names on installing
- * @param items
- * @return list of selected package names.
- */
- public List<String> getSelectedPackageNames(List<Item> items) {
- List<String> list = new ArrayList<String>();
- for (int i = 0; i < items.size(); i++) {
- items.get(i).getTerminalPackages(list, true);
- }
-
- return list;
- }
-
- /**
- * Installed packages do not have package version, installmanager will show warning dialog.
- * @return
- */
- private boolean checkVaildPkgVersion() {
- PackageSet installedPkgs = controller.getInstalledPackages();
- if (!installedPkgs.isEmpty()) {
- for (Package pkg : installedPkgs) {
- String vs = pkg.getVersion().toString();
- if (vs != "" && vs.equals("0.0.0")) {
- Log.err("Package version not found. ==> " + pkg.getPackageName());
- int confirm = MessageBoxDlg.showDlg(getShell(),
- "WARNING",
- "'" + pkg.getPackageName() + "'" + " package version is not found.\n" +
- "If you keep installing Tizen SDK, some unexpected may occur.\n" +
- "Do you want to continue?",
- DialogType.WARNING, false);
- if (confirm == MessageBoxDlg.YES) {
- return true;
- } else {
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Get install manager window object.
- * @return install manager window object.
- */
- public static InstallManagerWindow getInstallManagerWindow() {
- return window;
- }
-
- /**
- * Get complete page composite object
- * @return complete page composite object
- */
- public CompletePage getCompletePage() {
- return compositeCompletePage;
- }
-
- public LicensePage getLicensePage() {
- return compositeLicensePage;
- }
-
- public InstallableListPage getComponentSelectionPage() {
- return compositeInstallableListPage;
- }
-
- public WelcomePage getWelcomePage() {
- return compositeWelcomePage;
- }
-
- /**
- * Get setInstallDirectoryPage composite object
- * @return complete page composite object
- */
- public SetInstallDirectoryPage getSetInstallDirectoryPage() {
- return compositeSetInstallDirectoryPage;
- }
-
- public Button getNextButton() {
- return btnNext;
- }
-
- /**
- * If parameter is true, 'Next' button will be enabled. but false, 'Next' button will be disabled.
- * @param enabled
- */
- public static void setNextBtnEnabled(boolean enabled) {
- btnNext.setEnabled(enabled);
- }
-
- /**
- * If parameter is true, 'Back' button will be enabled. but false, 'Back' button will be disabled.
- * @param enabled
- */
- public static void setBackBtnEnabled(boolean enabled) {
- btnBack.setEnabled(enabled);
- }
-
- /**
- * If parameter is true, 'Cancel' button will be enabled. but false, 'Cancel' button will be disabled.
- * @param enabled
- */
- public void setCancelBtnEnabled(boolean enabled) {
- btnClose.setEnabled(enabled);
- }
-
- public ViewController getViewController() {
- return controller;
- }
-}
-
+/*\r
+* InstallManager\r
+*\r
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+*\r
+* Contact: \r
+* Wooyoung Cho <wooyoung1.cho@samsung.com>\r
+* Shihyun Kim <shihyun.kim@samsung.com>\r
+* Taeyoung Son <taeyoung2.son@samsung.com>\r
+* Yongsung kim <yongsung1.kim@samsung.com>\r
+* \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*\r
+* Contributors:\r
+* - S-Core Co., Ltd\r
+*\r
+*/\r
+\r
+package org.tizen.installmanager.ui;\r
+\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.Enumeration;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Map.Entry;\r
+import java.util.Properties;\r
+import java.util.Set;\r
+\r
+import org.eclipse.jface.window.ApplicationWindow;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.StackLayout;\r
+import org.eclipse.swt.events.PaintEvent;\r
+import org.eclipse.swt.events.PaintListener;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.graphics.RGB;\r
+import org.eclipse.swt.layout.RowData;\r
+import org.eclipse.swt.layout.RowLayout;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Layout;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.tizen.installmanager.cli.InstallManagerNoUI;\r
+import org.tizen.installmanager.core.Config;\r
+import org.tizen.installmanager.core.IMExitException;\r
+import org.tizen.installmanager.core.IMFatalException;\r
+import org.tizen.installmanager.core.InstallManager;\r
+import org.tizen.installmanager.core.Options;\r
+import org.tizen.installmanager.core.Performance;\r
+import org.tizen.installmanager.lib.ErrorController;\r
+import org.tizen.installmanager.lib.IMError;\r
+import org.tizen.installmanager.lib.Log;\r
+import org.tizen.installmanager.lib.Platform;\r
+import org.tizen.installmanager.lib.ProgramController;\r
+import org.tizen.installmanager.lib.Registry;\r
+import org.tizen.installmanager.lib.exception.IMNetworkException;\r
+import org.tizen.installmanager.lib.mac.CocoaUtil;\r
+import org.tizen.installmanager.pkg.lib.PackageManager;\r
+import org.tizen.installmanager.pkg.model.ConfigFile;\r
+import org.tizen.installmanager.pkg.model.PackageSet;\r
+import org.tizen.installmanager.ui.dialog.AddExtraRepositoryDialog;\r
+import org.tizen.installmanager.ui.dialog.IndeterminateProgressDialog;\r
+import org.tizen.installmanager.ui.dialog.MessageBoxDlg;\r
+import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;\r
+import org.tizen.installmanager.ui.dialog.ProxySettingsDialog;\r
+import org.tizen.installmanager.ui.model.Item;\r
+import org.tizen.installmanager.ui.page.CompletePage;\r
+import org.tizen.installmanager.ui.page.InstallPage;\r
+import org.tizen.installmanager.ui.page.InstallableListPage;\r
+import org.tizen.installmanager.ui.page.InstallingPage;\r
+import org.tizen.installmanager.ui.page.LicensePage;\r
+import org.tizen.installmanager.ui.page.SetInstallDirectoryPage;\r
+import org.tizen.installmanager.ui.page.UninstallableListPage;\r
+import org.tizen.installmanager.ui.page.UninstallingPage;\r
+import org.tizen.installmanager.ui.page.UpdatableListPage;\r
+import org.tizen.installmanager.ui.page.ViewController;\r
+import org.tizen.installmanager.ui.page.WelcomePage;\r
+import org.tizen.installmanager.ui.page.InstallingPage.InstallProgressMonitor;\r
+import org.tizen.installmanager.ui.page.WelcomePage.INSTALLMANAGER_ACTION;\r
+import org.tizen.installmanager.util.PathUtil;\r
+import org.tizen.installmanager.pkg.model.Package;\r
+\r
+\r
+/**\r
+ * This class is main class for install manager.\r
+ * @author Taeyoung Son <taeyoung2.son@samsung.com>\r
+ */\r
+public class InstallManagerWindow extends ApplicationWindow {\r
+ private static final RGB RGB_BACKGROUND = new RGB(242, 242, 242);\r
+\r
+ private static final Point POINT_MAIN_WINDOW = new Point(628, 478);\r
+ private static Image IMAGE_WINDOW_ICON;\r
+ private static Color COLOR_BACKGROUND;\r
+\r
+ private static InstallManagerWindow window;\r
+\r
+// private StackLayout sl_composite = new StackLayout();\r
+ public StackLayout sl_composite = new StackLayout();\r
+ private static Button btnClose;\r
+ private static Button btnBack;\r
+ private static Button btnNext;\r
+\r
+ private Composite pageComposite; // Page area\r
+ private WelcomePage compositeWelcomePage;\r
+ private LicensePage compositeLicensePage;\r
+ private InstallableListPage compositeInstallableListPage;\r
+ private UninstallableListPage compositeUninstallableListPage;\r
+ private InstallingPage compositeInstallingPage;\r
+ private UninstallingPage compositeUninstallingPage;\r
+ private CompletePage compositeCompletePage;\r
+ private SetInstallDirectoryPage compositeSetInstallDirectoryPage;\r
+ public UpdatableListPage compositeUpdatableListPage;\r
+\r
+ protected static ViewController controller;\r
+ private SelectionAdapter cancelBtnSelectionAdapter = null;\r
+ private SelectionAdapter closeBtnSelectionAdapter = null;\r
+\r
+ /**\r
+ * Create the application window.\r
+ */\r
+ public InstallManagerWindow() {\r
+ super(null);\r
+ setShellStyle(SWT.SHELL_TRIM);\r
+ setShellStyle(SWT.BORDER | SWT.TITLE);\r
+ }\r
+\r
+ /**\r
+ * Get installmanager window background color.\r
+ * @return background color\r
+ */\r
+ public static Color getBackgroundColor() {\r
+ if (COLOR_BACKGROUND == null) {\r
+ COLOR_BACKGROUND = new Color(null, RGB_BACKGROUND);\r
+ }\r
+ return COLOR_BACKGROUND;\r
+ }\r
+\r
+ private static Image getWindowIconImage() {\r
+ if (IMAGE_WINDOW_ICON == null) {\r
+ IMAGE_WINDOW_ICON = PathUtil.getImageFromResource("/res/icons/SDK_icon.png");\r
+ }\r
+ return IMAGE_WINDOW_ICON;\r
+ }\r
+\r
+ private void init() throws IMExitException{\r
+ Log.log("Window init start");\r
+ \r
+ //make waiting dialog.\r
+ final IndeterminateProgressDialog progressbar = IndeterminateProgressDialog.getInstance();\r
+ \r
+ final Shell shell = progressbar.getParent();\r
+ shell.getDisplay().asyncExec(new Runnable(){\r
+ public void run() { \r
+ //initialize installmanager\r
+ progressbar.updateName("Connecting to package server.\nIt may take a minute...");\r
+ \r
+ shell.getDisplay().asyncExec(new Runnable() {\r
+ public void run() {\r
+ initInstallManager();\r
+ }\r
+ \r
+ });\r
+ \r
+ //init end\r
+ progressbar.finish();\r
+ }\r
+ });\r
+ \r
+ if (!shell.isDisposed()) {\r
+ progressbar.open();\r
+ }\r
+\r
+ Log.log("Window init end");\r
+ }\r
+ \r
+ private void updateInstallManager(Shell shell) {\r
+ if (controller.canInstallManagerUpdate()) {\r
+ String msg = "There is a new installer on the server. \nNew install-manager will be started. \nIt may take a minute...";\r
+ MessageBoxDlg.showDlg(shell, "InstallManager", msg, DialogType.NOTIFY, false);\r
+ \r
+ controller.updateInstallManager();\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * init IM's configuation and packages information.\r
+ * @return\r
+ */\r
+ public boolean initInstallManager() {\r
+ ErrorController.setInstallationSuccess(true);\r
+ \r
+ controller = new ViewController();\r
+ \r
+ if (controller.init()) {\r
+ if (Config.isSupportMultiSDK()) {\r
+ Log.log("Multi SDK installation.");\r
+ } else {\r
+ Log.log("Single SDK installation.");\r
+ }\r
+ return true;\r
+ } else {\r
+ Log.err("InstallManager init fail.");\r
+ ErrorController.setInstallationSuccess(false);\r
+ \r
+ return false;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Create contents of the application window.\r
+ * \r
+ * @param parent\r
+ */\r
+ @Override\r
+ protected Control createContents(Composite parent) {\r
+\r
+ parent.setSize(630, 490);\r
+ IMError.setComposite(parent);\r
+ Composite container = new Composite(parent, SWT.NONE);\r
+ \r
+ // Set layout attributes.\r
+ RowLayout rl_container = new RowLayout(SWT.VERTICAL);\r
+ rl_container.spacing = 0;\r
+ rl_container.marginTop = 0;\r
+ rl_container.marginRight = 0;\r
+ rl_container.marginLeft = 0;\r
+ rl_container.marginBottom = 0;\r
+ container.setLayout(rl_container);\r
+\r
+ // Set page composite size. (image, label, etc.)\r
+ pageComposite = new Composite(container, SWT.NONE);\r
+ pageComposite.setLayoutData(new RowData(628, 405));\r
+ pageComposite.setLayout(sl_composite);\r
+ \r
+ Composite composite_buttonArea = new Composite(container, SWT.NONE);\r
+ composite_buttonArea.setLayoutData(new RowData(628, 52));\r
+ composite_buttonArea.setBackground(getBackgroundColor());\r
+\r
+ setButtonClose(composite_buttonArea);\r
+ setButtonNext(composite_buttonArea);\r
+ setButtonBack(composite_buttonArea);\r
+\r
+ compositeWelcomePage = new WelcomePage(pageComposite, SWT.NONE);\r
+ compositeLicensePage = new LicensePage(pageComposite, SWT.NONE);\r
+ compositeCompletePage = new CompletePage(pageComposite, SWT.NONE);\r
+ compositeInstallingPage = new InstallingPage(pageComposite, SWT.NONE);\r
+ compositeInstallableListPage = new InstallableListPage(pageComposite, SWT.NONE);\r
+ compositeUninstallingPage = new UninstallingPage(pageComposite, SWT.NONE);\r
+ compositeUninstallableListPage = new UninstallableListPage(pageComposite, SWT.NONE);\r
+ compositeSetInstallDirectoryPage = new SetInstallDirectoryPage(pageComposite, SWT.NONE);\r
+ compositeUpdatableListPage = new UpdatableListPage(pageComposite, SWT.NONE);\r
+\r
+// registLicensePageListener();\r
+// registCompletePageListener();\r
+\r
+ initWelcomePage();\r
+ \r
+ return container;\r
+ }\r
+\r
+ private void setButtonClose(Composite composite) {\r
+ btnClose = new Button(composite, SWT.NONE);\r
+ btnClose.setText("Cancel");\r
+ cancelBtnSelectionAdapter = new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ int result = MessageBoxDlg.NO;\r
+ if (sl_composite.topControl == compositeInstallingPage) {\r
+ InstallProgressMonitor mon = compositeInstallingPage.getInstallProgressMonitor();\r
+ mon.setCancelRequested(true);\r
+ result = MessageBoxDlg.showDlg(\r
+ e.display.getActiveShell(),\r
+ "Tizen SDK Install Manager",\r
+ "Are you sure you want to quit Install Manager?\n\nIf you click \"Yes\", the installation is stopped.",\r
+ DialogType.WARNING, false);\r
+ if (result == MessageBoxDlg.YES) {\r
+ mon.setCanceled(true);\r
+ } else {\r
+ mon.setCancelRequested(false);\r
+ }\r
+ return;\r
+ } else if (sl_composite.topControl == compositeUninstallingPage) {\r
+ result = MessageBoxDlg.showDlg(\r
+ e.display.getActiveShell(),\r
+ "Tizen SDK Install Manager",\r
+ "Are you sure to quit Install Manager?\n\nIf you click \"Yes\", the uninstallation is stopped.",\r
+ DialogType.WARNING, false);\r
+ } else if (sl_composite.topControl == compositeCompletePage) {\r
+ controller.showChangeLog();\r
+ \r
+ if (!Options.doResumeDownloading) {\r
+ controller.cleanUpTargetDirectory();\r
+ }\r
+ \r
+ result = MessageBoxDlg.YES;\r
+ } else {\r
+ result = MessageBoxDlg.showDlg(e.display.getActiveShell(),\r
+ "Tizen SDK Install Manager",\r
+ "Are you sure to quit Install Manager?",\r
+ DialogType.WARNING, false);\r
+ }\r
+ \r
+ if (result == MessageBoxDlg.YES) {\r
+ e.display.close();\r
+ }\r
+ }\r
+ };\r
+ \r
+ closeBtnSelectionAdapter = new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent arg0) {\r
+ arg0.display.close();\r
+ }\r
+ };\r
+ \r
+ btnClose.addSelectionListener(cancelBtnSelectionAdapter);\r
+ btnClose.setBounds(531, 10, 78, 29);\r
+ }\r
+ \r
+ private void setButtonNext(Composite composite) {\r
+ btnNext = new Button(composite, SWT.NONE);\r
+ btnNext.setText("Next");\r
+ btnNext.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ if (sl_composite.topControl == compositeWelcomePage) {\r
+ updateInstallManager(e.display.getActiveShell());\r
+ btnNext.setVisible(false);\r
+ if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.INSTALL) {\r
+ if (!checkVaildPkgVersion()) {\r
+ return;\r
+ }\r
+ \r
+ if (!controller.isNewInstallation()) {// Update case\r
+ Config.status = Config.Status.UPDATE;\r
+ compositeUpdatableListPage.loadPage(controller);\r
+ btnBack.setVisible(true);\r
+ btnNext.setVisible(true);\r
+ showComposite(compositeUpdatableListPage);\r
+ if (controller.existRemovablePackage()) {\r
+ btnNext.setText("Install");\r
+ }\r
+ btnBack.setVisible(true);\r
+ } else {\r
+ boolean hasItem = compositeInstallableListPage.loadPage(controller);\r
+ if (hasItem) {\r
+ Config.status = Config.Status.INSTALL;\r
+ showComposite(compositeInstallableListPage);\r
+ btnNext.setVisible(true);\r
+ btnNext.setEnabled(hasItem);\r
+ btnBack.setVisible(hasItem);\r
+ if (controller.existRemovablePackage()) {\r
+ btnNext.setText("Install");\r
+ }\r
+ } else {\r
+ Log.err("Installable packages do not exist. This is error.");\r
+ //TODO\r
+ }\r
+ }\r
+ } else if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.UPDATE) {\r
+// btnNext.setEnabled(compositeLicensePage.getAcceptButton().getSelection());\r
+ btnNext.setEnabled(true);\r
+ PackageManager.dispose();\r
+ initInstallManager();\r
+ compositeUpdatableListPage.loadPage(controller);\r
+ btnBack.setVisible(true);\r
+ showComposite(compositeUpdatableListPage);\r
+ if (controller.existRemovablePackage()) {\r
+ btnNext.setText("Install");\r
+ }\r
+ btnBack.setVisible(true);\r
+ } else if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.UNINSTALL) {\r
+ showComposite(compositeUninstallableListPage);\r
+ btnNext.setVisible(true);\r
+ btnBack.setVisible(true);\r
+ btnNext.setText("Uninstall");\r
+ compositeUninstallableListPage.loadPage(controller);\r
+// int resultDialog = MessageBoxDlg.NO;\r
+// resultDialog = MessageBoxDlg.showDlg(\r
+// e.display.getActiveShell(),\r
+// "Tizen SDK Install Manager",\r
+// "Are you sure you want to remove the Tizen SDK?\n\nIf you click \"Yes\", the Tizen SDK is uninstalled.",\r
+// DialogType.WARNING, false);\r
+// if (resultDialog == MessageBoxDlg.YES) {\r
+// showComposite(compositeUninstallingPage);\r
+// btnBack.setVisible(false);\r
+// btnNext.setVisible(false);\r
+// btnClose.setEnabled(false);\r
+// \r
+// if (Config.isSupportMultiSDK()) {\r
+// PackageManager.dispose();\r
+// initInstallManager(); \r
+// }\r
+//\r
+// List<Item> items = compositeUninstallablePage.getItems();\r
+// boolean result = compositeUninstallingPage.loadPage(getSelectedPackageNames(items) /* compositeInstallablePage.getCheckedPackageNames()*/,\r
+// controller,\r
+// window);\r
+// if (!result) {\r
+// showComposite(compositeWelcomePage);\r
+// btnBack.setVisible(true);\r
+// btnNext.setVisible(true);\r
+// btnClose.setEnabled(true);\r
+// }\r
+// } else {\r
+// return;\r
+// }\r
+ }\r
+ } else if (sl_composite.topControl == compositeInstallableListPage) {\r
+// btnNext.setEnabled(compositeLicensePage.getAcceptButton().getSelection());\r
+ btnNext.setEnabled(true);\r
+ if (Config.isSupportMultiSDK()) {\r
+ compositeLicensePage.loadPage(compositeInstallableListPage.getSelectedItems());\r
+ showComposite(compositeLicensePage);\r
+ btnBack.setVisible(true);\r
+ } else {\r
+ if (!controller.isNewInstallation()) {// Update case\r
+ compositeUpdatableListPage.loadPage(controller);\r
+ btnBack.setVisible(true);\r
+ showComposite(compositeUpdatableListPage);\r
+ if (controller.existRemovablePackage()) {\r
+ btnNext.setText("Install");\r
+ }\r
+ btnBack.setVisible(true);\r
+ } else {\r
+ //License page button status setting.\r
+ compositeLicensePage.loadPage(compositeInstallableListPage.getSelectedItems());\r
+ showComposite(compositeLicensePage);\r
+ btnNext.setText("I agree");\r
+ btnNext.setEnabled(true);\r
+ btnNext.setFocus();\r
+ btnBack.setVisible(true);\r
+ }\r
+ }\r
+ } else if (sl_composite.topControl == compositeLicensePage) {\r
+ List<Item> items = compositeInstallableListPage.getItems();\r
+ if (getSelectedPackageNames(items).size() <= 0) {\r
+ return;\r
+ }\r
+ if (Config.isSupportMultiSDK()) {\r
+ showComposite(compositeSetInstallDirectoryPage);\r
+ compositeSetInstallDirectoryPage.loadPage(\r
+ controller, compositeInstallableListPage.getCheckedPackageSize(false));\r
+// btnNext.setText("Install");\r
+ } else {\r
+ if (controller.existRemovablePackage()) { // update case\r
+ btnBack.setVisible(false);\r
+ btnNext.setVisible(false);\r
+ showComposite(compositeInstallingPage);\r
+ boolean result = compositeInstallingPage.loadPage(getSelectedPackageNames(items),\r
+ controller,\r
+ Registry.getInstalledPath(),\r
+ window, true);\r
+ if (!result) {\r
+ showComposite(compositeInstallableListPage);\r
+ btnBack.setVisible(true);\r
+ btnNext.setVisible(true);\r
+ btnClose.setEnabled(true);\r
+ }\r
+ } else {\r
+ showComposite(compositeSetInstallDirectoryPage);\r
+ compositeSetInstallDirectoryPage.loadPage(\r
+ controller, compositeInstallableListPage.getCheckedPackageSize(false));\r
+ btnNext.setText("Install");\r
+// btnNext.setVisible(false);\r
+// btnBack.setBounds(447, 10, 78, 29);\r
+ }\r
+ }\r
+ } else if (sl_composite.topControl == compositeUpdatableListPage) {\r
+ List<Item> items = compositeUpdatableListPage.getItems();\r
+ if (getSelectedPackageNames(items).size() <= 0) {\r
+ return;\r
+ }\r
+ \r
+ btnBack.setVisible(false);\r
+ btnNext.setVisible(false);\r
+ showComposite(compositeInstallingPage);\r
+ boolean result = compositeInstallingPage.loadPage(getSelectedPackageNames(items), controller, Registry.getInstalledPath(), window, true);\r
+ \r
+ if (!result) {\r
+ showComposite(compositeUpdatableListPage);\r
+ btnBack.setVisible(true);\r
+ btnNext.setVisible(true);\r
+ btnClose.setEnabled(true);\r
+ }\r
+ } else if (sl_composite.topControl == compositeSetInstallDirectoryPage) {\r
+ boolean installable = compositeSetInstallDirectoryPage.isInstallablePath();\r
+\r
+ Config.USER_CONFIG_HOME_PATH = compositeSetInstallDirectoryPage.getSDKWorkSpacePath();\r
+ Registry.sdkDataPath = controller.getSDKWorkSpacePath();\r
+ Registry.targetPath = controller.getInstallPath();\r
+ Registry.saveSDKInfo(Registry.targetPath);\r
+ \r
+ InstallManager.getInstance().initPackageList();\r
+\r
+ if (!installable) {\r
+ MessageBoxDlg.showDlg(\r
+ Display.getCurrent().getShells()[0],\r
+ "Error",\r
+ "Not enough disk space for the installation. Select a different installation path.",\r
+ DialogType.ERROR, false);\r
+ return;\r
+ }\r
+ \r
+ if (!compositeSetInstallDirectoryPage.isWorkSpaceDuplicate()) {\r
+ int result = MessageBoxDlg.showDlg(\r
+ Display.getCurrent().getShells()[0],\r
+ "Warning",\r
+ "Tizen SDK data directory is used already. Do you want to continue?",\r
+ DialogType.WARNING, false);\r
+ if (result == MessageBoxDlg.NO) {\r
+ return;\r
+ }\r
+ }\r
+\r
+ btnBack.setVisible(false);\r
+ btnNext.setVisible(false);\r
+ List<Item> items = compositeInstallableListPage.getItems();\r
+ showComposite(compositeInstallingPage);\r
+ boolean result = compositeInstallingPage.loadPage(getSelectedPackageNames(items),\r
+ controller,\r
+ compositeSetInstallDirectoryPage.getInstallPath(),\r
+ window, false);\r
+ if (!result) {\r
+ showComposite(compositeInstallableListPage);\r
+ btnBack.setVisible(true);\r
+ btnNext.setVisible(true);\r
+ btnClose.setEnabled(true);\r
+ }\r
+ } else if (sl_composite.topControl == compositeUninstallableListPage) {\r
+ showComposite(compositeUninstallingPage);\r
+ btnBack.setVisible(false);\r
+ btnNext.setVisible(false);\r
+ btnClose.setEnabled(false);\r
+ List<Item> items = compositeUninstallableListPage.getItems();\r
+ boolean result = compositeUninstallingPage.loadPage(getSelectedPackageNames(items) /* compositeInstallablePage.getCheckedPackageNames()*/,\r
+ controller,\r
+ window);\r
+ if (!result) {\r
+ showComposite(compositeUninstallableListPage);\r
+ btnBack.setVisible(true);\r
+ btnNext.setVisible(true);\r
+ btnClose.setEnabled(true);\r
+ }\r
+ }\r
+ }\r
+ });\r
+ btnNext.setBounds(447, 10, 78, 29);\r
+ }\r
+ \r
+ private void setButtonBack(Composite composite) {\r
+ btnBack = new Button(composite, SWT.NONE); \r
+ btnBack.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ if (sl_composite.topControl == compositeInstallableListPage\r
+ || sl_composite.topControl == compositeUpdatableListPage) {\r
+ compositeInstallableListPage.getItems().clear();\r
+ showComposite(compositeWelcomePage);\r
+// if (controller.existRemovablePackage()) {\r
+// btnBack.setVisible(false);\r
+// showComposite(compositeWelcomePage);\r
+// } else {\r
+// showComposite(compositeLicensePage);\r
+// }\r
+ btnNext.setEnabled(true);\r
+ btnNext.setText("Next");\r
+ } else if (sl_composite.topControl == compositeLicensePage) {\r
+ btnNext.setEnabled(true);\r
+ btnBack.setVisible(false);\r
+ btnNext.setFocus();\r
+ if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.INSTALL) {\r
+ showComposite(compositeInstallableListPage);\r
+ btnNext.setText("Next");\r
+ btnBack.setVisible(true);\r
+ } else if (compositeWelcomePage.getSelectedButton() == INSTALLMANAGER_ACTION.UPDATE) {\r
+ showComposite(compositeUpdatableListPage);\r
+ btnNext.setText("Next");\r
+ btnBack.setVisible(true);\r
+ }\r
+ } else if (sl_composite.topControl == compositeSetInstallDirectoryPage) {\r
+ showComposite(compositeLicensePage);\r
+ btnNext.setText("I agree");\r
+ btnNext.setEnabled(true);\r
+ } else if (sl_composite.topControl == compositeUninstallableListPage) {\r
+ showComposite(compositeWelcomePage);\r
+ btnNext.setText("Next");\r
+ btnNext.setEnabled(true);\r
+ btnBack.setVisible(false);\r
+ }\r
+ }\r
+ });\r
+ btnBack.setBounds(363, 10, 78, 29);\r
+ btnBack.setText("Back");\r
+ btnBack.setVisible(false);\r
+ }\r
+ \r
+ private void initWelcomePage() {\r
+ compositeWelcomePage.setViewController(controller);\r
+ \r
+ if (ErrorController.checkInstallationSuccess()) {\r
+// compositeWelcomePage.setTitle(WelcomePage.STRING_TITLE);\r
+// compositeWelcomePage.setSubTitleBounds(20, 190, 600, 40);\r
+// compositeWelcomePage.setSubTitle(WelcomePage.STRING_SUBTITLE1);\r
+// \r
+// compositeWelcomePage.setVisibleRadioButton(true);\r
+// btnNext.setEnabled(true);\r
+ btnNext.setVisible(false);\r
+ btnClose.setText("Cancel");\r
+ \r
+ btnClose.removeSelectionListener(closeBtnSelectionAdapter);\r
+ btnClose.removeSelectionListener(cancelBtnSelectionAdapter);\r
+ btnClose.addSelectionListener(cancelBtnSelectionAdapter);\r
+ \r
+ compositeWelcomePage.setButtonStatus();\r
+ } else {\r
+ compositeWelcomePage.setVisibleRadioButton(false);\r
+ btnNext.setVisible(false);\r
+ \r
+ compositeWelcomePage.setTitle("Cannot start Tizen SDK Install Manager.");\r
+ \r
+ String errMsg = ErrorController.getErrorMessage();\r
+ String repository = Config.getInstance().getConfigFile().getRepository();\r
+ \r
+ if (repository != null && !repository.isEmpty()) {\r
+ errMsg = errMsg + "\n(" + repository + ")";\r
+ }\r
+ compositeWelcomePage.setSubTitleBounds(20, 190, 600, 100);\r
+ compositeWelcomePage.setErrorSubTitle(errMsg);\r
+\r
+ btnClose.setText("Close");\r
+ \r
+ btnClose.removeSelectionListener(closeBtnSelectionAdapter);\r
+ btnClose.removeSelectionListener(cancelBtnSelectionAdapter);\r
+ btnClose.addSelectionListener(closeBtnSelectionAdapter);\r
+ }\r
+ btnNext.setFocus();\r
+ sl_composite.topControl = compositeWelcomePage;\r
+// sl_composite.topControl = compositeUninstallingPage;\r
+ }\r
+ \r
+ /**\r
+ * Refresh InstallManager. \r
+ * Refresh packages and configuration information.\r
+ */\r
+ public void refresh() {\r
+ final IndeterminateProgressDialog progressbar = IndeterminateProgressDialog.getInstance();\r
+ final Shell shell = progressbar.getParent();\r
+ shell.getDisplay().asyncExec(new Runnable(){\r
+ public void run() {\r
+ progressbar.updateName("Initializing...");\r
+ \r
+ shell.getDisplay().syncExec(new Runnable() {\r
+ public void run() {\r
+ PackageManager.dispose();\r
+ initInstallManager();\r
+ initWelcomePage();\r
+ }\r
+ });\r
+ \r
+ //init end\r
+ progressbar.finish();\r
+ }\r
+ });\r
+ \r
+ if (!shell.isDisposed()) {\r
+ progressbar.open();\r
+ }\r
+\r
+ Log.log("Window refresh end");\r
+ }\r
+\r
+ /**\r
+ * Checks if there's updatable meta package.\r
+ * Then print "updatable" to stdout.\r
+ */\r
+ private static void checkMetaPackageUpdate() {\r
+ if (PackageManager.getInstance().getUpdatableMetaPackages().size() != 0) {\r
+ System.out.println("updatable");\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * There is no UI, just download packages.\r
+ * @throws IMExitException\r
+ */\r
+ private static void onlyDownloadPackages() throws IMExitException {\r
+ ViewController controller = new ViewController();\r
+ controller.init();\r
+\r
+ InstallManager installManager = InstallManager.getInstance();\r
+ PackageManager packageManager = installManager.getPackageManager();\r
+ \r
+ // Get all meta packages list by boundary.(eg. public, partner, all....) \r
+ PackageSet filteredMeta = filterPackageSet();\r
+ PackageSet downloadablePkgs = packageManager.getDependsPackagesFromRepository(filteredMeta);\r
+ \r
+ // Download all meta packages. \r
+ boolean filteredPackages = false;\r
+ try {\r
+ filteredPackages = installManager.downloadPackages(\r
+ downloadablePkgs, null);\r
+ } catch (IMNetworkException e) {\r
+ Log.ExceptionLog(e);\r
+ return;\r
+ }\r
+ \r
+ if (filteredPackages) {\r
+ Log.log("Success to download packages from repository");\r
+ } else {\r
+ Log.err("Fail to download packages from repository");\r
+ return;\r
+ }\r
+ }\r
+ \r
+ private static PackageSet filterPackageSet() {\r
+ PackageManager pm = PackageManager.getInstance();\r
+ \r
+ PackageSet downloadPackageList = pm.getLeafMetaPackages();\r
+ \r
+ String boundary = Options.boundary;\r
+ if (boundary.equalsIgnoreCase("public")) {\r
+ PackageSet partnerMetaPackages = pm.getPartnerMetaPackages();\r
+ \r
+ if (!partnerMetaPackages.isEmpty()) {\r
+ downloadPackageList.removeAll(partnerMetaPackages);\r
+ }\r
+ } else if (boundary.equalsIgnoreCase("partner")) {\r
+ PackageSet publicMetaPackages = pm.getPublicMetaPackages();\r
+ \r
+ if (!publicMetaPackages.isEmpty()) {\r
+ downloadPackageList.removeAll(publicMetaPackages);\r
+ }\r
+ }\r
+ \r
+ return downloadPackageList;\r
+ }\r
+ \r
+ private static void showInstallManagerVersion() {\r
+ System.out.println("InstallManager Version : " + \r
+ Config.getInstance().getInstallManagerVersion().toString());\r
+ }\r
+ \r
+ /**\r
+ * Logging all system information.\r
+ */\r
+ private static void loggingProperty() {\r
+ Log.log("=========== System properties ===========");\r
+ Properties sysprops = System.getProperties();\r
+ for (Enumeration e = sysprops.propertyNames(); e.hasMoreElements();) {\r
+ String key = (String) e.nextElement();\r
+ String value = sysprops.getProperty(key);\r
+ Log.log(key + " = " + value);\r
+ }\r
+ \r
+ Log.log("=========== Environment variables ===========");\r
+\r
+ Map<String, String> env = System.getenv();\r
+ Set<String> set = env.keySet();\r
+ Iterator<String> iter = set.iterator();\r
+\r
+ while (iter.hasNext()) {\r
+ String key = (String) iter.next();\r
+ Set<Entry<String, String>> value = env.entrySet();\r
+ Log.log(key + " = " + value);\r
+ }\r
+ Log.log("=============================================");\r
+ }\r
+\r
+ /**\r
+ * Launch the application.\r
+ * \r
+ * @param args\r
+ */\r
+ public static void main(String args[]) {\r
+ //performance measurement\r
+ Performance.setIMStartTime();\r
+ \r
+ InstallManager.deleteTempFile();\r
+ \r
+ Log.open();\r
+ Log.LogTitle("Installmanager start");\r
+ Log.log(Platform.getPlatformInfo());\r
+ Log.log(PathUtil.getCurrentDir());\r
+ \r
+ if (Options.propertyLogging) {\r
+ loggingProperty();\r
+ }\r
+ \r
+ try {\r
+ Options.loadCmdArgs(args);\r
+ } catch (IMFatalException e) {\r
+ Log.err("Check your options. => " + Arrays.toString(args));\r
+ System.out.println("Check your options. => " + Arrays.toString(args));\r
+ return;\r
+ }\r
+ \r
+ try { \r
+ if (Options.onlyDownload) {\r
+ onlyDownloadPackages();\r
+ System.exit(0);\r
+ } else if (Options.doInstallNoUI) {\r
+ if (InstallManagerNoUI.cliInstall(Options.packages)) {\r
+ Log.log("Success to command line install.");\r
+ System.out.println("Success to console install.");\r
+ } else {\r
+ Log.log("Fail to command line install.");\r
+ System.out.println("Fail to console install.");\r
+ }\r
+ \r
+ Performance.setIMEndTime();\r
+ if (Options.doTest) {\r
+ Performance.printTestResultXmlFormat();\r
+// Performance.printTestResultXmlFormat2();\r
+ }\r
+ \r
+ System.exit(0);\r
+ } else if (Options.doRemoveNoUI) {\r
+ if (InstallManagerNoUI.cliUninstall(Options.packages)) {\r
+ Log.log("Success to command line remove.");\r
+ System.out.println("Success to remove.");\r
+ } else {\r
+ Log.log("Fail to command line remove.");\r
+ System.out.println("Fail to remove.");\r
+ }\r
+ \r
+ Performance.setIMEndTime();\r
+ if (Options.doTest) {\r
+ Performance.printTestResultXmlFormat();\r
+// Performance.printTestResultXmlFormat2();\r
+ }\r
+ \r
+ System.exit(0);\r
+ } else if (Options.showVersion) {\r
+ showInstallManagerVersion();\r
+ System.exit(0);\r
+ } else if (Options.doShowHelp) {\r
+ InstallManagerNoUI.cliShowHelp();\r
+ System.exit(0);\r
+ }\r
+ \r
+ if (Platform.isMacOS()) {\r
+ System.setProperty("apple.laf.useScreenMenuBar", "true");\r
+ System.setProperty(\r
+ "com.apple.mrj.application.apple.menu.about.name",\r
+ "Emulator Manager");\r
+ Display display = Display.getDefault();\r
+ display.syncExec(new Runnable() {\r
+ @Override\r
+ public void run() {\r
+ new CocoaUtil().removeTopMenuItems();\r
+ }\r
+ });\r
+ }\r
+ \r
+ window = new InstallManagerWindow();\r
+ window.setBlockOnOpen(true);\r
+ \r
+ window.init();\r
+ \r
+ Log.log("after init");\r
+ if (Options.checkPackageUpdate) {\r
+ checkMetaPackageUpdate();\r
+ } else if (Options.printDepGraph) {\r
+ InstallManager.getInstance().getPackageManager().printDepGraph();\r
+ } else if (Options.doShowDistListNoUI) {\r
+ InstallManagerNoUI.cliShowRepoInformation();\r
+ } else if (Options.doShowPackageListNoUI) {\r
+ InstallManagerNoUI.cliShowPackageList();\r
+ } else if (Options.doShowSDKInstallStatus) {\r
+ InstallManagerNoUI.cliShowInstallInformation();\r
+ } else {\r
+ window.open();\r
+ if (Display.getCurrent() != null\r
+ && !Display.getCurrent().isDisposed()) {\r
+ Display.getCurrent().dispose();\r
+ }\r
+ }\r
+ } catch (IMExitException e) {\r
+ // do not remove sdk temp dir if exit for self update\r
+ if (ErrorController.getExitCode() == Config.EXITCODE_HAS_SELF_UPDATE) {\r
+ Options.doRemoveTempTizenSDK = false;\r
+ }\r
+ \r
+ Log.log("Gracefully exit");\r
+ } catch (Throwable e) {\r
+ Log.err("Unexpected error occurred");\r
+ Log.ExceptionLog(e);\r
+ \r
+ if (Options.doInstallNoUI || Options.doRemoveNoUI) {\r
+ PathUtil.remove(Registry.REGISTRY_FILE_PATH);\r
+ PathUtil.remove(Registry.MULTI_SDK_FILE_PATH);\r
+ System.out.println("Fatal error occurred.");\r
+ System.exit(0);\r
+ }\r
+ \r
+ // show error message\r
+ if (window != null) {\r
+ window.open();\r
+ \r
+ if (Display.getCurrent() != null\r
+ && !Display.getCurrent().isDisposed()) {\r
+ Display.getCurrent().dispose();\r
+ }\r
+ }\r
+ \r
+ ErrorController.setExitCode(Config.EXITCODE_UNKNOWN_ERROR);\r
+ } finally {\r
+ if (Platform.isWindows()) {\r
+ ProgramController.createProgramController().removeSDKTempDir();\r
+ }\r
+ \r
+ //performance measurement\r
+ Performance.setIMEndTime();\r
+ Performance.printToLogFile();\r
+ \r
+ if (Options.doTest) {\r
+ Performance.printTestResultXmlFormat();\r
+// Performance.printTestResultXmlFormat2();\r
+ }\r
+ \r
+ Log.LogTitle("Installmanager finish");\r
+ Log.close();\r
+ \r
+ if (Platform.isMacOS()) {\r
+ System.exit(ErrorController.getExitCode());\r
+ } else {\r
+ if (ErrorController.getExitCode() == Config.EXITCODE_HAS_SELF_UPDATE) {\r
+ String binary = PathUtil.get(Registry.getInstalledPath(), Config.INSTALL_MANAGER_DIRECTORY, Config.EXECUTE_FILE_NAME_OF_INSTALL_MANAGER);\r
+ try {\r
+ Runtime.getRuntime().exec(binary);\r
+ } catch (IOException e) {\r
+ Log.ExceptionLog(e);\r
+ }\r
+ } else if (ErrorController.getExitCode() != Config.EXITCODE_NORMAL) {\r
+ System.exit(ErrorController.getExitCode());\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ @Override\r
+ protected void configureShell(Shell newShell) {\r
+ newShell.setBackground(getBackgroundColor());\r
+ newShell.setMinimumSize(getInitialSize());\r
+ newShell.setSize(getInitialSize());\r
+ newShell.setImage(getWindowIconImage());\r
+ super.configureShell(newShell);\r
+\r
+ newShell.setText("Tizen SDK Install Manager");\r
+ }\r
+\r
+ @Override\r
+ /**\r
+ * Install manager window is close.\r
+ */\r
+ public boolean close() {\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * Return the initial size of the window.\r
+ */\r
+ @Override\r
+ protected Point getInitialSize() {\r
+ return POINT_MAIN_WINDOW;\r
+ }\r
+\r
+ /**\r
+ * Show the composite depending on parameter.\r
+ * @param composite\r
+ */\r
+ public void showComposite(Composite composite) {\r
+ StackLayout layout;\r
+ if (composite.getParent().getLayout() instanceof StackLayout) {\r
+ layout = (StackLayout) composite.getParent().getLayout();\r
+ layout.topControl = composite;\r
+ }\r
+ composite.getParent().layout();\r
+ }\r
+\r
+// private void registLicensePageListener() {\r
+// compositeLicensePage.getAcceptButton()\r
+// .addSelectionListener(new SelectionAdapter() {\r
+//\r
+// @Override\r
+// public void widgetSelected(SelectionEvent e) {\r
+// btnNext.setEnabled(compositeLicensePage.getAcceptButton()\r
+// .getSelection());\r
+// }\r
+// });\r
+// }\r
+\r
+ private void registCompletePageListener() {\r
+ compositeCompletePage.addPaintListener(new PaintListener() {\r
+\r
+ @Override\r
+ public void paintControl(PaintEvent arg0) {\r
+ btnClose.setText("Close");\r
+ }\r
+ });\r
+ }\r
+ \r
+ public void setNameOfCancelButton(String name) {\r
+ btnClose.setText("Close");\r
+ }\r
+\r
+ /**\r
+ * Get selected package names on installing\r
+ * @param items\r
+ * @return list of selected package names.\r
+ */\r
+ public List<String> getSelectedPackageNames(List<Item> items) {\r
+ List<String> list = new ArrayList<String>();\r
+ for (int i = 0; i < items.size(); i++) {\r
+ items.get(i).getTerminalPackages(list, true);\r
+ }\r
+\r
+ return list;\r
+ }\r
+ \r
+ /**\r
+ * Installed packages do not have package version, installmanager will show warning dialog.\r
+ * @return\r
+ */\r
+ private boolean checkVaildPkgVersion() {\r
+ PackageSet installedPkgs = controller.getInstalledPackages();\r
+ if (!installedPkgs.isEmpty()) {\r
+ for (Package pkg : installedPkgs) {\r
+ String vs = pkg.getVersion().toString();\r
+ if (vs != "" && vs.equals("0.0.0")) {\r
+ Log.err("Package version not found. ==> " + pkg.getPackageName());\r
+ int confirm = MessageBoxDlg.showDlg(getShell(), \r
+ "WARNING", \r
+ "'" + pkg.getPackageName() + "'" + " package version is not found.\n" +\r
+ "If you keep installing Tizen SDK, some unexpected may occur.\n" +\r
+ "Do you want to continue?", \r
+ DialogType.WARNING, false);\r
+ if (confirm == MessageBoxDlg.YES) {\r
+ return true;\r
+ } else {\r
+ return false;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ return true;\r
+ }\r
+ \r
+ /**\r
+ * Get install manager window object.\r
+ * @return install manager window object.\r
+ */\r
+ public static InstallManagerWindow getInstallManagerWindow() {\r
+ return window;\r
+ }\r
+\r
+ /**\r
+ * Get complete page composite object\r
+ * @return complete page composite object\r
+ */\r
+ public CompletePage getCompletePage() {\r
+ return compositeCompletePage;\r
+ }\r
+ \r
+ public LicensePage getLicensePage() {\r
+ return compositeLicensePage;\r
+ }\r
+ \r
+ public InstallableListPage getComponentSelectionPage() {\r
+ return compositeInstallableListPage;\r
+ }\r
+ \r
+ public WelcomePage getWelcomePage() {\r
+ return compositeWelcomePage;\r
+ }\r
+ \r
+ /**\r
+ * Get setInstallDirectoryPage composite object\r
+ * @return complete page composite object\r
+ */\r
+ public SetInstallDirectoryPage getSetInstallDirectoryPage() {\r
+ return compositeSetInstallDirectoryPage;\r
+ }\r
+ \r
+ public Button getNextButton() {\r
+ return btnNext;\r
+ }\r
+\r
+ /**\r
+ * If parameter is true, 'Next' button will be enabled. but false, 'Next' button will be disabled.\r
+ * @param enabled\r
+ */\r
+ public static void setNextBtnEnabled(boolean enabled) {\r
+ btnNext.setEnabled(enabled);\r
+ }\r
+\r
+ /**\r
+ * If parameter is true, 'Back' button will be enabled. but false, 'Back' button will be disabled.\r
+ * @param enabled\r
+ */\r
+ public static void setBackBtnEnabled(boolean enabled) {\r
+ btnBack.setEnabled(enabled);\r
+ }\r
+\r
+ /**\r
+ * If parameter is true, 'Cancel' button will be enabled. but false, 'Cancel' button will be disabled.\r
+ * @param enabled\r
+ */\r
+ public void setCancelBtnEnabled(boolean enabled) {\r
+ btnClose.setEnabled(enabled);\r
+ }\r
+ \r
+ public ViewController getViewController() {\r
+ return controller;\r
+ }\r
+}\r
+\r
-/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
- * 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.installmanager.ui.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.tizen.installmanager.pkg.lib.PackageManager;
-import org.tizen.installmanager.pkg.model.Package;
-import org.tizen.installmanager.pkg.model.PackageSet;
-
-/**
- * This class support items for tree view.
- * @author Taeyong Son <taeyong2.son@samsung.com>
- */
-public class Item implements Comparable<Item> {
- private Package latestPackage;
- private Package installedPackage;
- private Item parent = null;
- private ArrayList<Item> children;
- private CheckState checkState= CheckState.UNCHECKED;
- private InstallState installState = InstallState.INSTALL;
- private boolean isConflict = false;
-
- /**
- * Package item status enumeration.<br>
- * INSTALL : This item need to install.<br>
- * UPDATE : This item need to update.<br>
- * UNINSTALL : This item need to uninstall.
- */
- public enum InstallState {
- INSTALL("Not installed"),
- UPDATE("Update"),
- UNINSTALL("Installed");
-
- private String msg = "";
-
- InstallState(String message) {
- this.msg = message;
- }
-
- public String getMessage() {
- return msg;
- }
- }
-
- /**
- * item check status enumeration.<br>
- * CHECKED : this item's check state is checked.<br>
- * GRAYED : this item's check state is grayed.<br>
- * UNCHECKED : this item's check state is unchecked.
- */
- public enum CheckState {
- CHECKED,
- GRAYED,
- UNCHECKED
- }
-
- /**
- * Construct Item class.
- * @param parent
- * @param name is item name.
- * @param latestVersion is the latest version of item.
- * @param installedVersion is a version of installed item already.
- * @param size is a item size.
- * @param state is a item state.
- */
- public Item(Package latestPackage, Package installedPackage, InstallState state) {
- setLatestPackage(latestPackage);
- setInstalledPackage(installedPackage);
- setInstallState(state);
-
- this.children = new ArrayList<Item>();
- }
-
- /**
- * Get display name of item.
- * @return
- */
- public String getDisplayName() {
- if (latestPackage != null) {
- return latestPackage.getLabel();
- } else {
- return "";
- }
- }
-
- /**
- * Get package name of item.
- * @return
- */
- public String getPackageName() {
- if (latestPackage != null) {
- return latestPackage.getPackageName();
- } else {
- return "";
- }
- }
-
- /**
- * Get package item current version.
- * @return
- */
- public String getLatestVersion() {
- if (latestPackage != null) {
- return latestPackage.getVersion().toString();
- } else {
- return "";
- }
- }
-
- /**
- * Get package item installed version
- * @return
- */
- public String getInstalledVersion() {
- if (installedPackage != null) {
- return installedPackage.getVersion().toString();
- } else {
- return "";
- }
- }
-
- /**
- * Get total checked items size
- * @return Checked items size
- */
- public Long getSize() {
- PackageManager pm = PackageManager.getInstance();
-
- if (pm == null) {
- return 0l;
- } else {
- long size = 0l;
- PackageSet checkedChildPackages = getCheckedPackages();
-
- if (installState == InstallState.UNINSTALL) {
- size = pm.getTotalSizeOfRemovablePackages(checkedChildPackages);
- } else {
- size = pm.getTotalSizeOfInstallablePackages(checkedChildPackages, true);
- }
-
- return size;
- }
- }
-
- private ArrayList<Item> getCheckedItems() {
- ArrayList<Item> checkedItems = getCheckedChildItems();
-
- if (this.getCheckState() == CheckState.CHECKED) {
- checkedItems.add(this);
- }
-
- return checkedItems;
- }
-
- private ArrayList<Item> getCheckedChildItems() {
- ArrayList<Item> checkedItems = new ArrayList<Item>();
-
- ArrayList<Item> childItems = getChildren();
- for (Item childItem : childItems) {
- if (childItem.getCheckState() == CheckState.CHECKED) {
- checkedItems.add(childItem);
- } else if (childItem.getCheckState() == CheckState.GRAYED) {
- checkedItems.addAll(childItem.getCheckedChildItems());
- }
- }
-
- return checkedItems;
- }
-
- private PackageSet getCheckedPackages() {
- PackageSet checkedPackages = new PackageSet();
-
- ArrayList<Item> checkedItems = getCheckedItems();
-
- for (Item checkedItem : checkedItems) {
- if (installState == InstallState.UNINSTALL) {
- checkedPackages.add(checkedItem.getInstalledPackage());
- } else {
- checkedPackages.add(checkedItem.getLatestPackage());
- }
- }
-
- return checkedPackages;
- }
-
- /**
- * Get package item order
- * @return item order
- */
- public int getPackageOrder() {
- if (latestPackage != null) {
- return latestPackage.getOrder();
- } else {
- return 0;
- }
- }
-
- /**
- * add child item on current item.
- */
- public void addChildItem(Item item) {
- this.children.add(item);
- }
-
- /**
- * Clear children items on current item.
- */
- public void clearChildrenItems() {
- this.children.clear();
- }
-
- /**
- * Get dependent package item on current item.
- * @return
- */
- public ArrayList<Item> getChildren() {
- return children;
- }
-
- /**
- * Check package is checked.
- * @return true is checked, false is unchecked.
- */
- public CheckState getCheckState() {
- return checkState;
- }
-
- /**
- * Check package has child package.
- * @return If package has children, return true. if not, return false.
- */
- public boolean hasChildren() {
- return !getChildren().isEmpty();
- }
-
- /**
- * Get parent package.
- * @return parent package.
- */
- public Item getParent() {
- return parent;
- }
-
- /**
- * Get latest package.
- * @return
- */
- public Package getLatestPackage() {
- return latestPackage;
- }
-
- /**
- * Get installed package.
- * @return
- */
- public Package getInstalledPackage() {
- return latestPackage;
- }
-
- /**
- * Get package that depends on the state.
- * @return
- */
- public Package getPackage() {
- if (this.installState == InstallState.UNINSTALL) {
- return installedPackage;
- } else {
- return latestPackage;
- }
- }
-
- /**
- * Set latest package for tree item.
- * @param pkg
- */
- public void setLatestPackage(Package pkg) {
- this.latestPackage = pkg;
- }
-
- /**
- * Set installed package for tree item.
- * @param pkg
- */
- public void setInstalledPackage(Package pkg) {
- this.installedPackage = pkg;
- }
-
- /**
- * Set parent package.
- * @param parent
- */
- public void setParent(Item parentItem) {
- parent = parentItem;
- }
-
- /**
- * Set package's checked flag.
- * @param CHECKED is true, this package is selected by tree view.
- */
- public void setCheckState(CheckState state) {
-
- this.checkState = state;
- }
-
- public void setCheckState(boolean state) {
- if (state) {
- this.checkState = CheckState.CHECKED;
- } else {
- this.checkState = CheckState.UNCHECKED;
- }
- }
-
- /**
- * Set item's state.
- * @param state
- * @see InstallState
- */
- public void setInstallState(InstallState state) {
- if (state == InstallState.UPDATE) {
- this.checkState = CheckState.CHECKED;
- } else if (state == InstallState.UNINSTALL) {
- this.checkState = CheckState.UNCHECKED;
- }
-
- this.installState = state;
- }
-
- /**
- * Get item's state
- * @return state
- * @see InstallState
- */
- public InstallState getInstallState() {
- return installState;
- }
-
- /**
- * Get item's display order
- * @return display order
- */
- public int getOrder() {
- return latestPackage.getOrder();
- }
-
- /**
- * Set state by children's state
- */
- public void setStateByChildren() {
- setCheckStateByChildren(this);
-// setInstallStateByChildren(this);
- }
-
- private void setCheckStateByChildren(Item parentItem) {
- if (parentItem.hasChildren()) {
- for (Item childItem : parentItem.getChildren()) {
- setCheckStateByChildren(childItem);
- }
-
- if (parentItem.isChildrenAllChecked()) {
- parentItem.setCheckState(CheckState.CHECKED);
- } else if (parentItem.isChildrenAllUnchecked()) {
- parentItem.setCheckState(CheckState.UNCHECKED);
- } else {
- parentItem.setCheckState(CheckState.GRAYED);
- }
- } else {
- if (parentItem.getInstallState() != InstallState.INSTALL) {
- parentItem.setCheckState(true);
- } else {
- parentItem.setCheckState(false);
- }
- }
- }
-
-
- /**
- * check children's checkbox state.
- * @return if true, children's checkbox state is all checked.
- */
- public boolean isChildrenAllChecked() {
- for (Item item : getChildren()) {
- if (item.getCheckState() != CheckState.CHECKED) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * check children's checkbox state.
- * @return if true, children's checkbox state is all unchecked.
- */
- public boolean isChildrenAllUnchecked() {
- for (Item item : getChildren()) {
- if (item.getCheckState() != CheckState.UNCHECKED) {
- return false;
- }
- }
- return true;
- }
-
- public String getInstallStateMessage() {
- if (hasChildren() || getParent() == null) {
- return "";
- } else {
- return installState.getMessage();
- }
- }
-
- /**
- * If parent item is checked, child items should be checked.
- * @param state is true, every child items' checked flag is true. false is the opposite.
- */
- public void setSubItemChecked(boolean state) {
- setCheckState(state);
-
- if (hasChildren()) {
- for (int i = 0; i < getChildren().size(); i++) {
- ((Item) getChildren().get(i)).setSubItemChecked(state);
- }
- }
- }
-
- /**
- * Check the existing children and checked flag, add to installed package list.
- * @param installList is packages list which is installed already.
- * @param checked is true, checking in box on tree view. false is the opposite.
- */
- public void getTerminalPackages(List<String> installList, boolean checked) {
- if (getCheckState() == CheckState.CHECKED) {
- if (!getPackageName().equalsIgnoreCase("EXTRAS")) {
- installList.add(getPackageName());
- }
- } else if (getCheckState() == CheckState.GRAYED) {
- for (Item childItem : getChildren()) {
- childItem.getTerminalPackages(installList, checked);
- }
- } else {
- return;
- }
- }
-
- /**
- * Get child items list.
- * @return child items list.
- */
- public List<Item> getDescendants() {
- List<Item> descendants = new ArrayList<Item>();
- descendants.add(this);
- if (hasChildren()) {
- for (int i = 0; i < getChildren().size(); i++) {
- descendants.addAll(((Item) getChildren().get(i)).getDescendants());
- }
- }
- return descendants;
- }
-
- public boolean hasGrayedChild(List<Item> grayCheckedItems) {
- for (int i = 0; i < grayCheckedItems.size(); i++) {
- for (int j = 0; j < getChildren().size(); j++) {
- if (grayCheckedItems.get(i) == getChildren().get(j)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * check children's checkbox state.
- * @return if true, child item's checkbox state is grayed.
- */
- public boolean hasGrayedChild() {
- for (Item item : getChildren()) {
- if (item.getCheckState() == CheckState.GRAYED) {
- return true;
- }
- }
- return false;
- }
-
- public void checkSuperItemGrayed(
- List<Item> grayCheckedItems, List<Item> checkedItems, List<Item> unCheckedItems) {
- if (hasChildren()) {
- boolean isAllChecked = true;
- boolean isAllUnchecked = true;
- for (int i = 0; i < getChildren().size(); i++) {
- if (((Item) getChildren().get(i)).getCheckState() == CheckState.UNCHECKED) {
- isAllChecked = false;
- } else {
- isAllUnchecked = false;
- }
- }
- if (isAllChecked == false && isAllUnchecked == false || hasGrayedChild(grayCheckedItems) == true) {
- grayCheckedItems.add(this);
-// setChecked(true);
- } else if (isAllChecked == true && isAllUnchecked == false && hasGrayedChild(grayCheckedItems) == false) {
- checkedItems.add(this);
- setCheckState(CheckState.CHECKED);
- } else if (isAllChecked == false && isAllUnchecked == true && hasGrayedChild(grayCheckedItems) == false) {
- unCheckedItems.add(this);
- setCheckState(CheckState.UNCHECKED);
- }
- }
- if (getParent() != null) {
- getParent().checkSuperItemGrayed(grayCheckedItems, checkedItems, unCheckedItems);
- }
- }
-
- public void setConflict(boolean isConflict) {
- this.isConflict = isConflict;
- }
-
- /**
- * Check the package conflict.
- * @return If true, this is conflict package.
- */
- public boolean isConflict() {
- return isConflict;
- }
-
- public String toString() {
- if (getParent() == null) {
- return getPackageName();
- } else {
- return getParent() + "/" + getPackageName();
- }
- }
-
- public int hashCode() {
- if (getParent() == null) {
- return getPackageName().hashCode();
- } else {
- return (getParent() + "/" + getPackageName()).hashCode();
- }
- }
-
- @Override
- public int compareTo(Item item) {
- int order = item.getOrder();
- if (order > getOrder()) {
- return -1;
- } else if (order == getOrder()) {
- return 0;
- } else if (order < getOrder()) {
- return 1;
- }
- return 0;
- }
-}
+/*\r
+* InstallManager\r
+*\r
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+*\r
+* Contact: \r
+* Wooyoung Cho <wooyoung1.cho@samsung.com>\r
+* Shihyun Kim <shihyun.kim@samsung.com>\r
+* Taeyoung Son <taeyoung2.son@samsung.com>\r
+* Yongsung kim <yongsung1.kim@samsung.com>\r
+* \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*\r
+* Contributors:\r
+* - S-Core Co., Ltd\r
+*\r
+*/\r
+\r
+package org.tizen.installmanager.ui.model;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.tizen.installmanager.pkg.lib.PackageManager;\r
+import org.tizen.installmanager.pkg.model.Package;\r
+import org.tizen.installmanager.pkg.model.PackageSet;\r
+\r
+/**\r
+ * This class support items for tree view. \r
+ * @author Taeyong Son <taeyong2.son@samsung.com>\r
+ */\r
+public class Item implements Comparable<Item> {\r
+ private Package repoPackage;\r
+ private Package installedPackage;\r
+ private Item parent = null;\r
+ private ArrayList<Item> children;\r
+ private CheckState checkState= CheckState.UNCHECKED;\r
+ private InstallState installState = InstallState.INSTALL;\r
+ private boolean isConflict = false;\r
+\r
+ /**\r
+ * Package item status enumeration.<br>\r
+ * INSTALL : This item need to install.<br>\r
+ * UPDATE : This item need to update.<br>\r
+ * UNINSTALL : This item need to uninstall.\r
+ */\r
+ public enum InstallState {\r
+ INSTALL("Not installed"),\r
+ UPDATE("Update"),\r
+ UNINSTALL("Installed");\r
+ \r
+ private String msg = "";\r
+ \r
+ InstallState(String message) {\r
+ this.msg = message;\r
+ }\r
+ \r
+ public String getMessage() {\r
+ return msg;\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * item check status enumeration.<br>\r
+ * CHECKED : this item's check state is checked.<br>\r
+ * GRAYED : this item's check state is grayed.<br>\r
+ * UNCHECKED : this item's check state is unchecked.\r
+ */\r
+ public enum CheckState {\r
+ CHECKED,\r
+ GRAYED,\r
+ UNCHECKED\r
+ }\r
+\r
+ /**\r
+ * Construct Item class.\r
+ * @param parent\r
+ * @param name is item name.\r
+ * @param latestVersion is the latest version of item.\r
+ * @param installedVersion is a version of installed item already. \r
+ * @param size is a item size.\r
+ * @param state is a item state.\r
+ */\r
+ public Item(Package latestPackage, Package installedPackage, InstallState state) {\r
+ setRepoPackage(latestPackage);\r
+ setInstalledPackage(installedPackage);\r
+ setInstallState(state);\r
+ \r
+ this.children = new ArrayList<Item>();\r
+ }\r
+\r
+ /**\r
+ * Get display name of item.\r
+ * @return\r
+ */\r
+ public String getDisplayName() {\r
+ if (repoPackage != null) {\r
+ return repoPackage.getLabel(); \r
+ } else {\r
+ return "";\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Get package name of item.\r
+ * @return\r
+ */\r
+ public String getPackageName() {\r
+ if (repoPackage != null) {\r
+ return repoPackage.getPackageName();\r
+ } else {\r
+ return "";\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Get package item current version.\r
+ * @return\r
+ */\r
+ public String getLatestVersion() {\r
+ if (repoPackage != null) {\r
+ return repoPackage.getVersion().toString();\r
+ } else {\r
+ return "";\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Get package item installed version\r
+ * @return\r
+ */\r
+ public String getInstalledVersion() {\r
+ if (installedPackage != null) {\r
+ return installedPackage.getVersion().toString();\r
+ } else {\r
+ return "";\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Get total checked items size \r
+ * @return Checked items size\r
+ */\r
+ public Long getSize() {\r
+ PackageManager pm = PackageManager.getInstance();\r
+ \r
+ if (pm == null) {\r
+ return 0l;\r
+ } else {\r
+ long size = 0l;\r
+ PackageSet checkedChildPackages = getCheckedPackages();\r
+ \r
+ if (installState == InstallState.UNINSTALL) {\r
+ size = pm.getTotalSizeOfRemovablePackages(checkedChildPackages);\r
+ } else {\r
+ size = pm.getTotalSizeOfInstallablePackages(checkedChildPackages, true);\r
+ }\r
+ \r
+ return size;\r
+ }\r
+ }\r
+ \r
+ private ArrayList<Item> getCheckedItems() { \r
+ ArrayList<Item> checkedItems = getCheckedChildItems();\r
+ \r
+ if (this.getCheckState() == CheckState.CHECKED) {\r
+ checkedItems.add(this);\r
+ }\r
+ \r
+ return checkedItems;\r
+ }\r
+ \r
+ private ArrayList<Item> getCheckedChildItems() {\r
+ ArrayList<Item> checkedItems = new ArrayList<Item>();\r
+ \r
+ ArrayList<Item> childItems = getChildren();\r
+ for (Item childItem : childItems) {\r
+ if (childItem.getCheckState() == CheckState.CHECKED) {\r
+ checkedItems.add(childItem);\r
+ } else if (childItem.getCheckState() == CheckState.GRAYED) {\r
+ checkedItems.addAll(childItem.getCheckedChildItems());\r
+ }\r
+ }\r
+ \r
+ return checkedItems;\r
+ }\r
+ \r
+ private PackageSet getCheckedPackages() {\r
+ PackageSet checkedPackages = new PackageSet();\r
+ \r
+ ArrayList<Item> checkedItems = getCheckedItems();\r
+ \r
+ for (Item checkedItem : checkedItems) {\r
+ if (installState == InstallState.UNINSTALL) {\r
+ checkedPackages.add(checkedItem.getInstalledPackage());\r
+ } else {\r
+ checkedPackages.add(checkedItem.getLatestPackage());\r
+ }\r
+ }\r
+ \r
+ return checkedPackages;\r
+ }\r
+ \r
+ /**\r
+ * Get package item order\r
+ * @return item order\r
+ */\r
+ public int getPackageOrder() {\r
+ if (repoPackage != null) {\r
+ return repoPackage.getOrder();\r
+ } else {\r
+ return 0;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * add child item on current item.\r
+ */\r
+ public void addChildItem(Item item) {\r
+ this.children.add(item);\r
+ }\r
+ \r
+ /**\r
+ * Clear children items on current item.\r
+ */\r
+ public void clearChildrenItems() {\r
+ this.children.clear();\r
+ }\r
+ \r
+ /**\r
+ * Get dependent package item on current item. \r
+ * @return\r
+ */\r
+ public ArrayList<Item> getChildren() {\r
+ return children;\r
+ }\r
+\r
+ /**\r
+ * Check package is checked.\r
+ * @return true is checked, false is unchecked.\r
+ */\r
+ public CheckState getCheckState() {\r
+ return checkState;\r
+ }\r
+\r
+ /**\r
+ * Check package has child package.\r
+ * @return If package has children, return true. if not, return false.\r
+ */\r
+ public boolean hasChildren() {\r
+ return !getChildren().isEmpty();\r
+ }\r
+ \r
+ /**\r
+ * Get parent package.\r
+ * @return parent package.\r
+ */\r
+ public Item getParent() { \r
+ return parent;\r
+ }\r
+ \r
+ /**\r
+ * Get latest package.\r
+ * @return\r
+ */\r
+ public Package getLatestPackage() {\r
+ return repoPackage;\r
+ }\r
+ \r
+ /**\r
+ * Get installed package.\r
+ * @return\r
+ */\r
+ public Package getInstalledPackage() {\r
+ return repoPackage;\r
+ }\r
+ \r
+ /**\r
+ * Get package that depends on the state.\r
+ * @return\r
+ */\r
+ public Package getPackage() {\r
+ if (this.installState == InstallState.UNINSTALL) {\r
+ return installedPackage;\r
+ } else {\r
+ return repoPackage;\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Set latest package for tree item.\r
+ * @param pkg\r
+ */\r
+ public void setRepoPackage(Package pkg) {\r
+ this.repoPackage = pkg;\r
+ }\r
+ \r
+ /**\r
+ * Set installed package for tree item.\r
+ * @param pkg\r
+ */\r
+ public void setInstalledPackage(Package pkg) {\r
+ this.installedPackage = pkg;\r
+ }\r
+\r
+ /**\r
+ * Set parent package.\r
+ * @param parent\r
+ */\r
+ public void setParent(Item parentItem) {\r
+ parent = parentItem;\r
+ }\r
+\r
+ /**\r
+ * Set package's checked flag.\r
+ * @param CHECKED is true, this package is selected by tree view.\r
+ */\r
+ public void setCheckState(CheckState state) {\r
+ \r
+ this.checkState = state;\r
+ }\r
+ \r
+ public void setCheckState(boolean state) {\r
+ if (state) {\r
+ this.checkState = CheckState.CHECKED;\r
+ } else {\r
+ this.checkState = CheckState.UNCHECKED;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Set item's state.\r
+ * @param state\r
+ * @see InstallState\r
+ */\r
+ public void setInstallState(InstallState state) {\r
+ if (state == InstallState.UPDATE) {\r
+ this.checkState = CheckState.CHECKED;\r
+ } else if (state == InstallState.UNINSTALL) {\r
+ this.checkState = CheckState.UNCHECKED;\r
+ }\r
+ \r
+ this.installState = state;\r
+ }\r
+\r
+ /**\r
+ * Get item's state\r
+ * @return state\r
+ * @see InstallState\r
+ */\r
+ public InstallState getInstallState() {\r
+ return installState;\r
+ }\r
+ \r
+ /**\r
+ * Get item's display order\r
+ * @return display order\r
+ */\r
+ public int getOrder() {\r
+ return repoPackage.getOrder();\r
+ }\r
+ \r
+ /**\r
+ * Set state by children's state\r
+ */\r
+ public void setStateByChildren() {\r
+ setCheckStateByChildren(this);\r
+// setInstallStateByChildren(this);\r
+ }\r
+ \r
+ private void setCheckStateByChildren(Item parentItem) {\r
+ if (parentItem.hasChildren()) {\r
+ for (Item childItem : parentItem.getChildren()) {\r
+ setCheckStateByChildren(childItem);\r
+ }\r
+ \r
+ if (parentItem.isChildrenAllChecked()) {\r
+ parentItem.setCheckState(CheckState.CHECKED);\r
+ } else if (parentItem.isChildrenAllUnchecked()) {\r
+ parentItem.setCheckState(CheckState.UNCHECKED);\r
+ } else {\r
+ parentItem.setCheckState(CheckState.GRAYED);\r
+ }\r
+ } else {\r
+ if (parentItem.getInstallState() != InstallState.INSTALL) {\r
+ parentItem.setCheckState(true);\r
+ } else {\r
+ parentItem.setCheckState(false);\r
+ }\r
+ }\r
+ }\r
+ \r
+ \r
+ /**\r
+ * check children's checkbox state.\r
+ * @return if true, children's checkbox state is all checked.\r
+ */\r
+ public boolean isChildrenAllChecked() {\r
+ for (Item item : getChildren()) {\r
+ if (item.getCheckState() != CheckState.CHECKED) {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+ \r
+ /**\r
+ * check children's checkbox state.\r
+ * @return if true, children's checkbox state is all unchecked.\r
+ */\r
+ public boolean isChildrenAllUnchecked() {\r
+ for (Item item : getChildren()) {\r
+ if (item.getCheckState() != CheckState.UNCHECKED) {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+ \r
+ public String getInstallStateMessage() {\r
+ if (hasChildren() || getParent() == null) {\r
+ return "";\r
+ } else {\r
+ return installState.getMessage();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * If parent item is checked, child items should be checked. \r
+ * @param state is true, every child items' checked flag is true. false is the opposite. \r
+ */\r
+ public void setSubItemChecked(boolean state) {\r
+ setCheckState(state);\r
+\r
+ if (hasChildren()) {\r
+ for (int i = 0; i < getChildren().size(); i++) {\r
+ ((Item) getChildren().get(i)).setSubItemChecked(state);\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Check the existing children and checked flag, add to installed package list.\r
+ * @param installList is packages list which is installed already.\r
+ * @param checked is true, checking in box on tree view. false is the opposite.\r
+ */\r
+ public void getTerminalPackages(List<String> installList, boolean checked) {\r
+ if (getCheckState() == CheckState.CHECKED) {\r
+ if (!getPackageName().equalsIgnoreCase("EXTRAS")) {\r
+ installList.add(getPackageName()); \r
+ }\r
+ } else if (getCheckState() == CheckState.GRAYED) {\r
+ for (Item childItem : getChildren()) {\r
+ childItem.getTerminalPackages(installList, checked);\r
+ }\r
+ } else {\r
+ return;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Get child items list.\r
+ * @return child items list.\r
+ */\r
+ public List<Item> getDescendants() {\r
+ List<Item> descendants = new ArrayList<Item>();\r
+ descendants.add(this);\r
+ if (hasChildren()) {\r
+ for (int i = 0; i < getChildren().size(); i++) {\r
+ descendants.addAll(((Item) getChildren().get(i)).getDescendants());\r
+ }\r
+ }\r
+ return descendants;\r
+ }\r
+ \r
+ public boolean hasGrayedChild(List<Item> grayCheckedItems) {\r
+ for (int i = 0; i < grayCheckedItems.size(); i++) {\r
+ for (int j = 0; j < getChildren().size(); j++) {\r
+ if (grayCheckedItems.get(i) == getChildren().get(j)) {\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+ \r
+ /**\r
+ * check children's checkbox state.\r
+ * @return if true, child item's checkbox state is grayed.\r
+ */\r
+ public boolean hasGrayedChild() {\r
+ for (Item item : getChildren()) {\r
+ if (item.getCheckState() == CheckState.GRAYED) {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ public void checkSuperItemGrayed(\r
+ List<Item> grayCheckedItems, List<Item> checkedItems, List<Item> unCheckedItems) {\r
+ if (hasChildren()) {\r
+ boolean isAllChecked = true;\r
+ boolean isAllUnchecked = true;\r
+ for (int i = 0; i < getChildren().size(); i++) {\r
+ if (((Item) getChildren().get(i)).getCheckState() == CheckState.UNCHECKED) {\r
+ isAllChecked = false;\r
+ } else {\r
+ isAllUnchecked = false;\r
+ }\r
+ }\r
+ if (isAllChecked == false && isAllUnchecked == false || hasGrayedChild(grayCheckedItems) == true) {\r
+ grayCheckedItems.add(this);\r
+// setChecked(true);\r
+ } else if (isAllChecked == true && isAllUnchecked == false && hasGrayedChild(grayCheckedItems) == false) {\r
+ checkedItems.add(this);\r
+ setCheckState(CheckState.CHECKED);\r
+ } else if (isAllChecked == false && isAllUnchecked == true && hasGrayedChild(grayCheckedItems) == false) {\r
+ unCheckedItems.add(this);\r
+ setCheckState(CheckState.UNCHECKED);\r
+ }\r
+ }\r
+ if (getParent() != null) {\r
+ getParent().checkSuperItemGrayed(grayCheckedItems, checkedItems, unCheckedItems);\r
+ }\r
+ }\r
+ \r
+ public void setConflict(boolean isConflict) {\r
+ this.isConflict = isConflict;\r
+ }\r
+ \r
+ /**\r
+ * Check the package conflict.\r
+ * @return If true, this is conflict package.\r
+ */\r
+ public boolean isConflict() {\r
+ return isConflict;\r
+ }\r
+ \r
+ public String toString() {\r
+ if (getParent() == null) {\r
+ return getPackageName();\r
+ } else {\r
+ return getParent() + "/" + getPackageName();\r
+ }\r
+ }\r
+ \r
+ public int hashCode() {\r
+ if (getParent() == null) {\r
+ return getPackageName().hashCode();\r
+ } else {\r
+ return (getParent() + "/" + getPackageName()).hashCode();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public int compareTo(Item item) {\r
+ int order = item.getOrder();\r
+ if (order > getOrder()) {\r
+ return -1;\r
+ } else if (order == getOrder()) {\r
+ return 0;\r
+ } else if (order < getOrder()) {\r
+ return 1;\r
+ }\r
+ return 0;\r
+ }\r
+}\r
-/*
- * InstallManager
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Wooyoung Cho <wooyoung1.cho@samsung.com>
- * Shihyun Kim <shihyun.kim@samsung.com>
- * Taeyoung Son <taeyoung2.son@samsung.com>
- * Yongsung kim <yongsung1.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.installmanager.ui.page;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.tizen.installmanager.core.Config;
-import org.tizen.installmanager.core.IMFatalException;
-import org.tizen.installmanager.core.InstallManager;
-import org.tizen.installmanager.lib.ErrorController;
-import org.tizen.installmanager.lib.IMError;
-import org.tizen.installmanager.lib.Log;
-import org.tizen.installmanager.ui.InstallManagerWindow;
-import org.tizen.installmanager.ui.dialog.AddExtraRepositoryDialog;
-import org.tizen.installmanager.ui.model.Item;
-import org.tizen.installmanager.util.PathUtil;
-import org.tizen.installmanager.pkg.lib.PackageManager;
-import org.tizen.installmanager.pkg.model.Package;
-
-/**
- * This class displays installable package list on page.
- *
- * @author Yongsung Kim <yongsung1.kim@samsung.com>
- */
-public class InstallableListPage extends PackageListPage {
-
- private static final String RSC_PATH_IMAGE = RESOURCE_PATH
- + "/install_manager_graphicmotif_002.png";
- private static final String RSC_PATH_IMAGE_NEW = RESOURCE_PATH_NEW + "/02_installation_option_bg.png";
- private static final String RSC_PATH_BUTTON_NORMAL = RESOURCE_PATH_NEW + "/btn_01_normal.png";
- private static final String RSC_PATH_BUTTON_HOVER = RESOURCE_PATH_NEW + "/btn_01_hover.png";
- private static final String RSC_PATH_BUTTON_PUSHED = RESOURCE_PATH_NEW + "/btn_01_pushed.png";
- private static final String RSC_PATH_BUTTON_SELECTED = RESOURCE_PATH_NEW + "/btn_01_selected.png";
-
- private static final String STRING_TITLE = "Select installation type";
-
- // Web, Native minimal packages name.
- private static final String TYPICAL_PACKAGE_NAME = "TYPICAL";
- private static final String MINIMAL_PACKAGE_NAME = "MINIMAL";
- private static final String WEB_MINIMAL_PACKAGE_NAME = "WEB-MINIMAL";
- private static final String NATIVE_MINIMAL_PACKAGE_NAME = "NATIVE-MINIMAL";
-
- // UI button names
- private static final String TYPICAL_BUTTON_NAME = "Typical";
- private static final String MINIMAL_BUTTON_NAME = "Minimal";
- private static final String CUSTOM_BUTTON_NAME = "Custom";
- private static final String WEB_MINIMAL_BUTTON_NAME = "Web app";
- private static final String NATIVE_MINIMAL_BUTTON_NAME = "Native app";
-
- private Composite buttonComposite;
-
- // Install Type button
- private Button typicalButton;
- private Button minimalButton;
- private Button customButton;
- private Button webMinimalButton;
- private Button nativeMinimalButton;
- private Button addExtraButton;
-
- private AddExtraRepositoryDialog extraDialog;
-
- /**
- * @param parent
- * @param style
- */
- public InstallableListPage(Composite parent, int style) {
- super(parent, style, Type.INSTALL);
-
- setLeftImageFromResource(RSC_PATH_IMAGE_NEW);
- disableTitleBounds();
- disableSubtitleBounds();
-
- setTitleLabelText(STRING_TITLE);
-
- buttonComposite = new Composite(getCustomComposite(), SWT.NONE);
-
-// buttonComposite.setSize(10, 60);
-// buttonComposite.setLocation(160, 27);
- buttonComposite.setBounds(10, 31, 134, 268);
- buttonComposite.setBackground(InstallManagerWindow.getBackgroundColor());
-// buttonComposite.setBackground(new Color(null, new RGB(159, 201, 60)));
-
- setButtons();
- }
-
- /**
- * Set Install Type radio buttons.
- */
- private void setButtons() {
- setTypicalButton();
- setMinimalButton();
- setCustomButton();
- setAddRepositoryButton();
-
- setWebMinimalButton();
- setNativeMinimalButton();
- }
-
- /**
- * Set Typical Type radio button.
- */
- private void setTypicalButton() {
- if (typicalButton == null) {
- typicalButton = new Button(buttonComposite, SWT.PUSH | SWT.LEFT);
- }
-
- typicalButton.setSelection(true);
-
- typicalButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- refreshByType(InstallType.TYPICAL);
-
-// if (viewController.hasWebNativeMinimal()) {
-// minimalLabel.setVisible(true);
-//
-// webMinimalButton.setVisible(false);
-// nativeMinimalButton.setVisible(false);
-//
-// // These checkbox button can be enabled for only Minimal button.
-// webMinimalButton.setEnabled(false);
-// nativeMinimalButton.setEnabled(false);
-// }
-
- customButton.setBounds(0, 76, 134, 34);
- addExtraButton.setBounds(0, 114, 133, 34);
- String description = viewController.getDescription(TYPICAL_PACKAGE_NAME);
- setComponentDescriptionText(description);
- }
- });
-
- typicalButton.setBounds(0, 0, 134, 34);
- typicalButton.setText(TYPICAL_BUTTON_NAME);
- typicalButton.setBackground(InstallManagerWindow.getBackgroundColor());
- typicalButton.setBackgroundImage(PathUtil.getImageFromResource(RSC_PATH_BUTTON_NORMAL));
-
-// typicalLabel = new Label(buttonComposite, SWT.NONE);
-// typicalLabel.setBounds(84, 0, 410, 17);
- }
-
- /**
- * Set Minimal Type radio button.
- */
- private void setMinimalButton() {
- if (minimalButton == null) {
- minimalButton = new Button(buttonComposite, SWT.PUSH | SWT.LEFT);
- }
-
- minimalButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (viewController.hasWebNativeMinimal()) {
- if (webMinimalButton.getSelection() && !nativeMinimalButton.getSelection()) {
- refreshByType(InstallType.WEB_MINIMAL);
- } else if (!webMinimalButton.getSelection() && nativeMinimalButton.getSelection()) {
- refreshByType(InstallType.NATIVE_MINIMAL);
- } else if (webMinimalButton.getSelection() && nativeMinimalButton.getSelection()) {
- refreshByType(InstallType.MINIMAL);
- }
- webMinimalButton.setVisible(true);
- webMinimalButton.setEnabled(true);
-
- nativeMinimalButton.setVisible(true);
- nativeMinimalButton.setEnabled(true);
- } else {
- refreshByType(InstallType.MINIMAL);
- }
- customButton.setBounds(0, 152, 134, 34);
- addExtraButton.setBounds(0, 190, 134, 34);
-
- String description = viewController.getDescription(MINIMAL_PACKAGE_NAME);
- setComponentDescriptionText(description);
- }
- });
-
- minimalButton.setBounds(0, 38, 134, 34);
- minimalButton.setText(MINIMAL_BUTTON_NAME);
- minimalButton.setBackground(InstallManagerWindow.getBackgroundColor());
- minimalButton.setBackgroundImage(PathUtil.getImageFromResource(RSC_PATH_BUTTON_NORMAL));
- }
-
- /**
- * Set Web Minimal Type checkbox button.
- */
- private void setWebMinimalButton() {
- if (webMinimalButton == null) {
- webMinimalButton = new Button(buttonComposite, SWT.CHECK);
- }
-
- webMinimalButton.setBounds(14, 76, 120, 34);
- webMinimalButton.setText(WEB_MINIMAL_BUTTON_NAME);
- webMinimalButton.setBackground(InstallManagerWindow.getBackgroundColor());
- webMinimalButton.setVisible(false);
- webMinimalButton.setEnabled(false);
- webMinimalButton.setSelection(true);
-
- webMinimalButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (webMinimalButton.getSelection()) {
- if (nativeMinimalButton.getSelection()) {
- refreshByType(InstallType.MINIMAL);
- } else {
- refreshByType(InstallType.WEB_MINIMAL);
- }
- } else {
- if (!nativeMinimalButton.getSelection()) {
- nativeMinimalButton.setSelection(true);
- }
-
- refreshByType(InstallType.NATIVE_MINIMAL);
- }
- }
- });
- }
-
- /**
- * Set Native Minimal Type checkbox button.
- */
- private void setNativeMinimalButton() {
- if (nativeMinimalButton == null) {
- nativeMinimalButton = new Button(buttonComposite, SWT.CHECK);
- }
-
- nativeMinimalButton.setBounds(14, 114, 120, 34);
- nativeMinimalButton.setText(NATIVE_MINIMAL_BUTTON_NAME);
- nativeMinimalButton.setBackground(InstallManagerWindow.getBackgroundColor());
- nativeMinimalButton.setVisible(false);
- nativeMinimalButton.setEnabled(false);
-// nativeMinimalButton.setSelection(false);
-
- nativeMinimalButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (nativeMinimalButton.getSelection()) {
- if (webMinimalButton.getSelection()) {
- refreshByType(InstallType.MINIMAL);
- } else {
- refreshByType(InstallType.NATIVE_MINIMAL);
- }
- } else {
- if (!webMinimalButton.getSelection()) {
- webMinimalButton.setSelection(true);
- }
- refreshByType(InstallType.WEB_MINIMAL);
- }
- }
- });
- }
-
- /**
- * Set Custom Type radio button.
- */
- private void setCustomButton() {
- if (customButton == null) {
- customButton = new Button(buttonComposite, SWT.PUSH | SWT.LEFT);
- }
-
- customButton.setBounds(0, 76, 134, 34);
- customButton.setText(CUSTOM_BUTTON_NAME);
- customButton.setBackground(InstallManagerWindow.getBackgroundColor());
-
- customButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
-// if (viewController.hasWebNativeMinimal()) {
-// minimalLabel.setVisible(true);
-//
-// webMinimalButton.setVisible(false);
-// nativeMinimalButton.setVisible(false);
-//
-// // These checkbox button can be enabled for only Minimal button.
-// webMinimalButton.setEnabled(false);
-// nativeMinimalButton.setEnabled(false);
-//
-// setComponentDescriptionText("Position your mouse pointer over an item to view its description.");
-// }
- checkboxTreeViewer.getTree().setEnabled(true);
- setComponentDescriptionText("Position your mouse pointer over an item to view its description.");
- }
- });
- }
-
- /**
- * Set add Repository button.
- */
- private void setAddRepositoryButton() {
- if (addExtraButton == null) {
- addExtraButton = new Button(buttonComposite ,SWT.NONE | SWT.LEFT);
- }
-
- addExtraButton.setBounds(0, 114, 133, 34);
- addExtraButton.setText("Extra repository");
- addExtraButton.setBackground(InstallManagerWindow.getBackgroundColor());
-
- addExtraButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- extraDialog = new AddExtraRepositoryDialog(buttonComposite.getShell(), viewController);
- extraDialog.open();
- loadPage(InstallManagerWindow.getInstallManagerWindow().getViewController());
- }
- });
- }
-
- /**
- * When a install type is changed, components size and tree checked status are should be changed.
- * @param installType
- */
- private void refreshByType(InstallType instType) {
- String iType = null;
-
- if (instType == InstallType.TYPICAL) {
- iType = TYPICAL_PACKAGE_NAME;
- } else if (instType == InstallType.MINIMAL) {
- iType = MINIMAL_PACKAGE_NAME;
- } else if (instType == InstallType.WEB_MINIMAL) {
- iType = WEB_MINIMAL_PACKAGE_NAME;
- } else if (instType == InstallType.NATIVE_MINIMAL) {
- iType = NATIVE_MINIMAL_PACKAGE_NAME;
- }
-
- setCheckedByType(iType);
-
- checkboxTreeViewer.getTree().setEnabled(false);
- checkboxTreeViewer.refresh();
-
- lblRequiredSize.setText("Download size : "
- + convertToVolumeSize(getCheckedPackageSize(false)));
- lblUncompressedSize.setText("Install size : "
- + convertToVolumeSize(getCheckedPackageSize(true)));
- setNextBtnEnabledAboutCheckedPackageCount();
- }
-
- /**
- * Check tree item by each install type.
- */
- private void setCheckedByType(String installType) {
- if (installType == null || installType.isEmpty()) {
- Log.err("Install type is empty. check install type or package server is old.");
- }
-
- Package pkg = InstallManager.getInstance().getPackageManager().getPackageByName(installType);
-
- if (pkg == null) {
- Log.err(installType + " do not exist in package list.");
- return;
- }
-
- Collection<Item> checkedItems = new ArrayList<Item>();
-
- for (String pkgName : pkg.getDependentPackageNames()) {
- Item item = findItem(pkgName, items);
-
- if (item != null) {
- checkedItems.add(item);
- }
- }
-
- setCheckedItem(checkedItems);
- }
-
- private void setCheckedItem(Collection<Item> itemList) {
- checkboxTreeViewer.setCheckedElements(itemList.toArray());
-
- // refresh tree item. All of items are unchecked.
- setAllChecked(false);
-
- // check selected item.
- for (Item item : itemList) {
- setCheckbox(item, true);
- }
- }
-
- /**
- * Initialize minimal selection when installable page is re-loaded.
- */
- private void initMinimalSetting() {
- webMinimalButton.setSelection(true);
- nativeMinimalButton.setSelection(false);
-
- webMinimalButton.setVisible(false);
- nativeMinimalButton.setVisible(false);
- }
-
- /**
- * Display installable package list from view controller.
- */
- public boolean loadPage(ViewController controller) {
- this.viewController = controller;
- getItems().clear();
-
- // back to next on component selection page case.
- // in this case, page status should be typical selection case.
- if (customButton.getSelection()) {
- customButton.setSelection(false);
- typicalButton.setSelection(true);
- } else if (minimalButton.getSelection()) {
- minimalButton.setSelection(false);
- typicalButton.setSelection(true);
- }
-
- initMinimalSetting();
-
- try {
- if (Config.isSupportMultiSDK()) {
- loadPackagesToTreeViewer(viewController.getAllMetaPackages(), Type.INSTALL);
- } else {
- loadPackagesToTreeViewer(viewController.getInstallableMetaPackageList(), Type.INSTALL);
- }
- viewController.loadSdkExtension();
- addExtensionPackagesToExtra(viewController.getRootMetaPackageListOfExtension());
-
- } catch (IMFatalException fatalException) {
- Log.err(ErrorController.getErrorMessage());
- IMError.fatalError(ErrorController.getErrorMessage());
- }
-
- checkboxTreeViewer.refresh();
-
- if (getItems().size() <= 0) {
- return false;
- }
-
- refreshByType(InstallType.TYPICAL);
-
- initDescriptionToInstallType();
-
- return true;
- }
-
- private void initDescriptionToInstallType() {
- PackageManager pm = PackageManager.getInstance();
-
- //set typical description
- String typicalExplain = "";
- Package typicalPackage = pm.getPackageByName(TYPICAL_PACKAGE_NAME);
- if (typicalPackage != null) {
- typicalExplain = typicalPackage.getDescription();
- }
-
- //set minimal description
- String minimalExplain = "";
- Package minimalPackage = pm.getPackageByName(MINIMAL_PACKAGE_NAME);
- if (minimalPackage != null) {
- minimalExplain = minimalPackage.getDescription();
- }
-
- String description = viewController.getDescription(TYPICAL_PACKAGE_NAME);
- setComponentDescriptionText(description);
- }
-
- /**
- * Find item which should be checked in component tree.
- *
- * @param name
- * the name of item which should be checked.
- * @param itemList
- * @return item which should be checked in component tree.
- */
- private Item findItem(String name, Collection<Item> itemList) {
- Item retItem = null;
- for (Item item : itemList) {
- if (name.equalsIgnoreCase(item.getPackageName())) {
- return item;
- } else {
- Collection<Item> childItemList = item.getChildren();
-
- if (childItemList.size() > 0) {
- retItem = findItem(name, childItemList);
-
- if (retItem != null) {
- break;
- }
- }
- }
- }
- return retItem;
- }
-
- public CheckboxTreeViewer getCheckboxTreeViewer() {
- return checkboxTreeViewer;
- }
-}
-
+/*\r
+ * InstallManager\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>\r
+ * Shihyun Kim <shihyun.kim@samsung.com>\r
+ * Taeyoung Son <taeyoung2.son@samsung.com>\r
+ * Yongsung kim <yongsung1.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
+\r
+package org.tizen.installmanager.ui.page;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.eclipse.jface.viewers.CheckboxTreeViewer;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.RGB;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.tizen.installmanager.core.Config;\r
+import org.tizen.installmanager.core.IMFatalException;\r
+import org.tizen.installmanager.core.InstallManager;\r
+import org.tizen.installmanager.lib.ErrorController;\r
+import org.tizen.installmanager.lib.IMError;\r
+import org.tizen.installmanager.lib.Log;\r
+import org.tizen.installmanager.ui.InstallManagerWindow;\r
+import org.tizen.installmanager.ui.dialog.AddExtraRepositoryDialog;\r
+import org.tizen.installmanager.ui.model.Item;\r
+import org.tizen.installmanager.util.PathUtil;\r
+import org.tizen.installmanager.pkg.lib.PackageManager;\r
+import org.tizen.installmanager.pkg.model.Package;\r
+\r
+/**\r
+ * This class displays installable package list on page.\r
+ * \r
+ * @author Yongsung Kim <yongsung1.kim@samsung.com>\r
+ */\r
+public class InstallableListPage extends PackageListPage {\r
+\r
+ private static final String RSC_PATH_IMAGE = RESOURCE_PATH\r
+ + "/install_manager_graphicmotif_002.png";\r
+ private static final String RSC_PATH_IMAGE_NEW = RESOURCE_PATH_NEW + "/02_installation_option_bg.png";\r
+ private static final String RSC_PATH_BUTTON_NORMAL = RESOURCE_PATH_NEW + "/btn_01_normal.png";\r
+ private static final String RSC_PATH_BUTTON_HOVER = RESOURCE_PATH_NEW + "/btn_01_hover.png";\r
+ private static final String RSC_PATH_BUTTON_PUSHED = RESOURCE_PATH_NEW + "/btn_01_pushed.png";\r
+ private static final String RSC_PATH_BUTTON_SELECTED = RESOURCE_PATH_NEW + "/btn_01_selected.png";\r
+ \r
+ private static final String STRING_TITLE = "Select installation type";\r
+ \r
+ // Web, Native minimal packages name.\r
+ private static final String TYPICAL_PACKAGE_NAME = "TYPICAL";\r
+ private static final String MINIMAL_PACKAGE_NAME = "MINIMAL";\r
+ private static final String WEB_MINIMAL_PACKAGE_NAME = "WEB-MINIMAL";\r
+ private static final String NATIVE_MINIMAL_PACKAGE_NAME = "NATIVE-MINIMAL";\r
+\r
+ // UI button names\r
+ private static final String TYPICAL_BUTTON_NAME = "Typical";\r
+ private static final String MINIMAL_BUTTON_NAME = "Minimal";\r
+ private static final String CUSTOM_BUTTON_NAME = "Custom";\r
+ private static final String WEB_MINIMAL_BUTTON_NAME = "Web app";\r
+ private static final String NATIVE_MINIMAL_BUTTON_NAME = "Native app";\r
+\r
+ private Composite buttonComposite;\r
+\r
+ // Install Type button\r
+ private Button typicalButton;\r
+ private Button minimalButton;\r
+ private Button customButton;\r
+ private Button webMinimalButton;\r
+ private Button nativeMinimalButton;\r
+ private Button addExtraButton;\r
+\r
+ private AddExtraRepositoryDialog extraDialog;\r
+ \r
+ /**\r
+ * @param parent\r
+ * @param style\r
+ */\r
+ public InstallableListPage(Composite parent, int style) {\r
+ super(parent, style, Type.INSTALL);\r
+\r
+ setLeftImageFromResource(RSC_PATH_IMAGE_NEW);\r
+ disableTitleBounds();\r
+ disableSubtitleBounds();\r
+ \r
+ setTitleLabelText(STRING_TITLE);\r
+ \r
+ buttonComposite = new Composite(getCustomComposite(), SWT.NONE);\r
+// buttonComposite.setSize(10, 60);\r
+// buttonComposite.setLocation(160, 27);\r
+ buttonComposite.setBounds(10, 31, 134, 268);\r
+ buttonComposite.setBackground(InstallManagerWindow.getBackgroundColor());\r
+// buttonComposite.setBackground(new Color(null, new RGB(159, 201, 60)));\r
+ \r
+ setButtons();\r
+ }\r
+\r
+ /**\r
+ * Set Install Type radio buttons.\r
+ */\r
+ private void setButtons() {\r
+ setTypicalButton();\r
+ setMinimalButton();\r
+ setCustomButton();\r
+ setAddRepositoryButton();\r
+ \r
+ setWebMinimalButton();\r
+ setNativeMinimalButton();\r
+ }\r
+\r
+ /**\r
+ * Set Typical Type radio button.\r
+ */\r
+ private void setTypicalButton() {\r
+ if (typicalButton == null) {\r
+ typicalButton = new Button(buttonComposite, SWT.PUSH | SWT.LEFT);\r
+ }\r
+\r
+ typicalButton.setSelection(true);\r
+\r
+ typicalButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ refreshByType(InstallType.TYPICAL);\r
+ \r
+// if (viewController.hasWebNativeMinimal()) {\r
+// minimalLabel.setVisible(true);\r
+// \r
+// webMinimalButton.setVisible(false);\r
+// nativeMinimalButton.setVisible(false);\r
+// \r
+// // These checkbox button can be enabled for only Minimal button.\r
+// webMinimalButton.setEnabled(false);\r
+// nativeMinimalButton.setEnabled(false); \r
+// }\r
+\r
+ customButton.setBounds(0, 76, 134, 34);\r
+ addExtraButton.setBounds(0, 114, 133, 34);\r
+ String description = viewController.getDescription(TYPICAL_PACKAGE_NAME);\r
+ setComponentDescriptionText(description);\r
+ }\r
+ });\r
+\r
+ typicalButton.setBounds(0, 0, 134, 34);\r
+ typicalButton.setText(TYPICAL_BUTTON_NAME);\r
+ typicalButton.setBackground(InstallManagerWindow.getBackgroundColor());\r
+ typicalButton.setBackgroundImage(PathUtil.getImageFromResource(RSC_PATH_BUTTON_NORMAL));\r
+\r
+// typicalLabel = new Label(buttonComposite, SWT.NONE);\r
+// typicalLabel.setBounds(84, 0, 410, 17);\r
+ }\r
+\r
+ /**\r
+ * Set Minimal Type radio button.\r
+ */\r
+ private void setMinimalButton() {\r
+ if (minimalButton == null) {\r
+ minimalButton = new Button(buttonComposite, SWT.PUSH | SWT.LEFT);\r
+ }\r
+\r
+ minimalButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ if (viewController.hasWebNativeMinimal()) {\r
+ if (webMinimalButton.getSelection() && !nativeMinimalButton.getSelection()) {\r
+ refreshByType(InstallType.WEB_MINIMAL);\r
+ } else if (!webMinimalButton.getSelection() && nativeMinimalButton.getSelection()) {\r
+ refreshByType(InstallType.NATIVE_MINIMAL);\r
+ } else if (webMinimalButton.getSelection() && nativeMinimalButton.getSelection()) {\r
+ refreshByType(InstallType.MINIMAL);\r
+ }\r
+ webMinimalButton.setVisible(true);\r
+ webMinimalButton.setEnabled(true);\r
+ \r
+ nativeMinimalButton.setVisible(true);\r
+ nativeMinimalButton.setEnabled(true);\r
+ } else {\r
+ refreshByType(InstallType.MINIMAL);\r
+ }\r
+ customButton.setBounds(0, 152, 134, 34);\r
+ addExtraButton.setBounds(0, 190, 134, 34);\r
+ \r
+ String description = viewController.getDescription(MINIMAL_PACKAGE_NAME);\r
+ setComponentDescriptionText(description);\r
+ }\r
+ });\r
+\r
+ minimalButton.setBounds(0, 38, 134, 34);\r
+ minimalButton.setText(MINIMAL_BUTTON_NAME);\r
+ minimalButton.setBackground(InstallManagerWindow.getBackgroundColor());\r
+ minimalButton.setBackgroundImage(PathUtil.getImageFromResource(RSC_PATH_BUTTON_NORMAL));\r
+ }\r
+ \r
+ /**\r
+ * Set Web Minimal Type checkbox button.\r
+ */\r
+ private void setWebMinimalButton() {\r
+ if (webMinimalButton == null) {\r
+ webMinimalButton = new Button(buttonComposite, SWT.CHECK);\r
+ }\r
+\r
+ webMinimalButton.setBounds(14, 76, 120, 34);\r
+ webMinimalButton.setText(WEB_MINIMAL_BUTTON_NAME);\r
+ webMinimalButton.setBackground(InstallManagerWindow.getBackgroundColor());\r
+ webMinimalButton.setVisible(false);\r
+ webMinimalButton.setEnabled(false);\r
+ webMinimalButton.setSelection(true);\r
+ \r
+ webMinimalButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ if (webMinimalButton.getSelection()) {\r
+ if (nativeMinimalButton.getSelection()) {\r
+ refreshByType(InstallType.MINIMAL);\r
+ } else {\r
+ refreshByType(InstallType.WEB_MINIMAL); \r
+ }\r
+ } else {\r
+ if (!nativeMinimalButton.getSelection()) {\r
+ nativeMinimalButton.setSelection(true);\r
+ }\r
+ \r
+ refreshByType(InstallType.NATIVE_MINIMAL);\r
+ }\r
+ }\r
+ });\r
+ }\r
+ \r
+ /**\r
+ * Set Native Minimal Type checkbox button.\r
+ */\r
+ private void setNativeMinimalButton() {\r
+ if (nativeMinimalButton == null) {\r
+ nativeMinimalButton = new Button(buttonComposite, SWT.CHECK);\r
+ }\r
+ \r
+ nativeMinimalButton.setBounds(14, 114, 120, 34);\r
+ nativeMinimalButton.setText(NATIVE_MINIMAL_BUTTON_NAME);\r
+ nativeMinimalButton.setBackground(InstallManagerWindow.getBackgroundColor());\r
+ nativeMinimalButton.setVisible(false);\r
+ nativeMinimalButton.setEnabled(false);\r
+// nativeMinimalButton.setSelection(false);\r
+ \r
+ nativeMinimalButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ if (nativeMinimalButton.getSelection()) {\r
+ if (webMinimalButton.getSelection()) {\r
+ refreshByType(InstallType.MINIMAL);\r
+ } else {\r
+ refreshByType(InstallType.NATIVE_MINIMAL); \r
+ }\r
+ } else {\r
+ if (!webMinimalButton.getSelection()) {\r
+ webMinimalButton.setSelection(true);\r
+ }\r
+ refreshByType(InstallType.WEB_MINIMAL);\r
+ }\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Set Custom Type radio button.\r
+ */\r
+ private void setCustomButton() {\r
+ if (customButton == null) {\r
+ customButton = new Button(buttonComposite, SWT.PUSH | SWT.LEFT);\r
+ }\r
+\r
+ customButton.setBounds(0, 76, 134, 34);\r
+ customButton.setText(CUSTOM_BUTTON_NAME);\r
+ customButton.setBackground(InstallManagerWindow.getBackgroundColor());\r
+\r
+ customButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+// if (viewController.hasWebNativeMinimal()) {\r
+// minimalLabel.setVisible(true);\r
+// \r
+// webMinimalButton.setVisible(false);\r
+// nativeMinimalButton.setVisible(false);\r
+// \r
+// // These checkbox button can be enabled for only Minimal button.\r
+// webMinimalButton.setEnabled(false);\r
+// nativeMinimalButton.setEnabled(false);\r
+// \r
+// setComponentDescriptionText("Position your mouse pointer over an item to view its description."); \r
+// }\r
+ checkboxTreeViewer.getTree().setEnabled(true);\r
+ setComponentDescriptionText("Position your mouse pointer over an item to view its description.");\r
+ }\r
+ });\r
+ }\r
+ \r
+ /**\r
+ * Set add Repository button. \r
+ */\r
+ private void setAddRepositoryButton() {\r
+ if (addExtraButton == null) {\r
+ addExtraButton = new Button(buttonComposite ,SWT.NONE | SWT.LEFT); \r
+ }\r
+\r
+ addExtraButton.setBounds(0, 114, 133, 34);\r
+ addExtraButton.setText("Extra repository");\r
+ addExtraButton.setBackground(InstallManagerWindow.getBackgroundColor());\r
+ \r
+ addExtraButton.addSelectionListener(new SelectionAdapter() {\r
+ public void widgetSelected(SelectionEvent e) {\r
+ extraDialog = new AddExtraRepositoryDialog(buttonComposite.getShell(), viewController);\r
+ extraDialog.open();\r
+ loadPage(InstallManagerWindow.getInstallManagerWindow().getViewController());\r
+ }\r
+ });\r
+ }\r
+ \r
+ /**\r
+ * When a install type is changed, components size and tree checked status are should be changed.\r
+ * @param installType\r
+ */\r
+ private void refreshByType(InstallType instType) {\r
+ String iType = null;\r
+\r
+ if (instType == InstallType.TYPICAL) {\r
+ iType = TYPICAL_PACKAGE_NAME;\r
+ } else if (instType == InstallType.MINIMAL) {\r
+ iType = MINIMAL_PACKAGE_NAME;\r
+ } else if (instType == InstallType.WEB_MINIMAL) {\r
+ iType = WEB_MINIMAL_PACKAGE_NAME;\r
+ } else if (instType == InstallType.NATIVE_MINIMAL) {\r
+ iType = NATIVE_MINIMAL_PACKAGE_NAME;\r
+ }\r
+\r
+ setCheckedByType(iType);\r
+\r
+ checkboxTreeViewer.getTree().setEnabled(false);\r
+ checkboxTreeViewer.refresh();\r
+ \r
+ lblRequiredSize.setText("Download size : "\r
+ + convertToVolumeSize(getCheckedPackageSize(false)));\r
+ lblUncompressedSize.setText("Install size : "\r
+ + convertToVolumeSize(getCheckedPackageSize(true)));\r
+ setNextBtnEnabledAboutCheckedPackageCount();\r
+ }\r
+\r
+ /**\r
+ * Check tree item by each install type.\r
+ */\r
+ private void setCheckedByType(String installType) {\r
+ if (installType == null || installType.isEmpty()) {\r
+ Log.err("Install type is empty. check install type or package server is old.");\r
+ }\r
+\r
+ Package pkg = InstallManager.getInstance().getPackageManager().getPackageByName(installType);\r
+\r
+ if (pkg == null) {\r
+ Log.err(installType + " do not exist in package list.");\r
+ return;\r
+ }\r
+\r
+ Collection<Item> checkedItems = new ArrayList<Item>();\r
+\r
+ for (String pkgName : pkg.getDependentPackageNames()) {\r
+ Item item = findItem(pkgName, items);\r
+\r
+ if (item != null) {\r
+ checkedItems.add(item);\r
+ }\r
+ }\r
+\r
+ setCheckedItem(checkedItems);\r
+ }\r
+\r
+ private void setCheckedItem(Collection<Item> itemList) {\r
+ checkboxTreeViewer.setCheckedElements(itemList.toArray());\r
+\r
+ // refresh tree item. All of items are unchecked.\r
+ setAllChecked(false);\r
+\r
+ // check selected item.\r
+ for (Item item : itemList) {\r
+ setCheckbox(item, true);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Initialize minimal selection when installable page is re-loaded.\r
+ */\r
+ private void initMinimalSetting() {\r
+ webMinimalButton.setSelection(true);\r
+ nativeMinimalButton.setSelection(false);\r
+ \r
+ webMinimalButton.setVisible(false);\r
+ nativeMinimalButton.setVisible(false); \r
+ }\r
+ \r
+ /**\r
+ * Display installable package list from view controller.\r
+ */\r
+ public boolean loadPage(ViewController controller) {\r
+ this.viewController = controller;\r
+ getItems().clear();\r
+\r
+ // back to next on component selection page case.\r
+ // in this case, page status should be typical selection case.\r
+ if (customButton.getSelection()) {\r
+ customButton.setSelection(false);\r
+ typicalButton.setSelection(true);\r
+ } else if (minimalButton.getSelection()) {\r
+ minimalButton.setSelection(false);\r
+ typicalButton.setSelection(true);\r
+ }\r
+ \r
+ initMinimalSetting();\r
+\r
+ try {\r
+ if (Config.isSupportMultiSDK()) {\r
+ loadPackagesToTreeViewer(viewController.getAllMetaPackages(), Type.INSTALL);\r
+ } else {\r
+ loadPackagesToTreeViewer(viewController.getInstallableMetaPackageList(), Type.INSTALL); \r
+ }\r
+ viewController.loadSdkExtension();\r
+ addExtensionPackagesToExtra(viewController.getRootMetaPackageListOfExtension());\r
+ \r
+ } catch (IMFatalException fatalException) {\r
+ Log.err(ErrorController.getErrorMessage());\r
+ IMError.fatalError(ErrorController.getErrorMessage());\r
+ }\r
+\r
+ checkboxTreeViewer.refresh();\r
+\r
+ if (getItems().size() <= 0) {\r
+ return false;\r
+ }\r
+ \r
+ refreshByType(InstallType.TYPICAL);\r
+\r
+ initDescriptionToInstallType();\r
+\r
+ return true;\r
+ }\r
+ \r
+ private void initDescriptionToInstallType() {\r
+ PackageManager pm = PackageManager.getInstance();\r
+ \r
+ //set typical description\r
+ String typicalExplain = "";\r
+ Package typicalPackage = pm.getPackageByName(TYPICAL_PACKAGE_NAME);\r
+ if (typicalPackage != null) {\r
+ typicalExplain = typicalPackage.getDescription();\r
+ }\r
+ \r
+ //set minimal description \r
+ String minimalExplain = "";\r
+ Package minimalPackage = pm.getPackageByName(MINIMAL_PACKAGE_NAME);\r
+ if (minimalPackage != null) {\r
+ minimalExplain = minimalPackage.getDescription();\r
+ }\r
+ \r
+ String description = viewController.getDescription(TYPICAL_PACKAGE_NAME);\r
+ setComponentDescriptionText(description);\r
+ }\r
+\r
+ /**\r
+ * Find item which should be checked in component tree.\r
+ * \r
+ * @param name\r
+ * the name of item which should be checked.\r
+ * @param itemList\r
+ * @return item which should be checked in component tree.\r
+ */\r
+ private Item findItem(String name, Collection<Item> itemList) {\r
+ Item retItem = null;\r
+ for (Item item : itemList) {\r
+ if (name.equalsIgnoreCase(item.getPackageName())) {\r
+ return item;\r
+ } else {\r
+ Collection<Item> childItemList = item.getChildren();\r
+\r
+ if (childItemList.size() > 0) {\r
+ retItem = findItem(name, childItemList);\r
+\r
+ if (retItem != null) {\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ return retItem;\r
+ }\r
+ \r
+ public CheckboxTreeViewer getCheckboxTreeViewer() {\r
+ return checkboxTreeViewer;\r
+ }\r
+}\r
+\r
-/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
- * 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.installmanager.ui.page;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.installmanager.util.PathUtil;
-
-
-/**
- * @author Taeyoung Son <taeyoung2.son@samsung.com>
- *
- */
-public class LicensePage extends PageTemplate {
- private static final String RSC_PATH_IMAGE_NEW = RESOURCE_PATH_NEW + "/03_software_license_agreement_bg.png";
-
- private StyledText txtLicense;
-
- /**
- * Set basic environment of license page.
- * @param parent
- * @param style
- */
- public LicensePage(Composite parent, int style) {
- super(parent, style, true);
-
- setLeftImageFromResource(RSC_PATH_IMAGE_NEW);
- disableTitleBounds();
- disableSubtitleBounds();
-
- txtLicense = new StyledText(
- customComposite, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
- txtLicense.setBounds(10, 14, 608, 282);
-
- String txt = PathUtil.readAllTextFromResource("/res/COPYING");
- txtLicense.setText(txt);
- txtLicense.setLineAlignment(1, 1, SWT.CENTER);
- }
-}
+/*\r
+ * InstallManager\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>\r
+ * Shihyun Kim <shihyun.kim@samsung.com>\r
+ * Taeyoung Son <taeyoung2.son@samsung.com>\r
+ * Yongsung kim <yongsung1.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
+\r
+package org.tizen.installmanager.ui.page;\r
+\r
+import java.util.List;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.ScrolledComposite;\r
+import org.eclipse.swt.custom.StyledText;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.tizen.installmanager.ui.InstallManagerWindow;\r
+import org.tizen.installmanager.ui.model.Item;\r
+import org.tizen.installmanager.util.PathUtil;\r
+\r
+/**\r
+ * @author Taeyoung Son <taeyoung2.son@samsung.com>\r
+ * \r
+ */\r
+public class LicensePage extends PageTemplate {\r
+ private static final String RSC_PATH_IMAGE_NEW = RESOURCE_PATH_NEW\r
+ + "/03_software_license_agreement_bg.png";\r
+\r
+ private StyledText txtLicense;\r
+ // contains button\r
+ private static final int DEFAULT_HEIGHT = 34;\r
+ private ScrolledComposite sc = null;\r
+ private Composite leftComposite;\r
+ private List<Item> licenseItems = null;\r
+\r
+ /**\r
+ * Set basic environment of license page.\r
+ * \r
+ * @param parent\r
+ * @param style\r
+ */\r
+ public LicensePage(Composite parent, int style) {\r
+ super(parent, style, true);\r
+\r
+ setLeftImageFromResource(RSC_PATH_IMAGE_NEW);\r
+ disableTitleBounds();\r
+ disableSubtitleBounds();\r
+\r
+ sc = new ScrolledComposite(customComposite, SWT.V_SCROLL | SWT.BORDER);\r
+ sc.setBounds(10, 10, 134, 280);\r
+\r
+ // TODO : remove\r
+ txtLicense = new StyledText(customComposite, SWT.BORDER | SWT.READ_ONLY\r
+ | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.CENTER);\r
+ txtLicense.setBounds(154, 10, 464, 282);\r
+\r
+ String txt = PathUtil.readAllTextFromResource("/res/COPYING");\r
+ txtLicense.setText(txt);\r
+ txtLicense.setLineAlignment(1, 1, SWT.CENTER);\r
+ }\r
+\r
+ public void loadPage(List<Item> items) {\r
+ createLeftComposite(getCustomComposite(), items);\r
+ }\r
+\r
+ private void createLeftComposite(Composite parent, List<Item> items) {\r
+ if (leftComposite != null) {\r
+ leftComposite.dispose();\r
+ }\r
+\r
+ licenseItems = items;\r
+\r
+ // create left composite\r
+ leftComposite = new Composite(sc, SWT.NONE);\r
+ leftComposite.setBackground(InstallManagerWindow.getBackgroundColor());\r
+\r
+ // contain default license\r
+ int height = DEFAULT_HEIGHT;\r
+ int width = 130;\r
+ if ((height * (items.size() + 1)) > 280) {\r
+ width = 113;\r
+ }\r
+\r
+ // add default license\r
+ addSDKLicense(height, width);\r
+\r
+ // add license of items\r
+ int yCoordinate = height;\r
+ for (Item i : items) {\r
+ Button b = new Button(leftComposite, SWT.LEFT);\r
+ b.setBounds(0, yCoordinate, width, height);\r
+ b.setText(i.getDisplayName());\r
+ b.setToolTipText(i.getDisplayName());\r
+\r
+ b.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ Button b = (Button) e.widget;\r
+\r
+ txtLicense.setText(getLicense(b.getText()));\r
+ try {\r
+ txtLicense.setAlignment(SWT.CENTER);\r
+ } catch (IllegalArgumentException ie) {\r
+ ie.printStackTrace();\r
+ }\r
+ }\r
+ });\r
+\r
+ yCoordinate += height;\r
+ }\r
+\r
+ sc.setContent(leftComposite);\r
+ sc.setExpandVertical(true);\r
+ sc.setExpandHorizontal(true);\r
+ sc.setMinSize(leftComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
+ }\r
+\r
+ private String getLicense(String label) {\r
+ for (Item i : licenseItems) {\r
+ if (i.getDisplayName().equals(label)) {\r
+ return i.getPackage().getDescription();\r
+ }\r
+ }\r
+\r
+ return "";\r
+ }\r
+\r
+ private void addSDKLicense(int height, int width) {\r
+ Button b = new Button(leftComposite, SWT.PUSH | SWT.LEFT);\r
+ b.setBounds(0, 0, width, height); \r
+ b.setText("Tizen SDK");\r
+ b.setToolTipText("Tizen SDK");\r
+ b.setSelection(true);\r
+\r
+ b.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ String txt = PathUtil.readAllTextFromResource("/res/COPYING");\r
+ txtLicense.setText(txt);\r
+ txtLicense.setLineAlignment(1, 1, SWT.CENTER);\r
+ }\r
+ });\r
+ }\r
+}\r
-/*
- * InstallManager
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Wooyoung Cho <wooyoung1.cho@samsung.com>
- * Shihyun Kim <shihyun.kim@samsung.com>
- * Taeyoung Son <taeyoung2.son@samsung.com>
- * Yongsung kim <yongsung1.kim@samsung.com>
- *
- * 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.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.installmanager.ui.page;
-
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-import org.tizen.installmanager.core.Config;
-import org.tizen.installmanager.lib.Platform;
-import org.tizen.installmanager.pkg.lib.PackageManager;
-import org.tizen.installmanager.pkg.model.Package;
-import org.tizen.installmanager.pkg.model.PackageSet;
-import org.tizen.installmanager.ui.InstallManagerWindow;
-import org.tizen.installmanager.ui.dialog.MessageBoxDlg;
-import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;
-import org.tizen.installmanager.ui.model.Item;
-import org.tizen.installmanager.ui.model.ItemLabelProvider;
-import org.tizen.installmanager.ui.model.ItemTreeContentProvider;
-import org.tizen.installmanager.ui.model.Item.CheckState;
-import org.tizen.installmanager.ui.model.Item.InstallState;
-
-/**
- * Display install or uninstall package lists via tree view.
- *
- * @author Taeyoung Son <taeyoung2.son@samsung.com>
- */
-public abstract class PackageListPage extends PageTemplate {
-
- private StyledText mDescriptionText;
- protected Tree tree;
- protected Label titleLabel;
- protected Label lblRequiredSize;
- protected Label lblUncompressedSize;
- protected List<Item> items;
- protected Label lblDescriptions;
- CheckboxTreeViewer checkboxTreeViewer;
- ViewController viewController = null;
-
- private static final String EXTRAS_OF_TREE_ITEM = "EXTRAS";
- public enum Type {
- INSTALL, UNINSTALL, UPDATE
- }
-
- protected enum InstallType {
- TYPICAL, MINIMAL, WEB_MINIMAL, NATIVE_MINIMAL, CUSTOM
- }
-
- /**
- * Set environments for packagelist page, such as style, adding listener.
- *
- * @param parent
- * @param style
- */
- public PackageListPage(Composite parent, int style, final Type type) {
- super(parent, style, true);
-
- items = new ArrayList<Item>();
-
- setTitleLabel(getCustomComposite());
- setDescriptionText(getCustomComposite());
- setTree(getCustomComposite());
- setCheckboxTreeViewer(type);
- }
-
- private void setTitleLabel(Composite composite) {
- titleLabel = new Label(composite, SWT.NONE);
- titleLabel.setBounds(10, 6, 200, 23);
- }
-
- private void setSizeLabel(Composite composite) {
- if (Config.status == Config.Status.INSTALL) {
- lblRequiredSize = new Label(getCustomComposite(), SWT.NONE);
- lblRequiredSize.setBounds(300, 6, 170, 23);
- lblRequiredSize.setBackground(InstallManagerWindow.getBackgroundColor());
-
- lblUncompressedSize = new Label(getCustomComposite(), SWT.NONE);
- lblUncompressedSize.setBounds(475, 6, 170, 23);
- lblUncompressedSize.setBackground(InstallManagerWindow.getBackgroundColor());
- }
- }
-
- private void setTree(Composite composite) {
- checkboxTreeViewer = new CheckboxTreeViewer(customComposite, SWT.BORDER | SWT.H_SCROLL | SWT.LEFT);
- tree = checkboxTreeViewer.getTree();
- tree.setBounds(150, 31, 468, 213);
- tree.setHeaderVisible(true);
- tree.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- tree.addMouseTrackListener(new MouseTrackAdapter() {
- @Override
- public void mouseExit(MouseEvent arg0) {
- mDescriptionText.setForeground(new Color(null, 96, 96, 96));
- }
- });
-
- tree.addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent arg0) {
- Point mousePoint = new Point(arg0.x, arg0.y);
- TreeItem item = tree.getItem(mousePoint);
- if (item != null) {
- mDescriptionText.setForeground(new Color(null, 0, 0, 0));
- Item it = (Item)item.getData();
- String packageName = it.getPackageName();
- String description = viewController.getDescription(packageName);
-
- if (!description.isEmpty()) {
- setComponentDescriptionText(description);
- } else {
- setComponentDescriptionText("\"" + packageName + "\" category.");
- }
- } else {
- mDescriptionText.setForeground(new Color(null, 96, 96, 96));
- }
- }
- });
-
- TreeColumn trclmnA = new TreeColumn(tree, SWT.LEFT);
- trclmnA.setWidth(240);
- trclmnA.setText("Name");
-
- TreeColumn trclmnB = new TreeColumn(tree, SWT.CENTER);
- trclmnB.setWidth(110);
- trclmnB.setText("Status");
-
- TreeColumn trclmnC = new TreeColumn(tree, SWT.CENTER);
- trclmnC.setWidth(70);
- trclmnC.setText("Install size");
- }
-
- private void setCheckboxTreeViewer(final Type type) {
- checkboxTreeViewer = new CheckboxTreeViewer(tree);
-
- ColumnViewerToolTipSupport.enableFor(checkboxTreeViewer);
-
- setSizeLabel(getCustomComposite());
-
- checkboxTreeViewer.setContentProvider(new ItemTreeContentProvider());
- checkboxTreeViewer.setLabelProvider(new ItemLabelProvider());
-
- List<Item> tmp = getItems();
- checkboxTreeViewer.setInput(getItems());
-
- checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent e) {
- if (e.getElement() instanceof Item) {
-
- Item item = (Item) e.getElement();
-
- if (item.getPackageName().equals(Config.SDK_NAME)) {
- checkboxTreeViewer.setSubtreeChecked(item, !e.getChecked());
- setCheckbox(item, e.getChecked());
- setNextBtnEnabledAboutCheckedPackageCount();
- return;
- } else {
- if (item.isConflict()) {
- setCheckbox(item, false);
- PackageSet causePackages = viewController.getCauseOfConflict(getCheckedPackages(), item.getPackage());
- showConflictDialog(causePackages);
- return;
- }
-
- if (item.getPackageName().equalsIgnoreCase(EXTRAS_OF_TREE_ITEM)) {
- if (item.hasChildren()) {
- setCheckbox(item, e.getChecked());
- }
- } else {
- setCheckbox(item, e.getChecked());
- }
-
- setConflictCheckbox(item);
- checkboxTreeViewer.refresh();
-
- setNextBtnEnabledAboutCheckedPackageCount();
- if (type == Type.INSTALL || type == Type.UPDATE) {
- lblRequiredSize.setText("Download size : "
- + convertToVolumeSize(getCheckedPackageSize(false)));
- lblUncompressedSize.setText("Install size : "
- + convertToVolumeSize(getCheckedPackageSize(true)));
- }
- }
- }
- }
- });
- }
-
- private void showConflictDialog(PackageSet causePackages) {
- String msg = null;
- if (causePackages == null) {
- msg = "test";
- } else {
- msg = "This package is conflict package of\n";
- List<String> causePkgs = new ArrayList<String>();
- for (Package pkg : causePackages) {
- causePkgs.add(pkg.getPackageName());
- }
- msg = "'" + causePkgs + "'\n";
- }
-
- MessageBoxDlg.showDlg(Display.getCurrent().getShells()[0],
- "Warning",
- msg,
- DialogType.INFO, false);
- }
-
- private void setDescriptionText(Composite composite) {
- mDescriptionText = new StyledText(
- composite,
- SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI);
- mDescriptionText.setForeground(new Color(null, 96, 96, 96));
- mDescriptionText.setEditable(false);
- mDescriptionText.setEnabled(false);
-
- if (Platform.isUbuntu()) {
- mDescriptionText.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));
- } else if (Platform.isWindows()) {
- mDescriptionText.setFont((new Font(Display.getCurrent(), new FontData("Verdana", 9, SWT.NONE))));
- }
-
- mDescriptionText.setBounds(150, 248, 468, 47);
-// if (mType == Type.INSTALL) {
-// mDescriptionText.setBounds(0, 257, 447, 45);
-// } else if (mType == Type.UPDATE) {
-// mDescriptionText.setBounds(0, 287, 447, 45);
-// }
- }
-
- protected void setComponentDescriptionText(String text) {
- StringBuffer newText = new StringBuffer();
- ArrayList<StyleRange> styles = new ArrayList<StyleRange>();
- StyleRange currentStyle = null;
- int styleCount = 0;
-
- for (int i = 0; i < text.length(); i++) {
- char c = text.charAt(i);
- if (c == '<' && text.indexOf('>', i) != -1) {
- int startIdx = i;
- int endIdx = text.indexOf('>', startIdx);
-
- String tag = text.substring(startIdx, endIdx + 1);
- if (tag.equals("<b>")) {
- if (currentStyle == null) {
- currentStyle = new StyleRange();
- currentStyle.start = newText.length();
- }
- currentStyle.fontStyle |= SWT.BOLD;
-
- styleCount++;
- i += (tag.length() - 1);
- } else if (tag.equals("</b>") && currentStyle != null) {
- styleCount--;
-
- if (styleCount == 0) {
- currentStyle.length = newText.length()
- - currentStyle.start;
- styles.add(currentStyle);
- currentStyle = null;
- }
-
- i += (tag.length() - 1);
- } else if (tag.matches("<font color=\"#[0-9a-fA-F]+\">")) {
- int hexStartIdx = tag.indexOf('#');
- int r = -1, g = -1, b = -1;
- try {
- r = Integer
- .parseInt(tag.substring(hexStartIdx + 1,
- hexStartIdx + 3), 16);
- g = Integer
- .parseInt(tag.substring(hexStartIdx + 3,
- hexStartIdx + 5), 16);
- b = Integer
- .parseInt(tag.substring(hexStartIdx + 5,
- hexStartIdx + 7), 16);
- } catch (IndexOutOfBoundsException e) {
- r = -1;
- g = -1;
- b = -1;
- } catch (NumberFormatException e) {
- r = -1;
- g = -1;
- b = -1;
- }
-
- if (currentStyle == null) {
- currentStyle = new StyleRange();
- currentStyle.start = newText.length();
- }
- if (r != -1 && g != -1 && b != -1) {
- currentStyle.foreground = new Color(null, r, g, b);
- }
-
- styleCount++;
- i += (tag.length() - 1);
- } else if (tag.equals("</font>") && currentStyle != null) {
- styleCount--;
-
- if (styleCount == 0) {
- currentStyle.length = newText.length()
- - currentStyle.start;
- styles.add(currentStyle);
- currentStyle = null;
- }
-
- i += (tag.length() - 1);
- } else {
- newText.append(c);
- }
- } else {
- newText.append(c);
- }
- }
- mDescriptionText.setText(newText.toString());
- mDescriptionText.setStyleRanges(styles.toArray(new StyleRange[0]));
- }
-
- protected void setTitleLabelText(String title) {
- titleLabel.setText(title);
- }
-
- protected void setNextBtnEnabledAboutCheckedPackageCount() {
- if (getCheckedPackageNumber() > 0) {
- InstallManagerWindow.setNextBtnEnabled(true);
- } else {
- InstallManagerWindow.setNextBtnEnabled(false);
- }
- }
-
- protected void setConflictCheckbox(Package pkg, boolean checked) {
- for (Item item : items) {
- if (pkg.getPackageName().equalsIgnoreCase(item.getPackageName())) {
- item.setConflict(true);
- setCheckbox(item, checked);
- }
- }
- }
-
- protected List<Item> getLeafItemsToCheck(Item item) {
- List<Item> leafItemsToCheck = new ArrayList<Item>();
-
- if (item.hasChildren()) {
- for (Item childItem : item.getChildren()) {
- leafItemsToCheck.addAll(getLeafItemsToCheck(childItem));
- }
- } else {
- for (Item i : getItems()) {
- if (item.getPackageName().equals(i.getPackageName())) {
- leafItemsToCheck.add(i);
- }
- }
- }
-
- return leafItemsToCheck;
- }
-
- protected void setCheckbox(Item item, boolean checked) {
- if (item == null) {
- return;
- } else {
- List<Item> leafItemsToCheck = getLeafItemsToCheck(item);
-
- for (Item i : leafItemsToCheck) {
- setCheckState(i, checked);
- setParentCheckbox(i.getParent());
- }
-
-// setChildCheckbox(checkboxTreeViewer, item, checked);
-//
-// if (item.getParent() != null) {
-// for (Item i : getItems()) {
-// if (i.getPackageName().equalsIgnoreCase(item.getPackageName())) {
-// setParentCheckbox(i.getParent());
-// }
-// }
-// }
-
- changeCheckboxStatus(items);
- }
- }
-
- private void setChildCheckbox(CheckboxTreeViewer checkboxTreeViewer,
- Item selectedItem, boolean checked) {
- if (!selectedItem.hasChildren()) {
- for (Item i : getItems()) {
- if (i.getPackageName().equalsIgnoreCase(selectedItem.getPackageName())) {
- setCheckState(i, checked);
- }
- }
- } else {
- for (Item item : selectedItem.getChildren()) {
- setChildCheckbox(checkboxTreeViewer, item, checked);
- }
-
- for (Item i : getItems()) {
- if (i.getPackageName().equalsIgnoreCase(selectedItem.getPackageName())) {
- setCheckStateByChildren(i);
- }
- }
- }
- }
-
- private void setConflictCheckbox(Item selectedItem) {
- refreshConflictStatus();
- PackageSet conflictPackages = viewController.getConflictPackages(getCheckedPackages());
-
- for (Package pkg : conflictPackages) {
- setConflictCheckbox(pkg, false);
- }
- }
-
- private void refreshConflictStatus() {
- for (Item item : items) {
- item.setConflict(false);
- }
- }
-
- protected PackageSet getCheckedPackages() {
- PackageSet checkedPackages = new PackageSet();
-
- for (Item item : getCheckedItem()) {
- checkedPackages.add(item.getPackage());
- }
-
- return checkedPackages;
- }
-
- protected List<Item> getCheckedItem() {
- List<Item> checkedItems = new ArrayList<Item>();
-
- for (Item item : items) {
- if (item.getCheckState() == CheckState.CHECKED) {
- checkedItems.add(item);
- }
- }
-
- return checkedItems;
- }
-
- private void setCheckState(Item selectedItem, boolean checked) {
- if (Config.status == Config.Status.UPDATE) {
- if (selectedItem.getInstallState() == InstallState.INSTALL) {
- selectedItem.setCheckState(checked);
- }
- } else {
- selectedItem.setCheckState(checked);
- }
- }
-
- private void setParentCheckbox(Item parentItem) {
- if (parentItem == null) {
- return;
- }
- setCheckStateByChildren(parentItem);
-
- if (parentItem.getParent() != null) {
- setParentCheckbox(parentItem.getParent());
- }
- }
-
- private void setCheckStateByChildren(Item treeItem) {
- if (treeItem.isChildrenAllChecked()) {
- treeItem.setCheckState(true);
- } else if (treeItem.isChildrenAllUnchecked()) {
- treeItem.setCheckState(false);
- } else {
- treeItem.setCheckState(CheckState.GRAYED);
- }
- }
-
- protected void changeCheckboxStatus(List<Item> itemList) {
- checkboxTreeViewer.setCheckedElements(itemList.toArray());
-
- for (Item item : itemList) {
- if (item.getCheckState() == CheckState.CHECKED) {
- checkboxTreeViewer.setGrayed(item, false);
- checkboxTreeViewer.setChecked(item, true);
- } else if (item.getCheckState() == CheckState.UNCHECKED) {
- checkboxTreeViewer.setGrayed(item, false);
- checkboxTreeViewer.setChecked(item, false);
- } else {
- checkboxTreeViewer.setGrayed(item, true);
- }
- }
- }
-
- /**
- * Get items list.
- *
- * @return items list.
- */
- public List<Item> getItems() {
- return items;
- }
-
- abstract public boolean loadPage(ViewController controller);
-
- protected void loadPackagesToTreeViewer(PackageSet packageSet, Type type) {
- //make tree items from package set.
- List<Item> treeItems = new ArrayList<Item>();
- List<Item> treeIts;
- if (type != Type.UNINSTALL) {
- treeItems = viewController.getPackageSetOfTree();
-
- items.addAll(treeItems);
- // make relation for item tree.
- makeRelation(items);
- } else {
- treeIts = viewController.getPackageSetOfTree();
- treeItems = getRemovableSetOfTree(treeIts);
- items.addAll(treeItems);
- }
-
-// items.addAll(treeItems);
-//
-//// make relation for item tree.
-// makeRelation(items);
- makeState();
- }
-
- public List<Item> getRemovableSetOfTree(List<Item> treeItemSet) {
- makeRelation(treeItemSet);
- List<Item> treeItems = new ArrayList<Item>();
-
- for (Item item : treeItemSet) {
- if (item.hasChildren()) {
- treeItems.addAll(getRemovableSetOfTree(item.getChildren()));
- } else {
- if (item.getInstallState() == InstallState.UNINSTALL) {
- if (!treeItems.contains(item)) {
- treeItems.add(item);
- }
-
- if (item.getParent() != null && !treeItems.contains(item.getParent())) {
- treeItems.add(item.getParent());
- }
- }
- }
- }
-
- return treeItems;
- }
-
- public void addExtensionPackagesToExtra(PackageSet packageSet) {
- Item extraItem = getExtraTreeItem();
- if (extraItem == null) {
- return;
- }
-
- //Always refresh Extra component whatever add and remove.
- removeChildrenOfExtra();
-
- setDisableExtra();
-
- List<Item> extensionItems = viewController.makeTreeItem(packageSet);
-
- makeRelation(extensionItems);
-
- //Add top items of extension items to extra.
- for (Item extensionItem : extensionItems) {
- if (extensionItem.getParent() == null) {
- extraItem.addChildItem(extensionItem);
- extensionItem.setParent(extraItem);
- }
- }
-
- for (Item item : items) {
- if (item.getPackageName().equals(EXTRAS_OF_TREE_ITEM)) {
- item.setStateByChildren();
- }
- }
-
- items.addAll(extensionItems);
- checkboxTreeViewer.refresh();
- }
-
- private Item getExtraTreeItem() {
- for (Item tItem : items) {
- if (tItem.getPackageName().equalsIgnoreCase(EXTRAS_OF_TREE_ITEM)) {
- return tItem;
- }
- }
- return null;
- }
-
- private void setDisableExtra() {
- checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent e) {
- Item item = (Item) e.getElement();
- if (item.equals(getExtraTreeItem())) {
- if (!item.hasChildren()) {
- checkboxTreeViewer.setChecked(item, false);
- setNextBtnEnabledAboutCheckedPackageCount();
- }
- }
- }
- });
- }
-
- private void removeChildrenOfExtra() {
- Item extraItem = getExtraTreeItem();
-
- if (extraItem != null) {
- if (extraItem.getChildren() != null) {
- for (Item childItem : extraItem.getChildren()) {
- removeTreeItem(childItem);
- }
- }
- extraItem.clearChildrenItems();
- }
- }
-
- private void removeTreeItem(Item item) {
- if (item.hasChildren()) {
- for (Item childItem : item.getChildren()) {
- removeTreeItem(childItem);
- }
- }
-
- items.remove(item);
- }
-
- private void makeRelation(List<Item> treeItems) {
- // set relation of items.
- List<Item> addedItems = new ArrayList<Item>();
- for (Item item : treeItems) {
- setRelationOfItem(item, treeItems, addedItems);
- }
- treeItems.addAll(addedItems);
-
- Collections.sort(treeItems);
- }
-
- private void makeState() {
- for (Item item : items) {
- item.setStateByChildren();
- }
- }
-
- private void setRelationOfItem(Item parentItem, List<Item> compareList, List<Item> addedList) {
- Package packageOfParentItem = parentItem.getPackage();
- Collection<String> theChildPackage = packageOfParentItem.getDependentPackageNames();
-
- for (String childPackage : theChildPackage) {
- for (Item treeItem : compareList) {
- String packageNameOfTreeItem = treeItem.getPackageName();
-
- if (packageNameOfTreeItem.equalsIgnoreCase(childPackage)) {
- if (treeItem.getParent() != null) {
- Item childItem = new Item(treeItem.getLatestPackage(), treeItem.getInstalledPackage(), treeItem.getInstallState());
-
- parentItem.addChildItem(childItem);
- childItem.setParent(parentItem);
-
- addedList.add(childItem);
- } else {
- parentItem.addChildItem(treeItem);
- treeItem.setParent(parentItem);
- }
- }
- }
- }
- }
-
- protected void setAllChecked(boolean checked) {
- List<Item> items = getItems();
- if (items == null) {
- return;
- }
-
- for (Item treeItem : items) {
- setCheckbox(treeItem, checked);
- }
- }
-
- protected void setDisableChecked(List<Item> items, boolean checked) {
- if (items == null) {
- return;
- }
-
- for (Item item : items) {
- setDisableChecked(item, checked);
- }
- }
-
- protected void setDisableChecked(Item item, boolean checked) {
- if (item == null) {
- return;
- }
-
- setChildCheckbox(checkboxTreeViewer, item, checked);
- setParentCheckbox(item);
- }
-
- /**
- * Get checked packages count.
- *
- * @return checked packages count.
- */
- public int getCheckedPackageNumber() {
- int result = 0;
- int leafCnt = 0;
- int installedCnt = 0;
-
- Object[] items = checkboxTreeViewer.getCheckedElements();
-
- if (Config.status == Config.Status.UPDATE) {
- if (checkboxTreeViewer != null) {
- List<Item> itemList = new ArrayList<Item>();
- for (Object o : items) {
- itemList.add((Item)o);
- }
-
- // Count checked node items.
- for (Item i : itemList) {
- if (i.getParent() != null) { // it means leaf node.
- leafCnt ++;
- } else if (!i.hasChildren()) { // it means top node which does not have children.
- leafCnt ++;
- }
- }
-
- // Count installed items among checked items.
- for (Item i : itemList) {
- if (i.getInstallState() == InstallState.UNINSTALL) {
- installedCnt++;
- }
- }
-
- result = leafCnt - installedCnt;
- }
- } else {
- result = items.length;
- }
-
- return result;
- }
-
- /**
- * Get checked packages size.
- * @param isUncompressed Uncompressed is true, not false.
- * @return checked uncompressed packages size or compressed packages size.
- */
- public long getCheckedPackageSize(boolean isUncompressed) {
- List<String> listPkgName = new ArrayList<String>();
-
- if (checkboxTreeViewer != null) {
- Object[] items = checkboxTreeViewer.getCheckedElements();
-
- for (Object item : items) {
- Item checkedItem = (Item)item;
- if (checkedItem.getCheckState() == CheckState.CHECKED) {
- listPkgName.add(checkedItem.getPackageName());
- }
- }
- }
-
- return viewController.getTotalSizeWithDepends(listPkgName, isUncompressed);
- }
-
- public List<String> getCheckedPackageNames() {
- List<String> listPkgName = new ArrayList<String>();
-
- if (checkboxTreeViewer != null) {
- Object[] items = checkboxTreeViewer.getCheckedElements();
-
- for (int i = 0; i < items.length; i++) {
- Item item = (Item) items[i];
- if (item.getParent() != null) {
- listPkgName.add(item.getPackageName());
- }
- }
- }
-
- return listPkgName;
- }
-
- /**
- * Calculate byte to GB, MB, KB.
- *
- * @param byteSize
- * @return Converted byte to GB, MB, KB
- */
- public String convertToVolumeSize(long byteSize) {
- final double KB_SIZE = 1024;
- final double MB_SIZE = KB_SIZE * 1024;
- final double GB_SIZE = MB_SIZE * 1024;
-
- String sizeStr;
- String pattern = ".#";
- DecimalFormat dformat = new DecimalFormat(pattern);
-
- if (byteSize >= GB_SIZE) {
- sizeStr = dformat.format((byteSize / GB_SIZE)) + "GB";
- } else if (byteSize >= MB_SIZE) {
- sizeStr = dformat.format((byteSize / MB_SIZE)) + "MB";
- } else if (byteSize >= KB_SIZE) {
- sizeStr = dformat.format((byteSize / KB_SIZE)) + "KB";
- } else {
- sizeStr = byteSize + "byte";
- }
-
- return sizeStr;
- }
-}
+/*\r
+ * InstallManager\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Wooyoung Cho <wooyoung1.cho@samsung.com>\r
+ * Shihyun Kim <shihyun.kim@samsung.com>\r
+ * Taeyoung Son <taeyoung2.son@samsung.com>\r
+ * Yongsung kim <yongsung1.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
+\r
+package org.tizen.installmanager.ui.page;\r
+\r
+import java.text.DecimalFormat;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.viewers.CheckStateChangedEvent;\r
+import org.eclipse.jface.viewers.CheckboxTreeViewer;\r
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;\r
+import org.eclipse.jface.viewers.ICheckStateListener;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.StyleRange;\r
+import org.eclipse.swt.custom.StyledText;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseMoveListener;\r
+import org.eclipse.swt.events.MouseTrackAdapter;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.Font;\r
+import org.eclipse.swt.graphics.FontData;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.swt.widgets.TreeColumn;\r
+import org.eclipse.swt.widgets.TreeItem;\r
+import org.tizen.installmanager.core.Config;\r
+import org.tizen.installmanager.lib.Platform;\r
+import org.tizen.installmanager.pkg.lib.PackageManager;\r
+import org.tizen.installmanager.pkg.model.Package;\r
+import org.tizen.installmanager.pkg.model.PackageSet;\r
+import org.tizen.installmanager.ui.InstallManagerWindow;\r
+import org.tizen.installmanager.ui.dialog.MessageBoxDlg;\r
+import org.tizen.installmanager.ui.dialog.MessageBoxDlg.DialogType;\r
+import org.tizen.installmanager.ui.model.Item;\r
+import org.tizen.installmanager.ui.model.ItemLabelProvider;\r
+import org.tizen.installmanager.ui.model.ItemTreeContentProvider;\r
+import org.tizen.installmanager.ui.model.Item.CheckState;\r
+import org.tizen.installmanager.ui.model.Item.InstallState;\r
+\r
+/**\r
+ * Display install or uninstall package lists via tree view.\r
+ * \r
+ * @author Taeyoung Son <taeyoung2.son@samsung.com>\r
+ */\r
+public abstract class PackageListPage extends PageTemplate {\r
+\r
+ private StyledText mDescriptionText;\r
+ protected Tree tree;\r
+ protected Label titleLabel;\r
+ protected Label lblRequiredSize;\r
+ protected Label lblUncompressedSize;\r
+ protected List<Item> items;\r
+ protected Label lblDescriptions;\r
+ CheckboxTreeViewer checkboxTreeViewer;\r
+ ViewController viewController = null;\r
+\r
+ private static final String EXTRAS_OF_TREE_ITEM = "EXTRAS";\r
+ public enum Type {\r
+ INSTALL, UNINSTALL, UPDATE\r
+ }\r
+ \r
+ protected enum InstallType {\r
+ TYPICAL, MINIMAL, WEB_MINIMAL, NATIVE_MINIMAL, CUSTOM\r
+ }\r
+ \r
+ /**\r
+ * Set environments for packagelist page, such as style, adding listener.\r
+ * \r
+ * @param parent\r
+ * @param style\r
+ */\r
+ public PackageListPage(Composite parent, int style, final Type type) {\r
+ super(parent, style, true);\r
+\r
+ items = new ArrayList<Item>();\r
+ \r
+ setTitleLabel(getCustomComposite());\r
+ setDescriptionText(getCustomComposite());\r
+ setTree(getCustomComposite());\r
+ setCheckboxTreeViewer(type);\r
+ }\r
+ \r
+ private void setTitleLabel(Composite composite) {\r
+ titleLabel = new Label(composite, SWT.NONE);\r
+ titleLabel.setBounds(10, 6, 200, 23);\r
+ }\r
+ \r
+ private void setSizeLabel(Composite composite) {\r
+ if (Config.status == Config.Status.INSTALL) {\r
+ lblRequiredSize = new Label(getCustomComposite(), SWT.NONE);\r
+ lblRequiredSize.setBounds(300, 6, 170, 23);\r
+ lblRequiredSize.setBackground(InstallManagerWindow.getBackgroundColor());\r
+ \r
+ lblUncompressedSize = new Label(getCustomComposite(), SWT.NONE);\r
+ lblUncompressedSize.setBounds(475, 6, 170, 23);\r
+ lblUncompressedSize.setBackground(InstallManagerWindow.getBackgroundColor());\r
+ }\r
+ }\r
+ \r
+ private void setTree(Composite composite) {\r
+ checkboxTreeViewer = new CheckboxTreeViewer(customComposite, SWT.BORDER | SWT.H_SCROLL | SWT.LEFT);\r
+ tree = checkboxTreeViewer.getTree();\r
+ tree.setBounds(150, 31, 468, 213);\r
+ tree.setHeaderVisible(true);\r
+ tree.setLayoutData(new GridData(GridData.FILL_BOTH));\r
+ \r
+ tree.addMouseTrackListener(new MouseTrackAdapter() {\r
+ @Override\r
+ public void mouseExit(MouseEvent arg0) {\r
+ mDescriptionText.setForeground(new Color(null, 96, 96, 96));\r
+ }\r
+ });\r
+\r
+ tree.addMouseMoveListener(new MouseMoveListener() {\r
+ @Override\r
+ public void mouseMove(MouseEvent arg0) {\r
+ Point mousePoint = new Point(arg0.x, arg0.y);\r
+ TreeItem item = tree.getItem(mousePoint);\r
+ if (item != null) {\r
+ mDescriptionText.setForeground(new Color(null, 0, 0, 0));\r
+ Item it = (Item)item.getData();\r
+ String packageName = it.getPackageName();\r
+ String description = viewController.getDescription(packageName);\r
+\r
+ if (!description.isEmpty()) {\r
+ setComponentDescriptionText(description);\r
+ } else {\r
+ setComponentDescriptionText("\"" + packageName + "\" category.");\r
+ }\r
+ } else {\r
+ mDescriptionText.setForeground(new Color(null, 96, 96, 96));\r
+ }\r
+ }\r
+ });\r
+ \r
+ TreeColumn trclmnA = new TreeColumn(tree, SWT.LEFT);\r
+ trclmnA.setWidth(240);\r
+ trclmnA.setText("Name");\r
+\r
+ TreeColumn trclmnB = new TreeColumn(tree, SWT.CENTER);\r
+ trclmnB.setWidth(110);\r
+ trclmnB.setText("Status");\r
+ \r
+ TreeColumn trclmnC = new TreeColumn(tree, SWT.CENTER);\r
+ trclmnC.setWidth(70);\r
+ trclmnC.setText("Install size"); \r
+ }\r
+ \r
+ private void setCheckboxTreeViewer(final Type type) {\r
+ checkboxTreeViewer = new CheckboxTreeViewer(tree);\r
+\r
+ ColumnViewerToolTipSupport.enableFor(checkboxTreeViewer);\r
+\r
+ setSizeLabel(getCustomComposite());\r
+\r
+ checkboxTreeViewer.setContentProvider(new ItemTreeContentProvider());\r
+ checkboxTreeViewer.setLabelProvider(new ItemLabelProvider());\r
+\r
+ checkboxTreeViewer.setInput(getItems());\r
+\r
+ checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {\r
+ @Override\r
+ public void checkStateChanged(CheckStateChangedEvent e) {\r
+ if (e.getElement() instanceof Item) {\r
+\r
+ Item item = (Item) e.getElement();\r
+ \r
+ if (item.getPackageName().equals(Config.SDK_NAME)) {\r
+ checkboxTreeViewer.setSubtreeChecked(item, !e.getChecked());\r
+ setCheckbox(item, e.getChecked());\r
+ setNextBtnEnabledAboutCheckedPackageCount();\r
+ return;\r
+ } else {\r
+ if (item.isConflict()) {\r
+ setCheckbox(item, false);\r
+ PackageSet causePackages = viewController.getCauseOfConflict(getCheckedPackages(), item.getPackage());\r
+ showConflictDialog(causePackages);\r
+ return;\r
+ }\r
+ \r
+ if (item.getPackageName().equalsIgnoreCase(EXTRAS_OF_TREE_ITEM)) {\r
+ if (item.hasChildren()) {\r
+ setCheckbox(item, e.getChecked()); \r
+ }\r
+ } else {\r
+ setCheckbox(item, e.getChecked());\r
+ }\r
+\r
+ setConflictCheckbox(item);\r
+ checkboxTreeViewer.refresh();\r
+\r
+ setNextBtnEnabledAboutCheckedPackageCount();\r
+ if (type == Type.INSTALL || type == Type.UPDATE) {\r
+ lblRequiredSize.setText("Download size : " \r
+ + convertToVolumeSize(getCheckedPackageSize(false)));\r
+ lblUncompressedSize.setText("Install size : "\r
+ + convertToVolumeSize(getCheckedPackageSize(true)));\r
+ }\r
+ }\r
+ }\r
+ }\r
+ });\r
+ }\r
+ \r
+ private void showConflictDialog(PackageSet causePackages) {\r
+ String msg = null;\r
+ if (causePackages == null) {\r
+ msg = "test";\r
+ } else {\r
+ msg = "This package is conflict package of\n";\r
+ List<String> causePkgs = new ArrayList<String>();\r
+ for (Package pkg : causePackages) {\r
+ causePkgs.add(pkg.getPackageName());\r
+ }\r
+ msg = "'" + causePkgs + "'\n";\r
+ }\r
+ \r
+ MessageBoxDlg.showDlg(Display.getCurrent().getShells()[0], \r
+ "Warning", \r
+ msg, \r
+ DialogType.INFO, false);\r
+ }\r
+ \r
+ private void setDescriptionText(Composite composite) {\r
+ mDescriptionText = new StyledText(\r
+ composite,\r
+ SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI);\r
+ mDescriptionText.setForeground(new Color(null, 96, 96, 96));\r
+ mDescriptionText.setEditable(false);\r
+ mDescriptionText.setEnabled(false);\r
+ \r
+ if (Platform.isUbuntu()) {\r
+ mDescriptionText.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));\r
+ } else if (Platform.isWindows()) {\r
+ mDescriptionText.setFont((new Font(Display.getCurrent(), new FontData("Verdana", 9, SWT.NONE)))); \r
+ }\r
+ \r
+ mDescriptionText.setBounds(150, 248, 468, 47);\r
+// if (mType == Type.INSTALL) {\r
+// mDescriptionText.setBounds(0, 257, 447, 45);\r
+// } else if (mType == Type.UPDATE) {\r
+// mDescriptionText.setBounds(0, 287, 447, 45); \r
+// }\r
+ }\r
+ \r
+ protected void setComponentDescriptionText(String text) {\r
+ StringBuffer newText = new StringBuffer();\r
+ ArrayList<StyleRange> styles = new ArrayList<StyleRange>();\r
+ StyleRange currentStyle = null;\r
+ int styleCount = 0;\r
+\r
+ for (int i = 0; i < text.length(); i++) {\r
+ char c = text.charAt(i);\r
+ if (c == '<' && text.indexOf('>', i) != -1) {\r
+ int startIdx = i;\r
+ int endIdx = text.indexOf('>', startIdx);\r
+\r
+ String tag = text.substring(startIdx, endIdx + 1);\r
+ if (tag.equals("<b>")) {\r
+ if (currentStyle == null) {\r
+ currentStyle = new StyleRange();\r
+ currentStyle.start = newText.length();\r
+ }\r
+ currentStyle.fontStyle |= SWT.BOLD;\r
+\r
+ styleCount++;\r
+ i += (tag.length() - 1);\r
+ } else if (tag.equals("</b>") && currentStyle != null) {\r
+ styleCount--;\r
+\r
+ if (styleCount == 0) {\r
+ currentStyle.length = newText.length()\r
+ - currentStyle.start;\r
+ styles.add(currentStyle);\r
+ currentStyle = null;\r
+ }\r
+\r
+ i += (tag.length() - 1);\r
+ } else if (tag.matches("<font color=\"#[0-9a-fA-F]+\">")) {\r
+ int hexStartIdx = tag.indexOf('#');\r
+ int r = -1, g = -1, b = -1;\r
+ try {\r
+ r = Integer\r
+ .parseInt(tag.substring(hexStartIdx + 1,\r
+ hexStartIdx + 3), 16);\r
+ g = Integer\r
+ .parseInt(tag.substring(hexStartIdx + 3,\r
+ hexStartIdx + 5), 16);\r
+ b = Integer\r
+ .parseInt(tag.substring(hexStartIdx + 5,\r
+ hexStartIdx + 7), 16);\r
+ } catch (IndexOutOfBoundsException e) {\r
+ r = -1;\r
+ g = -1;\r
+ b = -1;\r
+ } catch (NumberFormatException e) {\r
+ r = -1;\r
+ g = -1;\r
+ b = -1;\r
+ }\r
+\r
+ if (currentStyle == null) {\r
+ currentStyle = new StyleRange();\r
+ currentStyle.start = newText.length();\r
+ }\r
+ if (r != -1 && g != -1 && b != -1) {\r
+ currentStyle.foreground = new Color(null, r, g, b);\r
+ }\r
+\r
+ styleCount++;\r
+ i += (tag.length() - 1);\r
+ } else if (tag.equals("</font>") && currentStyle != null) {\r
+ styleCount--;\r
+\r
+ if (styleCount == 0) {\r
+ currentStyle.length = newText.length()\r
+ - currentStyle.start;\r
+ styles.add(currentStyle);\r
+ currentStyle = null;\r
+ }\r
+\r
+ i += (tag.length() - 1);\r
+ } else {\r
+ newText.append(c);\r
+ }\r
+ } else {\r
+ newText.append(c);\r
+ }\r
+ }\r
+ mDescriptionText.setText(newText.toString());\r
+ mDescriptionText.setStyleRanges(styles.toArray(new StyleRange[0]));\r
+ }\r
+ \r
+ protected void setTitleLabelText(String title) {\r
+ titleLabel.setText(title);\r
+ }\r
+\r
+ protected void setNextBtnEnabledAboutCheckedPackageCount() {\r
+ if (getCheckedPackageNumber() > 0) {\r
+ InstallManagerWindow.setNextBtnEnabled(true);\r
+ } else {\r
+ InstallManagerWindow.setNextBtnEnabled(false);\r
+ }\r
+ }\r
+ \r
+ protected void setConflictCheckbox(Package pkg, boolean checked) {\r
+ for (Item item : items) {\r
+ if (pkg.getPackageName().equalsIgnoreCase(item.getPackageName())) {\r
+ item.setConflict(true);\r
+ setCheckbox(item, checked);\r
+ }\r
+ }\r
+ }\r
+ \r
+ protected List<Item> getLeafItemsToCheck(Item item) {\r
+ List<Item> leafItemsToCheck = new ArrayList<Item>();\r
+ \r
+ if (item.hasChildren()) {\r
+ for (Item childItem : item.getChildren()) {\r
+ leafItemsToCheck.addAll(getLeafItemsToCheck(childItem));\r
+ }\r
+ } else {\r
+ for (Item i : getItems()) {\r
+ if (item.getPackageName().equals(i.getPackageName())) {\r
+ leafItemsToCheck.add(i);\r
+ }\r
+ }\r
+ }\r
+ \r
+ return leafItemsToCheck;\r
+ }\r
+\r
+ protected void setCheckbox(Item item, boolean checked) {\r
+ if (item == null) {\r
+ return;\r
+ } else {\r
+ List<Item> leafItemsToCheck = getLeafItemsToCheck(item);\r
+ \r
+ for (Item i : leafItemsToCheck) {\r
+ setCheckState(i, checked);\r
+ setParentCheckbox(i.getParent());\r
+ }\r
+\r
+// setChildCheckbox(checkboxTreeViewer, item, checked);\r
+// \r
+// if (item.getParent() != null) {\r
+// for (Item i : getItems()) {\r
+// if (i.getPackageName().equalsIgnoreCase(item.getPackageName())) {\r
+// setParentCheckbox(i.getParent());\r
+// }\r
+// }\r
+// }\r
+ \r
+ changeCheckboxStatus(items);\r
+ }\r
+ }\r
+\r
+ private void setChildCheckbox(CheckboxTreeViewer checkboxTreeViewer,\r
+ Item selectedItem, boolean checked) {\r
+ if (!selectedItem.hasChildren()) {\r
+ for (Item i : getItems()) {\r
+ if (i.getPackageName().equalsIgnoreCase(selectedItem.getPackageName())) {\r
+ setCheckState(i, checked);\r
+ }\r
+ }\r
+ } else {\r
+ for (Item item : selectedItem.getChildren()) {\r
+ setChildCheckbox(checkboxTreeViewer, item, checked);\r
+ }\r
+ \r
+ for (Item i : getItems()) {\r
+ if (i.getPackageName().equalsIgnoreCase(selectedItem.getPackageName())) {\r
+ setCheckStateByChildren(i);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ private void setConflictCheckbox(Item selectedItem) {\r
+ refreshConflictStatus();\r
+ PackageSet conflictPackages = viewController.getConflictPackages(getCheckedPackages());\r
+\r
+ for (Package pkg : conflictPackages) {\r
+ setConflictCheckbox(pkg, false);\r
+ }\r
+ }\r
+ \r
+ private void refreshConflictStatus() {\r
+ for (Item item : items) {\r
+ item.setConflict(false);\r
+ }\r
+ }\r
+ \r
+ protected PackageSet getCheckedPackages() {\r
+ PackageSet checkedPackages = new PackageSet();\r
+ \r
+ for (Item item : getCheckedItem()) {\r
+ checkedPackages.add(item.getPackage());\r
+ }\r
+ \r
+ return checkedPackages;\r
+ }\r
+ \r
+ protected List<Item> getCheckedItem() {\r
+ List<Item> checkedItems = new ArrayList<Item>();\r
+ \r
+ for (Item item : items) {\r
+ if (item.getCheckState() == CheckState.CHECKED) {\r
+ checkedItems.add(item);\r
+ }\r
+ }\r
+ \r
+ return checkedItems;\r
+ }\r
+\r
+ private void setCheckState(Item selectedItem, boolean checked) {\r
+ if (Config.status == Config.Status.UPDATE) {\r
+ if (selectedItem.getInstallState() == InstallState.INSTALL) {\r
+ selectedItem.setCheckState(checked); \r
+ }\r
+ } else {\r
+ selectedItem.setCheckState(checked);\r
+ }\r
+ }\r
+\r
+ private void setParentCheckbox(Item parentItem) {\r
+ if (parentItem == null) {\r
+ return;\r
+ }\r
+ setCheckStateByChildren(parentItem);\r
+ \r
+ if (parentItem.getParent() != null) {\r
+ setParentCheckbox(parentItem.getParent());\r
+ }\r
+ }\r
+ \r
+ private void setCheckStateByChildren(Item treeItem) {\r
+ if (treeItem.isChildrenAllChecked()) { \r
+ treeItem.setCheckState(true);\r
+ } else if (treeItem.isChildrenAllUnchecked()) { \r
+ treeItem.setCheckState(false);\r
+ } else { \r
+ treeItem.setCheckState(CheckState.GRAYED);\r
+ }\r
+ }\r
+ \r
+ protected void changeCheckboxStatus(List<Item> itemList) {\r
+ checkboxTreeViewer.setCheckedElements(itemList.toArray());\r
+ \r
+ for (Item item : itemList) {\r
+ if (item.getCheckState() == CheckState.CHECKED) {\r
+ checkboxTreeViewer.setGrayed(item, false);\r
+ checkboxTreeViewer.setChecked(item, true);\r
+ } else if (item.getCheckState() == CheckState.UNCHECKED) {\r
+ checkboxTreeViewer.setGrayed(item, false);\r
+ checkboxTreeViewer.setChecked(item, false);\r
+ } else {\r
+ checkboxTreeViewer.setGrayed(item, true);\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Get items list.\r
+ * \r
+ * @return items list.\r
+ */\r
+ public List<Item> getItems() {\r
+ return items;\r
+ }\r
+ \r
+ public List<Item> getSelectedItems() {\r
+ List<Item> selectedList = new ArrayList<Item>();\r
+ \r
+ for (Item i : getItems()) {\r
+ if (i.getCheckState() == CheckState.CHECKED) {\r
+ selectedList.add(i);\r
+ }\r
+ }\r
+ return selectedList;\r
+ }\r
+\r
+ abstract public boolean loadPage(ViewController controller);\r
+\r
+ protected void loadPackagesToTreeViewer(PackageSet packageSet, Type type) {\r
+ //make tree items from package set.\r
+ List<Item> treeItems = new ArrayList<Item>();\r
+ List<Item> treeIts;\r
+ if (type != Type.UNINSTALL) {\r
+ treeItems = viewController.getPackageSetOfTree();\r
+\r
+ items.addAll(treeItems);\r
+ // make relation for item tree.\r
+ makeRelation(items);\r
+ } else {\r
+ treeIts = viewController.getPackageSetOfTree();\r
+ treeItems = getRemovableSetOfTree(treeIts);\r
+ items.addAll(treeItems);\r
+ }\r
+ \r
+// items.addAll(treeItems);\r
+// \r
+//// make relation for item tree.\r
+// makeRelation(items);\r
+ makeState();\r
+ }\r
+ \r
+ public List<Item> getRemovableSetOfTree(List<Item> treeItemSet) {\r
+ makeRelation(treeItemSet);\r
+ List<Item> treeItems = new ArrayList<Item>();\r
+ \r
+ for (Item item : treeItemSet) {\r
+ if (item.hasChildren()) {\r
+ treeItems.addAll(getRemovableSetOfTree(item.getChildren()));\r
+ } else {\r
+ if (item.getInstallState() == InstallState.UNINSTALL) {\r
+ if (!treeItems.contains(item)) {\r
+ treeItems.add(item); \r
+ }\r
+ \r
+ if (item.getParent() != null && !treeItems.contains(item.getParent())) {\r
+ treeItems.add(item.getParent());\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ return treeItems;\r
+ }\r
+ \r
+ public void addExtensionPackagesToExtra(PackageSet packageSet) {\r
+ Item extraItem = getExtraTreeItem();\r
+ if (extraItem == null) {\r
+ return;\r
+ }\r
+ \r
+ //Always refresh Extra component whatever add and remove.\r
+ removeChildrenOfExtra();\r
+ \r
+ setDisableExtra();\r
+ \r
+ List<Item> extensionItems = viewController.makeTreeItem(packageSet);\r
+ \r
+ makeRelation(extensionItems);\r
+ \r
+ //Add top items of extension items to extra.\r
+ for (Item extensionItem : extensionItems) {\r
+ if (extensionItem.getParent() == null) {\r
+ extraItem.addChildItem(extensionItem);\r
+ extensionItem.setParent(extraItem);\r
+ }\r
+ }\r
+ \r
+ for (Item item : items) {\r
+ if (item.getPackageName().equals(EXTRAS_OF_TREE_ITEM)) {\r
+ item.setStateByChildren();\r
+ }\r
+ }\r
+\r
+ items.addAll(extensionItems);\r
+ checkboxTreeViewer.refresh();\r
+ }\r
+ \r
+ private Item getExtraTreeItem() {\r
+ for (Item tItem : items) {\r
+ if (tItem.getPackageName().equalsIgnoreCase(EXTRAS_OF_TREE_ITEM)) {\r
+ return tItem;\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ \r
+ private void setDisableExtra() {\r
+ checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {\r
+ @Override\r
+ public void checkStateChanged(CheckStateChangedEvent e) {\r
+ Item item = (Item) e.getElement();\r
+ if (item.equals(getExtraTreeItem())) {\r
+ if (!item.hasChildren()) {\r
+ checkboxTreeViewer.setChecked(item, false);\r
+ setNextBtnEnabledAboutCheckedPackageCount();\r
+ }\r
+ }\r
+ }\r
+ });\r
+ }\r
+\r
+ private void removeChildrenOfExtra() {\r
+ Item extraItem = getExtraTreeItem();\r
+ \r
+ if (extraItem != null) {\r
+ if (extraItem.getChildren() != null) {\r
+ for (Item childItem : extraItem.getChildren()) {\r
+ removeTreeItem(childItem);\r
+ }\r
+ }\r
+ extraItem.clearChildrenItems();\r
+ }\r
+ }\r
+ \r
+ private void removeTreeItem(Item item) {\r
+ if (item.hasChildren()) {\r
+ for (Item childItem : item.getChildren()) {\r
+ removeTreeItem(childItem);\r
+ }\r
+ }\r
+ \r
+ items.remove(item);\r
+ }\r
+\r
+ private void makeRelation(List<Item> treeItems) {\r
+ // set relation of items.\r
+ List<Item> addedItems = new ArrayList<Item>();\r
+ for (Item item : treeItems) {\r
+ setRelationOfItem(item, treeItems, addedItems);\r
+ }\r
+ treeItems.addAll(addedItems);\r
+ \r
+ Collections.sort(treeItems);\r
+ }\r
+\r
+ private void makeState() {\r
+ for (Item item : items) {\r
+ item.setStateByChildren();\r
+ }\r
+ }\r
+\r
+ private void setRelationOfItem(Item parentItem, List<Item> compareList, List<Item> addedList) {\r
+ Package packageOfParentItem = parentItem.getPackage();\r
+ Collection<String> theChildPackage = packageOfParentItem.getDependentPackageNames();\r
+ \r
+ for (String childPackage : theChildPackage) {\r
+ for (Item treeItem : compareList) {\r
+ String packageNameOfTreeItem = treeItem.getPackageName();\r
+ \r
+ if (packageNameOfTreeItem.equalsIgnoreCase(childPackage)) { \r
+ if (treeItem.getParent() != null) {\r
+ Item childItem = new Item(treeItem.getLatestPackage(), treeItem.getInstalledPackage(), treeItem.getInstallState());\r
+ \r
+ parentItem.addChildItem(childItem);\r
+ childItem.setParent(parentItem);\r
+ \r
+ addedList.add(childItem);\r
+ } else {\r
+ parentItem.addChildItem(treeItem);\r
+ treeItem.setParent(parentItem);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ protected void setAllChecked(boolean checked) {\r
+ List<Item> items = getItems();\r
+ if (items == null) {\r
+ return;\r
+ }\r
+ \r
+ for (Item treeItem : items) {\r
+ setCheckbox(treeItem, checked);\r
+ }\r
+ }\r
+\r
+ protected void setDisableChecked(List<Item> items, boolean checked) {\r
+ if (items == null) {\r
+ return;\r
+ }\r
+ \r
+ for (Item item : items) {\r
+ setDisableChecked(item, checked);\r
+ }\r
+ }\r
+\r
+ protected void setDisableChecked(Item item, boolean checked) {\r
+ if (item == null) {\r
+ return;\r
+ }\r
+\r
+ setChildCheckbox(checkboxTreeViewer, item, checked);\r
+ setParentCheckbox(item);\r
+ }\r
+\r
+ /**\r
+ * Get checked packages count.\r
+ * \r
+ * @return checked packages count.\r
+ */\r
+ public int getCheckedPackageNumber() {\r
+ int result = 0;\r
+ int leafCnt = 0;\r
+ int installedCnt = 0;\r
+ \r
+ Object[] items = checkboxTreeViewer.getCheckedElements();\r
+ \r
+ if (Config.status == Config.Status.UPDATE) {\r
+ if (checkboxTreeViewer != null) {\r
+ List<Item> itemList = new ArrayList<Item>(); \r
+ for (Object o : items) {\r
+ itemList.add((Item)o);\r
+ }\r
+\r
+ // Count checked node items.\r
+ for (Item i : itemList) {\r
+ if (i.getParent() != null) { // it means leaf node.\r
+ leafCnt ++;\r
+ } else if (!i.hasChildren()) { // it means top node which does not have children.\r
+ leafCnt ++;\r
+ }\r
+ }\r
+ \r
+ // Count installed items among checked items.\r
+ for (Item i : itemList) {\r
+ if (i.getInstallState() == InstallState.UNINSTALL) {\r
+ installedCnt++;\r
+ }\r
+ }\r
+ \r
+ result = leafCnt - installedCnt;\r
+ } \r
+ } else {\r
+ result = items.length;\r
+ }\r
+\r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * Get checked packages size.\r
+ * @param isUncompressed Uncompressed is true, not false.\r
+ * @return checked uncompressed packages size or compressed packages size.\r
+ */\r
+ public long getCheckedPackageSize(boolean isUncompressed) {\r
+ List<String> listPkgName = new ArrayList<String>();\r
+\r
+ if (checkboxTreeViewer != null) {\r
+ Object[] items = checkboxTreeViewer.getCheckedElements();\r
+\r
+ for (Object item : items) {\r
+ Item checkedItem = (Item)item;\r
+ if (checkedItem.getCheckState() == CheckState.CHECKED) {\r
+ listPkgName.add(checkedItem.getPackageName());\r
+ }\r
+ }\r
+ }\r
+\r
+ return viewController.getTotalSizeWithDepends(listPkgName, isUncompressed);\r
+ }\r
+ \r
+ public List<String> getCheckedPackageNames() {\r
+ List<String> listPkgName = new ArrayList<String>();\r
+\r
+ if (checkboxTreeViewer != null) {\r
+ Object[] items = checkboxTreeViewer.getCheckedElements();\r
+\r
+ for (int i = 0; i < items.length; i++) {\r
+ Item item = (Item) items[i];\r
+ if (item.getParent() != null) {\r
+ listPkgName.add(item.getPackageName());\r
+ }\r
+ }\r
+ }\r
+\r
+ return listPkgName;\r
+ }\r
+\r
+ /**\r
+ * Calculate byte to GB, MB, KB.\r
+ * \r
+ * @param byteSize\r
+ * @return Converted byte to GB, MB, KB\r
+ */\r
+ public String convertToVolumeSize(long byteSize) {\r
+ final double KB_SIZE = 1024;\r
+ final double MB_SIZE = KB_SIZE * 1024;\r
+ final double GB_SIZE = MB_SIZE * 1024;\r
+\r
+ String sizeStr;\r
+ String pattern = ".#";\r
+ DecimalFormat dformat = new DecimalFormat(pattern);\r
+\r
+ if (byteSize >= GB_SIZE) {\r
+ sizeStr = dformat.format((byteSize / GB_SIZE)) + "GB";\r
+ } else if (byteSize >= MB_SIZE) {\r
+ sizeStr = dformat.format((byteSize / MB_SIZE)) + "MB";\r
+ } else if (byteSize >= KB_SIZE) {\r
+ sizeStr = dformat.format((byteSize / KB_SIZE)) + "KB";\r
+ } else {\r
+ sizeStr = byteSize + "byte";\r
+ }\r
+ \r
+ return sizeStr;\r
+ }\r
+}\r
-/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
- * 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.installmanager.ui.page;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.installmanager.ui.model.Item;
-import org.tizen.installmanager.pkg.lib.PackageManager;
-import org.tizen.installmanager.pkg.model.Package;
-import org.tizen.installmanager.pkg.model.PackageSet;
-
-
-/**
- * This class displays uninstallable package list on page.
- * @author Taeyoung Son <taeyoung2.son@samsung.com>
- */
-public class UninstallableListPage extends PackageListPage {
- private static final String RSC_PATH_IMAGE_NEW = RESOURCE_PATH_NEW + "/02_installation_option_bg.png";
- static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/uninstaller_graphicmotif_001.png";
- static final String STRING_TITLE = "Select uninstall components";
- static final String STRING_SUBTITLE = "You can see the items to uninstall.";
-
- /**
- * Display packages tree structure and add check state listener. a package is selected by check,
- * if selected package has child packages, tree will be expanded and show children of selected package.
- * @param parent
- * @param style
- */
- public UninstallableListPage(Composite parent, int style) {
- super(parent, style, Type.UNINSTALL);
-
- setLeftImageFromResource(RSC_PATH_IMAGE_NEW);
-// setTitle(STRING_TITLE);
-// setSubTitle(STRING_SUBTITLE);
-
- disableTitleBounds();
- disableSubtitleBounds();
-
- setTitleLabelText(STRING_TITLE);
-
- checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent e) {
- if (e.getChecked()) {
- checkboxTreeViewer.setSubtreeChecked(e.getElement(), true);
-
- if (e.getElement() instanceof Item) {
- Item item = (Item) e.getElement();
- item.setSubItemChecked(true);
- Object[] descendants = item.getDescendants().toArray();
-
- for (int i = 0; i < descendants.length; i++) {
- checkboxTreeViewer.setGrayed(descendants[i], false);
- }
- }
- } else {
- checkboxTreeViewer.setSubtreeChecked(e.getElement(), false);
-
- if (e.getElement() instanceof Item) {
- Item item = (Item) e.getElement();
- item.setSubItemChecked(false);
- Object[] descendants = item.getDescendants().toArray();
-
- for (int i = 0; i < descendants.length; i++) {
- checkboxTreeViewer.setGrayed(descendants[i], false);
- }
- }
- }
-
- if (e.getElement() instanceof Item) {
- List<Item> grayCheckedItems = new ArrayList<Item>();
- List<Item> checkedItems = new ArrayList<Item>();
- List<Item> unCheckedItems = new ArrayList<Item>();
- Item item = (Item) e.getElement();
-
- if (item.getParent() != null) {
- item.getParent().checkSuperItemGrayed(
- grayCheckedItems, checkedItems, unCheckedItems);
-
- for (int i = 0; i < grayCheckedItems.size(); i++) {
- checkboxTreeViewer.setGrayChecked(grayCheckedItems.get(i), true);
- }
-
- for (int i = 0; i < checkedItems.size(); i++) {
- checkboxTreeViewer.setGrayed(checkedItems.get(i), false);
- checkboxTreeViewer.setChecked(checkedItems.get(i), true);
- }
-
- for (int i = 0; i < unCheckedItems.size(); i++) {
- checkboxTreeViewer.setGrayed(unCheckedItems.get(i), false);
- checkboxTreeViewer.setChecked(unCheckedItems.get(i), false);
- }
- }
- }
- }
- });
- }
-
- /**
- * Display uninstallable list page.
- */
- public boolean loadPage(ViewController controller) {
- this.viewController = controller;
- getItems().clear();
-
- PackageSet removablePkgs = viewController.getRemovableMetaPackageList();
- PackageSet ps2 = PackageManager.getInstance().getRootMetaPackagesOfRepository();
- PackageSet ps1 = viewController.getInstalledPackages();
- PackageSet ps = PackageManager.getInstance().getInstalledMetaPackages();
- for (Package p : viewController.getRemovableMetaPackageList()) {
- if (p.getAttribute().equalsIgnoreCase("extra")) {
- removablePkgs.remove(p);
- }
- }
- loadPackagesToTreeViewer(removablePkgs, Type.UNINSTALL);
-
-// viewController.loadSdkExtension();
-// addExtensionPackagesToExtra(viewController.getRootMetaPackageListOfExtension());
-
- if (getItems().size() <= 0) {
- setUninstallAll();
- }
-
- setUninstallColumn();
- checkboxTreeViewer.refresh();
- setAllChecked(true);
- return true;
- }
-
- /**
- * Change column in uninstallable list page.
- */
- protected void setUninstallColumn() {
- tree.getColumn(0).setWidth(350);
- tree.getColumn(1).setText("Status");
- tree.getColumn(2).setWidth(0);
-// tree.getColumn(2).setText("Installed version");
-// tree.getColumn(3).setWidth(0);
- }
-
- /**
- * When all packages must be removed, Set TIZEN SDK item in uninstallable list page
- */
- protected void setUninstallAll() {
- //TODO impl
-// getItems().add(new Item(null, Config.SDK_NAME, "", "unknown", 0, State.UNINSTALL));
- }
-}
+/*\r
+* InstallManager\r
+*\r
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+*\r
+* Contact: \r
+* Wooyoung Cho <wooyoung1.cho@samsung.com>\r
+* Shihyun Kim <shihyun.kim@samsung.com>\r
+* Taeyoung Son <taeyoung2.son@samsung.com>\r
+* Yongsung kim <yongsung1.kim@samsung.com>\r
+* \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*\r
+* Contributors:\r
+* - S-Core Co., Ltd\r
+*\r
+*/\r
+\r
+package org.tizen.installmanager.ui.page;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.viewers.CheckStateChangedEvent;\r
+import org.eclipse.jface.viewers.ICheckStateListener;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.tizen.installmanager.ui.model.Item;\r
+import org.tizen.installmanager.pkg.lib.PackageManager;\r
+import org.tizen.installmanager.pkg.model.Package;\r
+import org.tizen.installmanager.pkg.model.PackageSet;\r
+\r
+\r
+/**\r
+ * This class displays uninstallable package list on page.\r
+ * @author Taeyoung Son <taeyoung2.son@samsung.com>\r
+ */\r
+public class UninstallableListPage extends PackageListPage {\r
+ private static final String RSC_PATH_IMAGE_NEW = RESOURCE_PATH_NEW + "/02_installation_option_bg.png";\r
+ static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/uninstaller_graphicmotif_001.png";\r
+ static final String STRING_TITLE = "Select uninstall components";\r
+ static final String STRING_SUBTITLE = "You can see the items to uninstall.";\r
+\r
+ /**\r
+ * Display packages tree structure and add check state listener. a package is selected by check,\r
+ * if selected package has child packages, tree will be expanded and show children of selected package. \r
+ * @param parent\r
+ * @param style\r
+ */\r
+ public UninstallableListPage(Composite parent, int style) {\r
+ super(parent, style, Type.UNINSTALL);\r
+\r
+ setLeftImageFromResource(RSC_PATH_IMAGE_NEW);\r
+// setTitle(STRING_TITLE);\r
+// setSubTitle(STRING_SUBTITLE);\r
+ \r
+ disableTitleBounds();\r
+ disableSubtitleBounds();\r
+\r
+ setTitleLabelText(STRING_TITLE);\r
+\r
+ checkboxTreeViewer.addCheckStateListener(new ICheckStateListener() {\r
+ @Override\r
+ public void checkStateChanged(CheckStateChangedEvent e) {\r
+ if (e.getChecked()) {\r
+ checkboxTreeViewer.setSubtreeChecked(e.getElement(), true);\r
+ \r
+ if (e.getElement() instanceof Item) {\r
+ Item item = (Item) e.getElement();\r
+ item.setSubItemChecked(true);\r
+ Object[] descendants = item.getDescendants().toArray();\r
+ \r
+ for (int i = 0; i < descendants.length; i++) {\r
+ checkboxTreeViewer.setGrayed(descendants[i], false);\r
+ }\r
+ }\r
+ } else {\r
+ checkboxTreeViewer.setSubtreeChecked(e.getElement(), false);\r
+ \r
+ if (e.getElement() instanceof Item) {\r
+ Item item = (Item) e.getElement();\r
+ item.setSubItemChecked(false);\r
+ Object[] descendants = item.getDescendants().toArray();\r
+ \r
+ for (int i = 0; i < descendants.length; i++) {\r
+ checkboxTreeViewer.setGrayed(descendants[i], false);\r
+ }\r
+ }\r
+ }\r
+ \r
+ if (e.getElement() instanceof Item) {\r
+ List<Item> grayCheckedItems = new ArrayList<Item>();\r
+ List<Item> checkedItems = new ArrayList<Item>();\r
+ List<Item> unCheckedItems = new ArrayList<Item>();\r
+ Item item = (Item) e.getElement();\r
+ \r
+ if (item.getParent() != null) {\r
+ item.getParent().checkSuperItemGrayed(\r
+ grayCheckedItems, checkedItems, unCheckedItems);\r
+ \r
+ for (int i = 0; i < grayCheckedItems.size(); i++) {\r
+ checkboxTreeViewer.setGrayChecked(grayCheckedItems.get(i), true);\r
+ }\r
+ \r
+ for (int i = 0; i < checkedItems.size(); i++) {\r
+ checkboxTreeViewer.setGrayed(checkedItems.get(i), false);\r
+ checkboxTreeViewer.setChecked(checkedItems.get(i), true);\r
+ }\r
+ \r
+ for (int i = 0; i < unCheckedItems.size(); i++) {\r
+ checkboxTreeViewer.setGrayed(unCheckedItems.get(i), false);\r
+ checkboxTreeViewer.setChecked(unCheckedItems.get(i), false);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Display uninstallable list page.\r
+ */\r
+ public boolean loadPage(ViewController controller) {\r
+ this.viewController = controller;\r
+ getItems().clear();\r
+\r
+ PackageSet removablePkgs = viewController.getRemovableMetaPackageList();\r
+ PackageSet ps2 = PackageManager.getInstance().getRootMetaPackagesOfRepository();\r
+ PackageSet ps1 = viewController.getInstalledPackages();\r
+ PackageSet ps = PackageManager.getInstance().getInstalledMetaPackages();\r
+ for (Package p : viewController.getRemovableMetaPackageList()) {\r
+ if (p.getAttribute().equalsIgnoreCase("extra")) {\r
+ removablePkgs.remove(p);\r
+ }\r
+ }\r
+ loadPackagesToTreeViewer(removablePkgs, Type.UNINSTALL);\r
+ \r
+// viewController.loadSdkExtension();\r
+// addExtensionPackagesToExtra(viewController.getRootMetaPackageListOfExtension());\r
+\r
+ if (getItems().size() <= 0) {\r
+ setUninstallAll();\r
+ }\r
+\r
+ setUninstallColumn();\r
+ checkboxTreeViewer.refresh();\r
+ setAllChecked(true);\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * Change column in uninstallable list page.\r
+ */\r
+ protected void setUninstallColumn() {\r
+ tree.getColumn(0).setWidth(350);\r
+ tree.getColumn(1).setText("Status");\r
+ tree.getColumn(2).setWidth(0);\r
+// tree.getColumn(2).setText("Installed version");\r
+// tree.getColumn(3).setWidth(0);\r
+ }\r
+\r
+ /**\r
+ * When all packages must be removed, Set TIZEN SDK item in uninstallable list page \r
+ */\r
+ protected void setUninstallAll() {\r
+ //TODO impl\r
+// getItems().add(new Item(null, Config.SDK_NAME, "", "unknown", 0, State.UNINSTALL));\r
+ }\r
+}\r
-/*
-* InstallManager
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Wooyoung Cho <wooyoung1.cho@samsung.com>
-* Shihyun Kim <shihyun.kim@samsung.com>
-* Taeyoung Son <taeyoung2.son@samsung.com>
-* Yongsung kim <yongsung1.kim@samsung.com>
-*
- * 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.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
-
-package org.tizen.installmanager.ui.page;
-
-
-import java.util.ArrayList;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.installmanager.core.Config;
-import org.tizen.installmanager.core.IMFatalException;
-import org.tizen.installmanager.core.InstallManager;
-import org.tizen.installmanager.core.Options;
-import org.tizen.installmanager.lib.ErrorController;
-import org.tizen.installmanager.lib.Log;
-import org.tizen.installmanager.lib.Platform;
-import org.tizen.installmanager.lib.Registry;
-import org.tizen.installmanager.pkg.model.ConfigFile;
-import org.tizen.installmanager.ui.InstallManagerWindow;
-import org.tizen.installmanager.ui.dialog.ConfigurationDialog;
-import org.tizen.installmanager.ui.dialog.ProxySettingsDialog;
-import org.tizen.installmanager.ui.lib.IMButton;
-import org.tizen.installmanager.util.PathUtil;
-
-/**
- * This class displays welcome page.
- * @author Taeyoung Son <taeyoung2.son@samsung.ncom>
- */
-public class WelcomePage extends PageTemplate {
-
- static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/install_manager_graphicmotif_welcome.png";
- static final String RSC_PATH_IMAGE_NEW = RESOURCE_PATH_NEW + "/01_welcome_page_bg.png";
- static final String RSC_INSTALL_BUTTON_NORMAL = RESOURCE_PATH_NEW + "/btn_welcome_page_install_normal.png";
- static final String RSC_INSTALL_BUTTON_NORMAL_BACKGROUND = RESOURCE_PATH_NEW + "/btn_welcome_page_install_normal_background.png";
- static final String RSC_INSTALL_BUTTON_ICON = RESOURCE_PATH_NEW + "/btn_welcome_page_install_icon.png";
- static final String RSC_INSTALL_BUTTON_HOVER = RESOURCE_PATH_NEW + "/btn_welcome_page_install_hover.png";
- static final String RSC_INSTALL_BUTTON_HOVER_BACKGROUND = RESOURCE_PATH_NEW + "/btn_welcome_page_install_hover_background.png";
- static final String RSC_UNINSTALL_BUTTON_NORMAL = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_normal.png";
- static final String RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_normal_background.png";
- static final String RSC_UNINSTALL_BUTTON_ICON = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_icon.png";
- static final String RSC_UNINSTALL_BUTTON_HOVER = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_hover.png";
- static final String RSC_UNINSTALL_BUTTON_HOVER_BACKGROUND = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_hover_background.png";
- public static final String STRING_TITLE = "Welcome to Tizen SDK";
- public static final String STRING_SUBTITLE1 = "Tizen SDK will be installed on your computer.";
- public static final String STRING_SUBTITLE2 = "Close all other applications before starting the installation.";
-
- private INSTALLMANAGER_ACTION selectedButton = INSTALLMANAGER_ACTION.INSTALL;
- IMButton buttonInstall = null;
- IMButton buttonUninstall = null;
- Button buttonUpdate = null;
- Button configurationButton = null;
-
- Label installIconLabel = null;
- Label installTextLabel = null;
- Label installSubTextLabel = null;
-
- Label unInstallIconLabel = null;
- Label unInstallTextLabel = null;
- Label unInstallSubTextLabel = null;
-
- Label advancedLabel = null;
- Label proxyLabel = null;
-
- Combo updateCombo = null;
- Combo uninstallCombo = null;
-
- ViewController viewController = null;
-
- ConfigurationDialog rDialog = null;
-
- InstallManagerWindow mainWindow = InstallManagerWindow.getInstallManagerWindow();
-
- boolean isMultiSdk = false;
-
- public enum INSTALLMANAGER_ACTION {
- INSTALL,
- UNINSTALL,
- UPDATE
- }
-
- /**
- * INSTALLED_NOTHING : Nothing to install before<br>
- * INSTALLED_SOME_PACKAGES : Some packages are installed before<br>
- * INSTALLED_ALL_PACKAGES : All packages are installed before<br>
- * INSTALLED_AND_INSTALLABLE_NOTHING : Nothing to install before and now<br>
- * INSTALLED_OLDSDK : There is no compatible old sdk and current sdk<br>
- */
- public enum InstalledStatus {
- INSTALLED_NOTHING,
- INSTALLED_SOME_PACKAGES,
- INSTALLED_ALL_PACKAGES,
- INSTALLED_AND_INSTALLABLE_NOTHING,
- INSTALLED_OLDSDK
- }
-
-
- /**
- * Create the composite.
- * @param parent
- * @param style
- */
- public WelcomePage(Composite parent, int style) {
- super(parent, style, false);
-// setImageBounds(0, 0, 630, 144);
-// setImageBounds(0, 0, 150, 405);
-// setTitleBounds(20, 160, 400, 20);
-// setSubTitleBounds(20, 190, 600, 40);
-// setCustomCompositeBounds(0, 220, 620, 173);
-// setLeftImageFromResource(RSC_PATH_IMAGE_NEW);
-// setTitle(STRING_TITLE);
-// setSubTitle(STRING_SUBTITLE);
-
- isMultiSdk = Config.isSupportMultiSDK();
-// setButton();
-
- setCustomCompositeBounds(0, 0, 628, 405);
- Image welcomeImg = new Image(Display.getCurrent(),
- "/home/reuentar/Work/dev_source/install-newUI/install-manager/InstallManager_java/src/res/new_images/01_welcome_page_bg.png");
- customComposite.setBackgroundImage(welcomeImg);
-
-// Shell shell = parent.getShell();
-// shell.setBackgroundImage(welcomeImg);
-// shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
-
- setWelcomeInfoLabel(customComposite);
- setInstallButton(customComposite);
- setUninstallButton(customComposite);
-
-// parent.setLayout(null);
-// parent.pack();
- System.out.println("asdfasdf");
- }
-
- private void setButton() {
-// setInstallButton();
-// setUninstallButton();
- setConfigurationButton();
- if (isMultiSdk) {
- setUpdateButton();
- setUpdateCombo();
- setUninstallCombo();
- }
- }
-
- private void setWelcomeInfoLabel(Composite composite) {
- Label label_1 = new Label(composite, SWT.TRANSPARENT);
- label_1.setBounds(18, 109, 400, 22);
- label_1.setText(STRING_SUBTITLE1);
- label_1.setForeground(new Color(null, new RGB(255, 255, 255)));
-
- Label label_2 = new Label(composite, SWT.NONE);
- label_2.setBounds(18, 131, 400, 22);
- label_2.setText(STRING_SUBTITLE2);
- label_2.setForeground(new Color(null, new RGB(255, 255, 255)));
-
- if (Platform.isUbuntu()) {
- label_1.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.BOLD))));
- label_2.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.BOLD))));
- } else if (Platform.isWindows()) {
- label_1.setFont((new Font(Display.getCurrent(), new FontData("Verdana", 9, SWT.BOLD))));
- label_2.setFont((new Font(Display.getCurrent(), new FontData("Verdana", 9, SWT.BOLD))));
- }
- }
-
- private void setInstallButton(Composite composite) {
- setAdvancedLabel(composite);
- setProxyLabel(composite);
- installIconLabel = new Label(composite, SWT.NONE);
- installIconLabel.setImage(PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_ICON));
- installIconLabel.setBounds(56, 204, 55, 55);
- installIconLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));
-
- installTextLabel = new Label(composite, SWT.NONE);
- installTextLabel.setText("Install");
- installTextLabel.setBounds(132, 200, 100, 30);
- installTextLabel.setForeground(new Color(null, new RGB(255, 255, 255)));
- installTextLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 24, SWT.NONE))));
- installTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));
-
- installSubTextLabel = new Label(composite, SWT.NONE);
- installSubTextLabel.setText("Install the latest version of Tizen SDK");
- installSubTextLabel.setBounds(132, 240, 230, 25);
- installSubTextLabel.setForeground(new Color(null, new RGB(255, 255, 255)));
- installSubTextLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));
- installSubTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));
-
- buttonInstall = new IMButton(composite, SWT.NONE);
- buttonInstall.setImage(PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL),
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER));
- buttonInstall.setSize(new Rectangle(33, 188, 558, 86));
-
- buttonInstall.addMouseTrackListener(new MouseTrackAdapter() {
- @Override
- public void mouseEnter(MouseEvent e) {
- installIconLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER_BACKGROUND));
- installTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER_BACKGROUND));
- installSubTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER_BACKGROUND));
-// proxyLabel.setBackgroundImage(
-// PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER_BACKGROUND));
- }
- @Override
- public void mouseExit(MouseEvent e) {
- installIconLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));
- installTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));
- installSubTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));
-// proxyLabel.setBackgroundImage(
-// PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));
- }
- });
-
- buttonInstall.addMouseListener(new MouseAdapter(){
- @Override
- public void mouseUp(MouseEvent e) {
-
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- System.out.println("button is pushed.");
- buttonInstall.setSelection(true);
-// mainWindow.showComposite(mainWindow.getComponentSelectionPage());
- selectedButton = INSTALLMANAGER_ACTION.INSTALL;
- Config.status = Config.Status.INSTALL;
- mainWindow.getNextButton().notifyListeners(SWT.Selection, new Event());
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- System.out.println("double click.");
- }
- });
- }
-
- private void setAdvancedLabel(Composite composite) {
- advancedLabel = new Label(composite, SWT.RIGHT | SWT.UNDERLINE_SINGLE);
- advancedLabel.setText("Advanced");
- advancedLabel.setBounds(475, 205, 100, 25);
- advancedLabel.setForeground(new Color(null, new RGB(255, 255, 255)));
- advancedLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));
-// proxyLabel.setBackgroundImage(
-// PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));
-
- final Cursor handCur = new Cursor(getDisplay(), SWT.CURSOR_HAND);
- final Cursor arrowCur = new Cursor(getDisplay(), SWT.CURSOR_ARROW);
- advancedLabel.addMouseTrackListener(new MouseTrackAdapter() {
- @Override
- public void mouseEnter(MouseEvent e) {
- advancedLabel.setCursor(handCur);
- }
- @Override
- public void mouseExit(MouseEvent e) {
- advancedLabel.setCursor(arrowCur);
- }
- });
-
- advancedLabel.addMouseListener(new MouseAdapter(){
- @Override
- public void mouseUp(MouseEvent e) {
-
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- rDialog = new ConfigurationDialog(customComposite.getShell());
-
- //set information to configuration dialog.
- ConfigFile confFile = Config.getInstance().getConfigFile();
- rDialog.setRepository(confFile.getRepository());
- rDialog.setCurrentDistribution(confFile.getDistribution());
- rDialog.setSnapshotPath(confFile.getSnapshotPath());
-
- int ret = rDialog.open();
- if (ret == 0){
- viewController.saveSnapshotSettings(rDialog.getRepository(), rDialog.getCurrentDistribution(), rDialog.getServerType(), rDialog.getSnapshotPath());
- Log.log("SDK image setting is successful. InstallManager will be refreshed");
- InstallManagerWindow.getInstallManagerWindow().refresh();
- } else {
- Log.log("Configuration dialog is canceled.");
- }
- rDialog.clear();
- }
- });
- }
-
- private void setProxyLabel(Composite composite) {
- proxyLabel = new Label(composite, SWT.RIGHT | SWT.UNDERLINE_SINGLE);
- proxyLabel.setText("Proxy settings");
- proxyLabel.setBounds(475, 235, 100, 25);
- proxyLabel.setForeground(new Color(null, new RGB(255, 255, 255)));
- proxyLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));
-// proxyLabel.setBackgroundImage(
-// PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));
-
- final Cursor handCur = new Cursor(getDisplay(), SWT.CURSOR_HAND);
- final Cursor arrowCur = new Cursor(getDisplay(), SWT.CURSOR_ARROW);
- proxyLabel.addMouseTrackListener(new MouseTrackAdapter() {
- @Override
- public void mouseEnter(MouseEvent e) {
- proxyLabel.setCursor(handCur);
- }
- @Override
- public void mouseExit(MouseEvent e) {
- proxyLabel.setCursor(arrowCur);
- }
- });
-
- proxyLabel.addMouseListener(new MouseAdapter(){
- @Override
- public void mouseUp(MouseEvent e) {
-
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- // TODO Auto-generated method stub
- System.out.println("button is pushed.");
- ConfigFile configFile = Config.getInstance().getConfigFile();
- ProxySettingsDialog psDialog = new ProxySettingsDialog(getShell());
-
- psDialog.setProxySettings(configFile.getProxyType(),
- configFile.getProxyHost(),
- configFile.getProxyPort());
-
- psDialog.open();
- }
- });
- }
-
- private void setUninstallButton(Composite composite) {
- unInstallIconLabel = new Label(composite, SWT.NONE);
- unInstallIconLabel.setImage(PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_ICON));
- unInstallIconLabel.setBounds(56, 311, 55, 55);
- unInstallIconLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));
-
- unInstallTextLabel = new Label(composite, SWT.NONE);
- unInstallTextLabel.setText("Uninstall");
- unInstallTextLabel.setBounds(132, 307, 140, 30);
- unInstallTextLabel.setForeground(new Color(null, new RGB(255, 255, 255)));
- unInstallTextLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 24, SWT.NONE))));
- unInstallTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));
-
- unInstallSubTextLabel = new Label(composite, SWT.NONE);
- unInstallSubTextLabel.setText("Uninstall the Tizen SDK");
- unInstallSubTextLabel.setBounds(132, 347, 230, 25);
- unInstallSubTextLabel.setForeground(new Color(null, new RGB(255, 255, 255)));
- unInstallSubTextLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));
- unInstallSubTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));
-
- buttonUninstall = new IMButton(composite, SWT.NONE);
- buttonUninstall.setImage(PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL),
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_HOVER));
-
- buttonUninstall.setSize(new Rectangle(33, 295, 558, 86));
-
- buttonUninstall.addMouseTrackListener(new MouseTrackAdapter() {
- @Override
- public void mouseEnter(MouseEvent e) {
- unInstallIconLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_HOVER_BACKGROUND));
- unInstallTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_HOVER_BACKGROUND));
- unInstallSubTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_HOVER_BACKGROUND));
- }
- @Override
- public void mouseExit(MouseEvent e) {
- unInstallIconLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));
- unInstallTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));
- unInstallSubTextLabel.setBackgroundImage(
- PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));
- }
- });
-
- buttonUninstall.addMouseListener(new MouseAdapter(){
- @Override
- public void mouseUp(MouseEvent e) {
-
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- System.out.println("uninstall button is pushed.");
- if (buttonUninstall.getEnabledFlag()) {
- buttonUninstall.setSelection(true);
- Config.status = Config.Status.UNINSTALL;
- selectedButton = INSTALLMANAGER_ACTION.UNINSTALL;
- mainWindow.getNextButton().notifyListeners(SWT.Selection, new Event());
- }
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- System.out.println("double click.");
- }
- });
- }
-
- private void setUpdateButton() {
- buttonUpdate = new Button(customComposite, SWT.RADIO);
- buttonUpdate.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedButton = INSTALLMANAGER_ACTION.UPDATE;
- Config.status = Config.Status.UPDATE;
- updateCombo.setEnabled(true);
- uninstallCombo.setEnabled(false);
- }
- });
- buttonUpdate.setBounds(26, 85, 250, 22);
- buttonUpdate.setText("Update " + Config.SDK_NAME + " version.");
- buttonUpdate.setBackground(InstallManagerWindow.getBackgroundColor());
- }
-
- private void setUpdateCombo() {
- updateCombo = new Combo(customComposite, SWT.READ_ONLY);
-
- ArrayList<String> sdkList = Registry.getSDKPath();
- if (!sdkList.isEmpty()) {
- for (String sdk : sdkList) {
- if (sdk != null) {
- updateCombo.add(sdk);
- }
- }
- String current = getDefaultVisiblePath(sdkList);
- if (current != null) {
- updateCombo.setText(current);
- } else {
- updateCombo.setText(updateCombo.getItem(0));
- }
- Config.setSelectedSDKPath(updateCombo.getText());
- } else {
- updateCombo.setText("");
- }
-
- updateCombo.setBounds(280, 85, 200, 22);
- updateCombo.setEnabled(false);
-
- updateCombo.addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- // TODO Auto-generated method stub
- Config.setSelectedSDKPath(updateCombo.getText());
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // TODO Auto-generated method stub
- }
- });
- }
-
- private void setUninstallCombo() {
- uninstallCombo = new Combo(customComposite, SWT.READ_ONLY);
-
- ArrayList<String> sdkList = Registry.getSDKPath();
- if (!sdkList.isEmpty()) {
- for (String sdk : sdkList) {
- if (sdk != null) {
- uninstallCombo.add(sdk);
- }
- }
- String current = getDefaultVisiblePath(sdkList);
- if (current != null) {
- uninstallCombo.setText(current);
- } else {
- uninstallCombo.setText(uninstallCombo.getItem(0));
- }
- Config.setSelectedSDKPath(uninstallCombo.getText());
- } else {
- uninstallCombo.setText("");
- }
-
- uninstallCombo.setBounds(280, 130, 200, 22);
- uninstallCombo.setEnabled(false);
-
- uninstallCombo.addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- // TODO Auto-generated method stub
- Config.setSelectedSDKPath(uninstallCombo.getText());
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // TODO Auto-generated method stub
- }
- });
- }
-
- private void setConfigurationButton() {
- configurationButton = new Button(customComposite, SWT.PUSH);
- configurationButton.setText("Advanced");
- configurationButton.setBackground(InstallManagerWindow.getBackgroundColor());
-
- configurationButton.setBounds(509, 120, 100, 29);
- configurationButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- rDialog = new ConfigurationDialog(customComposite.getShell());
-
- //set information to configuration dialog.
- ConfigFile confFile = Config.getInstance().getConfigFile();
- rDialog.setRepository(confFile.getRepository());
- rDialog.setCurrentDistribution(confFile.getDistribution());
- rDialog.setSnapshotPath(confFile.getSnapshotPath());
-
- int ret = rDialog.open();
- if (ret == 0){
- viewController.saveSnapshotSettings(rDialog.getRepository(), rDialog.getCurrentDistribution(), rDialog.getServerType(), rDialog.getSnapshotPath());
- Log.log("SDK image setting is successful. InstallManager will be refreshed");
- InstallManagerWindow.getInstallManagerWindow().refresh();
- } else {
- Log.log("Configuration dialog is canceled.");
- }
- rDialog.clear();
- }
- });
- }
-
- /**
- * Set install status, and set radio button.
- * @param status
- */
- public void setButtonStatus() {
- if (Options.doRemoveOldSDK) {
- setErrorSubTitle("Old version SDK(Tizen SDK) is installed. " +
- "Tizen SDK can be installed after removing old Tizen SDK.");
-// buttonInstall.setSelection(false);
-// buttonUninstall.setSelection(true);
-
- buttonInstall.setEnabled(false);
- buttonUninstall.setEnabled(true);
-
- selectedButton = INSTALLMANAGER_ACTION.UNINSTALL;
- return;
- }
-
- if (viewController == null) {
- return;
- }
-
- if (!viewController.existRemovablePackage()) {
-// buttonInstall.setText("Install the new " + Config.SDK_NAME + " version.");
-// buttonInstall.setBounds(26, 40, 500, 22);
-
-// buttonInstall.setSelection(true);
-// buttonUninstall.setSelection(false);
-
- buttonInstall.setEnabled(true);
- buttonUninstall.setEnabledFlag(false);
-
- if (isMultiSdk) {
- buttonUpdate.setSelection(false);
- buttonUpdate.setEnabled(false);
- }
-
-// selectedRadioBtn = RADIO_ACTION.INSTALL;
-
- Config.status = Config.Status.INSTALL;
- }/* else if (!viewController.existInstallableOrUpdatablePackages()) {
- buttonInstall.setSelection(false);
- buttonUninstall.setSelection(true);
-
- buttonInstall.setEnabled(false);
- buttonUninstall.setEnabled(true);
-
- selectedRadioBtn = RADIO_ACTION.UNINSTALL;
-
- Config.status = Config.Status.UNINSTALL;
- }*/ else {
- if (isMultiSdk) {
-// buttonInstall.setText("Install the new " + Config.SDK_NAME + " version.");
- buttonUpdate.setSelection(false);
- buttonUpdate.setEnabled(true);
-
- } else {
-// buttonInstall.setText("Install or update the " + Config.SDK_NAME);
- buttonUninstall.setEnabledFlag(true);
- Config.status = Config.Status.UNINSTALL;
- }
-
-// buttonInstall.setSelection(true);
-// buttonUninstall.setSelection(false);
-
- installTextLabel.setText("Update");
- installTextLabel.setBounds(132, 197, 130, 33);
- buttonInstall.setEnabled(true);
- buttonUninstall.setEnabled(true);
-
-// selectedRadioBtn = RADIO_ACTION.INSTALL;
- }
- }
-
- /**
- * Get selected radio button object.
- * @return radio button object
- */
- public INSTALLMANAGER_ACTION getSelectedButton() {
- INSTALLMANAGER_ACTION result = this.selectedButton;
- return result;
- }
-
- /**
- * If selection is true, button will be displayed.
- * @param selection
- */
- public void setVisibleRadioButton(boolean selection) {
- buttonInstall.setVisible(selection);
- buttonUninstall.setVisible(selection);
- if (isMultiSdk) {
- buttonUpdate.setVisible(selection);
- uninstallCombo.setVisible(selection);
- updateCombo.setVisible(selection);
- }
- }
-
- /**
- * Set ViewController instance
- * @param controller
- */
- public void setViewController(ViewController controller) {
- if (controller != null) {
- viewController = controller;
- } else {
- Log.err("viewcontroller is null.");
- ErrorController.setErrorMessage("Cannot initialize controller.");
- throw new IMFatalException("Can not read package informaion.");
- }
- }
-
- private String getDefaultVisiblePath(ArrayList<String> sdkList) {
- String currentInstalledPath = Registry.getCurrentInstalledSDKPath();
-
- for (String path : sdkList) {
- if (currentInstalledPath.equalsIgnoreCase(path)) {
- return currentInstalledPath;
- }
- }
-
- return null;
- }
-
- /**
- * refresh welcome page.
- */
- public void refresh() {
- InstallManager.getInstance().initPackageList();
- setButtonStatus();
- }
-}
+/*\r
+* InstallManager\r
+*\r
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+*\r
+* Contact: \r
+* Wooyoung Cho <wooyoung1.cho@samsung.com>\r
+* Shihyun Kim <shihyun.kim@samsung.com>\r
+* Taeyoung Son <taeyoung2.son@samsung.com>\r
+* Yongsung kim <yongsung1.kim@samsung.com>\r
+* \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*\r
+* Contributors:\r
+* - S-Core Co., Ltd\r
+*\r
+*/\r
+\r
+package org.tizen.installmanager.ui.page;\r
+\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.MouseAdapter;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseTrackAdapter;\r
+import org.eclipse.swt.events.SelectionAdapter;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.Font;\r
+import org.eclipse.swt.graphics.FontData;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.graphics.RGB;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.graphics.Cursor;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Combo;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.tizen.installmanager.core.Config;\r
+import org.tizen.installmanager.core.IMFatalException;\r
+import org.tizen.installmanager.core.InstallManager;\r
+import org.tizen.installmanager.core.Options;\r
+import org.tizen.installmanager.lib.ErrorController;\r
+import org.tizen.installmanager.lib.Log;\r
+import org.tizen.installmanager.lib.Platform;\r
+import org.tizen.installmanager.lib.Registry;\r
+import org.tizen.installmanager.pkg.model.ConfigFile;\r
+import org.tizen.installmanager.ui.InstallManagerWindow;\r
+import org.tizen.installmanager.ui.dialog.ConfigurationDialog;\r
+import org.tizen.installmanager.ui.dialog.ProxySettingsDialog;\r
+import org.tizen.installmanager.ui.lib.IMButton;\r
+import org.tizen.installmanager.util.PathUtil;\r
+\r
+/**\r
+ * This class displays welcome page.\r
+ * @author Taeyoung Son <taeyoung2.son@samsung.ncom>\r
+ */\r
+public class WelcomePage extends PageTemplate {\r
+\r
+ static final String RSC_PATH_IMAGE = RESOURCE_PATH + "/install_manager_graphicmotif_welcome.png";\r
+ static final String RSC_PATH_IMAGE_NEW = RESOURCE_PATH_NEW + "/01_welcome_page_bg.png";\r
+ static final String RSC_INSTALL_BUTTON_NORMAL = RESOURCE_PATH_NEW + "/btn_welcome_page_install_normal.png";\r
+ static final String RSC_INSTALL_BUTTON_NORMAL_BACKGROUND = RESOURCE_PATH_NEW + "/btn_welcome_page_install_normal_background.png";\r
+ static final String RSC_INSTALL_BUTTON_ICON = RESOURCE_PATH_NEW + "/btn_welcome_page_install_icon.png";\r
+ static final String RSC_INSTALL_BUTTON_HOVER = RESOURCE_PATH_NEW + "/btn_welcome_page_install_hover.png";\r
+ static final String RSC_INSTALL_BUTTON_HOVER_BACKGROUND = RESOURCE_PATH_NEW + "/btn_welcome_page_install_hover_background.png";\r
+ static final String RSC_UNINSTALL_BUTTON_NORMAL = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_normal.png";\r
+ static final String RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_normal_background.png";\r
+ static final String RSC_UNINSTALL_BUTTON_ICON = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_icon.png";\r
+ static final String RSC_UNINSTALL_BUTTON_HOVER = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_hover.png";\r
+ static final String RSC_UNINSTALL_BUTTON_HOVER_BACKGROUND = RESOURCE_PATH_NEW + "/btn_welcome_page_uninstall_hover_background.png";\r
+ public static final String STRING_TITLE = "Welcome to Tizen SDK";\r
+ public static final String STRING_SUBTITLE1 = "Tizen SDK will be installed on your computer.";\r
+ public static final String STRING_SUBTITLE2 = "Close all other applications before starting the installation.";\r
+\r
+ private INSTALLMANAGER_ACTION selectedButton = INSTALLMANAGER_ACTION.INSTALL;\r
+ IMButton buttonInstall = null;\r
+ IMButton buttonUninstall = null;\r
+ Button buttonUpdate = null;\r
+ Button configurationButton = null;\r
+ \r
+ Label installIconLabel = null;\r
+ Label installTextLabel = null;\r
+ Label installSubTextLabel = null;\r
+ \r
+ Label unInstallIconLabel = null;\r
+ Label unInstallTextLabel = null;\r
+ Label unInstallSubTextLabel = null;\r
+ \r
+ Label advancedLabel = null;\r
+ Label proxyLabel = null;\r
+ \r
+ Combo updateCombo = null;\r
+ Combo uninstallCombo = null;\r
+ \r
+ ViewController viewController = null;\r
+ \r
+ ConfigurationDialog rDialog = null;\r
+ \r
+ InstallManagerWindow mainWindow = InstallManagerWindow.getInstallManagerWindow();\r
+ \r
+ boolean isMultiSdk = false;\r
+ \r
+ public enum INSTALLMANAGER_ACTION {\r
+ INSTALL,\r
+ UNINSTALL,\r
+ UPDATE\r
+ }\r
+\r
+ /**\r
+ * INSTALLED_NOTHING : Nothing to install before<br>\r
+ * INSTALLED_SOME_PACKAGES : Some packages are installed before<br>\r
+ * INSTALLED_ALL_PACKAGES : All packages are installed before<br>\r
+ * INSTALLED_AND_INSTALLABLE_NOTHING : Nothing to install before and now<br>\r
+ * INSTALLED_OLDSDK : There is no compatible old sdk and current sdk<br>\r
+ */\r
+ public enum InstalledStatus {\r
+ INSTALLED_NOTHING,\r
+ INSTALLED_SOME_PACKAGES,\r
+ INSTALLED_ALL_PACKAGES,\r
+ INSTALLED_AND_INSTALLABLE_NOTHING,\r
+ INSTALLED_OLDSDK\r
+ }\r
+\r
+\r
+ /**\r
+ * Create the composite.\r
+ * @param parent\r
+ * @param style\r
+ */\r
+ public WelcomePage(Composite parent, int style) {\r
+ super(parent, style, false);\r
+// setImageBounds(0, 0, 630, 144);\r
+// setImageBounds(0, 0, 150, 405);\r
+// setTitleBounds(20, 160, 400, 20);\r
+// setSubTitleBounds(20, 190, 600, 40);\r
+// setCustomCompositeBounds(0, 220, 620, 173);\r
+// setLeftImageFromResource(RSC_PATH_IMAGE_NEW);\r
+// setTitle(STRING_TITLE);\r
+// setSubTitle(STRING_SUBTITLE);\r
+\r
+ isMultiSdk = Config.isSupportMultiSDK();\r
+// setButton();\r
+ \r
+ setCustomCompositeBounds(0, 0, 628, 405); \r
+ Image welcomeImg = PathUtil.getImageFromResource(RSC_PATH_IMAGE_NEW);\r
+ customComposite.setBackgroundImage(welcomeImg);\r
+\r
+// Shell shell = parent.getShell();\r
+// shell.setBackgroundImage(welcomeImg);\r
+// shell.setBackgroundMode(SWT.INHERIT_DEFAULT);\r
+ \r
+ setWelcomeInfoLabel(customComposite);\r
+ setInstallButton(customComposite);\r
+ setUninstallButton(customComposite);\r
+ \r
+// parent.setLayout(null);\r
+// parent.pack();\r
+ System.out.println("asdfasdf");\r
+ }\r
+ \r
+ private void setButton() {\r
+// setInstallButton();\r
+// setUninstallButton();\r
+ setConfigurationButton();\r
+ if (isMultiSdk) {\r
+ setUpdateButton();\r
+ setUpdateCombo();\r
+ setUninstallCombo();\r
+ }\r
+ }\r
+ \r
+ private void setWelcomeInfoLabel(Composite composite) {\r
+ Label label_1 = new Label(composite, SWT.TRANSPARENT);\r
+ label_1.setBounds(18, 109, 400, 22);\r
+ label_1.setText(STRING_SUBTITLE1);\r
+ label_1.setForeground(new Color(null, new RGB(255, 255, 255)));\r
+ \r
+ Label label_2 = new Label(composite, SWT.NONE);\r
+ label_2.setBounds(18, 131, 400, 22);\r
+ label_2.setText(STRING_SUBTITLE2);\r
+ label_2.setForeground(new Color(null, new RGB(255, 255, 255)));\r
+ \r
+ if (Platform.isUbuntu()) {\r
+ label_1.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.BOLD))));\r
+ label_2.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.BOLD))));\r
+ } else if (Platform.isWindows()) {\r
+ label_1.setFont((new Font(Display.getCurrent(), new FontData("Verdana", 9, SWT.BOLD))));\r
+ label_2.setFont((new Font(Display.getCurrent(), new FontData("Verdana", 9, SWT.BOLD))));\r
+ }\r
+ }\r
+ \r
+ private void setInstallButton(Composite composite) {\r
+ setAdvancedLabel(composite);\r
+ setProxyLabel(composite);\r
+ installIconLabel = new Label(composite, SWT.NONE);\r
+ installIconLabel.setImage(PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_ICON));\r
+ installIconLabel.setBounds(56, 204, 55, 55);\r
+ installIconLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ \r
+ installTextLabel = new Label(composite, SWT.NONE);\r
+ installTextLabel.setText("Install");\r
+ installTextLabel.setBounds(132, 200, 100, 30);\r
+ installTextLabel.setForeground(new Color(null, new RGB(255, 255, 255)));\r
+ installTextLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 24, SWT.NONE))));\r
+ installTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ \r
+ installSubTextLabel = new Label(composite, SWT.NONE);\r
+ installSubTextLabel.setText("Install the latest version of Tizen SDK");\r
+ installSubTextLabel.setBounds(132, 240, 230, 25);\r
+ installSubTextLabel.setForeground(new Color(null, new RGB(255, 255, 255)));\r
+ installSubTextLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));\r
+ installSubTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ \r
+ buttonInstall = new IMButton(composite, SWT.NONE);\r
+ buttonInstall.setImage(PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL),\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER));\r
+ buttonInstall.setSize(new Rectangle(33, 188, 558, 86));\r
+ \r
+ buttonInstall.addMouseTrackListener(new MouseTrackAdapter() {\r
+ @Override\r
+ public void mouseEnter(MouseEvent e) {\r
+ installIconLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER_BACKGROUND));\r
+ installTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER_BACKGROUND));\r
+ installSubTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER_BACKGROUND));\r
+// proxyLabel.setBackgroundImage(\r
+// PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_HOVER_BACKGROUND));\r
+ }\r
+ @Override\r
+ public void mouseExit(MouseEvent e) {\r
+ installIconLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ installTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ installSubTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));\r
+// proxyLabel.setBackgroundImage(\r
+// PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ }\r
+ });\r
+\r
+ buttonInstall.addMouseListener(new MouseAdapter(){\r
+ @Override\r
+ public void mouseUp(MouseEvent e) {\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public void mouseDown(MouseEvent e) {\r
+ System.out.println("button is pushed.");\r
+ buttonInstall.setSelection(true);\r
+// mainWindow.showComposite(mainWindow.getComponentSelectionPage());\r
+ selectedButton = INSTALLMANAGER_ACTION.INSTALL;\r
+ Config.status = Config.Status.INSTALL;\r
+ mainWindow.getNextButton().notifyListeners(SWT.Selection, new Event());\r
+ }\r
+ \r
+ @Override\r
+ public void mouseDoubleClick(MouseEvent e) {\r
+ System.out.println("double click.");\r
+ }\r
+ });\r
+ }\r
+ \r
+ private void setAdvancedLabel(Composite composite) {\r
+ advancedLabel = new Label(composite, SWT.RIGHT | SWT.UNDERLINE_SINGLE);\r
+ advancedLabel.setText("Advanced");\r
+ advancedLabel.setBounds(475, 205, 100, 25);\r
+ advancedLabel.setForeground(new Color(null, new RGB(255, 255, 255)));\r
+ advancedLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));\r
+// proxyLabel.setBackgroundImage(\r
+// PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));\r
+\r
+ final Cursor handCur = new Cursor(getDisplay(), SWT.CURSOR_HAND);\r
+ final Cursor arrowCur = new Cursor(getDisplay(), SWT.CURSOR_ARROW);\r
+ advancedLabel.addMouseTrackListener(new MouseTrackAdapter() {\r
+ @Override\r
+ public void mouseEnter(MouseEvent e) {\r
+ advancedLabel.setCursor(handCur);\r
+ }\r
+ @Override\r
+ public void mouseExit(MouseEvent e) {\r
+ advancedLabel.setCursor(arrowCur);\r
+ }\r
+ });\r
+ \r
+ advancedLabel.addMouseListener(new MouseAdapter(){\r
+ @Override\r
+ public void mouseUp(MouseEvent e) {\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public void mouseDown(MouseEvent e) {\r
+ rDialog = new ConfigurationDialog(customComposite.getShell());\r
+ \r
+ //set information to configuration dialog.\r
+ ConfigFile confFile = Config.getInstance().getConfigFile();\r
+ rDialog.setRepository(confFile.getRepository());\r
+ rDialog.setCurrentDistribution(confFile.getDistribution());\r
+ rDialog.setSnapshotPath(confFile.getSnapshotPath());\r
+ \r
+ int ret = rDialog.open();\r
+ if (ret == 0){\r
+ viewController.saveSnapshotSettings(rDialog.getRepository(), rDialog.getCurrentDistribution(), rDialog.getServerType(), rDialog.getSnapshotPath());\r
+ Log.log("SDK image setting is successful. InstallManager will be refreshed");\r
+ InstallManagerWindow.getInstallManagerWindow().refresh();\r
+ } else {\r
+ Log.log("Configuration dialog is canceled.");\r
+ }\r
+ rDialog.clear();\r
+ }\r
+ });\r
+ }\r
+ \r
+ private void setProxyLabel(Composite composite) {\r
+ proxyLabel = new Label(composite, SWT.RIGHT | SWT.UNDERLINE_SINGLE);\r
+ proxyLabel.setText("Proxy settings");\r
+ proxyLabel.setBounds(475, 235, 100, 25);\r
+ proxyLabel.setForeground(new Color(null, new RGB(255, 255, 255)));\r
+ proxyLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));\r
+// proxyLabel.setBackgroundImage(\r
+// PathUtil.getImageFromResource(RSC_INSTALL_BUTTON_NORMAL_BACKGROUND));\r
+\r
+ final Cursor handCur = new Cursor(getDisplay(), SWT.CURSOR_HAND);\r
+ final Cursor arrowCur = new Cursor(getDisplay(), SWT.CURSOR_ARROW);\r
+ proxyLabel.addMouseTrackListener(new MouseTrackAdapter() {\r
+ @Override\r
+ public void mouseEnter(MouseEvent e) {\r
+ proxyLabel.setCursor(handCur);\r
+ }\r
+ @Override\r
+ public void mouseExit(MouseEvent e) {\r
+ proxyLabel.setCursor(arrowCur);\r
+ }\r
+ });\r
+ \r
+ proxyLabel.addMouseListener(new MouseAdapter(){\r
+ @Override\r
+ public void mouseUp(MouseEvent e) {\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public void mouseDown(MouseEvent e) {\r
+ // TODO Auto-generated method stub\r
+ System.out.println("button is pushed.");\r
+ ConfigFile configFile = Config.getInstance().getConfigFile();\r
+ ProxySettingsDialog psDialog = new ProxySettingsDialog(getShell());\r
+ \r
+ psDialog.setProxySettings(configFile.getProxyType(), \r
+ configFile.getProxyHost(), \r
+ configFile.getProxyPort());\r
+ \r
+ psDialog.open();\r
+ }\r
+ });\r
+ }\r
+ \r
+ private void setUninstallButton(Composite composite) {\r
+ unInstallIconLabel = new Label(composite, SWT.NONE);\r
+ unInstallIconLabel.setImage(PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_ICON));\r
+ unInstallIconLabel.setBounds(56, 311, 55, 55);\r
+ unInstallIconLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ \r
+ unInstallTextLabel = new Label(composite, SWT.NONE);\r
+ unInstallTextLabel.setText("Uninstall");\r
+ unInstallTextLabel.setBounds(132, 307, 140, 30);\r
+ unInstallTextLabel.setForeground(new Color(null, new RGB(255, 255, 255)));\r
+ unInstallTextLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 24, SWT.NONE))));\r
+ unInstallTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ \r
+ unInstallSubTextLabel = new Label(composite, SWT.NONE);\r
+ unInstallSubTextLabel.setText("Uninstall the Tizen SDK");\r
+ unInstallSubTextLabel.setBounds(132, 347, 230, 25);\r
+ unInstallSubTextLabel.setForeground(new Color(null, new RGB(255, 255, 255)));\r
+ unInstallSubTextLabel.setFont((new Font(Display.getCurrent(), new FontData("Dejavu Sans", 9, SWT.NONE))));\r
+ unInstallSubTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ \r
+ buttonUninstall = new IMButton(composite, SWT.NONE);\r
+ buttonUninstall.setImage(PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL),\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_HOVER));\r
+\r
+ buttonUninstall.setSize(new Rectangle(33, 295, 558, 86));\r
+ \r
+ buttonUninstall.addMouseTrackListener(new MouseTrackAdapter() {\r
+ @Override\r
+ public void mouseEnter(MouseEvent e) {\r
+ unInstallIconLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_HOVER_BACKGROUND));\r
+ unInstallTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_HOVER_BACKGROUND));\r
+ unInstallSubTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_HOVER_BACKGROUND));\r
+ }\r
+ @Override\r
+ public void mouseExit(MouseEvent e) {\r
+ unInstallIconLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ unInstallTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ unInstallSubTextLabel.setBackgroundImage(\r
+ PathUtil.getImageFromResource(RSC_UNINSTALL_BUTTON_NORMAL_BACKGROUND));\r
+ }\r
+ });\r
+\r
+ buttonUninstall.addMouseListener(new MouseAdapter(){\r
+ @Override\r
+ public void mouseUp(MouseEvent e) {\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public void mouseDown(MouseEvent e) {\r
+ System.out.println("uninstall button is pushed.");\r
+ if (buttonUninstall.getEnabledFlag()) {\r
+ buttonUninstall.setSelection(true);\r
+ Config.status = Config.Status.UNINSTALL;\r
+ selectedButton = INSTALLMANAGER_ACTION.UNINSTALL;\r
+ mainWindow.getNextButton().notifyListeners(SWT.Selection, new Event()); \r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public void mouseDoubleClick(MouseEvent e) {\r
+ System.out.println("double click.");\r
+ } \r
+ });\r
+ }\r
+ \r
+ private void setUpdateButton() {\r
+ buttonUpdate = new Button(customComposite, SWT.RADIO);\r
+ buttonUpdate.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ selectedButton = INSTALLMANAGER_ACTION.UPDATE;\r
+ Config.status = Config.Status.UPDATE;\r
+ updateCombo.setEnabled(true);\r
+ uninstallCombo.setEnabled(false);\r
+ }\r
+ });\r
+ buttonUpdate.setBounds(26, 85, 250, 22);\r
+ buttonUpdate.setText("Update " + Config.SDK_NAME + " version.");\r
+ buttonUpdate.setBackground(InstallManagerWindow.getBackgroundColor());\r
+ }\r
+ \r
+ private void setUpdateCombo() {\r
+ updateCombo = new Combo(customComposite, SWT.READ_ONLY);\r
+ \r
+ ArrayList<String> sdkList = Registry.getSDKPath();\r
+ if (!sdkList.isEmpty()) {\r
+ for (String sdk : sdkList) {\r
+ if (sdk != null) {\r
+ updateCombo.add(sdk); \r
+ }\r
+ }\r
+ String current = getDefaultVisiblePath(sdkList);\r
+ if (current != null) {\r
+ updateCombo.setText(current);\r
+ } else {\r
+ updateCombo.setText(updateCombo.getItem(0));\r
+ }\r
+ Config.setSelectedSDKPath(updateCombo.getText());\r
+ } else {\r
+ updateCombo.setText("");\r
+ }\r
+ \r
+ updateCombo.setBounds(280, 85, 200, 22);\r
+ updateCombo.setEnabled(false);\r
+ \r
+ updateCombo.addSelectionListener(new SelectionListener() {\r
+ \r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ // TODO Auto-generated method stub\r
+ Config.setSelectedSDKPath(updateCombo.getText());\r
+ }\r
+ \r
+ @Override\r
+ public void widgetDefaultSelected(SelectionEvent e) {\r
+ // TODO Auto-generated method stub\r
+ }\r
+ });\r
+ }\r
+ \r
+ private void setUninstallCombo() {\r
+ uninstallCombo = new Combo(customComposite, SWT.READ_ONLY);\r
+ \r
+ ArrayList<String> sdkList = Registry.getSDKPath();\r
+ if (!sdkList.isEmpty()) {\r
+ for (String sdk : sdkList) {\r
+ if (sdk != null) {\r
+ uninstallCombo.add(sdk); \r
+ }\r
+ }\r
+ String current = getDefaultVisiblePath(sdkList);\r
+ if (current != null) {\r
+ uninstallCombo.setText(current);\r
+ } else {\r
+ uninstallCombo.setText(uninstallCombo.getItem(0));\r
+ }\r
+ Config.setSelectedSDKPath(uninstallCombo.getText());\r
+ } else {\r
+ uninstallCombo.setText("");\r
+ }\r
+\r
+ uninstallCombo.setBounds(280, 130, 200, 22);\r
+ uninstallCombo.setEnabled(false);\r
+ \r
+ uninstallCombo.addSelectionListener(new SelectionListener() {\r
+ \r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ // TODO Auto-generated method stub\r
+ Config.setSelectedSDKPath(uninstallCombo.getText());\r
+ }\r
+ \r
+ @Override\r
+ public void widgetDefaultSelected(SelectionEvent e) {\r
+ // TODO Auto-generated method stub\r
+ }\r
+ }); \r
+ }\r
+ \r
+ private void setConfigurationButton() {\r
+ configurationButton = new Button(customComposite, SWT.PUSH);\r
+ configurationButton.setText("Advanced");\r
+ configurationButton.setBackground(InstallManagerWindow.getBackgroundColor());\r
+\r
+ configurationButton.setBounds(509, 120, 100, 29);\r
+ configurationButton.addSelectionListener(new SelectionAdapter() {\r
+ @Override\r
+ public void widgetSelected(SelectionEvent e) {\r
+ rDialog = new ConfigurationDialog(customComposite.getShell());\r
+ \r
+ //set information to configuration dialog.\r
+ ConfigFile confFile = Config.getInstance().getConfigFile();\r
+ rDialog.setRepository(confFile.getRepository());\r
+ rDialog.setCurrentDistribution(confFile.getDistribution());\r
+ rDialog.setSnapshotPath(confFile.getSnapshotPath());\r
+ \r
+ int ret = rDialog.open();\r
+ if (ret == 0){\r
+ viewController.saveSnapshotSettings(rDialog.getRepository(), rDialog.getCurrentDistribution(), rDialog.getServerType(), rDialog.getSnapshotPath());\r
+ Log.log("SDK image setting is successful. InstallManager will be refreshed");\r
+ InstallManagerWindow.getInstallManagerWindow().refresh();\r
+ } else {\r
+ Log.log("Configuration dialog is canceled.");\r
+ }\r
+ rDialog.clear();\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Set install status, and set radio button.\r
+ * @param status\r
+ */\r
+ public void setButtonStatus() {\r
+ if (Options.doRemoveOldSDK) {\r
+ setErrorSubTitle("Old version SDK(Tizen SDK) is installed. " +\r
+ "Tizen SDK can be installed after removing old Tizen SDK.");\r
+// buttonInstall.setSelection(false);\r
+// buttonUninstall.setSelection(true);\r
+ \r
+ buttonInstall.setEnabled(false);\r
+ buttonUninstall.setEnabled(true);\r
+\r
+ selectedButton = INSTALLMANAGER_ACTION.UNINSTALL;\r
+ return;\r
+ }\r
+ \r
+ if (viewController == null) {\r
+ return;\r
+ }\r
+ \r
+ if (!viewController.existRemovablePackage()) {\r
+// buttonInstall.setText("Install the new " + Config.SDK_NAME + " version.");\r
+// buttonInstall.setBounds(26, 40, 500, 22);\r
+\r
+// buttonInstall.setSelection(true);\r
+// buttonUninstall.setSelection(false);\r
+\r
+ buttonInstall.setEnabled(true);\r
+ buttonUninstall.setEnabledFlag(false);\r
+ \r
+ if (isMultiSdk) {\r
+ buttonUpdate.setSelection(false);\r
+ buttonUpdate.setEnabled(false);\r
+ }\r
+ \r
+// selectedRadioBtn = RADIO_ACTION.INSTALL;\r
+ \r
+ Config.status = Config.Status.INSTALL;\r
+ }/* else if (!viewController.existInstallableOrUpdatablePackages()) {\r
+ buttonInstall.setSelection(false);\r
+ buttonUninstall.setSelection(true);\r
+ \r
+ buttonInstall.setEnabled(false);\r
+ buttonUninstall.setEnabled(true);\r
+\r
+ selectedRadioBtn = RADIO_ACTION.UNINSTALL;\r
+ \r
+ Config.status = Config.Status.UNINSTALL;\r
+ }*/ else {\r
+ if (isMultiSdk) {\r
+// buttonInstall.setText("Install the new " + Config.SDK_NAME + " version.");\r
+ buttonUpdate.setSelection(false);\r
+ buttonUpdate.setEnabled(true);\r
+\r
+ } else {\r
+// buttonInstall.setText("Install or update the " + Config.SDK_NAME);\r
+ buttonUninstall.setEnabledFlag(true);\r
+ Config.status = Config.Status.UNINSTALL;\r
+ }\r
+\r
+// buttonInstall.setSelection(true);\r
+// buttonUninstall.setSelection(false);\r
+ \r
+ installTextLabel.setText("Update");\r
+ installTextLabel.setBounds(132, 197, 130, 33);\r
+ buttonInstall.setEnabled(true);\r
+ buttonUninstall.setEnabled(true);\r
+ \r
+// selectedRadioBtn = RADIO_ACTION.INSTALL;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Get selected radio button object.\r
+ * @return radio button object\r
+ */\r
+ public INSTALLMANAGER_ACTION getSelectedButton() {\r
+ INSTALLMANAGER_ACTION result = this.selectedButton;\r
+ return result;\r
+ }\r
+\r
+ /**\r
+ * If selection is true, button will be displayed. \r
+ * @param selection\r
+ */\r
+ public void setVisibleRadioButton(boolean selection) {\r
+ buttonInstall.setVisible(selection);\r
+ buttonUninstall.setVisible(selection);\r
+ if (isMultiSdk) {\r
+ buttonUpdate.setVisible(selection);\r
+ uninstallCombo.setVisible(selection);\r
+ updateCombo.setVisible(selection);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Set ViewController instance\r
+ * @param controller\r
+ */\r
+ public void setViewController(ViewController controller) {\r
+ if (controller != null) {\r
+ viewController = controller; \r
+ } else {\r
+ Log.err("viewcontroller is null.");\r
+ ErrorController.setErrorMessage("Cannot initialize controller.");\r
+ throw new IMFatalException("Can not read package informaion.");\r
+ }\r
+ }\r
+ \r
+ private String getDefaultVisiblePath(ArrayList<String> sdkList) {\r
+ String currentInstalledPath = Registry.getCurrentInstalledSDKPath();\r
+ \r
+ for (String path : sdkList) {\r
+ if (currentInstalledPath.equalsIgnoreCase(path)) {\r
+ return currentInstalledPath;\r
+ }\r
+ }\r
+ \r
+ return null;\r
+ }\r
+ \r
+ /**\r
+ * refresh welcome page.\r
+ */\r
+ public void refresh() {\r
+ InstallManager.getInstance().initPackageList();\r
+ setButtonStatus();\r
+ }\r
+}\r