Search in sources :

Example 1 with GwtDeploymentPackage

use of org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage in project kapua by eclipse.

the class DeviceTabPackages method openUninstallDialog.

private void openUninstallDialog() {
    final GwtDeploymentPackage selectedDeploymentPackage = installedPackageTab.getSelectedDeploymentPackage();
    if (selectedDeploymentPackage != null) {
        toolBar.disable();
        final PackageUninstallDialog packageUninstallDialog = new PackageUninstallDialog(selectedDevice.getScopeId(), selectedDevice.getId(), selectedDeploymentPackage);
        packageUninstallDialog.addListener(Events.Hide, new Listener<BaseEvent>() {

            @Override
            public void handleEvent(BaseEvent be) {
                toolBar.enable();
                Boolean exitStatus = packageUninstallDialog.getExitStatus();
                if (exitStatus == null) {
                    // Operation Aborted
                    return;
                } else {
                    InfoDialogType exitDialogType;
                    String exitMessage = packageUninstallDialog.getExitMessage();
                    if (exitStatus == true) {
                        // Operation Success
                        exitDialogType = InfoDialogType.INFO;
                    } else {
                        // Operaton Failed
                        exitDialogType = InfoDialogType.ERROR;
                    }
                    // 
                    // Exit dialog
                    InfoDialog exitDialog = new InfoDialog(exitDialogType, exitMessage);
                    exitDialog.show();
                    m_uninstallButton.disable();
                    m_deviceTabs.setDevice(selectedDevice);
                }
            }
        });
        packageUninstallDialog.show();
    }
}
Also used : InfoDialogType(org.eclipse.kapua.app.console.client.widget.dialog.InfoDialog.InfoDialogType) GwtDeploymentPackage(org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage) InfoDialog(org.eclipse.kapua.app.console.client.widget.dialog.InfoDialog) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent)

Example 2 with GwtDeploymentPackage

use of org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage in project kapua by eclipse.

the class DeviceTabPackagesInstalled method refresh.

public void refresh() {
    if (m_dirty && m_initialized) {
        GwtDevice selectedDevice = getSelectedDevice();
        if (selectedDevice == null || !selectedDevice.isOnline()) {
            m_treeStore.removeAll();
            m_treeGrid.unmask();
            m_treeGrid.getView().setEmptyText(MSGS.deviceNoDeviceSelectedOrOffline());
        } else {
            m_treeGrid.mask(MSGS.loading());
            gwtDeviceManagementService.findDevicePackages(selectedDevice.getScopeId(), selectedDevice.getId(), new AsyncCallback<List<GwtDeploymentPackage>>() {

                @Override
                public void onSuccess(List<GwtDeploymentPackage> packages) {
                    m_treeStore.removeAll();
                    if (packages != null && !packages.isEmpty()) {
                        for (GwtDeploymentPackage pkg : packages) {
                            m_treeStore.add(pkg, false);
                            if (pkg.getBundleInfos() != null) {
                                for (GwtBundleInfo bundle : pkg.getBundleInfos()) {
                                    m_treeStore.add(pkg, bundle, false);
                                }
                            }
                        }
                    } else {
                        m_rootTabPanel.getUninstallButton().disable();
                        m_treeGrid.getView().setEmptyText(MSGS.deviceNoPackagesInstalled());
                        m_treeGrid.getView().refresh(false);
                    }
                    m_treeGrid.unmask();
                }

                @Override
                public void onFailure(Throwable caught) {
                    FailureHandler.handle(caught);
                    m_treeGrid.unmask();
                }
            });
        }
        m_dirty = false;
    }
}
Also used : GwtDevice(org.eclipse.kapua.app.console.shared.model.GwtDevice) GwtDeploymentPackage(org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage) List(java.util.List) GwtBundleInfo(org.eclipse.kapua.app.console.shared.model.GwtBundleInfo)

Example 3 with GwtDeploymentPackage

use of org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage in project kapua by eclipse.

the class DeviceTabPackagesInstalled method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    ColumnConfig name = new ColumnConfig("name", "Name", 100);
    name.setRenderer(new TreeGridCellRenderer<ModelData>());
    ColumnConfig version = new ColumnConfig("version", "Version", 150);
    version.setSortable(false);
    ColumnModel cm = new ColumnModel(Arrays.asList(name, version));
    m_treeGrid = new TreeGrid<ModelData>(m_treeStore, cm);
    m_treeGrid.setBorders(false);
    m_treeGrid.setLoadMask(true);
    m_treeGrid.getStyle().setLeafIcon(AbstractImagePrototype.create(Resources.INSTANCE.plugin()));
    m_treeGrid.setAutoExpandColumn("name");
    m_treeGrid.setTrackMouseOver(false);
    m_treeGrid.getAriaSupport().setLabelledBy(getHeader().getId() + "-label");
    m_treeGrid.getView().setAutoFill(true);
    m_treeGrid.getView().setEmptyText(MSGS.deviceNoDeviceSelectedOrOffline());
    m_treeGrid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<ModelData>() {

        @Override
        public void selectionChanged(SelectionChangedEvent<ModelData> se) {
            ModelData selectedItem = se.getSelectedItem();
            // Check if it's a package or a bundle
            if (selectedItem instanceof GwtDeploymentPackage) {
                m_rootTabPanel.getUninstallButton().enable();
            } else {
                m_rootTabPanel.getUninstallButton().disable();
            }
        }
    });
    add(m_treeGrid);
    m_initialized = true;
}
Also used : ModelData(com.extjs.gxt.ui.client.data.ModelData) ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) GwtDeploymentPackage(org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel)

Example 4 with GwtDeploymentPackage

use of org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage in project kapua by eclipse.

the class GwtDeviceManagementServiceImpl method findDevicePackages.

// 
// Packages
// 
@Override
public List<GwtDeploymentPackage> findDevicePackages(String scopeShortId, String deviceShortId) throws GwtKapuaException {
    List<GwtDeploymentPackage> gwtPkgs = new ArrayList<GwtDeploymentPackage>();
    try {
        KapuaLocator locator = KapuaLocator.getInstance();
        DevicePackageManagementService deviceManagementService = locator.getService(DevicePackageManagementService.class);
        KapuaId scopeId = KapuaEid.parseShortId(scopeShortId);
        KapuaId deviceId = KapuaEid.parseShortId(deviceShortId);
        DevicePackages deploymentPackages = deviceManagementService.getInstalled(scopeId, deviceId, null);
        for (DevicePackage deploymentPackage : deploymentPackages.getPackages()) {
            GwtDeploymentPackage gwtPkg = new GwtDeploymentPackage();
            gwtPkg.setName(deploymentPackage.getName());
            gwtPkg.setVersion(deploymentPackage.getVersion());
            DevicePackageBundleInfos devicePackageBundleInfos = deploymentPackage.getBundleInfos();
            if (devicePackageBundleInfos != null) {
                List<GwtBundleInfo> gwtBundleInfos = new ArrayList<GwtBundleInfo>();
                for (DevicePackageBundleInfo bundleInfo : devicePackageBundleInfos.getBundlesInfos()) {
                    GwtBundleInfo gwtBundleInfo = new GwtBundleInfo();
                    gwtBundleInfo.setName(bundleInfo.getName());
                    gwtBundleInfo.setVersion(bundleInfo.getVersion());
                    gwtBundleInfos.add(gwtBundleInfo);
                }
                gwtPkg.setBundleInfos(gwtBundleInfos);
            }
            gwtPkgs.add(gwtPkg);
        }
    } catch (Throwable t) {
        KapuaExceptionHandler.handle(t);
    }
    return gwtPkgs;
}
Also used : KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) GwtDeploymentPackage(org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage) ArrayList(java.util.ArrayList) DevicePackageBundleInfo(org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfo) DevicePackage(org.eclipse.kapua.service.device.management.packages.model.DevicePackage) DevicePackages(org.eclipse.kapua.service.device.management.packages.model.DevicePackages) DevicePackageManagementService(org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService) DevicePackageBundleInfos(org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfos) KapuaId(org.eclipse.kapua.model.id.KapuaId) GwtBundleInfo(org.eclipse.kapua.app.console.shared.model.GwtBundleInfo)

Aggregations

GwtDeploymentPackage (org.eclipse.kapua.app.console.shared.model.GwtDeploymentPackage)4 GwtBundleInfo (org.eclipse.kapua.app.console.shared.model.GwtBundleInfo)2 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)1 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 InfoDialog (org.eclipse.kapua.app.console.client.widget.dialog.InfoDialog)1 InfoDialogType (org.eclipse.kapua.app.console.client.widget.dialog.InfoDialog.InfoDialogType)1 GwtDevice (org.eclipse.kapua.app.console.shared.model.GwtDevice)1 KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)1 KapuaId (org.eclipse.kapua.model.id.KapuaId)1 DevicePackageManagementService (org.eclipse.kapua.service.device.management.packages.DevicePackageManagementService)1 DevicePackage (org.eclipse.kapua.service.device.management.packages.model.DevicePackage)1 DevicePackageBundleInfo (org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfo)1 DevicePackageBundleInfos (org.eclipse.kapua.service.device.management.packages.model.DevicePackageBundleInfos)1 DevicePackages (org.eclipse.kapua.service.device.management.packages.model.DevicePackages)1