binding2.setRealm(new Realm<String>("All", "10", "100", "500",
"1000", "10000"));
binding2.addCommitListener(new ICommitListener() {
public void commitPerformed(ICommand command) {
CTabItem selection = viewHolder.getSelection();
if (selection != null) {
BaseDataFacade bf = (BaseDataFacade) selection
.getData();
try {
bf.setLimit(Integer.parseInt(limit));
} catch (NumberFormatException e1) {
bf.setLimit(-1);
}
}
}
});
l.setBinding(binding2);
l.setLayoutData(GridDataFactory.fillDefaults().hint(50, -1)
.create());
ComboEnumeratedValueSelector<IProject> v = new ComboEnumeratedValueSelector<IProject>();
DisposeBindingListener.linkBindingLifeCycle(b, l);
binding = new Binding("");
binding.setRequired(true);
binding.setName("Project:");
projects = new Realm<IProject>();
initProjects(projects);
binding.setRealm(projects);
v.setBinding(binding);
if (projectString != null) {
for (IProject p : projects) {
if (p.getName().equals(projectString)) {
setProject(JavaCore.create(p));
}
}
}
DisposeBindingListener.linkBindingLifeCycle(binding, v);
binding.addValueListener(new IValueListener<Object>() {
public void valueChanged(Object oldValue, Object newValue) {
IProject pr = null;
if (newValue instanceof String) {
pr = ResourcesPlugin.getWorkspace().getRoot()
.getProject(newValue.toString());
}
if (newValue instanceof IProject) {
pr = (IProject) newValue;
}
if (pr != null) {
IJavaProject create = JavaCore.create(pr);
if (project == null
|| !create.getElementName().equals(
project.getElementName())) {
setProject(create);
}
} else {
setProject(null);
}
}
});
binding.setAdapter(ITextLabelProvider.class,
new ITextLabelProvider() {
public String getText(Object object) {
if (object == null) {
return "";
}
IProject p = (IProject) object;
return p.getName();
}
public String getDescription(Object object) {
return "";
}
});
r.add(l);
r.add(v);
r.add(new UniversalUIElement<ToolBar>(ToolBar.class, SWT.NONE) {
protected ToolBar createControl(Composite conComposite) {
ToolBarManager tm = new ToolBarManager();
tm.add(new Action("Add view") { // Add view from development
// server
{
/*
* ToolBarManager tm = new ToolBarManager(); boolean
* isLocal =
* Activator.getDefault().getPreferenceStore()
* .getDefaultBoolean("CONNECTION_MODE");
*/
/*
* if(isLocal){
* setText("Add view from local server");
* setToolTipText("Add view from local server");
*/
setImageDescriptor(Activator
.imageDescriptorFromPlugin(
Activator.PLUGIN_ID,
"/icons/exec_view_obj.gif"));
// setT
/*
* }else{
* setText("Add view from production server");
* setToolTipText
* ("Add view from production server");
*
* setImageDescriptor(Activator
* .imageDescriptorFromPlugin( Activator.PLUGIN_ID,
* "/icons/locale.png"));
*
* }
*/
}
public void run() {
boolean isLocal = isDebug();
if (isLocal) {
addView(true);
} else {
addView(false);
}
}
});
/*
* tm.add(new Action("Add view from production server") {
*
* { setImageDescriptor(Activator
* .imageDescriptorFromPlugin( Activator.PLUGIN_ID,
* "/icons/locale.png")); }
*
* public void run() { addView(false); }
*
* });
*/
return tm.createControl(conComposite);
}
});
viewHolder.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
CTabItem selection = viewHolder.getSelection();
// BaseDataFacade bf = (BaseDataFacade) selection.getData();
BlobStoreDataFacade bf = (BlobStoreDataFacade) selection
.getData();
try {
bf.setLimit(Integer.parseInt(limit));
} catch (NumberFormatException e1) {
bf.setLimit(-1);
}
tableUi.setFacade(bf);
String text = bf.getStatus();
statLabel.setText(text);
status.layout(true);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
status = new Composite(viewHolder, SWT.NONE);
GridLayout layout3 = new GridLayout();
layout3.marginHeight = 2;
status.setLayout(layout3);
statLabel = new Label(status, SWT.RIGHT);
statLabel.setText("Status");
statLabel.setLayoutData(GridDataFactory.fillDefaults()
.align(GridData.END, GridData.CENTER).grab(true, false)
.create());
statLabel.setForeground(Display.getCurrent().getSystemColor(
SWT.COLOR_LIST_SELECTION));
viewHolder.setTopRight(status, SWT.FILL);
viewHolder.addCTabFolder2Listener(new CTabFolder2Listener() {
public void showList(CTabFolderEvent event) {
}
public void restore(CTabFolderEvent event) {
}
public void minimize(CTabFolderEvent event) {
}
public void maximize(CTabFolderEvent event) {
}
public void close(CTabFolderEvent event) {
CTabItem widget = (CTabItem) event.item;
widget.getControl().dispose();
if (viewHolder.getItemCount() == 1) {
pageBook.showPage(lm);
for (IContributionItem i : toolBarManager.getItems()) {
ActionContributionItem b = (ActionContributionItem) i;
b.getAction().setEnabled(false);