Utils.centreWindow(shell);
display = shell.getDisplay();
shell.setText(MessageText.getString("subscriptions.listwindow.title"));
shell.setLayout(new FormLayout());
mainComposite = new Composite(shell,SWT.NONE);
Label separator = new Label(shell,SWT.SEPARATOR | SWT.HORIZONTAL);
Button cancel = new Button(shell,SWT.PUSH);
action = new Button(shell,SWT.PUSH);
cancel.setText(MessageText.getString("Button.cancel"));
FormData data;
data = new FormData();
data.left = new FormAttachment(0,0);
data.right = new FormAttachment(100,0);
data.top = new FormAttachment(0,0);
data.bottom = new FormAttachment(separator,0);
mainComposite.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(0,0);
data.right = new FormAttachment(100,0);
data.bottom = new FormAttachment(cancel,-2);
separator.setLayoutData(data);
data = new FormData();
data.right = new FormAttachment(action);
data.width = 100;
data.bottom = new FormAttachment(100,-5);
cancel.setLayoutData(data);
data = new FormData();
data.right = new FormAttachment(100,-5);
data.width = 100;
data.bottom = new FormAttachment(100,-5);
action.setLayoutData(data);
cancel.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
if(lookup != null) {
lookup.cancel();
}
if(!shell.isDisposed()) {
shell.dispose();
}
}
});
mainLayout = new StackLayout();
mainComposite.setLayout(mainLayout);
loadingPanel = new Composite(mainComposite,SWT.NONE);
loadingPanel.setLayout(new FormLayout());
listPanel = new Composite(mainComposite,SWT.NONE);
listPanel.setLayout(new FillLayout());
subscriptionsList = new Table(listPanel,SWT.V_SCROLL | SWT.SINGLE | SWT.FULL_SELECTION | SWT.VIRTUAL);
subscriptionsList.setHeaderVisible(true);
TableColumn name = new TableColumn(subscriptionsList,SWT.NONE);
name.setText(MessageText.getString("subscriptions.listwindow.name"));
name.setWidth(310);
name.setResizable(false);
TableColumn popularity = new TableColumn(subscriptionsList,SWT.NONE);
popularity.setText(MessageText.getString("subscriptions.listwindow.popularity"));
popularity.setWidth(70);
popularity.setResizable(false);
subscriptionsList.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event e) {
TableItem item = (TableItem) e.item;
int index = subscriptionsList.indexOf(item);
if(index >= 0 && index < subscriptionItems.length) {
SubscriptionItemModel subscriptionItem = subscriptionItems[index];
item.setText(0,subscriptionItem.name);
item.setText(1,subscriptionItem.popularityDisplay);
}
}
});
subscriptionsList.setSortColumn(popularity);
subscriptionsList.setSortDirection(SWT.DOWN);
subscriptionsList.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event arg0) {
action.setEnabled(subscriptionsList.getSelectionIndex() != -1);
}
});
Listener sortListener = new Listener() {
public void handleEvent(Event e) {
// determine new sort column and direction
TableColumn sortColumn = subscriptionsList.getSortColumn();
TableColumn currentColumn = (TableColumn) e.widget;
int dir = subscriptionsList.getSortDirection();
if (sortColumn == currentColumn) {
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
subscriptionsList.setSortColumn(currentColumn);
dir = SWT.DOWN;
}
subscriptionsList.setSortDirection(dir);
sortAndRefresh();
}
};
name.addListener(SWT.Selection, sortListener);
popularity.addListener(SWT.Selection, sortListener);
animatedImage = new AnimatedImage(loadingPanel);
loadingText = new Label(loadingPanel,SWT.WRAP | SWT.CENTER);
loadingProgress = new ProgressBar(loadingPanel,SWT.HORIZONTAL);
animatedImage.setImageFromName("spinner_big");
String contentName = "Dummy";
if(download != null) {
contentName = download.getDisplayName();
}
loadingText.setText(MessageText.getString("subscriptions.listwindow.loadingtext", new String[] {contentName}));
loadingProgress.setMinimum(0);
loadingProgress.setMaximum(300);
loadingProgress.setSelection(0);
data = new FormData();
data.left = new FormAttachment(1,2,-16);
data.top = new FormAttachment(1,2,-32);
data.width = 32;
data.height = 32;
animatedImage.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(0,5);
data.right = new FormAttachment(100,-5);
data.top = new FormAttachment(animatedImage.getControl(),10);
data.height = 50;
loadingText.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(0,5);
data.right = new FormAttachment(100,-5);
data.top = new FormAttachment(loadingText,5);
loadingProgress.setLayoutData(data);
boolean autoCheck = COConfigurationManager.getBooleanParameter("subscriptions.autocheck");
if(autoCheck) {
startChecking();
} else {
action.setText(MessageText.getString("Button.yes"));
Composite acceptPanel = new Composite(mainComposite,SWT.NONE);
acceptPanel.setLayout(new FormLayout());
Label acceptLabel = new Label(acceptPanel,SWT.WRAP | SWT.CENTER);
acceptLabel.setText(MessageText.getString("subscriptions.listwindow.autochecktext"));