import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.ISizeProvider;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.contexts.IContextService;
private ToolBar toolBar;
private TableViewer tableViewer;
+ private final int COL_IDX_ROOTNAME = 0;
+ private final int COL_IDX_ARCH = 1;
+ private Text rootDescText;
private Action actionSetDefault;
private Action actionPkgMgr;
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().addSelectionListener(listener);
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, TizenHelpContextIds.HELP_COMMON_CONNECTION_EXPLORER_CONTEXT);
- parent.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- parent.setLayout(new GridLayout(1, false));
-
- Composite top = new Composite(parent, SWT.NONE);
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
-
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END);
- gridData.horizontalSpan = 2;
-
- top.setLayoutData(gridData);
- top.setLayout(gridLayout);
-
- createToolBar(top, gridData);
-
- Composite bottom = new Composite(parent, SWT.NONE);
- bottom.setLayoutData(new GridData(GridData.FILL_BOTH));
- bottom.setLayout(new FillLayout());
-
- createRootstrapTableComposite(bottom);
+ GridLayout layout = new GridLayout(1,false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ parent.setLayout(layout);
+
+ createToolBar(parent);
+ createRootstrapTableComposite(parent);
+ createRootstrapDescComposite(parent);
makeActions();
activateContext();
}
+
+ // This override is for change the default/minimum size of Rootstrap view
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (ISizeProvider.class == adapter) {
+ return new ISizeProvider() {
+ public int getSizeFlags(boolean width) {
+ return SWT.MIN | SWT.MAX | SWT.FILL;
+ }
+
+ public int computePreferredSize(boolean width, int availableParallel, int availablePerpendicular, int preferredResult) {
+ return width ? 300 : preferredResult;
+ }
+ };
+ }
+ return super.getAdapter(adapter);
+ }
+
+
@Override
public void setFocus() {
}
- private void createToolBar(Composite parent, Object layoutData)
+ private void createToolBar(Composite composite)
{
-
- toolBar = new ToolBar(parent, SWT.NULL);
- toolBar.setLayoutData(layoutData);
-
+ toolBar = new ToolBar(composite, SWT.NULL);
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ toolBar.setLayoutData(gridData);
new ToolItem(toolBar, SWT.SEPARATOR); // Separator
ToolItem addRootstrap = new ToolItem(toolBar, SWT.PUSH);
private void createRootstrapTableComposite(Composite parent) {
- parent.setLayout(new FillLayout());
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout = new GridLayout(1,false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
- tableViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ tableViewer = new TableViewer(composite, SWT.BORDER|SWT.V_SCROLL);
Table table = tableViewer.getTable();
-
+ GridData tableGridData = new GridData(GridData.FILL_BOTH|GridData.VERTICAL_ALIGN_BEGINNING);
+ table.setLayoutData(tableGridData);
+
table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- String[] columnNames = new String[] {
- resources.getString("View.Table.Column.0"),
- resources.getString("View.Table.Column.1"),
- resources.getString("View.Table.Column.2")
- };
+ table.setLinesVisible(true);
- int[] columnWidths = new int[] {25, 210, 100};
- for (int i = 0; i < columnNames.length ; i++) {
- TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
-
- tableColumn.setText(columnNames[i]);
- tableColumn.setWidth(columnWidths[i]);
- tableColumn.setResizable(true);
- tableColumn.addSelectionListener(new TooltableSelectionAdapter());
- }
-
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setResizable(true);
+ column.setText(resources.getString("View.Table.Column.Rootstrap"));
+ column.setWidth(240);
+ column.addSelectionListener(new TooltableSelectionAdapter());
+
+ column = new TableColumn(table, SWT.NONE);
+ column.setResizable(true);
+ column.setText(resources.getString("View.Table.Column.Arch"));
+ column.setWidth(50);
+ column.addSelectionListener(new TooltableSelectionAdapter());
+
tableViewer.setLabelProvider(new TableViewerProvider());
tableViewer.setContentProvider(new ArrayContentProvider());
- tableViewer.setInput(RootstrapManager.getRootstraps());
+ tableViewer.setInput(RootstrapManager.getRootstraps());
+
tableViewer.getTable().addSelectionListener(new SelectionListener() {
@Override
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
+ Table table = tableViewer.getTable();
+ TableItem[] item = table.getSelection();
+ if ( item.length > 0 ) {
+ PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
+ rootDescText.setText( getRootstrapDescription(selected));
+ }
+ else {
+ rootDescText.setText("");
+ }
}
@Override
});
}
+
+ private String getRootstrapDescription( PlatformRootstrap rootstrap ) {
+ String archLine = String.format("* Architecture: %s(%s)",
+ getArchitectureCategory(rootstrap.getArch()),
+ rootstrap.getArch());
+ String statusLine = String.format("* Status : %s", rootstrap.isInitialized()? "OK":"Not Intialized");
+ String urlLine = "* Repository URLs";
+ for( String url: rootstrap.getRepositoryURLs() ) {
+ urlLine += String.format("\n - %s", url);
+ }
+
+ return archLine + "\n" + statusLine + "\n" + urlLine;
+ }
+
+
+ private void createRootstrapDescComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout = new GridLayout(1,false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+
+ Label descriptionLabel = new Label(composite, SWT.NONE);
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ descriptionLabel.setLayoutData(gridData);
+ descriptionLabel.setText(resources.getString("View.Description.Label"));
+
+ rootDescText = new Text( composite, SWT.MULTI|SWT.READ_ONLY|SWT.BORDER|SWT.H_SCROLL|SWT.V_SCROLL );
+ gridData = new GridData(GridData.FILL_BOTH);
+ gridData.heightHint = 50;
+ rootDescText.setLayoutData( gridData );
+ }
+
+
private void initContextMenu() {
// initalize the context menu
menuMgr = new MenuManager(resources.getString("View.Contextmenu.Title")); //$NON-NLS-1$
PlatformRootstrap entry_2 = (PlatformRootstrap)e2;
switch (column) {
- case 1:
+ case COL_IDX_ROOTNAME:
if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
return entry_1.getText().compareTo(entry_2.getText());
} else {
return entry_2.getText().compareTo(entry_1.getText());
}
- case 2:
+ case COL_IDX_ARCH:
if (tableViewer.getTable().getSortDirection() == SWT.DOWN) {
return entry_1.getArch().compareTo(entry_2.getArch());
} else {
if ( element instanceof PlatformRootstrap) {
PlatformRootstrap t = (PlatformRootstrap)element;
boolean checked = t.isChecked();
- if (checked && columnIndex == 0) {
+ if (checked && columnIndex == COL_IDX_ROOTNAME) {
Image checkIcon = ImageUtil.getImage(Activator.PLUGIN_ID, "icons/rootstrap/successed.png");
return checkIcon;
}
String arch = t.getArch();
switch(columnIndex) {
- case 1 :
+ case COL_IDX_ROOTNAME :
return name;
- case 2:
- return arch;
+ case COL_IDX_ARCH:
+ return getArchitectureCategory(arch);
}
}
return null;
}
}
+
+
+ private String getArchitectureCategory(String arch) {
+ if ( arch.toLowerCase().contains("arm")) {
+ return "arm";
+ }
+ else {
+ return "x86";
+ }
+ }
}