use of org.jboss.tools.openshift.internal.ui.models.IResourceWrapper in project jbosstools-openshift by jbosstools.
the class ManageEnvironmentVariablesWizard method findReplicationController.
/**
* If a replication controller is selected, method returns it.
* If a deployment config is selected, method returns it.
* If a deployment is selected, method finds a deployment config and returns it.
* @param event
* @return
*/
IReplicationController findReplicationController(ExecutionEvent event) {
ISelection selection = UIUtils.getCurrentSelection(event);
IDeploymentConfig dc = UIUtils.getFirstElement(selection, IDeploymentConfig.class);
if (dc != null) {
return dc;
}
IReplicationController rc = UIUtils.getFirstElement(selection, IReplicationController.class);
if (rc != null) {
return rc;
}
IServiceWrapper deployment = UIUtils.getFirstElement(selection, IServiceWrapper.class);
Collection<IResourceWrapper<?, ?>> dcs = deployment.getResourcesOfKind(ResourceKind.DEPLOYMENT_CONFIG);
if (!dcs.isEmpty()) {
dc = (IDeploymentConfig) dcs.iterator().next().getWrapped();
if (dc != null) {
return dc;
}
}
return null;
}
use of org.jboss.tools.openshift.internal.ui.models.IResourceWrapper in project jbosstools-openshift by jbosstools.
the class EventsPropertySection method addColumns.
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void addColumns(TableViewerBuilder tableViewerBuilder) {
addCreatedColumn(tableViewerBuilder);
ICellToolTipProvider toolTipProvider = new ICellToolTipProvider() {
@Override
public String getToolTipText(Object object) {
if (object instanceof IResourceWrapper && ((IResourceWrapper) object).getWrapped() instanceof IEvent) {
return ((IEvent) ((IResourceWrapper) object).getWrapped()).getMessage();
}
return null;
}
@Override
public int getToolTipDisplayDelayTime(Object event) {
return 0;
}
};
tableViewerBuilder.column(model -> StringUtils.substringBefore(getResource(model).getName(), ".")).name("Name").align(SWT.LEFT).weight(1).minWidth(15).cellToolTipProvider(toolTipProvider).buildColumn().column(model -> ((IEvent) getResource(model)).getInvolvedObject().getKind()).name("Kind").align(SWT.LEFT).weight(1).minWidth(5).cellToolTipProvider(toolTipProvider).buildColumn().column(model -> ((IEvent) getResource(model)).getReason()).name("Reason").align(SWT.LEFT).weight(1).minWidth(5).cellToolTipProvider(toolTipProvider).buildColumn();
}
use of org.jboss.tools.openshift.internal.ui.models.IResourceWrapper in project jbosstools-openshift by jbosstools.
the class OpenShiftResourcePropertySection method createCreationTimestampSorter.
protected ViewerComparator createCreationTimestampSorter(boolean descending) {
return new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
IResource r1 = ((IResourceWrapper<?, ?>) e1).getWrapped();
IResource r2 = ((IResourceWrapper<?, ?>) e2).getWrapped();
try {
Date d1 = DateTimeUtils.parse(r1.getCreationTimeStamp());
Date d2 = DateTimeUtils.parse(r2.getCreationTimeStamp());
return descending ? d2.compareTo(d1) : d1.compareTo(d2);
} catch (ParseException e) {
OpenShiftUIActivator.log(IStatus.ERROR, "Unable to parse dates in OpenShift Resource Property Tab Section", e);
}
return 0;
}
};
}
use of org.jboss.tools.openshift.internal.ui.models.IResourceWrapper in project jbosstools-openshift by jbosstools.
the class OpenShiftResourcePropertySection method createNameSorter.
protected ViewerComparator createNameSorter() {
return new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
IResource r1 = ((IResourceWrapper<?, ?>) e1).getWrapped();
IResource r2 = ((IResourceWrapper<?, ?>) e2).getWrapped();
return r1.getName().compareTo(r2.getName());
}
};
}
use of org.jboss.tools.openshift.internal.ui.models.IResourceWrapper in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerContentProvider method getProjectChildren.
protected Object[] getProjectChildren(IProjectWrapper project) {
switch(project.getState()) {
case LOADED:
removeStub(project);
Collection<IResourceWrapper<?, ?>> services = project.getResourcesOfKind(ResourceKind.SERVICE);
Collection<IReplicationControllerWrapper> dcs = project.getResourcesOfType(IReplicationControllerWrapper.class);
services.addAll(dcs);
Collection<IResourceWrapper<?, ?>> pods = project.getResourcesOfKind(ResourceKind.POD).stream().filter(wrapper -> ResourceUtils.isRuntimePod((IPod) wrapper.getWrapped()) && !((IPod) wrapper.getWrapped()).isAnnotatedWith(OpenShiftAPIAnnotations.DEPLOYMENT_NAME)).collect(Collectors.toList());
services.addAll(pods);
return services.toArray();
case LOAD_STOPPED:
LoadingStub stub = removeStub(project);
if (stub != null) {
return stub.getChildren();
}
default:
project.load(e -> {
handleLoadingException(project, e);
});
return new Object[] { makeStub(project) };
}
}
Aggregations