summaryrefslogtreecommitdiffstats
path: root/src/com/ibm/ServerWizard2/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/ibm/ServerWizard2/view')
-rw-r--r--src/com/ibm/ServerWizard2/view/GitDialog.java457
-rw-r--r--src/com/ibm/ServerWizard2/view/MainDialog.java181
-rw-r--r--src/com/ibm/ServerWizard2/view/PasswordPrompt.java98
3 files changed, 653 insertions, 83 deletions
diff --git a/src/com/ibm/ServerWizard2/view/GitDialog.java b/src/com/ibm/ServerWizard2/view/GitDialog.java
new file mode 100644
index 0000000..5aaa4c6
--- /dev/null
+++ b/src/com/ibm/ServerWizard2/view/GitDialog.java
@@ -0,0 +1,457 @@
+package com.ibm.ServerWizard2.view;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Vector;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import com.ibm.ServerWizard2.ServerWizard2;
+import com.ibm.ServerWizard2.utility.Github;
+import com.ibm.ServerWizard2.utility.GithubRepository;
+import org.eclipse.wb.swt.SWTResourceManager;
+
+public class GitDialog extends Dialog {
+ private Text txtNewRepo;
+ Github git = new Github(ServerWizard2.GIT_LOCATION);
+
+ private ListViewer listViewer;
+ private Button btnCloned;
+ private Button btnAdded;
+ private Button btnRemoved;
+ private Button btnChanged;
+ private Button btnConflicting;
+ private Button btnUntracked;
+ private Button btnMissing;
+ private Button btnNeedsPassword;
+ private Button btnRefresh;
+ private Text txtLocation;
+
+ /**
+ * Create the dialog.
+ *
+ * @param parentShell
+ */
+ public GitDialog(Shell parentShell) {
+ super(parentShell);
+ StatusLogger.getLogger().setLevel(Level.FATAL);
+ }
+
+ private boolean isStatusSet(Set<String> status) {
+ if (status.size() > 0) {
+ for (String s : status) {
+ ServerWizard2.LOGGER.info(s);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Create contents of the dialog.
+ *
+ * @param parent
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+
+ Label lblGitRepositoryUrl = new Label(container, SWT.NONE);
+ lblGitRepositoryUrl.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ lblGitRepositoryUrl.setText("Git Repository URL:");
+ listViewer = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL);
+
+ List repositoryList = listViewer.getList();
+ repositoryList.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ repositoryList.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ if (listViewer.getList().getSelectionCount() == 0) {
+ return;
+ }
+ GithubRepository g = (GithubRepository) listViewer
+ .getElementAt(listViewer.getList().getSelectionIndex());
+ txtNewRepo.setText(g.getRemoteUrl());
+ btnNeedsPassword.setSelection(g.needsPassword());
+ if (g.isCloned()) {
+ btnCloned.setSelection(true);
+ txtLocation.setText(g.getRootDirectory().getAbsolutePath());
+ org.eclipse.jgit.api.Status status = g.status();
+ if (status != null) {
+ btnAdded.setSelection(isStatusSet(status.getAdded()));
+ btnRemoved.setSelection(isStatusSet(status.getRemoved()));
+ btnChanged.setSelection(isStatusSet(status.getChanged()) | isStatusSet(status.getModified()));
+ btnConflicting.setSelection(isStatusSet(status.getConflicting()));
+ btnUntracked.setSelection(isStatusSet(status.getUntracked()));
+ btnMissing.setSelection(isStatusSet(status.getMissing()));
+
+ } else {
+ MessageDialog.openError(null, "Git Error",
+ "The Git Repository has been modified. Please restart Serverwiz." + g.getRemoteUrl());
+ }
+ } else {
+ btnCloned.setSelection(false);
+ }
+ }
+ });
+ GridData gd_repositoryList = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+ gd_repositoryList.widthHint = 314;
+ gd_repositoryList.heightHint = 111;
+ repositoryList.setLayoutData(gd_repositoryList);
+
+ Composite composite = new Composite(container, SWT.NONE);
+ composite.setLayout(new GridLayout(5, false));
+ GridData gd_composite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_composite.widthHint = 367;
+ gd_composite.heightHint = 52;
+ composite.setLayoutData(gd_composite);
+ composite.setEnabled(false);
+
+ Label lblNewLabel = new Label(composite, SWT.NONE);
+ lblNewLabel.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_lblNewLabel.widthHint = 48;
+ lblNewLabel.setLayoutData(gd_lblNewLabel);
+ lblNewLabel.setText("Status:");
+
+ btnCloned = new Button(composite, SWT.CHECK);
+ btnCloned.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnCloned.setText("Cloned");
+
+ btnAdded = new Button(composite, SWT.CHECK);
+ btnAdded.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnAdded.setText("Added");
+
+ btnRemoved = new Button(composite, SWT.CHECK);
+ btnRemoved.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnRemoved.setText("Removed");
+
+ btnChanged = new Button(composite, SWT.CHECK);
+ btnChanged.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnChanged.setText("Changed");
+ new Label(composite, SWT.NONE);
+ new Label(composite, SWT.NONE);
+
+ btnConflicting = new Button(composite, SWT.CHECK);
+ btnConflicting.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnConflicting.setText("Conflicting");
+
+ btnUntracked = new Button(composite, SWT.CHECK);
+ btnUntracked.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnUntracked.setText("Untracked");
+
+ btnMissing = new Button(composite, SWT.CHECK);
+ btnMissing.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnMissing.setText("Missing");
+
+ Composite composite_4 = new Composite(container, SWT.NONE);
+ composite_4.setLayout(new RowLayout(SWT.HORIZONTAL));
+ GridData gd_composite_4 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+ gd_composite_4.widthHint = 351;
+ gd_composite_4.heightHint = 31;
+ composite_4.setLayoutData(gd_composite_4);
+
+ Label lblLocalLocation = new Label(composite_4, SWT.NONE);
+ lblLocalLocation.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ lblLocalLocation.setLayoutData(new RowData(93, 24));
+ lblLocalLocation.setText("Local Location: ");
+
+ txtLocation = new Text(composite_4, SWT.BORDER);
+ txtLocation.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ txtLocation.setEditable(false);
+ txtLocation.setLayoutData(new RowData(251, SWT.DEFAULT));
+
+ Composite composite_3 = new Composite(container, SWT.NONE);
+ composite_3.setLayout(new RowLayout(SWT.HORIZONTAL));
+ GridData gd_composite_3 = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
+ gd_composite_3.widthHint = 194;
+ gd_composite_3.heightHint = 36;
+ composite_3.setLayoutData(gd_composite_3);
+
+ btnRefresh = new Button(composite_3, SWT.NONE);
+ btnRefresh.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnRefresh.setLayoutData(new RowData(80, SWT.DEFAULT));
+ btnRefresh.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ if (listViewer.getList().getSelectionCount() == 0) {
+ return;
+ }
+ GithubRepository g = (GithubRepository) listViewer
+ .getElementAt(listViewer.getList().getSelectionIndex());
+ try {
+ if (!g.isCloned()) {
+ g.cloneRepository();
+ }
+ org.eclipse.jgit.api.Status status = g.status();
+
+ if (!status.isClean()) {
+ boolean reset = MessageDialog.openQuestion(null, "Repository is Modified",
+ "The local repository for:\n" + g.getRemoteUrl() + "\n"
+ + "has been modified. Would you like to ignore changes and reset?");
+ if (reset) {
+ String r = g.fetch(true);
+ MessageDialog.openInformation(null, "Refresh Complete", "Reset Successful");
+
+ }
+ } else {
+ String r = g.fetch(false);
+ MessageDialog.openInformation(null, "Refresh Complete", "Message: " + r);
+ }
+ } catch (Exception e) {
+ MessageDialog.openError(null, "Git Refresh: " + g.getRemoteUrl(), e.getMessage());
+ }
+ }
+ });
+
+ btnRefresh.setText("Refresh");
+
+ Button btnDummy = new Button(composite_3, SWT.NONE);
+ btnDummy.setLayoutData(new RowData(14, SWT.DEFAULT));
+ btnDummy.setVisible(false);
+ btnDummy.setText("New Button");
+
+ Button btnDelete = new Button(composite_3, SWT.NONE);
+ btnDelete.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnDelete.setLayoutData(new RowData(80, SWT.DEFAULT));
+ btnDelete.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ if (listViewer.getList().getSelectionCount() == 0) {
+ return;
+ }
+ GithubRepository g = (GithubRepository) listViewer
+ .getElementAt(listViewer.getList().getSelectionIndex());
+
+ boolean delete = MessageDialog.openConfirm(null, "Delete Respository",
+ "Are you sure you want to delete the following repository?\n" + g.getRemoteUrl() + "\n"
+ + "Note: This will NOT delete repository from disk");
+
+ if (!delete) {
+ return;
+ }
+ if (g.getRemoteUrl().equals(ServerWizard2.DEFAULT_REMOTE_URL)) {
+ MessageDialog.openError(null, "Error", "Deleting of default repository is not allowed");
+ } else {
+ git.getRepositories().remove(g);
+ listViewer.refresh();
+ }
+ }
+ });
+ btnDelete.setText("Delete");
+
+ Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
+ GridData gd_separator = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+ gd_separator.heightHint = 7;
+ gd_separator.widthHint = 360;
+ separator.setLayoutData(gd_separator);
+
+ Composite composite_2 = new Composite(container, SWT.NONE);
+ composite_2.setLayout(new RowLayout(SWT.HORIZONTAL));
+ GridData gd_composite_2 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+ gd_composite_2.widthHint = 354;
+ gd_composite_2.heightHint = 31;
+ composite_2.setLayoutData(gd_composite_2);
+
+ Label lblNewRepository = new Label(composite_2, SWT.NONE);
+ lblNewRepository.setLayoutData(new RowData(95, SWT.DEFAULT));
+ lblNewRepository.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ lblNewRepository.setText("New Repository:");
+
+ txtNewRepo = new Text(composite_2, SWT.BORDER);
+ txtNewRepo.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ txtNewRepo.setLayoutData(new RowData(249, SWT.DEFAULT));
+
+ Composite composite_1 = new Composite(container, SWT.NONE);
+ RowLayout rl_composite_1 = new RowLayout(SWT.HORIZONTAL);
+ rl_composite_1.center = true;
+ composite_1.setLayout(rl_composite_1);
+ GridData gd_composite_1 = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
+ gd_composite_1.widthHint = 252;
+ gd_composite_1.heightHint = 30;
+ composite_1.setLayoutData(gd_composite_1);
+
+ btnNeedsPassword = new Button(composite_1, SWT.CHECK);
+ btnNeedsPassword.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnNeedsPassword.setLayoutData(new RowData(148, SWT.DEFAULT));
+ btnNeedsPassword.setText("Needs Password?");
+
+ Button btnAddRemote = new Button(composite_1, SWT.NONE);
+ btnAddRemote.setLayoutData(new RowData(93, SWT.DEFAULT));
+ btnAddRemote.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnAddRemote.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ String repo = txtNewRepo.getText();
+ if (repo.isEmpty()) {
+ MessageDialog.openError(null, "Error", "Repository URL is blank");
+ return;
+ }
+ GithubRepository g = new GithubRepository(repo, git.getLocation(), btnNeedsPassword.getSelection());
+ g.setShell(getShell());
+ if (git.isRepository(g)) {
+ MessageDialog.openError(null, "Error", "Repository already exists");
+ return;
+ }
+ try {
+ g.checkRemote();
+ g.cloneRepository();
+ git.getRepositories().add(g);
+ txtNewRepo.setText("");
+ listViewer.refresh();
+ } catch (Exception e) {
+ MessageDialog.openError(null, "Add Remote: " + g.getRemoteUrl(), e.getMessage());
+ }
+ }
+ });
+ btnAddRemote.setText("Add Remote");
+
+ Label label = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
+ label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+
+ listViewer.setLabelProvider(new LabelProvider() {
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ public String getText(Object element) {
+ GithubRepository g = (GithubRepository) element;
+ return g.getRemoteUrl();
+ }
+ });
+ listViewer.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ @SuppressWarnings("rawtypes")
+ Vector v = (Vector) inputElement;
+ return v.toArray();
+ }
+
+ @Override
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ listViewer.setInput(git.getRepositories());
+ this.getRepositories();
+ listViewer.refresh();
+ return container;
+ }
+
+ /**
+ * Create contents of the button bar.
+ *
+ * @param parent
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ Button button = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ button.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ button.setText("Exit");
+ }
+
+ /**
+ * Return the initial size of the dialog.
+ */
+ @Override
+ protected Point getInitialSize() {
+ return new Point(393, 480);
+ }
+
+ public void getRepositories() {
+ try {
+ boolean newFile = false;
+ File f = new File(ServerWizard2.PROPERTIES_FILE);
+ if (!f.exists()) {
+ ServerWizard2.LOGGER.info("Preferences file doesn't exist, creating...");
+ f.createNewFile();
+ newFile = true;
+ }
+ FileInputStream propFile = new FileInputStream(ServerWizard2.PROPERTIES_FILE);
+ Properties p = new Properties();
+ p.load(propFile);
+ propFile.close();
+
+ if (newFile) {
+ p.setProperty("repositories", ServerWizard2.DEFAULT_REMOTE_URL);
+ p.setProperty("needs_password", "false");
+ }
+ String repos = p.getProperty("repositories");
+ String pass = p.getProperty("needs_password");
+ String repo[] = repos.split(",");
+ String needsPass[] = pass.split(",");
+ git.getRepositories().removeAllElements();
+
+ for (int i = 0; i < repo.length; i++) {
+ boolean n = false;
+ if (needsPass[i].equals("true")) {
+ n = true;
+ }
+ GithubRepository g = new GithubRepository(repo[i], ServerWizard2.GIT_LOCATION, n);
+ g.setShell(getShell());
+ git.getRepositories().add(g);
+ }
+ } catch (Exception e) {
+ ServerWizard2.LOGGER.severe(e.getMessage());
+ }
+ }
+
+ public boolean close() {
+ Properties p = new Properties();
+ try {
+ FileInputStream propFile = new FileInputStream(ServerWizard2.PROPERTIES_FILE);
+ p.load(propFile);
+ propFile.close();
+
+ FileOutputStream out = new FileOutputStream(ServerWizard2.PROPERTIES_FILE);
+ String repo = git.getRepositoriesStr();
+ String pass = git.getPasswordStr();
+ p.setProperty("repositories", repo);
+ p.setProperty("needs_password", pass);
+ p.store(out, "");
+ out.close();
+ } catch (IOException e) {
+ ServerWizard2.LOGGER.severe("Unable to write preferences file");
+ }
+ return super.close();
+ }
+
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText("Manage Git Repositories");
+ }
+}
diff --git a/src/com/ibm/ServerWizard2/view/MainDialog.java b/src/com/ibm/ServerWizard2/view/MainDialog.java
index bb472a6..cc455d2 100644
--- a/src/com/ibm/ServerWizard2/view/MainDialog.java
+++ b/src/com/ibm/ServerWizard2/view/MainDialog.java
@@ -1,6 +1,5 @@
package com.ibm.ServerWizard2.view;
-import java.util.Map;
import java.util.Vector;
import org.eclipse.jface.dialogs.Dialog;
@@ -48,13 +47,14 @@ import org.eclipse.wb.swt.SWTResourceManager;
import com.ibm.ServerWizard2.ServerWizard2;
import com.ibm.ServerWizard2.controller.TargetWizardController;
-import com.ibm.ServerWizard2.model.Attribute;
import com.ibm.ServerWizard2.model.Connection;
import com.ibm.ServerWizard2.model.ConnectionEndpoint;
import com.ibm.ServerWizard2.model.Field;
import com.ibm.ServerWizard2.model.Target;
import com.ibm.ServerWizard2.utility.GithubFile;
+
+
public class MainDialog extends Dialog {
private TableViewer viewer;
private Tree tree;
@@ -79,6 +79,7 @@ public class MainDialog extends Dialog {
private Button btnDeleteTarget;
private Button btnSave;
private Button btnOpen;
+ private Button btnClone;
private Button btnOpenLib;
private Button btnDeleteConnection;
private Button btnSaveAs;
@@ -156,9 +157,9 @@ public class MainDialog extends Dialog {
rl_composite.wrap = false;
rl_composite.fill = true;
composite.setLayout(rl_composite);
- GridData gd_composite = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1);
+ GridData gd_composite = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
gd_composite.widthHint = 918;
- gd_composite.heightHint = 135;
+ gd_composite.heightHint = 154;
composite.setLayoutData(gd_composite);
sashForm_1 = new SashForm(container, SWT.BORDER | SWT.VERTICAL);
@@ -169,12 +170,28 @@ public class MainDialog extends Dialog {
buttonRow1 = new Composite(container, SWT.NONE);
GridData gd_buttonRow1 = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
- gd_buttonRow1.widthHint = 789;
+ gd_buttonRow1.widthHint = 850;
buttonRow1.setLayoutData(gd_buttonRow1);
GridLayout rl_buttonRow1 = new GridLayout(18, false);
buttonRow1.setLayout(rl_buttonRow1);
this.createButtonsForButtonBar2(buttonRow1);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
+ new Label(buttonRow1, SWT.NONE);
sashForm = new SashForm(sashForm_1, SWT.NONE);
@@ -200,6 +217,8 @@ public class MainDialog extends Dialog {
// //////////////////////////////////////////////////////////
// Tab folders
tabFolder = new TabFolder(composite, SWT.NONE);
+ tabFolder.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ tabFolder.setLayoutData(new RowData(SWT.DEFAULT, 119));
tbtmAddInstances = new TabItem(tabFolder, SWT.NONE);
tbtmAddInstances.setText("Instances");
@@ -243,11 +262,12 @@ public class MainDialog extends Dialog {
btnDeleteTarget.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
btnDeleteTarget.setText("Delete Instance");
- btnShowHidden = new Button(compositeInstance, SWT.CHECK);
- GridData gd_btnShowHidden = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
- gd_btnShowHidden.heightHint = 20;
- btnShowHidden.setLayoutData(gd_btnShowHidden);
- btnShowHidden.setText(" Show Hidden");
+ btnShowHidden = new Button(compositeInstance, SWT.CHECK);
+ btnShowHidden.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ GridData gd_btnShowHidden = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_btnShowHidden.heightHint = 20;
+ btnShowHidden.setLayoutData(gd_btnShowHidden);
+ btnShowHidden.setText(" Show Hidden");
btnCopyInstance = new Button(compositeInstance, SWT.NONE);
btnCopyInstance.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
@@ -272,6 +292,7 @@ public class MainDialog extends Dialog {
compositeBus.setLayout(new GridLayout(2, false));
lblChooseBus = new Label(compositeBus, SWT.NONE);
+ lblChooseBus.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
lblChooseBus.setAlignment(SWT.RIGHT);
GridData gd_lblChooseBus = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
gd_lblChooseBus.widthHint = 88;
@@ -279,6 +300,7 @@ public class MainDialog extends Dialog {
lblChooseBus.setText("Select Bus:");
cmbBusses = new Combo(compositeBus, SWT.READ_ONLY);
+ cmbBusses.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
cmbBusses.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 1, 1));
cmbBusses.add("NONE");
@@ -286,6 +308,7 @@ public class MainDialog extends Dialog {
cmbBusses.select(0);
lblSelectedCard = new Label(compositeBus, SWT.NONE);
+ lblSelectedCard.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
lblSelectedCard.setAlignment(SWT.RIGHT);
GridData gd_lblSelectedCard = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
gd_lblSelectedCard.widthHint = 93;
@@ -293,6 +316,7 @@ public class MainDialog extends Dialog {
lblSelectedCard.setText("Select Card:");
cmbCards = new Combo(compositeBus, SWT.READ_ONLY);
+ cmbCards.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
cmbCards.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
btnDeleteConnection = new Button(compositeBus, SWT.NONE);
@@ -301,6 +325,7 @@ public class MainDialog extends Dialog {
btnDeleteConnection.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
btnHideBusses = new Button(compositeBus, SWT.CHECK);
+ btnHideBusses.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
btnHideBusses.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
btnHideBusses.setText("Show only busses of selected type");
btnHideBusses.setSelection(true);
@@ -330,12 +355,11 @@ public class MainDialog extends Dialog {
+ "5. Navigate to connection destination\r\n6. Right-click on destination and select \"Add Connection\"");
listBusses = new List(sashForm, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ listBusses.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
this.addEvents();
-
- controller.init();
-
this.setDirtyState(false);
+
// load file if passed on command line
if (!mrwFilename.isEmpty()) {
controller.readXML(mrwFilename);
@@ -345,8 +369,8 @@ public class MainDialog extends Dialog {
cmbBusses.add(t.getType());
cmbBusses.setData(t.getType(), t);
}
+ attributes = new Vector<Field>();
this.initInstanceMode();
- // columnName.setWidth(200);
sashForm.setWeights(new int[] { 1, 1 });
columnName.pack();
@@ -380,12 +404,8 @@ public class MainDialog extends Dialog {
try {
controller.initModel();
setFilename("");
- initAll();
+ initInstanceMode();
setDirtyState(false);
- refreshInstanceTree();
- refreshConnections();
- updateView();
-
} catch (Exception e1) {
e1.printStackTrace();
}
@@ -417,7 +437,7 @@ public class MainDialog extends Dialog {
}
Boolean dirty = controller.readXML(filename);
setFilename(filename);
- initAll();
+ initInstanceMode();
setDirtyState(dirty);
}
});
@@ -481,6 +501,22 @@ public class MainDialog extends Dialog {
gd_sep.widthHint = 30;
label.setLayoutData(gd_sep);
+ btnClone = createButton(row1, IDialogConstants.NO_ID, "Manage Library", false);
+ GridData gd_btnClone = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ gd_btnClone.widthHint = 100;
+
+ btnClone.setLayoutData(gd_btnClone);
+ btnClone.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnClone.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ GitDialog dlg = new GitDialog(btnClone.getShell());
+ dlg.open();
+ }
+ });
+ btnClone.setToolTipText("Retrieves Library from github");
+
+
btnOpenLib = createButton(row1, IDialogConstants.NO_ID, "Open Lib", false);
GridData gd_btnOpenLib = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_btnOpenLib.widthHint = 90;
@@ -492,7 +528,7 @@ public class MainDialog extends Dialog {
public void widgetSelected(SelectionEvent e) {
Button b = (Button) e.getSource();
DirectoryDialog fdlg = new DirectoryDialog(b.getShell(), SWT.OPEN);
- fdlg.setFilterPath(controller.getWorkingDir());
+ fdlg.setFilterPath(ServerWizard2.getWorkingDir());
String libPath = fdlg.open();
if (libPath == null) {
return;
@@ -569,11 +605,6 @@ public class MainDialog extends Dialog {
return null;
}
- private void initAll() {
- tabFolder.setSelection(0);
- initInstanceMode();
- }
-
private void initBusMode() {
busMode = true;
this.lblBusDirections.setEnabled(true);
@@ -590,24 +621,24 @@ public class MainDialog extends Dialog {
}
if (cmbCards.getItemCount() > 0) {
cmbCards.select(-1);
- //this.targetForConnections = (Target)cmbCards.getData();
}
for (TreeItem item : tree.getItems()) {
Target target = (Target) item.getData();
- // controller.getRootTarget().hideBusses();
controller.hideBusses(target);
}
-
-
this.source = null;
this.dest = null;
this.selectedEndpoint = null;
refreshInstanceTree();
refreshConnections();
+ attributes.clear();
+ viewer.setInput(attributes);
+ viewer.refresh();
this.updateView();
}
private void initInstanceMode() {
+ tabFolder.setSelection(0);
busMode = false;
this.lblInstanceDirections.setEnabled(true);
this.lblInstanceDirections.setVisible(true);
@@ -618,6 +649,10 @@ public class MainDialog extends Dialog {
this.targetForConnections = null;
this.refreshInstanceTree();
this.listBusses.removeAll();
+ refreshConnections();
+ attributes.clear();
+ viewer.setInput(attributes);
+ viewer.refresh();
this.updateView();
}
@@ -637,6 +672,10 @@ public class MainDialog extends Dialog {
}
}
+ /*
+ * Updates button enabled states based on if target is selected
+ * Also updates attribute table based on selected target
+ */
private void updateView() {
Target targetInstance = getSelectedTarget();
if (targetInstance == null) {
@@ -650,10 +689,13 @@ public class MainDialog extends Dialog {
updatePopupMenu(targetInstance);
updateChildCombo(targetInstance);
+ //A target is selected so show the associated attributes
TreeItem item = tree.getSelection()[0];
ConnectionEndpoint ep = this.getEndpoint(item, null);
- refreshAttributes(targetInstance,ep);
-
+ attributes = controller.getAttributesAndGlobals(targetInstance, "/"+ep.getName());
+ viewer.setInput(attributes);
+ viewer.refresh();
+
if (targetInstance.isSystem()) {
btnDeleteTarget.setEnabled(false);
} else {
@@ -667,7 +709,10 @@ public class MainDialog extends Dialog {
btnDefaults.setEnabled(true);
}
-
+ /*
+ * Creates right-click popup menu for adding connections
+ *
+ */
private void updatePopupMenu(Target selectedTarget) {
if (selectedTarget == null || tree.getSelectionCount()==0) {
return;
@@ -819,36 +864,6 @@ public class MainDialog extends Dialog {
this.setFontStyle(item, SWT.BOLD | SWT.ITALIC, true);
selectedEndpoint = item;
}
-
- private void refreshAttributes(Target targetInstance,ConnectionEndpoint ep) {
- attributes.clear();
- for (Map.Entry<String, Attribute> entry : targetInstance.getAttributes().entrySet()) {
-
- Attribute attribute = entry.getValue();
- if (!attribute.isHidden()) {
- if (attribute.isGlobal() && !controller.getModelCreationMode()) {
- if (ep !=null) {
- String path="/"+ep.getName();
- Field field = controller.getGlobalSetting(path, attribute.name);
- if (field==null) {
- controller.setGlobalSetting(path, attribute.name, "");
- field = controller.getGlobalSetting(path, attribute.name);
- }
- field.type = attribute.getValue().getType();
- if (field.type.equals("enumeration")) {
- field.enumerator = attribute.getValue().getFields().get(0).enumerator;
- }
- attributes.add(field);
- }
- } else {
- for (Field field : attribute.getValue().getFields())
- attributes.add(field);
- }
- }
- }
- viewer.refresh();
- }
-
private void clearTreeAll() {
if (tree.getItemCount() > 0) {
clearTree(tree.getItem(0));
@@ -997,6 +1012,23 @@ public class MainDialog extends Dialog {
}
}
+ private void addConnection(Boolean cabled) {
+ Target busTarget = (Target) cmbBusses.getData(cmbBusses.getText());
+ Connection conn = targetForConnections.addConnection(busTarget, source, dest, cabled);
+ this.addConnection(conn);
+ setDirtyState(true);
+ }
+
+ private void deleteConnection() {
+ if (targetForConnections == null || listBusses.getSelectionCount() == 0) {
+ return;
+ }
+ Connection conn = (Connection) listBusses.getData(listBusses.getSelection()[0]);
+ controller.deleteConnection(targetForConnections, conn.busTarget, conn);
+ this.refreshConnections();
+ setDirtyState(true);
+ }
+
private void setFontStyle(TreeItem item, int style, boolean selected) {
if (item.isDisposed()) {
return;
@@ -1023,23 +1055,6 @@ public class MainDialog extends Dialog {
return super.close();
}
- private void addConnection(Boolean cabled) {
- Target busTarget = (Target) cmbBusses.getData(cmbBusses.getText());
- Connection conn = targetForConnections.addConnection(busTarget, source, dest, cabled);
- this.addConnection(conn);
- setDirtyState(true);
- }
-
- private void deleteConnection() {
- if (targetForConnections == null || listBusses.getSelectionCount() == 0) {
- return;
- }
- Connection conn = (Connection) listBusses.getData(listBusses.getSelection()[0]);
- controller.deleteConnection(targetForConnections, conn.busTarget, conn);
- this.refreshConnections();
- setDirtyState(true);
- }
-
public void setDirtyState(Boolean dirty) {
this.dirty = dirty;
if (this.btnSave != null) {
@@ -1196,7 +1211,9 @@ public class MainDialog extends Dialog {
public void widgetSelected(SelectionEvent arg0) {
if (listBusses.getSelectionCount() > 0) {
Connection conn = (Connection) listBusses.getData(listBusses.getSelection()[0]);
- refreshAttributes(conn.busTarget,null);
+ attributes = controller.getAttributesAndGlobals(conn.busTarget, "");
+ viewer.setInput(attributes);
+ viewer.refresh();
}
}
});
@@ -1288,7 +1305,5 @@ public class MainDialog extends Dialog {
});
viewer.setContentProvider(ArrayContentProvider.getInstance());
- attributes = new Vector<Field>();
- viewer.setInput(attributes);
}
}
diff --git a/src/com/ibm/ServerWizard2/view/PasswordPrompt.java b/src/com/ibm/ServerWizard2/view/PasswordPrompt.java
new file mode 100644
index 0000000..2197056
--- /dev/null
+++ b/src/com/ibm/ServerWizard2/view/PasswordPrompt.java
@@ -0,0 +1,98 @@
+package com.ibm.ServerWizard2.view;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.wb.swt.SWTResourceManager;
+
+public class PasswordPrompt extends Dialog {
+ private Text text;
+ public char passwd[];
+ private String label = "REPO";
+ Button btnOk;
+
+ /**
+ * Create the dialog.
+ * @param parentShell
+ */
+ public PasswordPrompt(Shell parentShell,String label) {
+ super(parentShell);
+ setShellStyle(SWT.APPLICATION_MODAL);
+ this.label = label;
+ }
+
+ /**
+ * Create contents of the dialog.
+ * @param parent
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+
+ Label lblEnterPasswordFor = new Label(container, SWT.NONE);
+ lblEnterPasswordFor.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ GridData gd_lblEnterPasswordFor = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+ gd_lblEnterPasswordFor.widthHint = 352;
+ gd_lblEnterPasswordFor.heightHint = 21;
+ lblEnterPasswordFor.setLayoutData(gd_lblEnterPasswordFor);
+ lblEnterPasswordFor.setText("Enter Password For:");
+
+ Label lblRepository = new Label(container, SWT.NONE);
+ lblRepository.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ GridData gd_lblRepository = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+ gd_lblRepository.widthHint = 419;
+ gd_lblRepository.heightHint = 20;
+ lblRepository.setLayoutData(gd_lblRepository);
+ lblRepository.setText(label);
+
+ Composite composite_1 = new Composite(container, SWT.NONE);
+ GridData gd_composite_1 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+ gd_composite_1.widthHint = 418;
+ gd_composite_1.heightHint = 38;
+ composite_1.setLayoutData(gd_composite_1);
+
+ text = new Text(composite_1, SWT.BORDER | SWT.PASSWORD);
+ text.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ text.setBounds(10, 10, 115, 21);
+
+ btnOk = new Button(composite_1, SWT.NONE);
+ btnOk.setFont(SWTResourceManager.getFont("Arial", 9, SWT.NORMAL));
+ btnOk.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent arg0) {
+ passwd = text.getTextChars();
+ close();
+ }
+ });
+ btnOk.setBounds(143, 6, 75, 25);
+ btnOk.setText("Ok");
+ this.getShell().setDefaultButton(btnOk);
+
+ return container;
+ }
+
+ /**
+ * Create contents of the button bar.
+ * @param parent
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ }
+
+ /**
+ * Return the initial size of the dialog.
+ */
+ @Override
+ protected Point getInitialSize() {
+ return new Point(447, 174);
+ }
+}
OpenPOWER on IntegriCloud