Search in sources :

Example 41 with IProject

use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.

the class EditDefaultRouteHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final Shell shell = HandlerUtil.getActiveShell(event);
    ISelection currentSelection = UIUtils.getCurrentSelection(event);
    IServiceWrapper service = UIUtils.getFirstElement(currentSelection, IServiceWrapper.class);
    if (service != null) {
        new RouteOpenerJob(service.getWrapped().getNamespaceName(), shell) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                this.routes = service.getResourcesOfKind(ResourceKind.ROUTE).stream().map(r -> (IRoute) r.getWrapped()).collect(Collectors.toList());
                return Status.OK_STATUS;
            }
        }.schedule();
        return Status.OK_STATUS;
    }
    final IProject project = UIUtils.getFirstElement(currentSelection, IProject.class);
    if (project != null) {
        new RouteOpenerJob(project.getName(), shell) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                this.routes = project.getResources(ResourceKind.ROUTE);
                return Status.OK_STATUS;
            }
        }.schedule();
        return Status.OK_STATUS;
    }
    return Status.OK_STATUS;
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) Shell(org.eclipse.swt.widgets.Shell) ResourceKind(com.openshift.restclient.ResourceKind) NLS(org.eclipse.osgi.util.NLS) SelectRouteDialog(org.jboss.tools.openshift.internal.ui.dialog.SelectRouteDialog) Status(org.eclipse.core.runtime.Status) ExecutionException(org.eclipse.core.commands.ExecutionException) Collectors(java.util.stream.Collectors) IServiceWrapper(org.jboss.tools.openshift.internal.ui.models.IServiceWrapper) IProject(com.openshift.restclient.model.IProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) HandlerUtil(org.eclipse.ui.handlers.HandlerUtil) List(java.util.List) IStatus(org.eclipse.core.runtime.IStatus) UIUtils(org.jboss.tools.openshift.internal.common.ui.utils.UIUtils) Dialog(org.eclipse.jface.dialogs.Dialog) IRoute(com.openshift.restclient.model.route.IRoute) UIUpdatingJob(org.jboss.tools.openshift.internal.common.ui.job.UIUpdatingJob) ISelection(org.eclipse.jface.viewers.ISelection) AbstractHandler(org.eclipse.core.commands.AbstractHandler) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IServiceWrapper(org.jboss.tools.openshift.internal.ui.models.IServiceWrapper) ISelection(org.eclipse.jface.viewers.ISelection) IRoute(com.openshift.restclient.model.route.IRoute) IProject(com.openshift.restclient.model.IProject)

Example 42 with IProject

use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.

the class ServerSettingsWizardPageModel method getDeployProject.

protected org.eclipse.core.resources.IProject getDeployProject(IResource resource) {
    // TODO: JBIDE-23490 check if association can be done for non service resources
    if (resource == null) {
        return null;
    }
    IProject openShiftProject = getOpenShiftProject(resource);
    List<IBuildConfig> buildConfigs = getBuildConfigs(openShiftProject);
    IBuildConfig buildConfig = ResourceUtils.getBuildConfigFor(resource, buildConfigs);
    return ResourceUtils.getWorkspaceProjectFor(buildConfig, getProjects());
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) IProject(com.openshift.restclient.model.IProject)

Example 43 with IProject

use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.

the class ManageProjectsWizardPage method createTable.

protected TableViewer createTable(Composite tableContainer) {
    Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    ICellToolTipProvider<IProject> cellToolTipProvider = new ICellToolTipProvider<IProject>() {

        @Override
        public String getToolTipText(IProject object) {
            return object.getDescription();
        }

        @Override
        public int getToolTipDisplayDelayTime(IProject object) {
            return 0;
        }
    };
    this.viewer = new TableViewerBuilder(table, tableContainer).contentProvider(new ArrayContentProvider()).column(new IColumnLabelProvider<IProject>() {

        @Override
        public String getValue(IProject project) {
            return project.getName();
        }
    }).cellToolTipProvider(cellToolTipProvider).name("Name").align(SWT.LEFT).weight(1).minWidth(75).buildColumn().column(new IColumnLabelProvider<IProject>() {

        @Override
        public String getValue(IProject project) {
            return project.getDisplayName();
        }
    }).cellToolTipProvider(cellToolTipProvider).name("Display Name").align(SWT.LEFT).weight(2).minWidth(100).buildColumn().buildViewer();
    return viewer;
}
Also used : IColumnLabelProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider) Table(org.eclipse.swt.widgets.Table) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ICellToolTipProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.ICellToolTipProvider) IProject(com.openshift.restclient.model.IProject) TableViewerBuilder(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder)

Example 44 with IProject

use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.

the class NewProjectWizardModel method createProject.

public IProject createProject() {
    if (connection == null) {
        OpenShiftUIActivator.getDefault().getLogger().logError("Could not create project, missing connection.");
        return null;
    }
    IProjectRequest request = connection.getResourceFactory().stub(ResourceKind.PROJECT_REQUEST, getProjectName());
    request.setDescription(getDescription());
    request.setDisplayName(getDisplayName());
    IProject project = (IProject) connection.createResource(request);
    List<IProject> newProjects = new ArrayList<>(projects);
    newProjects.add((IProject) connection.refresh(project));
    ConnectionsRegistrySingleton.getInstance().fireConnectionChanged(connection, ConnectionProperties.PROPERTY_PROJECTS, projects, Collections.unmodifiableList(newProjects));
    return this.project = project;
}
Also used : ArrayList(java.util.ArrayList) IProjectRequest(com.openshift.restclient.model.project.IProjectRequest) IProject(com.openshift.restclient.model.IProject)

Example 45 with IProject

use of com.openshift.restclient.model.IProject in project jbosstools-openshift by jbosstools.

the class NewResourceWizard method init.

@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
    Connection connection = UIUtils.getFirstElement(selection, Connection.class);
    if (connection == null) {
        IProject project = UIUtils.getFirstElement(selection, IProject.class);
        if (project != null) {
            model.setConnection(ConnectionsRegistryUtil.getConnectionFor(project));
            model.setProject(project);
        }
    } else {
        model.setConnection(connection);
    }
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IProject(com.openshift.restclient.model.IProject)

Aggregations

IProject (com.openshift.restclient.model.IProject)49 Test (org.junit.Test)18 Connection (org.jboss.tools.openshift.core.connection.Connection)16 IResource (com.openshift.restclient.model.IResource)13 ArrayList (java.util.ArrayList)8 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)7 ResourceKind (com.openshift.restclient.ResourceKind)6 IStatus (org.eclipse.core.runtime.IStatus)6 ObservableTreeItem (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem)6 List (java.util.List)5 ISelection (org.eclipse.jface.viewers.ISelection)5 IService (com.openshift.restclient.model.IService)4 IRoute (com.openshift.restclient.model.route.IRoute)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 OpenShiftException (com.openshift.restclient.OpenShiftException)3 IBuildConfig (com.openshift.restclient.model.IBuildConfig)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3