public static void add(ClientStorageAccount clientStorageAccount) { String json = new Gson().toJson(clientStorageAccount); String[] values = DefaultLoader.getIdeHelper().getProperties(EXTERNAL_STORAGE_LIST); ArrayList<String> list = new ArrayList<String>(); if (values != null) { list.addAll(Arrays.asList(values)); } list.add(json); DefaultLoader.getIdeHelper() .setProperties(EXTERNAL_STORAGE_LIST, list.toArray(new String[list.size()])); }
public static void detach(ClientStorageAccount clientStorageAccount) { String[] storageArray = DefaultLoader.getIdeHelper().getProperties(EXTERNAL_STORAGE_LIST); if (storageArray != null) { ArrayList<String> storageList = Lists.newArrayList(storageArray); for (String json : storageArray) { ClientStorageAccount csa = new Gson().fromJson(json, ClientStorageAccount.class); if (csa.getName().equals(clientStorageAccount.getName())) { storageList.remove(json); } } if (storageList.size() == 0) { DefaultLoader.getIdeHelper().unsetProperty(EXTERNAL_STORAGE_LIST); } else { DefaultLoader.getIdeHelper() .setProperties( EXTERNAL_STORAGE_LIST, storageList.toArray(new String[storageList.size()])); } } }
public static List<ClientStorageAccount> getList() { List<ClientStorageAccount> list = new ArrayList<ClientStorageAccount>(); String[] storageArray = DefaultLoader.getIdeHelper().getProperties(EXTERNAL_STORAGE_LIST); if (storageArray != null) { for (String json : storageArray) { ClientStorageAccount clientStorageAccount = new Gson().fromJson(json, ClientStorageAccount.class); list.add(clientStorageAccount); } } return list; }
@Override public void actionPerformed(NodeActionEvent e) { try { // get the parent MobileServiceNode node MobileServiceNode mobileServiceNode = customAPINode.findParentByType(MobileServiceNode.class); MobileService mobileService = mobileServiceNode.getMobileService(); saveCustomAPI( (Project) customAPINode.getProject(), mobileService.getName(), mobileService.getSubcriptionId()); } catch (AzureCmdException e1) { DefaultLoader.getUIHelper() .showException( "An error occurred while attempting to upload script.", e1, "Azure Services Explorer - Error Uploading Script", false, true); } }
public ListenableFuture<List<Node>> load() { final RefreshableNode node = this; final SettableFuture<List<Node>> future = SettableFuture.create(); DefaultLoader.getIdeHelper() .runInBackground( getProject(), "Loading " + getName() + "...", false, true, null, new Runnable() { @Override public void run() { final String nodeName = node.getName(); node.setName(nodeName + " (Refreshing...)"); Futures.addCallback( future, new FutureCallback<List<Node>>() { @Override public void onSuccess(List<Node> nodes) { updateName(null); } @Override public void onFailure(Throwable throwable) { updateName(throwable); } private void updateName(final Throwable throwable) { DefaultLoader.getIdeHelper() .invokeLater( new Runnable() { @Override public void run() { node.setName(nodeName); if (throwable != null) { DefaultLoader.getUIHelper() .showException( "An error occurred while attempting " + "to load " + node.getName() + ".", throwable, "MS Services - Error Loading " + node.getName(), false, true); } } }); } }); node.refreshItems(future); } }); return future; }