use of org.eclipse.jface.viewers.StructuredSelection in project cubrid-manager by CUBRID.
the class AddDashboardDialog method createDbTree.
/**
*
* Create table area
*
* @param parent the parent composite
*/
private void createDbTree(Composite parent) {
Label tipLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
tipLabel.setText(Messages.lblDashboardInfo);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
tipLabel.setLayoutData(gridData);
dbTv = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
{
dbTree = dbTv.getTree();
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 2;
gridData.heightHint = 200;
dbTree.setLayoutData(gridData);
dbTree.setHeaderVisible(true);
dbTree.setLinesVisible(true);
TreeColumn column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colIP);
column.setWidth(120);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colPort);
column.setWidth(50);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colServerType);
column.setWidth(100);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colServerStatus);
column.setWidth(100);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colName);
column.setWidth(150);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colStatus);
column.setWidth(150);
column = new TreeColumn(dbTree, SWT.CENTER);
column.setText(Messages.colType);
column.setWidth(60);
dbTv.setContentProvider(new DatabaseProvider());
dbTv.setLabelProvider(new DatabaseProvider());
dbTv.setInput(hostNodeList);
dbTree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
deleteButton.setEnabled(dbTree.getSelectionCount() > 0);
}
});
}
Composite composite = new Composite(parent, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
composite.setLayout(rowLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
composite.setLayoutData(gridData);
Button addButton = new Button(composite, SWT.NONE);
addButton.setText(Messages.btnAdd);
addButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) dbTv.getSelection();
HostNode hostNode = null;
int addType = 0;
if (selection != null && !selection.isEmpty()) {
Object obj = selection.getFirstElement();
if (obj instanceof HostNode) {
hostNode = (HostNode) obj;
addType = 0;
} else if (obj instanceof DatabaseNode) {
hostNode = ((DatabaseNode) obj).getParent();
addType = 1;
} else if (obj instanceof BrokerNode) {
hostNode = ((BrokerNode) obj).getParent();
addType = 2;
}
}
AddHostAndDbWizard wizard = new AddHostAndDbWizard(hostNode, hostNodeList, addType);
CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
dialog.setPageSize(660, 380);
if (IDialogConstants.OK_ID == dialog.open()) {
List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
HAUtil.mergeHostNode(hostNodeList, addedHostNodeList);
dbTv.refresh();
}
deleteButton.setEnabled(dbTree.getSelectionCount() > 0);
verify();
}
});
deleteButton = new Button(composite, SWT.NONE);
deleteButton.setText(Messages.btnDelete);
deleteButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) dbTv.getSelection();
if (selection != null && !selection.isEmpty()) {
Object[] objs = selection.toArray();
for (int i = 0; i < objs.length; i++) {
Object obj = objs[i];
if (obj instanceof HostNode) {
hostNodeList.remove((HostNode) obj);
} else if (obj instanceof DatabaseNode) {
((DatabaseNode) obj).getParent().getCopyedHaNodeList().remove((DatabaseNode) obj);
} else if (obj instanceof BrokerNode) {
((BrokerNode) obj).getParent().getCopyedHaNodeList().remove((BrokerNode) obj);
}
}
dbTv.refresh();
}
deleteButton.setEnabled(dbTree.getSelectionCount() > 0);
verify();
}
});
deleteButton.setEnabled(false);
}
use of org.eclipse.jface.viewers.StructuredSelection in project cubrid-manager by CUBRID.
the class AddHADatabaseDialog method createTable.
/**
*
* Create table area
*
* @param parent the parent composite
*/
private void createTable(Composite parent) {
Label tipLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
tipLabel.setText(Messages.lblDbListInfo);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
tipLabel.setLayoutData(gridData);
final String[] columnNameArr = new String[] { Messages.colDbName, Messages.colDbStatus, Messages.colIP, Messages.colPort, Messages.colServerStatus };
dbTableViewer = CommonUITool.createCommonTableViewer(parent, null, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 100));
dbTable = dbTableViewer.getTable();
for (int i = 0; i < dbTable.getColumnCount(); i++) {
dbTable.getColumn(i).pack();
}
dbTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
deleteDbButton.setEnabled(dbTable.getSelectionCount() > 0);
}
});
dbTableViewer.setInput(dbNodeList);
Composite composite = new Composite(parent, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
composite.setLayout(rowLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
composite.setLayoutData(gridData);
deleteDbButton = new Button(composite, SWT.NONE);
deleteDbButton.setText(Messages.btnDelete);
deleteDbButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
if (selection != null && !selection.isEmpty()) {
dbNodeList.removeAll(selection.toList());
}
dbTableViewer.refresh();
deleteDbButton.setEnabled(dbTable.getSelectionCount() > 0);
verify();
}
});
deleteDbButton.setEnabled(false);
}
use of org.eclipse.jface.viewers.StructuredSelection in project cubrid-manager by CUBRID.
the class VolumeSizeValidator method createTable.
/**
* Create volume table area
*
* @param parent the parent composite
*/
private void createTable(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
composite.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
composite.setLayout(layout);
Label tipLabel = new Label(composite, SWT.LEFT | SWT.WRAP);
tipLabel.setText(Messages.msgVolumeList);
tipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
gridData = new GridData(GridData.FILL_HORIZONTAL);
tipLabel.setLayoutData(gridData);
addVolumeButton = new Button(composite, SWT.NONE);
addVolumeButton.setText(Messages.btnAddVolume);
addVolumeButton.setEnabled(false);
addVolumeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String volumeName = volumeNameText.getText();
String volumeType = volumeTypeCombo.getText();
String volumeSize = volumeSizeText.getText();
String pageNumber = String.valueOf(CreateDatabaseWizard.calcVolumePageNum(volumeSize, pageSize));
String volumePath = volumePathText.getText();
Map<String, String> map = new HashMap<String, String>();
map.put("0", volumeName);
map.put("1", volumeType);
map.put("2", volumeSize);
map.put("3", pageNumber);
map.put("4", volumePath);
volumeTableList.add(map);
volumeTableViewer.refresh();
for (int i = 0; i < volumeTable.getColumnCount(); i++) {
volumeTable.getColumn(i).pack();
}
changeVolumeName();
changeAutoVolumeButton();
}
});
deleteVolumeButton = new Button(composite, SWT.NONE);
deleteVolumeButton.setText(Messages.btnDelVolume);
deleteVolumeButton.setEnabled(false);
deleteVolumeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) volumeTableViewer.getSelection();
if (selection != null && !selection.isEmpty()) {
volumeTableList.removeAll(selection.toList());
}
volumeTableViewer.refresh();
deleteVolumeButton.setEnabled(volumeTable.getSelectionCount() > 0);
changeAutoVolumeButton();
changeVolumeName();
}
});
final String[] columnNameArr = new String[] { Messages.tblColumnVolName, Messages.tblColumnVolType, Messages.tblColumnVolSize, Messages.tblColumnVolPath };
volumeTableViewer = CommonUITool.createCommonTableViewer(parent, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
volumeTableViewer.setLabelProvider(new VolumeInfoTableProvider());
volumeTableViewer.setInput(volumeTableList);
volumeTable = volumeTableViewer.getTable();
for (int i = 0; i < volumeTable.getColumnCount(); i++) {
volumeTable.getColumn(i).pack();
}
volumeTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
deleteVolumeButton.setEnabled(volumeTable.getSelectionCount() > 0);
}
});
// Create the cell editors
CellEditor[] editors = new CellEditor[4];
editors[0] = new TextCellEditor(volumeTable);
editors[1] = new ComboBoxCellEditor(volumeTable, VOLUME_TYPES, SWT.READ_ONLY);
editors[2] = new TextCellEditor(volumeTable);
editors[3] = null;
editors[0].setValidator(new VolumeNameValidator(volumeTableViewer));
editors[0].addListener(new ICellEditorListener() {
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
if (!newValidState) {
VolumeInfoPage.this.setErrorMessage(Messages.errVolumeName);
} else {
VolumeInfoPage.this.setErrorMessage(null);
}
}
public void cancelEditor() {
VolumeInfoPage.this.setErrorMessage(null);
}
public void applyEditorValue() {
VolumeInfoPage.this.setErrorMessage(null);
}
});
editors[2].setValidator(new VolumeSizeValidator());
editors[2].addListener(new ICellEditorListener() {
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
if (!newValidState) {
VolumeInfoPage.this.setErrorMessage(Messages.errVolumeSize);
} else {
VolumeInfoPage.this.setErrorMessage(null);
}
}
public void cancelEditor() {
VolumeInfoPage.this.setErrorMessage(null);
}
public void applyEditorValue() {
VolumeInfoPage.this.setErrorMessage(null);
}
});
volumeTableViewer.setCellEditors(editors);
volumeTableViewer.setColumnProperties(PROPS);
volumeTableViewer.setCellModifier(new VolumnCellEditor(this, volumeTableViewer));
}
use of org.eclipse.jface.viewers.StructuredSelection in project cubrid-manager by CUBRID.
the class MultiDatabaseLoginFailedDialog method buttonPressed.
/**
* When press button,call it
*
* @param buttonId the button id
*/
protected void buttonPressed(int buttonId) {
if (buttonId == EDIT_ID) {
IStructuredSelection selection = (StructuredSelection) databaseTable.getSelection();
MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo = (MultiDatabaseloginFailedInfo) selection.getFirstElement();
editHost(multiDatabaseloginFailedInfo);
//if all database login , close this dialog
if (!checkAllDatabaseLogin()) {
return;
}
}
setReturnCode(buttonId);
close();
}
use of org.eclipse.jface.viewers.StructuredSelection in project cubrid-manager by CUBRID.
the class RenameHostAction method doRun.
private void doRun(CubridServer server) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
RenameHostDialog dlg = new RenameHostDialog(shell, server);
int ret = dlg.open();
if (ret == IDialogConstants.OK_ID) {
server.setLabel(dlg.getNewName());
server.getServerInfo().setServerName(dlg.getNewName());
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
LOGGER.error("Error: Can't find the navigator view:" + CubridHostNavigatorView.ID);
return;
}
// Fire all the databases which are in the server logout
List<ICubridNode> children = server.getChildren();
if (children != null) {
for (ICubridNode child : children) {
if (!NodeType.DATABASE_FOLDER.equals(child.getType())) {
continue;
}
List<ICubridNode> childList = child.getChildren();
if (childList == null) {
continue;
}
for (ICubridNode node : childList) {
if (!NodeType.DATABASE.equals(node.getType())) {
continue;
}
CubridDatabase database = (CubridDatabase) node;
database.setLogined(false);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
}
}
}
// Refresh the tree view
server.removeAllChild();
if (server.getLoader() != null) {
server.getLoader().setLoaded(false);
}
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
treeViewer.setSelection(null, true);
treeViewer.setSelection(new StructuredSelection(server), true);
setEnabled(false);
// Save the data
CMHostNodePersistManager.getInstance().addServer(server.getServerInfo().getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName(), server.getServerInfo());
QueryOptions.removePref(server.getServerInfo());
BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(server.getLabel());
CMGroupNodePersistManager.getInstance().saveAllGroupNode();
CMHostNodePersistManager.getInstance().saveServers();
ActionManager.getInstance().fireSelectionChanged(getSelection());
LayoutManager.getInstance().fireSelectionChanged(getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
}
}
Aggregations