use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.
the class QueryRecordListComparator method createDialogArea.
/**
* Create dialog area content
*
* @param parent the parent composite
* @return the control
*/
protected Control createDialogArea(Composite parent) {
Composite container = new Composite(parent, SWT.None);
container.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
container.setLayout(new FormLayout());
topComposite = new Composite(container, SWT.None);
FormData topData = new FormData();
topData.top = new FormAttachment(0, 0);
topData.bottom = new FormAttachment(0, 30);
topData.left = new FormAttachment(0, 0);
topData.right = new FormAttachment(100, 0);
topComposite.setLayoutData(topData);
topComposite.setLayout(new GridLayout(6, false));
Label historyLable = new Label(topComposite, SWT.None);
historyLable.setText(Messages.lblProject);
historyLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
historyCombo = new Combo(topComposite, SWT.READ_ONLY);
historyCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
historyCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
String name = historyCombo.getText();
switchQueryRecordProject(name);
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
ToolBar toolBar = new ToolBar(topComposite, SWT.None);
toolBar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
addItem = new ToolItem(toolBar, SWT.PUSH);
addItem.setImage(CommonUIPlugin.getImage("icons/queryplan/add_query.gif"));
addItem.setToolTipText(Messages.itemTooltipAdd);
addItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addQueryRecordProject();
}
});
deleteItem = new ToolItem(toolBar, SWT.PUSH);
deleteItem.setImage(CommonUIPlugin.getImage("icons/queryplan/delete_query.gif"));
deleteItem.setToolTipText(Messages.itemTooltipRemove);
deleteItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
if (queryRecordLeftCombo.getItemCount() == 0) {
CommonUITool.openErrorBox(Messages.msgQueryTunerNotSavedProject);
tabFolder.setSelection(0);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
if (CommonUITool.openConfirmBox(Messages.confirmDeleteTuningProject)) {
ApplicationPersistUtil.getInstance().removeQueryRecordProject(database.getDatabaseInfo(), historyCombo.getText());
ApplicationPersistUtil.getInstance().save();
switchQueryRecordProject("");
}
}
});
renameItem = new ToolItem(toolBar, SWT.PUSH);
renameItem.setImage(CommonUIPlugin.getImage("icons/queryplan/rename_query.gif"));
renameItem.setToolTipText(Messages.itemTooltipRename);
renameItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
renameQueryRecordProject();
}
});
Label placeHolderLabel = new Label(topComposite, SWT.None);
placeHolderLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
buttomComposite = new Composite(container, SWT.None);
buttomComposite.setLayout(new FillLayout());
FormData buttomData = new FormData();
buttomData.top = new FormAttachment(0, 30);
buttomData.bottom = new FormAttachment(100, 0);
buttomData.left = new FormAttachment(0, 0);
buttomData.right = new FormAttachment(100, 0);
buttomComposite.setLayoutData(buttomData);
buttomComposite.setLayout(new FillLayout());
tabFolder = new CTabFolder(buttomComposite, SWT.BORDER);
tabFolder.setTabHeight(20);
tabFolder.marginHeight = 5;
tabFolder.marginWidth = 5;
tabFolder.setMaximizeVisible(false);
tabFolder.setMinimizeVisible(false);
tabFolder.setSimple(false);
tabFolder.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
if (tabFolder.getSelectionIndex() == 1) {
List<QueryRecordProject> projectList = loadProjectList();
if (projectList.size() == 0) {
CommonUITool.openErrorBox(Messages.msgQueryTunerNotSavedProject);
tabFolder.setSelection(0);
} else {
QueryRecordProject usingProject = null;
String projectName = historyCombo.getText();
for (int i = 0; i < projectList.size(); i++) {
QueryRecordProject temp = projectList.get(i);
if (StringUtil.isEqual(projectName, temp.getName())) {
usingProject = temp;
break;
}
}
if (usingProject != null) {
if (usingProject.getQueryRecordList().size() == 0) {
CommonUITool.openErrorBox(Messages.errNoQueryInProject);
return;
}
switchQueryRecordProject(historyCombo.getText());
}
}
}
}
});
createQueryTunerTab(tabFolder);
createQueryCompareTab(tabFolder);
init();
return parent;
}
use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.
the class AddTableFileDialog method createFromComposite.
/**
* Create the from composite
*/
private void createFromComposite() {
Composite fromComposite = new Composite(sashForm, SWT.NONE);
{
GridLayout gridLayout = new GridLayout();
gridLayout.horizontalSpacing = 0;
gridLayout.marginWidth = 0;
gridLayout.verticalSpacing = 5;
gridLayout.marginHeight = 0;
fromComposite.setLayout(gridLayout);
}
Label lblFrom = new Label(fromComposite, SWT.NONE);
lblFrom.setText(Messages.colFileColumn);
fromList = new org.eclipse.swt.widgets.List(fromComposite, SWT.BORDER | SWT.V_SCROLL);
{
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.heightHint = 200;
fromList.setLayoutData(gridData);
}
ToolBar fromToolbar = new ToolBar(fromComposite, SWT.FLAT);
fromToolbar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
ToolItem itemDel = new ToolItem(fromToolbar, SWT.PUSH);
itemDel.setText(Messages.importDeleteExcelColumnBTN);
itemDel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (fromList.getItemCount() > 0 && fromList.getSelectionCount() > 0) {
int index = fromList.getSelectionIndex();
if (index == fromList.getItemCount() - 1) {
fromList.setSelection(index - 1);
fromList.remove(index);
} else {
fromList.remove(index);
fromList.setSelection(index);
}
validate();
}
}
});
}
use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.
the class MonitorStatisticEditor method refreshToolbar.
private void refreshToolbar(boolean isEditMode) {
if (isEditMode) {
changeModeItem.setText(MESSAGE_EDIT_MODE);
changeModeItem.setImage(CubridManagerUIPlugin.getImage("icons/navigator/status_item.png"));
} else {
changeModeItem.setText(MESSAGE_View_MODE);
changeModeItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_backup_edit.png"));
}
ToolItem[] items = toolbar.getItems();
for (int i = 1; i < items.length; i++) {
items[i].dispose();
}
if (isEditMode) {
ToolItem addItem = new ToolItem(toolbar, SWT.PUSH);
addItem.setText(Messages.btnAdd);
addItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_backup_add.png"));
addItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
openEditStatisticItemDialog();
}
});
ToolItem deleteItem = new ToolItem(toolbar, SWT.PUSH);
deleteItem.setText(Messages.btnDelete);
deleteItem.setImage(CubridManagerUIPlugin.getImage("icons/action/auto_backup_delete.png"));
deleteItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
if (!CommonUITool.openConfirmBox(Messages.confirmMultiStatisticChartRemoveWarn)) {
return;
}
List<StatisticChartItem> chartItemList = new ArrayList<StatisticChartItem>();
for (MonitorStatisticChart chart : chartList) {
if (chart.getSelection()) {
chartItemList.add(chart.getStatisticChartItem());
}
}
removeStatisticItem(chartItemList);
}
});
ToolItem refreshItem = new ToolItem(toolbar, SWT.PUSH);
refreshItem.setText(Messages.btnRefresh);
refreshItem.setToolTipText(Messages.RefreshTooltip);
refreshItem.setImage(CommonUIPlugin.getImage("icons/action/refresh.png"));
refreshItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
statisticDataMap = refreshData(statisticItemList);
for (MonitorStatisticChart chart : chartList) {
chart.refreshChart(statisticDataMap.get(chart.getStatisticChartItem()));
}
}
});
selectBtn = new Button(toolbarComp, SWT.CHECK);
final GridData gdSelectBtn = new GridData(SWT.LEFT, SWT.CENTER, false, false);
selectBtn.setLayoutData(gdSelectBtn);
selectBtn.setText(MESSAGE_SELECT_ALL);
selectBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
Button btn = (Button) event.widget;
for (MonitorStatisticChart item : chartList) {
item.setSelection(btn.getSelection());
}
if (btn.getSelection()) {
btn.setText(MESSAGE_DESELECT_ALL);
} else {
btn.setText(MESSAGE_SELECT_ALL);
}
btn.getParent().layout();
}
});
} else {
ToolItem refreshItem = new ToolItem(toolbar, SWT.PUSH);
refreshItem.setText(Messages.btnRefresh);
refreshItem.setToolTipText(Messages.RefreshTooltip);
refreshItem.setImage(CommonUIPlugin.getImage("icons/action/refresh.png"));
refreshItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
statisticDataMap = refreshData(statisticItemList);
for (MonitorStatisticChart chart : chartList) {
chart.refreshChart(statisticDataMap.get(chart.getStatisticChartItem()));
}
}
});
if (selectBtn != null) {
selectBtn.dispose();
}
}
toolbarComp.layout();
}
use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.
the class SettingCubridHAConfPage method createControl.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
setDescription(Messages.descSettingCubridHAPage);
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout(4, false));
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(50, -5);
leftComposite.setLayoutData(leftData);
Label separator = new Label(container, SWT.SEPARATOR);
FormData separatorData = new FormData();
separatorData.top = new FormAttachment(0, 5);
separatorData.bottom = new FormAttachment(100, -5);
separatorData.left = new FormAttachment(50, -5);
separatorData.right = new FormAttachment(50, 5);
separator.setLayoutData(separatorData);
Composite rightComposite = new Composite(container, SWT.NONE);
rightComposite.setLayout(new GridLayout(4, false));
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 5);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
/*Create left widget*/
Label hostALabel = new Label(leftComposite, SWT.None);
hostALabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostALabel.setText(Messages.lblMaster);
masterHostLabel = new Label(leftComposite, SWT.None);
masterHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
masterViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION);
masterViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
masterViewer.getTable().setLinesVisible(true);
masterViewer.getTable().setHeaderVisible(true);
masterViewer.setContentProvider(new TableContentProvider());
masterViewer.setLabelProvider(new CubridConfTableProvider());
masterViewer.setColumnProperties(PROPS);
CellEditor[] editors = new CellEditor[2];
editors[0] = null;
editors[1] = new TextCellEditor(masterViewer.getTable());
masterViewer.setCellEditors(editors);
masterViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
masterViewer.refresh(model);
updateHAModel(masterViewer, model, false);
}
});
TableColumn keyAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
keyAColumn.setText(Messages.lblKey);
keyAColumn.setWidth(160);
TableColumn valueAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
valueAColumn.setText(Messages.lblValue);
valueAColumn.setWidth(200);
Label masterUserLabel = new Label(leftComposite, SWT.None);
masterUserLabel.setText(Messages.lblUser);
masterUserLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterUserCombo = new Combo(leftComposite, SWT.BORDER | SWT.READ_ONLY);
masterUserCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterUserCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
initMasterTableData();
}
});
ToolBar toolBarA = new ToolBar(leftComposite, SWT.None);
toolBarA.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 2, 1, -1, -1));
ToolItem addItemA = new ToolItem(toolBarA, SWT.None);
addItemA.setToolTipText(Messages.itemAddParameter);
addItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(masterViewer);
}
});
ToolItem editItemA = new ToolItem(toolBarA, SWT.None);
editItemA.setToolTipText(Messages.itemEditParameter);
editItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(masterViewer);
}
});
ToolItem dropItemA = new ToolItem(toolBarA, SWT.None);
dropItemA.setToolTipText(Messages.itemDeleteParameter);
dropItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(masterViewer);
}
});
/*Create right widget*/
Label hostBLabel = new Label(rightComposite, SWT.None);
hostBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostBLabel.setText(Messages.lblSlave);
slaveHostLabel = new Label(rightComposite, SWT.None);
slaveHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
slaveViewer = new TableViewer(rightComposite, SWT.BORDER | SWT.FULL_SELECTION);
slaveViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
slaveViewer.getTable().setLinesVisible(true);
slaveViewer.getTable().setHeaderVisible(true);
slaveViewer.setContentProvider(new TableContentProvider());
slaveViewer.setLabelProvider(new CubridConfTableProvider());
slaveViewer.setColumnProperties(PROPS);
CellEditor[] editorsB = new CellEditor[2];
editorsB[0] = null;
editorsB[1] = new TextCellEditor(slaveViewer.getTable());
slaveViewer.setCellEditors(editorsB);
slaveViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
slaveViewer.refresh(model);
updateHAModel(slaveViewer, model, false);
}
});
TableColumn keyBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
keyBColumn.setText(Messages.lblKey);
keyBColumn.setWidth(160);
TableColumn valueBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
valueBColumn.setText(Messages.lblValue);
valueBColumn.setWidth(200);
Label slaveUserLabel = new Label(rightComposite, SWT.None);
slaveUserLabel.setText(Messages.lblUser);
slaveUserLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
slaveUserCombo = new Combo(rightComposite, SWT.BORDER | SWT.READ_ONLY);
slaveUserCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
slaveUserCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
initSlaveTableData();
}
});
ToolBar toolBarB = new ToolBar(rightComposite, SWT.None);
toolBarB.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 2, 1, -1, -1));
ToolItem addItemB = new ToolItem(toolBarB, SWT.None);
addItemB.setToolTipText(Messages.itemAddParameter);
addItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(slaveViewer);
}
});
ToolItem editItemB = new ToolItem(toolBarB, SWT.None);
editItemB.setToolTipText(Messages.itemEditParameter);
editItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(slaveViewer);
}
});
ToolItem dropItemB = new ToolItem(toolBarB, SWT.None);
dropItemB.setToolTipText(Messages.itemDeleteParameter);
dropItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(slaveViewer);
}
});
}
use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.
the class ShardConnectionPanel method build.
public void build(Composite parent) {
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
parent.setLayout(layout);
Label connectionFileNameLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
connectionFileNameLabel.setText(Messages.shardConnnectionFileName);
gridData = new GridData();
gridData.widthHint = 200;
gridData.horizontalSpan = 2;
connectionFileNameLabel.setLayoutData(gridData);
connectionFileNameText = new Text(parent, SWT.BORDER);
connectionFileNameText.setTextLimit(32);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
connectionFileNameText.setLayoutData(gridData);
connectionFileNameText.setEnabled(false);
topLeftToolBar = new ToolBar(parent, SWT.FLAT);
insertRecordItem = new ToolItem(topLeftToolBar, SWT.PUSH);
insertRecordItem.setToolTipText(Messages.addConnection);
insertRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert.png"));
insertRecordItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert_disabled.png"));
insertRecordItem.setEnabled(true);
delRecordItem = new ToolItem(topLeftToolBar, SWT.PUSH);
delRecordItem.setToolTipText(Messages.deleteConnection);
delRecordItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
delRecordItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete_disabled.png"));
delRecordItem.setEnabled(false);
columnNameArrs = new String[] { Messages.tblShardId, Messages.tblDBName, Messages.tblConInfo };
int[] columnwidthArr = new int[] { 100, 180, 300 };
connectionTableViewer = CommonUITool.createCommonTableViewer(parent, null, columnNameArrs, columnwidthArr, CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, 320));
connectionTable = connectionTableViewer.getTable();
load();
initial();
}
Aggregations