use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.
the class OpenTriggerDetailInfoPartProgress method loadTriggerInfoList.
/**
* load trigger info list
*
* @return Catalog
*/
public void loadTriggerInfoList() {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
try {
new ProgressMonitorDialog(null).run(true, false, OpenTriggerDetailInfoPartProgress.this);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
});
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project azure-tools-for-java by Microsoft.
the class AzureDockerUIResources method updateAzureResourcesWithProgressDialog.
public static void updateAzureResourcesWithProgressDialog(Shell shell, IProject project) {
ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
try {
dialog.run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
monitor.beginTask("Loading Azure Resources", 100);
try {
monitor.subTask("Creating an Azure instance...");
AzureManager azureAuthManager = AuthMethodManager.getInstance().getAzureManager();
if (monitor.isCanceled()) {
monitor.done();
return;
}
// not signed in
if (azureAuthManager == null) {
monitor.done();
return;
}
AzureDockerHostsManager dockerManager = AzureDockerHostsManager.getAzureDockerHostsManagerEmpty(azureAuthManager);
monitor.worked(10);
monitor.subTask("Retrieving the subscription details...");
dockerManager.refreshDockerSubscriptions();
if (monitor.isCanceled()) {
monitor.done();
return;
}
monitor.worked(10);
monitor.subTask("Retrieving the key vault...");
dockerManager.refreshDockerVaults();
monitor.worked(10);
if (monitor.isCanceled()) {
monitor.done();
return;
}
monitor.worked(10);
monitor.subTask("Retrieving the key vault details...");
dockerManager.refreshDockerVaultDetails();
if (monitor.isCanceled()) {
CANCELED = true;
monitor.done();
return;
}
monitor.worked(10);
monitor.subTask("Retrieving the network details...");
dockerManager.refreshDockerVnetDetails();
if (monitor.isCanceled()) {
monitor.done();
return;
}
monitor.worked(10);
monitor.subTask("Retrieving the storage account details...");
dockerManager.refreshDockerStorageAccountDetails();
if (monitor.isCanceled()) {
monitor.done();
return;
}
monitor.subTask("Retrieving the Docker virtual machines details...");
dockerManager.refreshDockerHostDetails();
CANCELED = false;
} catch (Exception e) {
CANCELED = true;
log.log(Level.SEVERE, "updateAzureResourcesWithProgressDialog: " + e.getMessage(), e);
e.printStackTrace();
}
monitor.done();
}
});
} catch (Exception e) {
CANCELED = true;
log.log(Level.SEVERE, "updateAzureResourcesWithProgressDialog: " + e.getMessage(), e);
e.printStackTrace();
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project azure-tools-for-java by Microsoft.
the class SignInDialog method signInAsync.
private void signInAsync() throws InvocationTargetException, InterruptedException {
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Signing In...", IProgressMonitor.UNKNOWN);
try {
AdAuthManager.getInstance().signIn();
} catch (AuthCanceledException ex) {
System.out.println(ex.getMessage());
} catch (IOException ex) {
System.out.println("run@ProgressDialog@signInAsync@SingInDialog: " + ex.getMessage());
//ex.printStackTrace();
//LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "run@ProgressDialog@signInAsync@SingInDialog", e));
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
ErrorWindow.go(getShell(), ex.getMessage(), "Sign In Error");
;
}
});
}
}
};
new ProgressMonitorDialog(this.getShell()).run(true, false, op);
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project azure-tools-for-java by Microsoft.
the class SignInDialog method doCreateServicePrincipal.
private void doCreateServicePrincipal() {
setErrorMessage(null);
AdAuthManager adAuthManager = null;
try {
adAuthManager = AdAuthManager.getInstance();
if (adAuthManager.isSignedIn()) {
adAuthManager.signOut();
}
signInAsync();
if (!adAuthManager.isSignedIn()) {
// canceled by the user
System.out.println(">> Canceled by the user");
return;
}
AccessTokenAzureManager accessTokenAzureManager = new AccessTokenAzureManager();
SubscriptionManager subscriptionManager = accessTokenAzureManager.getSubscriptionManager();
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Getting Subscription List...", IProgressMonitor.UNKNOWN);
try {
subscriptionManager.getSubscriptionDetails();
} catch (Exception ex) {
System.out.println("run@ProgressDialog@doCreateServicePrincipal@SignInDialog: " + ex.getMessage());
LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "run@ProgressDialog@doCreateServicePrincipal@SignInDialogg", ex));
}
}
};
new ProgressMonitorDialog(this.getShell()).run(true, false, op);
SrvPriSettingsDialog d = SrvPriSettingsDialog.go(this.getShell(), subscriptionManager.getSubscriptionDetails());
List<SubscriptionDetail> subscriptionDetailsUpdated;
String destinationFolder;
if (d != null) {
subscriptionDetailsUpdated = d.getSubscriptionDetails();
destinationFolder = d.getDestinationFolder();
} else {
System.out.println(">> Canceled by the user");
return;
}
Map<String, List<String>> tidSidsMap = new HashMap<>();
for (SubscriptionDetail sd : subscriptionDetailsUpdated) {
if (sd.isSelected()) {
System.out.format(">> %s\n", sd.getSubscriptionName());
String tid = sd.getTenantId();
List<String> sidList;
if (!tidSidsMap.containsKey(tid)) {
sidList = new LinkedList<>();
} else {
sidList = tidSidsMap.get(tid);
}
sidList.add(sd.getSubscriptionId());
tidSidsMap.put(tid, sidList);
}
}
SrvPriCreationStatusDialog d1 = SrvPriCreationStatusDialog.go(this.getShell(), tidSidsMap, destinationFolder);
if (d1 == null) {
System.out.println(">> Canceled by the user");
return;
}
String path = d1.getSelectedAuthFilePath();
if (path == null) {
System.out.println(">> No file was created");
return;
}
textAuthenticationFilePath.setText(path);
fileDialog.setFilterPath(destinationFolder);
} catch (Exception ex) {
ex.printStackTrace();
LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "doCreateServicePrincipal@SignInDialog", ex));
} finally {
if (adAuthManager != null) {
adAuthManager.signOut();
}
}
}
use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project cubrid-manager by CUBRID.
the class UnifyHostConfigEditor method registerCubridBrokerTableContextMenu.
/**
* register CubridConfTable context menu
*/
private void registerCubridBrokerTableContextMenu() {
brokerConfTabTableViewer.getTable().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(brokerConfTabTableViewer.getTable());
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
Menu contextMenu = menuManager.createContextMenu(brokerConfTabTableViewer.getTable());
brokerConfTabTableViewer.getTable().setMenu(contextMenu);
Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
final MenuItem itemEditAnnotation = new MenuItem(menu, SWT.PUSH);
itemEditAnnotation.setText(Messages.confEditorTableMenuEditAnnotation);
itemEditAnnotation.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("all")
public void widgetSelected(SelectionEvent event) {
//seems like MenuEvent can't get the mouse click Point
//so use the point which table MouseDown event marked
Point pt = cubridBrokerTableClickPoint;
int selectIndex = brokerConfTabTableViewer.getTable().getSelectionIndex();
final TableItem item = brokerConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < brokerConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
if (i == 0) {
CommonUITool.openErrorBox(getSite().getShell(), Messages.annotationDialogOpenErrorMsg);
return;
}
IStructuredSelection selection = (IStructuredSelection) brokerConfTabTableViewer.getSelection();
HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
String serverName = cubridBrokerConfListData.get(0).get(i + "");
String parentPropertyKey = valueMap.get("0");
String parentKey = " ";
Map<String, String> brokerMap = cubridBrokerConfListData.get(1);
String brokerName = "";
if (brokerMap != null) {
brokerName = brokerMap.get(i + "");
}
if (selectIndex == 0) {
parentKey += serverName;
} else {
if (selectIndex == 1) {
parentKey += serverName + "->" + brokerName;
} else {
parentKey += serverName + "->" + brokerName + "->" + parentPropertyKey;
}
}
String annotationKey = Integer.toString(i) + BrokerConfPersistUtil.ANNOTATION;
CubridBrokerConfEditAnnotationDialog dialog = new CubridBrokerConfEditAnnotationDialog(getSite().getShell(), parentKey, annotationKey, valueMap);
if (IDialogConstants.OK_ID == dialog.open()) {
setDirty(true);
}
}
}
}
});
final MenuItem itemAddBrokerConf = new MenuItem(menu, SWT.PUSH);
itemAddBrokerConf.setText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorAddBrokerConfItemLabel);
itemAddBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_insert.png"));
itemAddBrokerConf.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// int horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y -
// brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
// = brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
monitor.beginTask(Messages.unifyHostConfigEditorAddColumnMsg, 1);
addBrokerConfColumn();
monitor.worked(1);
// horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - horizontalSelectionInt;
// brokerConfTabTableViewer.getTable().getHorizontalBar().setSelection(horizontalSelectionInt + 160);
}
});
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
setDirty(true);
}
});
final MenuItem itemDeleteBrokerConf = new MenuItem(menu, SWT.PUSH);
itemDeleteBrokerConf.setText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeleteBrokerConfItemLabel);
itemDeleteBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_delete.png"));
itemDeleteBrokerConf.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
progress.setCancelable(true);
progress.run(true, true, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor) throws InvocationTargetException {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
// int horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y -
// brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
// = brokerConfTabTableViewer.getTable().getHorizontalBar().getSelection();
monitor.beginTask(Messages.unifyHostConfigEditorDelColumnMsg, 1);
delBrokerConfColumn();
monitor.worked(1);
// horizontalSelectionInt = brokerConfTabTableViewer.getTable().getHorizontalBar().getSize().y - horizontalSelectionInt;
// brokerConfTabTableViewer.getTable().getHorizontalBar().setSelection(horizontalSelectionInt + 160);
}
});
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
setDirty(true);
}
});
menu.addMenuListener(new MenuAdapter() {
public void menuShown(MenuEvent event) {
//seems like MenuEvent can't get the mouse click Point
//so use the point which table MouseDown event marked
Point pt = cubridBrokerTableClickPoint;
// click timing
if (System.currentTimeMillis() - cubridBrokerTableClickPointTiming > 300) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
itemAddBrokerConf.setEnabled(false);
return;
}
int selectIndex = brokerConfTabTableViewer.getTable().getSelectionIndex();
if (selectIndex == -1) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
itemAddBrokerConf.setEnabled(false);
return;
}
if (selectIndex == 0) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
itemAddBrokerConf.setEnabled(true);
return;
}
final TableItem item = brokerConfTabTableViewer.getTable().getItem(selectIndex);
if (item == null) {
return;
}
for (int i = 0; i < brokerConfTabTableViewer.getTable().getColumnCount(); i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
if (i == 0) {
itemEditAnnotation.setEnabled(false);
itemDeleteBrokerConf.setEnabled(false);
} else {
itemEditAnnotation.setEnabled(true);
itemDeleteBrokerConf.setEnabled(true);
}
}
}
itemAddBrokerConf.setEnabled(true);
}
});
brokerConfTabTableViewer.getTable().setMenu(menu);
}
Aggregations