Java Code Examples for javafx.scene.control.ButtonType#equals()

The following examples show how to use javafx.scene.control.ButtonType#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpcUaBrowserController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteDataSource() {
	try {
		// delete
		OpcUaSource source = getSource();

		if (source != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", source.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}

			PersistenceService.instance().delete(source);
			servers.remove(getSource().getName());
			cbDataSources.setItems(servers);

			onNewDataSource();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 2
Source File: OpcDaBrowserController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteDataSource() {
	try {
		// delete
		OpcDaSource source = getSource();
		if (source != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", source.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}
			
			PersistenceService.instance().delete(source);
			progIds.remove(getSource().getProgId());

			onNewDataSource();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 3
Source File: DashboardController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteEvent() {
	try {
		OeeEvent event = tvResolvedEvents.getSelectionModel().getSelectedItem();

		if (event == null) {
			throw new Exception(DesignerLocalizer.instance().getErrorString("no.event"));
		}

		// confirm
		String msg = DesignerLocalizer.instance().getLangString("confirm.deletion", event.getEquipment().getName());
		ButtonType type = AppUtils.showConfirmationDialog(msg);

		if (type.equals(ButtonType.CANCEL)) {
			return;
		}

		PersistenceService.instance().delete(event);

		onRefresh();
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 4
Source File: HttpServerController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteDataSource() {
	try {
		// delete
		if (dataSource != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", dataSource.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}
			
			PersistenceService.instance().delete(dataSource);
			servers.remove(dataSource);

			onNewDataSource();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 5
Source File: DatabaseServerController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteDataSource() {
	try {
		// delete
		if (dataSource != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", dataSource.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}
			
			PersistenceService.instance().delete(dataSource);
			databaseServers.remove(dataSource);

			onNewDataSource();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 6
Source File: ModbusMasterController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteDataSource() {
	try {
		// delete
		ModbusSource source = getSource();

		if (source != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", source.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}
			
			PersistenceService.instance().delete(source);
			dataSources.remove(source);
			cbDataSources.setItems(dataSources);

			onNewDataSource();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 7
Source File: CronEditorController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteDataSource() {
	try {
		// delete
		if (dataSource != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", dataSource.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}

			PersistenceService.instance().delete(dataSource);
			cronSources.remove(dataSource);

			onNewDataSource();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 8
Source File: FileShareController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteDataSource() {
	try {
		// delete
		if (dataSource != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", dataSource.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}
			
			PersistenceService.instance().delete(dataSource);
			fileServers.remove(dataSource);

			onNewDataSource();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 9
Source File: MqBrokerController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteDataSource() {
	try {
		// delete
		if (dataSource != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", dataSource.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}
			
			PersistenceService.instance().delete(dataSource);
			brokers.remove(dataSource);

			 clearEditor();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 10
Source File: DataCollectorController.java    From OEE-Designer with MIT License 6 votes vote down vote up
@FXML
private void onDeleteCollector() {
	try {
		// delete
		DataCollector definition = getCollector();

		if (definition != null) {
			// confirm
			ButtonType type = AppUtils.showConfirmationDialog(
					DesignerLocalizer.instance().getLangString("object.delete", definition.toString()));

			if (type.equals(ButtonType.CANCEL)) {
				return;
			}
			
			PersistenceService.instance().delete(definition);
			collectors.remove(definition.getName());

			onNewCollector();
		}
	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 11
Source File: UomEditorController.java    From OEE-Designer with MIT License 5 votes vote down vote up
@FXML
private void onDeleteUom() {
	if (selectedUomItem == null || !selectedUomItem.getValue().isUnitOfMeasure()) {
		AppUtils.showErrorDialog(DesignerLocalizer.instance().getErrorString("unit.cannot.be.null"));
		return;
	}

	// confirm
	ButtonType type = AppUtils.showConfirmationDialog(
			DesignerLocalizer.instance().getLangString("uom.delete", getSelectedUom().getDisplayString()));

	if (type.equals(ButtonType.CANCEL)) {
		return;
	}

	try {
		// delete
		UnitOfMeasure toDelete = getSelectedUom();

		PersistenceService.instance().delete(toDelete);

		// remove this UOM from the tree
		TreeItem<UomNode> childNode = tvUoms.getSelectionModel().getSelectedItem();
		TreeItem<UomNode> parentNode = childNode.getParent();

		parentNode.getChildren().remove(childNode);
		tvUoms.refresh();
		parentNode.setExpanded(true);

		// update category list
		populateCategories();

		// clear editor
		onNewUom();

	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 12
Source File: MaterialEditorController.java    From OEE-Designer with MIT License 5 votes vote down vote up
@FXML
private void onDeleteMaterial() throws Exception {
	if (selectedMaterialItem == null || !selectedMaterialItem.getValue().isMaterial()) {
		AppUtils.showErrorDialog(DesignerLocalizer.instance().getErrorString("material.deletion"));
		return;
	}

	// confirm
	ButtonType type = AppUtils.showConfirmationDialog(
			DesignerLocalizer.instance().getLangString("delete.material", getSelectedMaterial().getName()));

	if (type.equals(ButtonType.CANCEL)) {
		return;
	}

	try {
		// delete
		Material toDelete = getSelectedMaterial();
		PersistenceService.instance().delete(toDelete);

		// remove this material from the tree
		TreeItem<MaterialNode> childNode = tvMaterials.getSelectionModel().getSelectedItem();
		TreeItem<MaterialNode> parentNode = childNode.getParent();

		parentNode.getChildren().remove(childNode);
		tvMaterials.refresh();
		parentNode.setExpanded(true);

		// update category list
		populateCategories();

		// clear editor
		onNewMaterial();

	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 13
Source File: Libimobiledevice.java    From blobsaver with GNU General Public License v3.0 4 votes vote down vote up
public static void throwIfNeeded(int errorCode, boolean showAlert, ErrorCodeType errorType) {
    if (errorCode == 0) {
        return;
    }
    if (errorType == null) {
        throw new IllegalArgumentException("errorType cannot be null");
    }

    String exceptionMessage = "";
    String alertMessage = "";
    boolean reportableError = false;
    if (errorType.equals(ErrorCodeType.idevice_error_t)) {
        if (errorCode == -3) { // IDEVICE_E_NO_DEVICE
            exceptionMessage = "idevice error: no device found/connected (IDEVICE_E_NO_DEVICE)";
            alertMessage = "Error: No devices found/connected. Make sure your device is connected via USB and unlocked.";
            if (PlatformUtil.isWindows()) {
                alertMessage = alertMessage + "\n\nEnsure iTunes or Apple's iOS Drivers are installed.";
            }
            if (showAlert) {
                ButtonType downloadItunes = new ButtonType("Download iTunes");
                Alert alert = new Alert(Alert.AlertType.ERROR, alertMessage, downloadItunes, ButtonType.OK);
                if (downloadItunes.equals(alert.showAndWait().orElse(null))) {
                    openURL("https://www.apple.com/itunes/download/win64");
                }
                showAlert = false;
            }
        } else {
            exceptionMessage = "idevice error: code=" + errorCode;
            alertMessage = exceptionMessage;
            reportableError = true;
        }
    } else if (errorType.equals(ErrorCodeType.lockdownd_error_t)) {
        switch (errorCode) {
            case -17:  // LOCKDOWN_E_PASSWORD_PROTECTED
                exceptionMessage = "lockdownd error: LOCKDOWN_E_PASSWORD_PROTECTED (-17)";
                alertMessage = "Error: The device is locked.\n\nPlease unlock your device and go to the homescreen then try again.";
                break;
            case -18:  // LOCKDOWN_E_USER_DENIED_PAIRING
                exceptionMessage = "lockdownd error: LOCKDOWN_E_USER_DENIED_PAIRING (-18)";
                alertMessage = "Error: The user denied the trust/pair request on the device. Please unplug your device and accept the dialog next time.";
                break;
            case -19:  // LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING
                exceptionMessage = "lockdownd error: LOCKDOWN_E_PAIRING_DIALOG_RESPONSE_PENDING (-19)";
                alertMessage = "Error: Please accept the trust/pair dialog on the device and try again.";
                break;
            case -8:  // LOCKDOWN_E_MUX_ERROR
                exceptionMessage = "lockdownd error: LOCKDOWN_E_MUX_ERROR (-8)";
                alertMessage = exceptionMessage;
                reportableError = true;
                break;
            default:
                exceptionMessage = "lockdownd error: code=" + errorCode;
                alertMessage = exceptionMessage;
                reportableError = true;
                break;
        }
    } else if (errorType.equals(ErrorCodeType.irecv_error_t)) {
        exceptionMessage = "irecovery error: code=" + errorCode;
        alertMessage = exceptionMessage + "\n\nIf your device is still in recovery mode, use the \"Exit Recovery Mode\" option from the help menu.";
        reportableError = true;
    }
    if (showAlert) {
        // temporary final variables are required because of the lambda
        final boolean finalReportableError = reportableError;
        final String finalAlertMessage = alertMessage;
        runSafe(() -> {
            if (finalReportableError) {
                newReportableError(finalAlertMessage);
            } else {
                newUnreportableError(finalAlertMessage);
            }
        });
    }
    throw new LibimobiledeviceException(exceptionMessage);
}
 
Example 14
Source File: ReasonEditorController.java    From OEE-Designer with MIT License 4 votes vote down vote up
@FXML
private void onDeleteReason() {
	Reason selectedReason = getSelectedReason();
	if (selectedReason == null) {
		AppUtils.showErrorDialog(DesignerLocalizer.instance().getErrorString("no.reason.selected"));
		return;
	}

	// confirm
	ButtonType type = AppUtils.showConfirmationDialog(
			DesignerLocalizer.instance().getLangString("delete.reason", selectedReason.getName()));

	if (type.equals(ButtonType.CANCEL)) {
		return;
	}

	try {
		Reason parentReason = selectedReason.getParent();
		if (parentReason != null) {
			// remove from parent with orphan removal
			parentReason.removeChild(selectedReason);
			PersistenceService.instance().save(parentReason);
		} else {
			// cascade delete
			PersistenceService.instance().delete(selectedReason);
		}

		// remove this reason from the tree
		TreeItem<ReasonNode> selectedReasonItem = tvReasons.getSelectionModel().getSelectedItem();
		TreeItem<ReasonNode> parentNode = selectedReasonItem.getParent();
		parentNode.getChildren().remove(selectedReasonItem);

		// clear fields
		onNewReason();
		tvReasons.getSelectionModel().clearSelection();

		tvReasons.refresh();
		parentNode.setExpanded(true);

	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}
 
Example 15
Source File: PhysicalModelController.java    From OEE-Designer with MIT License 4 votes vote down vote up
@FXML
private void onDeleteEntity() {
	PlantEntity selectedEntity = getSelectedEntity();

	if (selectedEntity == null) {
		AppUtils.showErrorDialog(DesignerLocalizer.instance().getErrorString("no.entity"));
		return;
	}

	// confirm
	ButtonType type = AppUtils.showConfirmationDialog(
			DesignerLocalizer.instance().getLangString("confirm.delete", selectedEntity.getName()));

	if (type.equals(ButtonType.CANCEL)) {
		return;
	}

	try {
		// delete from db if previously saved
		PlantEntity parentEntity = selectedEntity.getParent();
		if (parentEntity != null) {
			// remove from parent with orphan removal
			parentEntity.removeChild(selectedEntity);
			PersistenceService.instance().save(parentEntity);
		} else {
			// cascade delete
			PersistenceService.instance().delete(selectedEntity);
		}

		// remove this entity from the tree
		TreeItem<EntityNode> selectedEntityItem = tvEntities.getSelectionModel().getSelectedItem();
		TreeItem<EntityNode> parentNode = selectedEntityItem.getParent();
		parentNode.getChildren().remove(selectedEntityItem);
		tvEntities.getSelectionModel().clearSelection();

		tvEntities.refresh();
		parentNode.setExpanded(true);

		onNewEntity();

	} catch (Exception e) {
		AppUtils.showErrorDialog(e);
	}
}