--- /dev/null
+package org.tizen.nativeplatform.views.ui;
+
+public interface IRepoModifyListener {
+ void modified();
+}
import org.eclipse.core.runtime.IPath;
public interface IRepositoryTab {
- List<String> getRepositoryURLs();
- String getArchitecture();
- boolean isImmediateGenerateChecked();
- IPath getBuildConfFile();
- boolean saveState();
+ List<String> getRepositoryURLs();
+
+ String getArchitecture();
+
+ boolean isImmediateGenerateChecked();
+
+ IPath getBuildConfFile();
+
+ boolean saveState();
+
+ String getErrorMessage();
+
+ void addListener(IRepoModifyListener listener);
+
+ boolean genImmediatly();
}
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
private Button generateImmediateBt;
private String architecture;
+ private String errorMessage;
private List<String> repositoryURLs;
private IPath buildConfFile = null;
boolean isImmediateGenerateChecked;
+ private IRepoModifyListener listener;
+ private Color originColor;
protected final String BUNDLE_NAME = RemoteRepoTab.class.getPackage().getName()
+ ".RootstrapUIMessages";//$NON-NLS-1$
public LocalRepoTab(Shell shell, TabFolder folder) {
this.shell = shell;
this.folder = folder;
+ originColor = shell.getForeground();
}
public void createTab() {
gridData = new GridData(GridData.FILL_HORIZONTAL);
repoPathText.setLayoutData(gridData);
repoPathText.setEditable(false);
+ repoPathText.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
+ repoPathText.setText(resources.getString("GenRootDlg.Info.Local.Dir"));
Button searchBt = new Button(snapshotComp, SWT.PUSH);
searchBt.setText(resources.getString("LocalRepoTab.Button.Browse"));
.getString("LocalRepoTab.Error.getArch"));
return;
}
-
+ repoPathText.setForeground(originColor);
repoPathText.setText(repoPath);
archCombo.removeAll();
archCombo.setItems(archs.toArray(new String[0]));
archCombo.select(0);
+ notifyModified();
} else {
DialogUtil.openErrorDialog(resources
.getString("LocalRepoTab.Error.NotLocalRepo"));
return;
}
-
}
}
GridData gridData = new GridData(GridData.FILL_HORIZONTAL
| GridData.VERTICAL_ALIGN_BEGINNING);
generateImmediateBt.setLayoutData(gridData);
+ generateImmediateBt.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ notifyModified();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ });
}
private void createArchitectureComposite(Composite parent) {
gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.minimumHeight = 0;
archCombo.setLayoutData(gridData);
- archCombo.addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- // UpdateRepositoryURL();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- });
- // archCombo.setEnabled(false);
}
private void createConfFilePathComposite(Composite parent) {
gridData = new GridData(GridData.FILL_HORIZONTAL);
confFilePathText.setLayoutData(gridData);
confFilePathText.setEditable(false);
-
+ confFilePathText.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
+ confFilePathText.setText(resources.getString("GenRootDlg.Info.BuildConfFile"));
Button searchBt = new Button(snapshotComp, SWT.PUSH);
searchBt.setText(resources.getString("LocalRepoTab.Button.Browse"));
}
buildConfFile = new Path(filePath);
+ confFilePathText.setForeground(originColor);
confFilePathText.setText(buildConfFile.toOSString());
+ notifyModified();
}
@Override
});
}
+ private void notifyModified() {
+ listener.modified();
+ }
+
@Override
public List<String> getRepositoryURLs() {
return repositoryURLs;
@Override
public boolean saveState() {
String repo = repoPathText.getText();
- if (repo == null || repo.isEmpty()) {
- DialogUtil.openErrorDialog(resources.getString("LocalRepoTab.Error.Empty.Repo"));
+ if (repo == null || repo.isEmpty()
+ || repo.equals(resources.getString("GenRootDlg.Info.Local.Dir"))) {
+ errorMessage = resources.getString("LocalRepoTab.Error.Empty.Repo");
return false;
}
String arch = archCombo.getText();
if (arch == null || arch.isEmpty()) {
- DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Empty.Arch"));
+ errorMessage = resources.getString("GenRootDlg.Error.Empty.Arch");
return false;
}
- if (buildConfFile == null) {
- DialogUtil.openErrorDialog(resources.getString("LocalRepoTab.Error.Empty.ConfFile"));
+ if (buildConfFile == null
+ || buildConfFile.toOSString().equals(
+ resources.getString("LocalRepoTab.Button.Browse"))) {
+ errorMessage = resources.getString("LocalRepoTab.Error.Empty.ConfFile");
return false;
}
return true;
}
+ @Override
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ @Override
+ public void addListener(IRepoModifyListener listener) {
+ this.listener = listener;
+ }
+
+ @Override
+ public boolean genImmediatly() {
+ return generateImmediateBt.getSelection();
+ }
}
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
private TableViewer reposURLViewer;
private Combo archCombo;
private Button generateImmediateBt;
+ private Button searchBt;
private List<ICheckTreeItem> snapshotInfos;
private String architecture;
- private ArrayList<String> repositoryURLs;
+ private String errorMessage;
+ private List<String> repositoryURLs;
boolean isImmediateGenerateChecked;
+ private IRepoModifyListener listener;
+ private Color originColor;
private final static int COL_REPOS_NAME = 0;
private final static int COL_REPOS_URL = 1;
public RemoteRepoTab(Shell shell, TabFolder folder) {
this.shell = shell;
this.folder = folder;
+ originColor = shell.getForeground();
}
public void createTab() {
snapshotUrlText = new Text(snapshotComp, SWT.SINGLE | SWT.BORDER);
gridData = new GridData(GridData.FILL_HORIZONTAL);
snapshotUrlText.setLayoutData(gridData);
+ snapshotUrlText.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
+ snapshotUrlText.setText(resources.getString("GenRootDlg.Info.Snapshot.Guide"));
+ snapshotUrlText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ String url = snapshotUrlText.getText();
+ if (url != null && !url.isEmpty()
+ && !url.equals(resources.getString("GenRootDlg.Info.Snapshot.Guide"))) {
+ searchBt.setEnabled(true);
+ } else {
+ searchBt.setEnabled(false);
+ }
+ }
+ });
+
+ snapshotUrlText.addFocusListener(new FocusListener() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ // remove guide text
+ snapshotUrlText.setForeground(originColor);
+ String value = snapshotUrlText.getText();
+ if (value.equals(resources.getString("GenRootDlg.Info.Snapshot.Guide"))) {
+ snapshotUrlText.setText("");
+ }
+ }
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ }
+ });
- Button searchBt = new Button(snapshotComp, SWT.PUSH);
+ searchBt = new Button(snapshotComp, SWT.PUSH);
searchBt.setText(resources.getString("GenRootDlg.Button.Search"));
+ searchBt.setEnabled(false);
searchBt.addMouseListener(new MouseListener() {
GridData gridData = new GridData(GridData.FILL_HORIZONTAL
| GridData.VERTICAL_ALIGN_BEGINNING);
generateImmediateBt.setLayoutData(gridData);
+ generateImmediateBt.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ listener.modified();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ });
}
private void createArchitectureComposite(Composite parent) {
}
}
}
+
reposURLViewer.setInput(data);
+ noityModified();
+ }
+
+ private void noityModified() {
+ listener.modified();
}
private void createTreeViewer(Composite parent) {
@Override
public boolean saveState() {
-
TableItem[] repos = reposURLViewer.getTable().getItems();
if (repos.length == 0) {
- DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.NoAnyRepos"));
+ errorMessage = resources.getString("GenRootDlg.Error.NoAnyRepos");
return false;
}
String arch = archCombo.getText();
if (arch == null || arch.isEmpty()) {
- DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Empty.Arch"));
+ errorMessage = resources.getString("GenRootDlg.Error.Empty.Arch");
return false;
}
@Override
public IPath getBuildConfFile() {
- // Nothing to do
return null;
}
+
+ @Override
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ @Override
+ public void addListener(IRepoModifyListener listener) {
+ this.listener = listener;
+ }
+
+ @Override
+ public boolean genImmediatly() {
+ return generateImmediateBt.getSelection();
+ }
}
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.Text;
-
import org.tizen.common.util.DialogUtil;
import org.tizen.nativeplatform.rootstrap.RootstrapManager;
private RemoteRepoTab remoteTab;
private LocalRepoTab localTab;
private IRepositoryTab selectionTab = null;
+ private Label DescLabel;
+ private Label IconLabel;
private int selectionIndex = 0;
private String rootstrapName;
+ private Color whiteColor;
+
public static final int REMOTE_REPO_TAB = 0;
public static final int LOCAL_REPO_TAB = 1;
+ private final String REGEX_NAME = "([A-Za-z0-9\\-\\_]+)";
private final String BUNDLE_NAME = RootstrapGenDialog.class.getPackage().getName()
+ ".RootstrapUIMessages";//$NON-NLS-1$
private ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME);
+ private IRepoModifyListener repoModifyListener = new IRepoModifyListener() {
+ @Override
+ public void modified() {
+ validate();
+ }
+ };
+
public RootstrapGenDialog(Shell parentShell) {
super(parentShell);
}
@Override
+ public void create() {
+ super.create();
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ }
+
+ @Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(resources.getString("GenRootDlg.Title"));
-
newShell.setLocation(x, y);
newShell.setSize(width, height);
}
}
private void createDialogDescription(Composite composite) {
- Composite comp_descrip = new Composite(composite, SWT.NONE);
- Color whiteColor = new Color(composite.getDisplay(), 255, 255, 255);
+ Composite comp_descrip = new Composite(composite, SWT.NONE | SWT.BORDER);
+ whiteColor = new Color(composite.getDisplay(), 255, 255, 255);
- comp_descrip.setLayout(new GridLayout(1, false));
+ comp_descrip.setLayout(new GridLayout(2, false));
GridData comp_descrip_gd = new GridData(GridData.FILL_HORIZONTAL);
comp_descrip_gd.heightHint = 30;
comp_descrip.setLayoutData(comp_descrip_gd);
comp_descrip.setBackground(whiteColor);
- Label label = new Label(comp_descrip, SWT.NONE);
- label.setText(resources.getString("GenRootDlg.Desc"));
- label.setBackground(whiteColor);
+ IconLabel = new Label(comp_descrip, SWT.NONE);
+ IconLabel.setImage(JFaceResources.getImage(TitleAreaDialog.DLG_IMG_MESSAGE_INFO));
+ IconLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+ IconLabel.setBackground(whiteColor);
+
+ DescLabel = new Label(comp_descrip, SWT.NONE);
+ DescLabel.setText(resources.getString("GenRootDlg.Desc"));
+ DescLabel.setLayoutData(comp_descrip_gd);
+ DescLabel.setBackground(whiteColor);
+ }
+
+ private void showErrorMessage(String msg) {
+ IconLabel.setImage(JFaceResources.getImage(TitleAreaDialog.DLG_IMG_TITLE_ERROR));
+ DescLabel.setText(msg);
+ }
+
+ private void showMessage(String msg) {
+ IconLabel.setImage(JFaceResources.getImage(TitleAreaDialog.DLG_IMG_MESSAGE_INFO));
+ DescLabel.setText(msg);
+ }
+
+ private boolean validateRootstrapName(String name) {
+ return name.matches(REGEX_NAME);
+ }
+
+ public boolean validateTab() {
+ IRepositoryTab selectedTab = remoteTab;
+ if (tabFolder.getSelectionIndex() == LOCAL_REPO_TAB) {
+ selectedTab = localTab;
+ }
+ if (!selectedTab.saveState()) {
+ showErrorMessage(selectedTab.getErrorMessage());
+ return false;
+ }
+ if (selectedTab.genImmediatly()) {
+ showMessage(resources.getString("GenRootDlg.Info.Create.Rootstrap"));
+ } else {
+ showMessage(resources.getString("GenRootDlg.Info.Create.Meta.Rootstrap"));
+ }
+ return true;
+ }
+
+ public boolean validateAll() {
+ rootstrapName = rootstrapText.getText();
+ if (!validateRootstrapName(rootstrapName)) {
+ showErrorMessage(resources.getString("GenRootDlg.Info.RootstrapName"));
+ return false;
+ }
+ if (RootstrapManager.getRootstrap(rootstrapName) != null) {
+ showErrorMessage(String.format(
+ resources.getString("GenRootDlg.Error.Exists.Rootstrap"), rootstrapName));
+ return false;
+ }
+ if (!validateTab()) {
+ return false;
+ }
+ return true;
+ }
+
+ public void validate() {
+ if (validateAll()) {
+ getButton(IDialogConstants.OK_ID).setEnabled(true);
+ } else {
+ getButton(IDialogConstants.OK_ID).setEnabled(false);
+ }
}
private void createRootstrapNameComposite(Composite parent) {
GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.minimumHeight = 0;
rootstrapText.setLayoutData(gridData);
+ rootstrapText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validate();
+ }
+ });
}
private void createTabs(Composite parent) {
remoteTab = new RemoteRepoTab(getShell(), tabFolder);
remoteTab.createTab();
+ remoteTab.addListener(repoModifyListener);
+
localTab = new LocalRepoTab(getShell(), tabFolder);
localTab.createTab();
+ localTab.addListener(repoModifyListener);
tabFolder.setSelection(tabIndex);
+ tabFolder.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ validate();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
}
public IRepositoryTab getSelectionTab() {
@Override
protected void okPressed() {
- rootstrapName = rootstrapText.getText().trim();
- if (rootstrapName.isEmpty()) {
- DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Empty.Rootstrap"));
- return;
- }
-
- if (RootstrapManager.getRootstrap(rootstrapName) != null) {
- DialogUtil.openErrorDialog("Rootstrap name [" + rootstrapName + "] already exists!");
+ if (!validateAll()) {
+ DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Incorrect.Info"));
return;
}
-
if (tabFolder.getSelectionIndex() == REMOTE_REPO_TAB) {
- if (!remoteTab.saveState()) {
- // DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Incorrect.Info"));
- return;
- }
selectionTab = (IRepositoryTab) remoteTab;
selectionIndex = REMOTE_REPO_TAB;
} else if (tabFolder.getSelectionIndex() == LOCAL_REPO_TAB) {
- if (!localTab.saveState()) {
- // DialogUtil.openErrorDialog(resources.getString("GenRootDlg.Error.Incorrect.Info"));
- return;
- }
selectionTab = (IRepositoryTab) localTab;
selectionIndex = LOCAL_REPO_TAB;
}
GenRootDlg.Progress.Msg.Generating = Generating rootstrap...
GenRootDlg.Progress.Msg.Searching = Seaching repositories
+GenRootDlg.Info.Local.Dir = Ex) /home/user/localrepo
+GenRootDlg.Info.BuildConfFile = Ex) /var/tmp/user-gbs/tizen.conf
+GenRootDlg.Info.Snapshot.Guide = Ex) http://download.tizen.org/snapshots/2.2-emul/common/latest/
+GenRootDlg.Info.RootstrapName = You can use letters, numbers, hyphen(-), and underscore(_) as rootstrap name.
+GenRootDlg.Info.Create.Rootstrap = Rootstrap is created if the "Generate Immediately" is checked.
+GenRootDlg.Info.Create.Meta.Rootstrap = Rootstrap meta only is created if the "Generate Immediately" is not checked.
GenRootDlg.Error.Fail.Generate = Failed to generate rootstrap!
GenRootDlg.Error.Empty.Snapshot = Snapshot URL is empty
GenRootDlg.Error.Empty.Rootstrap = Rootstrap is empty
GenRootDlg.Error.Snapshot.Failed = Getting snapshot information failed!\n
GenRootDlg.Error.Gen.Rootstrap.Failed = Generating rootstrap failed!!\n
-GenRootDlg.Error.NoAnyRepos = There is no any repositories!
+GenRootDlg.Error.NoAnyRepos = You need to set repositories. Input snapshot URL and click the "Search" button.
GenRootDlg.Error.Incorrect.Info = Failed to validate information for generating rootstrap.
-GenRootDlg.Error.Empty.Arch = Architecture is empty
-GenRootDlg.Error.Miss.Prerequisite = \"%s\" package is not installed in your machine.\nTry to command \"sudo apt-get install %s\".
-
+GenRootDlg.Error.Empty.Arch = Architecture is empty.
+GenRootDlg.Error.Miss.Prerequisite = "%s" package is not installed in your machine.\nTry to command \"sudo apt-get install %s\".
+GenRootDlg.Error.Exists.Rootstrap = "%s" rootstrap exists.
ChangeConfFileDlg.Title = Change (build) configuration file
MofifyRootDlg.Button.ConfFile.Check = Specify project (build) configuration file
LocalRepoTab.Label.FilePath = File Path :
LocalRepoTab.Error.NotLocalRepo = The path is not local repository
LocalRepoTab.Error.getArch = Failed to get architecture information from local repository
-LocalRepoTab.Error.Empty.ConfFile = Configuration file is empty
-LocalRepoTab.Error.Empty.Repo = Repository path is empty
+LocalRepoTab.Error.Empty.ConfFile = You need to set (build) configuration file.
+LocalRepoTab.Error.Empty.Repo = You need to set local repository path. It should be created through "createrepo" command.
Action.Msg.Error.SelectRootstrap = The "%s" rootstrap can not be selected at "%s" configuration because of architecture mismatch.
Action.Msg.Error.RemoveDefault = Cannot remove basic rootstrap!