public void doWork() { int index = contextValuesTable.getSelectionIndex(); if (index >= 0) { String key = contextValuesTable.getSelection()[0].getText(0); ContextValue value = ConfigurationManager.getInstance(vEditor.getFile().getProject()) .getContextValue(key, vEditor.getFile(), false); ContextValueDialog dialog = new ContextValueDialog(new Shell(), value, vEditor.getFile()); if (IDialogConstants.OK_ID == dialog.open()) { reloadContextValues(); } } }
public void doWork() { int index = contextValuesTable.getSelectionIndex(); if (index >= 0) { try { boolean confirm = MessageDialog.openConfirm( new Shell(), "Confirmation", "Are you sure you want to delete this context value?"); if (confirm) { String key = contextValuesTable.getSelection()[0].getText(0); ContextValue value = ConfigurationManager.getInstance(vEditor.getFile().getProject()) .getContextValue(key, vEditor.getFile(), false); ConfigurationManager.getInstance(vEditor.getFile().getProject()) .removeContextValue(value.name, vEditor.getFile()); reloadContextValues(); } } catch (Exception e1) { Plugin.error(e1); } } }
public void reloadContextValues() { try { contextValuesTable.removeAll(); ContextValue[] values = ConfigurationManager.getInstance(vEditor.getFile().getProject()) .getContextValues(vEditor.getFile(), false); for (int i = 0; i < values.length; i++) { TableItem item = new TableItem(contextValuesTable, SWT.NULL); String[] arr = {values[i].name, values[i].objClass.getName()}; item.setText(arr); } editContextValueButton.setEnabled(false); deleteContextValueButton.setEnabled(false); } catch (Exception e) { Plugin.log(e); } contextValuesTable.redraw(); }