use of org.talend.core.model.general.ConnectionBean in project tdi-studio-se by Talend.
the class ConnectionsListButtonsToolBar method createAddPushButton.
@Override
protected AddPushButton createAddPushButton() {
return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {
@Override
protected Object getObjectToAdd() {
ConnectionBean newConnection = new ConnectionBean();
newConnection.setName(NEW_CONNECTION_LABEL);
return newConnection;
}
};
}
use of org.talend.core.model.general.ConnectionBean in project tdi-studio-se by Talend.
the class ConnectionsListComposite method setConnectionsFormComposite.
public void setConnectionsFormComposite(ConnectionFormComposite connectionsFormComposite) {
this.connectionsFormComposite = connectionsFormComposite;
table.getTableViewerCreator().getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {
@Override
public void handle(LineSelectionEvent e) {
ISelection sel = e.source.getTableViewer().getSelection();
IStructuredSelection sel2 = (IStructuredSelection) sel;
ConnectionBean selected = (ConnectionBean) sel2.getFirstElement();
setSelectedConnection(selected);
}
});
if (!list.isEmpty()) {
for (int i = 0; i < list.size(); i++) {
setSelectedConnection(list.get(i));
}
setSelectedConnection(list.get(0));
}
}
use of org.talend.core.model.general.ConnectionBean in project tdi-studio-se by Talend.
the class TOSLoginComposite method addListener.
private void addListener() {
createButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Project project = null;
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
NewProjectWizard newPrjWiz = new NewProjectWizard(null);
WizardDialog newProjectDialog = new WizardDialog(getShell(), newPrjWiz);
//$NON-NLS-1$
newProjectDialog.setTitle(Messages.getString("LoginDialog.newProjectTitle"));
if (newProjectDialog.open() == Window.OK) {
project = newPrjWiz.getProject();
refresh();
ArrayList<String> allProjects = (ArrayList<String>) projectListViewer.getInput();
int index = 0;
Collections.sort(allProjects);
for (int i = 0; i < allProjects.size(); i++) {
String projectName = allProjects.get(i);
if (project.getLabel().equals(projectName)) {
index = i;
break;
}
}
projectListViewer.getList().select(index);
projectListViewer.refresh();
}
}
});
deleteButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Shell activeShell = Display.getCurrent().getActiveShell();
SelectDeleteProjectDialog dialog = new SelectDeleteProjectDialog(activeShell, true);
if (dialog.open() == Dialog.OK) {
CorePlugin.getDefault().getRepositoryLocalProviderService().resetXmiResourceSet();
java.util.List<Object> delList = dialog.getDelList();
if (delList.size() != 0) {
for (Object obj : delList) {
if (obj instanceof IProject) {
IProject p = (IProject) obj;
if (projectsMap.containsKey(p.getName())) {
projectsMap.remove(p.getName());
String name = convertorMapper.get(p.getName());
if (name != null) {
convertorMapper.remove(p.getName());
TOSLoginComposite.this.projectListViewer.getList().remove(name);
}
if (TOSLoginComposite.this.projectListViewer.getList().getItemCount() == 0) {
enableOpenAndDelete(false);
} else if (TOSLoginComposite.this.projectListViewer.getSelection().isEmpty()) {
TOSLoginComposite.this.projectListViewer.getList().select(0);
}
try {
setStatusArea();
} catch (PersistenceException e1) {
ExceptionHandler.process(e1);
}
}
}
}
}
}
refresh();
}
});
importButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ImportDemoProjectAction.getInstance().setShell(getShell());
ImportProjectAsAction.getInstance().run();
String newProject = ImportProjectAsAction.getInstance().getProjectName();
if (newProject != null) {
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
Project[] projects = null;
try {
projects = repositoryFactory.readProject();
} catch (PersistenceException e1) {
e1.printStackTrace();
} catch (BusinessException e1) {
e1.printStackTrace();
}
if (!projectsMap.containsKey(newProject.toUpperCase())) {
for (Project project : projects) {
if (project.getLabel().toUpperCase().equals(newProject.toUpperCase())) {
projectsMap.put(newProject.toUpperCase(), project);
convertorMapper.put(newProject.toUpperCase(), newProject);
enableOpenAndDelete(true);
try {
setStatusArea();
} catch (PersistenceException e1) {
ExceptionHandler.process(e1);
}
}
}
TOSLoginComposite.this.projectListViewer.setInput(new ArrayList(convertorMapper.values()));
}
}
try {
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
ProxyRepositoryFactory.getInstance().initialize();
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
}
};
new ProgressMonitorDialog(getShell()).run(true, false, op);
refresh();
} catch (InvocationTargetException e1) {
e1.getTargetException();
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
changeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dirDialog = new DirectoryDialog(dialog.getShell());
String path = dirDialog.open();
if (path == null || "".equals(path)) {
//$NON-NLS-1$
workspaceText.setText(getRecentWorkSpace());
loginComposite.getConnection().setWorkSpace(getRecentWorkSpace());
} else {
workspaceText.setText(path);
loginComposite.getConnection().setWorkSpace(path);
if (!path.equals(oldPath)) {
oldPath = path;
restartBut.setVisible(true);
openButton.setEnabled(false);
deleteButton.setEnabled(false);
createButton.setEnabled(false);
importButton.setEnabled(false);
demoProjectButton.setEnabled(false);
changeButton.setEnabled(false);
}
}
java.util.List<ConnectionBean> list = new ArrayList<ConnectionBean>();
list.add(loginComposite.getConnection());
loginComposite.storedConnections = list;
perReader.saveConnections(loginComposite.storedConnections);
if (!loginComposite.isWorkSpaceSame()) {
try {
setStatusArea();
} catch (PersistenceException e1) {
ExceptionHandler.process(e1);
}
}
}
});
restartBut.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
LoginComposite.isRestart = true;
ConnectionBean connection = loginComposite.getConnection();
perReader.saveLastConnectionBean(connection);
// update the restart command line to specify the workspace to launch
// if relaunch, should delete the "disableLoginDialog" argument in eclipse data for bug TDI-19214
//$NON-NLS-1$
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand("-data", connection.getWorkSpace(), false);
// store the workspace in the eclipse history so that it is rememebered on next studio launch
//$NON-NLS-1$
ChooseWorkspaceData workspaceData = new ChooseWorkspaceData("");
workspaceData.workspaceSelected(connection.getWorkSpace());
workspaceData.writePersistedData();
dialog.okPressed();
}
});
openButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
loginComposite.setRepositoryContextInContext();
if (!TOSLoginComposite.this.projectListViewer.getSelection().isEmpty()) {
String selection = TOSLoginComposite.this.projectListViewer.getList().getSelection()[0];
if (selection != null && !selection.equals("")) {
Project project = (Project) projectsMap.get(selection.toUpperCase());
boolean flag = dialog.logIn(project);
if (flag) {
dialog.okPressed();
}
}
}
}
});
demoProjectButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ImportDemoProjectAction action = ImportDemoProjectAction.getInstance();
action.setShell(getShell());
action.run();
refresh();
}
});
}
Aggregations