import org.tizen.nativeplatform.wizards.model.TizenPlatformTemplateModel;
public class TizenPlatformPWComposite extends PWWidget {
- protected final Logger logger = LoggerFactory.getLogger(getClass());
+ protected final Logger logger = LoggerFactory.getLogger(getClass());
private int textMargin = 30;
private int tableWidth = 250;
private Tree tree;
private Table table;
-
+
private TizenNativeTreeRootModel modelRoot;
private Browser descBrowser;
private final TizenPlatformMainWizardPage wizardPage;
private TableViewer gitDescTable;
private int browserWidth = 418;
private static Color topColor = new Color(Display.getDefault(), 168, 198, 255); // Top Color
- private static Color bottomColor = new Color(Display.getDefault(), 104, 151, 239); // Bottom Color
-
+ private static Color bottomColor = new Color(Display.getDefault(), 104, 151, 239); // Bottom
+ // Color
+
private static String IMAGE_TREE_BG = "images/wizard/tree_viewer_bg.png";
private static String IMAGE_TABLE_BG = "images/wizard/list_viewer_bg.png";
private final String GIT_CATEGORY = "Git";
private final String TABLE_DATA_DELIMITER = "::";
-
- private final static String BUNDLE_NAME = TizenPlatformProjectWizard.class.getPackage().getName() + ".WizardUIMessages";//$NON-NLS-1$
- private static ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
-
- public TizenPlatformPWComposite(final String label, TizenNativeTreeRootModel modelRoot, TizenPlatformMainWizardPage page) {
+
+ private final static String BUNDLE_NAME = TizenPlatformProjectWizard.class.getPackage()
+ .getName() + ".WizardUIMessages";//$NON-NLS-1$
+ private static ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ public TizenPlatformPWComposite(final String label, TizenNativeTreeRootModel modelRoot,
+ TizenPlatformMainWizardPage page) {
super(label, null, 1, true);
this.modelRoot = modelRoot;
- this.wizardPage = page;
-
+ this.wizardPage = page;
+
setAlignment(GridData.FILL);
}
-
+
@Override
protected Control build(Composite parent) {
this.wizardPage.setLastSelectedTemplate(null);
this.wizardPage.h_selected = null;
-
+
Composite composite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout(3, false);
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
composite.setLayout(gridLayout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
if (this.getLabel().equals(GIT_CATEGORY)) {
- if ( modelRoot.getEntries().size() == 1 &&
- modelRoot.getEntries().get(0).getName().equals("no_category")) {
- createEmptyGitRepositoryComposite(composite);
- }
- else {
+ if (modelRoot.getEntries().size() == 1
+ && modelRoot.getEntries().get(0).getName().equals("no_category")) {
+ createEmptyGitRepositoryComposite(composite);
+ } else {
createTree(composite);
createTable(composite);
- createGitDescriptionComposite(composite);
- }
+ createGitDescriptionComposite(composite);
+ }
} else {
createTree(composite);
createTable(composite);
- createDescriptionComposite(composite);
+ createDescriptionComposite(composite);
}
-
-
+
+ initializeTabList();
+
wizardPage.setPageComplete(wizardPage.validatePage());
return composite;
}
-
+ private void initializeTabList() {
+ ArrayList<Control> tabList = new ArrayList<Control>();
+ if (this.tree == null) {
+ return;
+ }
+
+ if (this.tree.getItemCount() > 0) {
+ tabList.add(this.tree);
+ if (this.table.getItemCount() > 0) {
+ tabList.add(this.table);
+ }
+ }
+
+ this.tree.getParent().setTabList(tabList.toArray(new Control[tabList.size()]));
+ }
+
private void createEmptyGitRepositoryComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout(1, false);
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout(1, false);
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
composite.setLayout(gridLayout);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.minimumWidth = this.browserWidth;
- composite.setLayoutData(gridData);
+ composite.setLayoutData(gridData);
- Label emptyGitDescription = new Label(composite, SWT.NONE ) ;
- emptyGitDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL,true, true));
- emptyGitDescription.setAlignment(SWT.CENTER);
- emptyGitDescription.setText(resources.getString("WizardPage.GitError.NoInfo"));
+ Label emptyGitDescription = new Label(composite, SWT.NONE);
+ emptyGitDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ emptyGitDescription.setAlignment(SWT.CENTER);
+ emptyGitDescription.setText(resources.getString("WizardPage.GitError.NoInfo"));
}
-
private void createTable(Composite parent) {
this.table = new Table(parent, SWT.FULL_SELECTION);
TableColumn column = new TableColumn(this.table, SWT.NONE);
column.setResizable(true);
column.setWidth(this.tableWidth);
-
GridData tableGridData = new GridData(GridData.FILL_BOTH);
tableGridData.minimumWidth = this.tableWidth;
table.setLayoutData(tableGridData);
-
createTableListener();
-
+
this.table.setBackgroundImage(ImageUtil.getImage(Activator.PLUGIN_ID, IMAGE_TABLE_BG));
}
private void createTableListener() {
- final String label = this.getLabel();
+ final String label = this.getLabel();
table.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
- boolean errorOccured = false;
- if(table.getSelection() != null && table.getSelection().length > 0 ) {
- TizenPlatformTemplateModel templateModel = (TizenPlatformTemplateModel) table.getSelection()[0].getData();
+ boolean errorOccured = false;
+ if (table.getSelection() != null && table.getSelection().length > 0) {
+ TizenPlatformTemplateModel templateModel = (TizenPlatformTemplateModel) table
+ .getSelection()[0].getData();
EntryDescriptor ed = templateModel.getEntryDescriptor();
wizardPage.setLastSelectedTemplate(templateModel);
wizardPage.switchTo(ed.getHandler(), ed);
gitDescTable.setInput(inputs);
} else {
- descBrowser.setUrl(templateModel.getDescPath().toOSString());
+ descBrowser.setUrl(templateModel.getDescPath().toOSString());
}
if (errorOccured) {
- wizardPage.setPageError(true);
+ wizardPage.setPageError(true);
} else {
- wizardPage.setPageError(false);
+ wizardPage.setPageError(false);
}
wizardPage.setPageComplete(wizardPage.validatePage());
}
}
-
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
-
+
// margin
table.addListener(SWT.MeasureItem, new Listener() {
public void handleEvent(Event event) {
event.detail &= ~SWT.HOT;
if ((event.detail & SWT.SELECTED) == 0) {
table.drawBackground(event.gc, 0, event.y, tableWidth, event.height, 0, 0);
- return; /* item not selected */
+ return;
}
-
+
GC gc = event.gc;
Color oldForeground = gc.getForeground();
Color oldBackground = gc.getBackground();
event.detail &= ~SWT.SELECTED;
}
});
- }
-
+ }
+
private void createDescriptionComposite(Composite parent) {
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.minimumWidth = browserWidth;
try {
- descBrowser = new Browser(parent, SWT.NONE);
- initializebrowser(SWTUtil.getDisplay(), descBrowser);
- descBrowser.setLayoutData(gridData);
+ descBrowser = new Browser(parent, SWT.NONE);
+ initializebrowser(SWTUtil.getDisplay(), descBrowser);
+ descBrowser.setLayoutData(gridData);
} catch (SWTError e) {
- // Exception skip: Ubuntu 12.04 browser compatibility problem
- logger.error("Failed to create a browser", e);
- Composite temporaryControl = new Composite(parent, SWT.NONE);
- temporaryControl.setLayoutData(gridData);
+ // Exception skip: Ubuntu 12.04 browser compatibility problem
+ logger.error("Failed to create a browser", e);
+ Composite temporaryControl = new Composite(parent, SWT.NONE);
+ temporaryControl.setLayoutData(gridData);
}
}
private void createGitDescriptionComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout(1, false);
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout(1, false);
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
composite.setLayout(gridLayout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
createGitInfoComposite(composite);
}
-
- private void createGitInfoComposite(Composite parent) {
- gitDescTable = new TableViewer(parent, SWT.NONE);
-
- Table table = gitDescTable.getTable();
- table.setLinesVisible(true);
-
- gitDescTable.setLabelProvider(new TableViewerProvider());
- gitDescTable.setContentProvider(new ArrayContentProvider());
-
- TableColumn column = new TableColumn(table, SWT.NONE);
+ private void createGitInfoComposite(Composite parent) {
+ gitDescTable = new TableViewer(parent, SWT.NONE);
+
+ Table table = gitDescTable.getTable();
+ table.setLinesVisible(true);
+
+ gitDescTable.setLabelProvider(new TableViewerProvider());
+ gitDescTable.setContentProvider(new ArrayContentProvider());
+
+ TableColumn column = new TableColumn(table, SWT.NONE);
column.setResizable(true);
- //column.setWidth(this.tableWidth);
- column.setWidth(100);
-
+ // column.setWidth(this.tableWidth);
+ column.setWidth(100);
+
column = new TableColumn(table, SWT.FILL);
column.setResizable(true);
column.setWidth(318);
-
+
GridData tableGridData = new GridData(GridData.FILL_BOTH);
tableGridData.minimumWidth = this.browserWidth;
table.setLayoutData(tableGridData);
public String getColumnText(Object element, int columnIndex) {
String[] splitValues = ((String) element).split("::");
switch (columnIndex) {
- case 0:
- return splitValues[0];
- case 1:
- if (splitValues.length == 2) {
- return splitValues[1];
- } else {
- return "";
- }
- default:
- break;
+ case 0:
+ return splitValues[0];
+ case 1:
+ if (splitValues.length == 2) {
+ return splitValues[1];
+ } else {
+ return "";
+ }
+ default:
+ break;
}
return null;
}
- }
-
+ }
+
private void createTree(Composite parent) {
// Type Tree View
this.tree = new Tree(parent, SWT.NONE);
-
+
// set layout data
GridData treeGridData = new GridData(GridData.FILL_BOTH);
treeGridData.minimumWidth = 200;
this.tree.setLayoutData(treeGridData);
-
+
createTreeItem(parent, modelRoot.getEntries());
createTreeListener();
-
+
makeGradientTree(this.tree);
if (!modelRoot.getName().equals(GIT_CATEGORY)) {
- SWTUtil.expandTree(this.tree);
+ SWTUtil.expandTree(this.tree);
}
this.tree.setBackgroundImage(ImageUtil.getImage(Activator.PLUGIN_ID, IMAGE_TREE_BG));
}
private void createTreeListener() {
this.tree.addSelectionListener(new SelectionListener() {
-
+
@Override
public void widgetSelected(SelectionEvent e) {
- if(tree.getSelection() != null && tree.getSelection().length > 0) {
+ if (tree.getSelection() != null && tree.getSelection().length > 0) {
TreeItem selectedItem = tree.getSelection()[0];
Object data = selectedItem.getData();
-
- List<TizenNativeTemplateModel> templateList = ((TizenNativeTreeGroupModel)(data)).getTemplateList();
- if(templateList.size() > 0) {
+
+ List<TizenNativeTemplateModel> templateList = ((TizenNativeTreeGroupModel) (data))
+ .getTemplateList();
+ if (templateList.size() > 0) {
createTableItem(templateList);
- }
- else {
-// descBrowser.setVisible(false);
+ } else {
+ // descBrowser.setVisible(false);
wizardPage.setLastSelectedTemplate(null);
wizardPage.h_selected = null;
wizardPage.setPageComplete(wizardPage.validatePage());
table.removeAll();
}
+
+ initializeTabList();
}
}
+
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
private void createTableItem(List<TizenNativeTemplateModel> templates) {
this.table.removeAll();
this.table.setLinesVisible(false);
-
- for(TizenNativeTemplateModel template: templates) {
+
+ for (TizenNativeTemplateModel template : templates) {
TableItem tableItem = new TableItem(table, SWT.NONE);
tableItem.setText(template.getName());
tableItem.setData(template);
-
+
IPath iconPath = template.getIconPath();
-
+
Image wizardIconImage = null;
- if(iconPath != null) {
- wizardIconImage = ImageUtil.getImage(ImageDescriptor.createFromFile(null, iconPath.toOSString()));
+ if (iconPath != null) {
+ wizardIconImage = ImageUtil.getImage(ImageDescriptor.createFromFile(null,
+ iconPath.toOSString()));
+ } else {
+ wizardIconImage = ImageUtil.getImage(Activator.PLUGIN_ID,
+ TizenMainWizardPage.DEFAULT_WIZARD_ICON);
}
- else {
- wizardIconImage = ImageUtil.getImage(Activator.PLUGIN_ID, TizenMainWizardPage.DEFAULT_WIZARD_ICON);
- }
-
+
tableItem.setImage(wizardIconImage);
}
-
- if(templates.size() > 0) {
+
+ if (templates.size() > 0) {
Event e = new Event();
table.select(0);
e.item = this.table.getSelection()[0];
}
}
-
- private void createTreeItem(Composite parent,
- List<TizenNativeTreeGroupModel> entries) {
-
+ private void createTreeItem(Composite parent, List<TizenNativeTreeGroupModel> entries) {
+
Stack<TizenNativeTreeGroupModel> entryStack = new Stack<TizenNativeTreeGroupModel>();
Stack<TreeItem> treeStack = new Stack<TreeItem>();
-
+
for (TizenNativeTreeGroupModel entry : entries) {
TreeItem treeItem = new TreeItem(this.tree, SWT.None);
treeItem.setText(entry.getName());
entryStack.push(entry);
treeStack.push(treeItem);
}
-
- while(!entryStack.isEmpty()) {
+
+ while (!entryStack.isEmpty()) {
TizenNativeTreeGroupModel entry = entryStack.pop();
TreeItem treeItem = treeStack.pop();
-
- for(TizenNativeTreeGroupModel subEntry: entry.getEntries()) {
+
+ for (TizenNativeTreeGroupModel subEntry : entry.getEntries()) {
TreeItem subTreeItem = new TreeItem(treeItem, SWT.None);
subTreeItem.setText(subEntry.getName());
subTreeItem.setData(subEntry);
@Override
protected void check() {
}
-
+
private void initializebrowser(final Display currentDisplay, Browser pBrowser) {
-
+
pBrowser.addOpenWindowListener(new OpenWindowListener() {
@Override
public void open(WindowEvent event) {
- if (!event.required)
- {
- return; /* only do it if necessary */
- }
Shell shell = new Shell(currentDisplay, SWT.CLOSE | SWT.MAX | SWT.MIN | SWT.RESIZE);
-
+
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 1;
shell.setLayout(gridLayout);
HelpBrowser childBrowser = new HelpBrowser(shell, SWT.BORDER, true);
-
+
initializebrowser(currentDisplay, childBrowser.getBrowser());
event.browser = childBrowser.getBrowser();
shell.open();
public static void makeGradientTree(final Tree tree) {
/*
- * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.
- * Therefore, it is critical for performance that these methods be
- * as efficient as possible.
+ * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly. Therefore, it is
+ * critical for performance that these methods be as efficient as possible.
*/
tree.addListener(SWT.EraseItem, new Listener() {
public void handleEvent(Event event) {
GC gc = event.gc;
Rectangle area = tree.getClientArea();
/*
- * If you wish to paint the selection beyond the end of
- * last column, you must change the clipping region.
+ * If you wish to paint the selection beyond the end of last column, you must
+ * change the clipping region.
*/
int columnCount = tree.getColumnCount();
if (event.index == columnCount - 1 || columnCount == 0) {
region.dispose();
}
}
- //gc.setAdvanced(true);
- //if (gc.getAdvanced()) gc.setAlpha(127);
+ // gc.setAdvanced(true);
+ // if (gc.getAdvanced()) gc.setAlpha(127);
Rectangle rect = event.getBounds();
Color foreground = gc.getForeground();
Color background = gc.getBackground();
gc.setForeground(topColor);
gc.setBackground(bottomColor);
gc.fillGradientRectangle(0, rect.y, 200, rect.height, true);
-
+
// restore colors for subsequent drawing
gc.setForeground(foreground);
gc.setBackground(background);