Search in sources :

Example 1 with RepositoryPropertiesDlg

use of org.netxms.ui.eclipse.market.dialogs.RepositoryPropertiesDlg in project netxms by netxms.

the class RepositoryManager method addRepository.

/**
 * Add repository
 */
private void addRepository() {
    RepositoryPropertiesDlg dlg = new RepositoryPropertiesDlg(getSite().getShell(), null);
    if (dlg.open() != Window.OK)
        return;
    final Repository repository = new Repository(dlg.getUrl(), dlg.getToken(), dlg.getDescription());
    new ConsoleJob("Add repository", this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            session.addRepository(repository);
            runInUIThread(new Runnable() {

                @SuppressWarnings("unchecked")
                @Override
                public void run() {
                    ArrayList<RepositoryRuntimeInfo> repositories = (ArrayList<RepositoryRuntimeInfo>) viewer.getInput();
                    repositories.add(new RepositoryRuntimeInfo(repository));
                    viewer.refresh();
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return "Cannot add repository";
        }
    }.start();
}
Also used : RepositoryPropertiesDlg(org.netxms.ui.eclipse.market.dialogs.RepositoryPropertiesDlg) Repository(org.netxms.client.market.Repository) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) RepositoryRuntimeInfo(org.netxms.ui.eclipse.market.objects.RepositoryRuntimeInfo)

Aggregations

ArrayList (java.util.ArrayList)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Repository (org.netxms.client.market.Repository)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 RepositoryPropertiesDlg (org.netxms.ui.eclipse.market.dialogs.RepositoryPropertiesDlg)1 RepositoryRuntimeInfo (org.netxms.ui.eclipse.market.objects.RepositoryRuntimeInfo)1